CMS 3D CMS Logo

SiStripQualityHistory.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: SiStripQualityHistory
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 
38 
40 
42 
45 
47 
50 
52 //
53 // class decleration
54 //
55 
57 public:
59  ~SiStripQualityHistory() override;
60 
61  enum { Module, Fiber, APV, Strip };
62 
63 private:
64  void beginJob() override;
65  void beginRun(const edm::Run&, const edm::EventSetup&) override;
66  void analyze(const edm::Event&, const edm::EventSetup&) override;
67  void endJob() override;
68 
69  // ----------member data ---------------------------
70 
72  const std::vector<edm::ParameterSet> _monitoredssq;
73  const unsigned int _mode;
74  const bool m_run;
75  const unsigned int m_maxLS;
76  const unsigned int m_LSfrac;
77  // std::map<std::string,TGraph*> _history;
78  std::map<std::string, TH1F*> _history;
79  std::map<std::string, TProfile**> m_badmodrun;
80 };
81 
82 //
83 // constants, enums and typedefs
84 //
85 
86 //
87 // static data member definitions
88 //
89 
90 //
91 // constructors and destructor
92 //
94  : m_rhm(consumesCollector()),
95  _monitoredssq(iConfig.getParameter<std::vector<edm::ParameterSet> >("monitoredSiStripQuality")),
96  _mode(iConfig.getUntrackedParameter<unsigned int>("granularityMode", Module)),
97  m_run(iConfig.getParameter<bool>("runProcess")),
98  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 100)),
99  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 4)),
100  _history(),
101  m_badmodrun() {
102  //now do what ever initialization is needed
103 
105 
106  for (std::vector<edm::ParameterSet>::const_iterator ps = _monitoredssq.begin(); ps != _monitoredssq.end(); ++ps) {
107  std::string name = ps->getParameter<std::string>("name");
108  // _history[name] = tfserv->make<TGraph>();
109  // _history[name]->SetName(name.c_str()); _history[name]->SetTitle(name.c_str());
110 
111  if (m_run)
112  _history[name] = tfserv->make<TH1F>(name.c_str(), name.c_str(), 10, 0, 10);
113 
114  char hrunname[400];
115  sprintf(hrunname, "badmodrun_%s", name.c_str());
116  char hruntitle[400];
117  sprintf(hruntitle, "Number of bad modules %s", name.c_str());
118  m_badmodrun[name] = m_rhm.makeTProfile(hrunname, hruntitle, m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
119  }
120 }
121 
123  // do anything here that needs to be done at desctruction time
124  // (e.g. close files, deallocate resources etc.)
125 }
126 
127 //
128 // member functions
129 //
130 
131 // ------------ method called to for each event ------------
133  // edm::LogInfo("EventProcessing") << "event being processed";
134 
135  for (std::vector<edm::ParameterSet>::const_iterator ps = _monitoredssq.begin(); ps != _monitoredssq.end(); ++ps) {
136  std::string name = ps->getParameter<std::string>("name");
137  std::string label = ps->getParameter<std::string>("ssqLabel");
138 
140  iSetup.get<SiStripQualityRcd>().get(label, ssq);
141 
142  std::vector<SiStripQuality::BadComponent> bads = ssq->getBadComponentList();
143 
144  LogDebug("BadComponents") << bads.size() << " bad components found";
145 
146  int nbad = 0;
147 
148  if (_mode == Module || _mode == Fiber || _mode == APV) {
149  for (std::vector<SiStripQuality::BadComponent>::const_iterator bc = bads.begin(); bc != bads.end(); ++bc) {
150  if (_mode == Module) {
151  if (bc->BadModule)
152  ++nbad;
153  } else if (_mode == Fiber) {
154  for (int fiber = 1; fiber < 5; fiber *= 2) {
155  if ((bc->BadFibers & fiber) > 0)
156  ++nbad;
157  }
158  } else if (_mode == APV) {
159  for (int apv = 1; apv < 33; apv *= 2) {
160  if ((bc->BadApvs & apv) > 0)
161  ++nbad;
162  }
163  }
164  }
165  } else if (_mode == Strip) {
166  SiStripBadStrip::ContainerIterator dbegin = ssq->getDataVectorBegin();
167  SiStripBadStrip::ContainerIterator dend = ssq->getDataVectorEnd();
168  for (SiStripBadStrip::ContainerIterator data = dbegin; data < dend; ++data) {
169  nbad += ssq->decode(*data).range;
170  }
171  }
172 
173  if (m_badmodrun.find(name) != m_badmodrun.end() && m_badmodrun[name] && *m_badmodrun[name]) {
174  (*m_badmodrun[name])->Fill(iEvent.orbitNumber(), nbad);
175  }
176  }
177 }
178 
179 void SiStripQualityHistory::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
180  m_rhm.beginRun(iRun);
181 
182  // loop on all the SiStripQuality objects to be monitored
183 
184  for (std::vector<edm::ParameterSet>::const_iterator ps = _monitoredssq.begin(); ps != _monitoredssq.end(); ++ps) {
185  std::string name = ps->getParameter<std::string>("name");
186  std::string label = ps->getParameter<std::string>("ssqLabel");
187 
188  if (m_badmodrun.find(name) != m_badmodrun.end()) {
189  if (m_badmodrun[name] && *m_badmodrun[name]) {
190  (*m_badmodrun[name])->SetCanExtend(TH1::kXaxis);
191  (*m_badmodrun[name])->GetXaxis()->SetTitle("time [Orb#]");
192  (*m_badmodrun[name])->GetYaxis()->SetTitle("bad components");
193  }
194  }
195 
196  if (m_run) {
198  iSetup.get<SiStripQualityRcd>().get(label, ssq);
199 
200  std::vector<SiStripQuality::BadComponent> bads = ssq->getBadComponentList();
201 
202  LogDebug("BadComponents") << bads.size() << " bad components found";
203 
204  int nbad = 0;
205 
206  if (_mode == Module || _mode == Fiber || _mode == APV) {
207  for (std::vector<SiStripQuality::BadComponent>::const_iterator bc = bads.begin(); bc != bads.end(); ++bc) {
208  if (_mode == Module) {
209  if (bc->BadModule)
210  ++nbad;
211  } else if (_mode == Fiber) {
212  for (int fiber = 1; fiber < 5; fiber *= 2) {
213  if ((bc->BadFibers & fiber) > 0)
214  ++nbad;
215  }
216  } else if (_mode == APV) {
217  for (int apv = 1; apv < 33; apv *= 2) {
218  if ((bc->BadApvs & apv) > 0)
219  ++nbad;
220  }
221  }
222  }
223  } else if (_mode == Strip) {
226  for (SiStripBadStrip::ContainerIterator data = dbegin; data < dend; ++data) {
227  nbad += ssq->decode(*data).range;
228  }
229  }
230 
231  // _history[name]->SetPoint(_history[name]->GetN(),iRun.run(),nbad);
232  char runname[100];
233  sprintf(runname, "%d", iRun.run());
234  LogDebug("AnalyzedRun") << name << " " << runname << " " << nbad;
235  _history[name]->Fill(runname, nbad);
236  }
237  }
238 }
239 
240 // ------------ method called once each job just before starting event loop ------------
242 
243 // ------------ method called once each job just after ending the event loop ------------
245  /*
246  for(std::vector<edm::ParameterSet>::const_iterator ps=_monitoredssq.begin();ps!=_monitoredssq.end();++ps) {
247 
248  std::string name = ps->getParameter<std::string>("name");
249  _history[name]->Write();
250 
251  }
252  */
253 }
254 
255 //define this as a plug-in
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MessageLogger.h
ESHandle.h
Module
#define Module(md)
Definition: vmac.h:203
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripQualityHistory::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripQualityHistory.cc:132
SiStripBadStrip::decode
data decode(const unsigned int &value) const
Definition: SiStripBadStrip.h:78
EDAnalyzer.h
SiStripQualityHistory::_monitoredssq
const std::vector< edm::ParameterSet > _monitoredssq
Definition: SiStripQualityHistory.cc:72
SiStripBadStrip::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripBadStrip.h:73
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
MakerMacros.h
SiStripQuality::getBadComponentList
const std::vector< BadComponent > & getBadComponentList() const
Definition: SiStripQuality.h:119
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
RunInfoPI::m_run
Definition: RunInfoPayloadInspectoHelper.h:21
SiStripQualityHistory::Module
Definition: SiStripQualityHistory.cc:61
Service.h
RunHistogramManager.h
SiStripQualityRcd
Definition: SiStripDependentRecords.h:56
Run.h
edm::ESHandle< SiStripQuality >
SiStripQualityHistory::APV
Definition: SiStripQualityHistory.cc:61
SiStripQualityHistory
Definition: SiStripQualityHistory.cc:56
SiStripQualityHistory::_history
std::map< std::string, TH1F * > _history
Definition: SiStripQualityHistory.cc:78
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
SiStripBadStrip::getDataVectorEnd
ContainerIterator getDataVectorEnd() const
Definition: SiStripBadStrip.h:74
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
SiStripQualityHistory::beginJob
void beginJob() override
Definition: SiStripQualityHistory.cc:241
ParameterSet
Definition: Functions.h:16
SiStripQualityHistory::Strip
Definition: SiStripQualityHistory.cc:61
SiStripQualityHistory::m_LSfrac
const unsigned int m_LSfrac
Definition: SiStripQualityHistory.cc:76
SiStripQualityHistory::Fiber
Definition: SiStripQualityHistory.cc:61
SiStripQualityHistory::m_run
const bool m_run
Definition: SiStripQualityHistory.cc:74
SiStripQualityHistory::m_maxLS
const unsigned int m_maxLS
Definition: SiStripQualityHistory.cc:75
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
SiStripQualityHistory::m_badmodrun
std::map< std::string, TProfile ** > m_badmodrun
Definition: SiStripQualityHistory.cc:79
SiStripQualityHistory::m_rhm
RunHistogramManager m_rhm
Definition: SiStripQualityHistory.cc:71
SiStripQualityHistory::_mode
const unsigned int _mode
Definition: SiStripQualityHistory.cc:73
SiStripQualityHistory::endJob
void endJob() override
Definition: SiStripQualityHistory.cc:244
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
SiStripQualityHistory::SiStripQualityHistory
SiStripQualityHistory(const edm::ParameterSet &)
Definition: SiStripQualityHistory.cc:93
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
SiStripQuality.h
SiStripQualityHistory::~SiStripQualityHistory
~SiStripQualityHistory() override
Definition: SiStripQualityHistory.cc:122
SiStripQualityRcd.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiStripQualityHistory::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiStripQualityHistory.cc:179
SiStripBadStrip::data::range
unsigned short range
Definition: SiStripBadStrip.h:34
ParameterSet.h
edm::Event
Definition: Event.h:73
SiStripBadStrip::ContainerIterator
std::vector< unsigned int >::const_iterator ContainerIterator
Definition: SiStripBadStrip.h:52
label
const char * label
Definition: PFTauDecayModeTools.cc:11
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52