CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZdcSimHitStudy.cc
Go to the documentation of this file.
3 
5 #include "CLHEP/Units/GlobalSystemOfUnits.h"
6 
8 
9  g4Label = ps.getUntrackedParameter<std::string>("moduleLabel","g4SimHits");
10  zdcHits = ps.getUntrackedParameter<std::string>("HitCollection","ZdcHits");
11  outFile_ = ps.getUntrackedParameter<std::string>("outputFile", "zdcHitStudy.root");
12  verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
13  checkHit_= true;
14 
15  edm::LogInfo("ZdcSimHitStudy")
16  //std::cout
17  << "Module Label: " << g4Label << " Hits: "
18  << zdcHits << " / "<< checkHit_
19  << " Output: " << outFile_;
20 
22  if (dbe_) {
23  if (verbose_) {
24  dbe_->setVerbose(1);
25  sleep (3);
27  } else {
28  dbe_->setVerbose(0);
29  }
30  }
31 }
32 
34 
36  if (dbe_) {
37  dbe_->setCurrentFolder("ZdcHitsV/ZdcSimHitsTask");
38  //Histograms for Hits
39  if (checkHit_) {
40  meAllZdcNHit_ = dbe_->book1D("Hit01","Number of All Hits in Zdc",100,0.,100.);
41  meBadZdcDetHit_= dbe_->book1D("Hit02","Hits with wrong Det in Zdc",100,0.,100.);
42  meBadZdcSecHit_= dbe_->book1D("Hit03","Hits with wrong Section in Zdc",100,0.,100.);
43  meBadZdcIdHit_ = dbe_->book1D("Hit04","Hits with wrong ID in Zdc",100,0.,100.);
44  meZdcNHitEM_ = dbe_->book1D("Hit05","Number of Hits in Zdc EM",100,0.,100.);
45  meZdcNHitHad_ = dbe_->book1D("Hit06","Number of Hits in Zdc Had",100,0.,100.);
46  meZdcNHitLum_ = dbe_->book1D("Hit07","Number of Hits in Zdc Lum",100,0.,100.);
47  meZdcDetectHit_= dbe_->book1D("Hit08","Calo Detector ID",50,0.,50.);
48  meZdcSideHit_ = dbe_->book1D("Hit09","Side in Zdc",4,-2,2.);
49  meZdcSectionHit_ = dbe_->book1D("Hit10","Section in Zdc",4,0.,4.);
50  meZdcChannelHit_ = dbe_->book1D("Hit11","Channel in Zdc",10,0.,10.);
51  meZdcEnergyHit_= dbe_->book1D("Hit12","Hits Energy",4000,0.,8000.);
52  meZdcHadEnergyHit_= dbe_->book1D("Hit13","Hits Energy in Had Section",4000,0.,8000.);
53  meZdcEMEnergyHit_ = dbe_->book1D("Hit14","Hits Energy in EM Section",4000,0.,8000.);
54  meZdcTimeHit_ = dbe_->book1D("Hit15","Time in Zdc",300,0.,600.);
55  meZdcTimeWHit_ = dbe_->book1D("Hit16","Time in Zdc (E wtd)", 300,0.,600.);
56  meZdc10Ene_ = dbe_->book1D("Hit17","Log10Energy in Zdc", 140, -20., 20. );
57  meZdcHadL10EneP_ = dbe_->bookProfile("Hit18","Log10Energy in Had Zdc vs Hit contribution", 140, -1., 20., 100, 0., 1. );
58  meZdcEML10EneP_ = dbe_->bookProfile("Hit19","Log10Energy in EM Zdc vs Hit contribution", 140, -1., 20., 100, 0., 1. );
59  meZdcEHadCh_ = dbe_->book2D("Hit20","Zdc Had Section Energy vs Channel", 4000, 0., 8000., 6, 0., 6. );
60  meZdcEEMCh_ = dbe_->book2D("Hit21","Zdc EM Section Energy vs Channel", 4000, 0., 8000., 6, 0., 6. );
61  meZdcETime_ = dbe_->book2D("Hit22","Hits Zdc Energy vs Time", 4000, 0., 8000., 300, 0., 600. );
62  meZdcEneEmN1_ = dbe_->book1D("HitVal01","Energy EM module N1",4000,0.,8000.);
63  meZdcEneEmN2_ = dbe_->book1D("HitVal02","Energy EM module N2",4000,0.,8000.);
64  meZdcEneEmN3_ = dbe_->book1D("HitVal03","Energy EM module N3",4000,0.,8000.);
65  meZdcEneEmN4_ = dbe_->book1D("HitVal04","Energy EM module N4",4000,0.,8000.);
66  meZdcEneEmN5_ = dbe_->book1D("HitVal05","Energy EM module N5",4000,0.,8000.);
67  meZdcEneHadN1_ = dbe_->book1D("HitVal06","Energy HAD module N1",4000,0.,8000.);
68  meZdcEneHadN2_ = dbe_->book1D("HitVal07","Energy HAD module N2",4000,0.,8000.);
69  meZdcEneHadN3_ = dbe_->book1D("HitVal08","Energy HAD module N3",4000,0.,8000.);
70  meZdcEneHadN4_ = dbe_->book1D("HitVal09","Energy HAD module N4",4000,0.,8000.);
71  meZdcEneTEmN1_ = dbe_->book2D("HitVal11","Energy EM mod N1 vs Time", 4000, 0., 8000., 300, 0., 600. );
72  meZdcEneTEmN2_ = dbe_->book2D("HitVal12","Energy EM mod N2 vs Time", 4000, 0., 8000., 300, 0., 600. );
73  meZdcEneTEmN3_ = dbe_->book2D("HitVal13","Energy EM mod N3 vs Time", 4000, 0., 8000., 300, 0., 600. );
74  meZdcEneTEmN4_ = dbe_->book2D("HitVal14","Energy EM mod N4 vs Time", 4000, 0., 8000., 300, 0., 600. );
75  meZdcEneTEmN5_ = dbe_->book2D("HitVal15","Energy EM mod N5 vs Time", 4000, 0., 8000., 300, 0., 600. );
76  meZdcEneTHadN1_ = dbe_->book2D("HitVal16","Energy HAD mod N1 vs Time", 4000, 0., 8000., 300, 0., 600. );
77  meZdcEneTHadN2_ = dbe_->book2D("HitVal17","Energy HAD mod N2 vs Time", 4000, 0., 8000., 300, 0., 600. );
78  meZdcEneTHadN3_ = dbe_->book2D("HitVal18","Energy HAD mod N3 vs Time", 4000, 0., 8000., 300, 0., 600. );
79  meZdcEneTHadN4_ = dbe_->book2D("HitVal19","Energy HAD mod N4 vs Time", 4000, 0., 8000., 300, 0., 600. );
80  meZdcEneHadNTot_ = dbe_->book1D("HitVal20","Total HAD Energy N",4000,0.,8000.);
81  meZdcEneEmNTot_ = dbe_->book1D("HitVal21","Total EM Energy N",4000,0.,8000.);
82  meZdcEneNTot_ = dbe_->book1D("HitVal22","Total Energy N",4000,0.,8000.);
83  meZdcEneEmP1_ = dbe_->book1D("HitVal23","Energy EM module P1",4000,0.,8000.);
84  meZdcEneEmP2_ = dbe_->book1D("HitVal24","Energy EM module P2",4000,0.,8000.);
85  meZdcEneEmP3_ = dbe_->book1D("HitVal25","Energy EM module P3",4000,0.,8000.);
86  meZdcEneEmP4_ = dbe_->book1D("HitVal26","Energy EM module P4",4000,0.,8000.);
87  meZdcEneEmP5_ = dbe_->book1D("HitVal27","Energy EM module P5",4000,0.,8000.);
88  meZdcEneHadP1_ = dbe_->book1D("HitVal29","Energy HAD module P1",4000,0.,8000.);
89  meZdcEneHadP2_ = dbe_->book1D("HitVal29","Energy HAD module P2",4000,0.,8000.);
90  meZdcEneHadP3_ = dbe_->book1D("HitVal30","Energy HAD module P3",4000,0.,8000.);
91  meZdcEneHadP4_ = dbe_->book1D("HitVal31","Energy HAD module P4",4000,0.,8000.);
92  meZdcEneTEmP1_ = dbe_->book2D("HitVal32","Energy EM mod P1 vs Time", 4000, 0., 8000., 300, 0., 600. );
93  meZdcEneTEmP2_ = dbe_->book2D("HitVal33","Energy EM mod P2 vs Time", 4000, 0., 8000., 300, 0., 600. );
94  meZdcEneTEmP3_ = dbe_->book2D("HitVal34","Energy EM mod P3 vs Time", 4000, 0., 8000., 300, 0., 600. );
95  meZdcEneTEmP4_ = dbe_->book2D("HitVal35","Energy EM mod P4 vs Time", 4000, 0., 8000., 300, 0., 600. );
96  meZdcEneTEmP5_ = dbe_->book2D("HitVal36","Energy EM mod P5 vs Time", 4000, 0., 8000., 300, 0., 600. );
97  meZdcEneTHadP1_ = dbe_->book2D("HitVal37","Energy HAD mod P1 vs Time", 4000, 0., 8000., 300, 0., 600. );
98  meZdcEneTHadP2_ = dbe_->book2D("HitVal38","Energy HAD mod P2 vs Time", 4000, 0., 8000., 300, 0., 600. );
99  meZdcEneTHadP3_ = dbe_->book2D("HitVal39","Energy HAD mod P3 vs Time", 4000, 0., 8000., 300, 0., 600. );
100  meZdcEneTHadP4_ = dbe_->book2D("HitVal40","Energy HAD mod P4 vs Time", 4000, 0., 8000., 300, 0., 600. );
101  meZdcEneHadPTot_ = dbe_->book1D("HitVal41","Total HAD Energy P",4000,0.,8000.);
102  meZdcEneEmPTot_ = dbe_->book1D("HitVal42","Total EM Energy P",4000,0.,8000.);
103  meZdcEnePTot_ = dbe_->book1D("HitVal43","Total Energy P",4000,0.,8000.);
104  meZdcCorEEmNEHadN_= dbe_->book2D("HitVal47","Energy EMN vs HADN", 4000, 0., 8000.,4000, 0., 8000.);
105  meZdcCorEEmPEHadP_= dbe_->book2D("HitVal44","Energy EMP vs HADP", 4000, 0., 8000.,4000, 0., 8000.);
106  meZdcCorEtotNEtotP_ = dbe_->book2D("HitVal45","Energy N vs P", 4000, 0., 8000.,4000, 0., 8000.);
107  meZdcEneTot_ = dbe_->book1D("HitVal46","Total Energy ZDCs",4000,0.,8000.);
108  }
109  }
110 }
111 
113  if (dbe_ && outFile_.size() > 0) dbe_->save(outFile_);
114 }
115 
117 
118  LogDebug("ZdcSimHitStudy")
119  //std::cout
120  << "Run = " << e.id().run() << " Event = "
121  << e.id().event();
122  //std::cout<<std::endl;
123 
124  std::vector<PCaloHit> caloHits;
126 
127  bool getHits = false;
128  if (checkHit_) {
129  e.getByLabel(g4Label,zdcHits,hitsZdc);
130  if (hitsZdc.isValid()) getHits = true;
131  }
132 
133  LogDebug("ZdcSim") << "ZdcValidation: Input flags Hits " << getHits;
134 
135  if (getHits) {
136  caloHits.insert(caloHits.end(),hitsZdc->begin(),hitsZdc->end());
137  LogDebug("ZdcSimHitStudy")
138  //std::cout
139  << "ZdcValidation: Hit buffer "
140  << caloHits.size();
141  //<< std::endl;
142  analyzeHits (caloHits);
143  }
144 }
145 
146 void ZdcSimHitStudy::analyzeHits(std::vector<PCaloHit>& hits){
147  int nHit = hits.size();
148  int nZdcEM = 0, nZdcHad = 0, nZdcLum = 0;
149  int nBad1=0, nBad2=0, nBad=0;
150  std::vector<double> encontZdcEM(140, 0.);
151  std::vector<double> encontZdcHad(140, 0.);
152  double entotZdcEM = 0;
153  double entotZdcHad = 0;
154 
155  enetotEmN = 0;
156  enetotHadN = 0.;
157  enetotN = 0;
158  enetotEmP = 0;
159  enetotHadP = 0;
160  enetotP = 0;
161  enetot = 0;
162 
163  for (int i=0; i<nHit; i++) {
164  double energy = hits[i].energy();
165  double log10en = log10(energy);
166  int log10i = int( (log10en+10.)*10. );
167  double time = hits[i].time();
168  unsigned int id_ = hits[i].id();
169  HcalZDCDetId id = HcalZDCDetId(id_);
170  int det = id.det();
171  int side = id.zside();
172  int section = id.section();
173  int channel = id.channel();
174 
175  FillHitValHist(side,section,channel,energy,time);
176 
177 
178  LogDebug("ZdcSimHitStudy")
179  //std::cout
180  << "Hit[" << i << "] ID " << std::hex << id_
181  << std::dec <<" DetID "<<id
182  << " Det "<< det << " side "<< side
183  << " Section " << section
184  << " channel "<< channel
185  << " E " << energy
186  << " time \n" << time;
187  //<<std::endl;
188 
189  if(det == 5) { // Check DetId.h
190  if(section == HcalZDCDetId::EM)nZdcEM++;
191  else if(section == HcalZDCDetId::HAD)nZdcHad++;
192  else if(section == HcalZDCDetId::LUM)nZdcLum++;
193  else { nBad++; nBad2++;}
194  } else { nBad++; nBad1++;}
195  if (dbe_) {
196  meZdcDetectHit_->Fill(double(det));
197  if (det == 5) {
198  meZdcSideHit_->Fill(double(side));
199  meZdcSectionHit_->Fill(double(section));
200  meZdcChannelHit_->Fill(double(channel));
201  meZdcEnergyHit_->Fill(energy);
202  if(section == HcalZDCDetId::EM){
203  meZdcEMEnergyHit_->Fill(energy);
204  meZdcEEMCh_->Fill(energy,channel);
205  if( log10i >=0 && log10i < 140 )encontZdcEM[log10i] += energy;
206  entotZdcEM += energy;
207  }
208  if(section == HcalZDCDetId::HAD){
209  meZdcHadEnergyHit_->Fill(energy);
210  meZdcEHadCh_->Fill(energy,channel);
211  if( log10i >=0 && log10i < 140 )encontZdcHad[log10i] += energy;
212  entotZdcHad += energy;
213  }
214  meZdcTimeHit_->Fill(time);
215  meZdcTimeWHit_->Fill(double(time),energy);
216  meZdc10Ene_->Fill(log10en);
217  meZdcETime_->Fill(energy, double(time));
218  }
219  }
220  }
221 
222  if( entotZdcEM != 0 ) for( int i=0; i<140; i++ ) meZdcEML10EneP_->Fill( -10.+(float(i)+0.5)/10., encontZdcEM[i]/entotZdcEM);
223  if( entotZdcHad != 0 ) for( int i=0; i<140; i++ ) meZdcHadL10EneP_->Fill( -10.+(float(i)+0.5)/10.,encontZdcHad[i]/entotZdcHad);
224 
225  if (dbe_ && nHit>0) {
226  meAllZdcNHit_->Fill(double(nHit));
227  meBadZdcDetHit_->Fill(double(nBad1));
228  meBadZdcSecHit_->Fill(double(nBad2));
229  meBadZdcIdHit_->Fill(double(nBad));
230  meZdcNHitEM_->Fill(double(nZdcEM));
231  meZdcNHitHad_->Fill(double(nZdcHad));
232  meZdcNHitLum_->Fill(double(nZdcLum));
242  }
243  LogDebug("HcalSimHitStudy")
244  //std::cout
245  <<"HcalSimHitStudy::analyzeHits: Had " << nZdcHad
246  << " EM "<< nZdcEM
247  << " Bad " << nBad << " All " << nHit;
248  //<<std::endl;
249 }
250 
251 int ZdcSimHitStudy::FillHitValHist(int side,int section,int channel,double energy,double time){
252  enetot += enetot;
253  if(side == -1){
254  enetotN += energy;
255  if(section == HcalZDCDetId::EM){
256  enetotEmN += energy;
257  switch(channel){
258  case 1 :
259  meZdcEneEmN1_->Fill(energy);
260  meZdcEneTEmN1_->Fill(energy,time);
261  break;
262  case 2 :
263  meZdcEneEmN2_->Fill(energy);
264  meZdcEneTEmN2_->Fill(energy,time);
265  break;
266  case 3 :
267  meZdcEneEmN3_->Fill(energy);
268  meZdcEneTEmN3_->Fill(energy,time);
269  break;
270  case 4 :
271  meZdcEneEmN4_->Fill(energy);
272  meZdcEneTEmN4_->Fill(energy,time);
273  break;
274  case 5 :
275  meZdcEneEmN4_->Fill(energy);
276  meZdcEneTEmN4_->Fill(energy,time);
277  break;
278  }
279  }
280  if(section == HcalZDCDetId::HAD){
281  enetotHadN += energy;
282  switch(channel){
283  case 1 :
284  meZdcEneHadN1_->Fill(energy);
285  meZdcEneTHadN1_->Fill(energy,time);
286  break;
287  case 2 :
288  meZdcEneHadN2_->Fill(energy);
289  meZdcEneTHadN2_->Fill(energy,time);
290  break;
291  case 3 :
292  meZdcEneHadN3_->Fill(energy);
293  meZdcEneTHadN3_->Fill(energy,time);
294  break;
295  case 4 :
296  meZdcEneHadN4_->Fill(energy);
297  meZdcEneTHadN4_->Fill(energy,time);
298  break;
299  }
300  }
301  }
302  if(side == 1){
303  enetotP += energy;
304  if(section == HcalZDCDetId::EM){
305  enetotEmP += energy;
306  switch(channel){
307  case 1 :
308  meZdcEneEmP1_->Fill(energy);
309  meZdcEneTEmP1_->Fill(energy,time);
310  break;
311  case 2 :
312  meZdcEneEmP2_->Fill(energy);
313  meZdcEneTEmP2_->Fill(energy,time);
314  break;
315  case 3 :
316  meZdcEneEmP3_->Fill(energy);
317  meZdcEneTEmP3_->Fill(energy,time);
318  break;
319  case 4 :
320  meZdcEneEmP4_->Fill(energy);
321  meZdcEneTEmP4_->Fill(energy,time);
322  break;
323  case 5 :
324  meZdcEneEmP4_->Fill(energy);
325  meZdcEneTEmP4_->Fill(energy,time);
326  break;
327  }
328  }
329  if(section == HcalZDCDetId::HAD){
330  enetotHadP += energy;
331  switch(channel){
332  case 1 :
333  meZdcEneHadP1_->Fill(energy);
334  meZdcEneTHadP1_->Fill(energy,time);
335  break;
336  case 2 :
337  meZdcEneHadP2_->Fill(energy);
338  meZdcEneTHadP2_->Fill(energy,time);
339  break;
340  case 3 :
341  meZdcEneHadP3_->Fill(energy);
342  meZdcEneTHadP3_->Fill(energy,time);
343  break;
344  case 4 :
345  meZdcEneHadP4_->Fill(energy);
346  meZdcEneTHadP4_->Fill(energy,time);
347  break;
348  }
349  }
350  }
351  return 0;
352 }
353 
354 
355 
356 
357 
358 
359 
360 
361 
362 
363 
364 
365 
366 
367 
368 
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
MonitorElement * meZdcEneTHadP3_
MonitorElement * meZdcEnergyHit_
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meZdcEneTEmN1_
int i
Definition: DBlmapReader.cc:9
void analyzeHits(std::vector< PCaloHit > &)
MonitorElement * meZdcEneTEmP1_
MonitorElement * meZdcHadL10EneP_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * meZdcEneEmP3_
MonitorElement * meZdcEneEmPTot_
MonitorElement * meZdcEneEmN1_
MonitorElement * meZdcEneTEmP4_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
MonitorElement * meZdcEneHadN1_
MonitorElement * meZdcCorEEmNEHadN_
MonitorElement * meZdcEneEmN4_
MonitorElement * meZdcEneTHadN4_
MonitorElement * meZdcEneEmN5_
std::string outFile_
MonitorElement * meAllZdcNHit_
MonitorElement * meZdcEneTEmN2_
void sleep(Duration_t)
Definition: Utils.h:163
MonitorElement * meZdcEneHadN4_
MonitorElement * meZdcEneTHadN2_
void Fill(long long x)
MonitorElement * meZdcEneEmNTot_
MonitorElement * meZdcChannelHit_
MonitorElement * meZdcEneEmP2_
MonitorElement * meZdcEneHadP1_
MonitorElement * meZdcEML10EneP_
MonitorElement * meZdcEneTEmN5_
MonitorElement * meZdcEneEmN3_
MonitorElement * meZdcNHitHad_
MonitorElement * meBadZdcDetHit_
ZdcSimHitStudy(const edm::ParameterSet &ps)
MonitorElement * meZdcEneTEmP5_
MonitorElement * meZdcEnePTot_
MonitorElement * meZdcEneTEmN4_
MonitorElement * meZdcCorEEmPEHadP_
MonitorElement * meZdcEneTHadP2_
MonitorElement * meZdcSideHit_
MonitorElement * meZdcEneHadN3_
MonitorElement * meZdcEneEmN2_
MonitorElement * meZdcEneTHadN1_
MonitorElement * meZdcEneTEmP3_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1031
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
MonitorElement * meZdcDetectHit_
MonitorElement * meZdc10Ene_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * meZdcEneHadP4_
std::string zdcHits
int FillHitValHist(int side, int section, int channel, double energy, double time)
MonitorElement * meZdcEneTot_
MonitorElement * meZdcEneHadP3_
MonitorElement * meZdcEneTEmN3_
MonitorElement * meBadZdcSecHit_
MonitorElement * meZdcEneTHadP1_
void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * meZdcTimeHit_
MonitorElement * meBadZdcIdHit_
MonitorElement * meZdcEneTHadP4_
std::string g4Label
MonitorElement * meZdcEneHadNTot_
MonitorElement * meZdcCorEtotNEtotP_
MonitorElement * meZdcEneHadP2_
MonitorElement * meZdcEneEmP4_
MonitorElement * meZdcHadEnergyHit_
MonitorElement * meZdcEneEmP5_
edm::EventID id() const
Definition: EventBase.h:56
MonitorElement * meZdcEneTEmP2_
MonitorElement * meZdcSectionHit_
DQMStore * dbe_
MonitorElement * meZdcEneNTot_
MonitorElement * meZdcEneHadN2_
MonitorElement * meZdcEneHadPTot_
MonitorElement * meZdcEEMCh_
void showDirStructure(void) const
Definition: DQMStore.cc:2761
MonitorElement * meZdcEneEmP1_
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
MonitorElement * meZdcNHitEM_
MonitorElement * meZdcEneTHadN3_
MonitorElement * meZdcTimeWHit_
MonitorElement * meZdcEHadCh_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * meZdcETime_
MonitorElement * meZdcEMEnergyHit_
MonitorElement * meZdcNHitLum_