CMS 3D CMS Logo

SiStripBadComponentInfo.cc
Go to the documentation of this file.
4 
7 
12 
13 #include <iostream>
14 #include <iomanip>
15 #include <cstdio>
16 #include <string>
17 #include <sstream>
18 #include <cmath>
19 
20 //
21 // -- Contructor
22 //
24  bookedStatus_(false),
25  nSubSystem_(6),
26  qualityLabel_(pSet.getParameter<std::string>("StripQualityLabel"))
27 {
28  // Create MessageSender
29  LogDebug( "SiStripBadComponentInfo") << "SiStripBadComponentInfo::Deleting SiStripBadComponentInfo ";
30 }
31 //
32 // -- Destructor
33 //
35  LogDebug("SiStripBadComponentInfo") << "SiStripBadComponentInfo::Deleting SiStripBadComponentInfo ";
36  mapBadAPV.clear();
37  mapBadFiber.clear();
38  mapBadStrip.clear();
39 }
40 //
41 // -- Begin Run
42 //
44 }
45 //
46 // -- Read Condition
47 //
49 
50  LogDebug ("SiStripBadComponentInfo") <<"SiStripBadComponentInfo:: Begining of Run";
51 
52  //Retrieve tracker topology from geometry
53  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle_);
54  const TrackerTopology* const topo = tTopoHandle_.product();
55 
57 
58  auto const& BC = siStripQuality_->getBadComponentList();
59 
60  for (size_t i=0;i<BC.size();++i){
61  int subdet=-999; int component=-999;
62  //&&&&&&&&&&&&&&&&&
63  //Single SubSyste
64  //&&&&&&&&&&&&&&&&&
65  int subDet = DetId(BC[i].detid).subdetId();
66  if ( subDet == StripSubdetector::TIB ){
67  //&&&&&&&&&&&&&&&&&
68  //TIB
69  //&&&&&&&&&&&&&&&&&
70  subdet = 3;
71  component=topo->tibLayer(BC[i].detid);
72  } else if ( subDet == StripSubdetector::TID ) {
73  //&&&&&&&&&&&&&&&&&
74  //TID
75  //&&&&&&&&&&&&&&&&&
76  if (topo->tidSide(BC[i].detid)==2) subdet = 4;
77  else subdet = 5;
78  component = topo->tidWheel(BC[i].detid);
79  } else if ( subDet == StripSubdetector::TOB ) {
80  //&&&&&&&&&&&&&&&&&
81  //TOB
82  //&&&&&&&&&&&&&&&&&
83  subdet = 6;
84  component=topo->tobLayer(BC[i].detid);
85  } else if ( subDet == StripSubdetector::TEC ) {
86  //&&&&&&&&&&&&&&&&&
87  //TEC
88  //&&&&&&&&&&&&&&&&&
89  if (topo->tecSide(BC[i].detid)==2) subdet = 2;
90  else subdet=1;
91  component=topo->tecWheel(BC[i].detid);
92  }
93  fillBadComponentMaps(subdet,component,BC[i]);
94  }
95 
96  //&&&&&&&&&&&&&&&&&&
97  // Single Strip Info
98  //&&&&&&&&&&&&&&&&&&
99 
102 
103  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
104  uint32_t detid=rp->detid;
105  int subdet=-999; int component=-999;
106  DetId detectorId=DetId(detid);
107  int subDet = detectorId.subdetId();
108  if ( subDet == StripSubdetector::TIB ){
109  subdet=3;
110  component=topo->tibLayer(detid);
111  } else if ( subDet == StripSubdetector::TID ) {
112  if (topo->tidSide(detid)==2) subdet = 5;
113  else subdet = 4;
114  component = topo->tidWheel(detid);
115  } else if ( subDet == StripSubdetector::TOB ) {
116  subdet=6;
117  component=topo->tobLayer(detid);
118  } else if ( subDet == StripSubdetector::TEC ) {
119  if (topo->tecSide(detid) == 2) subdet = 2;
120  else subdet=1;
121  component=topo->tecWheel(detid);
122  }
123 
125 
126  for(int it=0;it<sqrange.second-sqrange.first;it++){
127  unsigned int range=siStripQuality_->decode( *(sqrange.first+it) ).range;
128  float val = (mapBadStrip.find(std::make_pair(subdet,component))!=mapBadStrip.end()) ? mapBadStrip.at(std::make_pair(subdet,component)) : 0.;
129  val += range;
130  mapBadStrip[std::make_pair(subdet,component)]=val;
131  }
132  }
133 }
134 //
135 // -- End Run
136 //
138  LogDebug ("SiStripBadComponentInfo") <<"SiStripBadComponentInfo:: End of Run";
139  checkBadComponents(eSetup);
140 }
141 //
142 // -- End Job
143 //
145  LogDebug ("SiStripBadComponentInfo") <<"SiStripBadComponentInfo::dqmEndRun";
146  bookBadComponentHistos(ibooker, igetter);
150 }
151 //
152 // -- Book MEs for SiStrip Dcs Fraction
153 //
155  if (!bookedStatus_) {
156  std::string strip_dir = "";
157  ibooker.cd();
158  // SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
159  if (igetter.dirExists("SiStrip")) {
160  ibooker.cd("SiStrip");
161  strip_dir = ibooker.pwd();
162  }
163  edm::LogInfo ("SiStripBadComponentInfo") << "SiStripBadComponentInfo::bookBadComponentHistos ==> " << strip_dir << " " << ibooker.pwd() << std::endl;
164  if (!strip_dir.empty()) ibooker.setCurrentFolder(strip_dir+"/EventInfo");
165  else ibooker.setCurrentFolder("SiStrip/EventInfo");
166 
167  ibooker.cd();
168  if (!strip_dir.empty()) ibooker.setCurrentFolder(strip_dir+"/EventInfo/BadComponentContents");
169 
170  std::string hname, htitle;
171  hname = "BadAPVMap";
172  htitle = "SiStrip Bad APVs";
173  badAPVME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_+0.5, 10, 0.5, 10.5);
174  badAPVME_->setAxisTitle("Sub Detector Type", 1);
175  badAPVME_->setAxisTitle("Layer/Disc Number", 2);
176 
177  hname = "BadFiberMap";
178  htitle = "SiStrip Bad Fibers";
179  badFiberME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_+0.5, 10, 0.5, 10.5);
180  badFiberME_->setAxisTitle("Sub Detector Type", 1);
181  badFiberME_->setAxisTitle("Layer/Disc Number", 2);
182 
183  hname = "BadStripMap";
184  htitle = "SiStrip Bad Strips";
185  badStripME_ = ibooker.book2D(hname, htitle, nSubSystem_, 0.5, nSubSystem_+0.5, 10, 0.5, 10.5);
186  badStripME_->setAxisTitle("Sub Detector Type", 1);
187  badStripME_->setAxisTitle("Layer/Disc Number", 2);
188 
189  std::vector<std::string> names;
190  names.push_back("TECB");
191  names.push_back("TECF");
192  names.push_back("TIB");
193  names.push_back("TIDB");
194  names.push_back("TIDF");
195  names.push_back("TOB");
196 
197  for (unsigned int i=0; i < names.size(); i++) {
198  badAPVME_->setBinLabel(i+1, names[i]);
199  badFiberME_->setBinLabel(i+1, names[i]);
200  badStripME_->setBinLabel(i+1, names[i]);
201  }
202 
203  bookedStatus_ = true;
204  ibooker.cd();
205  }
206 }
208 
209  auto index = std::make_pair(xbin,component);
210 
211  if (BC.BadApvs){
212  int ntot = std::bitset<16>(BC.BadApvs&0x3f).count();
213  float val = (mapBadAPV.find(index)!=mapBadAPV.end()) ? mapBadAPV.at(index) : 0.;
214  val += ntot;
216  }
217  if (BC.BadFibers){
218  int ntot = std::bitset<16>(BC.BadFibers&0x7).count();
219  float val = (mapBadFiber.find(index)!=mapBadFiber.end()) ? mapBadFiber.at(index) : 0.;
220  val+= ntot;
222  }
223 }
224 void SiStripBadComponentInfo::createSummary(MonitorElement* me,const std::map<std::pair<int,int>,float >& map) {
225  for (int i=1; i<nSubSystem_+1; i++) {
226  float sum = 0.0;
227  for (int k=1; k<me->getNbinsY(); k++) {
228  auto index = std::make_pair(i,k);
229  if (map.find(index)!=map.end()){
230  me->setBinContent(i,k,map.at(index)); // fill the layer/wheel bins
231  sum += map.at(index);
232  }
233  }
234  me->setBinContent(i,me->getNbinsY(), sum); // fill the summary bin (last one)
235  }
236 }
#define LogDebug(id)
unsigned short range
void setBinContent(int binx, double content)
set content of bin (1-D)
const std::vector< BadComponent > & getBadComponentList() const
unsigned int tibLayer(const DetId &id) const
std::map< std::pair< int, int >, float > mapBadFiber
void createSummary(MonitorElement *me, const std::map< std::pair< int, int >, float > &map)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endRun(edm::Run const &, edm::EventSetup const &) override
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
unsigned int tidWheel(const DetId &id) const
Registry::const_iterator RegistryIterator
edm::ESHandle< SiStripQuality > siStripQuality_
const std::string names[nVars_]
void bookBadComponentHistos(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
RegistryIterator getRegistryVectorEnd() const
unsigned int tidSide(const DetId &id) const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
void fillBadComponentMaps(int xbin, int component, SiStripQuality::BadComponent const &BC)
int k[5][pyjets_maxn]
ContainerIterator getDataVectorBegin() const
Definition: DetId.h:18
std::map< std::pair< int, int >, float > mapBadAPV
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::string const & pwd()
Definition: DQMStore.cc:278
bool dirExists(std::string const &path)
Definition: DQMStore.cc:343
void checkBadComponents(edm::EventSetup const &eSetup)
int getNbinsY() const
get # of bins in Y-axis
RegistryIterator getRegistryVectorBegin() const
edm::ESHandle< TrackerTopology > tTopoHandle_
std::pair< ContainerIterator, ContainerIterator > Range
T get() const
Definition: EventSetup.h:68
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::map< std::pair< int, int >, float > mapBadStrip
unsigned int tecWheel(const DetId &id) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:84
data decode(const unsigned int &value) const
unsigned int tobLayer(const DetId &id) const
Definition: Run.h:44
unsigned int tecSide(const DetId &id) const
SiStripBadComponentInfo(const edm::ParameterSet &ps)
Constructor.