25 for(
int k=0;
k<4;
k++) state.push_back(
true);
28 if ( !m_outputFileText.empty() ) {
29 cout <<
"Castor LED results will be saved to " << m_outputFileText.c_str() << endl;
30 m_outFile.open(m_outputFileText.c_str());
33 if ( !m_outputFileROOT.empty() ) {
34 cout <<
"Castor LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
38 if(m_nevtsample<1)m_nevtsample=9999999;
40 if(m_hiSaveflag<0)m_hiSaveflag=0;
41 if(m_hiSaveflag>0)m_hiSaveflag=1;
43 if(m_fitflag<0)m_fitflag=0;
44 if(m_fitflag>4)m_fitflag=4;
46 if(m_startTS<0) m_startTS=0;
49 m_logFile.open(
"CastorLedAnalysis.log");
54 castorHists.ALLLEDS =
new TH1F(
"Castor All LEDs",
"HF All Leds",10,0,9);
55 castorHists.LEDRMS=
new TH1F(
"Castor All LED RMS",
"HF All LED RMS",100,0,3);
56 castorHists.LEDMEAN=
new TH1F(
"Castor All LED Means",
"HF All LED Means",100,0,9);
57 castorHists.CHI2=
new TH1F(
"Castor Chi2 by ndf for Landau fit",
"HF Chi2/ndf Landau",200,0.,50.);
60 m_outputFileXML.open(m_outputFileX.c_str());
61 snprintf(
output,
sizeof output,
"<?xml version='1.0' encoding='UTF-8'?>");
62 m_outputFileXML <<
output << endl;
64 m_outputFileXML <<
output << endl << endl;
66 m_outputFileXML <<
output << endl;
68 m_outputFileXML <<
output << endl;
69 snprintf(
output,
sizeof output,
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>");
70 m_outputFileXML <<
output << endl;
71 snprintf(
output,
sizeof output,
" <NAME>HCAL LED Timing</NAME>");
72 m_outputFileXML <<
output << endl;
74 m_outputFileXML <<
output << endl;
76 m_outputFileXML <<
output << endl;
77 snprintf(
output,
sizeof output,
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>");
78 m_outputFileXML <<
output << endl;
79 snprintf(
output,
sizeof output,
" <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
80 m_outputFileXML <<
output << endl;
81 snprintf(
output,
sizeof output,
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>");
82 m_outputFileXML <<
output << endl;
83 snprintf(
output,
sizeof output,
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>");
84 m_outputFileXML <<
output << endl;
86 m_outputFileXML <<
output << endl;
88 m_outputFileXML <<
output << endl;
90 m_outputFileXML <<
output << endl;
92 m_outputFileXML <<
output << endl;
94 m_outputFileXML <<
output << endl;
96 m_outputFileXML <<
output << endl;
97 snprintf(
output,
sizeof output,
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>");
98 m_outputFileXML <<
output << endl;
99 snprintf(
output,
sizeof output,
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>");
100 m_outputFileXML <<
output << endl;
102 m_outputFileXML <<
output << endl;
103 snprintf(
output,
sizeof output,
" <TAG id='2' mode='auto'>");
104 m_outputFileXML <<
output << endl;
105 snprintf(
output,
sizeof output,
" <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
106 m_outputFileXML <<
output << endl;
107 snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>");
108 m_outputFileXML <<
output << endl;
109 snprintf(
output,
sizeof output,
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>");
110 m_outputFileXML <<
output << endl;
112 m_outputFileXML <<
output << endl;
114 m_outputFileXML <<
output << endl;
116 m_outputFileXML <<
output << endl;
118 m_outputFileXML <<
output << endl;
120 m_outputFileXML <<
output << endl;
121 snprintf(
output,
sizeof output,
" <DATA_SET idref='-1' />");
122 m_outputFileXML <<
output << endl;
124 m_outputFileXML <<
output << endl;
126 m_outputFileXML <<
output << endl;
128 m_outputFileXML <<
output << endl;
137 for(_meol=castorHists.LEDTRENDS.begin(); _meol!=castorHists.LEDTRENDS.end(); _meol++){
138 for(
int i=0;
i<15;
i++) _meol->second[
i].first->Delete();
141 castorHists.ALLLEDS->Delete();
142 castorHists.LEDRMS->Delete();
143 castorHists.LEDMEAN->Delete();
144 castorHists.CHI2->Delete();
150 m_file=
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
151 m_file->mkdir(
"Castor");
157 double time2=0;
double time1=0;
double time3=0;
double time4=0;
158 double dtime2=0;
double dtime1=0;
double dtime3=0;
double dtime4=0;
161 if (m_outputFileText!=
""){
162 if(m_fitflag==0 || m_fitflag==2) m_outFile<<
"Det Eta,Phi,D Mean Error"<<std::endl;
163 else if(m_fitflag==1 || m_fitflag==3) m_outFile<<
"Det Eta,Phi,D Peak Error"<<std::endl;
164 else if(m_fitflag==4) m_outFile<<
"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"<<std::endl;
166 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
168 _meol->second[10].first->Scale(1./evt_curr);
169 if(m_fitflag==0 || m_fitflag==4){
170 time1 = _meol->second[10].first->GetMean();
171 dtime1 = _meol->second[10].first->GetRMS()/
sqrt((
float)evt_curr*(m_endTS-m_startTS+1));
173 if(m_fitflag==1 || m_fitflag==4){
175 for(
int j=0; j<10; j++) _meol->second[10].first->SetBinError(j+1,_meol->second[j].first->GetRMS()/
sqrt((
float)evt_curr));
177 if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
178 _meol->second[10].first->Fit(
"landau",
"Q");
180 TF1 *
fit = _meol->second[10].first->GetFunction(
"landau");
182 time2=fit->GetParameter(1);
183 dtime2=fit->GetParError(1);
185 if(m_fitflag==2 || m_fitflag==4){
186 time3 = _meol->second[12].first->GetMean();
187 dtime3 = _meol->second[12].first->GetRMS()/
sqrt((
float)_meol->second[12].first->GetEntries());
189 if(m_fitflag==3 || m_fitflag==4){
190 time4 = _meol->second[13].first->GetMean();
191 dtime4 = _meol->second[13].first->GetRMS()/
sqrt((
float)_meol->second[13].first->GetEntries());
193 for (
int i=0;
i<10;
i++){
194 _meol->second[
i].first->GetXaxis()->SetTitle(
"Pulse height (fC)");
195 _meol->second[
i].first->GetYaxis()->SetTitle(
"Counts");
198 _meol->second[10].first->GetXaxis()->SetTitle(
"Time slice");
199 _meol->second[10].first->GetYaxis()->SetTitle(
"Averaged pulse (fC)");
200 if(m_hiSaveflag>0)_meol->second[10].first->Write();
201 _meol->second[10].second.first[0].push_back(time1);
202 _meol->second[10].second.first[1].push_back(dtime1);
203 _meol->second[11].second.first[0].push_back(time2);
204 _meol->second[11].second.first[1].push_back(dtime2);
205 _meol->second[12].first->GetXaxis()->SetTitle(
"Mean TS");
206 _meol->second[12].first->GetYaxis()->SetTitle(
"Counts");
207 if(m_fitflag==2 && m_hiSaveflag>0)_meol->second[12].first->Write();
208 _meol->second[12].second.first[0].push_back(time3);
209 _meol->second[12].second.first[1].push_back(dtime3);
210 _meol->second[13].first->GetXaxis()->SetTitle(
"Peak TS");
211 _meol->second[13].first->GetYaxis()->SetTitle(
"Counts");
212 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[13].first->Write();
213 _meol->second[13].second.first[0].push_back(time4);
214 _meol->second[13].second.first[1].push_back(dtime4);
215 _meol->second[14].first->GetXaxis()->SetTitle(
"Peak TS error");
216 _meol->second[14].first->GetYaxis()->SetTitle(
"Counts");
217 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[14].first->Write();
218 _meol->second[15].first->GetXaxis()->SetTitle(
"Chi2/NDF");
219 _meol->second[15].first->GetYaxis()->SetTitle(
"Counts");
220 if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[15].first->Write();
221 _meol->second[16].first->GetXaxis()->SetTitle(
"Integrated Signal");
222 _meol->second[16].first->Write();
228 if (m_outputFileText!=
""){
230 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<std::endl;
232 m_outputFileXML <<
output << endl;
233 snprintf(
output,
sizeof output,
" <VERSION>version:1</VERSION>");
234 m_outputFileXML <<
output << endl;
236 m_outputFileXML <<
output << endl;
237 snprintf(
output,
sizeof output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
238 m_outputFileXML <<
output << endl;
240 m_outputFileXML <<
output << endl;
242 m_outputFileXML <<
output << endl;
244 m_outputFileXML <<
output << endl;
246 m_outputFileXML <<
output << endl;
247 if(detid.
subdet() == 1) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
248 if(detid.
subdet() == 2) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
249 if(detid.
subdet() == 3) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
250 if(detid.
subdet() == 4) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
251 m_outputFileXML <<
output << endl;
252 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
253 m_outputFileXML <<
output << endl;
255 m_outputFileXML <<
output << endl;
257 m_outputFileXML <<
output << endl;
258 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time1);
259 m_outputFileXML <<
output << endl;
260 snprintf(
output,
sizeof output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
261 m_outputFileXML <<
output << endl;
262 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
263 m_outputFileXML <<
output << endl;
264 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
265 m_outputFileXML <<
output << endl;
266 snprintf(
output,
sizeof output,
" <STATUS_WORD> 0</STATUS_WORD>");
267 m_outputFileXML <<
output << endl;
269 m_outputFileXML <<
output << endl;
271 m_outputFileXML <<
output << endl;
274 else if(m_fitflag==1){
275 m_outFile<<detid<<
" "<<time2<<
" "<<dtime2<<std::endl;
277 m_outputFileXML <<
output << endl;
278 snprintf(
output,
sizeof output,
" <VERSION>version:1</VERSION>");
279 m_outputFileXML <<
output << endl;
281 m_outputFileXML <<
output << endl;
282 snprintf(
output,
sizeof output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
283 m_outputFileXML <<
output << endl;
285 m_outputFileXML <<
output << endl;
287 m_outputFileXML <<
output << endl;
289 m_outputFileXML <<
output << endl;
291 m_outputFileXML <<
output << endl;
292 if(detid.
subdet() == 1) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
293 if(detid.
subdet() == 2) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
294 if(detid.
subdet() == 3) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
295 if(detid.
subdet() == 4) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
296 m_outputFileXML <<
output << endl;
297 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
298 m_outputFileXML <<
output << endl;
300 m_outputFileXML <<
output << endl;
302 m_outputFileXML <<
output << endl;
303 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time2);
304 m_outputFileXML <<
output << endl;
305 snprintf(
output,
sizeof output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
306 m_outputFileXML <<
output << endl;
307 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
308 m_outputFileXML <<
output << endl;
309 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
310 m_outputFileXML <<
output << endl;
311 snprintf(
output,
sizeof output,
" <STATUS_WORD> 0</STATUS_WORD>");
312 m_outputFileXML <<
output << endl;
314 m_outputFileXML <<
output << endl;
316 m_outputFileXML <<
output << endl;
319 else if(m_fitflag==2){
320 m_outFile<<detid<<
" "<<time3<<
" "<<dtime3<<std::endl;
322 m_outputFileXML <<
output << endl;
323 snprintf(
output,
sizeof output,
" <VERSION>version:1</VERSION>");
324 m_outputFileXML <<
output << endl;
326 m_outputFileXML <<
output << endl;
327 snprintf(
output,
sizeof output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
328 m_outputFileXML <<
output << endl;
330 m_outputFileXML <<
output << endl;
332 m_outputFileXML <<
output << endl;
334 m_outputFileXML <<
output << endl;
336 m_outputFileXML <<
output << endl;
337 if(detid.
subdet() == 1) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
338 if(detid.
subdet() == 2) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
339 if(detid.
subdet() == 3) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
340 if(detid.
subdet() == 4) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
341 m_outputFileXML <<
output << endl;
342 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
343 m_outputFileXML <<
output << endl;
345 m_outputFileXML <<
output << endl;
347 m_outputFileXML <<
output << endl;
348 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time3);
349 m_outputFileXML <<
output << endl;
350 snprintf(
output,
sizeof output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
351 m_outputFileXML <<
output << endl;
352 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
353 m_outputFileXML <<
output << endl;
354 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
355 m_outputFileXML <<
output << endl;
356 snprintf(
output,
sizeof output,
" <STATUS_WORD> 0</STATUS_WORD>");
357 m_outputFileXML <<
output << endl;
359 m_outputFileXML <<
output << endl;
361 m_outputFileXML <<
output << endl;
363 else if(m_fitflag==3){
364 m_outFile<<detid<<
" "<<time4<<
" "<<dtime4<<std::endl;
366 m_outputFileXML <<
output << endl;
367 snprintf(
output,
sizeof output,
" <VERSION>version:1</VERSION>");
368 m_outputFileXML <<
output << endl;
370 m_outputFileXML <<
output << endl;
371 snprintf(
output,
sizeof output,
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>");
372 m_outputFileXML <<
output << endl;
374 m_outputFileXML <<
output << endl;
376 m_outputFileXML <<
output << endl;
378 m_outputFileXML <<
output << endl;
380 m_outputFileXML <<
output << endl;
381 if(detid.
subdet() == 1) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HB</DETECTOR_NAME>");
382 if(detid.
subdet() == 2) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HE</DETECTOR_NAME>");
383 if(detid.
subdet() == 3) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HO</DETECTOR_NAME>");
384 if(detid.
subdet() == 4) snprintf(
output,
sizeof output,
" <DETECTOR_NAME>HF</DETECTOR_NAME>");
385 m_outputFileXML <<
output << endl;
386 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId() );
387 m_outputFileXML <<
output << endl;
389 m_outputFileXML <<
output << endl;
391 m_outputFileXML <<
output << endl;
392 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time4);
393 m_outputFileXML <<
output << endl;
394 snprintf(
output,
sizeof output,
" <OFFSET_TIME> 0</OFFSET_TIME>");
395 m_outputFileXML <<
output << endl;
396 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
397 m_outputFileXML <<
output << endl;
398 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
399 m_outputFileXML <<
output << endl;
400 snprintf(
output,
sizeof output,
" <STATUS_WORD> 0</STATUS_WORD>");
401 m_outputFileXML <<
output << endl;
403 m_outputFileXML <<
output << endl;
405 m_outputFileXML <<
output << endl;
408 else if(m_fitflag==4){
409 m_outFile<<detid<<
" "<<time1<<
" "<<dtime1<<
" "<<time2<<
" "<<dtime2<<
" "<<time3<<
" "<<dtime3<<
" "<<time4<<
" "<<dtime4<<std::endl;
418 char LedSampleNum[20];
420 sprintf(LedSampleNum,
"LedSample_%d",
sample);
422 m_file->mkdir(LedSampleNum);
423 m_file->cd(LedSampleNum);
426 GetLedConst(castorHists.LEDTRENDS);
433 for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
436 sprintf(name,
"LED timing trend, eta=%d phi=%d depth=%d",detid.
ieta(),detid.
iphi(),detid.
depth());
437 int bins = _meol->second[10+m_fitflag].second.first[0].size();
440 _meol->second[10+m_fitflag].second.second.push_back(
new TH1F(name,name,bins,lo,hi));
442 std::vector<double>::iterator sample_it;
445 for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
446 sample_it!=_meol->second[10+m_fitflag].second.first[0].end();++sample_it){
447 _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
450 for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
451 sample_it!=_meol->second[10+m_fitflag].second.first[1].end();++sample_it){
452 _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
454 sprintf(name,
"Sample (%d events)",m_nevtsample);
455 _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
456 _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle(
"Peak position");
457 _meol->second[10+m_fitflag].second.second[0]->Write();
466 if(evt%m_nevtsample!=0) LedSampleAnalysis();
469 if(
sample>1 && m_fitflag!=4){
471 m_file->cd(
"Castor");
472 LedTrendings(castorHists.LEDTRENDS);
477 m_file->cd(
"Castor");
478 castorHists.ALLLEDS->Write();
479 castorHists.LEDRMS->Write();
480 castorHists.LEDMEAN->Write();
485 cout <<
"Castor histograms written to " << m_outputFileROOT.c_str() << endl;
493 sample = (evt-1)/m_nevtsample +1;
494 evt_curr = evt%m_nevtsample;
495 if(evt_curr==0)evt_curr=m_nevtsample;
499 if(castor.
empty())
throw (
int)castor.
size();
502 _meol = castorHists.LEDTRENDS.find(digi.
id());
503 if (_meol==castorHists.LEDTRENDS.end()){
504 SetupLEDHists(2,digi.
id(),castorHists.LEDTRENDS);
506 LedCastorHists(digi.
id(),digi,castorHists.LEDTRENDS,cond);
514 if(evt%m_nevtsample==0) LedSampleAnalysis();
520 string type =
"HBHE";
521 if(
id==1) type =
"HO";
522 if(
id==2) type =
"HF";
524 _meol = toolT.find(detid);
525 if (_meol==toolT.end()){
529 for(
int i=0;
i<10;
i++){
530 sprintf(name,
"%s Pulse height, eta=%d phi=%d depth=%d TS=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth(),
i);
531 insert[
i].first =
new TH1F(name,name,200,0.,2000.);
533 sprintf(name,
"%s LED Mean pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
534 insert[10].first =
new TH1F(name,name,10,-0.5,9.5);
535 sprintf(name,
"%s LED Pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
536 insert[11].first =
new TH1F(name,name,10,-0.5,9.5);
537 sprintf(name,
"%s Mean TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
538 insert[12].first =
new TH1F(name,name,200,0.,10.);
539 sprintf(name,
"%s Peak TS, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
540 insert[13].first =
new TH1F(name,name,200,0.,10.);
541 sprintf(name,
"%s Peak TS error, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
542 insert[14].first =
new TH1F(name,name,200,0.,0.05);
543 sprintf(name,
"%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
544 insert[15].first =
new TH1F(name,name,100,0.,50.);
545 sprintf(name,
"%s Integrated Signal, eta=%d phi=%d depth=%d",type.c_str(),detid.
ieta(),detid.
iphi(),detid.
depth());
546 insert[16].first =
new TH1F(name,name,500,0.,5000.);
554 map<int,LEDBUNCH> _mei;
555 _meol = toolT.find(detid);
556 _mei = _meol->second;
558 if((evt-1)%m_nevtsample==0 && state[0]){
559 for(
int k=0;
k<(
int)state.size();
k++) state[
k]=
false;
560 for(
int i=0;
i<16;
i++) _mei[
i].
first->Reset();
572 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++){
573 int capid = ledDigi[TS].capid();
575 int adc = (
int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
576 if (adc < 0){ adc = 0; }
578 double fC = m_coder->charge(*m_shape,adc,capid);
582 _mei[TS].first->Fill(ta);
583 _mei[10].first->AddBinContent(TS+1,ta);
585 if(TS==m_startTS)_mei[11].first->Reset();
586 _mei[11].first->SetBinContent(TS+1,ta);
601 for(
int i=0;
i<10;
i++)sum=sum+_mei[11].
first->GetBinContent(
i+1);
603 if(m_fitflag==2 || m_fitflag==4){
604 float timmean=_mei[11].first->GetMean();
605 float timmeancorr=BinsizeCorr(timmean);
606 _mei[12].first->Fill(timmeancorr);
608 _mei[16].first->Fill(_mei[11].
first->Integral());
609 if(m_fitflag==3 || m_fitflag==4){
610 _mei[11].first->Fit(
"landau",
"Q");
611 TF1 *
fit = _mei[11].first->GetFunction(
"landau");
612 _mei[13].first->Fill(fit->GetParameter(1));
613 _mei[14].first->Fill(fit->GetParError(1));
614 _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
631 static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
632 0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
633 0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
634 0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
635 static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
636 0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
637 0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
638 0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
641 int inttime=(
int)time;
642 float restime=time-inttime;
643 for(
int i=0;
i<=32;
i++) {
644 float lolim=0.;
float uplim=1.;
float tsdown;
float tsup;
649 else tsdown=tstrue[31]-1.;
654 else tsup=tstrue[0]+1.;
655 if(restime>=lolim && restime<uplim){
656 corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
int adc(sample_type sample)
get the ADC sample (12 bits)
T getUntrackedParameter(std::string const &, T const &) const
~CastorLedAnalysis()
Destructor.
HcalSubdetector subdet() const
get the subdetector
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
int zside() const
get the z-side of the cell (1/-1)
void LedSetup(const std::string &m_outputFileROOT)
constexpr uint32_t rawId() const
get the raw id
std::vector< CastorDataFrame >::const_iterator const_iterator
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
CastorLedAnalysis(const edm::ParameterSet &ps)
Constructor.
int depth() const
get the tower depth
void LedCastorHists(const HcalDetId &detid, const CastorDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const CastorDbService &cond)
const CastorQIEShape * getCastorShape() const
int ieta() const
get the cell ieta
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
float BinsizeCorr(float time)
int ietaAbs() const
get the absolute value of the cell ieta
const_iterator end() const
int iphi() const
get the cell iphi
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void processLedEvent(const CastorDigiCollection &castor, const CastorDbService &cond)
const HcalCastorDetId & id() const
int size() const
total number of samples in the digi
const_iterator begin() const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const