CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripTrackerMapCreator.cc
Go to the documentation of this file.
9 
12 
15 
20 
21 #include <iostream>
22 
23 //
24 // -- Constructor
25 //
26 /*
27 SiStripTrackerMapCreator::SiStripTrackerMapCreator() {
28  trackerMap_ = 0;
29  if(!edm::Service<TkDetMap>().isAvailable()){
30  edm::LogError("TkHistoMap") <<
31  "\n------------------------------------------"
32  "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
33  "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
34  "\n------------------------------------------";
35  }
36  tkDetMap_=edm::Service<TkDetMap>().operator->();
37 }
38 */
39 SiStripTrackerMapCreator::SiStripTrackerMapCreator(const edm::EventSetup& eSetup): meanToMaxFactor_(2.5),eSetup_(eSetup)
40  //, psumap_()
41 {
42  cached_detid=0;
43  cached_layer=0;
44  trackerMap_ = 0;
47  // psumap_.BuildMap("CalibTracker/SiStripDCS/data/StripPSUDetIDMap_FromJan132010.dat",false);
48  if(!edm::Service<TkDetMap>().isAvailable()){
49  edm::LogError("TkHistoMap") <<
50  "\n------------------------------------------"
51  "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
52  "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
53  "\n------------------------------------------";
54  }
56 }
57 //
58 // -- Destructor
59 //
61  if (trackerMap_) delete trackerMap_;
62 }
63 //
64 // -- Create Geometric and Fed Tracker Map
65 //
67  DQMStore* dqm_store, std::string& map_type,
68  const edm::EventSetup& eSetup) {
69 
70  const SiStripFedCabling* fedcabling = detcabling_->fedCabling();
71 
72  if(!fedcabling) return;
73 
75  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
76  const TrackerTopology* const tTopo = tTopoHandle.product();
77 
78  if (trackerMap_) delete trackerMap_;
79  trackerMap_ = new TrackerMap(tkmapPset, fedcabling,tTopo);
80  std::string tmap_title = " Tracker Map from " + map_type;
81  trackerMap_->setTitle(tmap_title);
82 
83  nDet = 0;
84  tkMapMax_ = 0.0;
85  tkMapMin_ = 0.0;
86  meanToMaxFactor_ = 2.5;
87  useSSQuality_ = false;
88  ssqLabel_ = "";
89  stripTopLevelDir_="SiStrip";
90 
91  if (map_type == "QTestAlarm") {
92  setTkMapFromAlarm(dqm_store, eSetup);
93  /*
94  trackerMap_->fillc_all_blank();
95  const std::vector<uint16_t>& feds = fedcabling->feds();
96  uint32_t detId_save = 0;
97  for(std::vector<unsigned short>::const_iterator ifed = feds.begin();
98  ifed < feds.end(); ifed++){
99  const std::vector<FedChannelConnection> fedChannels = fedcabling->connections( *ifed );
100  for(std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end(); iconn++){
101 
102  uint32_t detId = iconn->detId();
103  if (detId == 0 || detId == 0xFFFFFFFF) continue;
104  if (detId_save != detId) {
105  detId_save = detId;
106  paintTkMapFromAlarm(detId, dqm_store);
107  }
108  }
109  }
110  */
111  } else {
113  setTkMapFromHistogram(dqm_store, map_type, eSetup);
114  setTkMapRange(map_type);
115  }
117  delete trackerMap_;
118  trackerMap_ = 0;
119 }
120 //
121 // -- Create Tracker Map for Offline process
122 //
124  DQMStore* dqm_store, std::string& map_type,
125  const edm::EventSetup& eSetup) {
126 
127  // Determine the strip top level dirctory in the DQM file: it is the path where MechanicalView is minus one directory
128 
129  std::string mdir = "MechanicalView";
130  dqm_store->cd();
131  if (!SiStripUtility::goToDir(dqm_store, mdir)) {
132  edm::LogError("SiStripTopLevelDirNotFound") << "I cannot find the SiStrip top level directory in the DQM file";
133  }
134  else {
135  std::string mechanicalview_dir = dqm_store->pwd();
136  stripTopLevelDir_=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of("/"));
137  edm::LogInfo("SiStripTopLevelDirFound") << "SiStrip top level directory is " << stripTopLevelDir_;
138  }
139  dqm_store->cd();
140 
141  //
142  const SiStripFedCabling* fedcabling = detcabling_->fedCabling();
143 
144  if(!fedcabling) return;
145 
146  edm::ESHandle<TrackerTopology> tTopoHandle;
147  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
148  const TrackerTopology* const tTopo = tTopoHandle.product();
149 
150  if (trackerMap_) delete trackerMap_;
151  trackerMap_ = new TrackerMap(tkmapPset,fedcabling,tTopo);
152 
153  meanToMaxFactor_ = tkmapPset.getUntrackedParameter<double>("meanToMaxFact",2.5);
154  useSSQuality_ = tkmapPset.getUntrackedParameter<bool>("useSSQuality",false);
155  ssqLabel_ = tkmapPset.getUntrackedParameter<std::string>("ssqLabel","");
156  bool tkMapPSU = tkmapPset.getUntrackedParameter<bool>("psuMap",false);
157  bool tkMapFED = tkmapPset.getUntrackedParameter<bool>("fedMap",false);
158  std::string namesuffix = tkmapPset.getUntrackedParameter<std::string>("mapSuffix","");
159 
160  // std::string tmap_title = " Tracker Map from " + map_type;
161  unsigned int runNumber_ = tkmapPset.getUntrackedParameter<unsigned int>("RunNumber",1); //LG
162  std::stringstream ss; //LG
163  ss << runNumber_; //LG
164  sRunNumber = ss.str(); //LG
165  std::cout << sRunNumber << "\n\n\n\n\n\n";
166  std::string tmap_title; //LG
167  if (runNumber_>0) { tmap_title = " Run: " + sRunNumber + ", Tracker Map from " + map_type; } //LG
168  else { tmap_title = " Tracker Map from " + map_type; } //LG
169  trackerMap_->setTitle(tmap_title);
170 
171  if(tkmapPset.exists("TopModules"))
172  topModules=tkmapPset.getUntrackedParameter<bool>("TopModules");
173  else
174  topModules=false;
175 
176  if(tkmapPset.exists("numberTopModules"))
177  numTopModules=tkmapPset.getUntrackedParameter<uint32_t>("numberTopModules");
178  else
179  numTopModules = 20;
180 
181  if (tkmapPset.exists("topModLabel"))
182  topModLabel=tkmapPset.getUntrackedParameter<int32_t>("topModLabel");
183  else
184  topModLabel = " top Modules " + map_type;
185 
186  if (map_type == "QTestAlarm") {
187  setTkMapFromAlarm(dqm_store, eSetup);
188  }
189  else {
190  setTkMapFromHistogram(dqm_store, map_type, eSetup);
191  }
192  // if not overwitten by manual configuration min=0 and max= mean value * meanToMaxFactor_
194 
195  // check manual setting
196 
197  if(tkmapPset.exists("mapMax")) tkMapMax_ = tkmapPset.getUntrackedParameter<double>("mapMax");
198  if(tkmapPset.exists("mapMin")) tkMapMin_ = tkmapPset.getUntrackedParameter<double>("mapMin");
199 
200  edm::LogInfo("TkMapToBeSaved") << "Ready to save TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
201 
202  trackerMap_->save(true, tkMapMin_,tkMapMax_, map_type+namesuffix+".svg");
203  trackerMap_->save(true, tkMapMin_,tkMapMax_, map_type+namesuffix+".png",4500,2400);
204 
205  if(tkMapPSU) {
206 
207  edm::LogInfo("PSUMapToBeSaved") << "Ready to save PSU TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
208  // trackerMap_->save_as_psutrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_psu.svg");
209  trackerMap_->save_as_psutrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_psu.png");
210 
211  }
212 
213  if(tkMapFED) {
214 
215  edm::LogInfo("FEDMapToBeSaved") << "Ready to save FED TkMap " << map_type << namesuffix << " with range set to " << tkMapMin_ << " - " << tkMapMax_;
216  // trackerMap_->save_as_fedtrackermap(true, tkMapMin_,tkMapMax_, map_type+"_fed.svg");
217  trackerMap_->save_as_fedtrackermap(true, tkMapMin_,tkMapMax_, map_type+namesuffix+"_fed.png");
218 
219  }
220 
221  delete trackerMap_;
222  trackerMap_ = 0;
223 }
224 //
225 // -- Fill Tracker Map with QTest Alarms and SiStripQuality bad modules
227 
228  //Retrieve tracker topology from geometry
229  edm::ESHandle<TrackerTopology> tTopoHandle;
230  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
231  const TrackerTopology* const tTopo = tTopoHandle.product();
232 
233  nDet = 0;
234  tkMapMax_ = 0.0;
235  tkMapMin_ = 0.0;
236 
238 
240 
242 
243  std::map<unsigned int,std::string>* badmodmap = new std::map<unsigned int,std::string>;
244 
245  // used to avoid multiple checks on the same detid since the loop is done on the FED channels
246  uint32_t detId_save = 0;
247  // example of loop using SiStripDetCabling
248  for(std::map< uint32_t, std::vector<const FedChannelConnection *> >::const_iterator module = detcabling_->getDetCabling().begin();
249  module!=detcabling_->getDetCabling().end();++module) {
250  uint32_t detId = module->first;
251  if (detId == 0 || detId == 0xFFFFFFFF) continue;
252  if (detId_save != detId) {
253  detId_save = detId;
254  bool isBad = useSSQuality_ && ssq->IsModuleBad(detId);
255  paintTkMapFromAlarm(detId, tTopo, dqm_store,isBad,badmodmap);
256  }
257  else {
258  edm::LogWarning("TwiceTheSameDetId") << "The detid " << detId << " was found already in the loop on SiStripDetCabling";
259  }
260  }
261  //
262  printBadModuleList(badmodmap, eSetup);
263  delete badmodmap;
264 }
265 //
266 void SiStripTrackerMapCreator::printBadModuleList(std::map<unsigned int,std::string>* badmodmap, const edm::EventSetup& eSetup) {
267 
268  //Retrieve tracker topology from geometry
269  edm::ESHandle<TrackerTopology> tTopoHandle;
270  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
271  const TrackerTopology* const tTopo = tTopoHandle.product();
272 
273  bool tibDone=false,tidSide1Done=false,tidSide2Done=false,tobDone=false,tecSide1Done=false,tecSide2Done=false;
274  unsigned int tibFirst=369120277-1,
275  tidSide1First=402664197-1,tidSide2First=402672389-1,
276  tobFirst=436228134-1,
277  tecSide1First=470044965-1,tecSide2First=470307109-1;
278 
279  int ntib=0,ntids1=0,ntids2=0,ntob=0,ntecs1=0,ntecs2=0;
280 
281  for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
282  SiStripDetId ssdetid(badmod->first);
283  if(ssdetid.subDetector()==SiStripDetId::TIB) ntib++;
284  if(ssdetid.subDetector()==SiStripDetId::TID) {
285 
286  if(tTopo->tidSide(ssdetid)==1) ntids1++;
287  if(tTopo->tidSide(ssdetid)==2) ntids2++;
288  }
289  if(ssdetid.subDetector()==SiStripDetId::TOB) ntob++;
290  if(ssdetid.subDetector()==SiStripDetId::TEC) {
291 
292  if(tTopo->tecSide(ssdetid)==1) ntecs1++;
293  if(tTopo->tecSide(ssdetid)==2) ntecs2++;
294  }
295  }
296 
297  // edm::LogVerbatim("BadModuleList") << "Number of bad modules in total:";
298  edm::LogVerbatim("BadModuleList") << "Run: " << sRunNumber << ", Number of bad modules in total:"; //LG
299  edm::LogVerbatim("BadModuleList") << "--------------------------------------------------------------";
300  edm::LogVerbatim("BadModuleList") << "TIB: " << ntib;
301  edm::LogVerbatim("BadModuleList") << "TID/MINUS: " << ntids1;
302  edm::LogVerbatim("BadModuleList") << "TID/PLUS: " << ntids2;
303  edm::LogVerbatim("BadModuleList") << "TOB: " << ntob;
304  edm::LogVerbatim("BadModuleList") << "TEC/MINUS: " << ntecs1;
305  edm::LogVerbatim("BadModuleList") << "TEC/PLUS: " << ntecs2;
306  edm::LogVerbatim("BadModuleList") << "-------------------------------";
307  edm::LogVerbatim("BadModuleList") ;
308  edm::LogVerbatim("BadModuleList") << "List of bad modules per partition:";
309  edm::LogVerbatim("BadModuleList") << "----------------------------------";
310 
311  for(std::map<unsigned int,std::string>::const_iterator badmod = badmodmap->begin(); badmod!= badmodmap->end(); ++badmod) {
312  if(!tibDone && badmod->first >= tibFirst) {
313  tibDone = true;
314  edm::LogVerbatim("BadModuleList") ;
315  edm::LogVerbatim("BadModuleList") << "SubDetector TIB";
316  edm::LogVerbatim("BadModuleList") ;
317  }
318  if(!tidSide1Done && badmod->first >= tidSide1First) {
319  tidSide1Done = true;
320  edm::LogVerbatim("BadModuleList") ;
321  edm::LogVerbatim("BadModuleList") << "SubDetector TID/MINUS";
322  edm::LogVerbatim("BadModuleList") ;
323  }
324  if(!tidSide2Done && badmod->first >= tidSide2First) {
325  tidSide2Done = true;
326  edm::LogVerbatim("BadModuleList") ;
327  edm::LogVerbatim("BadModuleList") << "SubDetector TID/PLUS";
328  edm::LogVerbatim("BadModuleList") ;
329  }
330  if(!tobDone && badmod->first >= tobFirst) {
331  tobDone = true;
332  edm::LogVerbatim("BadModuleList") ;
333  edm::LogVerbatim("BadModuleList") << "SubDetector TOB";
334  edm::LogVerbatim("BadModuleList") ;
335  }
336  if(!tecSide1Done && badmod->first >= tecSide1First) {
337  tecSide1Done = true;
338  edm::LogVerbatim("BadModuleList") ;
339  edm::LogVerbatim("BadModuleList") << "SubDetector TEC/MINUS";
340  edm::LogVerbatim("BadModuleList") ;
341  }
342  if(!tecSide2Done && badmod->first >= tecSide2First) {
343  tecSide2Done = true;
344  edm::LogVerbatim("BadModuleList") ;
345  edm::LogVerbatim("BadModuleList") << "SubDetector TEC/PLUS";
346  edm::LogVerbatim("BadModuleList") ;
347  }
348  edm::LogVerbatim("BadModuleList") << badmod->second;
349  }
350 }
351 
352 //
353 // -- Paint Tracker Map with QTest Alarms
354 //
356  DQMStore* dqm_store, bool isBad, std::map<unsigned int,std::string>* badmodmap) {
357  std::ostringstream comment;
358  uint16_t flag = 0;
359  flag = getDetectorFlagAndComment(dqm_store, det_id, tTopo, comment);
360 
361  int rval, gval, bval;
362  SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
363  if(isBad) { rval=255; gval=255; bval = 0; comment << " PCLBadModule ";}
364  trackerMap_->setText(det_id, comment.str());
365  trackerMap_->fillc(det_id, rval, gval, bval);
366 
367  if(badmodmap && (flag!=0 || isBad)){
368  uint lay= tTopo->layer(SiStripDetId(det_id));
369  std::string layer =" Layer "+ std::to_string(lay);
370  (*badmodmap)[det_id] = comment.str() + layer;
371  }
372 
373  detflag_[det_id] = flag;
374 }
375 
376 //
377 // -- Paint Tracker Map from TkHistoMap Histograms
379  dqm_store->cd();
380 
381  std::string mdir = "MechanicalView";
382  if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
383  std::string mechanicalview_dir = dqm_store->pwd();
384 
385  std::vector<std::string> subdet_folder;
386  subdet_folder.push_back("TIB");
387  subdet_folder.push_back("TOB");
388  subdet_folder.push_back("TEC/MINUS");
389  subdet_folder.push_back("TEC/PLUS");
390  subdet_folder.push_back("TID/MINUS");
391  subdet_folder.push_back("TID/PLUS");
392 
393  nDet = 0;
394  tkMapMax_ = 0.0;
395  tkMapMin_ = 0.0;
396  std::vector<std::pair<float,uint32_t> >* topNmodVec = new std::vector<std::pair<float,uint32_t> >;
397 
398  for (std::vector<std::string>::const_iterator it = subdet_folder.begin(); it != subdet_folder.end(); it++) {
399  std::string dname = mechanicalview_dir + "/" + (*it);
400  if (!dqm_store->dirExists(dname)) continue;
401  dqm_store->cd(dname);
402  std::vector<std::string> layerVec = dqm_store->getSubdirs();
403  for (std::vector<std::string>::const_iterator iLayer = layerVec.begin(); iLayer != layerVec.end(); iLayer++) {
404  if ((*iLayer).find("BadModuleList") !=std::string::npos) continue;
405  std::vector<MonitorElement*> meVec = dqm_store->getContents((*iLayer));
406  MonitorElement* tkhmap_me = 0;
408  for (std::vector<MonitorElement*>::const_iterator itkh = meVec.begin(); itkh != meVec.end(); itkh++) {
409  name = (*itkh)->getName();
410  if (name.find("TkHMap") == std::string::npos) continue;
411  if (htype == "QTestAlarm" ){
412  edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
413  tkhmap_me = (*itkh);
414  break;
415  } else if (name.find(htype) != std::string::npos) {
416  tkhmap_me = (*itkh);
417  break;
418  }
419  }
420  if (tkhmap_me != 0) {
421  if (topModules){
422  paintTkMapFromHistogram(dqm_store,tkhmap_me, htype, topNmodVec);
423  }
424  else paintTkMapFromHistogram(dqm_store,tkhmap_me, htype, 0);
425  }
426  }
427  dqm_store->cd(mechanicalview_dir);
428  }
429  dqm_store->cd();
430  if (topModules) printTopModules(topNmodVec, eSetup);
431  delete topNmodVec;
432 }
433 
434 void SiStripTrackerMapCreator::printTopModules(std::vector<std::pair<float,uint32_t> >* topNmodVec, const edm::EventSetup& eSetup){
435 
437  //edm::ESHandle<TrackerTopology> tTopoHandle;
438  //eSetup.get<TrackerTopologyRecord>().get(tTopoHandle);
439  //const TrackerTopology* const tTopo = tTopoHandle.product();
440  edm::ESHandle<TrackerTopology> tTopoHandle;
441  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
442  const TrackerTopology* const tTopo = tTopoHandle.product();
443 
444  if (topNmodVec->empty()) return;
445 
446  std::sort(topNmodVec->rbegin(), topNmodVec->rend());
447  if (topNmodVec->size() > numTopModules) topNmodVec->resize(numTopModules);
448 
449  edm::LogVerbatim("TopModules") << topModLabel;
450  edm::LogVerbatim("TopModules") << "------------------------------------------------------";
451 
452  for (std::vector<std::pair<float, uint32_t> >::const_iterator itNmod = topNmodVec->begin(); itNmod != topNmodVec->end(); itNmod++){
453  std::pair<float, uint32_t> aPair=(*itNmod);
454  uint32_t det_id = aPair.second;
455  std::ostringstream comment;
457  SiStripDetId ssdetid(aPair.second);
458  if(ssdetid.subDetector()==SiStripDetId::TIB) subdetector = "TIB ";
459  if(ssdetid.subDetector()==SiStripDetId::TID){
460  if(tTopo->tidSide(ssdetid)==1) subdetector = "TID/MINUS ";
461  if(tTopo->tidSide(ssdetid)==2) subdetector = "TID/PLUS ";
462  }
463  if(ssdetid.subDetector()==SiStripDetId::TOB) subdetector = "TOB ";
464  if(ssdetid.subDetector()==SiStripDetId::TEC){
465  if(tTopo->tecSide(ssdetid)==1) subdetector = "TEC/MINUS ";
466  if(tTopo->tecSide(ssdetid)==2) subdetector = "TEC/PLUS ";
467  }
468  uint16_t flag = getDetectorFlagAndComment(0, det_id, tTopo, comment);
469  if (flag == 0) edm::LogVerbatim("TopModules") << subdetector << comment.str() << " value: "<< aPair.first;
470  }
471  edm::LogVerbatim("TopModules") << "------------------------------------------------------";
472 }
473 
474 
475 void SiStripTrackerMapCreator::paintTkMapFromHistogram(DQMStore* dqm_store, MonitorElement* me, std::string& htype, std::vector<std::pair<float, uint32_t> >* topNmodVec) {
476 
477  // edm::ESHandle<SiStripQuality> ssq;
478 
479  // if(useSSQuality_) { eSetup_.get<SiStripQualityRcd>().get(ssqLabel_,ssq); }
480 
481  std::string name = me->getName();
482  std::string lname = name.substr(name.find("TkHMap_")+7);
483  lname = lname.substr(lname.find("_T")+1);
484  std::vector<uint32_t> layer_detids;
485  tkDetMap_->getDetsForLayer(tkDetMap_->getLayerNum(lname), layer_detids);
486  for (std::vector<uint32_t>::const_iterator idet = layer_detids.begin(); idet != layer_detids.end(); idet++) {
487  uint32_t det_id= (*idet);
488  if (det_id <= 0) continue;
489  nDet++;
491  float fval = 0.0;
492  if ( (name.find("NumberOfOff") != std::string::npos) || //temporary fix
493  (name.find("NumberOfOnTrackCluster") != std::string::npos) ) {
495  TProfile2D* tp = me->getTProfile2D() ;
496  fval = tp->GetBinEntries(tp->GetBin(xyval.ix, xyval.iy)) * tp->GetBinContent(xyval.ix, xyval.iy);
497  }
498  } else fval = me->getBinContent(xyval.ix, xyval.iy);
499  if (htype == "QTestAlarm") {
500  edm::LogError("ItShouldNotBeHere") << "QTestAlarm map: you should not be here!";
501  /*
502  int rval, gval, bval;
503  std::ostringstream comment;
504  uint32_t flag = 0;
505  flag = getDetectorFlagAndComment(dqm_store, det_id, comment);
506  SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
507  if(useSSQuality_ && ssq->IsModuleBad(det_id)) { rval=255; gval=255; bval = 0;}
508  trackerMap_->fillc(det_id, rval, gval, bval);
509  trackerMap_->setText(det_id, comment.str());
510  */
511  } else {
512  if (fval == 0.0) trackerMap_->fillc(det_id,255, 255, 255);
513  else {
514  trackerMap_->fill_current_val(det_id, fval);
515  if(topNmodVec){
516  auto detPair = std::make_pair(fval,det_id);
517  topNmodVec->push_back(detPair);
518  }
519  }
520  tkMapMax_ += fval;
521  }
522  }
523 }
524 //
525 // -- Get Tracker Map Fill Range
526 //
528  tkMapMin_ = 0.0;
529  if (tkMapMax_ == 0.0) {
530  if (map_type.find("FractionOfBadChannels") != std::string::npos) tkMapMax_ = 1.0;
531  else if (map_type.find("NumberOfCluster") != std::string::npos) tkMapMax_ = 0.01;
532  else if (map_type.find("NumberOfDigi") != std::string::npos) tkMapMax_ = 0.6;
533  else if (map_type.find("NumberOfOffTrackCluster") != std::string::npos) tkMapMax_ = 100.0;
534  else if (map_type.find("NumberOfOnTrackCluster") != std::string::npos) tkMapMax_ = 50.0;
535  else if (map_type.find("StoNCorrOnTrack") != std::string::npos) tkMapMax_ = 200.0;
536  } else {
537  tkMapMax_ = tkMapMax_/nDet*1.0;
539  }
541 }
543  tkMapMin_ = 0.0;
544  if (tkMapMax_ != 0.0) {
545  tkMapMax_ = tkMapMax_/(nDet*1.0);
547  }
548  // the following line seems to be useless and misleading: in the offline map creation the range is set with the save... methods
549  // trackerMap_->setRange(tkMapMin_, tkMapMax_);
550 }
551 //
552 // -- Get Flag and status Comment
553 //
555  const TrackerTopology* tTopo, std::ostringstream& comment) {
556  // comment << " DetId " << det_id << " : ";
557  comment << "Module " << det_id;
558  uint16_t flag = 0;
559 
560  // get FED channels corresponding to the det_id
561 
562  // if(detcabling_) {
563  comment << " FEDCHs ";
564  std::vector<const FedChannelConnection*> conns = detcabling_->getConnections(det_id);
565  for(unsigned int i=0; i< conns.size() ;++i) {
566  if(conns[i]) {
567  comment << std::setw(3) << conns[i]->fedId() << "/" << std::setw(2) << conns[i]->fedCh()<< " ";
568  }
569  else {
570  comment << " ";
571  }
572  }
573  if(conns.size()==0) { comment << " "; }
574  if(conns.size()==1) { comment << " "; }
575  if(conns.size()==2) { comment << " "; }
576  // }
577  if(!dqm_store) return flag;
578  // get PSU channel corresponding to the det_id
579  /*
580  comment << " PSU: ";
581  comment << psumap_.getPSUName(det_id);
582  */
583  //
584 
585  SiStripFolderOrganizer folder_organizer;
586  std::string subdet_folder, badmodule_folder;
587 
588  dqm_store->cd();
589 
590  folder_organizer.setSiStripFolderName(stripTopLevelDir_);
591  folder_organizer.getSubDetFolder(det_id, tTopo, subdet_folder);
592 
593  LogDebug("SearchBadModule") << det_id << " " << subdet_folder << " " << stripTopLevelDir_;
594 
595  if (dqm_store->dirExists(subdet_folder)){
596  badmodule_folder = subdet_folder + "/BadModuleList";
597  LogDebug("SearchBadModule") << subdet_folder << " exists: " << badmodule_folder;
598  } else {
599  // badmodule_folder = dqm_store->pwd() + "/BadModuleList";
600  edm::LogError("SubDetFolderNotFound") << subdet_folder << " does not exist for detid " << det_id;
601  return flag;
602  }
603  if (!dqm_store->dirExists(badmodule_folder)) {
604  LogDebug("BadModuleFolderNotFound") << badmodule_folder << " does not exist for detid " << det_id;
605  return flag;
606  }
607  std::ostringstream badmodule_path;
608  badmodule_path << badmodule_folder << "/" << det_id;
609  LogDebug("SearchBadModule") << badmodule_folder << " exists: " << badmodule_path;
610 
611  MonitorElement* bad_module_me = dqm_store->get(badmodule_path.str());
612  if (bad_module_me && bad_module_me->kind() == MonitorElement::DQM_KIND_INT) {
613  LogDebug("SearchBadModule") << "Monitor Element found";
614  flag = bad_module_me->getIntValue();
616  SiStripUtility::getBadModuleStatus(flag, message);
617  comment << message.c_str();
618  }
619  return flag;
620 }
621 //
622 // -- create branches for root file with tracker map values by detId and fill it
623 //
624 void SiStripTrackerMapCreator::createInfoFile(std::vector<std::string> map_names, TTree* tkinfo_tree, DQMStore* dqm_store, std::vector<uint32_t> detidList) {
625 
626  std::map<std::string, float> tkhmap_value;
627  int qtalarm_flag = 0;
628  uint32_t det_id = 0;
629 
630  if(!tkinfo_tree) {
631  edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
632  }
633  else {
634  tkinfo_tree->Branch("DetId",&det_id,"DetId/i");
635  for(std::vector<std::string>::const_iterator in = map_names.begin(); in != map_names.end(); ++in) {
636  std::string mapname = (*in);
637  if(mapname == "QTestAlarm") {
638  qtalarm_flag = 0;
639  tkinfo_tree->Branch(mapname.c_str(),&qtalarm_flag,std::string(mapname+"/I").c_str());
640  } else {
641  tkhmap_value[mapname] = -1.0;
642  tkinfo_tree->Branch(mapname.c_str(),&tkhmap_value[mapname],std::string(mapname+"/F").c_str());
643  }
644  }
645 
646  std::string dirname = "";
647 
648  std::string mdir = "MechanicalView";
649  dqm_store->cd();
650  if (!SiStripUtility::goToDir(dqm_store, mdir)) {
651  edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "I cannot find the SiStrip top level directory in the DQM file";
652  }
653  else {
654  std::string mechanicalview_dir = dqm_store->pwd();
655  dirname=mechanicalview_dir.substr(0,mechanicalview_dir.find_last_of("/"));
656  edm::LogInfo("SiStripTrackerMapCreator::createInfoFile") << "SiStrip top level directory is " << dirname;
657  }
658  dqm_store->cd();
659 
660  std::vector<TkHistoMap*> tkHMaps;
661 
662  uint32_t nHists = map_names.size();
663 
664  for(uint32_t ih = 0; ih < nHists; ++ih) {
665  tkHMaps.push_back(new TkHistoMap());
666  if(map_names.at(ih) != "QTestAlarm") {
667  std::string tkhmap_name = "TkHMap_" + map_names.at(ih);
668  tkHMaps.at(ih)->loadTkHistoMap(dirname, tkhmap_name, true);
669  }
670  }
671 
672  for(std::vector<uint32_t>::const_iterator idet = detidList.begin(); idet != detidList.end(); ++idet) {
673  det_id = (*idet);
674  for(uint32_t ih = 0; ih < nHists; ++ih) {
675  if(map_names.at(ih) == "QTestAlarm") {
676  std::ostringstream comment;
677  qtalarm_flag = getDetectorFlag(det_id);
678  } else {
679  tkhmap_value[map_names.at(ih)] = tkHMaps.at(ih)->getValue(det_id);
680  }
681  }
682  if(!tkinfo_tree) {
683  edm::LogError("SiStripTrackerMapCreator::createInfoFile") << "Tree not found!";
684  }
685  else {
686  tkinfo_tree->Fill();
687  }
688  }
689 
690  // delete pointers
691  for(uint32_t ih = 0; ih < nHists; ++ih) {
692  delete tkHMaps.at(ih);
693  }
694 
695  }
696 
697 }
#define LogDebug(id)
int getLayerNum(const std::string &in) const
Definition: TkDetMap.cc:777
static const char runNumber_[]
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void fillc_all_blank()
Definition: TrackerMap.cc:2732
void setSiStripFolderName(std::string name)
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1726
TProfile2D * getTProfile2D(void) 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)
Definition: TrackerMap.cc:1844
TString subdetector
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:704
edm::ESHandle< SiStripDetCabling > detcabling_
bool exists(std::string const &parameterName) const
checks if a parameter exists
static void getDetectorStatusColor(int status, int &rval, int &gval, int &bval)
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)
static void getBadModuleStatus(uint16_t flag, std::string &message)
void paintTkMapFromAlarm(uint32_t det_id, const TrackerTopology *tTopo, DQMStore *dqm_store, bool isBad=false, std::map< unsigned int, std::string > *badmodmap=0)
void setTitle(std::string s)
Definition: TrackerMap.h:127
void fill_all_blank()
Definition: TrackerMap.cc:2740
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)
Definition: TrackerMap.cc:699
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1775
void getDetsForLayer(int layer, std::vector< uint32_t > &output) const
Definition: TkDetMap.cc:695
void setTkMapFromHistogram(DQMStore *dqm_store, std::string &htype, const edm::EventSetup &eSetup)
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1804
void fillc(int idmod, int RGBcode)
Definition: TrackerMap.h:104
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:792
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
unsigned long long int rval
Definition: vlib.h:22
SubDetector subDetector() const
Definition: SiStripDetId.h:114
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)
Definition: TrackerMap.cc:2126
void paintTkMapFromHistogram(DQMStore *dqm_store, MonitorElement *me, std::string &map_type, std::vector< std::pair< float, uint32_t > > *topNmodVec)
int64_t getIntValue(void) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
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)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void setRange(float min, float max)
Definition: TrackerMap.cc:671
unsigned int layer(const DetId &id) const
double getBinContent(int binx) const
get content of bin (1-D)
void printonline()
Definition: TrackerMap.cc:2878
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)
Definition: TrackerMap.cc:2750
tuple cout
Definition: gather_cfg.py:145
void setText(int idmod, std::string s)
Definition: TrackerMap.cc:2788
const TkLayerMap::XYbin & getXY(uint32_t &, uint32_t &cached_detid, int16_t &cached_layer, TkLayerMap::XYbin &cached_XYbin) const
Definition: TkDetMap.cc:652
static bool goToDir(DQMStore *dqm_store, std::string name)
Definition: vlib.h:208
void setTkMapRange(std::string &map_type)
void create(const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &htype, const edm::EventSetup &eSetup)
unsigned int tecSide(const DetId &id) const
const std::string & pwd(void) const
Definition: DQMStore.cc:699
#define comment(par)
Definition: vmac.h:161