19 for(
int k=0;
k<4;
k++)
state.push_back(
true);
22 if ( m_outputFileText.size() != 0 ) {
23 cout <<
"Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
24 m_outFile.open(m_outputFileText.c_str());
27 if ( m_outputFileROOT.size() != 0 ) {
28 cout <<
"Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
32 if(m_nevtsample<1)m_nevtsample=9999999;
34 if(m_hiSaveflag<0)m_hiSaveflag=0;
35 if(m_hiSaveflag>0)m_hiSaveflag=1;
37 if(m_fitflag<0)m_fitflag=0;
38 if(m_fitflag>4)m_fitflag=4;
40 if(m_startTS<0) m_startTS=0;
43 m_logFile.open(
"HcalLedAnalysis.log");
48 hbHists.ALLLEDS =
new TH1F(
"HBHE All LEDs",
"HB/HE All Leds",10,0,9);
49 hbHists.LEDRMS=
new TH1F(
"HBHE All LED RMS",
"HB/HE All LED RMS",100,0,3);
50 hbHists.LEDMEAN=
new TH1F(
"HBHE All LED Means",
"HB/HE All LED Means",100,0,9);
51 hbHists.CHI2=
new TH1F(
"HBHE Chi2 by ndf for Landau fit",
"HB/HE Chi2/ndf Landau",200,0.,50.);
53 hoHists.ALLLEDS =
new TH1F(
"HO All LEDs",
"HO All Leds",10,0,9);
54 hoHists.LEDRMS=
new TH1F(
"HO All LED RMS",
"HO All LED RMS",100,0,3);
55 hoHists.LEDMEAN=
new TH1F(
"HO All LED Means",
"HO All LED Means",100,0,9);
56 hoHists.CHI2=
new TH1F(
"HO Chi2 by ndf for Landau fit",
"HO Chi2/ndf Landau",200,0.,50.);
58 hfHists.ALLLEDS =
new TH1F(
"HF All LEDs",
"HF All Leds",10,0,9);
59 hfHists.LEDRMS=
new TH1F(
"HF All LED RMS",
"HF All LED RMS",100,0,3);
60 hfHists.LEDMEAN=
new TH1F(
"HF All LED Means",
"HF All LED Means",100,0,9);
61 hfHists.CHI2=
new TH1F(
"HF Chi2 by ndf for Landau fit",
"HF Chi2/ndf Landau",200,0.,50.);
64 m_outputFileXML.open(m_outputFileX.c_str());
65 sprintf(
output,
"<?xml version='1.0' encoding='UTF-8'?>");
66 m_outputFileXML <<
output << endl;
68 m_outputFileXML <<
output << endl << endl;
69 sprintf(
output,
" <HEADER>");
70 m_outputFileXML <<
output << endl;
71 sprintf(
output,
" <TYPE>");
72 m_outputFileXML <<
output << endl;
73 sprintf(
output,
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>");
74 m_outputFileXML <<
output << endl;
75 sprintf(
output,
" <NAME>HCAL LED Timing</NAME>");
76 m_outputFileXML <<
output << endl;
77 sprintf(
output,
" </TYPE>");
78 m_outputFileXML <<
output << endl;
80 m_outputFileXML <<
output << endl;
81 sprintf(
output,
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>");
82 m_outputFileXML <<
output << endl;
83 sprintf(
output,
" <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
84 m_outputFileXML <<
output << endl;
85 sprintf(
output,
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>");
86 m_outputFileXML <<
output << endl;
87 sprintf(
output,
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>");
88 m_outputFileXML <<
output << endl;
89 sprintf(
output,
" </RUN>");
90 m_outputFileXML <<
output << endl;
91 sprintf(
output,
" </HEADER>");
92 m_outputFileXML <<
output << endl;
93 sprintf(
output,
"<!-- Tags secton -->");
94 m_outputFileXML <<
output << endl;
95 sprintf(
output,
" <ELEMENTS>");
96 m_outputFileXML <<
output << endl;
97 sprintf(
output,
" <DATA_SET id='-1'/>");
98 m_outputFileXML <<
output << endl;
99 sprintf(
output,
" <IOV id='1'>");
100 m_outputFileXML <<
output << endl;
101 sprintf(
output,
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>");
102 m_outputFileXML <<
output << endl;
103 sprintf(
output,
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>");
104 m_outputFileXML <<
output << endl;
105 sprintf(
output,
" </IOV>");
106 m_outputFileXML <<
output << endl;
107 sprintf(
output,
" <TAG id='2' mode='auto'>");
108 m_outputFileXML <<
output << endl;
109 sprintf(
output,
" <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
110 m_outputFileXML <<
output << endl;
111 sprintf(
output,
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>");
112 m_outputFileXML <<
output << endl;
113 sprintf(
output,
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>");
114 m_outputFileXML <<
output << endl;
115 sprintf(
output,
" </TAG>");
116 m_outputFileXML <<
output << endl;
117 sprintf(
output,
" </ELEMENTS>");
118 m_outputFileXML <<
output << endl;
119 sprintf(
output,
" <MAPS>");
120 m_outputFileXML <<
output << endl;
121 sprintf(
output,
" <TAG idref ='2'>");
122 m_outputFileXML <<
output << endl;
123 sprintf(
output,
" <IOV idref='1'>");
124 m_outputFileXML <<
output << endl;
125 sprintf(
output,
" <DATA_SET idref='-1' />");
126 m_outputFileXML <<
output << endl;
127 sprintf(
output,
" </IOV>");
128 m_outputFileXML <<
output << endl;
129 sprintf(
output,
" </TAG>");
130 m_outputFileXML <<
output << endl;
131 sprintf(
output,
" </MAPS>");
132 m_outputFileXML <<
output << endl;
140 for(_meol=hbHists.LEDTRENDS.begin(); _meol!=hbHists.LEDTRENDS.end(); _meol++){
141 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
143 for(_meol=hoHists.LEDTRENDS.begin(); _meol!=hoHists.LEDTRENDS.end(); _meol++){
144 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
146 for(_meol=hfHists.LEDTRENDS.begin(); _meol!=hfHists.LEDTRENDS.end(); _meol++){
147 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
149 hbHists.ALLLEDS->Delete();
150 hbHists.LEDRMS->Delete();
151 hbHists.LEDMEAN->Delete();
152 hbHists.CHI2->Delete();
154 hoHists.ALLLEDS->Delete();
155 hoHists.LEDRMS->Delete();
156 hoHists.LEDMEAN->Delete();
157 hoHists.CHI2->Delete();
159 hfHists.ALLLEDS->Delete();
160 hfHists.LEDRMS->Delete();
161 hfHists.LEDMEAN->Delete();
162 hfHists.CHI2->Delete();
168 m_file=
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
169 m_file->mkdir(
"HBHE");
175 m_file->mkdir(
"Calib");
202 double time2=0;
double time1=0;
double time3=0;
double time4=0;
203 double dtime2=0;
double dtime1=0;
double dtime3=0;
double dtime4=0;
205 if (m_outputFileText!=
""){
206 if(m_fitflag==0 || m_fitflag==2) m_outFile<<
"Det Eta,Phi,D Mean Error"<<std::endl;
207 else if(m_fitflag==1 || m_fitflag==3) m_outFile<<
"Det Eta,Phi,D Peak Error"<<std::endl;
208 else if(m_fitflag==4) m_outFile<<
"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"<<std::endl;
210 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
212 _meol->second[10].first->Scale(1./evt_curr);
213 if(m_fitflag==0 || m_fitflag==4){
214 time1 = _meol->second[10].first->GetMean();
215 dtime1 = _meol->second[10].first->GetRMS()/
sqrt((
float)evt_curr*(m_endTS-m_startTS+1));
217 if(m_fitflag==1 || m_fitflag==4){
219 for(
int j=0;
j<10;
j++) _meol->second[10].first->SetBinError(
j+1,_meol->second[
j].first->GetRMS()/
sqrt((
float)evt_curr));
221 if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
222 _meol->second[10].first->Fit(
"landau",
"Q");
224 TF1 *fit = _meol->second[10].first->GetFunction(
"landau");
226 time2=fit->GetParameter(1);
227 dtime2=fit->GetParError(1);
229 if(m_fitflag==2 || m_fitflag==4){
230 time3 = _meol->second[12].first->GetMean();
231 dtime3 = _meol->second[12].first->GetRMS()/
sqrt((
float)_meol->second[12].first->GetEntries());
233 if(m_fitflag==3 || m_fitflag==4){
234 time4 = _meol->second[13].first->GetMean();
235 dtime4 = _meol->second[13].first->GetRMS()/
sqrt((
float)_meol->second[13].first->GetEntries());
237 for (
int i=0;
i<10;
i++){
238 _meol->second[
i].first->GetXaxis()->SetTitle(
"Pulse height (fC)");
239 _meol->second[
i].first->GetYaxis()->SetTitle(
"Counts");
242 _meol->second[10].first->GetXaxis()->SetTitle(
"Time slice");
243 _meol->second[10].first->GetYaxis()->SetTitle(
"Averaged pulse (fC)");
244 if(m_hiSaveflag>0)_meol->second[10].first->Write();
245 _meol->second[10].second.first[0].push_back(time1);
246 _meol->second[10].second.first[1].push_back(dtime1);
247 _meol->second[11].second.first[0].push_back(time2);
248 _meol->second[11].second.first[1].push_back(dtime2);
249 _meol->second[12].first->GetXaxis()->SetTitle(
"Mean TS");
250 _meol->second[12].first->GetYaxis()->SetTitle(
"Counts");
251 if(m_fitflag==2 && m_hiSaveflag>0)_meol->second[12].first->Write();
252 _meol->second[12].second.first[0].push_back(time3);
253 _meol->second[12].second.first[1].push_back(dtime3);
254 _meol->second[13].first->GetXaxis()->SetTitle(
"Peak TS");
255 _meol->second[13].first->GetYaxis()->SetTitle(
"Counts");
256 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[13].first->Write();
257 _meol->second[13].second.first[0].push_back(time4);
258 _meol->second[13].second.first[1].push_back(dtime4);
259 _meol->second[14].first->GetXaxis()->SetTitle(
"Peak TS error");
260 _meol->second[14].first->GetYaxis()->SetTitle(
"Counts");
261 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[14].first->Write();
262 _meol->second[15].first->GetXaxis()->SetTitle(
"Chi2/NDF");
263 _meol->second[15].first->GetYaxis()->SetTitle(
"Counts");
264 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[15].first->Write();
265 _meol->second[16].first->GetXaxis()->SetTitle(
"Integrated Signal");
266 _meol->second[16].first->Write();
272 if (m_outputFileText!=
""){
274 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<std::endl;
275 sprintf(
output,
" <DATA_SET>");
276 m_outputFileXML <<
output << endl;
277 sprintf(
output,
" <VERSION>version:1</VERSION>");
278 m_outputFileXML <<
output << endl;
279 sprintf(
output,
" <CHANNEL>");
280 m_outputFileXML <<
output << endl;
281 sprintf(
output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
282 m_outputFileXML <<
output << endl;
284 m_outputFileXML <<
output << endl;
285 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
286 m_outputFileXML <<
output << endl;
287 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
288 m_outputFileXML <<
output << endl;
290 m_outputFileXML <<
output << endl;
291 if(detid.
subdet() == 1) sprintf(
output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
292 if(detid.
subdet() == 2) sprintf(
output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
293 if(detid.
subdet() == 3) sprintf(
output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
294 if(detid.
subdet() == 4) sprintf(
output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
295 m_outputFileXML <<
output << endl;
296 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
297 m_outputFileXML <<
output << endl;
298 sprintf(
output,
" </CHANNEL>");
299 m_outputFileXML <<
output << endl;
300 sprintf(
output,
" <DATA>");
301 m_outputFileXML <<
output << endl;
302 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time1);
303 m_outputFileXML <<
output << endl;
304 sprintf(
output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
305 m_outputFileXML <<
output << endl;
306 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
307 m_outputFileXML <<
output << endl;
308 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
309 m_outputFileXML <<
output << endl;
310 sprintf(
output,
" <STATUS_WORD> 0</STATUS_WORD>");
311 m_outputFileXML <<
output << endl;
312 sprintf(
output,
" </DATA>");
313 m_outputFileXML <<
output << endl;
314 sprintf(
output,
" </DATA_SET>");
315 m_outputFileXML <<
output << endl;
318 else if(m_fitflag==1){
319 m_outFile<<detid<<
" "<<time2<<
" "<<dtime2<<std::endl;
320 sprintf(
output,
" <DATA_SET>");
321 m_outputFileXML <<
output << endl;
322 sprintf(
output,
" <VERSION>version:1</VERSION>");
323 m_outputFileXML <<
output << endl;
324 sprintf(
output,
" <CHANNEL>");
325 m_outputFileXML <<
output << endl;
326 sprintf(
output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
327 m_outputFileXML <<
output << endl;
329 m_outputFileXML <<
output << endl;
330 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
331 m_outputFileXML <<
output << endl;
332 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
333 m_outputFileXML <<
output << endl;
335 m_outputFileXML <<
output << endl;
336 if(detid.
subdet() == 1) sprintf(
output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
337 if(detid.
subdet() == 2) sprintf(
output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
338 if(detid.
subdet() == 3) sprintf(
output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
339 if(detid.
subdet() == 4) sprintf(
output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
340 m_outputFileXML <<
output << endl;
341 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
342 m_outputFileXML <<
output << endl;
343 sprintf(
output,
" </CHANNEL>");
344 m_outputFileXML <<
output << endl;
345 sprintf(
output,
" <DATA>");
346 m_outputFileXML <<
output << endl;
347 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time2);
348 m_outputFileXML <<
output << endl;
349 sprintf(
output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
350 m_outputFileXML <<
output << endl;
351 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
352 m_outputFileXML <<
output << endl;
353 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
354 m_outputFileXML <<
output << endl;
355 sprintf(
output,
" <STATUS_WORD> 0</STATUS_WORD>");
356 m_outputFileXML <<
output << endl;
357 sprintf(
output,
" </DATA>");
358 m_outputFileXML <<
output << endl;
359 sprintf(
output,
" </DATA_SET>");
360 m_outputFileXML <<
output << endl;
363 else if(m_fitflag==2){
364 m_outFile<<detid<<
" "<<time3<<
" "<<dtime3<<std::endl;
365 sprintf(
output,
" <DATA_SET>");
366 m_outputFileXML <<
output << endl;
367 sprintf(
output,
" <VERSION>version:1</VERSION>");
368 m_outputFileXML <<
output << endl;
369 sprintf(
output,
" <CHANNEL>");
370 m_outputFileXML <<
output << endl;
371 sprintf(
output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
372 m_outputFileXML <<
output << endl;
374 m_outputFileXML <<
output << endl;
375 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
376 m_outputFileXML <<
output << endl;
377 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
378 m_outputFileXML <<
output << endl;
380 m_outputFileXML <<
output << endl;
381 if(detid.
subdet() == 1) sprintf(
output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
382 if(detid.
subdet() == 2) sprintf(
output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
383 if(detid.
subdet() == 3) sprintf(
output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
384 if(detid.
subdet() == 4) sprintf(
output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
385 m_outputFileXML <<
output << endl;
386 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
387 m_outputFileXML <<
output << endl;
388 sprintf(
output,
" </CHANNEL>");
389 m_outputFileXML <<
output << endl;
390 sprintf(
output,
" <DATA>");
391 m_outputFileXML <<
output << endl;
392 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time3);
393 m_outputFileXML <<
output << endl;
394 sprintf(
output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
395 m_outputFileXML <<
output << endl;
396 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
397 m_outputFileXML <<
output << endl;
398 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
399 m_outputFileXML <<
output << endl;
400 sprintf(
output,
" <STATUS_WORD> 0</STATUS_WORD>");
401 m_outputFileXML <<
output << endl;
402 sprintf(
output,
" </DATA>");
403 m_outputFileXML <<
output << endl;
404 sprintf(
output,
" </DATA_SET>");
405 m_outputFileXML <<
output << endl;
407 else if(m_fitflag==3){
408 m_outFile<<detid<<
" "<<time4<<
" "<<dtime4<<std::endl;
409 sprintf(
output,
" <DATA_SET>");
410 m_outputFileXML <<
output << endl;
411 sprintf(
output,
" <VERSION>version:1</VERSION>");
412 m_outputFileXML <<
output << endl;
413 sprintf(
output,
" <CHANNEL>");
414 m_outputFileXML <<
output << endl;
415 sprintf(
output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
416 m_outputFileXML <<
output << endl;
418 m_outputFileXML <<
output << endl;
419 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
420 m_outputFileXML <<
output << endl;
421 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
422 m_outputFileXML <<
output << endl;
424 m_outputFileXML <<
output << endl;
425 if(detid.
subdet() == 1) sprintf(
output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
426 if(detid.
subdet() == 2) sprintf(
output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
427 if(detid.
subdet() == 3) sprintf(
output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
428 if(detid.
subdet() == 4) sprintf(
output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
429 m_outputFileXML <<
output << endl;
430 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
431 m_outputFileXML <<
output << endl;
432 sprintf(
output,
" </CHANNEL>");
433 m_outputFileXML <<
output << endl;
434 sprintf(
output,
" <DATA>");
435 m_outputFileXML <<
output << endl;
436 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time4);
437 m_outputFileXML <<
output << endl;
438 sprintf(
output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
439 m_outputFileXML <<
output << endl;
440 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
441 m_outputFileXML <<
output << endl;
442 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
443 m_outputFileXML <<
output << endl;
444 sprintf(
output,
" <STATUS_WORD> 0</STATUS_WORD>");
445 m_outputFileXML <<
output << endl;
446 sprintf(
output,
" </DATA>");
447 m_outputFileXML <<
output << endl;
448 sprintf(
output,
" </DATA_SET>");
449 m_outputFileXML <<
output << endl;
452 else if(m_fitflag==4){
453 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<
" "<<time2<<
" "<<dtime2<<
" "<<time3<<
" "<<dtime3<<
" "<<time4<<
" "<<dtime4<<std::endl;
462 char LedSampleNum[20];
464 sprintf(LedSampleNum,
"LedSample_%d",sample);
466 m_file->mkdir(LedSampleNum);
467 m_file->cd(LedSampleNum);
470 GetLedConst(hbHists.LEDTRENDS);
471 GetLedConst(hoHists.LEDTRENDS);
472 GetLedConst(hfHists.LEDTRENDS);
479 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
482 sprintf(name,
"LED timing trend, eta=%d phi=%d depth=%d",detid.
ieta(),detid.
iphi(),detid.
depth());
483 int bins = _meol->second[10+m_fitflag].second.first[0].size();
485 float hi = (float)bins+0.5;
486 _meol->second[10+m_fitflag].second.second.push_back(
new TH1F(name,name,bins,lo,hi));
488 std::vector<double>::iterator sample_it;
491 for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
492 sample_it!=_meol->second[10+m_fitflag].second.first[0].end();sample_it++){
493 _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
496 for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
497 sample_it!=_meol->second[10+m_fitflag].second.first[1].end();sample_it++){
498 _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
500 sprintf(name,
"Sample (%d events)",m_nevtsample);
501 _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
502 _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle(
"Peak position");
503 _meol->second[10+m_fitflag].second.second[0]->Write();
512 if(evt%m_nevtsample!=0) LedSampleAnalysis();
515 if(sample>1 && m_fitflag!=4){
518 LedTrendings(hbHists.LEDTRENDS);
521 LedTrendings(hoHists.LEDTRENDS);
524 LedTrendings(hfHists.LEDTRENDS);
531 hbHists.ALLLEDS->Write();
532 hbHists.LEDRMS->Write();
533 hbHists.LEDMEAN->Write();
537 hoHists.ALLLEDS->Write();
538 hoHists.LEDRMS->Write();
539 hoHists.LEDMEAN->Write();
543 hfHists.ALLLEDS->Write();
544 hfHists.LEDRMS->Write();
545 hfHists.LEDMEAN->Write();
549 for(_meca=calibHists.begin(); _meca!=calibHists.end(); _meca++){
550 _meca->second.avePulse->Write();
551 _meca->second.integPulse->Write();
557 cout <<
"Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
568 sample = (evt-1)/m_nevtsample +1;
569 evt_curr = evt%m_nevtsample;
570 if(evt_curr==0)evt_curr=m_nevtsample;
576 if(!calib.
size())
throw (
int)calib.
size();
582 ProcessCalibEvent(elecId.
fiberChanId(),calibId,digi);
593 if(!hbhe.
size())
throw (
int)hbhe.
size();
599 _meol = hbHists.LEDTRENDS.find(digi.
id());
600 if (_meol==hbHists.LEDTRENDS.end()){
601 SetupLEDHists(0,digi.
id(),hbHists.LEDTRENDS);
603 LedHBHEHists(digi.
id(),digi,hbHists.LEDTRENDS,cond);
612 if(!ho.
size())
throw (
int)ho.
size();
615 _meol = hoHists.LEDTRENDS.find(digi.
id());
616 if (_meol==hoHists.LEDTRENDS.end()){
617 SetupLEDHists(1,digi.
id(),hoHists.LEDTRENDS);
619 LedHOHists(digi.
id(),digi,hoHists.LEDTRENDS,cond);
628 if(!hf.
size())
throw (
int)hf.
size();
631 _meol = hfHists.LEDTRENDS.find(digi.
id());
632 if (_meol==hfHists.LEDTRENDS.end()){
633 SetupLEDHists(2,digi.
id(),hfHists.LEDTRENDS);
635 LedHFHists(digi.
id(),digi,hfHists.LEDTRENDS,cond);
643 if(evt%m_nevtsample==0) LedSampleAnalysis();
649 string type =
"HBHE";
650 if(
id==1) type =
"HO";
651 if(
id==2) type =
"HF";
653 _meol = toolT.find(detid);
654 if (_meol==toolT.end()){
658 for(
int i=0;
i<10;
i++){
659 sprintf(name,
"%s Pulse height, eta=%d phi=%d depth=%d TS=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth(),
i);
660 insert[
i].first =
new TH1F(name,name,200,0.,2000.);
662 sprintf(name,
"%s LED Mean pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
663 insert[10].first =
new TH1F(name,name,10,-0.5,9.5);
664 sprintf(name,
"%s LED Pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
665 insert[11].first =
new TH1F(name,name,10,-0.5,9.5);
666 sprintf(name,
"%s Mean TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
667 insert[12].first =
new TH1F(name,name,200,0.,10.);
668 sprintf(name,
"%s Peak TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
669 insert[13].first =
new TH1F(name,name,200,0.,10.);
670 sprintf(name,
"%s Peak TS error, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
671 insert[14].first =
new TH1F(name,name,200,0.,0.05);
672 sprintf(name,
"%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
673 insert[15].first =
new TH1F(name,name,100,0.,50.);
674 sprintf(name,
"%s Integrated Signal, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
675 insert[16].first =
new TH1F(name,name,500,0.,5000.);
683 map<int,LEDBUNCH> _mei;
684 _meol = toolT.find(detid);
685 _mei = _meol->second;
688 if((evt-1)%m_nevtsample==0 &&
state[0]){
690 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
702 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
703 int capid = ledDigi[TS].capid();
704 int adc = ledDigi[TS].adc();
705 double fC = m_coder->charge(*m_shape,adc,capid);
706 ta = (fC - m_ped->getValue(capid));
708 _mei[TS].first->Fill(ta);
709 _mei[10].first->AddBinContent(TS+1,ta);
711 if(TS==m_startTS)_mei[11].first->Reset();
712 _mei[11].first->SetBinContent(TS+1,ta);
727 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
729 if(m_fitflag==2 || m_fitflag==4){
730 float timmean=_mei[11].first->GetMean();
731 float timmeancorr=BinsizeCorr(timmean);
732 _mei[12].first->Fill(timmeancorr);
734 _mei[16].first->Fill(_mei[11].
first->Integral());
735 if(m_fitflag==3 || m_fitflag==4){
736 _mei[11].first->Fit(
"landau",
"Q");
737 TF1 *fit = _mei[11].first->GetFunction(
"landau");
738 _mei[13].first->Fill(fit->GetParameter(1));
739 _mei[14].first->Fill(fit->GetParError(1));
740 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
749 map<int,LEDBUNCH> _mei;
750 _meol = toolT.find(detid);
751 _mei = _meol->second;
753 if((evt-1)%m_nevtsample==0 &&
state[0]){
755 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
767 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
768 int capid = ledDigi[TS].capid();
769 int adc = ledDigi[TS].adc();
770 double fC = m_coder->charge(*m_shape,adc,capid);
771 ta = (fC - m_ped->getValue(capid));
772 _mei[TS].first->Fill(ta);
773 _mei[10].first->AddBinContent(TS+1,ta);
775 if(TS==m_startTS)_mei[11].first->Reset();
776 _mei[11].first->SetBinContent(TS+1,ta);
791 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
793 if(m_fitflag==2 || m_fitflag==4){
794 float timmean=_mei[11].first->GetMean();
795 float timmeancorr=BinsizeCorr(timmean);
796 _mei[12].first->Fill(timmeancorr);
798 _mei[16].first->Fill(_mei[11].
first->Integral());
799 if(m_fitflag==3 || m_fitflag==4){
800 _mei[11].first->Fit(
"landau",
"Q");
801 TF1 *fit = _mei[11].first->GetFunction(
"landau");
802 _mei[13].first->Fill(fit->GetParameter(1));
803 _mei[14].first->Fill(fit->GetParError(1));
804 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
813 map<int,LEDBUNCH> _mei;
814 _meol = toolT.find(detid);
815 _mei = _meol->second;
817 if((evt-1)%m_nevtsample==0 &&
state[0]){
819 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
832 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
833 int capid = ledDigi[TS].capid();
835 int adc = (int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
836 if (adc < 0){ adc = 0; }
838 double fC = m_coder->charge(*m_shape,adc,capid);
842 _mei[TS].first->Fill(ta);
843 _mei[10].first->AddBinContent(TS+1,ta);
845 if(TS==m_startTS)_mei[11].first->Reset();
846 _mei[11].first->SetBinContent(TS+1,ta);
862 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
864 if(m_fitflag==2 || m_fitflag==4){
865 float timmean=_mei[11].first->GetMean();
866 float timmeancorr=BinsizeCorr(timmean);
867 _mei[12].first->Fill(timmeancorr);
869 _mei[16].first->Fill(_mei[11].
first->Integral());
870 if(m_fitflag==3 || m_fitflag==4){
871 _mei[11].first->Fit(
"landau",
"Q");
872 TF1 *fit = _mei[11].first->GetFunction(
"landau");
873 _mei[13].first->Fill(fit->GetParameter(1));
874 _mei[14].first->Fill(fit->GetParError(1));
875 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
892 static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
893 0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
894 0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
895 0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
896 static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
897 0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
898 0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
899 0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
902 int inttime=(int)time;
903 float restime=time-inttime;
904 for(
int i=0;
i<=32;
i++) {
905 float lolim=0.;
float uplim=1.;
float tsdown;
float tsup;
910 else tsdown=tstrue[31]-1.;
915 else tsup=tstrue[0]+1.;
916 if(restime>=lolim && restime<uplim){
917 corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
932 _meca = calibHists.find(calibId);
933 if (_meca==calibHists.end()){
946 sprintf(name,
"%s Pin Diode Mean",prefix.c_str());
947 calibHists[calibId].avePulse =
new TProfile(name,name,10,-0.5,9.5,0,1000);
948 sprintf(name,
"%s Pin Diode Current Pulse",prefix.c_str());
949 calibHists[calibId].thisPulse =
new TH1F(name,name,10,-0.5,9.5);
950 sprintf(name,
"%s Pin Diode Integrated Pulse",prefix.c_str());
951 calibHists[calibId].integPulse =
new TH1F(name,name,200,0,500);
954 for (
int i=m_startTS;
i<digi.
size() &&
i<=m_endTS;
i++) {
955 calibHists[calibId].avePulse->Fill(
i,digi.
sample(
i).
adc());
956 calibHists[calibId].thisPulse->SetBinContent(
i+1,digi.
sample(
i).
adc());
958 calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
int adc(sample_type sample)
get the ADC sample (12 bits)
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
CalibDetType calibFlavor() const
get the flavor of this calibration detid
int zside() const
get the z-side of the cell (1/-1)
void LedSetup(const std::string &m_outputFileROOT)
int adc() const
get the ADC sample
int size() const
total number of samples in the digi
void processLedEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection calib, const HcalDbService &cond)
std::vector< T >::const_iterator const_iterator
~HcalLedAnalysis()
Destructor.
int ieta() const
get the rbx name (if relevant)
HcalLedAnalysis(const edm::ParameterSet &ps)
Constructor.
const HcalDetId & id() const
const HcalElectronicsId & elecId() const
uint32_t rawId() const
get the raw id
int size() const
total number of samples in the digi
int depth() const
get the tower depth
MVATrainerComputer * calib
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)
int ieta() const
get the cell ieta
const HcalQIESample & sample(int i) const
access a sample
int size() const
total number of samples in the digi
const HcalCalibDetId & id() const
int fiberChanId() const
get the fiber channel id (which of three channels on a readout fiber) (valid only for non-trigger-cha...
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame digi)
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the low-edge iphi (if relevant)
const_iterator end() const
int iphi() const
get the cell iphi
float BinsizeCorr(float time)
int size() const
total number of samples in the digi
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
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
const HcalDetId & id() const
void LedHOHists(const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
const HcalDetId & id() const
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
bool insert(Storage &, ItemType *, const IdTag &)
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const HcalQIEShape * getHcalShape() const
const_iterator begin() const