CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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 
39 
41 
43 
46 
48 
51 
52 //
53 // class decleration
54 //
55 
57  public:
60 
61  enum {Module,Fiber,APV};
62 
63  private:
64  virtual void beginJob() ;
65  virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
66  virtual void endRun(const edm::Run&, const edm::EventSetup&) ;
67  virtual void analyze(const edm::Event&, const edm::EventSetup&);
68  virtual void endJob() ;
69 
70  // ----------member data ---------------------------
71 
72  const std::vector<edm::ParameterSet> _monitoredssq;
73  const unsigned int _mode;
74  // std::map<std::string,TGraph*> _history;
75  std::map<std::string,TH1F*> _history;
76 
77 
78 };
79 
80 //
81 // constants, enums and typedefs
82 //
83 
84 //
85 // static data member definitions
86 //
87 
88 //
89 // constructors and destructor
90 //
92  _monitoredssq(iConfig.getParameter<std::vector<edm::ParameterSet> >("monitoredSiStripQuality")),
93  _mode(iConfig.getUntrackedParameter<unsigned int>("granularityMode",Module)),
94  _history()
95 {
96  //now do what ever initialization is needed
97 
99 
100  for(std::vector<edm::ParameterSet>::const_iterator ps=_monitoredssq.begin();ps!=_monitoredssq.end();++ps) {
101 
102  std::string name = ps->getParameter<std::string>("name");
103  // _history[name] = tfserv->make<TGraph>();
104  // _history[name]->SetName(name.c_str()); _history[name]->SetTitle(name.c_str());
105 
106  _history[name] = tfserv->make<TH1F>(name.c_str(),name.c_str(),10,0,10);
107 
108  }
109 
110 }
111 
112 
114 {
115 
116  // do anything here that needs to be done at desctruction time
117  // (e.g. close files, deallocate resources etc.)
118 
119 }
120 
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to for each event ------------
127 void
129 {
130  edm::LogInfo("EventProcessing") << "event being processed";
131 }
132 
133 void
135 {
136 
137  // loop on all the SiStripQuality objects to be monitored
138 
139  for(std::vector<edm::ParameterSet>::const_iterator ps=_monitoredssq.begin();ps!=_monitoredssq.end();++ps) {
140 
141  std::string name = ps->getParameter<std::string>("name");
142  std::string label = ps->getParameter<std::string>("ssqLabel");
143 
144 
146  iSetup.get<SiStripQualityRcd>().get(label,ssq);
147 
148  std::vector<SiStripQuality::BadComponent> bads = ssq->getBadComponentList();
149 
150  edm::LogInfo("Debug") << bads.size() << " bad components found";
151 
152  int nbad=0;
153 
154  for(std::vector<SiStripQuality::BadComponent>::const_iterator bc=bads.begin();bc!=bads.end();++bc) {
155 
156  if(_mode==Module) {
157  if(bc->BadModule) ++nbad;
158  }
159  else if(_mode == Fiber) {
160  for(int fiber=1;fiber<5;fiber*=2) {
161  if((bc->BadFibers & fiber)>0) ++nbad;
162  }
163  }
164  else if(_mode ==APV) {
165  for(int apv=1;apv<33;apv*=2) {
166  if((bc->BadApvs & apv)>0) ++nbad;
167  }
168  }
169  }
170 
171 
172  // _history[name]->SetPoint(_history[name]->GetN(),iRun.run(),nbad);
173  char runname[100];
174  sprintf(runname,"%d",iRun.run());
175  edm::LogInfo("Debug") << name << " " << runname << " " << nbad;
176  _history[name]->Fill(runname,nbad);
177 
178  }
179 
180 
181 
182 }
183 
184 void
186 {}
187 
188 
189 // ------------ method called once each job just before starting event loop ------------
190 void
192 {}
193 
194 // ------------ method called once each job just after ending the event loop ------------
195 void
197 {
198  /*
199  for(std::vector<edm::ParameterSet>::const_iterator ps=_monitoredssq.begin();ps!=_monitoredssq.end();++ps) {
200 
201  std::string name = ps->getParameter<std::string>("name");
202  _history[name]->Write();
203 
204  }
205  */
206 }
207 
208 
209 //define this as a plug-in
RunNumber_t run() const
Definition: RunBase.h:42
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
SiStripQualityHistory(const edm::ParameterSet &)
std::map< std::string, TH1F * > _history
#define Module(md)
Definition: vmac.h:202
const std::vector< edm::ParameterSet > _monitoredssq
int iEvent
Definition: GenABIO.cc:243
virtual void endRun(const edm::Run &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T * make() const
make new ROOT object
Definition: Run.h:33