CMS 3D CMS Logo

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