Skip to content

Commit

Permalink
getForTimeStamp instead of getSpecific
Browse files Browse the repository at this point in the history
  • Loading branch information
ekryshen committed Dec 20, 2024
1 parent 1993712 commit c4effc3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 71 deletions.
5 changes: 1 addition & 4 deletions Common/TableProducer/eventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
///
/// \author Evgeny Kryshen <[email protected]> and Igor Altsybeev <[email protected]>

#include <string>
#include <vector>
#include <map>

Expand Down Expand Up @@ -291,9 +290,7 @@ struct BcSelectionTask {
int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamC);
isPP = beamZ1 == 1 && beamZ2 == 1;
// prepare map of inactive chips
std::map<std::string, std::string> metadata;
metadata["runNumber"] = Form("%d", run);
auto itsDeadMap = ccdb->getSpecific<o2::itsmft::TimeDeadMap>("ITS/Calib/TimeDeadMap", ts, metadata);
auto itsDeadMap = ccdb->getForTimeStamp<o2::itsmft::TimeDeadMap>("ITS/Calib/TimeDeadMap", ts);
auto itsDeadMapOrbits = itsDeadMap->getEvolvingMapKeys(); // roughly every second, ~350 TFs = 350x32 orbits
std::vector<uint16_t> vClosest; // temporary vector of inactive chip ids for the current orbit range
for (const auto& orbit : itsDeadMapOrbits) {
Expand Down
132 changes: 65 additions & 67 deletions DPG/Tasks/AOTEvent/eventSelectionQa.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -577,80 +577,78 @@ struct EventSelectionQaTask {
}

// fill ITS dead maps
std::map<std::string, std::string> metadata;
metadata["runNumber"] = Form("%d", run);
o2::itsmft::TimeDeadMap* itsDeadMap = ccdb->getSpecific<o2::itsmft::TimeDeadMap>("ITS/Calib/TimeDeadMap", (tsSOR + tsEOR) / 2, metadata);

o2::itsmft::TimeDeadMap* itsDeadMap = ccdb->getForTimeStamp<o2::itsmft::TimeDeadMap>("ITS/Calib/TimeDeadMap", (tsSOR + tsEOR) / 2);
auto itsDeadMapOrbits = itsDeadMap->getEvolvingMapKeys(); // roughly every second, ~350 TFs = 350x32 orbits
std::vector<double> itsDeadMapOrbitsDouble(itsDeadMapOrbits.begin(), itsDeadMapOrbits.end());
const AxisSpec axisItsDeadMapOrbits{itsDeadMapOrbitsDouble};

for (int l = 0; l < o2::itsmft::ChipMappingITS::NLayers; l++) {
int nChips = o2::itsmft::ChipMappingITS::getNChipsOnLayer(l);
double idFirstChip = o2::itsmft::ChipMappingITS::getFirstChipsOnLayer(l);
// int nStaves = o2::itsmft::ChipMappingITS::getNStavesOnLr(l);
// double idFirstStave = o2::itsmft::ChipMappingITS::getFirstStavesOnLr(l);
histos.add(Form("hDeadChipsVsOrbitL%d", l), Form(";orbit; chip; Layer %d", l), kTH2C, {axisItsDeadMapOrbits, {nChips, idFirstChip, idFirstChip + nChips}});
histos.add(Form("hNumberOfInactiveChipsVsOrbitL%d", l), Form(";orbit; Layer %d", l), kTH1I, {axisItsDeadMapOrbits});
}
if (itsDeadMapOrbits.size() > 0) {
std::vector<double> itsDeadMapOrbitsDouble(itsDeadMapOrbits.begin(), itsDeadMapOrbits.end());
const AxisSpec axisItsDeadMapOrbits{itsDeadMapOrbitsDouble};

for (int l = 0; l < o2::itsmft::ChipMappingITS::NLayers; l++) {
int nChips = o2::itsmft::ChipMappingITS::getNChipsOnLayer(l);
double idFirstChip = o2::itsmft::ChipMappingITS::getFirstChipsOnLayer(l);
// int nStaves = o2::itsmft::ChipMappingITS::getNStavesOnLr(l);
// double idFirstStave = o2::itsmft::ChipMappingITS::getFirstStavesOnLr(l);
histos.add(Form("hDeadChipsVsOrbitL%d", l), Form(";orbit; chip; Layer %d", l), kTH2C, {axisItsDeadMapOrbits, {nChips, idFirstChip, idFirstChip + nChips}});
histos.add(Form("hNumberOfInactiveChipsVsOrbitL%d", l), Form(";orbit; Layer %d", l), kTH1I, {axisItsDeadMapOrbits});
}

std::vector<uint16_t> vClosest;
std::bitset<o2::itsmft::ChipMappingITS::getNChips()> alwaysDeadChips;
std::bitset<o2::itsmft::ChipMappingITS::getNChips()> deadChips;
alwaysDeadChips.set();
for (const auto& orbit : itsDeadMapOrbits) {
itsDeadMap->getMapAtOrbit(orbit, vClosest);
deadChips.reset();
for (size_t iel = 0; iel < vClosest.size(); iel++) {
uint16_t w1 = vClosest[iel];
bool isLastInSequence = (w1 & 0x8000) == 0;
uint16_t w2 = isLastInSequence ? w1 + 1 : vClosest[iel + 1];
uint16_t chipId1 = w1 & 0x7FFF;
uint16_t chipId2 = w2 & 0x7FFF;
// dead chips are stored as ranges
// vClosest contains first and last chip ids in the range
// last chip id in the range is marked with 0x8000 bit set to 1
for (int chipId = chipId1; chipId < chipId2; chipId++) {
histos.fill(HIST("hDeadChipsVsOrbitL0"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL1"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL2"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL3"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL4"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL5"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL6"), orbit, chipId, 1);
deadChips.set(chipId);
std::vector<uint16_t> vClosest;
std::bitset<o2::itsmft::ChipMappingITS::getNChips()> alwaysDeadChips;
std::bitset<o2::itsmft::ChipMappingITS::getNChips()> deadChips;
alwaysDeadChips.set();
for (const auto& orbit : itsDeadMapOrbits) {
itsDeadMap->getMapAtOrbit(orbit, vClosest);
deadChips.reset();
for (size_t iel = 0; iel < vClosest.size(); iel++) {
uint16_t w1 = vClosest[iel];
bool isLastInSequence = (w1 & 0x8000) == 0;
uint16_t w2 = isLastInSequence ? w1 + 1 : vClosest[iel + 1];
uint16_t chipId1 = w1 & 0x7FFF;
uint16_t chipId2 = w2 & 0x7FFF;
// dead chips are stored as ranges
// vClosest contains first and last chip ids in the range
// last chip id in the range is marked with 0x8000 bit set to 1
for (int chipId = chipId1; chipId < chipId2; chipId++) {
histos.fill(HIST("hDeadChipsVsOrbitL0"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL1"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL2"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL3"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL4"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL5"), orbit, chipId, 1);
histos.fill(HIST("hDeadChipsVsOrbitL6"), orbit, chipId, 1);
deadChips.set(chipId);
}
}
alwaysDeadChips &= deadChips; // chips active in the current orbit are set to 0
}
alwaysDeadChips &= deadChips; // chips active in the current orbit are set to 0
}
// std::cout << alwaysDeadChips << std::endl;

// filling histograms with number of inactive chips per layer vs orbit (ignoring always inactive)
for (const auto& orbit : itsDeadMapOrbits) {
itsDeadMap->getMapAtOrbit(orbit, vClosest);
std::vector<int16_t> nInactiveChips(o2::itsmft::ChipMappingITS::NLayers, 0);
for (size_t iel = 0; iel < vClosest.size(); iel++) {
uint16_t w1 = vClosest[iel];
bool isLastInSequence = (w1 & 0x8000) == 0;
uint16_t w2 = isLastInSequence ? w1 + 1 : vClosest[iel + 1];
uint16_t chipId1 = w1 & 0x7FFF;
uint16_t chipId2 = w2 & 0x7FFF;
for (int chipId = chipId1; chipId < chipId2; chipId++) {
if (alwaysDeadChips[chipId]) // skip always inactive chips
continue;
int32_t layer = o2::itsmft::ChipMappingITS::getLayer(chipId);
nInactiveChips[layer]++;
// std::cout << alwaysDeadChips << std::endl;

// filling histograms with number of inactive chips per layer vs orbit (ignoring always inactive)
for (const auto& orbit : itsDeadMapOrbits) {
itsDeadMap->getMapAtOrbit(orbit, vClosest);
std::vector<int16_t> nInactiveChips(o2::itsmft::ChipMappingITS::NLayers, 0);
for (size_t iel = 0; iel < vClosest.size(); iel++) {
uint16_t w1 = vClosest[iel];
bool isLastInSequence = (w1 & 0x8000) == 0;
uint16_t w2 = isLastInSequence ? w1 + 1 : vClosest[iel + 1];
uint16_t chipId1 = w1 & 0x7FFF;
uint16_t chipId2 = w2 & 0x7FFF;
for (int chipId = chipId1; chipId < chipId2; chipId++) {
if (alwaysDeadChips[chipId]) // skip always inactive chips
continue;
int32_t layer = o2::itsmft::ChipMappingITS::getLayer(chipId);
nInactiveChips[layer]++;
}
}
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL0"), orbit, nInactiveChips[0]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL1"), orbit, nInactiveChips[1]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL2"), orbit, nInactiveChips[2]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL3"), orbit, nInactiveChips[3]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL4"), orbit, nInactiveChips[4]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL5"), orbit, nInactiveChips[5]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL6"), orbit, nInactiveChips[6]);
}
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL0"), orbit, nInactiveChips[0]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL1"), orbit, nInactiveChips[1]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL2"), orbit, nInactiveChips[2]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL3"), orbit, nInactiveChips[3]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL4"), orbit, nInactiveChips[4]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL5"), orbit, nInactiveChips[5]);
histos.fill(HIST("hNumberOfInactiveChipsVsOrbitL6"), orbit, nInactiveChips[6]);
}

} // run >= 500000

// create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available
Expand Down

0 comments on commit c4effc3

Please sign in to comment.