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 //
62 // -- Begin Job
63 //
65 }
66 //
68 
69  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
70  if (m_cacheID_ == cacheID) return;
71 
72  //Retrieve tracker topology from geometry
74  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
75  const TrackerTopology* const tTopo = tTopoHandle.product();
76 
77  m_cacheID_ = cacheID;
78 
79  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
80  eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
81  eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
82 
83  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
84  " Reading SiStripQuality "<< std::endl;
85 
88  uint32_t detid;
89 
90  if (rbegin==rend) return;
91 
92  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
93 
94  detid = rp->detid;
95  // Check consistency in DetId
96  if (detid == 0 || detid == 0xFFFFFFFF){
97  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::bookHistograms : "
98  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
99  continue;
100  }
101  // check if the detid is connected in cabling
102  if (!detCabling_->IsConnected(detid)) {
103  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::bookHistograms : "
104  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
105  continue;
106  }
107 
108  MonitorElement* det_me;
109 
110  int nStrip = detCabling_->nApvPairs(detid) * 256;
111 
112  // use SistripHistoId for producing histogram id (and title)
113  SiStripHistoId hidmanager;
114  // create SiStripFolderOrganizer
115  SiStripFolderOrganizer folder_organizer;
116  // set appropriate folder using SiStripFolderOrganizer
117  folder_organizer.setDetectorFolder(detid, tTopo); // pass the detid to this method
118 
119  std::string hid;
120  hid = hidmanager.createHistoId("StripQualityFromCondDB","det", detid);
121 
122  det_me = ibooker.book1D(hid, hid, nStrip,0.5,nStrip+0.5);
123  ibooker.tag(det_me, detid);
124  det_me->setAxisTitle("Strip Number",1);
125  det_me->setAxisTitle("Quality Flag from CondDB ",2);
126  QualityMEs.insert( std::make_pair(detid, det_me));
127  }
128 
129 }
130 
131 
132 // ------------ method called to produce the data ------------
134 {
135  unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
136  if (m_cacheID_ == cacheID) return;
137 
138  //Retrieve tracker topology from geometry
139  edm::ESHandle<TrackerTopology> tTopoHandle;
140  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
141  const TrackerTopology* const tTopo = tTopoHandle.product();
142 
143  m_cacheID_ = cacheID;
144 
145  std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
146  eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
147  eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
148 
149  edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
150  " Reading SiStripQuality "<< std::endl;
151 
154  uint32_t detid;
155 
156  if (rbegin==rend) return;
157 
158  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
159 
160  detid = rp->detid;
161  // Check consistency in DetId
162  if (detid == 0 || detid == 0xFFFFFFFF){
163  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
164  << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
165  continue;
166  }
167  // check if the detid is connected in cabling
168  if (!detCabling_->IsConnected(detid)) {
169  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
170  << " DetId " << detid << " not connected, Neglecting !!!!!! ";
171  continue;
172  }
173  MonitorElement* me = getQualityME(detid, tTopo);
175  stripQuality_->getDataVectorBegin()+rp->iend );
176  SiStripBadStrip::ContainerIterator it=range.first;
177  for(;it!=range.second;++it){
178  unsigned int value=(*it);
179  short str_start = stripQuality_->decode(value).firstStrip;
180  short str_end = str_start + stripQuality_->decode(value).range;
181  for ( short isr = str_start; isr < str_end + 1; isr++) {
182  if (isr <= (me->getNbinsX()-1)) me->Fill(isr+1, 1.0);
183  }
184  }
185  }
186 }
187 //
188 // -- End Run
189 //
191  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
193  if (outputMEsInRootFile) {
194  //dqmStore_->showDirStructure();
195  dqmStore_->save(outputFileName);
196  }
197 }
198 //
199 // -- End Job
200 //
202  edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality::EndJob: "
203  << " Finishing!! ";
204 }
205 //
206 // -- End Job
207 //
209 
210  std::map<uint32_t, MonitorElement* >::iterator pos = QualityMEs.find(idet);
211  MonitorElement* det_me = nullptr;
212  if (pos != QualityMEs.end()) {
213  det_me = pos->second;
214  det_me->Reset();
215  } else {
216  //this should never happen because of bookHistograms()
217  edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::getQualityME : "
218  << "Wrong DetId !!!!!! " << idet << " No ME found!";
219  }
220  return det_me;
221 }
223 
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:118
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:291
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2702
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)
const T & get() const
Definition: EventSetup.h:58
RegistryIterator getRegistryVectorBegin() const
const uint16_t nApvPairs(uint32_t det_id) const
SiStripMonitorQuality(const edm::ParameterSet &)
HLT enums.
std::pair< ContainerIterator, ContainerIterator > Range
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:43