25 : detCabling_(detCabling), tkDetMap_(tkDetMap), tTopo_(tTopo) {}
39 std::string tmap_title =
" Tracker Map from " + map_type;
48 if (map_type ==
"QTestAlarm") {
68 edm::LogError(
"SiStripTopLevelDirNotFound") <<
"I cannot find the SiStrip top level directory in the DQM file";
71 stripTopLevelDir_ = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of(
'/'));
84 meanToMaxFactor_ = tkmapPset.getUntrackedParameter<
double>(
"meanToMaxFact", 2.5);
85 bool tkMapPSU = tkmapPset.getUntrackedParameter<
bool>(
"psuMap",
false);
86 bool tkMapFED = tkmapPset.getUntrackedParameter<
bool>(
"fedMap",
false);
90 unsigned int runNumber_ = tkmapPset.getUntrackedParameter<
unsigned int>(
"RunNumber", 1);
97 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
99 tmap_title =
" Tracker Map from " + map_type;
103 if (tkmapPset.exists(
"TopModules"))
104 topModules_ = tkmapPset.getUntrackedParameter<
bool>(
"TopModules");
108 if (tkmapPset.exists(
"numberTopModules"))
109 numTopModules_ = tkmapPset.getUntrackedParameter<uint32_t>(
"numberTopModules");
113 if (tkmapPset.exists(
"topModLabel"))
114 topModLabel_ = tkmapPset.getUntrackedParameter<int32_t>(
"topModLabel");
118 if (map_type ==
"QTestAlarm") {
128 if (tkmapPset.exists(
"mapMax"))
129 tkMapMax_ = tkmapPset.getUntrackedParameter<
double>(
"mapMax");
130 if (tkmapPset.exists(
"mapMin"))
131 tkMapMin_ = tkmapPset.getUntrackedParameter<
double>(
"mapMin");
133 if (map_type ==
"ResidualsMean") {
136 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to "
138 trackerMap_->save(
true, 0.0000000001, 0.005, map_type + namesuffix +
".svg");
139 trackerMap_->save(
true, 0.0000000001, 0.005, map_type + namesuffix +
".png", 4500, 2400);
141 map_type =
"ResidualsRMS";
142 if (runNumber_ > 0) {
143 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
145 tmap_title =
" Tracker Map from " + map_type;
149 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix
150 <<
" with range set to 0.0 - 1.0";
151 trackerMap_->save(
true, 0.0, 1.0, map_type + namesuffix +
".svg");
152 trackerMap_->save(
true, 0.0, 1.0, map_type + namesuffix +
".png", 4500, 2400);
155 map_type =
"ResidualsMean";
157 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to "
164 edm::LogInfo(
"PSUMapToBeSaved") <<
"Ready to save PSU TkMap " << map_type << namesuffix <<
" with range set to "
166 trackerMap_->save_as_psutrackermap(
true,
tkMapMin_, tkMapMax_, map_type + namesuffix +
"_psu.png");
170 edm::LogInfo(
"FEDMapToBeSaved") <<
"Ready to save FED TkMap " << map_type << namesuffix <<
" with range set to "
172 trackerMap_->save_as_fedtrackermap(
true,
tkMapMin_, tkMapMax_, map_type + namesuffix +
"_fed.png");
187 std::map<unsigned int, std::string> badmodmap;
190 uint32_t detId_save = 0;
193 uint32_t detId =
module.first;
194 if (detId == 0 || detId == 0xFFFFFFFF)
196 if (detId_save != detId) {
198 bool isBad = stripQuality && stripQuality->
IsModuleBad(detId);
202 <<
"The detid " << detId <<
" was found already in the loop on SiStripDetCabling";
214 std::map<unsigned int, std::string>& badmodmap) {
215 std::ostringstream comment;
219 int rval, gval, bval;
225 comment <<
" PCLBadModule ";
230 if (flag != 0 || isBad) {
233 badmodmap[det_id] = comment.str() +
layer;
249 std::vector<std::string> subdet_folder;
250 subdet_folder.push_back(
"TIB");
251 subdet_folder.push_back(
"TOB");
252 subdet_folder.push_back(
"TEC/MINUS");
253 subdet_folder.push_back(
"TEC/PLUS");
254 subdet_folder.push_back(
"TID/MINUS");
255 subdet_folder.push_back(
"TID/PLUS");
261 auto topNmodVec =
topModules_ ?
new std::vector<std::pair<float, uint32_t>>{} :
nullptr;
262 for (
auto const&
sd : subdet_folder) {
267 std::vector<std::string> layerVec = dqm_store.
getSubdirs();
268 for (
auto const&
layer : layerVec) {
269 if (
layer.find(
"BadModuleList") != std::string::npos)
274 for (
auto tkh : meVec) {
275 name = tkh->getName();
276 if (name.find(
"TkHMap") == std::string::npos)
278 if (htype ==
"QTestAlarm") {
279 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
282 }
else if (name.find(htype) != std::string::npos) {
287 if (tkhmap_me !=
nullptr) {
291 dqm_store.
cd(mechanicalview_dir);
300 std::vector<std::pair<float, uint32_t>>* topNmodVec) {
302 std::string lname = name.substr(name.find(
"TkHMap_") + 7);
303 lname = lname.substr(lname.find(
"_T") + 1);
305 if (det_id.rawId() <= 0)
310 if (name.find(
"Residuals") != std::string::npos) {
315 tp->GetBinError(xyval.
ix, xyval.
iy) *
sqrt(tp->GetBinEntries(tp->GetBin(xyval.
ix, xyval.
iy)));
324 if (htype ==
"QTestAlarm") {
325 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
332 topNmodVec->emplace_back(fval, det_id);
343 uint32_t
const det_id,
344 std::ostringstream& comment) {
345 comment <<
"Module " << det_id;
350 comment <<
" FEDCHs ";
351 constexpr std::size_t indent_width{7ull};
353 for (
auto const conn : conns) {
355 comment << std::setw(3) <<
conn->fedId() <<
"/" << std::setw(2) <<
conn->fedCh() <<
" ";
362 }
else if (conns.size() == 1) {
364 }
else if (conns.size() == 2) {
381 if (dqm_store->
dirExists(subdet_folder)) {
382 badmodule_folder = subdet_folder +
"/BadModuleList";
383 LogDebug(
"SearchBadModule") << subdet_folder <<
" exists: " << badmodule_folder;
385 edm::LogError(
"SubDetFolderNotFound") << subdet_folder <<
" does not exist for detid " << det_id;
388 if (!dqm_store->
dirExists(badmodule_folder)) {
389 LogDebug(
"BadModuleFolderNotFound") << badmodule_folder <<
" does not exist for detid " << det_id;
392 std::ostringstream badmodule_path;
393 badmodule_path << badmodule_folder <<
"/" << det_id;
394 LogDebug(
"SearchBadModule") << badmodule_folder <<
" exists: " << badmodule_path.str();
396 auto const* bad_module_me = dqm_store->
get(badmodule_path.str());
398 LogDebug(
"SearchBadModule") <<
"Monitor Element found";
399 flag = bad_module_me->getIntValue();
402 comment << message.c_str();
413 std::map<std::string, float> tkhmap_value;
414 int qtalarm_flag = 0;
418 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
420 tkinfo_tree->Branch(
"DetId", &det_id,
"DetId/i");
421 for (
auto const& mapname : map_names) {
422 if (mapname ==
"QTestAlarm") {
424 tkinfo_tree->Branch(mapname.c_str(), &qtalarm_flag,
std::string(mapname +
"/I").c_str());
426 tkhmap_value[mapname] = -1.0;
427 tkinfo_tree->Branch(mapname.c_str(), &tkhmap_value[mapname],
std::string(mapname +
"/F").c_str());
437 <<
"I cannot find the SiStrip top level directory in the DQM file";
440 dirname = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of(
'/'));
441 edm::LogInfo(
"SiStripTrackerMapCreator::createInfoFile") <<
"SiStrip top level directory is " <<
dirname;
445 std::vector<TkHistoMap> tkHMaps;
447 uint32_t nHists = map_names.size();
449 for (uint32_t ih = 0; ih < nHists; ++ih) {
451 if (map_names.at(ih) !=
"QTestAlarm") {
452 std::string tkhmap_name =
"TkHMap_" + map_names.at(ih);
453 tkHMaps.at(ih).loadTkHistoMap(dirname, tkhmap_name,
true);
458 for (
auto const id : detidList) {
460 for (uint32_t ih = 0; ih < nHists; ++ih) {
461 if (map_names.at(ih) ==
"QTestAlarm") {
464 tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih).getValue(
id);
468 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
480 bool tibDone =
false, tidSide1Done =
false, tidSide2Done =
false, tobDone =
false, tecSide1Done =
false,
481 tecSide2Done =
false;
482 constexpr
unsigned int tibFirst = 369120277 - 1, tidSide1First = 402664197 - 1, tidSide2First = 402672389 - 1,
483 tobFirst = 436228134 - 1, tecSide1First = 470044965 - 1, tecSide2First = 470307109 - 1;
485 int ntib = 0, ntids1 = 0, ntids2 = 0, ntob = 0, ntecs1 = 0, ntecs2 = 0;
487 for (
auto const& badmod : badmodmap) {
508 edm::LogVerbatim(
"BadModuleList") <<
"--------------------------------------------------------------";
520 for (
auto const& badmod : badmodmap) {
521 if (!tibDone && badmod.first >= tibFirst) {
527 if (!tidSide1Done && badmod.first >= tidSide1First) {
533 if (!tidSide2Done && badmod.first >= tidSide2First) {
539 if (!tobDone && badmod.first >= tobFirst) {
545 if (!tecSide1Done && badmod.first >= tecSide1First) {
551 if (!tecSide2Done && badmod.first >= tecSide2First) {
562 if (topNmodVec.empty())
565 std::sort(topNmodVec.rbegin(), topNmodVec.rend());
570 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
572 for (
auto const& aPair : topNmodVec) {
573 uint32_t det_id = aPair.second;
574 std::ostringstream comment;
578 subdetector =
"TIB ";
581 subdetector =
"TID/MINUS ";
583 subdetector =
"TID/PLUS ";
586 subdetector =
"TOB ";
589 subdetector =
"TEC/MINUS ";
591 subdetector =
"TEC/PLUS ";
595 edm::LogVerbatim(
"TopModules") << subdetector << comment.str() <<
" value: " << aPair.first;
597 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
606 if (map_type.find(
"FractionOfBadChannels") != std::string::npos)
608 else if (map_type.find(
"NumberOfCluster") != std::string::npos)
610 else if (map_type.find(
"NumberOfDigi") != std::string::npos)
612 else if (map_type.find(
"NumberOfOffTrackCluster") != std::string::npos)
614 else if (map_type.find(
"NumberOfOnTrackCluster") != std::string::npos)
616 else if (map_type.find(
"StoNCorrOnTrack") != std::string::npos)
static const char runNumber_[]
void paintTkMapFromAlarm(uint32_t det_id, DQMStore &dqm_store, bool isBad, std::map< unsigned int, std::string > &badmodmap)
Log< level::Info, true > LogVerbatim
std::unique_ptr< TrackerMap > trackerMap_
TkLayerMap::XYbin cachedXYbin_
void printBadModuleList(std::map< unsigned int, std::string > const &badmodmap)
const std::map< uint32_t, std::vector< const FedChannelConnection * > > & getDetCabling() const
void setSiStripFolderName(std::string name)
uint16_t getDetectorFlag(uint32_t const det_id)
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
uint16_t *__restrict__ id
void printTopModules(std::vector< std::pair< float, uint32_t >> &topNmodVec)
TkDetMap const * tkDetMap_
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
static constexpr auto TID
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
static void getDetectorStatusColor(int status, int &rval, int &gval, int &bval)
Kind kind() const
Get the type of the monitor element.
const std::string & getName() const
get name of ME
std::string to_string(const V &value)
virtual bool dirExists(std::string const &path) const
std::string pwd() override
void paintTkMapFromHistogram(MonitorElement const *me, std::string const &map_type, std::vector< std::pair< float, uint32_t >> *topNmodVec)
Log< level::Error, false > LogError
static void getBadModuleStatus(uint16_t flag, std::string &message)
std::vector< DetId > getDetsForLayer(int layer) const
const SiStripDetCabling * detCabling_
constexpr std::array< uint8_t, layerIndexSize > layer
void createForOffline(edm::ParameterSet const &tkmapPset, DQMStore &dqm_store, std::string &htype, const SiStripQuality *)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
static int getLayerNum(const std::string &in)
unsigned int tidSide(const DetId &id) const
void create(edm::ParameterSet const &tkmapPset, DQMStore &dqm_store, std::string const &htype)
void setTkMapRangeOffline()
virtual MonitorElement * get(std::string const &fullpath) const
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
void createInfoFile(std::vector< std::string > const &map_names, TTree *tkinfo_tree, DQMStore &dqm_store, const GeometricDet *geomDet)
Abs< T >::type abs(const T &t)
SiStripTrackerMapCreator(const SiStripDetCabling *detCabling, const TkDetMap *tkDetMap, const TrackerTopology *tTopo)
std::string stripTopLevelDir_
virtual double getBinContent(int binx) const
get content of bin (1-D)
static constexpr auto TOB
virtual TProfile2D * getTProfile2D() const
const SiStripFedCabling * fedCabling() const
Log< level::Info, false > LogInfo
Detector identifier class for the strip tracker.
SubDetector subDetector() const
void setTkMapRange(std::string const &map_type)
SiStripFolderOrganizer folder_organizer
bool IsModuleBad(uint32_t detid) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
static constexpr auto TIB
unsigned int layer(const DetId &id) const
std::map< uint32_t, uint16_t > detFlag_
static bool goToDir(DQMStore &dqm_store, std::string const &name)
void setTkMapFromHistogram(DQMStore &dqm_store, std::string const &htype)
const TkLayerMap::XYbin & getXY(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Log< level::Warning, false > LogWarning
const TrackerTopology * tTopo_
void setTkMapFromAlarm(DQMStore &dqm_store, const SiStripQuality *stripQuality)
static constexpr auto TEC
uint16_t getDetectorFlagAndComment(DQMStore *dqm_store, uint32_t det_id, std::ostringstream &comment)
unsigned int tecSide(const DetId &id) const