46 trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo);
47 std::string tmap_title =
" Tracker Map from " + map_type;
58 if (map_type ==
"QTestAlarm") {
78 edm::LogError(
"SiStripTopLevelDirNotFound") <<
"I cannot find the SiStrip top level directory in the DQM file";
81 stripTopLevelDir_ = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of(
"/"));
96 trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo);
98 meanToMaxFactor_ = tkmapPset.getUntrackedParameter<
double>(
"meanToMaxFact", 2.5);
99 useSSQuality_ = tkmapPset.getUntrackedParameter<
bool>(
"useSSQuality",
false);
101 bool tkMapPSU = tkmapPset.getUntrackedParameter<
bool>(
"psuMap",
false);
102 bool tkMapFED = tkmapPset.getUntrackedParameter<
bool>(
"fedMap",
false);
106 unsigned int runNumber_ = tkmapPset.getUntrackedParameter<
unsigned int>(
"RunNumber", 1);
107 std::stringstream
ss;
112 if (runNumber_ > 0) {
113 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
115 tmap_title =
" Tracker Map from " + map_type;
119 if (tkmapPset.exists(
"TopModules"))
120 topModules_ = tkmapPset.getUntrackedParameter<
bool>(
"TopModules");
124 if (tkmapPset.exists(
"numberTopModules"))
125 numTopModules_ = tkmapPset.getUntrackedParameter<uint32_t>(
"numberTopModules");
129 if (tkmapPset.exists(
"topModLabel"))
130 topModLabel_ = tkmapPset.getUntrackedParameter<int32_t>(
"topModLabel");
134 if (map_type ==
"QTestAlarm") {
144 if (tkmapPset.exists(
"mapMax"))
145 tkMapMax_ = tkmapPset.getUntrackedParameter<
double>(
"mapMax");
146 if (tkmapPset.exists(
"mapMin"))
147 tkMapMin_ = tkmapPset.getUntrackedParameter<
double>(
"mapMin");
149 if (map_type ==
"ResidualsMean") {
152 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to " 154 trackerMap_->save(
true, 0.0000000001, 0.005, map_type + namesuffix +
".svg");
155 trackerMap_->save(
true, 0.0000000001, 0.005, map_type + namesuffix +
".png", 4500, 2400);
157 map_type =
"ResidualsRMS";
158 if (runNumber_ > 0) {
159 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
161 tmap_title =
" Tracker Map from " + map_type;
165 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix
166 <<
" with range set to 0.0 - 1.0";
167 trackerMap_->save(
true, 0.0, 1.0, map_type + namesuffix +
".svg");
168 trackerMap_->save(
true, 0.0, 1.0, map_type + namesuffix +
".png", 4500, 2400);
170 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to " 177 edm::LogInfo(
"PSUMapToBeSaved") <<
"Ready to save PSU TkMap " << map_type << namesuffix <<
" with range set to " 179 trackerMap_->save_as_psutrackermap(
true,
tkMapMin_, tkMapMax_, map_type + namesuffix +
"_psu.png");
183 edm::LogInfo(
"FEDMapToBeSaved") <<
"Ready to save FED TkMap " << map_type << namesuffix <<
" with range set to " 185 trackerMap_->save_as_fedtrackermap(
true,
tkMapMin_, tkMapMax_, map_type + namesuffix +
"_fed.png");
211 std::map<unsigned int, std::string> badmodmap;
214 uint32_t detId_save = 0;
217 uint32_t detId =
module.first;
218 if (detId == 0 || detId == 0xFFFFFFFF)
220 if (detId_save != detId) {
226 <<
"The detid " << detId <<
" was found already in the loop on SiStripDetCabling";
239 std::map<unsigned int, std::string>& badmodmap) {
244 int rval, gval, bval;
250 comment <<
" PCLBadModule ";
255 if (flag != 0 || isBad) {
257 std::string layer =
" Layer " + std::to_string(lay);
258 badmodmap[det_id] = comment.str() + layer;
276 std::vector<std::string> subdet_folder;
277 subdet_folder.push_back(
"TIB");
278 subdet_folder.push_back(
"TOB");
279 subdet_folder.push_back(
"TEC/MINUS");
280 subdet_folder.push_back(
"TEC/PLUS");
281 subdet_folder.push_back(
"TID/MINUS");
282 subdet_folder.push_back(
"TID/PLUS");
288 auto topNmodVec =
topModules_ ?
new std::vector<std::pair<float, uint32_t>>{} :
nullptr;
289 for (
auto const&
sd : subdet_folder) {
294 std::vector<std::string> layerVec = dqm_store.
getSubdirs();
295 for (
auto const& layer : layerVec) {
296 if (layer.find(
"BadModuleList") != std::string::npos)
298 std::vector<MonitorElement*> meVec = dqm_store.
getContents(layer);
301 for (
auto tkh : meVec) {
302 name = tkh->getName();
303 if (name.find(
"TkHMap") == std::string::npos)
305 if (htype ==
"QTestAlarm") {
306 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
309 }
else if (name.find(htype) != std::string::npos) {
314 if (tkhmap_me !=
nullptr) {
318 dqm_store.
cd(mechanicalview_dir);
327 std::vector<std::pair<float, uint32_t>>* topNmodVec) {
329 std::string lname = name.substr(name.find(
"TkHMap_") + 7);
330 lname = lname.substr(lname.find(
"_T") + 1);
332 if (det_id.rawId() <= 0)
337 if (name.find(
"Residuals") != std::string::npos) {
342 tp->GetBinError(xyval.
ix, xyval.
iy) *
sqrt(tp->GetBinEntries(tp->GetBin(xyval.
ix, xyval.
iy)));
351 if (htype ==
"QTestAlarm") {
352 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
359 topNmodVec->emplace_back(fval, det_id);
370 uint32_t
const det_id,
373 comment <<
"Module " << det_id;
378 comment <<
" FEDCHs ";
379 constexpr std::size_t indent_width{7ull};
381 for (
auto const conn : conns) {
383 comment << std::setw(3) <<
conn->fedId() <<
"/" << std::setw(2) <<
conn->fedCh() <<
" ";
390 }
else if (conns.size() == 1) {
392 }
else if (conns.size() == 2) {
409 if (dqm_store->
dirExists(subdet_folder)) {
410 badmodule_folder = subdet_folder +
"/BadModuleList";
411 LogDebug(
"SearchBadModule") << subdet_folder <<
" exists: " << badmodule_folder;
413 edm::LogError(
"SubDetFolderNotFound") << subdet_folder <<
" does not exist for detid " << det_id;
416 if (!dqm_store->
dirExists(badmodule_folder)) {
417 LogDebug(
"BadModuleFolderNotFound") << badmodule_folder <<
" does not exist for detid " << det_id;
420 std::ostringstream badmodule_path;
421 badmodule_path << badmodule_folder <<
"/" << det_id;
422 LogDebug(
"SearchBadModule") << badmodule_folder <<
" exists: " << badmodule_path;
424 auto const* bad_module_me = dqm_store->
get(badmodule_path.str());
426 LogDebug(
"SearchBadModule") <<
"Monitor Element found";
427 flag = bad_module_me->getIntValue();
430 comment << message.c_str();
440 std::map<std::string, float> tkhmap_value;
441 int qtalarm_flag = 0;
445 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
447 tkinfo_tree->Branch(
"DetId", &det_id,
"DetId/i");
448 for (
auto const& mapname : map_names) {
449 if (mapname ==
"QTestAlarm") {
451 tkinfo_tree->Branch(mapname.c_str(), &qtalarm_flag,
std::string(mapname +
"/I").c_str());
453 tkhmap_value[mapname] = -1.0;
454 tkinfo_tree->Branch(mapname.c_str(), &tkhmap_value[mapname],
std::string(mapname +
"/F").c_str());
464 <<
"I cannot find the SiStrip top level directory in the DQM file";
467 dirname = mechanicalview_dir.substr(0, mechanicalview_dir.find_last_of(
"/"));
468 edm::LogInfo(
"SiStripTrackerMapCreator::createInfoFile") <<
"SiStrip top level directory is " <<
dirname;
472 std::vector<TkHistoMap> tkHMaps;
474 uint32_t nHists = map_names.size();
476 for (uint32_t ih = 0; ih < nHists; ++ih) {
478 if (map_names.at(ih) !=
"QTestAlarm") {
479 std::string tkhmap_name =
"TkHMap_" + map_names.at(ih);
480 tkHMaps.at(ih).loadTkHistoMap(dirname, tkhmap_name,
true);
487 for (
auto const id : detidList) {
489 for (uint32_t ih = 0; ih < nHists; ++ih) {
490 if (map_names.at(ih) ==
"QTestAlarm") {
493 tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih).getValue(
id);
497 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
514 bool tibDone =
false, tidSide1Done =
false, tidSide2Done =
false, tobDone =
false, tecSide1Done =
false,
515 tecSide2Done =
false;
516 constexpr unsigned int tibFirst = 369120277 - 1, tidSide1First = 402664197 - 1, tidSide2First = 402672389 - 1,
517 tobFirst = 436228134 - 1, tecSide1First = 470044965 - 1, tecSide2First = 470307109 - 1;
519 int ntib = 0, ntids1 = 0, ntids2 = 0, ntob = 0, ntecs1 = 0, ntecs2 = 0;
521 for (
auto const& badmod : badmodmap) {
526 if (tTopo->
tidSide(ssdetid) == 1)
528 if (tTopo->
tidSide(ssdetid) == 2)
534 if (tTopo->
tecSide(ssdetid) == 1)
536 if (tTopo->
tecSide(ssdetid) == 2)
542 edm::LogVerbatim(
"BadModuleList") <<
"--------------------------------------------------------------";
554 for (
auto const& badmod : badmodmap) {
555 if (!tibDone && badmod.first >= tibFirst) {
561 if (!tidSide1Done && badmod.first >= tidSide1First) {
567 if (!tidSide2Done && badmod.first >= tidSide2First) {
573 if (!tobDone && badmod.first >= tobFirst) {
579 if (!tecSide1Done && badmod.first >= tecSide1First) {
585 if (!tecSide2Done && badmod.first >= tecSide2First) {
602 if (topNmodVec.empty())
605 std::sort(topNmodVec.rbegin(), topNmodVec.rend());
610 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
612 for (
auto const& aPair : topNmodVec) {
613 uint32_t det_id = aPair.second;
618 subdetector =
"TIB ";
620 if (tTopo->
tidSide(ssdetid) == 1)
621 subdetector =
"TID/MINUS ";
622 if (tTopo->
tidSide(ssdetid) == 2)
623 subdetector =
"TID/PLUS ";
626 subdetector =
"TOB ";
628 if (tTopo->
tecSide(ssdetid) == 1)
629 subdetector =
"TEC/MINUS ";
630 if (tTopo->
tecSide(ssdetid) == 2)
631 subdetector =
"TEC/PLUS ";
635 edm::LogVerbatim(
"TopModules") << subdetector << comment.str() <<
" value: " << aPair.first;
637 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
646 if (map_type.find(
"FractionOfBadChannels") != std::string::npos)
648 else if (map_type.find(
"NumberOfCluster") != std::string::npos)
650 else if (map_type.find(
"NumberOfDigi") != std::string::npos)
652 else if (map_type.find(
"NumberOfOffTrackCluster") != std::string::npos)
654 else if (map_type.find(
"NumberOfOnTrackCluster") != std::string::npos)
656 else if (map_type.find(
"StoNCorrOnTrack") != std::string::npos)
static const char runNumber_[]
std::unique_ptr< TrackerMap > trackerMap_
void createForOffline(edm::ParameterSet const &tkmapPset, DQMStore &dqm_store, std::string &htype, edm::EventSetup const &eSetup)
TkLayerMap::XYbin cachedXYbin_
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)
TkDetMap const * tkDetMap_
void setTkMapFromAlarm(DQMStore &dqm_store, edm::EventSetup const &eSetup)
static constexpr auto TID
std::vector< 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 const & pwd() const
void paintTkMapFromHistogram(MonitorElement const *me, std::string const &map_type, std::vector< std::pair< float, uint32_t >> *topNmodVec)
static void getBadModuleStatus(uint16_t flag, std::string &message)
void cd()
go to top directory (ie. root)
std::vector< DetId > getDetsForLayer(int layer) const
void printTopModules(std::vector< std::pair< float, uint32_t >> &topNmodVec, edm::EventSetup const &eSetup)
void setTkMapFromHistogram(DQMStore &dqm_store, std::string const &htype, edm::EventSetup const &eSetup)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
static int getLayerNum(const std::string &in)
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
unsigned int tidSide(const DetId &id) const
void setTkMapRangeOffline()
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
Abs< T >::type abs(const T &t)
bool IsModuleBad(const uint32_t &detid) const
std::string stripTopLevelDir_
virtual double getBinContent(int binx) const
get content of bin (1-D)
SiStripTrackerMapCreator(edm::EventSetup const &eSetup)
static constexpr auto TOB
virtual TProfile2D * getTProfile2D() const
void createInfoFile(std::vector< std::string > const &map_names, TTree *tkinfo_tree, DQMStore &dqm_store)
void printBadModuleList(std::map< unsigned int, std::string > const &badmodmap, edm::EventSetup const &eSetup)
const SiStripFedCabling * fedCabling() const
Detector identifier class for the strip tracker.
void create(edm::ParameterSet const &tkmapPset, DQMStore &dqm_store, std::string const &htype, edm::EventSetup const &eSetup)
unsigned long long int rval
SubDetector subDetector() const
uint16_t getDetectorFlagAndComment(DQMStore *dqm_store, uint32_t det_id, TrackerTopology const *tTopo, std::ostringstream &comment)
edm::ESHandle< SiStripDetCabling > detCabling_
void setTkMapRange(std::string const &map_type)
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::vector< std::string > getSubdirs() const
void paintTkMapFromAlarm(uint32_t det_id, const TrackerTopology *tTopo, DQMStore &dqm_store, bool isBad, std::map< unsigned int, std::string > &badmodmap)
std::map< uint32_t, uint16_t > detFlag_
static bool goToDir(DQMStore &dqm_store, std::string const &name)
const TkLayerMap::XYbin & getXY(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
T const * product() const
static constexpr auto TEC
edm::EventSetup const & eSetup_
unsigned int tecSide(const DetId &id) const
bool dirExists(std::string const &path) const
true if directory exists