Skip to content

Commit cc25f8a

Browse files
authored
[Common] Updated chain to analyze ZDC in light ion systems (#18131)
1 parent 858ef22 commit cc25f8a

3 files changed

Lines changed: 588 additions & 92 deletions

File tree

‎Common/DataModel/ZDCLightIons.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ DECLARE_SOA_COLUMN(CentralityFt0c, centralityFt0c, float); //! Centrality
5656
DECLARE_SOA_COLUMN(CentralityFt0a, centralityFt0a, float); //! Centrality
5757
DECLARE_SOA_COLUMN(CentralityFt0m, centralityFt0m, float); //! Centrality
5858
DECLARE_SOA_COLUMN(Timestamp, timestamp, uint64_t); //! Timestamp
59-
DECLARE_SOA_COLUMN(SelectionBits, selectionBits, uint8_t); //! Selection Flags
59+
DECLARE_SOA_COLUMN(SelectionBits, selectionBits, uint8_t); //! Selection flags x collisions
60+
DECLARE_SOA_COLUMN(BcMask, bcMask, uint8_t); //! Selection flags x BC
6061
} // namespace zdclightions
6162

6263
DECLARE_SOA_TABLE(ZDCLightIons, "AOD", "ZDCTABLELIGHTIONS",
@@ -92,7 +93,8 @@ DECLARE_SOA_TABLE(ZDCLightIons, "AOD", "ZDCTABLELIGHTIONS",
9293
zdclightions::CentralityFt0a,
9394
zdclightions::CentralityFt0m,
9495
zdclightions::Timestamp,
95-
zdclightions::SelectionBits);
96+
zdclightions::SelectionBits,
97+
zdclightions::BcMask);
9698
} // namespace o2::aod
9799

98100
#endif // COMMON_DATAMODEL_ZDCLIGHTIONS_H_

‎Common/TableProducer/zdcTaskLightIons.cxx‎

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "Common/DataModel/EventSelection.h"
1919
#include "Common/DataModel/ZDCLightIons.h"
2020

21+
#include <CCDB/BasicCCDBManager.h>
22+
#include <CommonConstants/LHCConstants.h>
23+
#include <DataFormatsParameters/GRPLHCIFData.h>
2124
#include <Framework/AnalysisDataModel.h>
2225
#include <Framework/AnalysisHelpers.h>
2326
#include <Framework/AnalysisTask.h>
@@ -31,7 +34,10 @@
3134
#include <TH1.h>
3235
#include <TH2.h>
3336

37+
#include <bitset>
3438
#include <cstdint>
39+
#include <map>
40+
#include <string>
3541

3642
using namespace o2;
3743
using namespace o2::aod;
@@ -45,6 +51,14 @@ using ColEvSels = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0As, aod::C
4551
struct ZdcTaskLightIons {
4652

4753
Produces<aod::ZDCLightIons> zdcTableLI;
54+
Service<o2::ccdb::BasicCCDBManager> ccdb;
55+
static const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches;
56+
std::bitset<nBCsPerOrbit> beamPatternA;
57+
std::bitset<nBCsPerOrbit> beamPatternC;
58+
std::bitset<nBCsPerOrbit> bcPatternB;
59+
std::bitset<nBCsPerOrbit> bcPatternA;
60+
std::bitset<nBCsPerOrbit> bcPatternC;
61+
std::bitset<nBCsPerOrbit> bcPatternE;
4862

4963
// Configurable parameters
5064
Configurable<int> nBinsTiming{"nBinsTiming", 200, "n bins for debunching histo"};
@@ -78,6 +92,14 @@ struct ZdcTaskLightIons {
7892
nEventSelections
7993
};
8094

95+
enum bcMaskBits {
96+
bcMask_beamB,
97+
bcMask_beamA,
98+
bcMask_beamC,
99+
bcMask_beamE,
100+
nBits
101+
};
102+
81103
void init(InitContext const&)
82104
{
83105
registry.add("zdcDebunchHist", "ZN sum vs. diff; ZNA-ZNC (ns); ZNA+ZNC (ns)", {HistType::kTH2D, {{nBinsTiming, -20., 20.}, {nBinsTiming, -20., 20.}}});
@@ -158,9 +180,46 @@ struct ZdcTaskLightIons {
158180

159181
void processZDCBC(BCsRun3 const& bcs, aod::Zdcs const& /*zdcs*/)
160182
{
183+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
184+
uint64_t timeStamp = bcs.iteratorAt(0).timestamp();
185+
std::map<std::string, std::string> metadata;
186+
// use getSpecific to set metadata to avoid crashes related to specific run number
187+
auto grplhcif = ccdbMgr.getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata);
188+
// auto grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp);
189+
if (grplhcif == nullptr) {
190+
LOG(fatal) << "GRPLHCIFData not in database, timestamp:" << timeStamp;
191+
}
192+
193+
beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0);
194+
beamPatternC = grplhcif->getBunchFilling().getBeamPattern(1);
195+
bcPatternB = grplhcif->getBunchFilling().getBCPattern();
196+
bcPatternA = beamPatternA & ~beamPatternC;
197+
bcPatternC = ~beamPatternA & beamPatternC;
198+
bcPatternE = ~beamPatternA & ~beamPatternC;
199+
161200
for (const auto& bc : bcs) {
201+
162202
if (bc.has_zdc()) {
163203

204+
// int64_t timestamp = bc.timestamp();
205+
auto timestampFromSOR = (bc.timestamp() - grplhcif->getFillNumberTime()) / 1e3; // Convert to seconds
206+
207+
int bcInOrbit = bc.globalBC() % nBCsPerOrbit;
208+
209+
uint8_t maskSel = 0;
210+
if (bcPatternB[bcInOrbit]) {
211+
maskSel |= (uint8_t)(0x1u << bcMask_beamB);
212+
}
213+
if (bcPatternA[bcInOrbit]) {
214+
maskSel |= (uint8_t)(0x1u << bcMask_beamA);
215+
}
216+
if (bcPatternC[bcInOrbit]) {
217+
maskSel |= (uint8_t)(0x1u << bcMask_beamC);
218+
}
219+
if (bcPatternE[bcInOrbit]) {
220+
maskSel |= (uint8_t)(0x1u << bcMask_beamE);
221+
}
222+
164223
auto tdcZNA = bc.zdc().timeZNA();
165224
auto tdcZNC = bc.zdc().timeZNC();
166225
auto tdcZPA = bc.zdc().timeZPA();
@@ -225,8 +284,9 @@ struct ZdcTaskLightIons {
225284
-1, -1, -1,
226285
-1.,
227286
-1, -1, -1,
228-
bc.timestamp(),
229-
-1);
287+
timestampFromSOR,
288+
0,
289+
maskSel);
230290
}
231291
}
232292
}
@@ -333,7 +393,8 @@ struct ZdcTaskLightIons {
333393
zv,
334394
centralityFT0C, centralityFT0A, centralityFT0M,
335395
foundBC.timestamp(),
336-
evSelection);
396+
evSelection,
397+
0);
337398
}
338399
}
339400
}

0 commit comments

Comments
 (0)