99// granted to it by virtue of its status as an Intergovernmental Organization
1010// or submit itself to any jurisdiction.
1111//
12+ #include < fairlogger/Logger.h>
13+ #include < cstdint>
1214#include < iostream>
1315#include < fstream>
1416#include " Framework/AnalysisTask.h"
@@ -33,12 +35,7 @@ using namespace o2::aod;
3335
3436using MyEvents = soa::Join<aod::Collisions, aod::EvSels>;
3537using MyBCs = soa::Join<aod::BCsWithTimestamps, aod::BcSels, aod::Run3MatchedToBCSparse>;
36- using MyBarrelTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection,
37- aod::pidTPCFullEl, aod::pidTPCFullPi,
38- aod::pidTPCFullKa, aod::pidTPCFullPr,
39- aod::pidTOFFullEl, aod::pidTOFFullPi,
40- aod::pidTOFFullKa, aod::pidTOFFullPr>;
41-
38+ using MyBarrelTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TrackSelection>;
4239using MyMuons = aod::FwdTracks;
4340
4441constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision;
@@ -48,9 +45,10 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses);
4845struct DQFilterPbPbTask {
4946 Produces<aod::DQEventFilter> eventFilter;
5047 OutputObj<TH1I> fStats {" Statistics" };
51- OutputObj<TH1F> fIsEventDGOutcome {TH1F (" Filter outcome" , " Filter outcome" , 7 , -0 .5 , 6.5 )};
48+ OutputObj<TH1F> fIsEventDGOutcome {TH1F (" Filter outcome" , " Filter outcome" , 8 , -1 .5 , 6.5 )};
5249
5350 Configurable<std::string> fConfigBarrelSelections {" cfgBarrelSels" , " jpsiPID1:2:5" , " <track-cut>:<nmin>:<nmax>,[<track-cut>:<nmin>:<nmax>],..." };
51+ Configurable<std::string> fConfigEventTypes {" cfgEventTypes" , " doublegap,singlegap" , " Which event types to select. doublegap, singlegap or both, comma separated" };
5452 Configurable<int > fConfigNDtColl {" cfgNDtColl" , 4 , " Number of standard deviations to consider in BC range" };
5553 Configurable<int > fConfigMinNBCs {" cfgMinNBCs" , 7 , " Minimum number of BCs to consider in BC range" };
5654 Configurable<int > fConfigMinNPVCs {" cfgMinNPVCs" , 2 , " Minimum number of PV contributors" };
@@ -73,17 +71,21 @@ struct DQFilterPbPbTask {
7371 std::vector<int > fBarrelNminTracks ; // minimal number of tracks in barrel
7472 std::vector<int > fBarrelNmaxTracks ; // maximal number of tracks in barrel
7573
74+ int eventTypeMap = 0 ;
75+ std::vector<std::string> eventTypeOptions = {" doublegap" , " singlegap" }; // Map for which types of event to select
76+
7677 // Helper function for selecting DG events
7778 template <typename TEvent, typename TBCs, typename TTracks, typename TMuons>
7879 uint64_t isEventDG (TEvent const & collision, TBCs const & bcs, TTracks const & tracks, TMuons const & muons,
7980 aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds,
80- std::vector<float > FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime,
81+ int eventTypes, std::vector<float > FITAmpLimits, int nDtColl, int minNBCs, int minNPVCs, int maxNPVCs, float maxFITTime,
8182 bool useFV0, bool useFT0, bool useFDD, bool doVetoFwd, bool doVetoBarrel)
8283 {
8384 fIsEventDGOutcome ->Fill (0 ., 1 .);
8485 // Find BC associated with collision
8586 if (!collision.has_foundBC ()) {
86- return -1 ;
87+ fIsEventDGOutcome ->Fill (-1 ., 1 );
88+ return 0 ;
8789 }
8890 // foundBCId is stored in EvSels
8991 auto bc = collision.template foundBC_as <TBCs>();
@@ -207,12 +209,17 @@ struct DQFilterPbPbTask {
207209
208210 // Compute FIT decision
209211 uint64_t FITDecision = 0 ;
210- if (isSideAClean && isSideCClean) {
211- FITDecision |= (uint64_t (1 ) << VarManager::kDoubleGap );
212- } else if (isSideAClean && !isSideCClean) {
213- FITDecision |= (uint64_t (1 ) << VarManager::kSingleGapA );
214- } else if (!isSideAClean && isSideCClean) {
215- FITDecision |= (uint64_t (1 ) << VarManager::kSingleGapC );
212+ if (eventTypes & (uint32_t (1 ) << 0 )) {
213+ if (isSideAClean && isSideCClean) {
214+ FITDecision |= (uint64_t (1 ) << VarManager::kDoubleGap );
215+ }
216+ }
217+ if (eventTypes & (uint32_t (1 ) << 1 )) {
218+ if (isSideAClean && !isSideCClean) {
219+ FITDecision |= (uint64_t (1 ) << VarManager::kSingleGapA );
220+ } else if (!isSideAClean && isSideCClean) {
221+ FITDecision |= (uint64_t (1 ) << VarManager::kSingleGapC );
222+ }
216223 }
217224 if (!FITDecision) {
218225 fIsEventDGOutcome ->Fill (2 , 1 );
@@ -289,6 +296,17 @@ struct DQFilterPbPbTask {
289296 void init (o2::framework::InitContext&)
290297 {
291298 DefineCuts ();
299+
300+ TString eventTypesString = fConfigEventTypes .value ;
301+ for (std::vector<std::string>::size_type i = 0 ; i < eventTypeOptions.size (); i++) {
302+ if (eventTypesString.Contains (eventTypeOptions[i])) {
303+ eventTypeMap |= (uint32_t (1 ) << i);
304+ LOGF (info, " filterPbPb will select '%s' events" , eventTypeOptions[i]);
305+ }
306+ }
307+ if (eventTypeMap == 0 ) {
308+ LOGF (fatal, " No valid choice of event types to select. Use 'doublegap', 'singlegap' or both" );
309+ }
292310 }
293311
294312 template <uint32_t TEventFillMap>
@@ -299,7 +317,7 @@ struct DQFilterPbPbTask {
299317
300318 std::vector<float > FITAmpLimits = {fConfigFV0AmpLimit , fConfigFT0AAmpLimit , fConfigFT0CAmpLimit , fConfigFDDAAmpLimit , fConfigFDDCAmpLimit };
301319 uint64_t filter = isEventDG (collision, bcs, tracks, muons, ft0s, fv0as, fdds,
302- FITAmpLimits, fConfigNDtColl , fConfigMinNBCs , fConfigMinNPVCs , fConfigMaxNPVCs , fConfigMaxFITTime ,
320+ eventTypeMap, FITAmpLimits, fConfigNDtColl , fConfigMinNBCs , fConfigMinNPVCs , fConfigMaxNPVCs , fConfigMaxFITTime ,
303321 fConfigUseFV0 , fConfigUseFT0 , fConfigUseFDD , fConfigVetoForward , fConfigVetoBarrel );
304322
305323 bool isSelected = filter;
0 commit comments