CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorMonitorModule.cc
Go to the documentation of this file.
6 
7 //**************************************************************//
8 //***************** CastorMonitorModule ******************//
9 //***************** Author: Dmytro Volyanskyy ******************//
10 //***************** Date : 22.11.2008 (first version) *********//
16 //**************************************************************//
17 
18 //---- critical revision 26.06.2014 (Vladimir Popov)
19 
20 //==================================================================//
21 //======================= Constructor ==============================//
23 {
24  fVerbosity = ps.getUntrackedParameter<int>("debug", 0);
25  if(fVerbosity>0) std::cout<<"CastorMonitorModule Constructor(start)"<<std::endl;
26 
27  inputTokenRaw_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawLabel"));
28  inputTokenReport_ = consumes<HcalUnpackerReport>(ps.getParameter<edm::InputTag>("unpackerReportLabel"));
29  inputTokenDigi_ = consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("digiLabel"));
30  inputTokenRecHitCASTOR_ = consumes<CastorRecHitCollection>(ps.getParameter<edm::InputTag>("CastorRecHitLabel"));
31  inputTokenCastorTowers_ = consumes<CastorTowerCollection>(ps.getParameter<edm::InputTag>("CastorTowerLabel"));
32  JetAlgorithm = consumes<BasicJetCollection>(ps.getParameter<edm::InputTag>("CastorBasicJetsLabel"));
33 
34  NBunchesOrbit = ps.getUntrackedParameter<int>("nBunchesOrbit",3563);
35  showTiming_ = ps.getUntrackedParameter<bool>("showTiming",false);
36 
37 // inputLabelCastorTowers_ = ps.getParameter<edm::InputTag>("CastorTowerLabel");
38 
39  irun_=0;
40  ilumisec_=0;
41  ievent_=0;
42  itime_=0;
43  ibunch_=0;
44 
45  DigiMon_ = NULL;
46  RecHitMon_ = NULL;
47  LedMon_ = NULL;
48 
49  //---------------------- DigiMonitor ----------------------//
50  if ( ps.getUntrackedParameter<bool>("DigiMonitor", false) ) {
51  if(fVerbosity>0) std::cout << "CastorMonitorModule: Digi monitor flag is on...." << std::endl;
52  DigiMon_ = new CastorDigiMonitor(ps);
53 // DigiMon_ = new CastorDigiMonitor();
54  DigiMon_->setup(ps);
55  }
56 
58  if ( ps.getUntrackedParameter<bool>("RecHitMonitor", false) ) {
59  if(fVerbosity>0) std::cout << "CastorMonitorModule: RecHit monitor flag is on...." << std::endl;
61  RecHitMon_->setup(ps);
62  }
64  if ( ps.getUntrackedParameter<bool>("LEDMonitor", false) ) {
65  if(fVerbosity>0) std::cout << "CastorMonitorModule: LED monitor flag is on...." << std::endl;
66  LedMon_ = new CastorLEDMonitor(ps);
67  LedMon_->setup(ps);
68  }
69  //-------------------------------------------------------------//
70 
71  std::string subsystemname = ps.getUntrackedParameter<std::string>("subSystemFolder","Castor");
72  if(fVerbosity>1) std::cout << "===>CastorMonitor name = " << subsystemname << std::endl;
73 
74  ievt_ = 0;
75 
76  if(fVerbosity>0) std::cout<<"CastorMonitorModule Constructor(end)"<< std::endl;
77 }
78 
79 //======================= Destructor ===============================//
81  if (DigiMon_ != NULL) { delete DigiMon_; }
82  if (RecHitMon_ != NULL) { delete RecHitMon_; }
83  if (LedMon_ != NULL) { delete LedMon_; }
84 }
85 
87  const edm::EventSetup& iSetup) {
88  iSetup.get<CastorDbRecord>().get(conditions_);
89 
91  iSetup.get<CastorPedestalsRcd>().get(dbPedestals);
92  if(!dbPedestals.isValid() && fVerbosity>0) {
93  std::cout<<"CASTOR has no CastorPedestals in the CondDB"<<std::endl;
94  }
95 }
96 
97 //=============== bookHistograms =================//
99  const edm::Run& iRun, const edm::EventSetup& iSetup)
100 {
101  if(fVerbosity>0) std::cout<<"CastorMonitorModule::beginRun (start)" << std::endl;
102 
103  if (DigiMon_ != NULL) { DigiMon_->bookHistograms(ibooker,iRun,iSetup);}
104  if (RecHitMon_ != NULL) { RecHitMon_->bookHistograms(ibooker,iRun,iSetup); }
105  if (LedMon_ != NULL) { LedMon_->bookHistograms(ibooker,iRun,iSetup); }
106 
107 //std::cout<<"CastorMonitorModule::bookHist(): CastorCurrentFolder:"<<rootFolder_<<std::endl;
108  ibooker.setCurrentFolder(rootFolder_ + "CastorEventProducts");
109  char s[60];
110  sprintf(s,"CastorEventProducts");
111  CastorEventProduct = ibooker.book1D(s,s,4,-0.5,3.5);
112  CastorEventProduct->getTH1F()->GetXaxis()->SetBinLabel(1,"FEDs/3");
113  CastorEventProduct->getTH1F()->GetXaxis()->SetBinLabel(2,"RawData");
114  CastorEventProduct->getTH1F()->GetXaxis()->SetBinLabel(3,"CastorDigi");
115  CastorEventProduct->getTH1F()->GetXaxis()->SetBinLabel(4,"CastorRecHits");
116 
117  if(fVerbosity>0)
118  std::cout<<"CastorMonitorModule::bookHistogram(end)"<< std::endl;
119  return;
120 }
121 
123  const edm::EventSetup& context) { }
124 
126  const edm::EventSetup& context) {}
127 
129 {}
130 
131 //========================== analyze ===============================//
133 {
134  if (fVerbosity>0) std::cout <<" "<<std::endl;
135  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (start)"<<std::endl;
136 
137  using namespace edm;
138 
139  irun_ = iEvent.id().run();
140  ilumisec_ = iEvent.luminosityBlock();
141  ievent_ = iEvent.id().event();
142  itime_ = iEvent.time().value();
143  ibunch_ = iEvent.bunchCrossing() % NBunchesOrbit;
144 
145  if (fVerbosity>1) {
146 //std::cout << " CastorMonitorModule: evts: "<<nevt_ <<", run: "<<irun_<<", LS: "<<ilumisec_<<std::endl;
147  std::cout <<" evt:"<<ievent_<<", time: "<<itime_ <<"\t total count = "<<ievt_<<std::endl;
148  }
149 
150  ievt_++;
151 
152  bool rawOK_ = true;
153  bool digiOK_ = true;
154  bool rechitOK_ = true;
155 
157  iEvent.getByToken(inputTokenRaw_,RawData);
158  if (!RawData.isValid()) {
159  rawOK_=false;
160  if (fVerbosity>0) std::cout << "RAW DATA NOT FOUND!" << std::endl;
161  }
162 
165  if (!report.isValid()) {
166  rawOK_=false;
167  if (fVerbosity>0) std::cout << "UNPACK REPORT HAS FAILED!" << std::endl;
168  }
169  else
170  {
171  const std::vector<int> feds = (*report).getFedsUnpacked();
172  fedsUnpacked = float(feds.size())/3.;
173  }
174 
176  iEvent.getByToken(inputTokenDigi_,CastorDigi);
177  if (!CastorDigi.isValid()) {
178  digiOK_=false;
179  if (fVerbosity>0) std::cout << "DIGI DATA NOT FOUND!" << std::endl;
180  }
181 
183  iEvent.getByToken(inputTokenRecHitCASTOR_,CastorHits);
184  if (!CastorHits.isValid()) {
185  rechitOK_ = false;
186  if (fVerbosity>0) std::cout << "RECO DATA NOT FOUND!" << std::endl;
187  }
188 
190  CastorEventProduct->Fill(1,int(rawOK_));
193 
194  if(digiOK_) DigiMon_->processEvent(*CastorDigi,*conditions_);
195  if (showTiming_){
196  cpu_timer.stop();
197  if (DigiMon_!=NULL) std::cout <<"TIMER:: DIGI MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
199  }
200 
201  if(rechitOK_) {
202 // RecHitMon_->processEvent(*CastorHits,*hltResults);
203  RecHitMon_->processEvent(*CastorHits);
205 // iEvent.getByLabel(inputLabelCastorTowers_,castorTowers);
206  iEvent.getByToken(inputTokenCastorTowers_,castorTowers);
207  RecHitMon_->processEventTowers(*castorTowers);
209 // iEvent.getByLabel(JetAlgorithm,jets);
210  iEvent.getByToken(JetAlgorithm,jets);
212  }
213 
214  if (showTiming_){
215  cpu_timer.stop();
216  if (RecHitMon_!=NULL) std::cout <<"TIMER:: RECHIT MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
218  }
219 
220  if(digiOK_) LedMon_->processEvent(*CastorDigi,*conditions_);
221  if (showTiming_){
222  cpu_timer.stop();
223  if (LedMon_!=NULL) std::cout <<"TIMER:: LED MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
225  }
226 
227  if(fVerbosity>1 && ievt_%100 == 0)
228  std::cout << "CastorMonitorModule: processed "<<ievt_<<" events"<<std::endl;
229  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (end)"<<std::endl;
230  return;
231 }
232 
236 
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
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
void setup(const edm::ParameterSet &ps)
void endRun(const edm::Run &run, const edm::EventSetup &eventSetup)
void start()
Definition: CPUTimer.cc:74
void setup(const edm::ParameterSet &ps)
edm::EDGetTokenT< FEDRawDataCollection > inputTokenRaw_
void analyze(const edm::Event &iEvent, const edm::EventSetup &eventSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::ESHandle< CastorDbService > conditions_
int bunchCrossing() const
Definition: EventBase.h:65
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:62
CastorLEDMonitor * LedMon_
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
edm::ESHandle< CastorPedestals > dbPedestals
void Fill(long long x)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
edm::EDGetTokenT< CastorDigiCollection > inputTokenDigi_
edm::EDGetTokenT< CastorTowerCollection > inputTokenCastorTowers_
tuple report
Definition: zeeHLT_cff.py:9
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_
void setup(const edm::ParameterSet &ps)
Times stop()
Definition: CPUTimer.cc:94
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:276
const T & get() const
Definition: EventSetup.h:56
TH1F * getTH1F(void) const
edm::EDGetTokenT< BasicJetCollection > JetAlgorithm
MonitorElement * CastorEventProduct
edm::EventID id() const
Definition: EventBase.h:59
void processEventTowers(const reco::CastorTowerCollection &castorTowers)
edm::EDGetTokenT< HcalUnpackerReport > inputTokenReport_
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
CastorRecHitMonitor * RecHitMon_
tuple cout
Definition: gather_cfg.py:145
void processEvent(const CastorRecHitCollection &castorHits)
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup)
bool isValid() const
Definition: ESHandle.h:47
edm::EDGetTokenT< CastorRecHitCollection > inputTokenRecHitCASTOR_
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:60
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: Run.h:43