23 for(
int k=0;
k<4;
k++) state.push_back(
true);
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());
31 if ( !m_outputFileROOT.empty() ) {
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.);
70 m_outputFileXML.open(m_outputFileX.c_str());
72 m_outputFileXML <<
"<?xml version='1.0' encoding='UTF-8'?>" << endl;
74 m_outputFileXML <<
"<ROOT>" << endl;
76 m_outputFileXML <<
" <HEADER>" << endl;
78 m_outputFileXML <<
" <TYPE>" << endl;
80 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
82 m_outputFileXML <<
" <NAME>HCAL LED Timing</NAME>" << endl;
84 m_outputFileXML <<
" </TYPE>" << endl;
86 m_outputFileXML <<
" <RUN>" << endl;
88 m_outputFileXML <<
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
90 snprintf(
output,
sizeof output,
" <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
91 m_outputFileXML <<
output << endl;
93 m_outputFileXML <<
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
95 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
97 m_outputFileXML <<
" </RUN>" << endl;
99 m_outputFileXML <<
" </HEADER>" << endl;
101 m_outputFileXML <<
"<!-- Tags secton -->" << endl;
103 m_outputFileXML <<
" <ELEMENTS>" << endl;
105 m_outputFileXML <<
" <DATA_SET id='-1'/>" << endl;
107 m_outputFileXML <<
" <IOV id='1'>" << endl;
109 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
111 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
113 m_outputFileXML <<
" </IOV>" << endl;
115 m_outputFileXML <<
" <TAG id='2' mode='auto'>" << endl;
117 snprintf(
output,
sizeof output,
" <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
118 m_outputFileXML <<
output << endl;
120 m_outputFileXML <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
122 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
124 m_outputFileXML <<
" </TAG>" << endl;
126 m_outputFileXML <<
" </ELEMENTS>" << endl;
128 m_outputFileXML <<
" <MAPS>" << endl;
130 m_outputFileXML <<
" <TAG idref ='2'>" << endl;
132 m_outputFileXML <<
" <IOV idref='1'>" << endl;
134 m_outputFileXML <<
" <DATA_SET idref='-1' />" << endl;
136 m_outputFileXML <<
" </IOV>" << endl;
138 m_outputFileXML <<
" </TAG>" << endl;
140 m_outputFileXML <<
" </MAPS>" << endl;
147 for(_meol=hbHists.LEDTRENDS.begin(); _meol!=hbHists.LEDTRENDS.end(); _meol++){
148 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
150 for(_meol=hoHists.LEDTRENDS.begin(); _meol!=hoHists.LEDTRENDS.end(); _meol++){
151 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
153 for(_meol=hfHists.LEDTRENDS.begin(); _meol!=hfHists.LEDTRENDS.end(); _meol++){
154 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
156 hbHists.ALLLEDS->Delete();
157 hbHists.LEDRMS->Delete();
158 hbHists.LEDMEAN->Delete();
159 hbHists.CHI2->Delete();
161 hoHists.ALLLEDS->Delete();
162 hoHists.LEDRMS->Delete();
163 hoHists.LEDMEAN->Delete();
164 hoHists.CHI2->Delete();
166 hfHists.ALLLEDS->Delete();
167 hfHists.LEDRMS->Delete();
168 hfHists.LEDMEAN->Delete();
169 hfHists.CHI2->Delete();
175 m_file=
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
176 m_file->mkdir(
"HBHE");
182 m_file->mkdir(
"Calib");
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;
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;
218 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
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));
225 if(m_fitflag==1 || m_fitflag==4){
227 for(
int j=0; j<10; j++) _meol->second[10].first->SetBinError(j+1,_meol->second[j].first->GetRMS()/
sqrt((
float)evt_curr));
229 if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
230 _meol->second[10].first->Fit(
"landau",
"Q");
232 TF1 *
fit = _meol->second[10].first->GetFunction(
"landau");
234 time2=fit->GetParameter(1);
235 dtime2=fit->GetParError(1);
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());
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());
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");
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();
280 if (m_outputFileText!=
""){
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;
288 m_outputFileXML <<
output << endl;
290 m_outputFileXML <<
output << endl;
292 m_outputFileXML <<
output << endl;
294 m_outputFileXML <<
output << endl;
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;
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;
323 m_outputFileXML <<
output << endl;
325 m_outputFileXML <<
output << endl;
327 m_outputFileXML <<
output << endl;
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;
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;
357 m_outputFileXML <<
output << endl;
359 m_outputFileXML <<
output << endl;
361 m_outputFileXML <<
output << endl;
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;
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;
390 m_outputFileXML <<
output << endl;
392 m_outputFileXML <<
output << endl;
394 m_outputFileXML <<
output << endl;
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;
417 else if(m_fitflag==4){
418 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<
" "<<time2<<
" "<<dtime2<<
" "<<time3<<
" "<<dtime3<<
" "<<time4<<
" "<<dtime4<<std::endl;
427 char LedSampleNum[20];
429 snprintf(LedSampleNum,
sizeof LedSampleNum,
"LedSample_%d",
sample);
431 m_file->mkdir(LedSampleNum);
432 m_file->cd(LedSampleNum);
435 GetLedConst(hbHists.LEDTRENDS);
436 GetLedConst(hoHists.LEDTRENDS);
437 GetLedConst(hfHists.LEDTRENDS);
444 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
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();
451 _meol->second[10+m_fitflag].second.second.push_back(
new TH1F(name,name,bins,lo,hi));
453 std::vector<double>::iterator sample_it;
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);
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);
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();
477 if(evt%m_nevtsample!=0) LedSampleAnalysis();
480 if(
sample>1 && m_fitflag!=4){
483 LedTrendings(hbHists.LEDTRENDS);
486 LedTrendings(hoHists.LEDTRENDS);
489 LedTrendings(hfHists.LEDTRENDS);
496 hbHists.ALLLEDS->Write();
497 hbHists.LEDRMS->Write();
498 hbHists.LEDMEAN->Write();
502 hoHists.ALLLEDS->Write();
503 hoHists.LEDRMS->Write();
504 hoHists.LEDMEAN->Write();
508 hfHists.ALLLEDS->Write();
509 hfHists.LEDRMS->Write();
510 hfHists.LEDMEAN->Write();
514 for(_meca=calibHists.begin(); _meca!=calibHists.end(); _meca++){
515 _meca->second.avePulse->Write();
516 _meca->second.integPulse->Write();
522 cout <<
"Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
533 sample = (evt-1)/m_nevtsample +1;
534 evt_curr = evt%m_nevtsample;
535 if(evt_curr==0)evt_curr=m_nevtsample;
541 if(calib.
empty())
throw (
int)calib.
size();
547 ProcessCalibEvent(elecId.
fiberChanId(),calibId,digi);
562 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
true;
564 _meol = hbHists.LEDTRENDS.find(digi.
id());
565 if (_meol==hbHists.LEDTRENDS.end()){
566 SetupLEDHists(0,digi.
id(),hbHists.LEDTRENDS);
568 LedHBHEHists(digi.
id(),digi,hbHists.LEDTRENDS,cond);
580 _meol = hoHists.LEDTRENDS.find(digi.
id());
581 if (_meol==hoHists.LEDTRENDS.end()){
582 SetupLEDHists(1,digi.
id(),hoHists.LEDTRENDS);
584 LedHOHists(digi.
id(),digi,hoHists.LEDTRENDS,cond);
596 _meol = hfHists.LEDTRENDS.find(digi.
id());
597 if (_meol==hfHists.LEDTRENDS.end()){
598 SetupLEDHists(2,digi.
id(),hfHists.LEDTRENDS);
600 LedHFHists(digi.
id(),digi,hfHists.LEDTRENDS,cond);
608 if(evt%m_nevtsample==0) LedSampleAnalysis();
614 string type =
"HBHE";
615 if(
id==1) type =
"HO";
616 if(
id==2) type =
"HF";
618 _meol = toolT.find(detid);
619 if (_meol==toolT.end()){
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.);
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.);
648 map<int,LEDBUNCH> _mei;
649 _meol = toolT.find(detid);
650 _mei = _meol->second;
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();
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));
673 _mei[TS].first->Fill(ta);
674 _mei[10].first->AddBinContent(TS+1,ta);
676 if(TS==m_startTS)_mei[11].first->Reset();
677 _mei[11].first->SetBinContent(TS+1,ta);
692 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
694 if(m_fitflag==2 || m_fitflag==4){
695 float timmean=_mei[11].first->GetMean();
696 float timmeancorr=BinsizeCorr(timmean);
697 _mei[12].first->Fill(timmeancorr);
699 _mei[16].first->Fill(_mei[11].
first->Integral());
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());
714 map<int,LEDBUNCH> _mei;
715 _meol = toolT.find(detid);
716 _mei = _meol->second;
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();
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);
740 if(TS==m_startTS)_mei[11].first->Reset();
741 _mei[11].first->SetBinContent(TS+1,ta);
756 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
758 if(m_fitflag==2 || m_fitflag==4){
759 float timmean=_mei[11].first->GetMean();
760 float timmeancorr=BinsizeCorr(timmean);
761 _mei[12].first->Fill(timmeancorr);
763 _mei[16].first->Fill(_mei[11].
first->Integral());
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());
778 map<int,LEDBUNCH> _mei;
779 _meol = toolT.find(detid);
780 _mei = _meol->second;
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();
797 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
798 int capid = ledDigi[TS].capid();
800 int adc = (
int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
801 if (adc < 0){ adc = 0; }
803 double fC = m_coder->charge(*m_shape,adc,capid);
807 _mei[TS].first->Fill(ta);
808 _mei[10].first->AddBinContent(TS+1,ta);
810 if(TS==m_startTS)_mei[11].first->Reset();
811 _mei[11].first->SetBinContent(TS+1,ta);
827 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
829 if(m_fitflag==2 || m_fitflag==4){
830 float timmean=_mei[11].first->GetMean();
831 float timmeancorr=BinsizeCorr(timmean);
832 _mei[12].first->Fill(timmeancorr);
834 _mei[16].first->Fill(_mei[11].
first->Integral());
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());
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,
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;
875 else tsdown=tstrue[31]-1.;
880 else tsup=tstrue[0]+1.;
881 if(restime>=lolim && restime<uplim){
882 corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
897 _meca = calibHists.find(calibId);
898 if (_meca==calibHists.end()){
907 snprintf(name,
sizeof name,
"%s %+d iphi=%d %s", sector.c_str(), calibId.
ieta(), calibId.
iphi(), calibId.
cboxChannelString().c_str());
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);
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());
923 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 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)
constexpr uint32_t rawId() const
get the raw id
HcalDetId const & id() const
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
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
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)
constexpr int adc() const
get the ADC sample
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)
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