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