Skip to content

Commit 14d35cd

Browse files
Adding code to fill histograms for pileup and normalization
1 parent b4f0592 commit 14d35cd

File tree

1 file changed

+90
-19
lines changed

1 file changed

+90
-19
lines changed

PWGDQ/TableProducer/tableMaker_withAssoc.cxx

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "PWGDQ/DataModel/ReducedInfoTables.h"
3636

3737
#include "Common/CCDB/TriggerAliases.h"
38+
#include "Common/CCDB/ctpRateFetcher.h"
3839
#include "Common/Core/TableHelper.h"
3940
#include "Common/Core/Zorro.h"
4041
#include "Common/DataModel/Centrality.h"
@@ -54,6 +55,7 @@
5455
#include "DataFormatsITSMFT/ROFRecord.h"
5556
#include "DataFormatsParameters/GRPMagField.h"
5657
#include "DataFormatsParameters/GRPObject.h"
58+
#include "DataFormatsParameters/GRPLHCIFData.h"
5759
#include "DetectorsBase/GeometryManager.h"
5860
#include "DetectorsBase/Propagator.h"
5961
#include "DetectorsVertexing/PVertexerParams.h"
@@ -119,7 +121,7 @@ using MyMuonsWithCov = soa::Join<aod::FwdTracks, aod::FwdTracksCov, aod::FwdTrac
119121
using MyMuonsRealignWithCov = soa::Join<aod::FwdTracksReAlign, aod::FwdTrksCovReAlign, aod::FwdTracksDCA>;
120122
using MyMuonsColl = soa::Join<aod::FwdTracks, aod::FwdTracksDCA, aod::FwdTrkCompColls>;
121123
using MyMuonsCollWithCov = soa::Join<aod::FwdTracks, aod::FwdTracksCov, aod::FwdTracksDCA, aod::FwdTrkCompColls>;
122-
using MyBCs = soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse, aod::BcSels>;
124+
using MyBCs = soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse, aod::BcSels, aod::MatchedBCCollisionsSparseMulti>;
123125
using ExtBCs = soa::Join<aod::BCs, aod::Timestamps, aod::MatchedBCCollisionsSparseMulti>;
124126

125127
// Declaration of various bit maps containing information on which tables are included in a Join
@@ -154,6 +156,7 @@ constexpr static uint32_t gkMFTCovFillMap = VarManager::ObjTypes::TrackMFT | Var
154156
// Enum containing the ordering of statistics histograms to be written in the QA file
155157
enum SkimStatsHists {
156158
kStatsEvent = 0,
159+
kStatsBcs,
157160
kStatsTracks,
158161
kStatsMuons,
159162
kStatsOrphanTracks,
@@ -212,6 +215,7 @@ struct TableMaker {
212215
// Steer QA output
213216
struct : ConfigurableGroup {
214217
Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
218+
Configurable<bool> fConfigFillBcStat{"cfgFillBcStat", false, "If true, fill QA histograms for normalization studies (for OO and Pb-Pb)"};
215219
Configurable<bool> fConfigDetailedQA{"cfgDetailedQA", false, "If true, include more QA histograms (BeforeCuts classes)"};
216220
Configurable<std::string> fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"};
217221
Configurable<std::string> fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"};
@@ -338,6 +342,9 @@ struct TableMaker {
338342
Partition<MyBarrelTracksWithCov> tracksPosWithCov = (((aod::track::flags & static_cast<uint32_t>(o2::aod::track::PVContributor)) == static_cast<uint32_t>(o2::aod::track::PVContributor)) && (aod::track::tgl > static_cast<float>(0.05)));
339343
Partition<MyBarrelTracksWithCov> tracksNegWithCov = (((aod::track::flags & static_cast<uint32_t>(o2::aod::track::PVContributor)) == static_cast<uint32_t>(o2::aod::track::PVContributor)) && (aod::track::tgl < static_cast<float>(-0.05)));
340344

345+
ctpRateFetcher mRateFetcher;
346+
parameters::GRPLHCIFData* mLHCIFdata = nullptr;
347+
341348
struct {
342349
std::map<int32_t, float> oMeanTimeShortA;
343350
std::map<int32_t, float> oMeanTimeShortC;
@@ -569,6 +576,7 @@ struct TableMaker {
569576

570577
// Create statistics histograms which will be stored in the QA output
571578
// Event statistics: kStatsEvent
579+
// BC statistics + Pileup calculation: kStatsBcs
572580
// Track statistics: kStatsTracks
573581
// Muon statistics: kStatsMuons
574582
// Orphan track statistics: kStatsOrphanTracks
@@ -588,6 +596,14 @@ struct TableMaker {
588596
histEvents->GetYaxis()->SetBinLabel(o2::aod::evsel::kNsel + 1, "Total");
589597
fStatsList->AddAt(histEvents, kStatsEvent);
590598

599+
std::vector<TString> bcLabels{"all", "tvx", "sel8", "sel8 & Cent", "sel8 & Scent", "sel8 & (Cent | Scent)", "sel8 & (ZNA & ZNC)"};
600+
TH2D* histBcs = new TH2D("BcStats", "Bc statistics;;#mu", bcLabels.size(), -0.5, bcLabels.size() - 0.5, 3000, 0, 0.3);
601+
ib = 1;
602+
for (auto label = bcLabels.begin(); label != bcLabels.end(); label++, ib++) {
603+
histBcs->GetXaxis()->SetBinLabel(ib, (*label).Data());
604+
}
605+
fStatsList->AddAt(histBcs, kStatsBcs);
606+
591607
// Track statistics: one bin for each track selection and 5 bins for V0 tags (gamma, K0s, Lambda, anti-Lambda, Omega)
592608
TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0);
593609
ib = 1;
@@ -794,6 +810,23 @@ struct TableMaker {
794810
} // end loop over collisions
795811
}
796812

813+
// Function to compute the mu for pileup estimation, taken from EM code
814+
double calculateMu(const auto& bc)
815+
{
816+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
817+
818+
uint64_t timeStamp = bc.timestamp();
819+
std::map<std::string, std::string> metadata;
820+
mLHCIFdata = ccdbMgr.getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata);
821+
822+
auto bfilling = mLHCIFdata->getBunchFilling();
823+
double nbc = bfilling.getFilledBCs().size();
824+
double tvxRate = mRateFetcher.fetch(&ccdbMgr, timeStamp, bc.runNumber(), "T0VTX");
825+
double nTriggersPerFilledBC = tvxRate / nbc / o2::constants::lhc::LHCRevFreq;
826+
double mu = -std::log(1 - nTriggersPerFilledBC);
827+
return mu;
828+
}
829+
797830
template <uint32_t TEventFillMap, typename TEvents, typename TBCs,
798831
typename TZdcs, typename TFt0s, typename TFv0as, typename TFdds>
799832
void skimCollisions(TEvents const& collisions, TBCs const& bcs, TZdcs const& /*zdcs*/,
@@ -820,6 +853,44 @@ struct TableMaker {
820853
float centFT0A = -1.0;
821854
float centFT0M = -1.0;
822855

856+
if (fConfigHistOutput.fConfigFillBcStat) {
857+
for (const auto& bc : bcs) {
858+
double muTVX = calculateMu(bc);
859+
860+
if (bc.has_ft0()) {
861+
std::bitset<8> fT0Triggers = bc.ft0().triggerMask();
862+
bool isTvx = fT0Triggers[o2::ft0::Triggers::bitVertex];
863+
bool isSemiCentral = fT0Triggers[o2::ft0::Triggers::bitSCen];
864+
bool isCentral = fT0Triggers[o2::ft0::Triggers::bitCen];
865+
866+
bool noBorder = bc.selection_bit(aod::evsel::kNoTimeFrameBorder) && bc.selection_bit(aod::evsel::kNoITSROFrameBorder);
867+
//bool isTriggerTVX = bc.selection_bit(aod::evsel::kIsTriggerTVX); // difference w.r.t fT0Triggers[o2::ft0::Triggers::bitVertex] ?
868+
bool isTriggerZNA = bc.selection_bit(aod::evsel::kIsBBZNA);
869+
bool isTriggerZNC = bc.selection_bit(aod::evsel::kIsBBZNC);
870+
871+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(0.0, muTVX);
872+
if (isTvx) {
873+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(1.0, muTVX);
874+
if (noBorder) {
875+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(2.0, muTVX);
876+
if (isCentral) {
877+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(3.0, muTVX);
878+
}
879+
if (isSemiCentral) {
880+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(4.0, muTVX);
881+
}
882+
if (isCentral || isSemiCentral) {
883+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(5.0, muTVX);
884+
}
885+
if (isTriggerZNA && isTriggerZNC) {
886+
(reinterpret_cast<TH1D*>(fStatsList->At(kStatsBcs)))->Fill(6.0, muTVX);
887+
}
888+
}
889+
}
890+
}
891+
}
892+
}
893+
823894
for (const auto& collision : collisions) {
824895

825896
for (int i = 0; i < o2::aod::evsel::kNsel; i++) {
@@ -1591,7 +1662,7 @@ struct TableMaker {
15911662
}
15921663

15931664
// produce the full DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), subscribe to the DQ event filter (filter-pp or filter-PbPb)
1594-
void processPPWithFilter(MyEventsWithMultsAndFilter const& collisions, BCsWithTimestamps const& bcs,
1665+
void processPPWithFilter(MyEventsWithMultsAndFilter const& collisions, MyBCs const& bcs,
15951666
MyBarrelTracksWithCov const& tracksBarrel,
15961667
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
15971668
TrackAssoc const& trackAssocs, FwdTrackAssoc const& fwdTrackAssocs,
@@ -1609,14 +1680,14 @@ struct TableMaker {
16091680
}
16101681

16111682
// produce the muon-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), subscribe to the DQ event filter (filter-pp or filter-PbPb)
1612-
void processPPWithFilterMuonOnly(MyEventsWithMultsAndFilter const& collisions, BCsWithTimestamps const& bcs,
1683+
void processPPWithFilterMuonOnly(MyEventsWithMultsAndFilter const& collisions, MyBCs const& bcs,
16131684
MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs)
16141685
{
16151686
fullSkimming<gkEventFillMapWithMultsAndEventFilter, 0u, gkMuonFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr);
16161687
}
16171688

16181689
// produce the muon+mft DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), subscribe to the DQ event filter (filter-pp or filter-PbPb)
1619-
void processPPWithFilterMuonMFT(MyEventsWithMultsAndFilter const& collisions, BCsWithTimestamps const& bcs,
1690+
void processPPWithFilterMuonMFT(MyEventsWithMultsAndFilter const& collisions, MyBCs const& bcs,
16201691
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
16211692
FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs)
16221693
{
@@ -1640,37 +1711,37 @@ struct TableMaker {
16401711
}
16411712

16421713
// produce the muon-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data
1643-
void processPPMuonOnly(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs,
1714+
void processPPMuonOnly(MyEventsWithMults const& collisions, MyBCs const& bcs,
16441715
MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs)
16451716
{
16461717
fullSkimming<gkEventFillMapWithMults, 0u, gkMuonFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr);
16471718
}
16481719

16491720
// produce the realigned muon-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data
1650-
void processPPRealignedMuonOnly(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs,
1721+
void processPPRealignedMuonOnly(MyEventsWithMults const& collisions, MyBCs const& bcs,
16511722
MyMuonsRealignWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs)
16521723
{
16531724
fullSkimming<gkEventFillMapWithMults, 0u, gkMuonRealignFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr);
16541725
}
16551726

16561727
// produce the muon+mft DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data
1657-
void processPPMuonMFT(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs,
1728+
void processPPMuonMFT(MyEventsWithMults const& collisions, MyBCs const& bcs,
16581729
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
16591730
FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs)
16601731
{
16611732
fullSkimming<gkEventFillMapWithMults, 0u, gkMuonFillMapWithCov, gkMFTFillMap>(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, nullptr, nullptr, nullptr, nullptr);
16621733
}
16631734

16641735
// Central barrel multiplicity estimation
1665-
void processPPMuonMFTWithMultsExtra(MyEventsWithMultsExtra const& collisions, BCsWithTimestamps const& bcs,
1736+
void processPPMuonMFTWithMultsExtra(MyEventsWithMultsExtra const& collisions, MyBCs const& bcs,
16661737
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
16671738
FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs)
16681739
{
16691740
fullSkimming<gkEventFillMapWithMultsExtra, 0u, gkMuonFillMapWithCov, gkMFTFillMap>(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, nullptr, nullptr, nullptr, nullptr);
16701741
}
16711742

16721743
// produce the full DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1673-
void processPbPb(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1744+
void processPbPb(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
16741745
MyBarrelTracksWithCov const& tracksBarrel,
16751746
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
16761747
TrackAssoc const& trackAssocs, FwdTrackAssoc const& fwdTrackAssocs,
@@ -1680,15 +1751,15 @@ struct TableMaker {
16801751
}
16811752

16821753
// produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1683-
void processPbPbBarrelOnly(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1754+
void processPbPbBarrelOnly(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
16841755
MyBarrelTracksWithCov const& tracksBarrel,
16851756
TrackAssoc const& trackAssocs)
16861757
{
16871758
fullSkimming<gkEventFillMapWithCentAndMults, gkTrackFillMapWithCov, 0u, 0u>(collisions, bcs, nullptr, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
16881759
}
16891760

16901761
// produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no TOF
1691-
void processPbPbBarrelOnlyNoTOF(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1762+
void processPbPbBarrelOnlyNoTOF(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
16921763
MyBarrelTracksWithCovNoTOF const& tracksBarrel,
16931764
TrackAssoc const& trackAssocs)
16941765
{
@@ -1706,7 +1777,7 @@ struct TableMaker {
17061777
}
17071778

17081779
// produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1709-
void processPbPbBarrelOnlyWithV0Bits(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1780+
void processPbPbBarrelOnlyWithV0Bits(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
17101781
MyBarrelTracksWithV0Bits const& tracksBarrel,
17111782
TrackAssoc const& trackAssocs)
17121783
{
@@ -1715,7 +1786,7 @@ struct TableMaker {
17151786
}
17161787

17171788
// produce the barrel only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1718-
void processPbPbBarrelOnlyWithV0BitsNoTOF(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1789+
void processPbPbBarrelOnlyWithV0BitsNoTOF(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
17191790
MyBarrelTracksWithV0BitsNoTOF const& tracksBarrel,
17201791
TrackAssoc const& trackAssocs)
17211792
{
@@ -1724,29 +1795,29 @@ struct TableMaker {
17241795
}
17251796

17261797
// produce the muon only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1727-
void processPbPbMuonOnly(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1728-
MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs)
1798+
void processPbPbMuonOnly(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
1799+
MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs, aod::FT0s& ft0s, aod::FV0As& fv0as, aod::FDDs& fdds)
17291800
{
1730-
fullSkimming<gkEventFillMapWithCentAndMults, 0u, gkMuonFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr);
1801+
fullSkimming<gkEventFillMapWithCentAndMults, 0u, gkMuonFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, ft0s, fv0as, fdds);
17311802
}
17321803

17331804
// produce the realigned muon only DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1734-
void processPbPbRealignedMuonOnly(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1805+
void processPbPbRealignedMuonOnly(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
17351806
MyMuonsRealignWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs)
17361807
{
17371808
fullSkimming<gkEventFillMapWithCentAndMults, 0u, gkMuonRealignFillMapWithCov, 0u>(collisions, bcs, nullptr, nullptr, muons, nullptr, nullptr, fwdTrackAssocs, nullptr, nullptr, nullptr, nullptr, nullptr);
17381809
}
17391810

17401811
// produce the muon+mft DQ skimmed data model typically for Pb-Pb (with centrality), no subscribtion to the DQ event filter
1741-
void processPbPbMuonMFT(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs,
1812+
void processPbPbMuonMFT(MyEventsWithCentAndMults const& collisions, MyBCs const& bcs,
17421813
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
17431814
FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs)
17441815
{
17451816
fullSkimming<gkEventFillMapWithCentAndMults, 0u, gkMuonFillMapWithCov, gkMFTFillMap>(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs, nullptr, nullptr, nullptr, nullptr);
17461817
}
17471818

17481819
// produce the muon+mft DQ skimmed data model typically including MFT covariances
1749-
void processPPMuonRefit(MyEventsWithMults const& collisions, BCsWithTimestamps const& bcs,
1820+
void processPPMuonRefit(MyEventsWithMults const& collisions, MyBCs const& bcs,
17501821
MyMuonsWithCov const& muons, MFTTracks const& mftTracks,
17511822
FwdTrackAssoc const& fwdTrackAssocs, MFTTrackAssoc const& mftAssocs,
17521823
aod::MFTTracksCov const& mftCovs)

0 commit comments

Comments
 (0)