CMS 3D CMS Logo

CastorMonitorModule.cc
Go to the documentation of this file.
8 
9 
10 //**************************************************************//
11 //***************** CastorMonitorModule ******************//
12 //***************** Author: Dmytro Volyanskyy ******************//
13 //***************** Date : 22.11.2008 (first version) *********//
19 //**************************************************************//
20 
21 //---- critical revision 26.06.2014 (Vladimir Popov)
22 
23 //**************************************************************//
24 
26 {
27  fVerbosity = ps.getUntrackedParameter<int>("debug", 0);
28  if(fVerbosity>0) std::cout<<"CastorMonitorModule Constructor(start)"<<std::endl;
29  subsystemname_=ps.getUntrackedParameter<std::string>("subSystemFolder","Castor");
30  inputTokenRaw_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawLabel"));
31  inputTokenReport_ = consumes<HcalUnpackerReport>(ps.getParameter<edm::InputTag>("unpackerReportLabel"));
32  inputTokenDigi_ = consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("digiLabel"));
33  inputTokenRecHitCASTOR_ = consumes<CastorRecHitCollection>(ps.getParameter<edm::InputTag>("CastorRecHitLabel"));
34  inputTokenCastorTowers_ = consumes<CastorTowerCollection>(ps.getParameter<edm::InputTag>("CastorTowerLabel"));
35  JetAlgorithm = consumes<BasicJetCollection>(ps.getParameter<edm::InputTag>("CastorBasicJetsLabel"));
36 
37  NBunchesOrbit = ps.getUntrackedParameter<int>("nBunchesOrbit",3563);
38  showTiming_ = ps.getUntrackedParameter<bool>("showTiming",false);
39 
41 
42  DigiMon_ = nullptr;
43  RecHitMon_ = nullptr;
44  LedMon_ = nullptr;
45 
46  if ( ps.getUntrackedParameter<bool>("DigiMonitor", false) )
47  DigiMon_ = new CastorDigiMonitor(ps);
48 
49  if ( ps.getUntrackedParameter<bool>("RecHitMonitor", false) )
51 
52  if ( ps.getUntrackedParameter<bool>("LEDMonitor", false) )
53  LedMon_ = new CastorLEDMonitor(ps);
54 
55  ievt_ = 0;
56 
57  if(fVerbosity>0) std::cout<<"CastorMonitorModule Constructor(end)"<< std::endl;
58 }
59 
61  if (DigiMon_ != nullptr) delete DigiMon_;
62  if (RecHitMon_ != nullptr) delete RecHitMon_;
63  if (LedMon_ != nullptr) delete LedMon_;
64 }
65 
67  const edm::EventSetup& iSetup) {
68  iSetup.get<CastorDbRecord>().get(conditions_);
69 
71  iSetup.get<CastorPedestalsRcd>().get(dbPedestals);
72  if(!dbPedestals.isValid() && fVerbosity>0) {
73  std::cout<<"CASTOR has no CastorPedestals in the CondDB"<<std::endl;
74  }
75 }
76 
78  const edm::Run& iRun, const edm::EventSetup& iSetup)
79 {
80  if(fVerbosity>0) std::cout<<"CastorMonitorModule::beginRun (start)" << std::endl;
81 
82  if (DigiMon_ != nullptr) { DigiMon_->bookHistograms(ibooker,iRun,iSetup);}
83  if (RecHitMon_ != nullptr) { RecHitMon_->bookHistograms(ibooker,iRun,iSetup); }
84  if (LedMon_ != nullptr) { LedMon_->bookHistograms(ibooker,iRun,iSetup); }
85 
87  char s[60];
88  sprintf(s,"CastorEventProducts");
89  CastorEventProduct = ibooker.book1D(s,s,6,-0.5,5.5);
90  CastorEventProduct->getTH1F()->GetYaxis()->SetTitle("Events");
91  TAxis *xa = CastorEventProduct->getTH1F()->GetXaxis();
92  xa->SetBinLabel(1,"FEDs/3");
93  xa->SetBinLabel(2,"RawData");
94  xa->SetBinLabel(3,"Digi");
95  xa->SetBinLabel(4,"RecHits");
96  xa->SetBinLabel(5,"Towers");
97  xa->SetBinLabel(6,"Jets");
98 
99  sprintf(s,"CASTORUnpackReport");
100  hunpkrep=ibooker.bookProfile(s,s,6,-0.5,5.5, 100,0,1.e10,"");
101  xa = hunpkrep->getTProfile()->GetXaxis();
102  xa->SetBinLabel(1, "N_FEDs");
103  xa->SetBinLabel(2, "SPIGOT_Err");
104  xa->SetBinLabel(3, "empty");
105  xa->SetBinLabel(4, "busy");
106  xa->SetBinLabel(5, "OvF");
107  xa->SetBinLabel(6, "BadDigis");
108 
109  return;
110 }
111 
113  const edm::EventSetup& context) { }
114 
116  const edm::EventSetup& context) {}
117 
119 {}
120 
122 {
123  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (start)"<<std::endl;
124 
125  using namespace edm;
126 
127  irun_ = iEvent.id().run();
128  ilumisec_ = iEvent.luminosityBlock();
129  ievent_ = iEvent.id().event();
130  ibunch_ = iEvent.bunchCrossing() % NBunchesOrbit;
131 
132  if (fVerbosity>1) {
133  std::cout <<"CastorMonitorModule: run="<<irun_<<" LS:"<<ilumisec_
134  <<" evt="<<ievent_<<"\t total count = "<<ievt_<<std::endl;
135  }
136 
137  ievt_++;
138 
139  bool rawOK_ = true;
140  bool digiOK_ = true;
141  bool rechitOK_ = true, towerOK_ = true, jetsOK_ = true;
142  int nDigi = 0, nrecHits = 0, nTowers = 0, nJets=0;
143 
145  iEvent.getByToken(inputTokenRaw_,RawData);
146  if (!RawData.isValid()) rawOK_=false;
147 
148  float fedsUnpacked=0.;
150  iEvent.getByToken(inputTokenReport_,report);
151  if (!report.isValid()) rawOK_=false;
152  else
153  {
154  const std::vector<int> feds = (*report).getFedsUnpacked();
155  fedsUnpacked = float(feds.size());
156  hunpkrep->Fill(0,fedsUnpacked);
157  hunpkrep->Fill(1,report->spigotFormatErrors());
158  hunpkrep->Fill(2,report->emptyEventSpigots());
159  hunpkrep->Fill(3,report->busySpigots());
160  hunpkrep->Fill(4,report->OFWSpigots());
161  hunpkrep->Fill(5,report->badQualityDigis());
162  }
163 
165  iEvent.getByToken(inputTokenDigi_,CastorDigi);
166  if (CastorDigi.isValid()) nDigi = CastorDigi->size();
167  else digiOK_=false;
168 
170  iEvent.getByToken(inputTokenRecHitCASTOR_,CastorHits);
171  if (CastorHits.isValid()) nrecHits=CastorHits->size();
172  else rechitOK_ = false;
173 
175  iEvent.getByToken(inputTokenCastorTowers_,castorTowers);
176  if (castorTowers.isValid()) nTowers = castorTowers->size();
177  else towerOK_ = false;
178 
180  iEvent.getByToken(JetAlgorithm,jets);
181  if(jets.isValid()) nJets = jets->size();
182  else jetsOK_ = false;
183 
184  if(fVerbosity>0)
185  std::cout<<"CastorProductValid(size): RawDataValid="<<RawData.isValid()
186  <<" Digi="<<digiOK_ << "(" <<nDigi<<") Hits="<<rechitOK_<< "("<<nrecHits << ")"
187  <<" Towers="<<towerOK_<< "(" << nTowers << ")"
188  <<" Jets="<<jetsOK_<< "(" << nJets << ")" <<std::endl;
189 
190  CastorEventProduct->Fill(0,fedsUnpacked/3.);
191  CastorEventProduct->Fill(1,rawOK_);
192  CastorEventProduct->Fill(2,digiOK_);
193  CastorEventProduct->Fill(3,rechitOK_);
194  CastorEventProduct->Fill(4,towerOK_);
195  CastorEventProduct->Fill(5,jetsOK_);
196 
197  if(digiOK_) DigiMon_->processEvent(*CastorDigi,*conditions_);
198  if (showTiming_){
199  cpu_timer.stop();
200  if (DigiMon_!=nullptr) std::cout <<"TIMER:: DIGI MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
202  }
203 
204  if(rechitOK_) RecHitMon_->processEvent(*CastorHits);
205  if(showTiming_){
206  cpu_timer.stop();
207  if (RecHitMon_!=nullptr) std::cout<<"TIMER:: RECHIT MONITOR->"<<cpu_timer.cpuTime()<<std::endl;
209  }
210 
211  if(digiOK_) LedMon_->processEvent(*CastorDigi,*conditions_);
212  if (showTiming_){
213  cpu_timer.stop();
214  if(LedMon_!=nullptr) std::cout <<"TIMER:: LED MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
216  }
217 
218  if(towerOK_) RecHitMon_->processEventTowers(*castorTowers);
219  if(jetsOK_) RecHitMon_->processEventJets(*jets);
220 
221  if(fVerbosity>1 && ievt_%100 == 0)
222  std::cout << "CastorMonitorModule: processed "<<ievt_<<" events"<<std::endl;
223  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (end)"<<std::endl;
224  return;
225 }
226 
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
int spigotFormatErrors() const
void start()
Definition: CPUTimer.cc:74
int emptyEventSpigots() const
edm::EDGetTokenT< FEDRawDataCollection > inputTokenRaw_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void endRun(const edm::Run &run, const edm::EventSetup &eventSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup) override
edm::ESHandle< CastorDbService > conditions_
MonitorElement * hunpkrep
int bunchCrossing() const
Definition: EventBase.h:66
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
CastorLEDMonitor * LedMon_
void reset()
Definition: CPUTimer.cc:107
edm::ESHandle< CastorPedestals > dbPedestals
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
void Fill(long long x)
edm::EDGetTokenT< CastorDigiCollection > inputTokenDigi_
edm::EDGetTokenT< CastorTowerCollection > inputTokenCastorTowers_
int iEvent
Definition: GenABIO.cc:230
void processEventJets(const reco::BasicJetCollection &Jets)
CastorMonitorModule(const edm::ParameterSet &ps)
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
CastorDigiMonitor * DigiMon_
Times stop()
Definition: CPUTimer.cc:94
bool isValid() const
Definition: HandleBase.h:74
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
double cpuTime() const
Definition: CPUTimer.cc:158
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
const T & get() const
Definition: EventSetup.h:55
TH1F * getTH1F(void) const
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup) override
edm::EDGetTokenT< BasicJetCollection > JetAlgorithm
int badQualityDigis() const
void analyze(const edm::Event &iEvent, const edm::EventSetup &eventSetup) override
MonitorElement * CastorEventProduct
edm::EventID id() const
Definition: EventBase.h:60
void processEventTowers(const reco::CastorTowerCollection &castorTowers)
HLT enums.
size_type size() const
TProfile * getTProfile(void) const
edm::EDGetTokenT< HcalUnpackerReport > inputTokenReport_
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
CastorRecHitMonitor * RecHitMon_
void processEvent(const CastorRecHitCollection &castorHits)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bool isValid() const
Definition: ESHandle.h:47
edm::EDGetTokenT< CastorRecHitCollection > inputTokenRecHitCASTOR_
int busySpigots() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: Run.h:43