CMS 3D CMS Logo

HcalLedAnalysis.cc
Go to the documentation of this file.
1 
5 
7 #include "TFile.h"
8 #include <cmath>
9 using namespace std;
10 
11 
13 {
14  // init
15 
16  m_coder = nullptr;
17  m_ped = nullptr;
18  m_shape = nullptr;
19  evt=0;
20  sample=0;
21  m_file=nullptr;
22  // output files
23  for(int k=0;k<4;k++) state.push_back(true); // 4 cap-ids (do we care?)
24  m_outputFileText = ps.getUntrackedParameter<string>("outputFileText", "");
25  m_outputFileX = ps.getUntrackedParameter<string>("outputFileXML","");
26  if ( !m_outputFileText.empty() ) {
27  cout << "Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
28  m_outFile.open(m_outputFileText.c_str());
29  }
30  m_outputFileROOT = ps.getUntrackedParameter<string>("outputFileHist", "");
31  if ( !m_outputFileROOT.empty() ) {
32  cout << "Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
33  }
34 
35  m_nevtsample = ps.getUntrackedParameter<int>("nevtsample",9999999);
36  if(m_nevtsample<1)m_nevtsample=9999999;
37  m_hiSaveflag = ps.getUntrackedParameter<int>("hiSaveflag",0);
38  if(m_hiSaveflag<0)m_hiSaveflag=0;
39  if(m_hiSaveflag>0)m_hiSaveflag=1;
40  m_fitflag = ps.getUntrackedParameter<int>("analysisflag",2);
41  if(m_fitflag<0)m_fitflag=0;
42  if(m_fitflag>4)m_fitflag=4;
43  m_startTS = ps.getUntrackedParameter<int>("firstTS", 0);
44  if(m_startTS<0) m_startTS=0;
45  m_endTS = ps.getUntrackedParameter<int>("lastTS", 9);
46  m_usecalib = ps.getUntrackedParameter<bool>("usecalib",false);
47  m_logFile.open("HcalLedAnalysis.log");
48 
49  int runNum = ps.getUntrackedParameter<int>("runNumber",999999);
50 
51  // histogram booking
52  hbHists.ALLLEDS = new TH1F("HBHE All LEDs","HB/HE All Leds",10,0,9);
53  hbHists.LEDRMS= new TH1F("HBHE All LED RMS","HB/HE All LED RMS",100,0,3);
54  hbHists.LEDMEAN= new TH1F("HBHE All LED Means","HB/HE All LED Means",100,0,9);
55  hbHists.CHI2= new TH1F("HBHE Chi2 by ndf for Landau fit","HB/HE Chi2/ndf Landau",200,0.,50.);
56 
57  hoHists.ALLLEDS = new TH1F("HO All LEDs","HO All Leds",10,0,9);
58  hoHists.LEDRMS= new TH1F("HO All LED RMS","HO All LED RMS",100,0,3);
59  hoHists.LEDMEAN= new TH1F("HO All LED Means","HO All LED Means",100,0,9);
60  hoHists.CHI2= new TH1F("HO Chi2 by ndf for Landau fit","HO Chi2/ndf Landau",200,0.,50.);
61 
62  hfHists.ALLLEDS = new TH1F("HF All LEDs","HF All Leds",10,0,9);
63  hfHists.LEDRMS= new TH1F("HF All LED RMS","HF All LED RMS",100,0,3);
64  hfHists.LEDMEAN= new TH1F("HF All LED Means","HF All LED Means",100,0,9);
65  hfHists.CHI2= new TH1F("HF Chi2 by ndf for Landau fit","HF Chi2/ndf Landau",200,0.,50.);
66 
67  char output[100]{0};
68 
69  //XML file header
70  m_outputFileXML.open(m_outputFileX.c_str());
71 
72  m_outputFileXML << "<?xml version='1.0' encoding='UTF-8'?>" << endl;
73 
74  m_outputFileXML << "<ROOT>" << endl;
75 
76  m_outputFileXML << " <HEADER>" << endl;
77 
78  m_outputFileXML << " <TYPE>" << endl;
79 
80  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
81 
82  m_outputFileXML << " <NAME>HCAL LED Timing</NAME>" << endl;
83 
84  m_outputFileXML << " </TYPE>" << endl;
85 
86  m_outputFileXML << " <RUN>" << endl;
87 
88  m_outputFileXML << " <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
89 
90  snprintf(output, sizeof output, " <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
91  m_outputFileXML << output << endl;
92 
93  m_outputFileXML << " <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
94 
95  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
96 
97  m_outputFileXML << " </RUN>" << endl;
98 
99  m_outputFileXML << " </HEADER>" << endl;
100 
101  m_outputFileXML << "<!-- Tags secton -->" << endl;
102 
103  m_outputFileXML << " <ELEMENTS>" << endl;
104 
105  m_outputFileXML << " <DATA_SET id='-1'/>" << endl;
106 
107  m_outputFileXML << " <IOV id='1'>" << endl;
108 
109  m_outputFileXML << " <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
110 
111  m_outputFileXML << " <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
112 
113  m_outputFileXML << " </IOV>" << endl;
114 
115  m_outputFileXML << " <TAG id='2' mode='auto'>" << endl;
116 
117  snprintf(output, sizeof output, " <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
118  m_outputFileXML << output << endl;
119 
120  m_outputFileXML << " <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
121 
122  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
123 
124  m_outputFileXML << " </TAG>" << endl;
125 
126  m_outputFileXML << " </ELEMENTS>" << endl;
127 
128  m_outputFileXML << " <MAPS>" << endl;
129 
130  m_outputFileXML << " <TAG idref ='2'>" << endl;
131 
132  m_outputFileXML << " <IOV idref='1'>" << endl;
133 
134  m_outputFileXML << " <DATA_SET idref='-1' />" << endl;
135 
136  m_outputFileXML << " </IOV>" << endl;
137 
138  m_outputFileXML << " </TAG>" << endl;
139 
140  m_outputFileXML << " </MAPS>" << endl;
141 
142 }
143 
144 //-----------------------------------------------------------------------------
147  for(_meol=hbHists.LEDTRENDS.begin(); _meol!=hbHists.LEDTRENDS.end(); _meol++){
148  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
149  }
150  for(_meol=hoHists.LEDTRENDS.begin(); _meol!=hoHists.LEDTRENDS.end(); _meol++){
151  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
152  }
153  for(_meol=hfHists.LEDTRENDS.begin(); _meol!=hfHists.LEDTRENDS.end(); _meol++){
154  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
155  }
156  hbHists.ALLLEDS->Delete();
157  hbHists.LEDRMS->Delete();
158  hbHists.LEDMEAN->Delete();
159  hbHists.CHI2->Delete();
160 
161  hoHists.ALLLEDS->Delete();
162  hoHists.LEDRMS->Delete();
163  hoHists.LEDMEAN->Delete();
164  hoHists.CHI2->Delete();
165 
166  hfHists.ALLLEDS->Delete();
167  hfHists.LEDRMS->Delete();
168  hfHists.LEDMEAN->Delete();
169  hfHists.CHI2->Delete();
170 }
171 
172 //-----------------------------------------------------------------------------
173 void HcalLedAnalysis::LedSetup(const std::string& m_outputFileROOT) {
174  // open the histogram file, create directories within
175  m_file=new TFile(m_outputFileROOT.c_str(),"RECREATE");
176  m_file->mkdir("HBHE");
177  m_file->cd();
178  m_file->mkdir("HO");
179  m_file->cd();
180  m_file->mkdir("HF");
181  m_file->cd();
182  m_file->mkdir("Calib");
183  m_file->cd();
184 }
185 
186 //-----------------------------------------------------------------------------
187 /*
188 void HcalLedAnalysis::doPeds(const HcalPedestal* fInputPedestals){
189 // put all pedestals in a map m_AllPedVals, to be used in processLedEvent -
190 // sorry, this is the only way I was able to implement pedestal subtraction
191 
192 // DEPRECATED
193 // This is no longer useful, better ways of doing it -A
194  HcalDetId detid;
195  map<int,float> PedVals;
196  pedCan = fInputPedestals;
197  if(pedCan){
198  std::vector<DetId> Channs=pedCan->getAllChannels();
199  for (int i=0; i<(int)Channs.size(); i++){
200  detid=HcalDetId (Channs[i]);
201  for (int icap=0; icap<4; icap++) PedVals[icap]=pedCan->getValue(detid,icap);
202  m_AllPedVals[detid]=PedVals;
203  }
204  }
205 }
206 */
207 //-----------------------------------------------------------------------------
208 void HcalLedAnalysis::GetLedConst(map<HcalDetId, map<int,LEDBUNCH> > &toolT){
209  double time2=0; double time1=0; double time3=0; double time4=0;
210  double dtime2=0; double dtime1=0; double dtime3=0; double dtime4=0;
211  char output[256]{0};
212 
213  if (m_outputFileText!=""){
214  if(m_fitflag==0 || m_fitflag==2) m_outFile<<"Det Eta,Phi,D Mean Error"<<std::endl;
215  else if(m_fitflag==1 || m_fitflag==3) m_outFile<<"Det Eta,Phi,D Peak Error"<<std::endl;
216  else if(m_fitflag==4) m_outFile<<"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"<<std::endl;
217  }
218  for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
219 // scale the LED pulse to 1 event
220  _meol->second[10].first->Scale(1./evt_curr);
221  if(m_fitflag==0 || m_fitflag==4){
222  time1 = _meol->second[10].first->GetMean();
223  dtime1 = _meol->second[10].first->GetRMS()/sqrt((float)evt_curr*(m_endTS-m_startTS+1));
224  }
225  if(m_fitflag==1 || m_fitflag==4){
226 // put proper errors
227  for(int j=0; j<10; j++) _meol->second[10].first->SetBinError(j+1,_meol->second[j].first->GetRMS()/sqrt((float)evt_curr));
228  }
229  if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
230  _meol->second[10].first->Fit("landau","Q");
231 // _meol->second[10].first->Fit("gaus","Q");
232  TF1 *fit = _meol->second[10].first->GetFunction("landau");
233 // TF1 *fit = _meol->second[10].first->GetFunction("gaus");
234  time2=fit->GetParameter(1);
235  dtime2=fit->GetParError(1);
236  }
237  if(m_fitflag==2 || m_fitflag==4){
238  time3 = _meol->second[12].first->GetMean();
239  dtime3 = _meol->second[12].first->GetRMS()/sqrt((float)_meol->second[12].first->GetEntries());
240  }
241  if(m_fitflag==3 || m_fitflag==4){
242  time4 = _meol->second[13].first->GetMean();
243  dtime4 = _meol->second[13].first->GetRMS()/sqrt((float)_meol->second[13].first->GetEntries());
244  }
245  for (int i=0; i<10; i++){
246  _meol->second[i].first->GetXaxis()->SetTitle("Pulse height (fC)");
247  _meol->second[i].first->GetYaxis()->SetTitle("Counts");
248 // if(m_hiSaveflag>0)_meol->second[i].first->Write();
249  }
250  _meol->second[10].first->GetXaxis()->SetTitle("Time slice");
251  _meol->second[10].first->GetYaxis()->SetTitle("Averaged pulse (fC)");
252  if(m_hiSaveflag>0)_meol->second[10].first->Write();
253  _meol->second[10].second.first[0].push_back(time1);
254  _meol->second[10].second.first[1].push_back(dtime1);
255  _meol->second[11].second.first[0].push_back(time2);
256  _meol->second[11].second.first[1].push_back(dtime2);
257  _meol->second[12].first->GetXaxis()->SetTitle("Mean TS");
258  _meol->second[12].first->GetYaxis()->SetTitle("Counts");
259  if(m_fitflag==2 && m_hiSaveflag>0)_meol->second[12].first->Write();
260  _meol->second[12].second.first[0].push_back(time3);
261  _meol->second[12].second.first[1].push_back(dtime3);
262  _meol->second[13].first->GetXaxis()->SetTitle("Peak TS");
263  _meol->second[13].first->GetYaxis()->SetTitle("Counts");
264  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[13].first->Write();
265  _meol->second[13].second.first[0].push_back(time4);
266  _meol->second[13].second.first[1].push_back(dtime4);
267  _meol->second[14].first->GetXaxis()->SetTitle("Peak TS error");
268  _meol->second[14].first->GetYaxis()->SetTitle("Counts");
269  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[14].first->Write();
270  _meol->second[15].first->GetXaxis()->SetTitle("Chi2/NDF");
271  _meol->second[15].first->GetYaxis()->SetTitle("Counts");
272  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[15].first->Write();
273  _meol->second[16].first->GetXaxis()->SetTitle("Integrated Signal");
274  _meol->second[16].first->Write();
275 
276 
277 // Ascii printout (need to modify to include new info)
278  HcalDetId detid = _meol->first;
279 
280  if (m_outputFileText!=""){
281  if(m_fitflag==0) {
282  m_outFile<<detid<<" "<<time1<<" "<<dtime1<<std::endl;
283  m_outputFileXML << " <DATA_SET>" << endl;
284  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
285  m_outputFileXML << " <CHANNEL>" << endl;
286  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
287  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs() );
288  m_outputFileXML << output << endl;
289  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi() );
290  m_outputFileXML << output << endl;
291  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth() );
292  m_outputFileXML << output << endl;
293  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside() );
294  m_outputFileXML << output << endl;
295 
296  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
297  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
298  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
299  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
300  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
301  m_outputFileXML << output << endl;
302  m_outputFileXML << " </CHANNEL>" << endl;
303  m_outputFileXML << " <DATA>" << endl;
304  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time1);
305  m_outputFileXML << output << endl;
306  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
307  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
308  m_outputFileXML << output << endl;
309  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
310  m_outputFileXML << output << endl;
311  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
312  m_outputFileXML << " </DATA>" << endl;
313  m_outputFileXML << " </DATA_SET>" << endl;
314 
315  }
316  else if(m_fitflag==1){
317  m_outFile<<detid<<" "<<time2<<" "<<dtime2<<std::endl;
318  m_outputFileXML << " <DATA_SET>" << endl;
319  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
320  m_outputFileXML << " <CHANNEL>" << endl;
321  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
322  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs() );
323  m_outputFileXML << output << endl;
324  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi() );
325  m_outputFileXML << output << endl;
326  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth() );
327  m_outputFileXML << output << endl;
328  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside() );
329  m_outputFileXML << output << endl;
330  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>"<< endl;
331  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>"<< endl;
332  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>"<< endl;
333  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>"<< endl;
334  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
335  m_outputFileXML << output << endl;
336  m_outputFileXML << " </CHANNEL>" << endl;
337  m_outputFileXML << " <DATA>" << endl;
338  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time2);
339  m_outputFileXML << output << endl;
340  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
341  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
342  m_outputFileXML << output << endl;
343  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
344  m_outputFileXML << output << endl;
345  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
346  m_outputFileXML << " </DATA>" << endl;
347  m_outputFileXML << " </DATA_SET>" << endl;
348  }
349 
350  else if(m_fitflag==2){
351  m_outFile<<detid<<" "<<time3<<" "<<dtime3<<std::endl;
352  m_outputFileXML << " <DATA_SET>" << endl;
353  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
354  m_outputFileXML << " <CHANNEL>" << endl;
355  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
356  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs() );
357  m_outputFileXML << output << endl;
358  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi() );
359  m_outputFileXML << output << endl;
360  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth() );
361  m_outputFileXML << output << endl;
362  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside() );
363  m_outputFileXML << output << endl;
364  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
365  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
366  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
367  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
368  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
369  m_outputFileXML << output << endl;
370  m_outputFileXML << " </CHANNEL>" << endl;
371  m_outputFileXML << " <DATA>" << endl;
372  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time3);
373  m_outputFileXML << output << endl;
374  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
375  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
376  m_outputFileXML << output << endl;
377  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
378  m_outputFileXML << output << endl;
379  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
380  m_outputFileXML << " </DATA>" << endl;
381  m_outputFileXML << " </DATA_SET>" << endl;
382  }
383  else if(m_fitflag==3){
384  m_outFile<<detid<<" "<<time4<<" "<<dtime4<<std::endl;
385  m_outputFileXML << " <DATA_SET>" << endl;
386  m_outputFileXML <<" <VERSION>version:1</VERSION>" << endl;
387  m_outputFileXML << " <CHANNEL>" << endl;
388  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
389  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs() );
390  m_outputFileXML << output << endl;
391  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi() );
392  m_outputFileXML << output << endl;
393  snprintf(output, sizeof output," <DEPTH>%2i</DEPTH>", detid.depth() );
394  m_outputFileXML << output << endl;
395  sprintf(output, " <Z>%2i</Z>", detid.zside() );
396  m_outputFileXML << output << endl;
397  if(detid.subdet() == 1) m_outputFileXML <<" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
398  if(detid.subdet() == 2) m_outputFileXML <<" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
399  if(detid.subdet() == 3) m_outputFileXML <<" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
400  if(detid.subdet() == 4) m_outputFileXML <<" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
401  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
402  m_outputFileXML << output << endl;
403  m_outputFileXML << " </CHANNEL>" << endl;
404  m_outputFileXML << " <DATA>" << endl;
405  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time4);
406  m_outputFileXML << output << endl;
407  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
408  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
409  m_outputFileXML << output << endl;
410  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
411  m_outputFileXML << output << endl;
412  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
413  m_outputFileXML << " </DATA>" << endl;
414  m_outputFileXML << " </DATA_SET>" << endl;
415  }
416 
417  else if(m_fitflag==4){
418  m_outFile<<detid<<" "<<time1<<" "<<dtime1<<" "<<time2<<" "<<dtime2<<" "<<time3<<" "<<dtime3<<" "<<time4<<" "<<dtime4<<std::endl;
419  }
420  }
421  }
422 }
423 
424 //-----------------------------------------------------------------------------
426  // it is called every m_nevtsample events (a sample) and the end of run
427  char LedSampleNum[20];
428 
429  snprintf(LedSampleNum, sizeof LedSampleNum, "LedSample_%d", sample);
430  m_file->cd();
431  m_file->mkdir(LedSampleNum);
432  m_file->cd(LedSampleNum);
433 
434 // Compute LED constants for each HB/HE, HO, HF
435  GetLedConst(hbHists.LEDTRENDS);
436  GetLedConst(hoHists.LEDTRENDS);
437  GetLedConst(hfHists.LEDTRENDS);
438 }
439 
440 //-----------------------------------------------------------------------------
441 void HcalLedAnalysis::LedTrendings(map<HcalDetId, map<int,LEDBUNCH> > &toolT)
442 {
443 
444  for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
445  char name[1024];
446  HcalDetId detid = _meol->first;
447  snprintf(name, sizeof name, "LED timing trend, eta=%d phi=%d depth=%d", detid.ieta(), detid.iphi(), detid.depth());
448  int bins = _meol->second[10+m_fitflag].second.first[0].size();
449  float lo =0.5;
450  float hi = (float)bins+0.5;
451  _meol->second[10+m_fitflag].second.second.push_back(new TH1F(name,name,bins,lo,hi));
452 
453  std::vector<double>::iterator sample_it;
454 // LED timing - put content and errors
455  int j=0;
456  for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
457  sample_it!=_meol->second[10+m_fitflag].second.first[0].end();++sample_it){
458  _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
459  }
460  j=0;
461  for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
462  sample_it!=_meol->second[10+m_fitflag].second.first[1].end();++sample_it){
463  _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
464  }
465  snprintf(name, sizeof name, "Sample (%d events)", m_nevtsample);
466  _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
467  _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle("Peak position");
468  _meol->second[10+m_fitflag].second.second[0]->Write();
469  }
470 }
471 
472 //-----------------------------------------------------------------------------
474 {
475 
476 // First process the last sample (remaining events).
477  if(evt%m_nevtsample!=0) LedSampleAnalysis();
478 
479 // Now do the end of run analysis: trending histos
480  if(sample>1 && m_fitflag!=4){
481  m_file->cd();
482  m_file->cd("HBHE");
483  LedTrendings(hbHists.LEDTRENDS);
484  m_file->cd();
485  m_file->cd("HO");
486  LedTrendings(hoHists.LEDTRENDS);
487  m_file->cd();
488  m_file->cd("HF");
489  LedTrendings(hfHists.LEDTRENDS);
490  }
491 
492  // Write other histograms.
493  // HB
494  m_file->cd();
495  m_file->cd("HBHE");
496  hbHists.ALLLEDS->Write();
497  hbHists.LEDRMS->Write();
498  hbHists.LEDMEAN->Write();
499  // HO
500  m_file->cd();
501  m_file->cd("HO");
502  hoHists.ALLLEDS->Write();
503  hoHists.LEDRMS->Write();
504  hoHists.LEDMEAN->Write();
505  // HF
506  m_file->cd();
507  m_file->cd("HF");
508  hfHists.ALLLEDS->Write();
509  hfHists.LEDRMS->Write();
510  hfHists.LEDMEAN->Write();
511  // Calib
512  m_file->cd();
513  m_file->cd("Calib");
514  for(_meca=calibHists.begin(); _meca!=calibHists.end(); _meca++){
515  _meca->second.avePulse->Write();
516  _meca->second.integPulse->Write();
517  }
518 
519  // Write the histo file and close it
520 // m_file->Write();
521  m_file->Close();
522  cout << "Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
523 }
524 
525 //-----------------------------------------------------------------------------
527  const HODigiCollection& ho,
528  const HFDigiCollection& hf,
530  const HcalDbService& cond)
531 {
532  evt++;
533  sample = (evt-1)/m_nevtsample +1;
534  evt_curr = evt%m_nevtsample;
535  if(evt_curr==0)evt_curr=m_nevtsample;
536 
537  // Calib
538 
539  if (m_usecalib){
540  try{
541  if(calib.empty()) throw (int)calib.size();
542  // this is effectively a loop over electronic channels
543  for (HcalCalibDigiCollection::const_iterator j=calib.begin(); j!=calib.end(); ++j){
544  const HcalCalibDataFrame digi = (const HcalCalibDataFrame)(*j);
545  HcalElectronicsId elecId = digi.elecId();
546  HcalCalibDetId calibId = digi.id();
547  ProcessCalibEvent(elecId.fiberChanId(),calibId,digi); //Shouldn't depend on anything in elecId but not sure how else to do it
548  }
549  }
550  catch (int i ) {
551  // m_logFile<< "Event with " << i<<" Calib Digis passed." << std::endl;
552  }
553  }
554 
555 
556  // HB + HE
557  try{
558  if(hbhe.empty()) throw (int)hbhe.size();
559 // this is effectively a loop over electronic channels
560  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); ++j){
561  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
562  for(int k=0; k<(int)state.size();k++) state[k]=true;
563  // See if histos exist for this channel, and if not, create them
564  _meol = hbHists.LEDTRENDS.find(digi.id());
565  if (_meol==hbHists.LEDTRENDS.end()){
566  SetupLEDHists(0,digi.id(),hbHists.LEDTRENDS);
567  }
568  LedHBHEHists(digi.id(),digi,hbHists.LEDTRENDS,cond);
569  }
570  }
571  catch (int i ) {
572 // m_logFile<< "Event with " << i<<" HBHE Digis passed." << std::endl;
573  }
574 
575  // HO
576  try{
577  if(ho.empty()) throw (int)ho.size();
578  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); ++j){
579  const HODataFrame digi = (const HODataFrame)(*j);
580  _meol = hoHists.LEDTRENDS.find(digi.id());
581  if (_meol==hoHists.LEDTRENDS.end()){
582  SetupLEDHists(1,digi.id(),hoHists.LEDTRENDS);
583  }
584  LedHOHists(digi.id(),digi,hoHists.LEDTRENDS,cond);
585  }
586  }
587  catch (int i ) {
588 // m_logFile << "Event with " << i<<" HO Digis passed." << std::endl;
589  }
590 
591  // HF
592  try{
593  if(hf.empty()) throw (int)hf.size();
594  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); ++j){
595  const HFDataFrame digi = (const HFDataFrame)(*j);
596  _meol = hfHists.LEDTRENDS.find(digi.id());
597  if (_meol==hfHists.LEDTRENDS.end()){
598  SetupLEDHists(2,digi.id(),hfHists.LEDTRENDS);
599  }
600  LedHFHists(digi.id(),digi,hfHists.LEDTRENDS,cond);
601  }
602  }
603  catch (int i ) {
604 // m_logFile << "Event with " << i<<" HF Digis passed." << std::endl;
605  }
606 
607  // Call the function every m_nevtsample events
608  if(evt%m_nevtsample==0) LedSampleAnalysis();
609 
610 }
611 //----------------------------------------------------------------------------
612 void HcalLedAnalysis::SetupLEDHists(int id, const HcalDetId detid, map<HcalDetId, map<int,LEDBUNCH> > &toolT) {
613 
614  string type = "HBHE";
615  if(id==1) type = "HO";
616  if(id==2) type = "HF";
617 
618  _meol = toolT.find(detid);
619  if (_meol==toolT.end()){
620 // if histos for this channel do not exist, create them
621  map<int,LEDBUNCH> insert;
622  char name[1024];
623  for(int i=0; i<10; i++){
624  snprintf(name, sizeof name, "%s Pulse height, eta=%d phi=%d depth=%d TS=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth(), i);
625  insert[i].first = new TH1F(name,name,200,0.,2000.);
626  }
627  snprintf(name, sizeof name, "%s LED Mean pulse, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
628  insert[10].first = new TH1F(name,name,10,-0.5,9.5);
629  snprintf(name, sizeof name, "%s LED Pulse, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
630  insert[11].first = new TH1F(name,name,10,-0.5,9.5);
631  snprintf(name, sizeof name, "%s Mean TS, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
632  insert[12].first = new TH1F(name,name,200,0.,10.);
633  snprintf(name, sizeof name, "%s Peak TS, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
634  insert[13].first = new TH1F(name,name,200,0.,10.);
635  snprintf(name, sizeof name, "%s Peak TS error, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
636  insert[14].first = new TH1F(name,name,200,0.,0.05);
637  snprintf(name, sizeof name, "%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
638  insert[15].first = new TH1F(name,name,100,0.,50.);
639  snprintf(name, sizeof name, "%s Integrated Signal, eta=%d phi=%d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
640  insert[16].first = new TH1F(name,name,500,0.,5000.);
641 
642  toolT[detid] = insert;
643  }
644 }
645 //-----------------------------------------------------------------------------
646 void HcalLedAnalysis::LedHBHEHists(const HcalDetId& detid, const HBHEDataFrame& ledDigi, map<HcalDetId, map<int,LEDBUNCH> > &toolT, const HcalDbService& cond){
647 
648  map<int,LEDBUNCH> _mei;
649  _meol = toolT.find(detid);
650  _mei = _meol->second;
651 
652  // Reset the histos if we're at the end of a 'bunch'
653  if((evt-1)%m_nevtsample==0 && state[0]){
654  for(int k=0; k<(int)state.size();k++) state[k]=false;
655  for(int i=0; i<16; i++) _mei[i].first->Reset();
656  }
657 
658  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
659 
660 
661  // int maxTS = -1;
662  float max_fC = 0;
663  float ta = 0;
664  m_coder = cond.getHcalCoder(detid);
665  m_ped = cond.getPedestal(detid);
666  m_shape = cond.getHcalShape(m_coder);
667  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
668  int capid = ledDigi[TS].capid();
669  int adc = ledDigi[TS].adc();
670  double fC = m_coder->charge(*m_shape,adc,capid);
671  ta = (fC - m_ped->getValue(capid));
672  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " fC: " << fC << endl;
673  _mei[TS].first->Fill(ta);
674  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
675  if(m_fitflag>1){
676  if(TS==m_startTS)_mei[11].first->Reset();
677  _mei[11].first->SetBinContent(TS+1,ta);
678  }
679  // keep track of max TS and max amplitude (in fC)
680  if (ta > max_fC){
681  max_fC = ta;
682  // maxTS = TS;
683  }
684  }
685 
686  // Now we have a sample with pedestals subtracted and in units of fC
687  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
688  // we now want to use Phil's timing correction. This is not necessary
689  // if we are performing a Landau fit (m_fitflag = 3)
690 
691  float sum=0.;
692  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
693  if(sum>100){
694  if(m_fitflag==2 || m_fitflag==4){
695  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
696  float timmeancorr=BinsizeCorr(timmean);
697  _mei[12].first->Fill(timmeancorr);
698  }
699  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
700  if(m_fitflag==3 || m_fitflag==4){
701  _mei[11].first->Fit("landau","Q");
702  TF1 *fit = _mei[11].first->GetFunction("landau");
703  _mei[13].first->Fill(fit->GetParameter(1));
704  _mei[14].first->Fill(fit->GetParError(1));
705  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
706  }
707  }
708 
709 }
710 
711 //-----------------------------------------------------------------------------
712 void HcalLedAnalysis::LedHOHists(const HcalDetId& detid, const HODataFrame& ledDigi, map<HcalDetId, map<int,LEDBUNCH> > &toolT, const HcalDbService& cond) {
713 
714  map<int,LEDBUNCH> _mei;
715  _meol = toolT.find(detid);
716  _mei = _meol->second;
717  // Rest the histos if we're at the end of a 'bunch'
718  if((evt-1)%m_nevtsample==0 && state[0]){
719  for(int k=0; k<(int)state.size();k++) state[k]=false;
720  for(int i=0; i<16; i++) _mei[i].first->Reset();
721  }
722 
723  // now we have the signal in fC, let's get rid of that darn pedestal
724  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
725 
726  // int maxTS = -1;
727  float max_fC = 0;
728  float ta = 0;
729  m_coder = cond.getHcalCoder(detid);
730  m_ped = cond.getPedestal(detid);
731  m_shape = cond.getHcalShape(m_coder);
732  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
733  int capid = ledDigi[TS].capid();
734  int adc = ledDigi[TS].adc();
735  double fC = m_coder->charge(*m_shape,adc,capid);
736  ta = (fC - m_ped->getValue(capid));
737  _mei[TS].first->Fill(ta);
738  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
739  if(m_fitflag>1){
740  if(TS==m_startTS)_mei[11].first->Reset();
741  _mei[11].first->SetBinContent(TS+1,ta);
742  }
743  // keep track of max TS and max amplitude (in fC)
744  if (ta > max_fC){
745  max_fC = ta;
746  // maxTS = TS;
747  }
748  }
749 
750  // Now we have a sample with pedestals subtracted and in units of fC
751  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
752  // we now want to use Phil's timing correction. This is not necessary
753  // if we are performing a Landau fit (m_fitflag = 3)
754 
755  float sum=0.;
756  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
757  if(sum>100){
758  if(m_fitflag==2 || m_fitflag==4){
759  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
760  float timmeancorr=BinsizeCorr(timmean);
761  _mei[12].first->Fill(timmeancorr);
762  }
763  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
764  if(m_fitflag==3 || m_fitflag==4){
765  _mei[11].first->Fit("landau","Q");
766  TF1 *fit = _mei[11].first->GetFunction("landau");
767  _mei[13].first->Fill(fit->GetParameter(1));
768  _mei[14].first->Fill(fit->GetParError(1));
769  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
770  }
771  }
772 
773 }
774 
775 //-----------------------------------------------------------------------------
776 void HcalLedAnalysis::LedHFHists(const HcalDetId& detid, const HFDataFrame& ledDigi, map<HcalDetId, map<int,LEDBUNCH> > &toolT, const HcalDbService& cond) {
777 
778  map<int,LEDBUNCH> _mei;
779  _meol = toolT.find(detid);
780  _mei = _meol->second;
781  // Rest the histos if we're at the end of a 'bunch'
782  if((evt-1)%m_nevtsample==0 && state[0]){
783  for(int k=0; k<(int)state.size();k++) state[k]=false;
784  for(int i=0; i<16; i++) _mei[i].first->Reset();
785  }
786 
787  // now we have the signal in fC, let's get rid of that darn pedestal
788  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
789 
790  // int maxTS = -1;
791  float max_fC = 0;
792  float ta = 0;
793  m_coder = cond.getHcalCoder(detid);
794  m_ped = cond.getPedestal(detid);
795  m_shape = cond.getHcalShape(m_coder);
796  //cout << "New Digi!!!!!!!!!!!!!!!!!!!!!!" << endl;
797  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
798  int capid = ledDigi[TS].capid();
799  // BE CAREFUL: this is assuming peds are stored in ADCs
800  int adc = (int)(ledDigi[TS].adc() - m_ped->getValue(capid));
801  if (adc < 0){ adc = 0; } // to prevent negative adcs after ped subtraction, which should really only happen
802  // if you're using the wrong peds.
803  double fC = m_coder->charge(*m_shape,adc,capid);
804  //ta = (fC - m_ped->getValue(capid));
805  ta = fC;
806  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " Ped: " << m_ped->getValue(capid) << " fC: " << fC << endl;
807  _mei[TS].first->Fill(ta);
808  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
809  if(m_fitflag>1){
810  if(TS==m_startTS)_mei[11].first->Reset();
811  _mei[11].first->SetBinContent(TS+1,ta);
812  }
813 
814  // keep track of max TS and max amplitude (in fC)
815  if (ta > max_fC){
816  max_fC = ta;
817  // maxTS = TS;
818  }
819  }
820 
821  // Now we have a sample with pedestals subtracted and in units of fC
822  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
823  // we now want to use Phil's timing correction. This is not necessary
824  // if we are performing a Landau fit (m_fitflag = 3)
825 
826  float sum=0.;
827  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
828  if(sum>100){
829  if(m_fitflag==2 || m_fitflag==4){
830  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
831  float timmeancorr=BinsizeCorr(timmean);
832  _mei[12].first->Fill(timmeancorr);
833  }
834  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
835  if(m_fitflag==3 || m_fitflag==4){
836  _mei[11].first->Fit("landau","Q");
837  TF1 *fit = _mei[11].first->GetFunction("landau");
838  _mei[13].first->Fill(fit->GetParameter(1));
839  _mei[14].first->Fill(fit->GetParError(1));
840  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
841  }
842  }
843 
844 
845 
846 }
847 
848 
849 //-----------------------------------------------------------------------------
851 
852 // this is the bin size correction to be applied for laser data (from Andy),
853 // it comes from a pulse shape measured from TB04 data (from Jordan)
854 // This should eventually be replaced with the more thorough treatment from Phil
855 
856  float corrtime=0.;
857  static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
858  0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
859  0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
860  0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
861  static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
862  0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
863  0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
864  0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
865  0.95072, 0.9726};
866 
867  int inttime=(int)time;
868  float restime=time-inttime;
869  for(int i=0; i<=32; i++) {
870  float lolim=0.; float uplim=1.; float tsdown; float tsup;
871  if(i>0){
872  lolim=tsreco[i-1];
873  tsdown=tstrue[i-1];
874  }
875  else tsdown=tstrue[31]-1.;
876  if(i<32){
877  uplim=tsreco[i];
878  tsup=tstrue[i];
879  }
880  else tsup=tstrue[0]+1.;
881  if(restime>=lolim && restime<uplim){
882  corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
883  }
884  }
885  corrtime+=inttime;
886 
887  return corrtime;
888 }
889 //-----------------------------------------------------------------------------
890 
891 // Will try to implement Phil's time slew correction here at some point
892 
893 
894 //-----------------------------------------------------------------------------
895 void HcalLedAnalysis::ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame& digi){
896 
897  _meca = calibHists.find(calibId);
898  if (_meca==calibHists.end()){
899  // if histos for this channel do not exist, first create them
900  char name[1024];
903  std::string sector=(calibId.hcalSubdet()==HcalBarrel)?("HB"):
904  (calibId.hcalSubdet()==HcalEndcap)?("HE"):
905  (calibId.hcalSubdet()==HcalOuter)?("HO"):
906  (calibId.hcalSubdet()==HcalForward)?("HF"):"";
907  snprintf(name, sizeof name, "%s %+d iphi=%d %s", sector.c_str(), calibId.ieta(), calibId.iphi(), calibId.cboxChannelString().c_str());
908  prefix=name;
909  }
910 
911  snprintf(name, sizeof name, "%s Pin Diode Mean", prefix.c_str());
912  calibHists[calibId].avePulse = new TProfile(name,name,10,-0.5,9.5,0,1000);
913  snprintf(name, sizeof name, "%s Pin Diode Current Pulse", prefix.c_str());
914  calibHists[calibId].thisPulse = new TH1F(name,name,10,-0.5,9.5);
915  snprintf(name, sizeof name, "%s Pin Diode Integrated Pulse", prefix.c_str());
916  calibHists[calibId].integPulse = new TH1F(name,name,200,0,500);
917  }
918  else {
919  for (int i=m_startTS; i<digi.size() && i<=m_endTS; i++) {
920  calibHists[calibId].avePulse->Fill(i,digi.sample(i).adc());
921  calibHists[calibId].thisPulse->SetBinContent(i+1,digi.sample(i).adc());
922  }
923  calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
924  }
925 }
926 
int adc(sample_type sample)
get the ADC sample (12 bits)
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
void LedHBHEHists(const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:142
CalibDetType calibFlavor() const
get the flavor of this calibration detid
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:145
void LedSetup(const std::string &m_outputFileROOT)
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:31
void processLedEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection &calib, const HcalDbService &cond)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
HcalDetId const & id() const
Definition: HODataFrame.h:27
std::vector< HcalCalibDataFrame >::const_iterator const_iterator
~HcalLedAnalysis()
Destructor.
int ieta() const
get the rbx name (if relevant)
HcalLedAnalysis(const edm::ParameterSet &ps)
Constructor.
const HcalElectronicsId & elecId() const
int size() const
total number of samples in the digi
int depth() const
get the tower depth
Definition: HcalDetId.h:162
std::string cboxChannelString() const
get the calibration box channel as a string (if relevant)
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
HcalDetId const & id() const
Definition: HFDataFrame.h:26
T sqrt(T t)
Definition: SSEVec.h:18
int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
const HcalQIESample & sample(int i) const
access a sample
int size() const
total number of samples in the digi
Definition: HODataFrame.h:31
const HcalCalibDetId & id() const
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:59
int k[5][pyjets_maxn]
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:150
int iphi() const
get the low-edge iphi (if relevant)
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
float BinsizeCorr(float time)
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:30
void LedHFHists(const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
Definition: plugin.cc:24
size_type size() const
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
const HcalDetId & id() const
Definition: HBHEDataFrame.h:27
void LedHOHists(const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
Readout chain identification for Hcal.
const_iterator begin() const