@@ -89,7 +89,8 @@ struct EnergyFlowGfw {
8989 TriggerSelected,
9090 CentralitySelected,
9191 HasValidZdc,
92- SpectatorSelected
92+ SpectatorSelected,
93+ SelectedWithoutZdc
9394 };
9495
9596 enum ZdcQaStep : uint8_t {
@@ -136,7 +137,7 @@ struct EnergyFlowGfw {
136137 Configurable<float > cfgMaxCentrality{" cfgMaxCentrality" , 100 .f , " Maximum accepted centrality percentile" };
137138 Configurable<bool > cfgFillEfficiency{" fillEfficiency" , false , " Fill MC tracking efficiency; ignored by data processes" };
138139 Configurable<bool > cfgFillAcceptance{" fillAcceptance" , false , " Fill GFW acceptance weights instead of running the reconstructed analysis" };
139- Configurable<bool > cfgUseRun2EventSelectionWithoutZdc{" cfgUseRun2EventSelectionWithoutZdc" , false , " For Run 2 data, require kINT7 and every CCDB-enabled barrel sel7 criterion except the ZDC beam-beam criteria; retain the ZDC beam-gas vetoes " };
140+ Configurable<bool > cfgUseRun2EventSelectionWithoutZdc{" cfgUseRun2EventSelectionWithoutZdc" , false , " For Run 2 data, omit the ZDC beam-beam sel7 criteria even when the activity axis requires ZDC " };
140141
141142 Configurable<float > cfgSpectatorEnergyPerNucleon{" cfgSpectatorEnergyPerNucleon" , 1 .f , " ZDC energy corresponding to one spectator nucleon" };
142143 Configurable<float > cfgMaxTotalSpectators{" cfgMaxTotalSpectators" , 500 .f , " Maximum accepted spectator count from ZNA+ZNC+ZPA+ZPC" };
@@ -189,6 +190,7 @@ struct EnergyFlowGfw {
189190 Preslice<TracksMC> tracksPerCollision = aod::track::collisionId;
190191
191192 OutputObj<FlowContainer> flowContainer{" FlowContainer" };
193+ OutputObj<FlowContainer> flowContainerGen{" FlowContainer_gen" };
192194 OutputObj<GFWWeights> acceptanceWeights{GFWWeights (" weights" )};
193195 HistogramRegistry registry{" registry" };
194196 Service<o2::ccdb::BasicCCDBManager> ccdb{};
@@ -281,7 +283,6 @@ struct EnergyFlowGfw {
281283 corrConfigs.push_back (std::move (config));
282284 }
283285 gfw->CreateRegions ();
284- flowContainer.setObject (new FlowContainer (" FlowContainer" ));
285286 const AxisSpec activityAxis = [this ]() {
286287 if (cfgActivityAxis.value == NchAxis) {
287288 return AxisSpec{axisNGlobalTracks, " N_{global tracks}" };
@@ -291,10 +292,20 @@ struct EnergyFlowGfw {
291292 }
292293 return AxisSpec{axisCentrality, " centrality (%)" };
293294 }();
294- if (activityAxis.nBins .has_value ()) {
295- flowContainer->Initialize (profileNames.get (), activityAxis.nBins .value (), activityAxis.binEdges .front (), activityAxis.binEdges .back (), cfgBootstrapSamples);
296- } else {
297- flowContainer->Initialize (profileNames.get (), activityAxis, cfgBootstrapSamples);
295+ const auto initializeFlowContainer = [&](auto & output, const char * name) {
296+ output.setObject (new FlowContainer (name));
297+ if (activityAxis.nBins .has_value ()) {
298+ output->Initialize (profileNames.get (), activityAxis.nBins .value (), activityAxis.binEdges .front (), activityAxis.binEdges .back (), cfgBootstrapSamples);
299+ } else {
300+ output->Initialize (profileNames.get (), activityAxis, cfgBootstrapSamples);
301+ }
302+ };
303+ initializeFlowContainer (flowContainer, " FlowContainer" );
304+ if (doprocessRun2MC || doprocessRun3MC) {
305+ initializeFlowContainer (flowContainerGen, " FlowContainer_gen" );
306+ if (cfgActivityAxis.value == ZdcSpectatorAxis) {
307+ LOGF (warning, " The generated-level FlowContainer cannot be filled with the ZDC spectator activity axis because no generator-level spectator estimator is implemented" );
308+ }
298309 }
299310 if (cfgFillAcceptance) {
300311 acceptanceWeights->init (true , false );
@@ -304,12 +315,21 @@ struct EnergyFlowGfw {
304315 registry.add (" event/centrality" , " Accepted events;centrality;events" , HistType::kTH1F , {axisCentrality});
305316 registry.add (" event/activity" , " Accepted events;event activity;events" , HistType::kTH1F , {activityAxis});
306317 registry.add (" event/vertex" , " Accepted events;z-vtx (cm);events" , HistType::kTH1F , {axisVertex});
307- registry.add (" event/aodSelection" , " AOD event selection;selection;events" , HistType::kTH1F , {{5 , -0.5 , 4 .5 }});
318+ registry.add (" event/aodSelection" , " AOD event selection;selection;events" , HistType::kTH1F , {{6 , -0.5 , 5 .5 }});
308319 registry.add (" event/totalSpectators" , " ZDC spectator estimate;N_{spectators};events" , HistType::kTH1F , {axisTotalSpectators});
309320 registry.add (" track/ptEta" , " Selected tracks;p_{T} (GeV/c);#eta" , HistType::kTH2F , {axisPt, etaAxis});
310321 registry.add (" track/energy" , " Energy entering the GFW;E_{T} (GeV);tracks" , HistType::kTH1F , {axisEnergy});
311322 registry.add (" track/pid" , " PID mass assignment;species;tracks" , HistType::kTH1F , {{4 , -0.5 , 3.5 }});
312323
324+ if (doprocessRun2MC || doprocessRun3MC) {
325+ registry.add (" generated/event/centrality" , " Generated-level accepted events;reconstructed centrality;events" , HistType::kTH1F , {axisCentrality});
326+ registry.add (" generated/event/activity" , " Generated-level accepted events;event activity;events" , HistType::kTH1F , {activityAxis});
327+ registry.add (" generated/event/vertex" , " Generated-level accepted events;generated z-vtx (cm);events" , HistType::kTH1F , {axisVertex});
328+ registry.add (" generated/particle/ptEta" , " Selected physical-primary charged particles;p_{T} (GeV/c);#eta" , HistType::kTH2F , {axisPt, etaAxis});
329+ registry.add (" generated/particle/energy" , " Generated energy entering the GFW;E_{T} (GeV);particles" , HistType::kTH1F , {axisEnergy});
330+ registry.add (" generated/particle/pid" , " Generated particle species;species;particles" , HistType::kTH1F , {{4 , -0.5 , 3.5 }});
331+ }
332+
313333 if (cfgFillEfficiency && (doprocessRun2MC || doprocessRun3MC)) {
314334 const AxisSpec efficiencySpeciesAxis{EfficiencySpeciesCount, -0.5 , static_cast <float >(EfficiencySpeciesCount) - 0.5 , " particle" };
315335 const AxisSpec efficiencyStepAxis{EfficiencyStepCount, -0.5 , static_cast <float >(EfficiencyStepCount) - 0.5 , " generated/reconstructed" };
@@ -374,6 +394,7 @@ struct EnergyFlowGfw {
374394 selectionHistogram->GetXaxis ()->SetBinLabel (CentralitySelected + 1 , " centrality threshold" );
375395 selectionHistogram->GetXaxis ()->SetBinLabel (HasValidZdc + 1 , " valid ZDC" );
376396 selectionHistogram->GetXaxis ()->SetBinLabel (SpectatorSelected + 1 , " spectator threshold" );
397+ selectionHistogram->GetXaxis ()->SetBinLabel (SelectedWithoutZdc + 1 , " selection (no ZDC)" );
377398 auto zdcQaHistogram = registry.get <TH1 >(HIST (" zdc/qaSelection" ));
378399 zdcQaHistogram->GetXaxis ()->SetBinLabel (MatchedZdc + 1 , " matched ZDC" );
379400 zdcQaHistogram->GetXaxis ()->SetBinLabel (FiniteCommonEnergy + 1 , " finite common energies" );
@@ -386,6 +407,13 @@ struct EnergyFlowGfw {
386407 pidHistogram->GetXaxis ()->SetBinLabel (Pion + 1 , " pion" );
387408 pidHistogram->GetXaxis ()->SetBinLabel (Kaon + 1 , " kaon" );
388409 pidHistogram->GetXaxis ()->SetBinLabel (Proton + 1 , " proton" );
410+ if (doprocessRun2MC || doprocessRun3MC) {
411+ auto generatedPidHistogram = registry.get <TH1 >(HIST (" generated/particle/pid" ));
412+ generatedPidHistogram->GetXaxis ()->SetBinLabel (Unidentified + 1 , " other charged" );
413+ generatedPidHistogram->GetXaxis ()->SetBinLabel (Pion + 1 , " pion" );
414+ generatedPidHistogram->GetXaxis ()->SetBinLabel (Kaon + 1 , " kaon" );
415+ generatedPidHistogram->GetXaxis ()->SetBinLabel (Proton + 1 , " proton" );
416+ }
389417
390418 ccdb->setURL (" http://alice-ccdb.cern.ch" );
391419 ccdb->setCaching (true );
@@ -570,7 +598,7 @@ struct EnergyFlowGfw {
570598 }
571599
572600 template <typename TBCs, typename TCollision>
573- bool eventSelected (TCollision const & collision, bool triggerSelected, float numberOfGlobalTracks, float centrality, float & spectators)
601+ bool eventSelected (TCollision const & collision, bool triggerSelected, float numberOfGlobalTracks, float centrality, bool requireZdc, float & spectators)
574602 {
575603 spectators = -1 .f ;
576604 registry.fill (HIST (" event/aodSelection" ), AllAodEvents);
@@ -579,6 +607,15 @@ struct EnergyFlowGfw {
579607 }
580608 registry.fill (HIST (" event/aodSelection" ), TriggerSelected);
581609
610+ if (!requireZdc) {
611+ if (!std::isfinite (centrality) || centrality < 0 .f || centrality > cfgMaxCentrality) {
612+ return false ;
613+ }
614+ registry.fill (HIST (" event/aodSelection" ), CentralitySelected);
615+ registry.fill (HIST (" event/aodSelection" ), SelectedWithoutZdc);
616+ return true ;
617+ }
618+
582619 if (!collision.has_foundBC ()) {
583620 return false ;
584621 }
@@ -607,18 +644,26 @@ struct EnergyFlowGfw {
607644 return true ;
608645 }
609646
647+ bool activityRequiresZdc () const
648+ {
649+ return cfgActivityAxis.value == ZdcSpectatorAxis;
650+ }
651+
610652 static bool isZdcBeamBeamSelectionFlag (int flag)
611653 {
612654 return flag == aod::evsel::kIsBBZNA || flag == aod::evsel::kIsBBZNC || flag == aod::evsel::kIsBBZAC ;
613655 }
614656
615- template <typename TBCs, typename TCollision>
616- bool run2EventSelected (TCollision const & collision)
657+ template <bool IsMC, typename TBCs, typename TCollision>
658+ bool run2EventSelected (TCollision const & collision, bool requireZdc )
617659 {
660+ if constexpr (IsMC) {
661+ return collision.sel7 ();
662+ }
618663 if (!collision.alias_bit (kINT7 )) {
619664 return false ;
620665 }
621- if (!cfgUseRun2EventSelectionWithoutZdc) {
666+ if (requireZdc && !cfgUseRun2EventSelectionWithoutZdc. value ) {
622667 return collision.sel7 ();
623668 }
624669 if (!collision.has_foundBC ()) {
@@ -773,6 +818,39 @@ struct EnergyFlowGfw {
773818 return std::hypot (track.pt (), mass / std::cosh (track.eta ()));
774819 }
775820
821+ template <typename TParticle>
822+ int generatedParticleId (TParticle const & particle) const
823+ {
824+ const int absolutePdg = std::abs (particle.pdgCode ());
825+ if (absolutePdg == PDG_t::kPiPlus ) {
826+ return Pion;
827+ }
828+ if (absolutePdg == PDG_t::kKPlus ) {
829+ return Kaon;
830+ }
831+ if (absolutePdg == PDG_t::kProton ) {
832+ return Proton;
833+ }
834+ return Unidentified;
835+ }
836+
837+ template <typename TParticle>
838+ double generatedTransverseEnergy (TParticle const & particle) const
839+ {
840+ if (energy.weightMode .value == PtWeight) {
841+ return particle.pt ();
842+ }
843+ const auto * pdgParticle = pdgDB->GetParticle (particle.pdgCode ());
844+ if (!pdgParticle) {
845+ return -1 .;
846+ }
847+ const double mass = pdgParticle->Mass ();
848+ if (energy.weightMode .value == MtWeight) {
849+ return std::hypot (particle.pt (), mass);
850+ }
851+ return std::hypot (particle.pt (), mass / std::cosh (particle.eta ()));
852+ }
853+
776854 template <typename TParticle>
777855 bool isEfficiencyParticle (TParticle const & particle) const
778856 {
@@ -875,10 +953,11 @@ struct EnergyFlowGfw {
875953 registry.fill (HIST (" event/centrality" ), centrality);
876954 registry.fill (HIST (" event/activity" ), activity);
877955 registry.fill (HIST (" event/vertex" ), collision.posZ ());
878- fillFlowContainer (activity);
956+ fillFlowContainer (flowContainer, activity);
879957 }
880958
881- void fillFlowContainer (float activity)
959+ template <typename TFlowContainer>
960+ void fillFlowContainer (TFlowContainer& output, float activity)
882961 {
883962 const double randomNumber = random->Rndm ();
884963 for (std::size_t index = 0 ; index < corrConfigs.size (); ++index) {
@@ -887,7 +966,7 @@ struct EnergyFlowGfw {
887966 const double raw = gfw->Calculate (config, 0 , false ).real ();
888967 if (std::isfinite (raw) && raw > 0 .) {
889968 const std::string rawName = config.Head + " _raw" ;
890- flowContainer ->FillProfile (rawName.c_str (), activity, raw, 1 ., randomNumber);
969+ output ->FillProfile (rawName.c_str (), activity, raw, 1 ., randomNumber);
891970 }
892971 continue ;
893972 }
@@ -901,21 +980,57 @@ struct EnergyFlowGfw {
901980 continue ;
902981 }
903982 const std::string rawName = config.Head + " _raw" ;
904- flowContainer ->FillProfile (rawName.c_str (), activity, raw, 1 ., randomNumber);
905- flowContainer ->FillProfile (config.Head .c_str (), activity, raw / denominator, denominator, randomNumber);
983+ output ->FillProfile (rawName.c_str (), activity, raw, 1 ., randomNumber);
984+ output ->FillProfile (config.Head .c_str (), activity, raw / denominator, denominator, randomNumber);
906985 }
907986 }
908987
988+ template <typename TMcCollision, typename TParticles>
989+ void processGeneratedCollision (TMcCollision const & mcCollision, TParticles const & particles, float centrality)
990+ {
991+ if (std::abs (mcCollision.posZ ()) >= cuts.vertexZ .value || !std::isfinite (centrality) || centrality < 0 .f || centrality > cfgMaxCentrality.value || cfgActivityAxis.value == ZdcSpectatorAxis) {
992+ return ;
993+ }
994+
995+ gfw->Clear ();
996+ int numberOfSelectedParticles = 0 ;
997+ for (const auto & particle : particles) {
998+ if (!isEfficiencyParticle (particle)) {
999+ continue ;
1000+ }
1001+ const double et = generatedTransverseEnergy (particle);
1002+ if (!std::isfinite (et) || et <= 0 .) {
1003+ continue ;
1004+ }
1005+ const int pid = generatedParticleId (particle);
1006+ gfw->Fill (particle.eta (), 0 , particle.phi (), et, gfwMask);
1007+ ++numberOfSelectedParticles;
1008+ registry.fill (HIST (" generated/particle/ptEta" ), particle.pt (), particle.eta ());
1009+ registry.fill (HIST (" generated/particle/energy" ), et);
1010+ registry.fill (HIST (" generated/particle/pid" ), pid);
1011+ }
1012+
1013+ const float activity = cfgActivityAxis.value == NchAxis ? static_cast <float >(numberOfSelectedParticles) : centrality;
1014+ registry.fill (HIST (" generated/event/centrality" ), centrality);
1015+ registry.fill (HIST (" generated/event/activity" ), activity);
1016+ registry.fill (HIST (" generated/event/vertex" ), mcCollision.posZ ());
1017+ fillFlowContainer (flowContainerGen, activity);
1018+ }
1019+
9091020 void processRun2 (CollisionsRun2::iterator const & collision, Tracks const & tracks, BCsRun2 const &, aod::Zdcs const &)
9101021 {
9111022 float spectators = -1 .f ;
912- if (!eventSelected<BCsRun2>(collision, run2EventSelected<BCsRun2>(collision), static_cast <float >(tracks.size ()), collision.centRun2V0M (), spectators)) {
1023+ const bool requireZdc = !cfgFillAcceptance.value && activityRequiresZdc ();
1024+ if (!eventSelected<BCsRun2>(collision, run2EventSelected<false , BCsRun2>(collision, requireZdc), static_cast <float >(tracks.size ()), collision.centRun2V0M (), requireZdc, spectators)) {
9131025 return ;
9141026 }
9151027 if (cfgFillAcceptance) {
9161028 fillAcceptanceWeights (collision, tracks, collision.centRun2V0M ());
9171029 return ;
9181030 }
1031+ if (!collision.has_foundBC ()) {
1032+ return ;
1033+ }
9191034 const auto & bc = collision.foundBC_as <BCsRun2>();
9201035 loadEfficiency (bc.timestamp ());
9211036 loadAcceptance (bc.timestamp (), bc.runNumber ());
@@ -935,12 +1050,16 @@ struct EnergyFlowGfw {
9351050 }
9361051
9371052 for (const auto & collision : collisions) {
1053+ if (!cfgFillEfficiency.value && !cfgFillAcceptance.value ) {
1054+ processGeneratedCollision (mcCollision, mcParticles, collision.centRun2V0M ());
1055+ }
9381056 if (std::abs (collision.posZ ()) >= cuts.vertexZ .value ) {
9391057 return ;
9401058 }
9411059 const auto groupedTracks = tracks.sliceBy (tracksPerCollision, collision.globalIndex ());
9421060 float spectators = -1 .f ;
943- if (!eventSelected<BCsRun2>(collision, collision.alias_bit (kINT7 ) && collision.sel7 (), static_cast <float >(groupedTracks.size ()), collision.centRun2V0M (), spectators)) {
1061+ const bool requireZdc = !cfgFillEfficiency.value && !cfgFillAcceptance.value && activityRequiresZdc ();
1062+ if (!eventSelected<BCsRun2>(collision, run2EventSelected<true , BCsRun2>(collision, requireZdc), static_cast <float >(groupedTracks.size ()), collision.centRun2V0M (), requireZdc, spectators)) {
9441063 return ;
9451064 }
9461065
@@ -957,25 +1076,32 @@ struct EnergyFlowGfw {
9571076 return ;
9581077 }
9591078
1079+ if (!collision.has_foundBC ()) {
1080+ return ;
1081+ }
9601082 const auto & bc = collision.foundBC_as <BCsRun2>();
9611083 loadEfficiency (bc.timestamp ());
9621084 loadAcceptance (bc.timestamp (), bc.runNumber ());
9631085 processCollision (collision, groupedTracks, collision.centRun2V0M (), spectators);
9641086 return ;
9651087 }
9661088 }
967- PROCESS_SWITCH (EnergyFlowGfw, processRun2MC, " Process matched Run 2 MC for efficiency, acceptance, or reconstructed closure " , false );
1089+ PROCESS_SWITCH (EnergyFlowGfw, processRun2MC, " Process matched Run 2 MC for corrections or simultaneous generated and reconstructed analyses " , false );
9681090
9691091 void processRun3 (CollisionsRun3::iterator const & collision, Tracks const & tracks, BCsRun3 const &, aod::Zdcs const &)
9701092 {
9711093 float spectators = -1 .f ;
972- if (!eventSelected<BCsRun3>(collision, collision.sel8 (), static_cast <float >(tracks.size ()), collision.centFT0C (), spectators)) {
1094+ const bool requireZdc = !cfgFillAcceptance.value && activityRequiresZdc ();
1095+ if (!eventSelected<BCsRun3>(collision, collision.sel8 (), static_cast <float >(tracks.size ()), collision.centFT0C (), requireZdc, spectators)) {
9731096 return ;
9741097 }
9751098 if (cfgFillAcceptance) {
9761099 fillAcceptanceWeights (collision, tracks, collision.centFT0C ());
9771100 return ;
9781101 }
1102+ if (!collision.has_foundBC ()) {
1103+ return ;
1104+ }
9791105 const auto & bc = collision.foundBC_as <BCsRun3>();
9801106 loadEfficiency (bc.timestamp ());
9811107 loadAcceptance (bc.timestamp (), bc.runNumber ());
@@ -995,12 +1121,16 @@ struct EnergyFlowGfw {
9951121 }
9961122
9971123 for (const auto & collision : collisions) {
1124+ if (!cfgFillEfficiency.value && !cfgFillAcceptance.value ) {
1125+ processGeneratedCollision (mcCollision, mcParticles, collision.centFT0C ());
1126+ }
9981127 if (std::abs (collision.posZ ()) >= cuts.vertexZ .value ) {
9991128 return ;
10001129 }
10011130 const auto groupedTracks = tracks.sliceBy (tracksPerCollision, collision.globalIndex ());
10021131 float spectators = -1 .f ;
1003- if (!eventSelected<BCsRun3>(collision, collision.sel8 (), static_cast <float >(groupedTracks.size ()), collision.centFT0C (), spectators)) {
1132+ const bool requireZdc = !cfgFillEfficiency.value && !cfgFillAcceptance.value && activityRequiresZdc ();
1133+ if (!eventSelected<BCsRun3>(collision, collision.sel8 (), static_cast <float >(groupedTracks.size ()), collision.centFT0C (), requireZdc, spectators)) {
10041134 return ;
10051135 }
10061136
@@ -1017,14 +1147,17 @@ struct EnergyFlowGfw {
10171147 return ;
10181148 }
10191149
1150+ if (!collision.has_foundBC ()) {
1151+ return ;
1152+ }
10201153 const auto & bc = collision.foundBC_as <BCsRun3>();
10211154 loadEfficiency (bc.timestamp ());
10221155 loadAcceptance (bc.timestamp (), bc.runNumber ());
10231156 processCollision (collision, groupedTracks, collision.centFT0C (), spectators);
10241157 return ;
10251158 }
10261159 }
1027- PROCESS_SWITCH (EnergyFlowGfw, processRun3MC, " Process matched Run 3 MC for efficiency, acceptance, or reconstructed closure " , false );
1160+ PROCESS_SWITCH (EnergyFlowGfw, processRun3MC, " Process matched Run 3 MC for corrections or simultaneous generated and reconstructed analyses " , false );
10281161};
10291162
10301163WorkflowSpec defineDataProcessing (ConfigContext const & context)
0 commit comments