Skip to content

Commit 67e476f

Browse files
authored
Access CCDB to account for BC mask
Added CCDB manager and GRPLHCIFData handling to processZDCBC method. Introduced new bitset patterns for beam and bunch configurations. Needed for cross-section calculation in light ions
1 parent e1e71bf commit 67e476f

1 file changed

Lines changed: 60 additions & 3 deletions

File tree

‎Common/TableProducer/zdcTaskLightIons.cxx‎

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

21+
#include <CCDB/BasicCCDBManager.h>
22+
#include <DataFormatsParameters/GRPLHCIFData.h>
2123
#include <Framework/AnalysisDataModel.h>
2224
#include <Framework/AnalysisHelpers.h>
2325
#include <Framework/AnalysisTask.h>
@@ -45,6 +47,14 @@ using ColEvSels = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0As, aod::C
4547
struct ZdcTaskLightIons {
4648

4749
Produces<aod::ZDCLightIons> zdcTableLI;
50+
Service<o2::ccdb::BasicCCDBManager> ccdb;
51+
static const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches;
52+
std::bitset<nBCsPerOrbit> beamPatternA;
53+
std::bitset<nBCsPerOrbit> beamPatternC;
54+
std::bitset<nBCsPerOrbit> bcPatternB;
55+
std::bitset<nBCsPerOrbit> bcPatternA;
56+
std::bitset<nBCsPerOrbit> bcPatternC;
57+
std::bitset<nBCsPerOrbit> bcPatternE;
4858

4959
// Configurable parameters
5060
Configurable<int> nBinsTiming{"nBinsTiming", 200, "n bins for debunching histo"};
@@ -78,6 +88,14 @@ struct ZdcTaskLightIons {
7888
nEventSelections
7989
};
8090

91+
enum bcMaskBits {
92+
bcMask_beamB,
93+
bcMask_beamA,
94+
bcMask_beamC,
95+
bcMask_beamE,
96+
nBits
97+
};
98+
8199
void init(InitContext const&)
82100
{
83101
registry.add("zdcDebunchHist", "ZN sum vs. diff; ZNA-ZNC (ns); ZNA+ZNC (ns)", {HistType::kTH2D, {{nBinsTiming, -20., 20.}, {nBinsTiming, -20., 20.}}});
@@ -158,9 +176,46 @@ struct ZdcTaskLightIons {
158176

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

200+
// int64_t timestamp = bc.timestamp();
201+
auto timestampFromSOR = (bc.timestamp() - grplhcif->getFillNumberTime()) / 1e3; // Convert to seconds
202+
203+
int bcInOrbit = bc.globalBC() % nBCsPerOrbit;
204+
205+
uint8_t maskSel = 0;
206+
if (bcPatternB[bcInOrbit]) {
207+
maskSel |= (uint8_t)(0x1u << bcMask_beamB);
208+
}
209+
if (bcPatternA[bcInOrbit]) {
210+
maskSel |= (uint8_t)(0x1u << bcMask_beamA);
211+
}
212+
if (bcPatternC[bcInOrbit]) {
213+
maskSel |= (uint8_t)(0x1u << bcMask_beamC);
214+
}
215+
if (bcPatternE[bcInOrbit]) {
216+
maskSel |= (uint8_t)(0x1u << bcMask_beamE);
217+
}
218+
164219
auto tdcZNA = bc.zdc().timeZNA();
165220
auto tdcZNC = bc.zdc().timeZNC();
166221
auto tdcZPA = bc.zdc().timeZPA();
@@ -225,8 +280,9 @@ struct ZdcTaskLightIons {
225280
-1, -1, -1,
226281
-1.,
227282
-1, -1, -1,
228-
bc.timestamp(),
229-
-1);
283+
timestampFromSOR,
284+
0,
285+
maskSel);
230286
}
231287
}
232288
}
@@ -333,7 +389,8 @@ struct ZdcTaskLightIons {
333389
zv,
334390
centralityFT0C, centralityFT0A, centralityFT0M,
335391
foundBC.timestamp(),
336-
evSelection);
392+
evSelection,
393+
0);
337394
}
338395
}
339396
}

0 commit comments

Comments
 (0)