1212// / \file femtoDreamProducer.cxx
1313// / \brief Tasks that produces the track tables used for the pairing
1414// / \author Ravindra Singh, GSI, ravindra.singh@cern.ch
15+ // / \author Biao Zhang, Heidelberg University, biao.zhang@cern.ch
1516
1617#include < string>
1718#include < vector>
3940#include " PWGHF/DataModel/CandidateReconstructionTables.h"
4041#include " PWGHF/DataModel/CandidateSelectionTables.h"
4142#include " PWGHF/Utils/utilsBfieldCCDB.h"
43+ #include " PWGHF/Utils/utilsEvSelHf.h"
44+ #include " PWGHF/Core/CentralityEstimation.h"
4245
4346using namespace o2 ;
4447using namespace o2 ::framework;
4548using namespace o2 ::framework::expressions;
4649using namespace o2 ::analysis::femtoDream;
50+ using namespace o2 ::hf_evsel;
51+ using namespace o2 ::hf_centrality;
52+
53+ // event types
54+ enum Event : uint8_t {
55+ kAll = 0 ,
56+ kRejEveSel ,
57+ kRejNoTracksAndCharm ,
58+ kTrackSelected ,
59+ kCharmSelected ,
60+ kPairSelected
61+ };
4762
4863struct HfFemtoDreamProducer {
4964
@@ -69,19 +84,6 @@ struct HfFemtoDreamProducer {
6984
7085 // Configurable<bool> isForceGRP{"isForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"};
7186
72- // / Event selection
73- // Configurable<float> evtZvtx{"evtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"};
74- // Configurable<bool> evtTriggerCheck{"evtTriggerCheck", true, "Evt sel: check for trigger"};
75- // Configurable<int> evtTriggerSel{"evtTriggerSel", kINT7, "Evt sel: trigger"};
76- // Configurable<bool> evtOfflineCheck{"evtOfflineCheck", false, "Evt sel: check for offline selection"};
77- // Configurable<bool> evtAddOfflineCheck{"evtAddOfflineCheck", false, "Evt sel: additional checks for offline selection (not part of sel8 yet)"};
78-
79- Configurable<bool > evtAddOfflineCheck{" evtAddOfflineCheck" , false , " Evt sel: additional checks for offline selection (not part of sel8 yet)" };
80- Configurable<bool > evtOfflineCheck{" evtOfflineCheck" , false , " Evt sel: check for offline selection" };
81- Configurable<bool > evtTriggerCheck{" evtTriggerCheck" , true , " Evt sel: check for trigger" };
82- Configurable<int > evtTriggerSel{" evtTriggerSel" , kINT7 , " Evt sel: trigger" };
83- Configurable<float > evtZvtx{" evtZvtx" , 10 .f , " Evt sel: Max. z-Vertex (cm)" };
84-
8587 Configurable<bool > isDebug{" isDebug" , true , " Enable Debug tables" };
8688 Configurable<bool > isRun3{" isRun3" , true , " Running on Run3 or pilot" };
8789
@@ -121,7 +123,6 @@ struct HfFemtoDreamProducer {
121123
122124 using GeneratedMc = soa::Filtered<soa::Join<aod::McParticles, aod::HfCand3ProngMcGen>>;
123125
124- FemtoDreamCollisionSelection colCuts;
125126 FemtoDreamTrackSelection trackCuts;
126127
127128 Filter filterSelectCandidateLc = (aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc);
@@ -130,6 +131,7 @@ struct HfFemtoDreamProducer {
130131 HistogramRegistry TrackRegistry{" Tracks" , {}, OutputObjHandlingPolicy::AnalysisObject};
131132
132133 HfHelper hfHelper;
134+ o2::hf_evsel::HfEventSelection hfEvSel;
133135
134136 float magField;
135137 int runNumber;
@@ -148,8 +150,21 @@ struct HfFemtoDreamProducer {
148150 int CutBits = 8 * sizeof (o2::aod::femtodreamparticle::cutContainerType);
149151 TrackRegistry.add (" AnalysisQA/CutCounter" , " ; Bit; Counter" , kTH1F , {{CutBits + 1 , -0.5 , CutBits + 0.5 }});
150152
151- colCuts.setCuts (evtZvtx.value , evtTriggerCheck.value , evtTriggerSel.value , evtOfflineCheck.value , evtAddOfflineCheck.value , isRun3.value );
152- colCuts.init (&qaRegistry);
153+ // event QA histograms
154+ constexpr int kEventTypes = kPairSelected + 1 ;
155+ std::string labels[kEventTypes ];
156+ labels[Event::kAll ] = " All events" ;
157+ labels[Event::kRejEveSel ] = " rejected by event selection" ;
158+ labels[Event::kRejNoTracksAndCharm ] = " rejected by no tracks and charm" ;
159+ labels[Event::kTrackSelected ] = " with tracks " ;
160+ labels[Event::kCharmSelected ] = " with charm hadrons " ;
161+ labels[Event::kPairSelected ] = " with pairs" ;
162+
163+ static const AxisSpec axisEvents = {kEventTypes , 0.5 , kEventTypes + 0.5 , " " };
164+ qaRegistry.add (" hEventQA" , " Events;;entries" , HistType::kTH1F , {axisEvents});
165+ for (int iBin = 0 ; iBin < kEventTypes ; iBin++) {
166+ qaRegistry.get <TH1>(HIST (" hEventQA" ))->GetXaxis ()->SetBinLabel (iBin + 1 , labels[iBin].data ());
167+ }
153168
154169 trackCuts.setSelection (trkCharge, femtoDreamTrackSelection::kSign , femtoDreamSelection::kEqual );
155170 trackCuts.setSelection (trkPtmin, femtoDreamTrackSelection::kpTMin, femtoDreamSelection::kLowerLimit );
@@ -175,6 +190,8 @@ struct HfFemtoDreamProducer {
175190 ccdb->setCaching (true );
176191 ccdb->setLocalObjectValidityChecking ();
177192
193+ hfEvSel.addHistograms (qaRegistry); // collision monitoring
194+
178195 int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
179196 ccdb->setCreatedNotAfter (now);
180197 }
@@ -335,8 +352,7 @@ struct HfFemtoDreamProducer {
335352 {
336353 const auto vtxZ = col.posZ ();
337354 const auto sizeCand = candidates.size ();
338-
339- const auto spher = colCuts.computeSphericity (col, tracks);
355+ const auto spher = 2 .; // dummy value for the moment
340356 float mult = 0 ;
341357 int multNtr = 0 ;
342358 if (isRun3) {
@@ -351,15 +367,20 @@ struct HfFemtoDreamProducer {
351367 multNtr = col.multTracklets ();
352368 }
353369
354- colCuts.fillQA (col, mult);
370+ const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask <true , CentralityEstimator::None, aod::BCsWithTimestamps>(col, mult, ccdb, qaRegistry);
371+
372+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kAll );
355373
356- // check whether the basic event selection criteria are fulfilled
357- // that included checking if there is at least on usable track or V0
358- if (!colCuts.isSelectedCollision (col)) {
374+ // / monitor the satisfied event selections
375+ hfEvSel.fillHistograms (col, rejectionMask, mult);
376+ if (rejectionMask != 0 ) {
377+ // / at least one event selection not satisfied --> reject the candidate
378+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kRejEveSel );
359379 return ;
360380 }
361381
362- if (colCuts.isEmptyCollision (col, tracks, trackCuts)) {
382+ if (isNoSelectedTracks (col, tracks, trackCuts) && sizeCand <= 0 ) {
383+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kRejNoTracksAndCharm );
363384 return ;
364385 }
365386
@@ -437,18 +458,39 @@ struct HfFemtoDreamProducer {
437458 aod::femtodreamcollision::BitMaskType bitTrack = 0 ;
438459 if (isTrackFilled) {
439460 bitTrack |= 1 << 0 ;
461+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kTrackSelected );
440462 }
441463
442464 aod::femtodreamcollision::BitMaskType bitCand = 0 ;
443465 if (sizeCand > 0 ) {
444466 bitCand |= 1 << 0 ;
467+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kCharmSelected );
445468 }
446469
470+ if (isTrackFilled && (sizeCand > 0 ))
471+ qaRegistry.fill (HIST (" hEventQA" ), 1 + Event::kPairSelected );
472+
447473 rowMasks (static_cast <aod::femtodreamcollision::BitMaskType>(bitTrack),
448474 static_cast <aod::femtodreamcollision::BitMaskType>(bitCand),
449475 0 );
450476 }
451477
478+ // check if there is no selected track
479+ // / \param C type of the collision
480+ // / \param T type of the tracks
481+ // / \param TC type of the femto track cuts
482+ // / \return whether or not the tracks fulfills the all selections
483+ template <typename C, typename T, typename TC>
484+ bool isNoSelectedTracks (C const & /* col*/ , T const & tracks, TC& trackCuts)
485+ {
486+ for (auto const & track : tracks) {
487+ if (trackCuts.isSelectedMinimal (track)) {
488+ return false ;
489+ }
490+ }
491+ return true ;
492+ }
493+
452494 template <typename ParticleType>
453495 void fillCharmHadMcGen (ParticleType particles)
454496 {
0 commit comments