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 
112 
113 
115 {}
116 
118 {
119  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (start)"<<std::endl;
120 
121  using namespace edm;
122 
123  irun_ = iEvent.id().run();
124  ilumisec_ = iEvent.luminosityBlock();
125  ievent_ = iEvent.id().event();
126  ibunch_ = iEvent.bunchCrossing() % NBunchesOrbit;
127 
128  if (fVerbosity>1) {
129  std::cout <<"CastorMonitorModule: run="<<irun_<<" LS:"<<ilumisec_
130  <<" evt="<<ievent_<<"\t total count = "<<ievt_<<std::endl;
131  }
132 
133  ievt_++;
134 
135  bool rawOK_ = true;
136  bool digiOK_ = true;
137  bool rechitOK_ = true, towerOK_ = true, jetsOK_ = true;
138  int nDigi = 0, nrecHits = 0, nTowers = 0, nJets=0;
139 
141  iEvent.getByToken(inputTokenRaw_,RawData);
142  if (!RawData.isValid()) rawOK_=false;
143 
144  float fedsUnpacked=0.;
146  iEvent.getByToken(inputTokenReport_,report);
147  if (!report.isValid()) rawOK_=false;
148  else
149  {
150  const std::vector<int> feds = (*report).getFedsUnpacked();
151  fedsUnpacked = float(feds.size());
152  hunpkrep->Fill(0,fedsUnpacked);
153  hunpkrep->Fill(1,report->spigotFormatErrors());
154  hunpkrep->Fill(2,report->emptyEventSpigots());
155  hunpkrep->Fill(3,report->busySpigots());
156  hunpkrep->Fill(4,report->OFWSpigots());
157  hunpkrep->Fill(5,report->badQualityDigis());
158  }
159 
161  iEvent.getByToken(inputTokenDigi_,CastorDigi);
162  if (CastorDigi.isValid()) nDigi = CastorDigi->size();
163  else digiOK_=false;
164 
166  iEvent.getByToken(inputTokenRecHitCASTOR_,CastorHits);
167  if (CastorHits.isValid()) nrecHits=CastorHits->size();
168  else rechitOK_ = false;
169 
171  iEvent.getByToken(inputTokenCastorTowers_,castorTowers);
172  if (castorTowers.isValid()) nTowers = castorTowers->size();
173  else towerOK_ = false;
174 
176  iEvent.getByToken(JetAlgorithm,jets);
177  if(jets.isValid()) nJets = jets->size();
178  else jetsOK_ = false;
179 
180  if(fVerbosity>0)
181  std::cout<<"CastorProductValid(size): RawDataValid="<<RawData.isValid()
182  <<" Digi="<<digiOK_ << "(" <<nDigi<<") Hits="<<rechitOK_<< "("<<nrecHits << ")"
183  <<" Towers="<<towerOK_<< "(" << nTowers << ")"
184  <<" Jets="<<jetsOK_<< "(" << nJets << ")" <<std::endl;
185 
186  CastorEventProduct->Fill(0,fedsUnpacked/3.);
187  CastorEventProduct->Fill(1,rawOK_);
188  CastorEventProduct->Fill(2,digiOK_);
189  CastorEventProduct->Fill(3,rechitOK_);
190  CastorEventProduct->Fill(4,towerOK_);
191  CastorEventProduct->Fill(5,jetsOK_);
192 
193  if(digiOK_) DigiMon_->processEvent(*CastorDigi,*conditions_);
194  if (showTiming_){
195  cpu_timer.stop();
196  if (DigiMon_!=nullptr) std::cout <<"TIMER:: DIGI MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
198  }
199 
200  if(rechitOK_) RecHitMon_->processEvent(*CastorHits);
201  if(showTiming_){
202  cpu_timer.stop();
203  if (RecHitMon_!=nullptr) std::cout<<"TIMER:: RECHIT MONITOR->"<<cpu_timer.cpuTime()<<std::endl;
205  }
206 
207  if(digiOK_) LedMon_->processEvent(*CastorDigi,*conditions_);
208  if (showTiming_){
209  cpu_timer.stop();
210  if(LedMon_!=nullptr) std::cout <<"TIMER:: LED MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
212  }
213 
214  if(towerOK_) RecHitMon_->processEventTowers(*castorTowers);
215  if(jetsOK_) RecHitMon_->processEventJets(*jets);
216 
217  if(fVerbosity>1 && ievt_%100 == 0)
218  std::cout << "CastorMonitorModule: processed "<<ievt_<<" events"<<std::endl;
219  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (end)"<<std::endl;
220  return;
221 }
222 
RunNumber_t run() const
Definition: EventID.h:39
TProfile * getTProfile() const
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:160
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
TH1F * getTH1F() const
void endRun(const edm::Run &run, const edm::EventSetup &eventSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:118
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:274
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
T get() const
Definition: EventSetup.h:63
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:44