CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/DQM/SiStripMonitorClient/src/SiStripTrackerMapCreator.cc

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