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; module=0; sector=0; zside=0; totEnergy=0.;
48 
49 
51  for (int mod=0; mod<14; mod++){
52  for (int sec=0; sec<16; sec++){
53  energyInEachChannel[mod][sec] = 0.;
55  allEnergySector[sec]=0;
56  }
57  }
58 
59  if ( m_dbe !=NULL ) {
62 meEVT_ = m_dbe->bookInt("RecHit Event Number"); // meEVT_->Fill(ievt_);
64 castorHists.meRECHIT_E_all = m_dbe->book1D("CastorRecHit Energies- above threshold on RecHitEnergy","CastorRecHit Energies- above threshold on RecHitEnergy",150,0,150);
65 castorHists.meRECHIT_T_all = m_dbe->book1D("CastorRecHit Times- above threshold on RecHitEnergy","CastorRecHit Times- above threshold on RecHitEnergy",300,-100,100);
67 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);
69 castorHists.meRECHIT_E_modules = m_dbe->book1D("CastorRecHit Energy in modules- above threshold","CastorRecHit Energy in modules- above threshold", 14, 0, 14);
71 castorHists.meRECHIT_E_sectors = m_dbe->book1D("CastorRecHit Energy in sectors- above threshold","CastorRecHit Energy in sectors- above threshold", 16, 0, 16);
72 
74 castorHists.meRECHIT_N_modules = m_dbe->book1D("Number of CastorRecHits in modules- above threshold","Number of CastorRecHits in modules- above threshold", 14, 0, 14);
76 castorHists.meRECHIT_N_sectors = m_dbe->book1D("Number of CastorRecHits in sectors- above threshold","Number of CastorRecHits in sectors- above threshold", 16, 0, 16);
78 castorHists.meCastorRecHitsOccupancy = m_dbe->book2D("CastorRecHits Occupancy Map", "CastorRecHits Occupancy Map", 14, 0,14, 16, 0,16);
80 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);
81 
82  m_dbe->setCurrentFolder(baseFolder_+"/EnergyFraction");
84 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);
86 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);
87 /*
88 castorHists.meRECHIT_E_relative_modules->getTH1F()->GetYaxis()->SetTitle("fraction of the total energy");
89 castorHists.meRECHIT_E_relative_sectors->getTH1F()->GetYaxis()->SetTitle("fraction of the total energy");
90 
91  char ibin1[1024];
92  for(int i=0; i<14; i++){
93  sprintf(ibin1,"%i", i+1);
94  castorHists.meRECHIT_E_relative_modules->getTH1F()->GetXaxis()->SetBinLabel(i+1,ibin1);
95  }
96  char ibin2[1024];
97  for(int i=0; i<16; i++){
98  sprintf(ibin2,"%i", i+1);
99  castorHists.meRECHIT_E_relative_sectors->getTH1F()->GetXaxis()->SetBinLabel(i+1,ibin2);
100  }
101 */
102 
103  }
104 
105 
106 
107  else{
108  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup - NO DQMStore service" << std::endl;
109  }
110 
111  if(fVerbosity>0) std::cout << "CastorRecHitMonitor::setup (end)" << std::endl;
112 
113  return;
114 }
115 
116 //==========================================================//
117 //=============== do histograms for every channel ==========//
118 //==========================================================//
119 
120 namespace CastorRecHitPerChan{
121 
122  template<class RecHit>
123 
124  inline void perChanHists(const RecHit& rhit,
125  std::map<HcalCastorDetId, MonitorElement*> &toolE,
126  std::map<HcalCastorDetId, MonitorElement*> &toolT,
127  DQMStore* dbe, std::string baseFolder) {
128 
129  std::map<HcalCastorDetId,MonitorElement*>::iterator _mei;
130 
131  std::string type = "CastorRecHitPerChannel";
132  if(dbe) dbe->setCurrentFolder(baseFolder+"/"+type);
133 
135  _mei=toolE.find(rhit.id()); //-- look for a histogram with this hit's id !!!
136  if (_mei!=toolE.end()){
137  if (_mei->second==0) return;
138  else _mei->second->Fill(rhit.energy()); //-- if it's there, fill it with energy
139  }
140  else{
141  if(dbe){
142  char name[1024];
143  sprintf(name,"CastorRecHit Energy zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
144  toolE[rhit.id()] = dbe->book1D(name,name,60,-10,20);
145  toolE[rhit.id()]->Fill(rhit.energy());
146  }
147  }
148 
150  _mei=toolT.find(rhit.id()); //-- look for a histogram with this hit's id
151  if (_mei!=toolT.end()){
152  if (_mei->second==0) return;
153  else _mei->second->Fill(rhit.time()); //-- if it's there, fill it with time
154  }
155  else{
156  if(dbe){
157  char name[1024];
158  sprintf(name,"CastorRecHit Time zside=%d module=%d sector=%d", rhit.id().zside(), rhit.id().module(), rhit.id().sector());
159  toolT[rhit.id()] = dbe->book1D(name,name,200,-100,100);
160  toolT[rhit.id()]->Fill(rhit.time());
161  }
162  }
163 
164 
165  }
166 }
167 
168 //==========================================================//
169 //================== processEvent ==========================//
170 //==========================================================//
171 
173 
174  if(fVerbosity>0) std::cout << "==>CastorRecHitMonitor::processEvent !!!"<< std::endl;
175 
176 
178  ievt_++; totEnergy=0.;
179 
181  meEVT_->Fill(ievt_);
182 
183 
184 
185  if(!m_dbe) {
186  if(fVerbosity>0) std::cout <<"CastorRecHitMonitor::processEvent => DQMStore is not instantiated !!!"<<std::endl;
187  return;
188  }
189 
191  if (showTiming) { cpu_timer.reset(); cpu_timer.start(); }
192 
193  //castorHists.meRECHIT_N_event->Fill(castorHits.size());
194  int iHit=0;
195 
196  if(castorHits.size()>0)
197  {
198  if(fVerbosity>0) std::cout << "==>CastorRecHitMonitor::processEvent: castorHits.size()>0 !!!" << std::endl;
199 
201  for (CASTORiter=castorHits.begin(); CASTORiter!=castorHits.end(); ++CASTORiter) {
202 
204  energy = CASTORiter->energy();
205  time = CASTORiter->time();
206 
208  HcalCastorDetId id(CASTORiter->detid().rawId());
209  //float zside = id.zside();
210  module = (int)id.module(); //-- get module
211  sector = (int)id.sector(); //-- get sector
212  channel = 16*(module-1)+sector; //-- define channel
213 
214  if (energy>0.) {
216  castorHists.meRECHIT_E_all->Fill(energy);
217  castorHists.meRECHIT_T_all->Fill(time);
219  castorHists.meRECHIT_MAP_CHAN_E->Fill(channel,energy);
221  castorHists.meRECHIT_E_modules->Fill(module-1, energy);
223  castorHists.meRECHIT_E_sectors->Fill(sector-1, energy);
225  castorHists.meRECHIT_N_modules->Fill(module-1);
227  castorHists.meRECHIT_N_sectors->Fill(sector-1);
228  iHit++;
229  }
230 
232  if(energy<0) energy=0;
233 
235  energyInEachChannel[module-1][sector-1] += energy;
236 
238  castorHists.meCastorRecHitsOccupancy->Fill(module-1,sector-1, energy);
239 
241  castorHists.meRECHIT_N_event->Fill(iHit);
242 
244  if( doPerChannel_)
245  CastorRecHitPerChan::perChanHists<CastorRecHit>(*CASTORiter, castorHists.meRECHIT_E, castorHists.meRECHIT_T, m_dbe, baseFolder_);
246  }
247 
249  for(int mod=0; mod<14;mod++)
250  for(int sec=0; sec<16;sec++)
252 
254  for(int mod=0; mod<14;mod++)
259 
261  for(int sec=0; sec<16;sec++)
265  energyInEachChannel[12][sec]+energyInEachChannel[13][sec];
266 
267 
269  for(int mod=0; mod<14;mod++)
270  castorHists.meRECHIT_E_relative_modules->getTH1F()->SetBinContent(mod+1,allEnergyModule[mod]/totEnergy);
271  for(int sec=0; sec<16;sec++)
272  castorHists.meRECHIT_E_relative_sectors->getTH1F()->SetBinContent(sec+1,allEnergySector[sec]/totEnergy);
273 
274 
275 
276  }
277 
278  else { if(fVerbosity>0) std::cout<<"CastorRecHitMonitor::processEvent NO Castor RecHits !!!"<<std::endl; }
279 
280  if (showTiming) {
281  cpu_timer.stop(); std::cout << " TIMER::CastorRecHit -> " << cpu_timer.cpuTime() << std::endl;
283  }
284 
285 
286  return;
287 }
288 
289 
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
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
float energyInEachChannel[14][16]
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)
list mod
Load physics model.
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::@188 castorHists
size_type size() const
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:624
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:845
Definition: vlib.h:209
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const_iterator begin() const