CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/DQM/SiStripMonitorClient/src/SiStripTrackerMapCreator.cc

Go to the documentation of this file.
00001 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
00002 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
00003 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00004 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
00005 #include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h"
00006 #include "DQMServices/Core/interface/DQMStore.h"
00007 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00008 
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "FWCore/Framework/interface/EventSetup.h"
00011 
00012 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00013 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00014 
00015 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00016 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00017 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00018 #include "DQM/SiStripMonitorClient/interface/SiStripTrackerMapCreator.h"
00019 
00020 #include <iostream>
00021 
00022 //
00023 // -- Constructor
00024 // 
00025 /*
00026 SiStripTrackerMapCreator::SiStripTrackerMapCreator() {
00027   trackerMap_ = 0;
00028   if(!edm::Service<TkDetMap>().isAvailable()){
00029     edm::LogError("TkHistoMap") <<
00030       "\n------------------------------------------"
00031       "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
00032       "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
00033       "\n------------------------------------------";
00034   }
00035   tkDetMap_=edm::Service<TkDetMap>().operator->();
00036 }
00037 */
00038 SiStripTrackerMapCreator::SiStripTrackerMapCreator(const edm::EventSetup& eSetup): meanToMaxFactor_(2.5),eSetup_(eSetup), psumap_() {
00039   trackerMap_ = 0;
00040   stripTopLevelDir_="";
00041   eSetup_.get<SiStripDetCablingRcd>().get(detcabling_);
00042   psumap_.BuildMap("CalibTracker/SiStripDCS/data/StripPSUDetIDMap_FromJan132010.dat",false);
00043   if(!edm::Service<TkDetMap>().isAvailable()){
00044     edm::LogError("TkHistoMap") <<
00045       "\n------------------------------------------"
00046       "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
00047       "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
00048       "\n------------------------------------------";
00049   }
00050   tkDetMap_=edm::Service<TkDetMap>().operator->();
00051 }
00052 //
00053 // -- Destructor
00054 //
00055 SiStripTrackerMapCreator::~SiStripTrackerMapCreator() {
00056   if (trackerMap_) delete trackerMap_;
00057 }
00058 //
00059 // -- Create Geometric and Fed Tracker Map
00060 //
00061 void SiStripTrackerMapCreator::create(const edm::ParameterSet & tkmapPset, 
00062                                       DQMStore* dqm_store, std::string& map_type) {
00063 
00064   const SiStripFedCabling* fedcabling = detcabling_->fedCabling();
00065 
00066   if(!fedcabling) return;
00067 
00068   if (trackerMap_) delete trackerMap_;
00069   trackerMap_ = new TrackerMap(tkmapPset, fedcabling);
00070   std::string tmap_title = " Tracker Map from  " + map_type;
00071   trackerMap_->setTitle(tmap_title);
00072  
00073   nDet     = 0;
00074   tkMapMax_ = 0.0; 
00075   tkMapMin_ = 0.0; 
00076   meanToMaxFactor_ = 2.5;
00077   useSSQuality_ = false;
00078   ssqLabel_ = "";
00079   stripTopLevelDir_="SiStrip";
00080 
00081   if (map_type == "QTestAlarm") {
00082     setTkMapFromAlarm(dqm_store);
00083     /*
00084     trackerMap_->fillc_all_blank();
00085     const std::vector<uint16_t>& feds = fedcabling->feds(); 
00086     uint32_t detId_save = 0;
00087     for(std::vector<unsigned short>::const_iterator ifed = feds.begin(); 
00088         ifed < feds.end(); ifed++){
00089       const std::vector<FedChannelConnection> fedChannels = fedcabling->connections( *ifed );
00090       for(std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end(); iconn++){
00091         
00092         uint32_t detId = iconn->detId();
00093         if (detId == 0 || detId == 0xFFFFFFFF)  continue;
00094         if (detId_save != detId) {
00095           detId_save = detId;
00096           paintTkMapFromAlarm(detId, dqm_store);
00097         }
00098       }
00099     } 
00100     */
00101   } else {
00102     trackerMap_->fill_all_blank();
00103     setTkMapFromHistogram(dqm_store, map_type);
00104     setTkMapRange(map_type);
00105   }
00106   trackerMap_->printonline();
00107   delete trackerMap_;
00108   trackerMap_ = 0;
00109 }
00110 //
00111 // -- Create Tracker Map for Offline process
00112 //
00113 void SiStripTrackerMapCreator::createForOffline(const edm::ParameterSet & tkmapPset, 
00114                                                 DQMStore* dqm_store, std::string& map_type){
00115 
00116   // Determine the strip top level dirctory in the DQM file: it is the path where MechanicalView is minus one directory
00117 
00118   std::string mdir = "MechanicalView";
00119   dqm_store->cd();
00120   if (!SiStripUtility::goToDir(dqm_store, mdir)) {
00121     edm::LogError("SiStripTopLevelDirNotFound") << "I cannot find the SiStrip top level directory in the DQM file";
00122   }
00123   else {
00124     std::string mechanicalview_dir = dqm_store->pwd();
00125     stripTopLevelDir_=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of("/"));    
00126     edm::LogInfo("SiStripTopLevelDirFound") << "SiStrip top level directory is " << stripTopLevelDir_;
00127   }
00128   dqm_store->cd();
00129 
00130   //
00131   const SiStripFedCabling* fedcabling = detcabling_->fedCabling();
00132 
00133   if(!fedcabling) return;
00134 
00135   if (trackerMap_) delete trackerMap_;
00136   trackerMap_ = new TrackerMap(tkmapPset,fedcabling);
00137 
00138   meanToMaxFactor_ = tkmapPset.getUntrackedParameter<double>("meanToMaxFact",2.5);
00139   useSSQuality_ = tkmapPset.getUntrackedParameter<bool>("useSSQuality",false);
00140   ssqLabel_ = tkmapPset.getUntrackedParameter<std::string>("ssqLabel","");
00141   bool tkMapPSU = tkmapPset.getUntrackedParameter<bool>("psuMap",false);
00142   bool tkMapFED = tkmapPset.getUntrackedParameter<bool>("fedMap",false);
00143   std::string namesuffix = tkmapPset.getUntrackedParameter<std::string>("mapSuffix",""); 
00144  
00145   std::string tmap_title = " Tracker Map from  " + map_type;
00146   trackerMap_->setTitle(tmap_title);
00147 
00148   if (map_type == "QTestAlarm") {
00149     setTkMapFromAlarm(dqm_store);
00150   }
00151   else {
00152     setTkMapFromHistogram(dqm_store, map_type);
00153   }
00154   // if not overwitten by manual configuration min=0 and max= mean value * meanToMaxFactor_
00155   setTkMapRangeOffline();
00156 
00157   // check manual setting
00158   
00159   if(tkmapPset.exists("mapMax")) tkMapMax_ = tkmapPset.getUntrackedParameter<double>("mapMax");
00160   if(tkmapPset.exists("mapMin")) tkMapMin_ = tkmapPset.getUntrackedParameter<double>("mapMin");
00161   
00162   edm::LogInfo("TkMapToBeSaved") << "Ready to save TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
00163   
00164   trackerMap_->save(true, tkMapMin_,tkMapMax_, map_type+namesuffix+".svg");  
00165   trackerMap_->save(true, tkMapMin_,tkMapMax_, map_type+namesuffix+".png",4500,2400);
00166 
00167   if(tkMapPSU) {
00168 
00169     edm::LogInfo("PSUMapToBeSaved") << "Ready to save PSU TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
00170     //    trackerMap_->save_as_psutrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_psu.svg");
00171     trackerMap_->save_as_psutrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_psu.png");
00172 
00173   }
00174 
00175   if(tkMapFED) {
00176 
00177     edm::LogInfo("FEDMapToBeSaved") << "Ready to save FED TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
00178     //    trackerMap_->save_as_fedtrackermap(true, tkMapMin_,tkMapMax_, map_type+"_fed.svg");
00179     trackerMap_->save_as_fedtrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_fed.png");
00180 
00181   }
00182 
00183   delete trackerMap_;
00184   trackerMap_ = 0;
00185 }
00186 //
00187 // -- Fill Tracker Map with QTest Alarms and SiStripQuality bad modules
00188 void SiStripTrackerMapCreator::setTkMapFromAlarm(DQMStore* dqm_store) {
00189 
00190   nDet     = 0;
00191   tkMapMax_ = 0.0; 
00192   tkMapMin_ = 0.0; 
00193 
00194   edm::ESHandle<SiStripQuality> ssq;
00195 
00196   if(useSSQuality_) { eSetup_.get<SiStripQualityRcd>().get(ssqLabel_,ssq);  }
00197 
00198   trackerMap_->fillc_all_blank();
00199 
00200   std::map<unsigned int,std::string>* badmodmap = new std::map<unsigned int,std::string>;
00201 
00202   // used to avoid multiple checks on the same detid since the loop is done on the FED channels
00203     uint32_t detId_save = 0;
00204     // example of loop using SiStripDetCabling
00205     for(std::map< uint32_t, std::vector<const FedChannelConnection *> >::const_iterator module = detcabling_->getDetCabling().begin(); 
00206         module!=detcabling_->getDetCabling().end();++module) {
00207       uint32_t detId = module->first;
00208       if (detId == 0 || detId == 0xFFFFFFFF)  continue;
00209       if (detId_save != detId) {
00210         detId_save = detId;
00211         bool isBad = useSSQuality_ && ssq->IsModuleBad(detId);
00212         paintTkMapFromAlarm(detId, dqm_store,isBad,badmodmap);
00213       } 
00214       else {
00215         edm::LogWarning("TwiceTheSameDetId") << "The detid " << detId << " was found already in the loop on SiStripDetCabling";
00216       }
00217     }
00218     //
00219     printBadModuleList(badmodmap);
00220     delete badmodmap;
00221 }
00222 //
00223 void SiStripTrackerMapCreator::printBadModuleList(std::map<unsigned int,std::string>* badmodmap) {
00224 
00225   bool tibDone=false,tidSide1Done=false,tidSide2Done=false,tobDone=false,tecSide1Done=false,tecSide2Done=false;
00226   unsigned int tibFirst=369120277-1,
00227     tidSide1First=402664197-1,tidSide2First=402672389-1,
00228     tobFirst=436228134-1,
00229     tecSide1First=470044965-1,tecSide2First=470307109-1;
00230 
00231   int ntib=0,ntids1=0,ntids2=0,ntob=0,ntecs1=0,ntecs2=0;
00232 
00233   for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
00234     SiStripDetId ssdetid(badmod->first);
00235     if(ssdetid.subDetector()==SiStripDetId::TIB) ntib++;
00236     if(ssdetid.subDetector()==SiStripDetId::TID) {
00237       TIDDetId tiddetid(ssdetid);
00238       if(tiddetid.side()==1) ntids1++;
00239       if(tiddetid.side()==2) ntids2++;
00240     }
00241     if(ssdetid.subDetector()==SiStripDetId::TOB) ntob++;
00242     if(ssdetid.subDetector()==SiStripDetId::TEC) {
00243       TECDetId tecdetid(ssdetid);
00244       if(tecdetid.side()==1) ntecs1++;
00245       if(tecdetid.side()==2) ntecs2++;
00246     }
00247   }
00248 
00249   edm::LogVerbatim("BadModuleList") << "Number of bad modules in total:";
00250   edm::LogVerbatim("BadModuleList") << "--------------------------------------------------------------";
00251   edm::LogVerbatim("BadModuleList") << "TIB: " << ntib;
00252   edm::LogVerbatim("BadModuleList") << "TID/side_1: " << ntids1;
00253   edm::LogVerbatim("BadModuleList") << "TID/side_2: " << ntids2;
00254   edm::LogVerbatim("BadModuleList") << "TOB: " << ntob;
00255   edm::LogVerbatim("BadModuleList") << "TEC/side_1: " << ntecs1;
00256   edm::LogVerbatim("BadModuleList") << "TEC/side_2: " << ntecs2;
00257   edm::LogVerbatim("BadModuleList") << "-------------------------------";
00258   edm::LogVerbatim("BadModuleList") ;
00259   edm::LogVerbatim("BadModuleList") << "List of bad modules per partition:";
00260   edm::LogVerbatim("BadModuleList") << "----------------------------------";
00261   
00262   for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
00263     if(!tibDone && badmod->first >= tibFirst) {
00264       tibDone = true;
00265       edm::LogVerbatim("BadModuleList") ;
00266       edm::LogVerbatim("BadModuleList") << "SubDetector TIB";
00267       edm::LogVerbatim("BadModuleList") ;
00268     }
00269     if(!tidSide1Done && badmod->first >= tidSide1First) {
00270       tidSide1Done = true;
00271       edm::LogVerbatim("BadModuleList") ;
00272       edm::LogVerbatim("BadModuleList") << "SubDetector TID/side_1";
00273       edm::LogVerbatim("BadModuleList") ;
00274     }
00275     if(!tidSide2Done && badmod->first >= tidSide2First) {
00276       tidSide2Done = true;
00277       edm::LogVerbatim("BadModuleList") ;
00278       edm::LogVerbatim("BadModuleList") << "SubDetector TID/side_2";
00279       edm::LogVerbatim("BadModuleList") ;
00280     }
00281     if(!tobDone && badmod->first >= tobFirst) {
00282       tobDone = true;
00283       edm::LogVerbatim("BadModuleList") ;
00284       edm::LogVerbatim("BadModuleList") << "SubDetector TOB";
00285       edm::LogVerbatim("BadModuleList") ;
00286     }
00287     if(!tecSide1Done && badmod->first >= tecSide1First) {
00288       tecSide1Done = true;
00289       edm::LogVerbatim("BadModuleList") ;
00290       edm::LogVerbatim("BadModuleList") << "SubDetector TEC/side_1";
00291       edm::LogVerbatim("BadModuleList") ;
00292     }
00293     if(!tecSide2Done && badmod->first >= tecSide2First) {
00294       tecSide2Done = true;
00295       edm::LogVerbatim("BadModuleList") ;
00296       edm::LogVerbatim("BadModuleList") << "SubDetector TEC/side_2";
00297       edm::LogVerbatim("BadModuleList") ;
00298     }
00299     edm::LogVerbatim("BadModuleList") << badmod->second;
00300   }
00301 }
00302 
00303 //
00304 // -- Paint Tracker Map with QTest Alarms 
00305 //
00306 void SiStripTrackerMapCreator::paintTkMapFromAlarm(uint32_t det_id, DQMStore* dqm_store, bool isBad, std::map<unsigned int,std::string>* badmodmap) {
00307   
00308   std::ostringstream comment;
00309   uint16_t flag = 0; 
00310   flag = getDetectorFlagAndComment(dqm_store, det_id, comment);
00311 
00312   int rval, gval, bval;
00313   SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
00314   if(isBad) { rval=255; gval=255; bval = 0; comment << " PCLBadModule ";}
00315   trackerMap_->setText(det_id, comment.str());
00316   trackerMap_->fillc(det_id, rval, gval, bval);
00317   if(badmodmap && (flag!=0 || isBad)) (*badmodmap)[det_id] = comment.str();
00318 }
00319 
00320 //
00321 // --  Paint Tracker Map from TkHistoMap Histograms
00322 void SiStripTrackerMapCreator::setTkMapFromHistogram(DQMStore* dqm_store, std::string& htype) {
00323   dqm_store->cd();
00324 
00325   std::string mdir = "MechanicalView";
00326   if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
00327   std::string mechanicalview_dir = dqm_store->pwd();
00328 
00329   std::vector<std::string> subdet_folder;
00330   subdet_folder.push_back("TIB");
00331   subdet_folder.push_back("TOB");
00332   subdet_folder.push_back("TEC/side_1");
00333   subdet_folder.push_back("TEC/side_2");
00334   subdet_folder.push_back("TID/side_1");
00335   subdet_folder.push_back("TID/side_2");
00336 
00337   nDet     = 0;
00338   tkMapMax_ = 0.0; 
00339   tkMapMin_ = 0.0; 
00340 
00341   for (std::vector<std::string>::const_iterator it = subdet_folder.begin(); it != subdet_folder.end(); it++) {
00342     std::string dname = mechanicalview_dir + "/" + (*it);
00343     if (!dqm_store->dirExists(dname)) continue;
00344     dqm_store->cd(dname);  
00345     std::vector<std::string> layerVec = dqm_store->getSubdirs();
00346     for (std::vector<std::string>::const_iterator iLayer = layerVec.begin(); iLayer != layerVec.end(); iLayer++) { 
00347       if ((*iLayer).find("BadModuleList") !=std::string::npos) continue;
00348       std::vector<MonitorElement*> meVec = dqm_store->getContents((*iLayer));
00349       MonitorElement* tkhmap_me = 0;
00350       std::string name;
00351       for (std::vector<MonitorElement*>::const_iterator itkh = meVec.begin();  itkh != meVec.end(); itkh++) {
00352         name = (*itkh)->getName();
00353         if (name.find("TkHMap") == std::string::npos) continue;
00354         if (htype == "QTestAlarm" ){
00355           edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
00356           tkhmap_me = (*itkh);
00357           break;
00358         } else if (name.find(htype) != std::string::npos) {
00359           tkhmap_me = (*itkh);
00360           break; 
00361         } 
00362       }
00363       if (tkhmap_me != 0) {
00364         paintTkMapFromHistogram(dqm_store,tkhmap_me, htype);
00365       } 
00366     }
00367     dqm_store->cd(mechanicalview_dir);
00368   }
00369   dqm_store->cd();
00370 }
00371 void SiStripTrackerMapCreator::paintTkMapFromHistogram(DQMStore* dqm_store, MonitorElement* me, std::string& htype) {
00372 
00373   //  edm::ESHandle<SiStripQuality> ssq;
00374 
00375   //  if(useSSQuality_) { eSetup_.get<SiStripQualityRcd>().get(ssqLabel_,ssq);  }
00376 
00377   std::string name  = me->getName();
00378   std::string lname = name.substr(name.find("TkHMap_")+7);  
00379   lname = lname.substr(lname.find("_T")+1);
00380   std::vector<uint32_t> layer_detids;
00381   tkDetMap_->getDetsForLayer(tkDetMap_->getLayerNum(lname), layer_detids);
00382   for (std::vector<uint32_t>::const_iterator idet = layer_detids.begin(); idet != layer_detids.end(); idet++) {
00383     uint32_t det_id= (*idet);
00384     if (det_id <= 0) continue;
00385     nDet++;
00386     const TkLayerMap::XYbin& xyval = tkDetMap_->getXY(det_id);
00387     float fval = 0.0;
00388     if ( (name.find("NumberOfOfffTrackCluster") != std::string::npos) || 
00389          (name.find("NumberOfOnTrackCluster") != std::string::npos) ) {
00390       if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D) {   
00391         TProfile2D* tp = me->getTProfile2D() ;
00392         fval =  tp->GetBinEntries(tp->GetBin(xyval.ix, xyval.iy)) * tp->GetBinContent(xyval.ix, xyval.iy);
00393       }
00394     } else  fval = me->getBinContent(xyval.ix, xyval.iy);
00395     if (htype == "QTestAlarm") {
00396       edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
00397       /*
00398       int rval, gval, bval;
00399       std::ostringstream comment;
00400       uint32_t flag = 0;
00401       flag = getDetectorFlagAndComment(dqm_store, det_id, comment);
00402       SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
00403       if(useSSQuality_ && ssq->IsModuleBad(det_id)) { rval=255; gval=255; bval = 0;}
00404       trackerMap_->fillc(det_id, rval, gval, bval);
00405       trackerMap_->setText(det_id, comment.str());
00406       */
00407     } else {
00408       if (fval == 0.0) trackerMap_->fillc(det_id,255, 255, 255);  
00409       else {
00410         trackerMap_->fill_current_val(det_id, fval);
00411       }
00412       tkMapMax_ += fval;
00413     }
00414   }
00415 } 
00416 //
00417 // -- Get Tracker Map Fill Range
00418 //
00419 void SiStripTrackerMapCreator::setTkMapRange(std::string& map_type) {
00420   tkMapMin_ = 0.0;
00421   if (tkMapMax_ == 0.0) { 
00422     if (map_type.find("FractionOfBadChannels") != std::string::npos)        tkMapMax_ = 1.0;
00423     else if (map_type.find("NumberOfCluster") != std::string::npos)         tkMapMax_ = 0.01;
00424     else if (map_type.find("NumberOfDigi") != std::string::npos)            tkMapMax_ = 0.6;
00425     else if (map_type.find("NumberOfOffTrackCluster") != std::string::npos) tkMapMax_ = 100.0;
00426     else if (map_type.find("NumberOfOnTrackCluster") != std::string::npos)  tkMapMax_ = 50.0;
00427     else if (map_type.find("StoNCorrOnTrack") != std::string::npos)         tkMapMax_ = 200.0;
00428   } else {
00429     tkMapMax_ = tkMapMax_/nDet*1.0;
00430     tkMapMax_ = tkMapMax_ * meanToMaxFactor_;
00431  }
00432   trackerMap_->setRange(tkMapMin_, tkMapMax_);
00433 }
00434 void SiStripTrackerMapCreator::setTkMapRangeOffline() {
00435   tkMapMin_ = 0.0;
00436   if (tkMapMax_ != 0.0) { 
00437     tkMapMax_ = tkMapMax_/(nDet*1.0);
00438     tkMapMax_ = tkMapMax_ * meanToMaxFactor_;
00439  }
00440   // the following line seems to be useless and misleading: in the offline map creation the range is set with the save... methods
00441   //  trackerMap_->setRange(tkMapMin_, tkMapMax_);
00442 }
00443 //
00444 // -- Get Flag and status Comment
00445 //
00446 uint16_t SiStripTrackerMapCreator::getDetectorFlagAndComment(DQMStore* dqm_store, uint32_t det_id, std::ostringstream& comment) {
00447   //  comment << " DetId " << det_id << " : ";
00448   comment << "Module " << det_id;
00449   uint16_t flag = 0;
00450 
00451   // get FED channels corresponding to the det_id
00452 
00453   //  if(detcabling_) {
00454   comment << " FEDCHs ";
00455   std::vector<const FedChannelConnection*> conns = detcabling_->getConnections(det_id);
00456   for(unsigned int i=0; i< conns.size() ;++i) {
00457     if(conns[i]) {
00458       comment << std::setw(3) << conns[i]->fedId() << "/" << std::setw(2) << conns[i]->fedCh()<< " ";
00459     }
00460     else {
00461       comment << "       ";
00462     }
00463   }
00464   if(conns.size()==0) { comment << "                     ";      }
00465   if(conns.size()==1) { comment << "              ";      }
00466   if(conns.size()==2) { comment << "       ";      }
00467     //  }
00468 
00469   // get PSU channel corresponding to the det_id
00470   /*
00471   comment << " PSU: ";
00472   comment << psumap_.getPSUName(det_id);
00473   */
00474   //
00475 
00476   SiStripFolderOrganizer folder_organizer;
00477   std::string subdet_folder, badmodule_folder;
00478 
00479   dqm_store->cd();
00480 
00481   folder_organizer.setSiStripFolderName(stripTopLevelDir_);
00482   folder_organizer.getSubDetFolder(det_id, subdet_folder);
00483 
00484   LogDebug("SearchBadModule") << det_id << " " << subdet_folder << " " << stripTopLevelDir_;
00485 
00486   if (dqm_store->dirExists(subdet_folder)){ 
00487     badmodule_folder = subdet_folder + "/BadModuleList";
00488     LogDebug("SearchBadModule") << subdet_folder << " exists: " << badmodule_folder;
00489   } else {
00490     //    badmodule_folder = dqm_store->pwd() + "/BadModuleList"; 
00491     edm::LogError("SubDetFolderNotFound") << subdet_folder << " does not exist for detid " << det_id;
00492     return flag;
00493   }
00494   if (!dqm_store->dirExists(badmodule_folder))  {
00495     LogDebug("BadModuleFolderNotFound") << badmodule_folder << " does not exist for detid " << det_id;
00496     return flag;
00497   }
00498   std::ostringstream badmodule_path;
00499   badmodule_path << badmodule_folder << "/" << det_id;
00500   LogDebug("SearchBadModule") << badmodule_folder << " exists: " << badmodule_path;
00501 
00502   MonitorElement* bad_module_me = dqm_store->get(badmodule_path.str());
00503   if (bad_module_me && bad_module_me->kind() == MonitorElement::DQM_KIND_INT) {
00504     LogDebug("SearchBadModule") << "Monitor Element found";
00505     flag = bad_module_me->getIntValue();
00506     std::string message;
00507     SiStripUtility::getBadModuleStatus(flag, message);
00508     comment << message.c_str();
00509   }
00510   return flag;
00511 }