2424// / \since May 22, 2024
2525// /
2626
27- #include < utility>
28- #include < map>
29- #include < string>
30- #include < vector>
27+ #include " TableHelper.h"
3128
32- #include < TPDGCode.h>
29+ #include " ALICE3/Core/DelphesO2TrackSmearer.h"
30+ #include " ALICE3/Core/TrackUtilities.h"
31+ #include " ALICE3/DataModel/OTFTOF.h"
32+ #include " Common/Core/trackUtilities.h"
33+ #include " Common/DataModel/TrackSelectionTables.h"
3334
35+ #include " CCDB/BasicCCDBManager.h"
36+ #include " CCDB/CcdbApi.h"
37+ #include " CommonConstants/GeomConstants.h"
38+ #include " CommonConstants/MathConstants.h"
39+ #include " CommonConstants/PhysicsConstants.h"
40+ #include " CommonUtils/NameConf.h"
41+ #include " DataFormatsCalibration/MeanVertexObject.h"
42+ #include " DataFormatsParameters/GRPMagField.h"
43+ #include " DetectorsBase/GeometryManager.h"
44+ #include " DetectorsBase/Propagator.h"
45+ #include " DetectorsVertexing/HelixHelper.h"
46+ #include " Framework/ASoAHelpers.h"
3447#include " Framework/AnalysisDataModel.h"
3548#include " Framework/AnalysisTask.h"
36- #include " Framework/runDataProcessing.h"
37- #include " Framework/RunningWorkflowInfo.h"
3849#include " Framework/HistogramRegistry.h"
3950#include " Framework/O2DatabasePDGPlugin.h"
40- #include " Framework/ASoAHelpers.h"
41- #include " Common/DataModel/TrackSelectionTables.h"
42- #include " Common/Core/trackUtilities.h"
43- #include " ALICE3/Core/TrackUtilities.h"
51+ #include " Framework/RunningWorkflowInfo.h"
52+ #include " Framework/runDataProcessing.h"
4453#include " ReconstructionDataFormats/DCA.h"
45- #include " DetectorsBase/Propagator.h"
46- #include " DetectorsBase/GeometryManager.h"
47- #include " CommonUtils/NameConf.h"
48- #include " CCDB/CcdbApi.h"
49- #include " CCDB/BasicCCDBManager.h"
50- #include " DataFormatsParameters/GRPMagField.h"
51- #include " DataFormatsCalibration/MeanVertexObject.h"
52- #include " CommonConstants/GeomConstants.h"
53- #include " CommonConstants/PhysicsConstants.h"
54- #include " TRandom3.h"
55- #include " ALICE3/DataModel/OTFTOF.h"
56- #include " DetectorsVertexing/HelixHelper.h"
57- #include " TableHelper.h"
58- #include " ALICE3/Core/DelphesO2TrackSmearer.h"
54+
5955#include " TEfficiency.h"
6056#include " THashList.h"
57+ #include " TRandom3.h"
58+ #include < TPDGCode.h>
59+
60+ #include < map>
61+ #include < string>
62+ #include < utility>
63+ #include < vector>
6164
6265using namespace o2 ;
6366using namespace o2 ::framework;
@@ -84,7 +87,7 @@ struct OnTheFlyTofPid {
8487 // more could be added (especially a disk TOF at a certain z?)
8588 // in the evolution of this effort
8689 struct : ConfigurableGroup {
87- Configurable<float > dBz{ " dBz " , 20 , " magnetic field (kilogauss)" };
90+ Configurable<float > magneticField{ " magneticField " , 0 , " magnetic field (kilogauss) if 0, taken from the tracker task " };
8891 Configurable<bool > considerEventTime{" considerEventTime" , true , " flag to consider event time" };
8992 Configurable<float > innerTOFRadius{" innerTOFRadius" , 20 , " barrel inner TOF radius (cm)" };
9093 Configurable<float > outerTOFRadius{" outerTOFRadius" , 80 , " barrel outer TOF radius (cm)" };
@@ -140,6 +143,13 @@ struct OnTheFlyTofPid {
140143 void init (o2::framework::InitContext& initContext)
141144 {
142145 pRandomNumberGenerator.SetSeed (0 ); // fully randomize
146+ if (simConfig.magneticField .value < o2::constants::math::Epsilon) {
147+ LOG (info) << " Getting the magnetic field from the on-the-fly tracker task" ;
148+ if (!getTaskOptionValue (initContext, " on-the-fly-tracker" , simConfig.magneticField , false )) {
149+ LOG (fatal) << " Could not get Bz from on-the-fly-tracker task" ;
150+ }
151+ LOG (info) << " Bz = " << simConfig.magneticField .value << " T" ;
152+ }
143153
144154 // Check if inheriting the LUT configuration
145155 auto configLutPath = [&](Configurable<std::string>& lut) {
@@ -221,33 +231,33 @@ struct OnTheFlyTofPid {
221231
222232 std::string particleNames[kParticles ] = {" #it{e}" , " #it{#mu}" , " #it{#pi}" , " #it{K}" , " #it{p}" };
223233 std::string particleNames2[kParticles ] = {" Elec" , " Muon" , " Pion" , " Kaon" , " Prot" };
224- for (int i_true = 0 ; i_true < kParticles ; i_true ++) {
234+ for (int iTrue = 0 ; iTrue < kParticles ; iTrue ++) {
225235 auto addHistogram = [&](const std::string& name, const AxisSpec& axis) {
226236 return histos.add <TH2>(name, " " , kTH2F , {axisMomentum, axis});
227237 };
228238
229- const AxisSpec axisTrackTimeRes{plotsConfig.nBinsTimeRes , 0 .0f , +200 .0f , " Track time resolution - " + particleNames[i_true ] + " (ps)" };
230- h2dInnerTimeResTrack[i_true ] = addHistogram (" iTOF/res/h2dInnerTimeResTrack" + particleNames2[i_true ] + " VsP" , axisTrackTimeRes);
231- h2dOuterTimeResTrack[i_true ] = addHistogram (" oTOF/res/h2dOuterTimeResTrack" + particleNames2[i_true ] + " VsP" , axisTrackTimeRes);
232- const AxisSpec axisTotalTimeRes{plotsConfig.nBinsTimeRes , 0 .0f , +200 .0f , " Total time resolution - " + particleNames[i_true ] + " (ps)" };
233- h2dInnerTimeResTotal[i_true ] = addHistogram (" iTOF/res/h2dInnerTimeResTotal" + particleNames2[i_true ] + " VsP" , axisTotalTimeRes);
234- h2dOuterTimeResTotal[i_true ] = addHistogram (" oTOF/res/h2dOuterTimeResTotal" + particleNames2[i_true ] + " VsP" , axisTotalTimeRes);
235- for (int i_hyp = 0 ; i_hyp < kParticles ; i_hyp ++) {
236- std::string nameTitleInner = " h2dInnerNsigmaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" ;
237- std::string nameTitleOuter = " h2dOuterNsigmaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" ;
238- std::string nameTitleInnerDelta = " h2dInnerDeltaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" ;
239- std::string nameTitleOuterDelta = " h2dOuterDeltaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" ;
239+ const AxisSpec axisTrackTimeRes{plotsConfig.nBinsTimeRes , 0 .0f , +200 .0f , " Track time resolution - " + particleNames[iTrue ] + " (ps)" };
240+ h2dInnerTimeResTrack[iTrue ] = addHistogram (" iTOF/res/h2dInnerTimeResTrack" + particleNames2[iTrue ] + " VsP" , axisTrackTimeRes);
241+ h2dOuterTimeResTrack[iTrue ] = addHistogram (" oTOF/res/h2dOuterTimeResTrack" + particleNames2[iTrue ] + " VsP" , axisTrackTimeRes);
242+ const AxisSpec axisTotalTimeRes{plotsConfig.nBinsTimeRes , 0 .0f , +200 .0f , " Total time resolution - " + particleNames[iTrue ] + " (ps)" };
243+ h2dInnerTimeResTotal[iTrue ] = addHistogram (" iTOF/res/h2dInnerTimeResTotal" + particleNames2[iTrue ] + " VsP" , axisTotalTimeRes);
244+ h2dOuterTimeResTotal[iTrue ] = addHistogram (" oTOF/res/h2dOuterTimeResTotal" + particleNames2[iTrue ] + " VsP" , axisTotalTimeRes);
245+ for (int iHyp = 0 ; iHyp < kParticles ; iHyp ++) {
246+ std::string nameTitleInner = " h2dInnerNsigmaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" ;
247+ std::string nameTitleOuter = " h2dOuterNsigmaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" ;
248+ std::string nameTitleInnerDelta = " h2dInnerDeltaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" ;
249+ std::string nameTitleOuterDelta = " h2dOuterDeltaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" ;
240250 const AxisSpec axisX{plotsConfig.doSeparationVsPt .value ? axisPt : axisMomentum};
241- const AxisSpec axisNsigmaCorrect{plotsConfig.nBinsNsigmaCorrectSpecies , plotsConfig.minNsigmaRange , plotsConfig.maxNsigmaRange , " N#sigma - True " + particleNames[i_true ] + " vs " + particleNames[i_hyp ] + " hypothesis" };
242- const AxisSpec axisDeltaCorrect{plotsConfig.nBinsDeltaCorrectSpecies , plotsConfig.minDeltaRange , plotsConfig.maxDeltaRange , " #Delta - True " + particleNames[i_true ] + " vs " + particleNames[i_hyp ] + " hypothesis" };
243- const AxisSpec axisNsigmaWrong{plotsConfig.nBinsNsigmaWrongSpecies , plotsConfig.minNsigmaRange , plotsConfig.maxNsigmaRange , " N#sigma - True " + particleNames[i_true ] + " vs " + particleNames[i_hyp ] + " hypothesis" };
244- const AxisSpec axisDeltaWrong{plotsConfig.nBinsDeltaWrongSpecies , plotsConfig.minDeltaRange , plotsConfig.maxDeltaRange , " #Delta - True " + particleNames[i_true ] + " vs " + particleNames[i_hyp ] + " hypothesis" };
245- const AxisSpec axisNSigma{i_true == i_hyp ? axisNsigmaCorrect : axisNsigmaWrong};
246- const AxisSpec axisDelta{i_true == i_hyp ? axisDeltaCorrect : axisDeltaWrong};
247- h2dInnerNsigmaTrue[i_true][i_hyp ] = histos.add <TH2>(" iTOF/nsigma/h2dInnerNsigmaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisNSigma});
248- h2dOuterNsigmaTrue[i_true][i_hyp ] = histos.add <TH2>(" oTOF/nsigma/h2dOuterNsigmaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisNSigma});
249- h2dInnerDeltaTrue[i_true][i_hyp ] = histos.add <TH2>(" iTOF/delta/h2dInnerDeltaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisDelta});
250- h2dOuterDeltaTrue[i_true][i_hyp ] = histos.add <TH2>(" oTOF/delta/h2dOuterDeltaTrue" + particleNames2[i_true ] + " Vs" + particleNames2[i_hyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisDelta});
251+ const AxisSpec axisNsigmaCorrect{plotsConfig.nBinsNsigmaCorrectSpecies , plotsConfig.minNsigmaRange , plotsConfig.maxNsigmaRange , " N#sigma - True " + particleNames[iTrue ] + " vs " + particleNames[iHyp ] + " hypothesis" };
252+ const AxisSpec axisDeltaCorrect{plotsConfig.nBinsDeltaCorrectSpecies , plotsConfig.minDeltaRange , plotsConfig.maxDeltaRange , " #Delta - True " + particleNames[iTrue ] + " vs " + particleNames[iHyp ] + " hypothesis" };
253+ const AxisSpec axisNsigmaWrong{plotsConfig.nBinsNsigmaWrongSpecies , plotsConfig.minNsigmaRange , plotsConfig.maxNsigmaRange , " N#sigma - True " + particleNames[iTrue ] + " vs " + particleNames[iHyp ] + " hypothesis" };
254+ const AxisSpec axisDeltaWrong{plotsConfig.nBinsDeltaWrongSpecies , plotsConfig.minDeltaRange , plotsConfig.maxDeltaRange , " #Delta - True " + particleNames[iTrue ] + " vs " + particleNames[iHyp ] + " hypothesis" };
255+ const AxisSpec axisNSigma{iTrue == iHyp ? axisNsigmaCorrect : axisNsigmaWrong};
256+ const AxisSpec axisDelta{iTrue == iHyp ? axisDeltaCorrect : axisDeltaWrong};
257+ h2dInnerNsigmaTrue[iTrue][iHyp ] = histos.add <TH2>(" iTOF/nsigma/h2dInnerNsigmaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisNSigma});
258+ h2dOuterNsigmaTrue[iTrue][iHyp ] = histos.add <TH2>(" oTOF/nsigma/h2dOuterNsigmaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisNSigma});
259+ h2dInnerDeltaTrue[iTrue][iHyp ] = histos.add <TH2>(" iTOF/delta/h2dInnerDeltaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisDelta});
260+ h2dOuterDeltaTrue[iTrue][iHyp ] = histos.add <TH2>(" oTOF/delta/h2dOuterDeltaTrue" + particleNames2[iTrue ] + " Vs" + particleNames2[iHyp ] + " Hypothesis" , " " , kTH2F , {axisX, axisDelta});
251261 }
252262 }
253263 }
@@ -397,7 +407,7 @@ struct OnTheFlyTofPid {
397407
398408 static constexpr float kMaxEventTimeResolution = 200 .f ;
399409 if (sumw <= 0 . || tracks.size () <= 1 || std::sqrt (1 . / sumw) > kMaxEventTimeResolution ) {
400- tzero[0 ] = 0 .; // [ps]
410+ tzero[0 ] = 0 .; // [ps]
401411 tzero[1 ] = kMaxEventTimeResolution ; // [ps]
402412 return false ;
403413 }
@@ -496,13 +506,13 @@ struct OnTheFlyTofPid {
496506
497507 float xPv = -100 .f ;
498508 static constexpr float kTrkXThreshold = -99 .f ; // Threshold to consider a good propagation of the track
499- if (o2track.propagateToDCA (mcPvVtx, simConfig.dBz )) {
509+ if (o2track.propagateToDCA (mcPvVtx, simConfig.magneticField )) {
500510 xPv = o2track.getX ();
501511 }
502512 float trackLengthInnerTOF = -1 , trackLengthOuterTOF = -1 ;
503513 if (xPv > kTrkXThreshold ) {
504- trackLengthInnerTOF = computeTrackLength (o2track, simConfig.innerTOFRadius , simConfig.dBz );
505- trackLengthOuterTOF = computeTrackLength (o2track, simConfig.outerTOFRadius , simConfig.dBz );
514+ trackLengthInnerTOF = computeTrackLength (o2track, simConfig.innerTOFRadius , simConfig.magneticField );
515+ trackLengthOuterTOF = computeTrackLength (o2track, simConfig.outerTOFRadius , simConfig.magneticField );
506516 }
507517
508518 // get mass to calculate velocity
@@ -526,12 +536,12 @@ struct OnTheFlyTofPid {
526536 float trackLengthRecoInnerTOF = -1 , trackLengthRecoOuterTOF = -1 ;
527537 auto recoTrack = getTrackParCov (track);
528538 xPv = -100 .f ;
529- if (recoTrack.propagateToDCA (pvVtx, simConfig.dBz )) {
539+ if (recoTrack.propagateToDCA (pvVtx, simConfig.magneticField )) {
530540 xPv = recoTrack.getX ();
531541 }
532542 if (xPv > kTrkXThreshold ) {
533- trackLengthRecoInnerTOF = computeTrackLength (recoTrack, simConfig.innerTOFRadius , simConfig.dBz );
534- trackLengthRecoOuterTOF = computeTrackLength (recoTrack, simConfig.outerTOFRadius , simConfig.dBz );
543+ trackLengthRecoInnerTOF = computeTrackLength (recoTrack, simConfig.innerTOFRadius , simConfig.magneticField );
544+ trackLengthRecoOuterTOF = computeTrackLength (recoTrack, simConfig.outerTOFRadius , simConfig.magneticField );
535545 }
536546
537547 // cache the track info needed for the event time calculation
@@ -639,8 +649,8 @@ struct OnTheFlyTofPid {
639649 ptResolution = mSmearer .getAbsPtRes (pdgInfoThis->PdgCode (), dNdEta, pseudorapidity, momentum / std::cosh (pseudorapidity));
640650 etaResolution = mSmearer .getAbsEtaRes (pdgInfoThis->PdgCode (), dNdEta, pseudorapidity, momentum / std::cosh (pseudorapidity));
641651 }
642- float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced (momentum / std::cosh (pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.innerTOFRadius , simConfig.dBz );
643- float outerTrackTimeReso = calculateTrackTimeResolutionAdvanced (momentum / std::cosh (pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.outerTOFRadius , simConfig.dBz );
652+ float innerTrackTimeReso = calculateTrackTimeResolutionAdvanced (momentum / std::cosh (pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.innerTOFRadius , simConfig.magneticField );
653+ float outerTrackTimeReso = calculateTrackTimeResolutionAdvanced (momentum / std::cosh (pseudorapidity), pseudorapidity, ptResolution, etaResolution, masses[ii], simConfig.outerTOFRadius , simConfig.magneticField );
644654 innerTotalTimeReso = std::hypot (simConfig.innerTOFTimeReso , innerTrackTimeReso);
645655 outerTotalTimeReso = std::hypot (simConfig.outerTOFTimeReso , outerTrackTimeReso);
646656
0 commit comments