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  std::vector<edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd>> m_spqTokens;
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 // constants, enums and typedefs
86 //
87 
88 //
89 // static data member definitions
90 //
91 
92 //
93 // constructors and destructor
94 //
96  : m_rhm(consumesCollector()),
97  m_monitoredspq(iConfig.getParameter<std::vector<edm::ParameterSet>>("monitoredSiPixelQuality")),
98  m_mode(iConfig.getUntrackedParameter<unsigned int>("granularityMode", Module)),
99  m_run(iConfig.getParameter<bool>("runProcess")),
100  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 100)),
101  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 4)),
102  m_history(),
103  m_badmodrun() {
104  //now do what ever initialization is needed
105 
107 
108  for (const auto& ps : m_monitoredspq) {
109  m_spqTokens.emplace_back(
110  esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{"", ps.getParameter<std::string>("spqLabel")}));
111 
112  std::string name = ps.getParameter<std::string>("name");
113 
114  if (m_run)
115  m_history[name] = tfserv->make<TH1F>(name.c_str(), name.c_str(), 10, 0, 10);
116 
117  char hrunname[400];
118  sprintf(hrunname, "badmodrun_%s", name.c_str());
119  char hruntitle[400];
120  sprintf(hruntitle, "Number of bad modules %s", name.c_str());
121  m_badmodrun[name] = m_rhm.makeTProfile(hrunname, hruntitle, m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
122  }
123 }
124 
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 }
129 
130 //
131 // member functions
132 //
133 
134 // ------------ method called to for each event ------------
136  // edm::LogInfo("EventProcessing") << "event being processed";
137 
138  for (std::size_t iMon = 0; iMon != m_monitoredspq.size(); ++iMon) {
139  std::string name = m_monitoredspq[iMon].getParameter<std::string>("name");
140  const auto& spq = iSetup.getData(m_spqTokens[iMon]);
141 
142  int nbad = 0;
143 
144  if (m_mode == Summary) {
145  // nbad = spq.BadModuleNumber();
146 
147  } else {
148  std::vector<SiPixelQuality::disabledModuleType> bads = spq.getBadComponentList();
149 
150  LogDebug("BadComponents") << bads.size() << " bad components found";
151 
152  for (const auto& bc : bads) {
153  if (m_mode == Module) {
154  if (spq.IsModuleBad(bc.DetID))
155  ++nbad;
156  // if(bc.errorType==0) ++nbad;
157  } else if (m_mode == ROC) {
158  for (int roc = 1; roc < 2 * 2 * 2 * 2 * 2 * 2 * 2 + 1; roc *= 2) {
159  if ((bc.BadRocs & roc) > 0)
160  ++nbad;
161  }
162  }
163  }
164  }
165  if (m_badmodrun.find(name) != m_badmodrun.end() && m_badmodrun[name] && *m_badmodrun[name]) {
166  (*m_badmodrun[name])->Fill(iEvent.orbitNumber(), nbad);
167  }
168  }
169 }
170 
171 void SiPixelQualityHistory::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
172  m_rhm.beginRun(iRun);
173 
174  // loop on all the SiPixelQuality objects to be monitored
175  for (std::size_t iMon = 0; iMon != m_monitoredspq.size(); ++iMon) {
176  const auto& ps = m_monitoredspq[iMon];
177  std::string name = ps.getParameter<std::string>("name");
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) {
188  const auto& spq = iSetup.getData(m_spqTokens[iMon]);
189 
190  int nbad = 0;
191 
192  if (m_mode == Summary) {
193  // nbad = spq.BadModuleNumber();
194 
195  } else {
196  std::vector<SiPixelQuality::disabledModuleType> bads = spq.getBadComponentList();
197 
198  LogDebug("BadComponents") << bads.size() << " bad components found";
199 
200  for (const auto& bc : bads) {
201  if (m_mode == Module) {
202  if (spq.IsModuleBad(bc.DetID))
203  ++nbad;
204  // if(bc.errorType==0) ++nbad;
205  } else if (m_mode == ROC) {
206  for (int roc = 1; roc < 2 * 2 * 2 * 2 * 2 * 2 * 2 + 1; roc *= 2) {
207  if ((bc.BadRocs & roc) > 0)
208  ++nbad;
209  }
210  }
211  }
212  }
213  char runname[100];
214  sprintf(runname, "%d", iRun.run());
215  LogDebug("AnalyzedRun") << name << " " << runname << " " << nbad;
216  m_history[name]->Fill(runname, nbad);
217  }
218  }
219 }
220 
221 // ------------ method called once each job just before starting event loop ------------
223 
224 // ------------ method called once each job just after ending the event loop ------------
226  /*
227  for(std::vector<edm::ParameterSet>::const_iterator ps=m_monitoredspq.begin();ps!=m_monitoredspq.end();++ps) {
228 
229  std::string name = ps->getParameter<std::string>("name");
230  m_history[name]->Write();
231 
232  }
233  */
234 }
235 
236 //define this as a plug-in
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
ESHandle.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelQualityHistory::endJob
void endJob() override
Definition: SiPixelQualityHistory.cc:225
SiPixelQualityHistory::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiPixelQualityHistory.cc:171
SiPixelQualityHistory::m_mode
const unsigned int m_mode
Definition: SiPixelQualityHistory.cc:75
EDAnalyzer.h
SiPixelQualityHistory::ROC
Definition: SiPixelQualityHistory.cc:62
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
SiPixelQualityHistory::m_maxLS
const unsigned int m_maxLS
Definition: SiPixelQualityHistory.cc:77
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
SiPixelQualityHistory::m_LSfrac
const unsigned int m_LSfrac
Definition: SiPixelQualityHistory.cc:78
SiPixelQualityHistory::Module
Definition: SiPixelQualityHistory.cc:62
MakerMacros.h
SiPixelQualityHistory
Definition: SiPixelQualityHistory.cc:57
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:24
Service.h
RunHistogramManager.h
SiPixelQualityHistory::m_history
std::map< std::string, TH1F * > m_history
Definition: SiPixelQualityHistory.cc:80
Run.h
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:125
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelQualityHistory::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiPixelQualityHistory.cc:135
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
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
SiPixelQualityHistory::m_spqTokens
std::vector< edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > > m_spqTokens
Definition: SiPixelQualityHistory.cc:74
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiPixelQualityHistory::beginJob
void beginJob() override
Definition: SiPixelQualityHistory.cc:222
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
SiPixelQualityHistory::m_badmodrun
std::map< std::string, TProfile ** > m_badmodrun
Definition: SiPixelQualityHistory.cc:81
SiPixelQualityHistory::m_run
const bool m_run
Definition: SiPixelQualityHistory.cc:76
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
SiPixelQualityHistory::Summary
Definition: SiPixelQualityHistory.cc:62
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:95
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52