43 if(!fedcabling)
return;
49 trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo);
50 std::string tmap_title =
" Tracker Map from " + map_type;
61 if (map_type ==
"QTestAlarm") {
83 edm::LogError(
"SiStripTopLevelDirNotFound") <<
"I cannot find the SiStrip top level directory in the DQM file";
87 stripTopLevelDir_=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of(
"/"));
95 if(!fedcabling)
return;
101 trackerMap_ = std::make_unique<TrackerMap>(tkmapPset, fedcabling, tTopo);
103 meanToMaxFactor_ = tkmapPset.getUntrackedParameter<
double>(
"meanToMaxFact",2.5);
104 useSSQuality_ = tkmapPset.getUntrackedParameter<
bool>(
"useSSQuality",
false);
106 bool tkMapPSU = tkmapPset.getUntrackedParameter<
bool>(
"psuMap",
false);
107 bool tkMapFED = tkmapPset.getUntrackedParameter<
bool>(
"fedMap",
false);
112 tkmapPset.getUntrackedParameter<
unsigned int>(
"RunNumber", 1);
113 std::stringstream ss;
118 if (runNumber_ > 0) {
119 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
121 tmap_title =
" Tracker Map from " + map_type;
125 if(tkmapPset.exists(
"TopModules"))
126 topModules_ = tkmapPset.getUntrackedParameter<
bool>(
"TopModules");
130 if(tkmapPset.exists(
"numberTopModules"))
132 tkmapPset.getUntrackedParameter<uint32_t>(
"numberTopModules");
136 if (tkmapPset.exists(
"topModLabel"))
137 topModLabel_ = tkmapPset.getUntrackedParameter<int32_t>(
"topModLabel");
141 if (map_type ==
"QTestAlarm") {
152 if(tkmapPset.exists(
"mapMax"))
tkMapMax_ = tkmapPset.getUntrackedParameter<
double>(
"mapMax");
153 if(tkmapPset.exists(
"mapMin"))
tkMapMin_ = tkmapPset.getUntrackedParameter<
double>(
"mapMin");
155 if (map_type ==
"ResidualsMean"){
159 trackerMap_->save(
true, 0.0000000001,0.005, map_type+namesuffix+
".svg");
160 trackerMap_->save(
true, 0.0000000001,0.005, map_type+namesuffix+
".png",4500,2400);
162 map_type =
"ResidualsRMS";
163 if (runNumber_ > 0) {
164 tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type;
166 tmap_title =
" Tracker Map from " + map_type;
170 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to 0.0 - 1.0";
171 trackerMap_->save(
true, 0.0, 1.0, map_type+namesuffix+
".svg");
172 trackerMap_->save(
true, 0.0, 1.0, map_type+namesuffix+
".png",4500,2400);
181 edm::LogInfo(
"PSUMapToBeSaved") <<
"Ready to save PSU TkMap " << map_type << namesuffix <<
" with range set to " <<
tkMapMin_ <<
" - " <<
tkMapMax_;
188 edm::LogInfo(
"FEDMapToBeSaved") <<
"Ready to save FED TkMap " << map_type << namesuffix <<
" with range set to " <<
tkMapMin_ <<
" - " <<
tkMapMax_;
217 std::map<unsigned int, std::string> badmodmap;
220 uint32_t detId_save = 0;
223 uint32_t detId =
module.first;
224 if (detId == 0 || detId == 0xFFFFFFFF)
continue;
225 if (detId_save != detId) {
231 <<
"The detid " << detId
232 <<
" was found already in the loop on SiStripDetCabling";
243 uint32_t
const det_id,
247 std::map<unsigned int, std::string>& badmodmap)
253 int rval, gval, bval;
259 comment <<
" PCLBadModule ";
264 if (flag != 0 || isBad) {
267 badmodmap[det_id] = comment.str() + layer;
286 std::vector<std::string> subdet_folder;
287 subdet_folder.push_back(
"TIB");
288 subdet_folder.push_back(
"TOB");
289 subdet_folder.push_back(
"TEC/MINUS");
290 subdet_folder.push_back(
"TEC/PLUS");
291 subdet_folder.push_back(
"TID/MINUS");
292 subdet_folder.push_back(
"TID/PLUS");
299 topModules_ ?
new std::vector<std::pair<float, uint32_t>>{} :
nullptr;
300 for (
auto const&
sd : subdet_folder) {
302 if (!dqm_store.
dirExists(dname))
continue;
304 std::vector<std::string> layerVec = dqm_store.
getSubdirs();
305 for (
auto const& layer : layerVec) {
306 if (layer.find(
"BadModuleList") != std::string::npos)
continue;
307 std::vector<MonitorElement*> meVec = dqm_store.
getContents(layer);
310 for (
auto tkh : meVec) {
311 name = tkh->getName();
312 if (name.find(
"TkHMap") == std::string::npos)
continue;
313 if (htype ==
"QTestAlarm" ){
314 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
317 }
else if (name.find(htype) != std::string::npos) {
322 if (tkhmap_me !=
nullptr) {
326 dqm_store.
cd(mechanicalview_dir);
336 std::vector<std::pair<float, uint32_t>>* topNmodVec)
339 std::string lname = name.substr(name.find(
"TkHMap_") + 7);
340 lname = lname.substr(lname.find(
"_T")+1);
342 if (det_id.rawId() <= 0)
continue;
347 if (name.find(
"Residuals") != std::string::npos) {
351 float fval_prov = tp->GetBinError(xyval.
ix, xyval.
iy) *
sqrt(tp->GetBinEntries(tp->GetBin(xyval.
ix, xyval.
iy)));
359 if (htype ==
"QTestAlarm") {
360 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
362 if (fval == 0.0)
trackerMap_->fillc(det_id,255, 255, 255);
366 topNmodVec->emplace_back(fval, det_id);
379 uint32_t
const det_id,
383 comment <<
"Module " << det_id;
388 comment <<
" FEDCHs ";
389 constexpr std::size_t indent_width{7ull};
390 std::vector<const FedChannelConnection*> conns =
392 for (
auto const conn : conns) {
394 comment << std::setw(3) << conn->fedId() <<
"/" << std::setw(2)
395 << conn->fedCh() <<
" ";
403 }
else if (conns.size() == 1) {
405 }
else if (conns.size() == 2) {
409 if(!dqm_store)
return flag;
421 if (dqm_store->
dirExists(subdet_folder)){
422 badmodule_folder = subdet_folder +
"/BadModuleList";
423 LogDebug(
"SearchBadModule") << subdet_folder <<
" exists: " << badmodule_folder;
425 edm::LogError(
"SubDetFolderNotFound") << subdet_folder <<
" does not exist for detid " << det_id;
428 if (!dqm_store->
dirExists(badmodule_folder)) {
429 LogDebug(
"BadModuleFolderNotFound") << badmodule_folder <<
" does not exist for detid " << det_id;
432 std::ostringstream badmodule_path;
433 badmodule_path << badmodule_folder <<
"/" << det_id;
434 LogDebug(
"SearchBadModule") << badmodule_folder <<
" exists: " << badmodule_path;
436 auto const* bad_module_me = dqm_store->
get(badmodule_path.str());
438 LogDebug(
"SearchBadModule") <<
"Monitor Element found";
439 flag = bad_module_me->getIntValue();
442 comment << message.c_str();
451 std::vector<std::string>
const& map_names,
454 std::vector<uint32_t>
const& detidList)
456 std::map<std::string, float> tkhmap_value;
457 int qtalarm_flag = 0;
461 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
464 tkinfo_tree->Branch(
"DetId", &det_id,
"DetId/i");
465 for (
auto const& mapname : map_names) {
466 if(mapname ==
"QTestAlarm") {
468 tkinfo_tree->Branch(mapname.c_str(),&qtalarm_flag,
std::string(mapname+
"/I").c_str());
470 tkhmap_value[mapname] = -1.0;
471 tkinfo_tree->Branch(mapname.c_str(),&tkhmap_value[mapname],
std::string(mapname+
"/F").c_str());
480 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"I cannot find the SiStrip top level directory in the DQM file";
484 dirname=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of(
"/"));
485 edm::LogInfo(
"SiStripTrackerMapCreator::createInfoFile") <<
"SiStrip top level directory is " <<
dirname;
489 std::vector<TkHistoMap> tkHMaps;
491 uint32_t nHists = map_names.size();
493 for (uint32_t ih = 0; ih < nHists; ++ih) {
495 if(map_names.at(ih) !=
"QTestAlarm") {
496 std::string tkhmap_name =
"TkHMap_" + map_names.at(ih);
497 tkHMaps.at(ih).loadTkHistoMap(dirname, tkhmap_name,
true);
501 for (
auto const id : detidList) {
503 for (uint32_t ih = 0; ih < nHists; ++ih) {
504 if (map_names.at(ih) ==
"QTestAlarm") {
507 tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih).getValue(
id);
511 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
524 std::map<unsigned int, std::string>
const& badmodmap,
532 bool tibDone =
false, tidSide1Done =
false, tidSide2Done =
false,
533 tobDone =
false, tecSide1Done =
false, tecSide2Done =
false;
534 constexpr unsigned int tibFirst = 369120277 - 1,
535 tidSide1First = 402664197 - 1,
536 tidSide2First = 402672389 - 1,
537 tobFirst = 436228134 - 1,
538 tecSide1First = 470044965 - 1,
539 tecSide2First = 470307109 - 1;
541 int ntib = 0, ntids1 = 0, ntids2 = 0, ntob = 0, ntecs1 = 0, ntecs2 = 0;
543 for (
auto const& badmod : badmodmap) {
548 if (tTopo->
tidSide(ssdetid) == 1) ntids1++;
549 if (tTopo->
tidSide(ssdetid) == 2) ntids2++;
554 if (tTopo->
tecSide(ssdetid) == 1) ntecs1++;
555 if (tTopo->
tecSide(ssdetid) == 2) ntecs2++;
560 <<
"Run: " <<
sRunNumber <<
", Number of bad modules in total:";
562 <<
"--------------------------------------------------------------";
574 for (
auto const& badmod : badmodmap) {
575 if (!tibDone && badmod.first >= tibFirst) {
581 if (!tidSide1Done && badmod.first >= tidSide1First) {
587 if (!tidSide2Done && badmod.first >= tidSide2First) {
593 if (!tobDone && badmod.first >= tobFirst) {
599 if (!tecSide1Done && badmod.first >= tecSide1First) {
605 if (!tecSide2Done && badmod.first >= tecSide2First) {
617 std::vector<std::pair<float, uint32_t>>& topNmodVec,
625 if (topNmodVec.empty())
return;
627 std::sort(topNmodVec.rbegin(), topNmodVec.rend());
632 <<
"------------------------------------------------------";
634 for (
auto const& aPair : topNmodVec) {
635 uint32_t det_id = aPair.second;
641 if (tTopo->
tidSide(ssdetid) == 1) subdetector =
"TID/MINUS ";
642 if (tTopo->
tidSide(ssdetid) == 2) subdetector =
"TID/PLUS ";
646 if (tTopo->
tecSide(ssdetid) == 1) subdetector =
"TEC/MINUS ";
647 if (tTopo->
tecSide(ssdetid) == 2) subdetector =
"TEC/PLUS ";
652 << subdetector << comment.str() <<
" value: " << aPair.first;
655 <<
"------------------------------------------------------";
666 if (map_type.find(
"FractionOfBadChannels") != std::string::npos)
668 else if (map_type.find(
"NumberOfCluster") != std::string::npos)
670 else if (map_type.find(
"NumberOfDigi") != std::string::npos)
672 else if (map_type.find(
"NumberOfOffTrackCluster") != std::string::npos)
674 else if (map_type.find(
"NumberOfOnTrackCluster") != std::string::npos)
676 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)
void createInfoFile(std::vector< std::string > const &map_names, TTree *tkinfo_tree, DQMStore &dqm_store, std::vector< uint32_t > const &detidList)
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)
std::vector< MonitorElement * > getContents(std::string const &path) const
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
TProfile2D * getTProfile2D() const
TkDetMap const * tkDetMap_
void setTkMapFromAlarm(DQMStore &dqm_store, edm::EventSetup const &eSetup)
static void getDetectorStatusColor(int status, int &rval, int &gval, int &bval)
const std::string & getName() const
get name of ME
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)
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)
unsigned int tidSide(const DetId &id) const
bool dirExists(std::string const &path) const
true if directory exists
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void setTkMapRangeOffline()
Abs< T >::type abs(const T &t)
bool IsModuleBad(const uint32_t &detid) const
std::string stripTopLevelDir_
SiStripTrackerMapCreator(edm::EventSetup const &eSetup)
std::vector< std::string > getSubdirs() const
void printBadModuleList(std::map< unsigned int, std::string > const &badmodmap, edm::EventSetup const &eSetup)
std::string const & pwd() const
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)
void cd()
go to top directory (ie. root)
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...
unsigned int layer(const DetId &id) const
void paintTkMapFromAlarm(uint32_t det_id, const TrackerTopology *tTopo, DQMStore &dqm_store, bool isBad, std::map< unsigned int, std::string > &badmodmap)
double getBinContent(int binx) const
get content of bin (1-D)
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
Kind kind() const
Get the type of the monitor element.
edm::EventSetup const & eSetup_
unsigned int tecSide(const DetId &id) const