CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorRecHitMonitor.cc
Go to the documentation of this file.
4 
5 //***************************************************//
6 //********** CastorRecHitMonitor: *******************//
7 //********** Author: Dmytro Volyanskyy ************//
8 //********** Date : 23.09.2008 (first version) ******//
9 //***************************************************//
12 
13 //==================================================================//
14 //======================= Constructor ==============================//
15 //==================================================================//
17  doPerChannel_ = true;
18  // occThresh_ = 1;
19  ievt_=0;
20 }
21 
22 //==================================================================//
23 //======================= Destructor ==============================//
24 //==================================================================//
26 }
27 
29 }
30 
31 
32 //==========================================================//
33 //========================= setup ==========================//
34 //==========================================================//
35 
37 
39  baseFolder_ = rootFolder_+"CastorRecHitMonitor";
40 
41  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup (start)" << std::endl;
42 
43  if ( ps.getUntrackedParameter<bool>("RecHitsPerChannel", false) ){
44  doPerChannel_ = true;
45  }
46 
47  ievt_=0;
48 
49  if ( m_dbe !=NULL ) {
52 meEVT_ = m_dbe->bookInt("RecHit Event Number"); // meEVT_->Fill(ievt_);
54 castorHists.meRECHIT_E_all = m_dbe->book1D("CastorRecHit Energies- above threshold on RecHitEnergy","CastorRecHit Energies- above threshold on RecHitEnergy",150,0,150);
55 castorHists.meRECHIT_T_all = m_dbe->book1D("CastorRecHit Times- above threshold on RecHitEnergy","CastorRecHit Times- above threshold on RecHitEnergy",300,-100,100);
57 castorHists.meRECHIT_MAP_CHAN_E = m_dbe->book1D("CastorRecHit Energy in each channel- above threshold","CastorRecHit Energy in each channel- above threshold",224,0,224);
59 castorHists.meRECHIT_MAP_CHAN_E2D = m_dbe->book2D("CastorRecHit 2D Energy Map- above threshold","CastorRecHit 2D Energy Map- above threshold",14, 0,14, 16, 0,16);
61 castorHists.meRECHIT_E_modules = m_dbe->book1D("CastorRecHit Energy in modules- above threshold","CastorRecHit Energy in modules- above threshold", 14, 0, 14);
63 castorHists.meRECHIT_E_sectors = m_dbe->book1D("CastorRecHit Energy in sectors- above threshold","CastorRecHit Energy in sectors- above threshold", 16, 0, 16);
65 castorHists.meRECHIT_N_modules = m_dbe->book1D("Number of CastorRecHits in modules- above threshold","Number of CastorRecHits in modules- above threshold", 14, 0, 14);
67 castorHists.meRECHIT_N_sectors = m_dbe->book1D("Number of CastorRecHits in sectors- above threshold","Number of CastorRecHits in sectors- above threshold", 16, 0, 16);
69  castorHists.meCastorRecHitsOccupancy = m_dbe->book2D("CastorRecHits occupancy- sector vs module", "CastorRecHits occupancy- sector vs module", 14, 0.5,14.5, 16, 0.5,16.5);
70 TH2F* CastorRecHitsOccupancy =castorHists.meCastorRecHitsOccupancy->getTH2F();
71 CastorRecHitsOccupancy->GetXaxis()->SetTitle("module");
72 CastorRecHitsOccupancy->GetYaxis()->SetTitle("sector");
73  }
74 
75  else{
76  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup - NO DQMStore service" << std::endl;
77  }
78 
79  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup (end)" << std::endl;
80 
81  return;
82 }
83 
84 //==========================================================//
85 //=============== do histograms for every channel ==========//
86 //==========================================================//
87 
88 namespace CastorRecHitPerChan{
89 
90  template<class RecHit>
91 
92  inline void perChanHists(const RecHit& rhit,
93  std::map<HcalCastorDetId, MonitorElement*> &toolE,
94  std::map<HcalCastorDetId, MonitorElement*> &toolT,
95  DQMStore* dbe, std::string baseFolder) {
96 
97  std::map<HcalCastorDetId,MonitorElement*>::iterator _mei;
98 
99  std::string type = "CastorRecHitPerChannel";
100  if(dbe) dbe->setCurrentFolder(baseFolder+"/"+type);
101 
103  _mei=toolE.find(rhit.id()); //-- look for a histogram with this hit's id !!!
104  if (_mei!=toolE.end()){
105  if (_mei->second==0) return;
106  else _mei->second->Fill(rhit.energy()); //-- if it's there, fill it with energy
107  }
108  else{
109  if(dbe){
110  char name[1024];
111  sprintf(name,"CastorRecHit Energy zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
112  toolE[rhit.id()] = dbe->book1D(name,name,60,-10,20);
113  toolE[rhit.id()]->Fill(rhit.energy());
114  }
115  }
116 
118  _mei=toolT.find(rhit.id()); //-- look for a histogram with this hit's id
119  if (_mei!=toolT.end()){
120  if (_mei->second==0) return;
121  else _mei->second->Fill(rhit.time()); //-- if it's there, fill it with time
122  }
123  else{
124  if(dbe){
125  char name[1024];
126  sprintf(name,"CastorRecHit Time zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
127  toolT[rhit.id()] = dbe->book1D(name,name,200,-100,100);
128  toolT[rhit.id()]->Fill(rhit.time());
129  }
130  }
131 
132 
133  }
134 }
135 
136 //==========================================================//
137 //================== processEvent ==========================//
138 //==========================================================//
139 
141 
142  if(fVerbosity>0) std::cout << "==>CastorRecHitMonitor::processEvent !!!"<< std::endl;
143 
144 
146  meEVT_->Fill(ievt_);
147 
148  if(!m_dbe) {
149  if(fVerbosity>0) std::cout <<"CastorRecHitMonitor::processEvent => DQMStore is not instantiated !!!"<<std::endl;
150  return;
151  }
152 
153 
155  if (showTiming) { cpu_timer.reset(); cpu_timer.start(); }
156 
157  if(castorHits.size()>0)
158  {
159  if(fVerbosity>0) std::cout << "==>CastorRecHitMonitor::processEvent: castorHits.size()>0 !!!" << std::endl;
160 
162  for (CASTORiter=castorHits.begin(); CASTORiter!=castorHits.end(); ++CASTORiter) {
163 
165  float energy = CASTORiter->energy();
166  float time = CASTORiter->time();
167 
169  HcalCastorDetId id(CASTORiter->detid().rawId());
170  //float zside = id.zside();
171  float module = id.module(); float sector = id.sector(); //-- get module & sector from id
172  float channel = 16*(module-1)+sector; //-- define channel
173 
174  if (energy>1.0) {
176  castorHists.meRECHIT_E_all->Fill(energy);
177  castorHists.meRECHIT_T_all->Fill(time);
179  castorHists.meRECHIT_MAP_CHAN_E->Fill(channel,energy);
181  castorHists.meRECHIT_MAP_CHAN_E2D->Fill(module-1,sector-1,energy);
183  castorHists.meRECHIT_E_modules->Fill(module-1, energy);
185  castorHists.meRECHIT_E_sectors->Fill(sector-1, energy);
187  castorHists.meRECHIT_N_modules->Fill(module-1);
189  castorHists.meRECHIT_N_sectors->Fill(sector-1);
191  castorHists.meCastorRecHitsOccupancy->Fill(module-1,sector-1);
192  }
193 
195  if(ievt_%100 == 0 && doPerChannel_)
196  CastorRecHitPerChan::perChanHists<CastorRecHit>(*CASTORiter, castorHists.meRECHIT_E, castorHists.meRECHIT_T, m_dbe, baseFolder_);
197  }
198 
199  }
200 
201  else { if(fVerbosity>0) std::cout<<"CastorRecHitMonitor::processEvent NO Castor RecHits !!!"<<std::endl; }
202 
203  if (showTiming) {
204  cpu_timer.stop(); std::cout << " TIMER::CastorRecHit -> " << cpu_timer.cpuTime() << std::endl;
206  }
207 
208  ievt_++;
209  return;
210 }
211 
212 
type
Definition: HCALResponse.h:22
T getUntrackedParameter(std::string const &, T const &) const
edm::CPUTimer cpu_timer
virtual void setup(const edm::ParameterSet &ps, DQMStore *dbe)
void start()
Definition: CPUTimer.cc:74
module()
Definition: vlib.cc:994
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
MonitorElement * meEVT_
std::vector< T >::const_iterator const_iterator
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
void Fill(long long x)
std::string baseFolder_
void perChanHists(const RecHit &rhit, std::map< HcalCastorDetId, MonitorElement * > &toolE, std::map< HcalCastorDetId, MonitorElement * > &toolT, DQMStore *dbe, std::string baseFolder)
Times stop()
Definition: CPUTimer.cc:94
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
const_iterator end() const
double cpuTime() const
Definition: CPUTimer.cc:157
struct CastorRecHitMonitor::@165 castorHists
size_type size() const
std::string rootFolder_
tuple cout
Definition: gather_cfg.py:41
void processEvent(const CastorRecHitCollection &castorHits)
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:426
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:647
Definition: vlib.h:209
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
const_iterator begin() const