CMS 3D CMS Logo

SiStripMonitorQuality.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorQuality
4 // Class: SiStripMonitorQuality
5 //
13 //
14 // Original Author: Suchandra Dutta
15 // Created: Fri Dec 7 20:50 CET 2007
16 //
17 //
18 
20 
23 
30 
31 
34 
37 
38 // std
39 #include <cstdlib>
40 #include <cmath>
41 #include <numeric>
42 #include <algorithm>
43 
45  dqmStore_(edm::Service<DQMStore>().operator->()),
46  conf_(iConfig),
47  m_cacheID_(0)
48 
49 
50 {
51  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
52  << " Constructing....... ";
53 }
54 
55 
57 {
58  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
59  << " Destructing....... ";
60 }
61 //
63 
64  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
65  if (m_cacheID_ == cacheID) return;
66 
67  //Retrieve tracker topology from geometry
69  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
70  const TrackerTopology* const tTopo = tTopoHandle.product();
71 
72  m_cacheID_ = cacheID;
73 
74  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
75  eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
76  eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
77 
78  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
79  " Reading SiStripQuality "<< std::endl;
80 
83  uint32_t detid;
84 
85  if (rbegin==rend) return;
86 
87  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
88 
89  detid = rp->detid;
90  // Check consistency in DetId
91  if (detid == 0 || detid == 0xFFFFFFFF){
92  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::bookHistograms : "
93  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
94  continue;
95  }
96  // check if the detid is connected in cabling
97  if (!detCabling_->IsConnected(detid)) {
98  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::bookHistograms : "
99  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
100  continue;
101  }
102 
103  MonitorElement* det_me;
104 
105  int nStrip = detCabling_->nApvPairs(detid) * 256;
106 
107  // use SistripHistoId for producing histogram id (and title)
108  SiStripHistoId hidmanager;
109  // create SiStripFolderOrganizer
110  SiStripFolderOrganizer folder_organizer;
111  // set appropriate folder using SiStripFolderOrganizer
112  folder_organizer.setDetectorFolder(detid, tTopo); // pass the detid to this method
113 
114  std::string hid;
115  hid = hidmanager.createHistoId("StripQualityFromCondDB","det", detid);
116 
117  det_me = ibooker.book1D(hid, hid, nStrip,0.5,nStrip+0.5);
118  ibooker.tag(det_me, detid);
119  det_me->setAxisTitle("Strip Number",1);
120  det_me->setAxisTitle("Quality Flag from CondDB ",2);
121  QualityMEs.insert( std::make_pair(detid, det_me));
122  }
123 
124 }
125 
126 
127 // ------------ method called to produce the data ------------
129 {
130  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
131  if (m_cacheID_ == cacheID) return;
132 
133  //Retrieve tracker topology from geometry
134  edm::ESHandle<TrackerTopology> tTopoHandle;
135  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
136  const TrackerTopology* const tTopo = tTopoHandle.product();
137 
138  m_cacheID_ = cacheID;
139 
140  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
141  eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
142  eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
143 
144  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
145  " Reading SiStripQuality "<< std::endl;
146 
149  uint32_t detid;
150 
151  if (rbegin==rend) return;
152 
153  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
154 
155  detid = rp->detid;
156  // Check consistency in DetId
157  if (detid == 0 || detid == 0xFFFFFFFF){
158  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
159  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
160  continue;
161  }
162  // check if the detid is connected in cabling
163  if (!detCabling_->IsConnected(detid)) {
164  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
165  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
166  continue;
167  }
168  MonitorElement* me = getQualityME(detid, tTopo);
170  stripQuality_->getDataVectorBegin()+rp->iend );
171  SiStripBadStrip::ContainerIterator it=range.first;
172  for(;it!=range.second;++it){
173  unsigned int value=(*it);
174  short str_start = stripQuality_->decode(value).firstStrip;
175  short str_end = str_start + stripQuality_->decode(value).range;
176  for ( short isr = str_start; isr < str_end + 1; isr++) {
177  if (isr <= (me->getNbinsX()-1)) me->Fill(isr+1, 1.0);
178  }
179  }
180  }
181 }
182 //
183 // -- End Run
184 //
186  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
188  if (outputMEsInRootFile) {
189  //dqmStore_->showDirStructure();
190  dqmStore_->save(outputFileName);
191  }
192 }
193 //
194 // -- End Job
195 //
197  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality::EndJob: "
198  << " Finishing!! ";
199 }
200 //
201 // -- End Job
202 //
204 
205  std::map<uint32_t, MonitorElement* >::iterator pos = QualityMEs.find(idet);
206  MonitorElement* det_me = nullptr;
207  if (pos != QualityMEs.end()) {
208  det_me = pos->second;
209  det_me->Reset();
210  } else {
211  //this should never happen because of bookHistograms()
212  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::getQualityME : "
213  << "Wrong DetId !!!!!! " << idet << " No ME found!";
214  }
215  return det_me;
216 }
218 
unsigned short range
T getParameter(std::string const &) const
edm::ESHandle< SiStripDetCabling > detCabling_
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< unsigned int >::const_iterator ContainerIterator
bool IsConnected(const uint32_t &det_id) const
Registry::const_iterator RegistryIterator
void Fill(long long x)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
int iEvent
Definition: GenABIO.cc:230
MonitorElement * getQualityME(uint32_t idet, const TrackerTopology *tTopo)
RegistryIterator getRegistryVectorEnd() const
edm::ESHandle< SiStripQuality > stripQuality_
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:283
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: value.py:1
void Reset()
reset ME (ie. contents, errors, etc)
ContainerIterator getDataVectorBegin() const
unsigned short firstStrip
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2443
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) const
SiStripMonitorQuality(const edm::ParameterSet &)
HLT enums.
std::pair< ContainerIterator, ContainerIterator > Range
T get() const
Definition: EventSetup.h:62
unsigned long long m_cacheID_
int getNbinsX() const
get # of bins in X-axis
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
std::map< uint32_t, MonitorElement * > QualityMEs
data decode(const unsigned int &value) const
Definition: Run.h:44