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  {
18 
19  doPerChannel_ = true;
20  // occThresh_ = 1;
21  ievt_=0;
22 
23  }
24 
25 //==================================================================//
26 //======================= Destructor ==============================//
27 //==================================================================//
29  {
30 
31  }
32 
33 
34 //==================================================================//
35 //======================= Reset ====================================//
36 //==================================================================//
37 
39  {
40 
41  }
42 
43 
44 //==========================================================//
45 //========================= setup ==========================//
46 //==========================================================//
47 
49  {
51  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup (start)" << std::endl;
52 
53  baseFolder_ = rootFolder_+"CastorRecHitMonitor";
54 
55  if ( ps.getUntrackedParameter<bool>("RecHitsPerChannel", false) ){
56  doPerChannel_ = true;
57  }
58 
59  ievt_=0; module=0; sector=0; zside=0; totEnergy=0.;
60 
61 
63  for (int mod=0; mod<14; mod++){
64  for (int sec=0; sec<16; sec++){
65  energyInEachChannel[mod][sec] = 0.;
67  allEnergySector[sec]=0;
68  }
69  }
70 
71  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup (end)" << std::endl;
72 
73  return;
74 }
75 
76 
77 //=================================================================//
78 //========================== beginRun =============================//
79 //================================================================//
81  {
82  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::beginRun (start)" << std::endl;
83 
84  if ( m_dbe !=NULL )
85  {
88  meEVT_ = m_dbe->bookInt("RecHit Event Number"); // meEVT_->Fill(ievt_);
90  castorHists.meRECHIT_E_all = m_dbe->book1D("CastorRecHit Energies- above threshold on RecHitEnergy","CastorRecHit Energies- above threshold on RecHitEnergy",150,0,150);
91  castorHists.meRECHIT_T_all = m_dbe->book1D("CastorRecHit Times- above threshold on RecHitEnergy","CastorRecHit Times- above threshold on RecHitEnergy",300,-100,100);
93  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);
95  castorHists.meRECHIT_E_modules = m_dbe->book1D("CastorRecHit Energy in modules- above threshold","CastorRecHit Energy in modules- above threshold", 14, 0, 14);
97  castorHists.meRECHIT_E_sectors = m_dbe->book1D("CastorRecHit Energy in sectors- above threshold","CastorRecHit Energy in sectors- above threshold", 16, 0, 16);
98 
100  castorHists.meRECHIT_N_modules = m_dbe->book1D("Number of CastorRecHits in modules- above threshold","Number of CastorRecHits in modules- above threshold", 14, 0, 14);
102  castorHists.meRECHIT_N_sectors = m_dbe->book1D("Number of CastorRecHits in sectors- above threshold","Number of CastorRecHits in sectors- above threshold", 16, 0, 16);
104  castorHists.meCastorRecHitsOccupancy = m_dbe->book2D("CastorRecHits Occupancy Map", "CastorRecHits Occupancy Map", 14, 0,14, 16, 0,16);
106  castorHists.meRECHIT_N_event = m_dbe->book1D("Number of CASTOR RecHits per event- above threshold","Number of CASTOR RecHits per event- above threshold", 23, 0, 230);
107 
108 
109  m_dbe->setCurrentFolder(baseFolder_+"/EnergyFraction");
111  castorHists.meRECHIT_E_relative_modules = m_dbe->book1D("Fraction of the total energy in CASTOR modules","Fraction of the total energy in CASTOR modules", 14, 0, 14);
113  castorHists.meRECHIT_E_relative_sectors = m_dbe->book1D("Fraction of the total energy in CASTOR sectors","Fraction of the total energy in CASTOR sectors", 16, 0, 16);
114  /*
115  castorHists.meRECHIT_E_relative_modules->getTH1F()->GetYaxis()->SetTitle("fraction of the total energy");
116  castorHists.meRECHIT_E_relative_sectors->getTH1F()->GetYaxis()->SetTitle("fraction of the total energy");
117 
118  char ibin1[1024];
119  for(int i=0; i<14; i++)
120  {
121  sprintf(ibin1,"%i", i+1);
122  castorHists.meRECHIT_E_relative_modules->getTH1F()->GetXaxis()->SetBinLabel(i+1,ibin1);
123  }
124  char ibin2[1024];
125  for(int i=0; i<16; i++)
126  {
127  sprintf(ibin2,"%i", i+1);
128  castorHists.meRECHIT_E_relative_sectors->getTH1F()->GetXaxis()->SetBinLabel(i+1,ibin2);
129  }
130 */
131 
132  }
133  else
134  {
135  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::beginRun - NO DQMStore service" << std::endl;
136  }
137 
138 
139  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::beginRun (end)" << std::endl;
140 
141  return;
142 }
143 
144 //==========================================================//
145 //=============== do histograms for every channel ==========//
146 //==========================================================//
147 
148 namespace CastorRecHitPerChan{
149 
150  template<class RecHit>
151 
152  inline void perChanHists(const RecHit& rhit,
153  std::map<HcalCastorDetId, MonitorElement*> &toolE,
154  std::map<HcalCastorDetId, MonitorElement*> &toolT,
155  DQMStore* dbe, std::string baseFolder) {
156 
157  std::map<HcalCastorDetId,MonitorElement*>::iterator _mei;
158 
159  std::string type = "CastorRecHitPerChannel";
160  if(dbe) dbe->setCurrentFolder(baseFolder+"/"+type);
161 
163  _mei=toolE.find(rhit.id()); //-- look for a histogram with this hit's id !!!
164  if (_mei!=toolE.end()){
165  if (_mei->second==0) return;
166  else _mei->second->Fill(rhit.energy()); //-- if it's there, fill it with energy
167  }
168  else{
169  if(dbe){
170  char name[1024];
171  sprintf(name,"CastorRecHit Energy zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
172  toolE[rhit.id()] = dbe->book1D(name,name,60,-10,20);
173  toolE[rhit.id()]->Fill(rhit.energy());
174  }
175  }
176 
178  _mei=toolT.find(rhit.id()); //-- look for a histogram with this hit's id
179  if (_mei!=toolT.end()){
180  if (_mei->second==0) return;
181  else _mei->second->Fill(rhit.time()); //-- if it's there, fill it with time
182  }
183  else{
184  if(dbe){
185  char name[1024];
186  sprintf(name,"CastorRecHit Time zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
187  toolT[rhit.id()] = dbe->book1D(name,name,200,-100,100);
188  toolT[rhit.id()]->Fill(rhit.time());
189  }
190  }
191 
192 
193  }
194 }
195 
196 //==========================================================//
197 //================== processEvent ==========================//
198 //==========================================================//
199 
201 
202  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::processEvent (begin)"<< std::endl;
203 
204 
206  ievt_++; totEnergy=0.;
207 
209  meEVT_->Fill(ievt_);
210 
211 
212 
213  if(!m_dbe) {
214  if(fVerbosity>0) std::cout <<"CastorRecHitMonitor::processEvent => DQMStore is not instantiated !!!"<<std::endl;
215  return;
216  }
217 
219  if (showTiming) { cpu_timer.reset(); cpu_timer.start(); }
220 
221  //castorHists.meRECHIT_N_event->Fill(castorHits.size());
222  int iHit=0;
223 
224  if(castorHits.size()>0)
225  {
226  if(fVerbosity>1) std::cout << "==>CastorRecHitMonitor::processEvent: castorHits.size()>0 !!!" << std::endl;
227 
229  for (CASTORiter=castorHits.begin(); CASTORiter!=castorHits.end(); ++CASTORiter) {
230 
232  energy = CASTORiter->energy();
233  time = CASTORiter->time();
234 
236  HcalCastorDetId id(CASTORiter->detid().rawId());
237  //float zside = id.zside();
238  module = (int)id.module(); //-- get module
239  sector = (int)id.sector(); //-- get sector
240  channel = 16*(module-1)+sector; //-- define channel
241 
242  if (energy>0.) {
244  castorHists.meRECHIT_E_all->Fill(energy);
245  castorHists.meRECHIT_T_all->Fill(time);
247  castorHists.meRECHIT_MAP_CHAN_E->Fill(channel,energy);
249  castorHists.meRECHIT_E_modules->Fill(module-1, energy);
251  castorHists.meRECHIT_E_sectors->Fill(sector-1, energy);
253  castorHists.meRECHIT_N_modules->Fill(module-1);
255  castorHists.meRECHIT_N_sectors->Fill(sector-1);
256  iHit++;
257  }
258 
260  if(energy<0) energy=0;
261 
263  energyInEachChannel[module-1][sector-1] += energy;
264 
266  castorHists.meCastorRecHitsOccupancy->Fill(module-1,sector-1, energy);
267 
269  castorHists.meRECHIT_N_event->Fill(iHit);
270 
272  // if( doPerChannel_)
273  // CastorRecHitPerChan::perChanHists<CastorRecHit>(*CASTORiter, castorHists.meRECHIT_E, castorHists.meRECHIT_T, m_dbe, baseFolder_);
274  }
275 
277  for(int mod=0; mod<14;mod++)
278  for(int sec=0; sec<16;sec++)
280 
282  for(int mod=0; mod<14;mod++)
287 
289  for(int sec=0; sec<16;sec++)
293  energyInEachChannel[12][sec]+energyInEachChannel[13][sec];
294 
295 
297  for(int mod=0; mod<14;mod++)
298  castorHists.meRECHIT_E_relative_modules->getTH1F()->SetBinContent(mod+1,allEnergyModule[mod]/totEnergy);
299  for(int sec=0; sec<16;sec++)
300  castorHists.meRECHIT_E_relative_sectors->getTH1F()->SetBinContent(sec+1,allEnergySector[sec]/totEnergy);
301 
302 
303 
304  }
305 
306  else { if(fVerbosity>0) std::cout<<"CastorRecHitMonitor::processEvent NO Castor RecHits !!!"<<std::endl; }
307 
308  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::processEvent (end)"<< std::endl;
309 
310  return;
311 }
312 
313 
type
Definition: HCALResponse.h:21
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
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
float energyInEachChannel[14][16]
MonitorElement * meEVT_
std::vector< CastorRecHit >::const_iterator const_iterator
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
void Fill(long long x)
struct CastorRecHitMonitor::@278 castorHists
std::string baseFolder_
void perChanHists(const RecHit &rhit, std::map< HcalCastorDetId, MonitorElement * > &toolE, std::map< HcalCastorDetId, MonitorElement * > &toolT, DQMStore *dbe, std::string baseFolder)
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
const_iterator end() const
size_type size() const
void beginRun(const edm::EventSetup &iSetup)
std::string rootFolder_
tuple cout
Definition: gather_cfg.py:121
void processEvent(const CastorRecHitCollection &castorHits)
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:861
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
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
Definition: vlib.h:208
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
const_iterator begin() const