@@ -96,6 +96,7 @@ struct UccZdc {
9696 ConfigurableAxis binsCent{" binsCent" , {VARIABLE_WIDTH, 0 ., 10 ., 20 ., 30 ., 40 ., 50 ., 60 ., 70 ., 80 ., 90 ., 100 .}, " T0C binning" };
9797
9898 // Configurables Event Selection
99+ Configurable<bool > useTimeStamps{" useTimeStamps" , true , " Use time stamps for CCDB object calls" };
99100 Configurable<bool > isNoCollInTimeRangeStrict{" isNoCollInTimeRangeStrict" , true , " isNoCollInTimeRangeStrict?" };
100101 Configurable<bool > isNoCollInTimeRangeStandard{" isNoCollInTimeRangeStandard" , false , " isNoCollInTimeRangeStandard?" };
101102 Configurable<bool > isNoCollInRofStrict{" isNoCollInRofStrict" , true , " isNoCollInRofStrict?" };
@@ -252,7 +253,7 @@ struct UccZdc {
252253 registry.add (" NchVsFourParCorrVsZN" , " ;#it{N}_{ch} (|#eta| < 0.8, Corrected);ZNA+ZNC;#LT[#it{p}_{T}^{(4)}]#GT" , kTProfile2D , {{{nBinsNch, minNch, maxNch}, {nBinsZDC, -0.5 , maxZN}}});
253254
254255 registry.add (" RejectedEvtsVsFT0M" , " ;T0A+T0C (#times 1/100, -3.3 < #eta < -2.1 and 3.5 < #eta < 4.9);Entries;" , kTH1F , {{nBinsAmpFT0, 0 ., 3000 .}});
255- registry.add (" RejectedEvtsVsNch" , " ;#it{N}_{ch} (|#eta|<0.8);Entries;" , kTH1F , {{nBinsNch, minNch, maxNch }});
256+ registry.add (" RejectedEvtsVsNch" , " ;#it{N}_{ch} (|#eta|<0.8);Entries;" , kTH1F , {{300 , 0 , 3000 }});
256257 }
257258
258259 // MC Histograms
@@ -358,10 +359,8 @@ struct UccZdc {
358359 // Enabling object caching, otherwise each call goes to the CCDB server
359360 ccdb->setCaching (true );
360361 ccdb->setLocalObjectValidityChecking ();
361- // Not later than now, will be replaced by the value of the train creation
362- // This avoids that users can replace objects **while** a train is running
363- int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
364- ccdb->setCreatedNotAfter (now);
362+ ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
363+ ccdb->setFatalWhenNull (false );
365364 }
366365
367366 template <typename CheckCol>
@@ -451,9 +450,7 @@ struct UccZdc {
451450 void processQA (o2::aod::ColEvSels::iterator const & collision, o2::aod::BCsRun3 const & /* */ , aod::Zdcs const & /* */ , aod::FV0As const & /* */ , aod::FT0s const & /* */ , TheFilteredTracks const & tracks)
452451 {
453452 const double ePerNucleon{2.68 };
454- // LOG(info) << " Collisions size: " << collisions.size() << " Table's size: " << collisions.tableSize() << "\n";
455453 const auto & foundBC = collision.foundBC_as <o2::aod::BCsRun3>();
456- // LOG(info) << "Run number: " << foundBC.runNumber() << "\n";
457454 if (!isEventSelected (collision)) {
458455 return ;
459456 }
@@ -515,14 +512,14 @@ struct UccZdc {
515512 registry.fill (HIST (" hEventCounter" ), EvCutLabel::Zem);
516513 }
517514
518- // Get Nch-based selection objects from the CCDB
519- fMeanNch = ccdb-> getForTimeStamp <TF1>(paTHmeanNch. value , foundBC. timestamp ());
520- fSigmaNch = ccdb-> getForTimeStamp <TF1>(paTHsigmaNch. value , foundBC.timestamp ());
521- if ( fMeanNch == nullptr ) {
522- LOGF (fatal, " Could not load fMeanNch! " );
515+ bool areParsLoaded{ false };
516+ if (useTimeStamps) {
517+ areParsLoaded = loadMeanSigmaNchParams ( foundBC.timestamp ());
518+ } else {
519+ areParsLoaded = loadMeanSigmaNchParams (foundBC. runNumber () );
523520 }
524- if (fSigmaNch == nullptr ) {
525- LOGF (fatal, " Could not load fSigmaNch! " ) ;
521+ if (!areParsLoaded ) {
522+ return ;
526523 }
527524
528525 float znA{zdc.amplitudeZNA ()};
@@ -620,11 +617,6 @@ struct UccZdc {
620617 const auto & foundBC = collision.foundBC_as <o2::aod::BCsRun3>();
621618 // LOGF(info, "Getting object %s for run number %i from timestamp=%llu", paTH.value.data(), foundBC.runNumber(), foundBC.timestamp());
622619
623- efficiency = ccdb->getForTimeStamp <TH1F>(paTH.value , foundBC.timestamp ());
624- if (efficiency == nullptr ) {
625- LOGF (fatal, " Could not load efficiency!" );
626- }
627-
628620 // has ZDC?
629621 if (!foundBC.has_zdc ()) {
630622 return ;
@@ -676,14 +668,26 @@ struct UccZdc {
676668 registry.fill (HIST (" hEventCounter" ), EvCutLabel::Zem);
677669 }
678670
671+ // Load Efficiency correction
672+ bool isEffLoaded{false };
673+ if (useTimeStamps) {
674+ isEffLoaded = loadEfficiencyCorrection (foundBC.timestamp ());
675+ } else {
676+ isEffLoaded = loadEfficiencyCorrection (foundBC.runNumber ());
677+ }
678+ if (!isEffLoaded) {
679+ return ;
680+ }
681+
679682 // Get Nch-based selection objects from the CCDB
680- fMeanNch = ccdb->getForTimeStamp <TF1>(paTHmeanNch.value , foundBC.timestamp ());
681- fSigmaNch = ccdb->getForTimeStamp <TF1>(paTHsigmaNch.value , foundBC.timestamp ());
682- if (fMeanNch == nullptr ) {
683- LOGF (fatal, " Could not load fMeanNch!" );
683+ bool areParsLoaded{false };
684+ if (useTimeStamps) {
685+ areParsLoaded = loadMeanSigmaNchParams (foundBC.timestamp ());
686+ } else {
687+ areParsLoaded = loadMeanSigmaNchParams (foundBC.runNumber ());
684688 }
685- if (fSigmaNch == nullptr ) {
686- LOGF (fatal, " Could not load fSigmaNch! " ) ;
689+ if (!areParsLoaded ) {
690+ return ;
687691 }
688692
689693 std::vector<float > pTs;
@@ -783,13 +787,7 @@ struct UccZdc {
783787 // ----- MC reconstructed -----//
784788 for (const auto & collision : collisions) {
785789
786- // To use run-by-run efficiency
787790 const auto & foundBC = collision.foundBC_as <o2::aod::BCsRun3>();
788- auto efficiency = ccdb->getForTimeStamp <TH1F>(paTH.value , foundBC.timestamp ());
789- // auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
790- if (!efficiency) {
791- LOGF (fatal, " Efficiency object not found!" );
792- }
793791
794792 // Event selection
795793 if (!isEventSelected (collision)) {
@@ -800,6 +798,17 @@ struct UccZdc {
800798 continue ;
801799 }
802800
801+ // Load Efficiency correction
802+ bool isEffLoaded{false };
803+ if (useTimeStamps) {
804+ isEffLoaded = loadEfficiencyCorrection (foundBC.timestamp ());
805+ } else {
806+ isEffLoaded = loadEfficiencyCorrection (foundBC.runNumber ());
807+ }
808+ if (!isEffLoaded) {
809+ return ;
810+ }
811+
803812 registry.fill (HIST (" T0Ccent" ), collision.centFT0C ());
804813 registry.fill (HIST (" zPos" ), collision.posZ ());
805814
@@ -1024,6 +1033,65 @@ struct UccZdc {
10241033 return false ;
10251034 }
10261035 }
1036+
1037+ template <typename T>
1038+ bool loadMeanSigmaNchParams (const T& parameter)
1039+ {
1040+ fMeanNch = nullptr ;
1041+ fSigmaNch = nullptr ;
1042+ // Get Nch-based selection objects from the CCDB
1043+ if (useTimeStamps) {
1044+ fMeanNch = ccdb->getForTimeStamp <TF1>(paTHmeanNch.value , parameter);
1045+ fSigmaNch = ccdb->getForTimeStamp <TF1>(paTHsigmaNch.value , parameter);
1046+ } else {
1047+ fMeanNch = ccdb->getForRun <TF1>(paTHmeanNch.value , parameter);
1048+ fSigmaNch = ccdb->getForRun <TF1>(paTHsigmaNch.value , parameter);
1049+ // auto efficiency = ccdb->getForRun<TH1F>(paTH.value, foundBC.runNumber());
1050+ }
1051+ if (!fMeanNch ) {
1052+ LOGF (fatal, " Could not load fMeanNch from %s" , paTHmeanNch.value .c_str ());
1053+ return false ;
1054+ }
1055+ if (!fSigmaNch ) {
1056+ LOGF (fatal, " Could not load fSigmaNch from %s" , paTHsigmaNch.value .c_str ());
1057+ return false ;
1058+ }
1059+ // if (fMeanNch) {
1060+ // LOGF(info, "Loaded fMeanNch from %s (%p)", paTHmeanNch.value.c_str(), (void*)fMeanNch);
1061+ // }
1062+ // if (fSigmaNch) {
1063+ // LOGF(info, "Loaded fSigmaNch from %s (%p)", paTHsigmaNch.value.c_str(), (void*)fSigmaNch);
1064+ // }
1065+ if (!fMeanNch || !fSigmaNch ) {
1066+ return false ;
1067+ } else {
1068+ return true ;
1069+ }
1070+ }
1071+
1072+ template <typename T>
1073+ bool loadEfficiencyCorrection (const T& parameter)
1074+ {
1075+ efficiency = nullptr ;
1076+ // Get Nch-based selection objects from the CCDB
1077+ if (useTimeStamps) {
1078+ efficiency = ccdb->getForTimeStamp <TH1F>(paTH.value , parameter);
1079+ } else {
1080+ efficiency = ccdb->getForRun <TH1F>(paTH.value , parameter);
1081+ }
1082+ if (!efficiency) {
1083+ LOGF (fatal, " Could not load efficiency from %s" , paTH.value .c_str ());
1084+ return false ;
1085+ }
1086+ // if (efficiency) {
1087+ // LOGF(info, "Loaded efficiency from %s (%p)", paTH.value.c_str(), (void*)efficiency);
1088+ // }
1089+ if (!efficiency) {
1090+ return false ;
1091+ } else {
1092+ return true ;
1093+ }
1094+ }
10271095};
10281096
10291097WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments