CMS 3D CMS Logo

SiPixelQualityHistory.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: SiPixelQualityHistory
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Sep 18 17:52:00 CEST 2009
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
24 
25 #include <vector>
26 #include <map>
27 
28 //#include "TGraph.h"
29 #include "TH1F.h"
30 
33 
37 
40 
42 
44 
47 
49 
52 
54 //
55 // class decleration
56 //
57 
59  public:
61  ~SiPixelQualityHistory() override;
62 
63  enum {Summary,Module,ROC};
64 
65  private:
66  void beginJob() override ;
67  void beginRun(const edm::Run&, const edm::EventSetup&) override;
68  void analyze(const edm::Event&, const edm::EventSetup&) override;
69  void endJob() override ;
70 
71  // ----------member data ---------------------------
72 
74  const std::vector<edm::ParameterSet> m_monitoredspq;
75  const unsigned int m_mode;
76  const bool m_run;
77  const unsigned int m_maxLS;
78  const unsigned int m_LSfrac;
79  // std::map<std::string,TGraph*> m_history;
80  std::map<std::string,TH1F*> m_history;
81  std::map<std::string,TProfile**> m_badmodrun;
82 
83 };
84 
85 //
86 // constants, enums and typedefs
87 //
88 
89 //
90 // static data member definitions
91 //
92 
93 //
94 // constructors and destructor
95 //
98  m_monitoredspq(iConfig.getParameter<std::vector<edm::ParameterSet> >("monitoredSiPixelQuality")),
99  m_mode(iConfig.getUntrackedParameter<unsigned int>("granularityMode",Module)),
100  m_run(iConfig.getParameter<bool>("runProcess")),
101  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin",100)),
102  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction",4)),
104 {
105  //now do what ever initialization is needed
106 
108 
109  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
110 
111  std::string name = ps->getParameter<std::string>("name");
112 
113  if(m_run) m_history[name] = tfserv->make<TH1F>(name.c_str(),name.c_str(),10,0,10);
114 
115  char hrunname[400];
116  sprintf(hrunname,"badmodrun_%s",name.c_str());
117  char hruntitle[400];
118  sprintf(hruntitle,"Number of bad modules %s",name.c_str());
119  m_badmodrun[name] = m_rhm.makeTProfile(hrunname,hruntitle,m_LSfrac*m_maxLS,0,m_maxLS*262144);
120  }
121 
122 }
123 
124 
126 {
127 
128  // do anything here that needs to be done at desctruction time
129  // (e.g. close files, deallocate resources etc.)
130 
131 }
132 
133 
134 //
135 // member functions
136 //
137 
138 // ------------ method called to for each event ------------
139 void
141 {
142  // edm::LogInfo("EventProcessing") << "event being processed";
143 
144  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
145 
146  std::string name = ps->getParameter<std::string>("name");
147  std::string label = ps->getParameter<std::string>("spqLabel");
148 
149 
150 
152  iSetup.get<SiPixelQualityRcd>().get(label,spq);
153 
154  int nbad=0;
155 
156  if(m_mode==Summary) {
157 
158  // nbad = spq->BadModuleNumber();
159 
160  }
161  else {
162 
163  std::vector<SiPixelQuality::disabledModuleType> bads = spq->getBadComponentList();
164 
165  LogDebug("BadComponents") << bads.size() << " bad components found";
166 
167  for(std::vector<SiPixelQuality::disabledModuleType>::const_iterator bc=bads.begin();bc!=bads.end();++bc) {
168 
169  if(m_mode==Module) {
170  if(spq->IsModuleBad(bc->DetID)) ++nbad;
171  // if(bc->errorType==0) ++nbad;
172  }
173  else if(m_mode == ROC) {
174  for(int roc=1;roc<2*2*2*2*2*2*2+1;roc*=2) {
175  if((bc->BadRocs & roc)>0) ++nbad;
176  }
177  }
178  }
179  }
180  if(m_badmodrun.find(name)!=m_badmodrun.end() && m_badmodrun[name] && *m_badmodrun[name]) {
181  (*m_badmodrun[name])->Fill(iEvent.orbitNumber(),nbad);
182  }
183 
184  }
185 }
186 
187 void
189 {
190 
191  m_rhm.beginRun(iRun);
192 
193  // loop on all the SiPixelQuality objects to be monitored
194 
195  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
196 
197  std::string name = ps->getParameter<std::string>("name");
198  std::string label = ps->getParameter<std::string>("spqLabel");
199 
200  if(m_badmodrun.find(name)!=m_badmodrun.end()) {
201  if(m_badmodrun[name] && *m_badmodrun[name]) {
202  (*m_badmodrun[name])->SetCanExtend(TH1::kXaxis);
203  (*m_badmodrun[name])->GetXaxis()->SetTitle("time [Orb#]"); (*m_badmodrun[name])->GetYaxis()->SetTitle("bad components");
204  }
205  }
206 
207  if(m_run) {
208 
210  iSetup.get<SiPixelQualityRcd>().get(label,spq);
211 
212  int nbad=0;
213 
214  if(m_mode==Summary) {
215 
216  // nbad = spq->BadModuleNumber();
217 
218  }
219  else {
220 
221  std::vector<SiPixelQuality::disabledModuleType> bads = spq->getBadComponentList();
222 
223  LogDebug("BadComponents") << bads.size() << " bad components found";
224 
225  for(std::vector<SiPixelQuality::disabledModuleType>::const_iterator bc=bads.begin();bc!=bads.end();++bc) {
226 
227  if(m_mode==Module) {
228  if(spq->IsModuleBad(bc->DetID)) ++nbad;
229  // if(bc->errorType==0) ++nbad;
230  }
231  else if(m_mode == ROC) {
232  for(int roc=1;roc<2*2*2*2*2*2*2+1;roc*=2) {
233  if((bc->BadRocs & roc)>0) ++nbad;
234  }
235  }
236  }
237  }
238  char runname[100];
239  sprintf(runname,"%d",iRun.run());
240  LogDebug("AnalyzedRun") << name << " " << runname << " " << nbad;
241  m_history[name]->Fill(runname,nbad);
242  }
243  }
244 
245 }
246 
247 // ------------ method called once each job just before starting event loop ------------
248 void
250 {}
251 
252 // ------------ method called once each job just after ending the event loop ------------
253 void
255 {
256  /*
257  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
258 
259  std::string name = ps->getParameter<std::string>("name");
260  m_history[name]->Write();
261 
262  }
263  */
264 }
265 
266 
267 //define this as a plug-in
#define LogDebug(id)
void beginRun(const edm::Run &, const edm::EventSetup &) override
RunNumber_t run() const
Definition: RunBase.h:40
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(const edm::Event &, const edm::EventSetup &) override
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::map< std::string, TH1F * > m_history
RunHistogramManager m_rhm
int iEvent
Definition: GenABIO.cc:230
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
std::map< std::string, TProfile ** > m_badmodrun
const std::vector< edm::ParameterSet > m_monitoredspq
int orbitNumber() const
Definition: EventBase.h:67
const std::vector< disabledModuleType > getBadComponentList() const
bool IsModuleBad(const uint32_t &detid) const
const T & get() const
Definition: EventSetup.h:58
void beginRun(const edm::Run &iRun)
const unsigned int m_LSfrac
HLT enums.
SiPixelQualityHistory(const edm::ParameterSet &)
Definition: Run.h:43
const unsigned int m_maxLS