CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDAQInfo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DQMO/HcalMonitorClient/HcalDAQInfo
4 // Class: HcalDAQInfo
5 //
13 //
14 // Original Author: "Igor Vodopiyanov"
15 // Created: Feb-21 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <stdio.h>
22 #include <math.h>
23 #include <sstream>
24 #include <fstream>
25 #include <exception>
26 
33 
35 
39 
46 
47 //
48 // class declaration
49 //
50 
51 class HcalDAQInfo : public edm::EDAnalyzer {
52  public:
53  explicit HcalDAQInfo(const edm::ParameterSet&);
54  ~HcalDAQInfo();
55 
56  private:
57  virtual void beginJob() override;
58  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
59  virtual void endJob() override ;
60  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override ;
61  virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override ;
62 
63  // ----------member data ---------------------------
64 
76  int debug_;
78 };
79 
80 //
81 // constants, enums and typedefs
82 //
83 
84 //
85 // static data member definitions
86 //
87 
88 //
89 // constructors and destructor
90 //
91 
93 {
94  // now do what ever initialization is needed
95  debug_=iConfig.getUntrackedParameter<int>("debug",0);
96  rootFolder_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal");
98 }
99 
101 {
102  // do anything here that needs to be done at destruction time
103  // (e.g. close files, deallocate resources etc.)
104 }
105 
106 //
107 // member functions
108 //
109 
110 // ------------ method called to for each event ------------
111 void
113 
114 // ------------ method called once each job just before starting event loop ------------
115 void
117 {
118  if (debug_>0) std::cout<<"<HcalDAQInfo::beginJob>"<< std::endl;
119 
121  std::string currDir = dbe_->pwd();
122  if (debug_>0) std::cout << "--- Current Directory " << currDir << std::endl;
123  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
124  if (debug_>0) std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
125 
126  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/");
127 
128  HcalDaqFraction = dbe_->bookFloat("DAQSummary");
129 
130  DAQSummaryMap = dbe_->book2D("DAQSummaryMap","HcalDAQSummaryMap",7,0.,7.,1,0.,1.);
131  DAQSummaryMap->setAxisRange(-1,1,3);
132  DAQSummaryMap->setBinLabel(1,"HB");
133  DAQSummaryMap->setBinLabel(2,"HE");
134  DAQSummaryMap->setBinLabel(3,"HO");
135  DAQSummaryMap->setBinLabel(4,"HF");
136  DAQSummaryMap->setBinLabel(5,"H00");
137  DAQSummaryMap->setBinLabel(6,"H012");
138  DAQSummaryMap->setBinLabel(7,"HFlumi");
139  DAQSummaryMap->setBinLabel(1,"Status",2);
140 
141  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/DAQContents/");
142  HBDaqFraction = dbe_->bookFloat("Hcal_HB");
143  HEDaqFraction = dbe_->bookFloat("Hcal_HE");
144  HODaqFraction = dbe_->bookFloat("Hcal_HO");
145  HFDaqFraction = dbe_->bookFloat("Hcal_HF");
146  HO0DaqFraction = dbe_->bookFloat("Hcal_HO0");
147  HO12DaqFraction = dbe_->bookFloat("Hcal_HO12");
148  HFlumiDaqFraction = dbe_->bookFloat("Hcal_HFlumi");
149 
150 }
151 
152 // ------------ method called once each job just after ending the event loop ------------
153 void
155 {
156  if (debug_>0) std::cout << "<HcalDAQInfo::endJob> " << std::endl;
157 }
158 
159 // ------------ method called just before starting a new run ------------
160 void
162 {
163  if (debug_>0) std::cout<<"<HcalDAQInfo::beginLuminosityBlock>"<<std::endl;
164 }
165 
166 // ------------ method called right after a run ends ------------
167 void
169 {
170  if (debug_>0) {
171  std::cout <<"<HcalDAQInfo::endLuminosityBlock> "<<std::endl;
173  std::string currDir = dbe_->pwd();
174  std::cout << "--- Current Directory " << currDir << std::endl;
175  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
176  std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
177  }
178 
179  HcalDaqFraction->Fill(-1);
180 
181  for (int ii=0; ii<7; ii++) DAQSummaryMap->setBinContent(ii+1,1,-1);
182 
183  HBDaqFraction->Fill(-1);
184  HEDaqFraction->Fill(-1);
185  HODaqFraction->Fill(-1);
186  HFDaqFraction->Fill(-1);
187  HO0DaqFraction->Fill(-1);
188  HO12DaqFraction->Fill(-1);
189  HFlumiDaqFraction->Fill(-1);
190 
192 
193  if( iSetup.find( recordKey ) ) {
194 
195  edm::ESHandle<RunInfo> sumFED;
196  iSetup.get<RunInfoRcd>().get(sumFED);
197 
198  std::vector<int> FedsInIds= sumFED->m_fed_in;
199 
200  float HcalFedCount = 0.;
201  float HBFedCount = 0.;
202  float HEFedCount = 0.;
203  float HFFedCount = 0.;
204  float HOFedCount = 0.;
205  float HO0FedCount = 0.;
206  float HO12FedCount = 0.;
207  float HFlumiFedCount = 0.;
208 
209  // By FED taking into account Nchannels per FED
210 
211  for( unsigned int fedItr=0; fedItr<FedsInIds.size(); ++fedItr ) {
212 
213  int fedID=FedsInIds[fedItr];
214 
215  if (fedID >= 700 && fedID <= 731) {
216  HcalFedCount++;
217  if (fedID >= 700 && fedID <= 717) {
218  HBFedCount++;
219  HEFedCount++;
220  }
221  else if (fedID >= 718 && fedID <= 723) {
222  HFFedCount++;
223  HFlumiFedCount++;
224  }
225  else if (fedID >= 724 && fedID <= 731) {
226  if (fedID%2 == 0) {
227  HOFedCount += 276;
228  HO0FedCount += 84;
229  HO12FedCount += 192;
230  }
231  else {
232  HOFedCount += 264;
233  HO0FedCount += 60;
234  HO12FedCount += 204;
235  }
236  }
237  }
238 
239  //else if ( fedID == 735 ) std::cout<<fedID<<" -- LumiScaler"<<std::endl;
240  }
241 
242  HcalFedCount = (HBFedCount*144+HEFedCount*144+HFFedCount*288+HOFedCount)/9072;
243  HBFedCount /= 18;
244  HEFedCount /= 18;
245  HFFedCount /= 6;
246  HFlumiFedCount /= 6;
247  HOFedCount /= 2160;
248  HO0FedCount /= 576;
249  HO12FedCount /= 1584;
250 
251  DAQSummaryMap->setBinContent(1,1,HBFedCount);
252  DAQSummaryMap->setBinContent(2,1,HEFedCount);
253  DAQSummaryMap->setBinContent(3,1,HOFedCount);
254  DAQSummaryMap->setBinContent(4,1,HFFedCount);
255  DAQSummaryMap->setBinContent(5,1,HO0FedCount);
256  DAQSummaryMap->setBinContent(6,1,HO12FedCount);
257  DAQSummaryMap->setBinContent(7,1,HFlumiFedCount);
258 
259  HcalDaqFraction->Fill(HcalFedCount);
260  HBDaqFraction->Fill(HBFedCount);
261  HEDaqFraction->Fill(HEFedCount);
262  HFDaqFraction->Fill(HFFedCount);
263  HODaqFraction->Fill(HOFedCount);
264  HO0DaqFraction->Fill(HO0FedCount);
265  HO12DaqFraction->Fill(HO12FedCount);
266  HFlumiDaqFraction->Fill(HFlumiFedCount);
267 
268  if (debug_>0) {
269  std::cout<<" HcalFedCount= "<<HcalFedCount<<std::endl;
270  std::cout<<" HBFedCount= "<<HBFedCount<<std::endl;
271  std::cout<<" HEFedCount= "<<HEFedCount<<std::endl;
272  std::cout<<" HFFedCount= "<<HFFedCount<<std::endl;
273  std::cout<<" HOFedCount= "<<HOFedCount<<std::endl;
274  std::cout<<" HO0FedCount= "<<HO0FedCount<<std::endl;
275  std::cout<<" HO12FedCount= "<<HO12FedCount<<std::endl;
276  std::cout<<" HFlumiFedCount= "<<HFlumiFedCount<<std::endl;
277  }
278  }
279  else edm::LogInfo(rootFolder_+"/EventInfo/")<<"No RunInfoRcd"<<std::endl;
280 
281 // ---------------------- end of DAQ Info
282  if (debug_>0) std::cout << "HcalDAQInfo::MEfilled " << std::endl;
283 
284 }
285 
286 //define this as a plug-in
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: HcalDAQInfo.cc:168
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
virtual void beginJob() override
Definition: HcalDAQInfo.cc:116
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: HcalDAQInfo.cc:161
MonitorElement * HO0DaqFraction
Definition: HcalDAQInfo.cc:73
int ii
Definition: cuy.py:588
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:891
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void Fill(long long x)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1921
int iEvent
Definition: GenABIO.cc:230
virtual void endJob() override
Definition: HcalDAQInfo.cc:154
MonitorElement * DAQSummaryMap
Definition: HcalDAQInfo.cc:68
MonitorElement * HBDaqFraction
Definition: HcalDAQInfo.cc:69
MonitorElement * HFDaqFraction
Definition: HcalDAQInfo.cc:72
DQMStore * dbe_
Definition: HcalDAQInfo.cc:66
MonitorElement * HODaqFraction
Definition: HcalDAQInfo.cc:71
const T & get() const
Definition: EventSetup.h:55
HcalDAQInfo(const edm::ParameterSet &)
Definition: HcalDAQInfo.cc:92
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HcalDAQInfo.cc:112
MonitorElement * HcalDaqFraction
Definition: HcalDAQInfo.cc:67
edm::ParameterSet conf_
Definition: HcalDAQInfo.cc:65
MonitorElement * HFlumiDaqFraction
Definition: HcalDAQInfo.cc:75
tuple cout
Definition: gather_cfg.py:121
std::string rootFolder_
Definition: HcalDAQInfo.cc:77
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
MonitorElement * HEDaqFraction
Definition: HcalDAQInfo.cc:70
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125
const std::string & pwd(void) const
Definition: DQMStore.cc:639
MonitorElement * HO12DaqFraction
Definition: HcalDAQInfo.cc:74