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 // system include files
20 #include <memory>
21 
22 // user include files
23 
24 #include <vector>
25 #include <map>
26 
27 //#include "TGraph.h"
28 #include "TH1F.h"
29 
32 
36 
39 
41 
43 
46 
48 
51 
53 //
54 // class decleration
55 //
56 
58 public:
60  ~SiPixelQualityHistory() override;
61 
62  enum { Summary, Module, ROC };
63 
64 private:
65  void beginJob() override;
66  void beginRun(const edm::Run&, const edm::EventSetup&) override;
67  void analyze(const edm::Event&, const edm::EventSetup&) override;
68  void endJob() override;
69 
70  // ----------member data ---------------------------
71 
73  const std::vector<edm::ParameterSet> m_monitoredspq;
74  const unsigned int m_mode;
75  const bool m_run;
76  const unsigned int m_maxLS;
77  const unsigned int m_LSfrac;
78  // std::map<std::string,TGraph*> m_history;
79  std::map<std::string, TH1F*> m_history;
80  std::map<std::string, TProfile**> m_badmodrun;
81 };
82 
83 //
84 // constants, enums and typedefs
85 //
86 
87 //
88 // static data member definitions
89 //
90 
91 //
92 // constructors and destructor
93 //
95  : m_rhm(consumesCollector()),
96  m_monitoredspq(iConfig.getParameter<std::vector<edm::ParameterSet> >("monitoredSiPixelQuality")),
97  m_mode(iConfig.getUntrackedParameter<unsigned int>("granularityMode", Module)),
98  m_run(iConfig.getParameter<bool>("runProcess")),
99  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 100)),
100  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 4)),
101  m_history(),
102  m_badmodrun() {
103  //now do what ever initialization is needed
104 
106 
107  for (std::vector<edm::ParameterSet>::const_iterator ps = m_monitoredspq.begin(); ps != m_monitoredspq.end(); ++ps) {
108  std::string name = ps->getParameter<std::string>("name");
109 
110  if (m_run)
111  m_history[name] = tfserv->make<TH1F>(name.c_str(), name.c_str(), 10, 0, 10);
112 
113  char hrunname[400];
114  sprintf(hrunname, "badmodrun_%s", name.c_str());
115  char hruntitle[400];
116  sprintf(hruntitle, "Number of bad modules %s", name.c_str());
117  m_badmodrun[name] = m_rhm.makeTProfile(hrunname, hruntitle, m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
118  }
119 }
120 
122  // do anything here that needs to be done at desctruction time
123  // (e.g. close files, deallocate resources etc.)
124 }
125 
126 //
127 // member functions
128 //
129 
130 // ------------ method called to for each event ------------
132  // edm::LogInfo("EventProcessing") << "event being processed";
133 
134  for (std::vector<edm::ParameterSet>::const_iterator ps = m_monitoredspq.begin(); ps != m_monitoredspq.end(); ++ps) {
135  std::string name = ps->getParameter<std::string>("name");
136  std::string label = ps->getParameter<std::string>("spqLabel");
137 
139  iSetup.get<SiPixelQualityRcd>().get(label, spq);
140 
141  int nbad = 0;
142 
143  if (m_mode == Summary) {
144  // nbad = spq->BadModuleNumber();
145 
146  } else {
147  std::vector<SiPixelQuality::disabledModuleType> bads = spq->getBadComponentList();
148 
149  LogDebug("BadComponents") << bads.size() << " bad components found";
150 
151  for (std::vector<SiPixelQuality::disabledModuleType>::const_iterator bc = bads.begin(); bc != bads.end(); ++bc) {
152  if (m_mode == Module) {
153  if (spq->IsModuleBad(bc->DetID))
154  ++nbad;
155  // if(bc->errorType==0) ++nbad;
156  } else if (m_mode == ROC) {
157  for (int roc = 1; roc < 2 * 2 * 2 * 2 * 2 * 2 * 2 + 1; roc *= 2) {
158  if ((bc->BadRocs & roc) > 0)
159  ++nbad;
160  }
161  }
162  }
163  }
164  if (m_badmodrun.find(name) != m_badmodrun.end() && m_badmodrun[name] && *m_badmodrun[name]) {
165  (*m_badmodrun[name])->Fill(iEvent.orbitNumber(), nbad);
166  }
167  }
168 }
169 
170 void SiPixelQualityHistory::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
171  m_rhm.beginRun(iRun);
172 
173  // loop on all the SiPixelQuality objects to be monitored
174 
175  for (std::vector<edm::ParameterSet>::const_iterator ps = m_monitoredspq.begin(); ps != m_monitoredspq.end(); ++ps) {
176  std::string name = ps->getParameter<std::string>("name");
177  std::string label = ps->getParameter<std::string>("spqLabel");
178 
179  if (m_badmodrun.find(name) != m_badmodrun.end()) {
180  if (m_badmodrun[name] && *m_badmodrun[name]) {
181  (*m_badmodrun[name])->SetCanExtend(TH1::kXaxis);
182  (*m_badmodrun[name])->GetXaxis()->SetTitle("time [Orb#]");
183  (*m_badmodrun[name])->GetYaxis()->SetTitle("bad components");
184  }
185  }
186 
187  if (m_run) {
189  iSetup.get<SiPixelQualityRcd>().get(label, spq);
190 
191  int nbad = 0;
192 
193  if (m_mode == Summary) {
194  // nbad = spq->BadModuleNumber();
195 
196  } else {
197  std::vector<SiPixelQuality::disabledModuleType> bads = spq->getBadComponentList();
198 
199  LogDebug("BadComponents") << bads.size() << " bad components found";
200 
201  for (std::vector<SiPixelQuality::disabledModuleType>::const_iterator bc = bads.begin(); bc != bads.end();
202  ++bc) {
203  if (m_mode == Module) {
204  if (spq->IsModuleBad(bc->DetID))
205  ++nbad;
206  // if(bc->errorType==0) ++nbad;
207  } else if (m_mode == ROC) {
208  for (int roc = 1; roc < 2 * 2 * 2 * 2 * 2 * 2 * 2 + 1; roc *= 2) {
209  if ((bc->BadRocs & roc) > 0)
210  ++nbad;
211  }
212  }
213  }
214  }
215  char runname[100];
216  sprintf(runname, "%d", iRun.run());
217  LogDebug("AnalyzedRun") << name << " " << runname << " " << nbad;
218  m_history[name]->Fill(runname, nbad);
219  }
220  }
221 }
222 
223 // ------------ method called once each job just before starting event loop ------------
225 
226 // ------------ method called once each job just after ending the event loop ------------
228  /*
229  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
230 
231  std::string name = ps->getParameter<std::string>("name");
232  m_history[name]->Write();
233 
234  }
235  */
236 }
237 
238 //define this as a plug-in
SiPixelQuality::IsModuleBad
bool IsModuleBad(const uint32_t &detid) const
Definition: SiPixelQuality.cc:97
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MessageLogger.h
SiPixelQualityRcd
Definition: SiPixelQualityRcd.h:13
ESHandle.h
Module
#define Module(md)
Definition: vmac.h:203
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelQualityHistory::endJob
void endJob() override
Definition: SiPixelQualityHistory.cc:227
SiPixelQualityHistory::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiPixelQualityHistory.cc:170
SiPixelQualityHistory::m_mode
const unsigned int m_mode
Definition: SiPixelQualityHistory.cc:74
SiPixelQualityHistory::Module
Definition: SiPixelQualityHistory.cc:62
EDAnalyzer.h
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
SiPixelQualityHistory::m_maxLS
const unsigned int m_maxLS
Definition: SiPixelQualityHistory.cc:76
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
SiPixelQualityHistory::Summary
Definition: SiPixelQualityHistory.cc:62
SiPixelQualityHistory::m_LSfrac
const unsigned int m_LSfrac
Definition: SiPixelQualityHistory.cc:77
MakerMacros.h
SiPixelQualityHistory
Definition: SiPixelQualityHistory.cc:57
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
RunHistogramManager
Definition: RunHistogramManager.h:210
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelQualityRcd.h
RunInfoPI::m_run
Definition: RunInfoPayloadInspectoHelper.h:21
Service.h
RunHistogramManager.h
SiPixelQualityHistory::ROC
Definition: SiPixelQualityHistory.cc:62
SiPixelQualityHistory::m_history
std::map< std::string, TH1F * > m_history
Definition: SiPixelQualityHistory.cc:79
Run.h
edm::ESHandle< SiPixelQuality >
SiPixelQualityHistory::m_rhm
RunHistogramManager m_rhm
Definition: SiPixelQualityHistory.cc:72
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
SiPixelQualityHistory::~SiPixelQualityHistory
~SiPixelQualityHistory() override
Definition: SiPixelQualityHistory.cc:121
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
SiPixelQualityHistory::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiPixelQualityHistory.cc:131
Event.h
ParameterSet
Definition: Functions.h:16
SiPixelQualityHistory::m_monitoredspq
const std::vector< edm::ParameterSet > m_monitoredspq
Definition: SiPixelQualityHistory.cc:73
RunHistogramManager::beginRun
void beginRun(const edm::Run &iRun)
Definition: RunHistogramManager.cc:101
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
InputTag.h
SiPixelQuality::getBadComponentList
const std::vector< disabledModuleType > getBadComponentList() const
Definition: SiPixelQuality.h:100
SiPixelQualityHistory::beginJob
void beginJob() override
Definition: SiPixelQualityHistory.cc:224
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
SiPixelQualityHistory::m_badmodrun
std::map< std::string, TProfile ** > m_badmodrun
Definition: SiPixelQualityHistory.cc:80
SiPixelQualityHistory::m_run
const bool m_run
Definition: SiPixelQualityHistory.cc:75
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
SiPixelQuality.h
ParameterSet.h
edm::Event
Definition: Event.h:73
label
const char * label
Definition: PFTauDecayModeTools.cc:11
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
SiPixelQualityHistory::SiPixelQualityHistory
SiPixelQualityHistory(const edm::ParameterSet &)
Definition: SiPixelQualityHistory.cc:94
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52