4242#include " CommonConstants/MathConstants.h"
4343#include " CommonConstants/PhysicsConstants.h"
4444#include " Common/Core/trackUtilities.h"
45+ #include " Common/CCDB/ctpRateFetcher.h"
4546#include " PWGLF/DataModel/LFStrangenessTables.h"
4647#include " PWGLF/DataModel/LFStrangenessMLTables.h"
4748#include " PWGLF/DataModel/LFStrangenessPIDTables.h"
@@ -80,6 +81,7 @@ struct derivedlambdakzeroanalysis {
8081 Configurable<bool > calculateFeeddownMatrix{" calculateFeeddownMatrix" , true , " fill feeddown matrix if MC" };
8182
8283 Configurable<bool > doPPAnalysis{" doPPAnalysis" , false , " if in pp, set to true" };
84+ Configurable<std::string> irSource{" irSource" , " T0VTX" , " Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)" };
8385
8486 struct : ConfigurableGroup {
8587 Configurable<bool > requireSel8{" requireSel8" , true , " require sel8 event selection" };
@@ -108,6 +110,9 @@ struct derivedlambdakzeroanalysis {
108110 // fast check on occupancy
109111 Configurable<float > minOccupancy{" minOccupancy" , -1 , " minimum occupancy from neighbouring collisions" };
110112 Configurable<float > maxOccupancy{" maxOccupancy" , -1 , " maximum occupancy from neighbouring collisions" };
113+ // fast check on interaction rate
114+ Configurable<float > minIR{" minIR" , -1 , " minimum IR collisions" };
115+ Configurable<float > maxIR{" maxIR" , -1 , " maximum IR collisions" };
111116 } eventSelections;
112117
113118 struct : ConfigurableGroup {
@@ -208,6 +213,8 @@ struct derivedlambdakzeroanalysis {
208213 } ccdbConfigurations;
209214
210215 o2::ccdb::CcdbApi ccdbApi;
216+ Service<o2::ccdb::BasicCCDBManager> ccdb;
217+ ctpRateFetcher rateFetcher;
211218 int mRunNumber ;
212219 std::map<std::string, std::string> metadata;
213220
@@ -221,6 +228,7 @@ struct derivedlambdakzeroanalysis {
221228 ConfigurableAxis axisLambdaMass{" axisLambdaMass" , {200 , 1 .101f , 1 .131f }, " " };
222229 ConfigurableAxis axisCentrality{" axisCentrality" , {VARIABLE_WIDTH, 0 .0f , 5 .0f , 10 .0f , 20 .0f , 30 .0f , 40 .0f , 50 .0f , 60 .0f , 70 .0f , 80 .0f , 90 .0f }, " Centrality" };
223230 ConfigurableAxis axisNch{" axisNch" , {500 , 0 .0f , +5000 .0f }, " Number of charged particles" };
231+ ConfigurableAxis axisIRBinning{" axisIRBinning" , {500 , 0 , 50 }, " Binning for the interaction rate (kHz)" };
224232
225233 ConfigurableAxis axisRawCentrality{"axisRawCentrality", {VARIABLE_WIDTH, 0.000f, 52.320f, 75.400f, 95.719f, 115.364f, 135.211f, 155.791f, 177.504f, 200.686f, 225.641f, 252.645f, 281.906f, 313.850f, 348.302f, 385.732f, 426.307f, 470.146f, 517.555f, 568.899f, 624.177f, 684.021f, 748.734f, 818.078f, 892.577f, 973.087f, 1058.789f, 1150.915f, 1249.319f, 1354.279f, 1465.979f, 1584.790f, 1710.778f, 1844.863f, 1985.746f, 2134.643f, 2291.610f, 2456.943f, 2630.653f, 2813.959f, 3006.631f, 3207.229f, 3417.641f, 3637.318f, 3865.785f, 4104.997f, 4354.938f, 4615.786f, 4885.335f, 5166.555f, 5458.021f, 5762.584f, 6077.881f, 6406.834f, 6746.435f, 7097.958f, 7462.579f, 7839.165f, 8231.629f, 8635.640f, 9052.000f, 9484.268f, 9929.111f, 10389.350f, 10862.059f, 11352.185f, 11856.823f, 12380.371f, 12920.401f, 13476.971f, 14053.087f, 14646.190f, 15258.426f, 15890.617f, 16544.433f, 17218.024f, 17913.465f, 18631.374f, 19374.983f, 20136.700f, 20927.783f, 21746.796f, 22590.880f, 23465.734f, 24372.274f, 25314.351f, 26290.488f, 27300.899f, 28347.512f, 29436.133f, 30567.840f, 31746.818f, 32982.664f, 34276.329f, 35624.859f, 37042.588f, 38546.609f, 40139.742f, 41837.980f, 43679.429f, 45892.130f, 400000.000f}, "raw centrality signal"}; // for QA
226234
@@ -334,6 +342,11 @@ struct derivedlambdakzeroanalysis {
334342
335343 void init (InitContext const &)
336344 {
345+ // setting CCDB service
346+ ccdb->setURL (ccdbConfigurations.ccdburl );
347+ ccdb->setCaching (true );
348+ ccdb->setFatalWhenNull (false );
349+
337350 // initialise bit masks
338351 maskTopological = (uint64_t (1 ) << selCosPA) | (uint64_t (1 ) << selRadius) | (uint64_t (1 ) << selDCANegToPV) | (uint64_t (1 ) << selDCAPosToPV) | (uint64_t (1 ) << selDCAV0Dau) | (uint64_t (1 ) << selRadiusMax);
339352 maskTopoNoV0Radius = (uint64_t (1 ) << selCosPA) | (uint64_t (1 ) << selDCANegToPV) | (uint64_t (1 ) << selDCAPosToPV) | (uint64_t (1 ) << selDCAV0Dau) | (uint64_t (1 ) << selRadiusMax);
@@ -425,6 +438,8 @@ struct derivedlambdakzeroanalysis {
425438 histos.get <TH1>(HIST (" hEventSelection" ))->GetXaxis ()->SetBinLabel (17 , " Below min occup." );
426439 histos.get <TH1>(HIST (" hEventSelection" ))->GetXaxis ()->SetBinLabel (18 , " Above max occup." );
427440 }
441+ histos.get <TH1>(HIST (" hEventSelection" ))->GetXaxis ()->SetBinLabel (19 , " Below min IR" );
442+ histos.get <TH1>(HIST (" hEventSelection" ))->GetXaxis ()->SetBinLabel (20 , " Above max IR" );
428443
429444 histos.add (" hEventCentrality" , " hEventCentrality" , kTH1F , {{101 , 0 .0f , 101 .0f }});
430445 histos.add (" hCentralityVsNch" , " hCentralityVsNch" , kTH2F , {{101 , 0 .0f , 101 .0f }, axisNch});
@@ -443,6 +458,9 @@ struct derivedlambdakzeroanalysis {
443458 histos.add (" hSelGapSide" , " Selected gap side; Entries" , kTH1F , {axisSelGap});
444459 histos.add (" hEventCentralityVsSelGapSide" , " ;Centrality (%); Selected gap side" , kTH2F , {{101 , 0 .0f , 101 .0f }, axisSelGap});
445460
461+ histos.add (" hInteractionRate" , " hInteractionRate" , kTH1F , {axisIRBinning});
462+ histos.add (" hCentralityVsInteractionRate" , " hCentralityVsInteractionRate" , kTH2F , {{101 , 0 .0f , 101 .0f }, axisIRBinning});
463+
446464 // for QA and test purposes
447465 auto hRawCentrality = histos.add <TH1>(" hRawCentrality" , " hRawCentrality" , kTH1F , {axisRawCentrality});
448466
@@ -1575,13 +1593,26 @@ struct derivedlambdakzeroanalysis {
15751593 histos.fill (HIST (" hEventSelection" ), 17 /* Above max occupancy */ );
15761594 }
15771595
1596+ double interactionRate = rateFetcher.fetch (ccdb.service , collision.timestamp (), collision.runNumber (), irSource) * 1 .e -3 ;
1597+ if (eventSelections.minIR >= 0 && interactionRate < eventSelections.minIR ) {
1598+ return false ;
1599+ }
1600+ if (fillHists)
1601+ histos.fill (HIST (" hEventSelection" ), 18 /* Below min IR */ );
1602+
1603+ if (eventSelections.maxIR >= 0 && interactionRate > eventSelections.maxIR ) {
1604+ return false ;
1605+ }
1606+ if (fillHists)
1607+ histos.fill (HIST (" hEventSelection" ), 19 /* Above max IR */ );
1608+
15781609 return true ;
15791610 }
15801611
15811612 // ______________________________________________________
15821613 // Simulated processing
15831614 // Return the list of indices to the recoed collision associated to a given MC collision.
1584- std::vector<int > getListOfRecoCollIndices (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraCollLabels> const & collisions)
1615+ std::vector<int > getListOfRecoCollIndices (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraStamps, aod:: StraCollLabels> const & collisions)
15851616 {
15861617 std::vector<int > listBestCollisionIdx (mcCollisions.size ());
15871618 for (auto const & mcCollision : mcCollisions) {
@@ -1611,7 +1642,7 @@ struct derivedlambdakzeroanalysis {
16111642 // ______________________________________________________
16121643 // Simulated processing
16131644 // Fill generated event information (for event loss/splitting estimation)
1614- void fillGeneratedEventProperties (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraCollLabels> const & collisions)
1645+ void fillGeneratedEventProperties (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraStamps, aod:: StraCollLabels> const & collisions)
16151646 {
16161647 std::vector<int > listBestCollisionIdx (mcCollisions.size ());
16171648 for (auto const & mcCollision : mcCollisions) {
@@ -1690,6 +1721,7 @@ struct derivedlambdakzeroanalysis {
16901721 centrality = hRawCentrality->GetBinContent (hRawCentrality->FindBin (doPPAnalysis ? collision.multFT0A () + collision.multFT0C () : collision.multFT0C ()));
16911722 }
16921723 float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange () : collision.trackOccupancyInTimeRange ();
1724+ double interactionRate = rateFetcher.fetch (ccdb.service , collision.timestamp (), collision.runNumber (), irSource) * 1 .e -3 ;
16931725
16941726 // gap side
16951727 int gapSide = collision.gapSide ();
@@ -1713,6 +1745,9 @@ struct derivedlambdakzeroanalysis {
17131745 histos.fill (HIST (" hEventOccupancy" ), collisionOccupancy);
17141746 histos.fill (HIST (" hCentralityVsOccupancy" ), centrality, collisionOccupancy);
17151747
1748+ histos.fill (HIST (" hInteractionRate" ), interactionRate);
1749+ histos.fill (HIST (" hCentralityVsInteractionRate" ), centrality, interactionRate);
1750+
17161751 // __________________________________________
17171752 // perform main analysis
17181753 int nK0Shorts = 0 ;
@@ -1770,6 +1805,7 @@ struct derivedlambdakzeroanalysis {
17701805 centrality = hRawCentrality->GetBinContent (hRawCentrality->FindBin (doPPAnalysis ? collision.multFT0A () + collision.multFT0C () : collision.multFT0C ()));
17711806 }
17721807 float collisionOccupancy = eventSelections.useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange () : collision.trackOccupancyInTimeRange ();
1808+ double interactionRate = rateFetcher.fetch (ccdb.service , collision.timestamp (), collision.runNumber (), irSource) * 1 .e -3 ;
17731809
17741810 // gap side
17751811 int gapSide = collision.gapSide ();
@@ -1793,6 +1829,9 @@ struct derivedlambdakzeroanalysis {
17931829 histos.fill (HIST (" hEventOccupancy" ), collisionOccupancy);
17941830 histos.fill (HIST (" hCentralityVsOccupancy" ), centrality, collisionOccupancy);
17951831
1832+ histos.fill (HIST (" hInteractionRate" ), interactionRate);
1833+ histos.fill (HIST (" hCentralityVsInteractionRate" ), centrality, interactionRate);
1834+
17961835 // __________________________________________
17971836 // perform main analysis
17981837 int nK0Shorts = 0 ;
@@ -1863,7 +1902,7 @@ struct derivedlambdakzeroanalysis {
18631902
18641903 // ______________________________________________________
18651904 // Simulated processing (subscribes to MC information too)
1866- void processGenerated (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::V0MCCores, aod::V0MCCollRefs> const & V0MCCores, soa::Join<aod::CascMCCores, aod::CascMCCollRefs> const & CascMCCores, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraCollLabels> const & collisions)
1905+ void processGenerated (soa::Join<aod::StraMCCollisions, aod::StraMCCollMults> const & mcCollisions, soa::Join<aod::V0MCCores, aod::V0MCCollRefs> const & V0MCCores, soa::Join<aod::CascMCCores, aod::CascMCCollRefs> const & CascMCCores, soa::Join<aod::StraCollisions, aod::StraCents, aod::StraEvSels, aod::StraStamps, aod:: StraCollLabels> const & collisions)
18671906 {
18681907 fillGeneratedEventProperties (mcCollisions, collisions);
18691908 std::vector<int > listBestCollisionIdx = getListOfRecoCollIndices (mcCollisions, collisions);
0 commit comments