|
18 | 18 | #include "Common/DataModel/EventSelection.h" |
19 | 19 | #include "Common/DataModel/ZDCLightIons.h" |
20 | 20 |
|
| 21 | +#include <CCDB/BasicCCDBManager.h> |
| 22 | +#include <DataFormatsParameters/GRPLHCIFData.h> |
21 | 23 | #include <Framework/AnalysisDataModel.h> |
22 | 24 | #include <Framework/AnalysisHelpers.h> |
23 | 25 | #include <Framework/AnalysisTask.h> |
@@ -45,6 +47,14 @@ using ColEvSels = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0As, aod::C |
45 | 47 | struct ZdcTaskLightIons { |
46 | 48 |
|
47 | 49 | 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; |
48 | 58 |
|
49 | 59 | // Configurable parameters |
50 | 60 | Configurable<int> nBinsTiming{"nBinsTiming", 200, "n bins for debunching histo"}; |
@@ -78,6 +88,14 @@ struct ZdcTaskLightIons { |
78 | 88 | nEventSelections |
79 | 89 | }; |
80 | 90 |
|
| 91 | + enum bcMaskBits { |
| 92 | + bcMask_beamB, |
| 93 | + bcMask_beamA, |
| 94 | + bcMask_beamC, |
| 95 | + bcMask_beamE, |
| 96 | + nBits |
| 97 | + }; |
| 98 | + |
81 | 99 | void init(InitContext const&) |
82 | 100 | { |
83 | 101 | 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 { |
158 | 176 |
|
159 | 177 | void processZDCBC(BCsRun3 const& bcs, aod::Zdcs const& /*zdcs*/) |
160 | 178 | { |
| 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 | + |
161 | 196 | for (const auto& bc : bcs) { |
| 197 | + |
162 | 198 | if (bc.has_zdc()) { |
163 | 199 |
|
| 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 | + |
164 | 219 | auto tdcZNA = bc.zdc().timeZNA(); |
165 | 220 | auto tdcZNC = bc.zdc().timeZNC(); |
166 | 221 | auto tdcZPA = bc.zdc().timeZPA(); |
@@ -225,8 +280,9 @@ struct ZdcTaskLightIons { |
225 | 280 | -1, -1, -1, |
226 | 281 | -1., |
227 | 282 | -1, -1, -1, |
228 | | - bc.timestamp(), |
229 | | - -1); |
| 283 | + timestampFromSOR, |
| 284 | + 0, |
| 285 | + maskSel); |
230 | 286 | } |
231 | 287 | } |
232 | 288 | } |
@@ -333,7 +389,8 @@ struct ZdcTaskLightIons { |
333 | 389 | zv, |
334 | 390 | centralityFT0C, centralityFT0A, centralityFT0M, |
335 | 391 | foundBC.timestamp(), |
336 | | - evSelection); |
| 392 | + evSelection, |
| 393 | + 0); |
337 | 394 | } |
338 | 395 | } |
339 | 396 | } |
|
0 commit comments