23 for(
int k=0;
k<4;
k++) state.push_back(
true);
26 if ( m_outputFileText.size() != 0 ) {
27 cout <<
"Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
28 m_outFile.open(m_outputFileText.c_str());
31 if ( m_outputFileROOT.size() != 0 ) {
32 cout <<
"Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
36 if(m_nevtsample<1)m_nevtsample=9999999;
38 if(m_hiSaveflag<0)m_hiSaveflag=0;
39 if(m_hiSaveflag>0)m_hiSaveflag=1;
41 if(m_fitflag<0)m_fitflag=0;
42 if(m_fitflag>4)m_fitflag=4;
44 if(m_startTS<0) m_startTS=0;
47 m_logFile.open(
"HcalLedAnalysis.log");
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.);
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.);
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.);
69 m_outputFileXML.open(m_outputFileX.c_str());
71 m_outputFileXML <<
"<?xml version='1.0' encoding='UTF-8'?>" << endl;
73 m_outputFileXML <<
"<ROOT>" << endl;
75 m_outputFileXML <<
" <HEADER>" << endl;
77 m_outputFileXML <<
" <TYPE>" << endl;
79 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
81 m_outputFileXML <<
" <NAME>HCAL LED Timing</NAME>" << endl;
83 m_outputFileXML <<
" </TYPE>" << endl;
85 m_outputFileXML <<
" <RUN>" << endl;
87 m_outputFileXML <<
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
89 sprintf(
output,
" <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
90 m_outputFileXML <<
output << endl;
92 m_outputFileXML <<
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
94 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
96 m_outputFileXML <<
" </RUN>" << endl;
98 m_outputFileXML <<
" </HEADER>" << endl;
100 m_outputFileXML <<
"<!-- Tags secton -->" << endl;
102 m_outputFileXML <<
" <ELEMENTS>" << endl;
104 m_outputFileXML <<
" <DATA_SET id='-1'/>" << endl;
106 m_outputFileXML <<
" <IOV id='1'>" << endl;
108 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
110 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
112 m_outputFileXML <<
" </IOV>" << endl;
114 m_outputFileXML <<
" <TAG id='2' mode='auto'>" << endl;
116 sprintf(
output,
" <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
117 m_outputFileXML <<
output << endl;
119 m_outputFileXML <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
121 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
123 m_outputFileXML <<
" </TAG>" << endl;
125 m_outputFileXML <<
" </ELEMENTS>" << endl;
127 m_outputFileXML <<
" <MAPS>" << endl;
129 m_outputFileXML <<
" <TAG idref ='2'>" << endl;
131 m_outputFileXML <<
" <IOV idref='1'>" << endl;
133 m_outputFileXML <<
" <DATA_SET idref='-1' />" << endl;
135 m_outputFileXML <<
" </IOV>" << endl;
137 m_outputFileXML <<
" </TAG>" << endl;
139 m_outputFileXML <<
" </MAPS>" << endl;
146 for(_meol=hbHists.LEDTRENDS.begin(); _meol!=hbHists.LEDTRENDS.end(); _meol++){
147 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
149 for(_meol=hoHists.LEDTRENDS.begin(); _meol!=hoHists.LEDTRENDS.end(); _meol++){
150 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
152 for(_meol=hfHists.LEDTRENDS.begin(); _meol!=hfHists.LEDTRENDS.end(); _meol++){
153 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
155 hbHists.ALLLEDS->Delete();
156 hbHists.LEDRMS->Delete();
157 hbHists.LEDMEAN->Delete();
158 hbHists.CHI2->Delete();
160 hoHists.ALLLEDS->Delete();
161 hoHists.LEDRMS->Delete();
162 hoHists.LEDMEAN->Delete();
163 hoHists.CHI2->Delete();
165 hfHists.ALLLEDS->Delete();
166 hfHists.LEDRMS->Delete();
167 hfHists.LEDMEAN->Delete();
168 hfHists.CHI2->Delete();
174 m_file=
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
175 m_file->mkdir(
"HBHE");
181 m_file->mkdir(
"Calib");
208 double time2=0;
double time1=0;
double time3=0;
double time4=0;
209 double dtime2=0;
double dtime1=0;
double dtime3=0;
double dtime4=0;
211 if (m_outputFileText!=
""){
212 if(m_fitflag==0 || m_fitflag==2) m_outFile<<
"Det Eta,Phi,D Mean Error"<<std::endl;
213 else if(m_fitflag==1 || m_fitflag==3) m_outFile<<
"Det Eta,Phi,D Peak Error"<<std::endl;
214 else if(m_fitflag==4) m_outFile<<
"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"<<std::endl;
216 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
218 _meol->second[10].first->Scale(1./evt_curr);
219 if(m_fitflag==0 || m_fitflag==4){
220 time1 = _meol->second[10].first->GetMean();
221 dtime1 = _meol->second[10].first->GetRMS()/
sqrt((
float)evt_curr*(m_endTS-m_startTS+1));
223 if(m_fitflag==1 || m_fitflag==4){
225 for(
int j=0; j<10; j++) _meol->second[10].first->SetBinError(j+1,_meol->second[j].first->GetRMS()/
sqrt((
float)evt_curr));
227 if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
228 _meol->second[10].first->Fit(
"landau",
"Q");
230 TF1 *
fit = _meol->second[10].first->GetFunction(
"landau");
232 time2=fit->GetParameter(1);
233 dtime2=fit->GetParError(1);
235 if(m_fitflag==2 || m_fitflag==4){
236 time3 = _meol->second[12].first->GetMean();
237 dtime3 = _meol->second[12].first->GetRMS()/
sqrt((
float)_meol->second[12].first->GetEntries());
239 if(m_fitflag==3 || m_fitflag==4){
240 time4 = _meol->second[13].first->GetMean();
241 dtime4 = _meol->second[13].first->GetRMS()/
sqrt((
float)_meol->second[13].first->GetEntries());
243 for (
int i=0;
i<10;
i++){
244 _meol->second[
i].first->GetXaxis()->SetTitle(
"Pulse height (fC)");
245 _meol->second[
i].first->GetYaxis()->SetTitle(
"Counts");
248 _meol->second[10].first->GetXaxis()->SetTitle(
"Time slice");
249 _meol->second[10].first->GetYaxis()->SetTitle(
"Averaged pulse (fC)");
250 if(m_hiSaveflag>0)_meol->second[10].first->Write();
251 _meol->second[10].second.first[0].push_back(time1);
252 _meol->second[10].second.first[1].push_back(dtime1);
253 _meol->second[11].second.first[0].push_back(time2);
254 _meol->second[11].second.first[1].push_back(dtime2);
255 _meol->second[12].first->GetXaxis()->SetTitle(
"Mean TS");
256 _meol->second[12].first->GetYaxis()->SetTitle(
"Counts");
257 if(m_fitflag==2 && m_hiSaveflag>0)_meol->second[12].first->Write();
258 _meol->second[12].second.first[0].push_back(time3);
259 _meol->second[12].second.first[1].push_back(dtime3);
260 _meol->second[13].first->GetXaxis()->SetTitle(
"Peak TS");
261 _meol->second[13].first->GetYaxis()->SetTitle(
"Counts");
262 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[13].first->Write();
263 _meol->second[13].second.first[0].push_back(time4);
264 _meol->second[13].second.first[1].push_back(dtime4);
265 _meol->second[14].first->GetXaxis()->SetTitle(
"Peak TS error");
266 _meol->second[14].first->GetYaxis()->SetTitle(
"Counts");
267 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[14].first->Write();
268 _meol->second[15].first->GetXaxis()->SetTitle(
"Chi2/NDF");
269 _meol->second[15].first->GetYaxis()->SetTitle(
"Counts");
270 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[15].first->Write();
271 _meol->second[16].first->GetXaxis()->SetTitle(
"Integrated Signal");
272 _meol->second[16].first->Write();
278 if (m_outputFileText!=
""){
280 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<std::endl;
281 m_outputFileXML <<
" <DATA_SET>" << endl;
282 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
283 m_outputFileXML <<
" <CHANNEL>" << endl;
284 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
286 m_outputFileXML <<
output << endl;
287 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
288 m_outputFileXML <<
output << endl;
289 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
290 m_outputFileXML <<
output << endl;
292 m_outputFileXML <<
output << endl;
294 if(detid.
subdet() == 1) m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
295 if(detid.
subdet() == 2) m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
296 if(detid.
subdet() == 3) m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
297 if(detid.
subdet() == 4) m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
298 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
299 m_outputFileXML <<
output << endl;
300 m_outputFileXML <<
" </CHANNEL>" << endl;
301 m_outputFileXML <<
" <DATA>" << endl;
302 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time1);
303 m_outputFileXML <<
output << endl;
304 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
305 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
306 m_outputFileXML <<
output << endl;
307 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
308 m_outputFileXML <<
output << endl;
309 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
310 m_outputFileXML <<
" </DATA>" << endl;
311 m_outputFileXML <<
" </DATA_SET>" << endl;
314 else if(m_fitflag==1){
315 m_outFile<<detid<<
" "<<time2<<
" "<<dtime2<<std::endl;
316 m_outputFileXML <<
" <DATA_SET>" << endl;
317 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
318 m_outputFileXML <<
" <CHANNEL>" << endl;
319 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
321 m_outputFileXML <<
output << endl;
322 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
323 m_outputFileXML <<
output << endl;
324 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
325 m_outputFileXML <<
output << endl;
327 m_outputFileXML <<
output << endl;
328 if(detid.
subdet() == 1) m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>"<< endl;
329 if(detid.
subdet() == 2) m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>"<< endl;
330 if(detid.
subdet() == 3) m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>"<< endl;
331 if(detid.
subdet() == 4) m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>"<< endl;
332 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
333 m_outputFileXML <<
output << endl;
334 m_outputFileXML <<
" </CHANNEL>" << endl;
335 m_outputFileXML <<
" <DATA>" << endl;
336 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time2);
337 m_outputFileXML <<
output << endl;
338 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
339 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
340 m_outputFileXML <<
output << endl;
341 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
342 m_outputFileXML <<
output << endl;
343 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
344 m_outputFileXML <<
" </DATA>" << endl;
345 m_outputFileXML <<
" </DATA_SET>" << endl;
348 else if(m_fitflag==2){
349 m_outFile<<detid<<
" "<<time3<<
" "<<dtime3<<std::endl;
350 m_outputFileXML <<
" <DATA_SET>" << endl;
351 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
352 m_outputFileXML <<
" <CHANNEL>" << endl;
353 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
355 m_outputFileXML <<
output << endl;
356 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
357 m_outputFileXML <<
output << endl;
358 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
359 m_outputFileXML <<
output << endl;
361 m_outputFileXML <<
output << endl;
362 if(detid.
subdet() == 1) m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
363 if(detid.
subdet() == 2) m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
364 if(detid.
subdet() == 3) m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
365 if(detid.
subdet() == 4) m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
366 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
367 m_outputFileXML <<
output << endl;
368 m_outputFileXML <<
" </CHANNEL>" << endl;
369 m_outputFileXML <<
" <DATA>" << endl;
370 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time3);
371 m_outputFileXML <<
output << endl;
372 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
373 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
374 m_outputFileXML <<
output << endl;
375 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
376 m_outputFileXML <<
output << endl;
377 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
378 m_outputFileXML <<
" </DATA>" << endl;
379 m_outputFileXML <<
" </DATA_SET>" << endl;
381 else if(m_fitflag==3){
382 m_outFile<<detid<<
" "<<time4<<
" "<<dtime4<<std::endl;
383 m_outputFileXML <<
" <DATA_SET>" << endl;
384 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
385 m_outputFileXML <<
" <CHANNEL>" << endl;
386 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
388 m_outputFileXML <<
output << endl;
389 sprintf(
output,
" <PHI>%2i</PHI>", detid.
iphi() );
390 m_outputFileXML <<
output << endl;
391 sprintf(
output,
" <DEPTH>%2i</DEPTH>", detid.
depth() );
392 m_outputFileXML <<
output << endl;
394 m_outputFileXML <<
output << endl;
395 if(detid.
subdet() == 1) m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
396 if(detid.
subdet() == 2) m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
397 if(detid.
subdet() == 3) m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
398 if(detid.
subdet() == 4) m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
399 sprintf(
output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
400 m_outputFileXML <<
output << endl;
401 m_outputFileXML <<
" </CHANNEL>" << endl;
402 m_outputFileXML <<
" <DATA>" << endl;
403 sprintf(
output,
" <MEAN_TIME>%7f</MEAN_TIME>", time4);
404 m_outputFileXML <<
output << endl;
405 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
406 sprintf(
output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
407 m_outputFileXML <<
output << endl;
408 sprintf(
output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
409 m_outputFileXML <<
output << endl;
410 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
411 m_outputFileXML <<
" </DATA>" << endl;
412 m_outputFileXML <<
" </DATA_SET>" << endl;
415 else if(m_fitflag==4){
416 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<
" "<<time2<<
" "<<dtime2<<
" "<<time3<<
" "<<dtime3<<
" "<<time4<<
" "<<dtime4<<std::endl;
425 char LedSampleNum[20];
427 sprintf(LedSampleNum,
"LedSample_%d",
sample);
429 m_file->mkdir(LedSampleNum);
430 m_file->cd(LedSampleNum);
433 GetLedConst(hbHists.LEDTRENDS);
434 GetLedConst(hoHists.LEDTRENDS);
435 GetLedConst(hfHists.LEDTRENDS);
442 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
445 sprintf(name,
"LED timing trend, eta=%d phi=%d depth=%d",detid.
ieta(),detid.
iphi(),detid.
depth());
446 int bins = _meol->second[10+m_fitflag].second.first[0].size();
449 _meol->second[10+m_fitflag].second.second.push_back(
new TH1F(name,name,bins,lo,hi));
451 std::vector<double>::iterator sample_it;
454 for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
455 sample_it!=_meol->second[10+m_fitflag].second.first[0].end();++sample_it){
456 _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
459 for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
460 sample_it!=_meol->second[10+m_fitflag].second.first[1].end();++sample_it){
461 _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
463 sprintf(name,
"Sample (%d events)",m_nevtsample);
464 _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
465 _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle(
"Peak position");
466 _meol->second[10+m_fitflag].second.second[0]->Write();
475 if(evt%m_nevtsample!=0) LedSampleAnalysis();
478 if(
sample>1 && m_fitflag!=4){
481 LedTrendings(hbHists.LEDTRENDS);
484 LedTrendings(hoHists.LEDTRENDS);
487 LedTrendings(hfHists.LEDTRENDS);
494 hbHists.ALLLEDS->Write();
495 hbHists.LEDRMS->Write();
496 hbHists.LEDMEAN->Write();
500 hoHists.ALLLEDS->Write();
501 hoHists.LEDRMS->Write();
502 hoHists.LEDMEAN->Write();
506 hfHists.ALLLEDS->Write();
507 hfHists.LEDRMS->Write();
508 hfHists.LEDMEAN->Write();
512 for(_meca=calibHists.begin(); _meca!=calibHists.end(); _meca++){
513 _meca->second.avePulse->Write();
514 _meca->second.integPulse->Write();
520 cout <<
"Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
531 sample = (evt-1)/m_nevtsample +1;
532 evt_curr = evt%m_nevtsample;
533 if(evt_curr==0)evt_curr=m_nevtsample;
539 if(!calib.
size())
throw (
int)calib.
size();
545 ProcessCalibEvent(elecId.
fiberChanId(),calibId,digi);
556 if(!hbhe.
size())
throw (
int)hbhe.
size();
560 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
true;
562 _meol = hbHists.LEDTRENDS.find(digi.
id());
563 if (_meol==hbHists.LEDTRENDS.end()){
564 SetupLEDHists(0,digi.
id(),hbHists.LEDTRENDS);
566 LedHBHEHists(digi.
id(),digi,hbHists.LEDTRENDS,cond);
575 if(!ho.
size())
throw (
int)ho.
size();
578 _meol = hoHists.LEDTRENDS.find(digi.
id());
579 if (_meol==hoHists.LEDTRENDS.end()){
580 SetupLEDHists(1,digi.
id(),hoHists.LEDTRENDS);
582 LedHOHists(digi.
id(),digi,hoHists.LEDTRENDS,cond);
591 if(!hf.
size())
throw (
int)hf.
size();
594 _meol = hfHists.LEDTRENDS.find(digi.
id());
595 if (_meol==hfHists.LEDTRENDS.end()){
596 SetupLEDHists(2,digi.
id(),hfHists.LEDTRENDS);
598 LedHFHists(digi.
id(),digi,hfHists.LEDTRENDS,cond);
606 if(evt%m_nevtsample==0) LedSampleAnalysis();
612 string type =
"HBHE";
613 if(
id==1) type =
"HO";
614 if(
id==2) type =
"HF";
616 _meol = toolT.find(detid);
617 if (_meol==toolT.end()){
621 for(
int i=0;
i<10;
i++){
622 sprintf(name,
"%s Pulse height, eta=%d phi=%d depth=%d TS=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth(),
i);
623 insert[
i].first =
new TH1F(name,name,200,0.,2000.);
625 sprintf(name,
"%s LED Mean pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
626 insert[10].first =
new TH1F(name,name,10,-0.5,9.5);
627 sprintf(name,
"%s LED Pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
628 insert[11].first =
new TH1F(name,name,10,-0.5,9.5);
629 sprintf(name,
"%s Mean TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
630 insert[12].first =
new TH1F(name,name,200,0.,10.);
631 sprintf(name,
"%s Peak TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
632 insert[13].first =
new TH1F(name,name,200,0.,10.);
633 sprintf(name,
"%s Peak TS error, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
634 insert[14].first =
new TH1F(name,name,200,0.,0.05);
635 sprintf(name,
"%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
636 insert[15].first =
new TH1F(name,name,100,0.,50.);
637 sprintf(name,
"%s Integrated Signal, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
638 insert[16].first =
new TH1F(name,name,500,0.,5000.);
646 map<int,LEDBUNCH> _mei;
647 _meol = toolT.find(detid);
648 _mei = _meol->second;
651 if((evt-1)%m_nevtsample==0 && state[0]){
652 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
false;
653 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
665 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
666 int capid = ledDigi[TS].capid();
667 int adc = ledDigi[TS].adc();
668 double fC = m_coder->charge(*m_shape,adc,capid);
669 ta = (fC - m_ped->getValue(capid));
671 _mei[TS].first->Fill(ta);
672 _mei[10].first->AddBinContent(TS+1,ta);
674 if(TS==m_startTS)_mei[11].first->Reset();
675 _mei[11].first->SetBinContent(TS+1,ta);
690 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
692 if(m_fitflag==2 || m_fitflag==4){
693 float timmean=_mei[11].first->GetMean();
694 float timmeancorr=BinsizeCorr(timmean);
695 _mei[12].first->Fill(timmeancorr);
697 _mei[16].first->Fill(_mei[11].
first->Integral());
698 if(m_fitflag==3 || m_fitflag==4){
699 _mei[11].first->Fit(
"landau",
"Q");
700 TF1 *
fit = _mei[11].first->GetFunction(
"landau");
701 _mei[13].first->Fill(fit->GetParameter(1));
702 _mei[14].first->Fill(fit->GetParError(1));
703 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
712 map<int,LEDBUNCH> _mei;
713 _meol = toolT.find(detid);
714 _mei = _meol->second;
716 if((evt-1)%m_nevtsample==0 && state[0]){
717 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
false;
718 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
730 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
731 int capid = ledDigi[TS].capid();
732 int adc = ledDigi[TS].adc();
733 double fC = m_coder->charge(*m_shape,adc,capid);
734 ta = (fC - m_ped->getValue(capid));
735 _mei[TS].first->Fill(ta);
736 _mei[10].first->AddBinContent(TS+1,ta);
738 if(TS==m_startTS)_mei[11].first->Reset();
739 _mei[11].first->SetBinContent(TS+1,ta);
754 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
756 if(m_fitflag==2 || m_fitflag==4){
757 float timmean=_mei[11].first->GetMean();
758 float timmeancorr=BinsizeCorr(timmean);
759 _mei[12].first->Fill(timmeancorr);
761 _mei[16].first->Fill(_mei[11].
first->Integral());
762 if(m_fitflag==3 || m_fitflag==4){
763 _mei[11].first->Fit(
"landau",
"Q");
764 TF1 *
fit = _mei[11].first->GetFunction(
"landau");
765 _mei[13].first->Fill(fit->GetParameter(1));
766 _mei[14].first->Fill(fit->GetParError(1));
767 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
776 map<int,LEDBUNCH> _mei;
777 _meol = toolT.find(detid);
778 _mei = _meol->second;
780 if((evt-1)%m_nevtsample==0 && state[0]){
781 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
false;
782 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
795 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
796 int capid = ledDigi[TS].capid();
798 int adc = (
int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
799 if (adc < 0){ adc = 0; }
801 double fC = m_coder->charge(*m_shape,adc,capid);
805 _mei[TS].first->Fill(ta);
806 _mei[10].first->AddBinContent(TS+1,ta);
808 if(TS==m_startTS)_mei[11].first->Reset();
809 _mei[11].first->SetBinContent(TS+1,ta);
825 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
827 if(m_fitflag==2 || m_fitflag==4){
828 float timmean=_mei[11].first->GetMean();
829 float timmeancorr=BinsizeCorr(timmean);
830 _mei[12].first->Fill(timmeancorr);
832 _mei[16].first->Fill(_mei[11].
first->Integral());
833 if(m_fitflag==3 || m_fitflag==4){
834 _mei[11].first->Fit(
"landau",
"Q");
835 TF1 *
fit = _mei[11].first->GetFunction(
"landau");
836 _mei[13].first->Fill(fit->GetParameter(1));
837 _mei[14].first->Fill(fit->GetParError(1));
838 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
855 static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
856 0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
857 0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
858 0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
859 static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
860 0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
861 0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
862 0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
865 int inttime=(
int)time;
866 float restime=time-inttime;
867 for(
int i=0;
i<=32;
i++) {
868 float lolim=0.;
float uplim=1.;
float tsdown;
float tsup;
873 else tsdown=tstrue[31]-1.;
878 else tsup=tstrue[0]+1.;
879 if(restime>=lolim && restime<uplim){
880 corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
895 _meca = calibHists.find(calibId);
896 if (_meca==calibHists.end()){
909 sprintf(name,
"%s Pin Diode Mean",prefix.c_str());
910 calibHists[calibId].avePulse =
new TProfile(name,name,10,-0.5,9.5,0,1000);
911 sprintf(name,
"%s Pin Diode Current Pulse",prefix.c_str());
912 calibHists[calibId].thisPulse =
new TH1F(name,name,10,-0.5,9.5);
913 sprintf(name,
"%s Pin Diode Integrated Pulse",prefix.c_str());
914 calibHists[calibId].integPulse =
new TH1F(name,name,200,0,500);
917 for (
int i=m_startTS;
i<digi.
size() &&
i<=m_endTS;
i++) {
918 calibHists[calibId].avePulse->Fill(
i,digi.
sample(
i).
adc());
919 calibHists[calibId].thisPulse->SetBinContent(
i+1,digi.
sample(
i).
adc());
921 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< HcalCalibDataFrame >::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
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)
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
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
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
const HcalQIEShape * getHcalShape(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
Readout chain identification for Hcal.
const_iterator begin() const