1313// Run 3 Pb-Pb centrality selections in 2023 data. It is compatible with
1414// derived data.
1515
16- #include " Framework/runDataProcessing.h"
17- #include " Framework/AnalysisTask.h"
18- #include " Framework/AnalysisDataModel.h"
19- #include " Common/DataModel/McCollisionExtra.h"
20- #include " Common/DataModel/Multiplicity.h"
16+ #include " Common/CCDB/ctpRateFetcher.h"
2117#include " Common/DataModel/Centrality.h"
2218#include " Common/DataModel/EventSelection.h"
19+ #include " Common/DataModel/McCollisionExtra.h"
20+ #include " Common/DataModel/Multiplicity.h"
21+
22+ #include " CCDB/BasicCCDBManager.h"
23+ #include " DataFormatsParameters/GRPECSObject.h"
24+ #include " Framework/AnalysisDataModel.h"
25+ #include " Framework/AnalysisTask.h"
2326#include " Framework/O2DatabasePDGPlugin.h"
27+ #include " Framework/runDataProcessing.h"
28+
2429#include " TH1F.h"
2530#include " TH2F.h"
31+ #include " TProfile.h"
32+
33+ #include < string>
2634
2735using namespace o2 ;
2836using namespace o2 ::framework;
@@ -32,13 +40,16 @@ using BCsWithRun3Matchings = soa::Join<aod::BCs, aod::Timestamps, aod::Run3Match
3240struct centralityStudy {
3341 // Raw multiplicities
3442 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
43+ Service<o2::ccdb::BasicCCDBManager> ccdb;
44+ ctpRateFetcher mRateFetcher ;
3545
3646 // Configurables
3747 Configurable<bool > do2DPlots{" do2DPlots" , true , " 0 - no, 1 - yes" };
3848 Configurable<bool > doOccupancyStudyVsCentrality2d{" doOccupancyStudyVsCentrality2d" , true , " 0 - no, 1 - yes" };
3949 Configurable<bool > doOccupancyStudyVsRawValues2d{" doOccupancyStudyVsRawValues2d" , true , " 0 - no, 1 - yes" };
4050 Configurable<bool > doOccupancyStudyVsCentrality3d{" doOccupancyStudyVsCentrality3d" , false , " 0 - no, 1 - yes" };
4151 Configurable<bool > doOccupancyStudyVsRawValues3d{" doOccupancyStudyVsRawValues3d" , false , " 0 - no, 1 - yes" };
52+ Configurable<bool > doTimeStudies{" doTimeStudies" , true , " 0 - no, 1 - yes" };
4253 Configurable<bool > doNGlobalTracksVsRawSignals{" doNGlobalTracksVsRawSignals" , true , " 0 - no, 1 - yes" };
4354 Configurable<bool > applySel8{" applySel8" , true , " 0 - no, 1 - yes" };
4455 Configurable<bool > applyVtxZ{" applyVtxZ" , true , " 0 - no, 1 - yes" };
@@ -70,6 +81,11 @@ struct centralityStudy {
7081 Configurable<float > scaleSignalFT0M{" scaleSignalFT0M" , 1 .00f , " scale FT0M signal for convenience" };
7182 Configurable<float > scaleSignalFV0A{" scaleSignalFV0A" , 1 .00f , " scale FV0A signal for convenience" };
7283
84+ Configurable<std::string> ccdbURL{" ccdbURL" , " http://alice-ccdb.cern.ch" , " ccdb url" };
85+ Configurable<std::string> pathGRPECSObject{" pathGRPECSObject" , " GLO/Config/GRPECS" , " Path to GRPECS object" };
86+ Configurable<std::string> irSource{" irSource" , " ZNC hadronic" , " Source of the interaction rate: (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)" };
87+ Configurable<bool > irCrashOnNull{" irCrashOnNull" , false , " Flag to avoid CTP RateFetcher crash." };
88+
7389 // _______________________________________
7490 // upc rejection criteria
7591 // reject low zna/c
@@ -113,10 +129,11 @@ struct centralityStudy {
113129 ConfigurableAxis axisCentrality{" axisCentrality" , {100 , 0 , 100 }, " FT0C percentile" };
114130 ConfigurableAxis axisPVChi2{" axisPVChi2" , {300 , 0 , 30 }, " FT0C percentile" };
115131 ConfigurableAxis axisDeltaTime{" axisDeltaTime" , {300 , 0 , 300 }, " #Delta time" };
132+ ConfigurableAxis axisDeltaTimestamp{" axisDeltaTimestamp" , {1440 , 0 , 24 }, " #Delta timestamp - sor (hours)" };
133+ ConfigurableAxis axisInteractionRate{" axisInteractionRate" , {500 , 0 , 100 }, " Binning for the interaction rate (kHz)" };
116134
117135 // For profile Z
118136 ConfigurableAxis axisPVz{" axisPVz" , {400 , -20 .0f , +20 .0f }, " PVz (cm)" };
119-
120137 ConfigurableAxis axisZN{" axisZN" , {1100 , -50 .0f , +500 .0f }, " ZN" };
121138
122139 void init (InitContext&)
@@ -227,13 +244,30 @@ struct centralityStudy {
227244 histos.add (" hFT0COccupancyVsNGlobalTracksVsCentrality" , " hFT0COccupancyVsNGlobalTracksVsCentrality" , kTH3F , {axisFT0COccupancy, axisMultGlobalTracks, axisCentrality});
228245 }
229246 }
247+
248+ if (doTimeStudies) {
249+ ccdb->setURL (ccdbURL);
250+ ccdb->setCaching (true );
251+ ccdb->setLocalObjectValidityChecking ();
252+ ccdb->setFatalWhenNull (false );
253+
254+ histos.add (" hFT0AvsTime" , " hFT0AvsTime" , kTH2F , {axisDeltaTimestamp, axisMultFT0A});
255+ histos.add (" hFT0CvsTime" , " hFT0CvsTime" , kTH2F , {axisDeltaTimestamp, axisMultFT0C});
256+ histos.add (" hFT0MvsTime" , " hFT0MvsTime" , kTH2F , {axisDeltaTimestamp, axisMultFT0M});
257+ histos.add (" hFV0AvsTime" , " hFV0AvsTime" , kTH2F , {axisDeltaTimestamp, axisMultFV0A});
258+ histos.add (" hMFTTracksvsTime" , " hMFTTracksvsTime" , kTH2F , {axisDeltaTimestamp, axisMultMFTTracks});
259+ histos.add (" hNGlobalVsTime" , " hNGlobalVsTime" , kTH2F , {axisDeltaTimestamp, axisMultGlobalTracks});
260+ histos.add (" hNTPVContributorsvsTime" , " hNTPVContributorsvsTime" , kTH2F , {axisDeltaTimestamp, axisMultPVContributors});
261+ histos.add (" hIRProfileVsTime" , " hIRProfileVsTime" , kTProfile , {axisDeltaTimestamp});
262+ histos.add (" hPVzProfileCoVsTime" , " hPVzProfileCoVsTime" , kTProfile , {axisDeltaTimestamp});
263+ histos.add (" hPVzProfileBcVsTime" , " hPVzProfileBcVsTime" , kTProfile , {axisDeltaTimestamp});
264+ }
230265 }
231266
232267 template <typename TCollision>
233268 void genericProcessCollision (TCollision collision)
234269 // process this collisions
235270 {
236-
237271 histos.fill (HIST (" hCollisionSelection" ), 0 ); // all collisions
238272 if (applySel8 && !collision.multSel8 ())
239273 return ;
@@ -403,19 +437,40 @@ struct centralityStudy {
403437 histos.fill (HIST (" hFT0COccupancyVsNGlobalTracksVsCentrality" ), collision.ft0cOccupancyInTimeRange (), collision.multNTracksGlobal (), collision.centFT0C ());
404438 }
405439 }
440+
441+ if (doTimeStudies && collision.has_multBC ()) {
442+ auto multbc = collision.template multBC_as <aod::MultBCs>();
443+ uint64_t bcTimestamp = multbc.timestamp ();
444+ o2::parameters::GRPECSObject* grpo = ccdb->getForTimeStamp <o2::parameters::GRPECSObject>(pathGRPECSObject, bcTimestamp);
445+ uint64_t startOfRunTimestamp = grpo->getTimeStart ();
446+
447+ float hoursAfterStartOfRun = static_cast <float >(bcTimestamp - startOfRunTimestamp) / 3600000.0 ;
448+ float interactionRate = mRateFetcher .fetch (ccdb.service , bcTimestamp, collision.multRunNumber (), irSource.value , irCrashOnNull) / 1000 .; // kHz
449+
450+ histos.fill (HIST (" hFT0AvsTime" ), hoursAfterStartOfRun, collision.multFT0A ());
451+ histos.fill (HIST (" hFT0CvsTime" ), hoursAfterStartOfRun, collision.multFT0C ());
452+ histos.fill (HIST (" hFT0MvsTime" ), hoursAfterStartOfRun, collision.multFT0M ());
453+ histos.fill (HIST (" hFV0AvsTime" ), hoursAfterStartOfRun, collision.multFV0A ());
454+ histos.fill (HIST (" hMFTTracksvsTime" ), hoursAfterStartOfRun, collision.mftNtracks ());
455+ histos.fill (HIST (" hNGlobalVsTime" ), hoursAfterStartOfRun, collision.multNTracksGlobal ());
456+ histos.fill (HIST (" hNTPVContributorsvsTime" ), hoursAfterStartOfRun, collision.multPVTotalContributors ());
457+ histos.fill (HIST (" hPVzProfileCoVsTime" ), hoursAfterStartOfRun, collision.multPVz ());
458+ histos.fill (HIST (" hPVzProfileBcVsTime" ), hoursAfterStartOfRun, multbc.multFT0PosZ ());
459+ histos.fill (HIST (" hIRProfileVsTime" ), hoursAfterStartOfRun, interactionRate);
460+ }
406461 }
407462
408- void processCollisions (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultsGlobal, aod::MultSelections>::iterator const & collision)
463+ void processCollisions (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultsGlobal, aod::MultSelections, aod::Mults2BC >::iterator const & collision, aod::MultBCs const & )
409464 {
410465 genericProcessCollision (collision);
411466 }
412467
413- void processCollisionsWithCentrality (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultSelections, aod::CentFT0Cs, aod::MultsGlobal>::iterator const & collision)
468+ void processCollisionsWithCentrality (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultSelections, aod::CentFT0Cs, aod::MultsGlobal, aod::Mults2BC >::iterator const & collision, aod::MultBCs const & )
414469 {
415470 genericProcessCollision (collision);
416471 }
417472
418- void processCollisionsWithCentralityWithNeighbours (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultSelections, aod::CentFT0Cs, aod::MultsGlobal, aod::MultNeighs>::iterator const & collision)
473+ void processCollisionsWithCentralityWithNeighbours (soa::Join<aod::Mults, aod::MFTMults, aod::MultsExtra, aod::MultSelections, aod::CentFT0Cs, aod::MultsGlobal, aod::MultNeighs, aod::Mults2BC >::iterator const & collision, aod::MultBCs const & )
419474 {
420475 genericProcessCollision (collision);
421476 }
0 commit comments