75 if(!fedcabling)
return;
83 std::string tmap_title =
" Tracker Map from " + map_type;
94 if (map_type ==
"QTestAlarm") {
135 edm::LogError(
"SiStripTopLevelDirNotFound") <<
"I cannot find the SiStrip top level directory in the DQM file";
139 stripTopLevelDir_=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of(
"/"));
147 if(!fedcabling)
return;
165 std::stringstream ss;
170 if (runNumber_>0) { tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type; }
171 else { tmap_title =
" Tracker Map from " + map_type; }
174 if(tkmapPset.
exists(
"TopModules"))
179 if(tkmapPset.
exists(
"numberTopModules"))
184 if (tkmapPset.
exists(
"topModLabel"))
189 if (map_type ==
"QTestAlarm") {
203 if (map_type ==
"ResidualsMean"){
207 trackerMap_->
save(
true, 0.0000000001,0.005, map_type+namesuffix+
".svg");
208 trackerMap_->
save(
true, 0.0000000001,0.005, map_type+namesuffix+
".png",4500,2400);
210 map_type =
"ResidualsRMS";
211 if (runNumber_>0) { tmap_title =
" Run: " + sRunNumber +
", Tracker Map from " + map_type; }
212 else { tmap_title =
" Tracker Map from " + map_type; }
215 edm::LogInfo(
"TkMapToBeSaved") <<
"Ready to save TkMap " << map_type << namesuffix <<
" with range set to 0.0 - 1.0";
217 trackerMap_->
save(
true, 0.0, 1.0, map_type+namesuffix+
".png",4500,2400);
226 edm::LogInfo(
"PSUMapToBeSaved") <<
"Ready to save PSU TkMap " << map_type << namesuffix <<
" with range set to " <<
tkMapMin_ <<
" - " <<
tkMapMax_;
234 edm::LogInfo(
"FEDMapToBeSaved") <<
"Ready to save FED TkMap " << map_type << namesuffix <<
" with range set to " <<
tkMapMin_ <<
" - " <<
tkMapMax_;
262 std::map<unsigned int,std::string>* badmodmap =
new std::map<unsigned int,std::string>;
265 uint32_t detId_save = 0;
269 uint32_t detId =
module->first;
270 if (detId == 0 || detId == 0xFFFFFFFF)
continue;
271 if (detId_save != detId) {
277 edm::LogWarning(
"TwiceTheSameDetId") <<
"The detid " << detId <<
" was found already in the loop on SiStripDetCabling";
292 bool tibDone=
false,tidSide1Done=
false,tidSide2Done=
false,tobDone=
false,tecSide1Done=
false,tecSide2Done=
false;
293 unsigned int tibFirst=369120277-1,
294 tidSide1First=402664197-1,tidSide2First=402672389-1,
295 tobFirst=436228134-1,
296 tecSide1First=470044965-1,tecSide2First=470307109-1;
298 int ntib=0,ntids1=0,ntids2=0,ntob=0,ntecs1=0,ntecs2=0;
300 for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
305 if(tTopo->
tidSide(ssdetid)==1) ntids1++;
306 if(tTopo->
tidSide(ssdetid)==2) ntids2++;
311 if(tTopo->
tecSide(ssdetid)==1) ntecs1++;
312 if(tTopo->
tecSide(ssdetid)==2) ntecs2++;
318 edm::LogVerbatim(
"BadModuleList") <<
"--------------------------------------------------------------";
330 for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
331 if(!tibDone && badmod->first >= tibFirst) {
337 if(!tidSide1Done && badmod->first >= tidSide1First) {
343 if(!tidSide2Done && badmod->first >= tidSide2First) {
349 if(!tobDone && badmod->first >= tobFirst) {
355 if(!tecSide1Done && badmod->first >= tecSide1First) {
361 if(!tecSide2Done && badmod->first >= tecSide2First) {
375 DQMStore* dqm_store,
bool isBad, std::map<unsigned int,std::string>* badmodmap) {
380 int rval, gval, bval;
382 if(isBad) { rval=255; gval=255; bval = 0; comment <<
" PCLBadModule ";}
386 if(badmodmap && (flag!=0 || isBad)){
389 (*badmodmap)[det_id] = comment.str() + layer;
404 std::vector<std::string> subdet_folder;
405 subdet_folder.push_back(
"TIB");
406 subdet_folder.push_back(
"TOB");
407 subdet_folder.push_back(
"TEC/MINUS");
408 subdet_folder.push_back(
"TEC/PLUS");
409 subdet_folder.push_back(
"TID/MINUS");
410 subdet_folder.push_back(
"TID/PLUS");
415 std::vector<std::pair<float,uint32_t> >* topNmodVec =
new std::vector<std::pair<float,uint32_t> >;
417 for (std::vector<std::string>::const_iterator it = subdet_folder.begin(); it != subdet_folder.end(); it++) {
419 if (!dqm_store->
dirExists(dname))
continue;
420 dqm_store->
cd(dname);
421 std::vector<std::string> layerVec = dqm_store->
getSubdirs();
422 for (std::vector<std::string>::const_iterator iLayer = layerVec.begin(); iLayer != layerVec.end(); iLayer++) {
423 if ((*iLayer).find(
"BadModuleList") !=std::string::npos)
continue;
424 std::vector<MonitorElement*> meVec = dqm_store->
getContents((*iLayer));
427 for (std::vector<MonitorElement*>::const_iterator itkh = meVec.begin(); itkh != meVec.end(); itkh++) {
428 name = (*itkh)->getName();
429 if (name.find(
"TkHMap") == std::string::npos)
continue;
430 if (htype ==
"QTestAlarm" ){
431 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
434 }
else if (name.find(htype) != std::string::npos) {
439 if (tkhmap_me !=
nullptr) {
446 dqm_store->
cd(mechanicalview_dir);
463 if (topNmodVec->empty())
return;
465 std::sort(topNmodVec->rbegin(), topNmodVec->rend());
469 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
471 for (std::vector<std::pair<float, uint32_t> >::const_iterator itNmod = topNmodVec->begin(); itNmod != topNmodVec->end(); itNmod++){
472 std::pair<float, uint32_t> aPair=(*itNmod);
473 uint32_t det_id = aPair.second;
479 if(tTopo->
tidSide(ssdetid)==1) subdetector =
"TID/MINUS ";
480 if(tTopo->
tidSide(ssdetid)==2) subdetector =
"TID/PLUS ";
484 if(tTopo->
tecSide(ssdetid)==1) subdetector =
"TEC/MINUS ";
485 if(tTopo->
tecSide(ssdetid)==2) subdetector =
"TEC/PLUS ";
488 if (flag == 0)
edm::LogVerbatim(
"TopModules") << subdetector << comment.str() <<
" value: "<< aPair.first;
490 edm::LogVerbatim(
"TopModules") <<
"------------------------------------------------------";
509 std::string lname = name.substr(name.find(
"TkHMap_")+7);
510 lname = lname.substr(lname.find(
"_T")+1);
512 if (det_id.rawId() <= 0)
continue;
522 if(name.find(
"Residuals") != std::string::npos){
526 float fval_prov = tp->GetBinError(xyval.
ix, xyval.
iy) *
sqrt(tp->GetBinEntries(tp->GetBin(xyval.
ix, xyval.
iy)));
534 if (htype ==
"QTestAlarm") {
535 edm::LogError(
"ItShouldNotBeHere") <<
"QTestAlarm map: you should not be here!";
551 auto detPair = std::make_pair(fval,det_id);
552 topNmodVec->push_back(detPair);
565 if (map_type.find(
"FractionOfBadChannels") != std::string::npos)
tkMapMax_ = 1.0;
566 else if (map_type.find(
"NumberOfCluster") != std::string::npos)
tkMapMax_ = 0.01;
567 else if (map_type.find(
"NumberOfDigi") != std::string::npos)
tkMapMax_ = 0.6;
568 else if (map_type.find(
"NumberOfOffTrackCluster") != std::string::npos)
tkMapMax_ = 100.0;
569 else if (map_type.find(
"NumberOfOnTrackCluster") != std::string::npos)
tkMapMax_ = 50.0;
570 else if (map_type.find(
"StoNCorrOnTrack") != std::string::npos)
tkMapMax_ = 200.0;
592 comment <<
"Module " << det_id;
598 comment <<
" FEDCHs ";
600 for(
unsigned int i=0;
i< conns.size() ;++
i) {
602 comment << std::setw(3) << conns[
i]->fedId() <<
"/" << std::setw(2) << conns[
i]->fedCh()<<
" ";
608 if(conns.empty()) { comment <<
" "; }
609 if(conns.size()==1) { comment <<
" "; }
610 if(conns.size()==2) { comment <<
" "; }
612 if(!dqm_store)
return flag;
630 if (dqm_store->
dirExists(subdet_folder)){
631 badmodule_folder = subdet_folder +
"/BadModuleList";
632 LogDebug(
"SearchBadModule") << subdet_folder <<
" exists: " << badmodule_folder;
635 edm::LogError(
"SubDetFolderNotFound") << subdet_folder <<
" does not exist for detid " << det_id;
638 if (!dqm_store->
dirExists(badmodule_folder)) {
639 LogDebug(
"BadModuleFolderNotFound") << badmodule_folder <<
" does not exist for detid " << det_id;
642 std::ostringstream badmodule_path;
643 badmodule_path << badmodule_folder <<
"/" << det_id;
644 LogDebug(
"SearchBadModule") << badmodule_folder <<
" exists: " << badmodule_path;
648 LogDebug(
"SearchBadModule") <<
"Monitor Element found";
652 comment << message.c_str();
661 std::map<std::string, float> tkhmap_value;
662 int qtalarm_flag = 0;
666 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
669 tkinfo_tree->Branch(
"DetId",&det_id,
"DetId/i");
670 for(std::vector<std::string>::const_iterator
in = map_names.begin();
in != map_names.end(); ++
in) {
672 if(mapname ==
"QTestAlarm") {
674 tkinfo_tree->Branch(mapname.c_str(),&qtalarm_flag,
std::string(mapname+
"/I").c_str());
676 tkhmap_value[mapname] = -1.0;
677 tkinfo_tree->Branch(mapname.c_str(),&tkhmap_value[mapname],
std::string(mapname+
"/F").c_str());
686 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"I cannot find the SiStrip top level directory in the DQM file";
690 dirname=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of(
"/"));
691 edm::LogInfo(
"SiStripTrackerMapCreator::createInfoFile") <<
"SiStrip top level directory is " <<
dirname;
695 std::vector<TkHistoMap> tkHMaps;
697 uint32_t nHists = map_names.size();
707 for(uint32_t ih = 0; ih < nHists; ++ih) {
709 if(map_names.at(ih) !=
"QTestAlarm") {
710 std::string tkhmap_name =
"TkHMap_" + map_names.at(ih);
711 tkHMaps.at(ih).loadTkHistoMap(dirname, tkhmap_name,
true);
715 for(std::vector<uint32_t>::const_iterator idet = detidList.begin(); idet != detidList.end(); ++idet) {
717 for(uint32_t ih = 0; ih < nHists; ++ih) {
718 if(map_names.at(ih) ==
"QTestAlarm") {
722 tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih).getValue(det_id);
726 edm::LogError(
"SiStripTrackerMapCreator::createInfoFile") <<
"Tree not found!";
static const char runNumber_[]
T getUntrackedParameter(std::string const &, T const &) const
int64_t getIntValue() const
const std::string & pwd() const
void setSiStripFolderName(std::string name)
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
TProfile2D * getTProfile2D() const
uint16_t getDetectorFlag(uint32_t det_id)
void save_as_psutrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="psu_svgmap.svg", int width=100+(360+100)*5+300, int height=50+(150+50)*6+300)
edm::ESHandle< SiStripDetCabling > detcabling_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static void getDetectorStatusColor(int status, int &rval, int &gval, int &bval)
const std::string & getName() const
get name of ME
uint16_t getDetectorFlagAndComment(DQMStore *dqm_store, uint32_t det_id, const TrackerTopology *tTopo, std::ostringstream &comment)
void printBadModuleList(std::map< unsigned int, std::string > *badmodmap, const edm::EventSetup &eSetup)
~SiStripTrackerMapCreator()
static void getBadModuleStatus(uint16_t flag, std::string &message)
std::vector< DetId > getDetsForLayer(int layer) const
void setTitle(std::string s)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
static int getLayerNum(const std::string &in)
void setTkMapFromAlarm(DQMStore *dqm_store, const edm::EventSetup &eSetup)
unsigned int tidSide(const DetId &id) const
std::map< uint32_t, uint16_t > detflag_
const edm::EventSetup & eSetup_
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
void setTkMapRangeOffline()
Abs< T >::type abs(const T &t)
bool IsModuleBad(const uint32_t &detid) const
std::string stripTopLevelDir_
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void setTkMapFromHistogram(DQMStore *dqm_store, std::string &htype, const edm::EventSetup &eSetup)
std::vector< MonitorElement * > getContents(const std::string &path) const
std::vector< std::string > getSubdirs() const
void fillc(int idmod, int RGBcode)
bool dirExists(const std::string &path) const
true if directory exists
const SiStripFedCabling * fedCabling() const
Detector identifier class for the strip tracker.
unsigned long long int rval
SubDetector subDetector() const
const std::map< uint32_t, std::vector< const FedChannelConnection * > > & getDetCabling() const
void save_as_fedtrackermap(bool print_total=true, float minval=0., float maxval=0., std::string s="fed_svgmap.svg", int width=100+(90+100)*31+300, int height=150+(2940+150)*1+300)
void cd()
go to top directory (ie. root)
void paintTkMapFromHistogram(DQMStore *dqm_store, MonitorElement *me, std::string &map_type, std::vector< std::pair< float, uint32_t > > *topNmodVec)
TkLayerMap::XYbin cached_XYbin
void createInfoFile(std::vector< std::string > map_names, TTree *tkinfo_tree, DQMStore *dqm_store, std::vector< uint32_t > detidList)
void printTopModules(std::vector< std::pair< float, uint32_t > > *topNmodVec, const edm::EventSetup &eSetup)
const TkDetMap * tkDetMap_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void setRange(float min, float max)
unsigned int layer(const DetId &id) const
double getBinContent(int binx) const
get content of bin (1-D)
void createForOffline(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &htype, const edm::EventSetup &eSetup)
SiStripTrackerMapCreator(const edm::EventSetup &eSetup)
void fill_current_val(int idmod, float current_val)
const TkLayerMap::XYbin & getXY(DetId detid, DetId &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
void setText(int idmod, std::string s)
static bool goToDir(DQMStore *dqm_store, std::string name)
T const * product() const
void setTkMapRange(std::string &map_type)
Kind kind() const
Get the type of the monitor element.
void create(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &htype, const edm::EventSetup &eSetup)
unsigned int tecSide(const DetId &id) const
void paintTkMapFromAlarm(uint32_t det_id, const TrackerTopology *tTopo, DQMStore *dqm_store, bool isBad=false, std::map< unsigned int, std::string > *badmodmap=nullptr)