24 #include <unordered_map> 55 #define LOGERROR(x) edm::LogError(x) 56 #define LOGWARNING(x) edm::LogWarning(x) 57 #define LOGINFO(x) edm::LogInfo(x) 58 #define LOGVERBATIM(x) edm::LogVerbatim(x) 59 #define LOGDEBUG(x) LogDebug(x) 63 #include "TObjString.h" 72 static const std::array<std::string, 5>
titles = {{
"noise",
"pedestals",
"G1 gain",
"G2 gain",
"Quality"}};
73 static const std::array<std::string, 5>
units = {{
"[ADC counts]",
"[ADC counts]",
"",
"",
""}};
76 template <
typename... Args>
78 using unused =
bool[];
80 std::size_t
ui{
ret.size()};
81 (
void)unused{
true, (
ret.set(--
ui, as),
true)...};
108 template <
class Payload>
139 doNoise_(iConfig.getParameter<
bool>(
"doNoise")),
140 doPeds_(iConfig.getParameter<
bool>(
"doPeds")),
141 doG1_(iConfig.getParameter<
bool>(
"doG1")),
142 doG2_(iConfig.getParameter<
bool>(
"doG2")),
143 doBadComps_(iConfig.getParameter<
bool>(
"doBadComps")),
164 std::vector<edm::ParameterSet> selconfigs = iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"selections");
165 for (std::vector<edm::ParameterSet>::const_iterator selconfig = selconfigs.begin(); selconfig != selconfigs.end();
180 const auto& badComponentsList =
obj->getBadComponentList();
182 for (
const auto& bc : badComponentsList) {
184 <<
" bad APVs:" << bc.BadApvs <<
" bad Fibers:" << bc.BadFibers
185 <<
" bad Module:" << bc.BadModule;
189 std::vector<uint32_t> activeDetIds;
191 badComponentsList.end(),
192 std::back_inserter(activeDetIds),
195 for (
const uint32_t& detid : activeDetIds) {
201 for (
unsigned int istrip_ = 0; istrip_ < nStrip; ++istrip_) {
202 bool isStripBad =
obj->IsStripBad(detid, istrip_);
203 float quant_ = isStripBad ? 1.f : 0.f;
204 if (!theMap.count(detid)) {
206 <<
"@SUB=SiStripCondVisualizer::analyze(): " << detid <<
" was not found in the quality histogram map!!!";
208 theMap[detid]->SetBinContent(istrip_, quant_);
218 template <
class Payload>
220 std::function<float(unsigned int, typename Payload::Range)> payloadFunctor = [&
obj](
unsigned int istrip,
222 if constexpr (std::is_same_v<Payload, SiStripNoises>) {
223 return obj->getNoise(istrip,
range);
224 }
else if constexpr (std::is_same_v<Payload, SiStripPedestals>) {
226 }
else if constexpr (std::is_same_v<Payload, SiStripApvGain>) {
227 return obj->getStripGain(istrip,
range);
231 std::vector<uint32_t> activeDetIds;
232 obj->getDetIds(activeDetIds);
234 for (
const uint32_t& detid : activeDetIds) {
241 for (
unsigned int istrip_ = 0; istrip_ < nStrip; ++istrip_) {
242 float quant_ = payloadFunctor(istrip_, condRange);
244 if (!theMap.count(detid)) {
246 <<
"@SUB=SiStripCondVisualizer::analyze(): " << detid <<
" was not found in the histogram map!!!";
248 theMap[detid]->SetBinContent(istrip_, quant_);
260 this->fillTheHistoMap<SiStripNoises>(noiseObj,
NoiseMap_);
264 this->fillTheHistoMap<SiStripPedestals>(pedestalObj,
PedMap_);
268 this->fillTheHistoMap<SiStripApvGain>(g1Obj,
G1Map_);
272 this->fillTheHistoMap<SiStripApvGain>(g2Obj,
G2Map_);
285 for (
const auto&
it : DetInfos) {
307 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n Before booking NoisMap_.size(): " 310 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n After booking NoisMap_.size(): " 314 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n Before booking PedMap_.size(): " 317 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n After booking PedMap_.size(): " 321 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n Before booking G1Map_.size(): " 324 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n After booking G1Map_.size(): " 328 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n Before booking G2Map_.size(): " 331 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n After booking G2Map_.size(): " 335 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n Before booking QualMap_.size(): " 338 LOGINFO(
"SiStripCondVisualizer") <<
"@SUB=SiStripCondVisualizer::beginRun() \n After booking QualMap_.size(): " 346 int subdetId_(-999),
layer_(-999), side_(-999);
348 std::tuple<std::string, int, int, int> def_tuple{
ret, subdetId_,
layer_, side_};
361 ret += (side_ == 1) ? Form(
"P_disk%i",
layer_) : Form(
"M_disk%i",
layer_);
372 ret += (side_ == 1) ? Form(
"P_disk%i",
layer_) : Form(
"M_disk%i",
layer_);
375 edm::LogError(
"SiStripCondVisualizer") <<
"SUB=SiStripCondVisualizer::setTopoInfo() \n unrecognizer partition.";
379 return std::make_tuple(
ret, subdetId_,
layer_, side_);
402 if (subdet ==
"TID" || subdet ==
"TEC") {
403 unsigned int sideStartBit_{0};
404 unsigned int wheelStartBit_{0};
405 unsigned int ringStartBit_{0};
406 unsigned int sideMask_{0};
407 unsigned int wheelMask_{0};
408 unsigned int ringMask_{0};
411 if (subdet ==
"TEC") {
421 if (subdet ==
"TID") {
431 int side =
int((
mod >> sideStartBit_) & sideMask_);
432 int wheel =
int((
mod >> wheelStartBit_) & wheelMask_);
433 int ring =
int((
mod >> ringStartBit_) & ringMask_);
437 d_l_t = Form(
"%s%s_W%dR%d", subdet.c_str(), s_side.c_str(),
wheel,
ring);
445 for (std::vector<DetIdSelector>::const_iterator detidsel =
detidsels_.begin(); detidsel !=
detidsels_.end();
447 if (detidsel->isSelected(detid)) {
458 TH1F::SetDefaultSumw2(kTRUE);
463 for (
const auto&
it : DetInfos) {
465 if (
it.first == 0 ||
it.first == 0xFFFFFFFF) {
467 <<
"Wrong det id: " <<
it.first <<
" ... neglecting!";
475 const std::string thePart = std::get<0>(topolInfo);
482 Form(
"%s for module %i (%s);n. strip; %s %s",
498 desc.setComment(
"Creates a ROOT file with the per-moudle profiles of different SiStrip Database tag contents.");
499 desc.add<
bool>(
"doNoise",
false);
500 desc.add<
bool>(
"doPeds",
false);
501 desc.add<
bool>(
"doG1",
false);
502 desc.add<
bool>(
"doG2",
false);
503 desc.add<
bool>(
"doBadComps",
false);
508 desc_detIdSelection.
add<
unsigned int>(
"detSelection");
510 desc_detIdSelection.addUntracked<std::vector<std::string>>(
"selection");
511 std::vector<edm::ParameterSet> default_detIdSelectionVector;
513 default_detIdSelector.
addParameter<
unsigned int>(
"detSelection", 1);
516 {
"0x1e000000-0x16000000",
517 "0x1e006000-0x18002000",
518 "0x1e006000-0x18004000",
519 "0x1e000000-0x1a000000",
520 "0x1e0c0000-0x1c040000",
521 "0x1e0c0000-0x1c080000"});
522 default_detIdSelectionVector.push_back(default_detIdSelector);
523 desc.addVPSet(
"selections", desc_detIdSelection, default_detIdSelectionVector);
static const std::string kSharedResource
static const std::array< std::string, 5 > titles
static const std::array< std::string, 5 > units
SiStripCondVisualizer(const edm::ParameterSet &)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
static const char layer_[]
unsigned int tobLayer(const DetId &id) const
std::string module_location_type(const unsigned int &mod)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
PixelRecoRange< float > Range
edm::Service< TFileService > fs_
std::bitset< 5 > plottedConditions_
static constexpr auto TID
ret
prodAgent to be discontinued
unsigned int tidSide(const DetId &id) const
std::tuple< std::string, int, int, int > setTopoInfo(uint32_t detId, const TrackerTopology *tTopo)
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
ALPAKA_FN_ACC int side(int ieta, int iphi)
SubDetector subDetector() const
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualToken_
Log< level::Error, false > LogError
HistoMap bookModuleHistograms(const TrackerTopology *tTopo, const SiStripCondTypes::condformat &type)
TEMPL(T2) struct Divides void
std::bitset< sizeof...(Args)> makeBitSet(Args... as)
std::map< uint32_t, TH1F * > HistoMap
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedToken_
unsigned int tecSide(const DetId &id) const
void addParameter(std::string const &name, T const &value)
void fillTheQualityMap(const SiStripQuality *obj, HistoMap &theMap)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
SiStripDetInfo read(std::string filePath)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static constexpr auto TOB
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > g1Token_
Detector identifier class for the strip tracker.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
~SiStripCondVisualizer() override=default
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void addUntrackedParameter(std::string const &name, T const &value)
Constants and enumerated types for FED/FEC systems.
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
std::vector< DetIdSelector > detidsels_
static constexpr auto TIB
bool isDetIdSelected(const uint32_t detid)
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
static const uint16_t STRIPS_PER_APV
void beginRun(edm::Run const &, edm::EventSetup const &) override
void fillTheHistoMap(const Payload *obj, HistoMap &theMap)
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
static constexpr char const *const kDefaultFile
unsigned int tibLayer(const DetId &id) const
void endRun(edm::Run const &, edm::EventSetup const &) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void analyze(const edm::Event &, const edm::EventSetup &) override
T mod(const T &a, const T &b)
edm::ESGetToken< SiStripApvGain, SiStripApvGain2Rcd > g2Token_
static constexpr auto TEC
std::map< std::string, TFileDirectory > outputFolders_