1 |
// |
// |
2 |
// Check the calorimter calibrations - Emiliano Mocchiutti |
// Check the calorimter calibrations - Emiliano Mocchiutti |
3 |
// |
// |
4 |
// FCaloCHKCALIB.c version 1.05 (2006-03-22) |
// FCaloCHKCALIB.c version 1.11 (2006-07-17) |
5 |
// |
// |
6 |
// The only input needed is the path to the directory created by YODA for the data file you want to analyze. |
// The only input needed is the path to the directory created by YODA for the data file you want to analyze. |
7 |
// |
// |
8 |
// Changelog: |
// Changelog: |
9 |
// |
// |
10 |
|
// 1.07 - 1.11 (2006-07-17): Adapted to flight conditions. |
11 |
|
// |
12 |
|
// 1.06 - 1.07 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN. Changed threshold for bad strip warning (from 0.005 to 0.03). |
13 |
|
// |
14 |
|
// 1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script! |
15 |
|
// |
16 |
// 1.04 - 1.05 (2006-03-22): Corrected wrong .C files. |
// 1.04 - 1.05 (2006-03-22): Corrected wrong .C files. |
17 |
// |
// |
18 |
// 1.03 - 1.04 (2006-03-20): Documentation updated. |
// 1.03 - 1.04 (2006-03-20): Documentation updated. |
65 |
} |
} |
66 |
|
|
67 |
TString getFilename(const TString filename){ |
TString getFilename(const TString filename){ |
68 |
const string fil = (const char*)filename; |
// |
69 |
Int_t posiz = fil.find("dw_"); |
const string fil = gSystem->BaseName(filename.Data()); |
70 |
if ( posiz == -1 ) posiz = fil.find("DW_"); |
Int_t posiz = fil.find(".root"); |
71 |
if ( posiz == -1 ) return 0; |
// |
72 |
Int_t posiz2 = posiz+13; |
TString file2; |
73 |
TString file2; |
if ( posiz == -1 ){ |
74 |
stringcopy(file2,filename,posiz,posiz2); |
file2 = gSystem->BaseName(filename.Data()); |
75 |
|
} else { |
76 |
|
Int_t posiz2 = 0; |
77 |
|
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
78 |
TString pdat(".dat"); |
TString pdat(".dat"); |
79 |
stringappend(file2,pdat); |
stringappend(file2,pdat); |
80 |
return file2; |
}; |
81 |
|
return file2; |
82 |
} |
} |
83 |
|
|
84 |
typedef struct Calib { |
typedef struct Calib { |
100 |
// |
// |
101 |
Float_t ccalrmsthr=0.99; |
Float_t ccalrmsthr=0.99; |
102 |
Float_t ccalpedthr=0.99; |
Float_t ccalpedthr=0.99; |
103 |
Float_t ccalbadthr=0.005; |
Float_t ccalbadthr=0.03;// 0.005 |
104 |
Float_t ccalthrthr=0.98; |
Float_t ccalthrthr=0.98; |
105 |
Float_t ccalvarthr=0.99; |
Float_t ccalvarthr=0.99; |
106 |
Float_t ccalbasthr=0.99; |
Float_t ccalbasthr=0.99; |
187 |
}; |
}; |
188 |
// |
// |
189 |
// |
// |
190 |
const string fil = (const char*)filename; |
const string fil = gSystem->BaseName(filename.Data()); |
191 |
Int_t posiz = fil.find("dw_"); |
Int_t posiz = fil.find(".root"); |
|
if ( posiz == -1 ) posiz = fil.find("DW_"); |
|
|
Int_t posiz2 = posiz+13; |
|
|
TString file2; |
|
|
stringcopy(file2,filename,posiz,posiz2); |
|
192 |
// |
// |
193 |
|
TString file2; |
194 |
|
if ( posiz == -1 ){ |
195 |
|
file2 = gSystem->BaseName(filename.Data()); |
196 |
|
} else { |
197 |
|
Int_t posiz2 = 0; |
198 |
|
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
199 |
|
}; |
200 |
const char *figrec = file2; |
const char *figrec = file2; |
201 |
|
// |
202 |
const char *outdir = outDir; |
const char *outdir = outDir; |
203 |
const char *format = saveas; |
const char *format = saveas; |
204 |
stringstream figsave; |
stringstream figsave; |
320 |
gDirectory->Delete("C14"); |
gDirectory->Delete("C14"); |
321 |
gDirectory->Delete("C15"); |
gDirectory->Delete("C15"); |
322 |
gDirectory->Delete("C16"); |
gDirectory->Delete("C16"); |
323 |
TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5); |
//TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5); |
324 |
TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5); |
// TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5); |
325 |
|
TH1F *calped = new TH1F("C14","calped",2112,-3.5,4227.5); |
326 |
|
// TH1F *calrms = new TH1F("C15","calrms",264,-2.,4226.); |
327 |
|
TH1F *calrms = new TH1F("C15","calrms",2112,-3.5,4228.5); |
328 |
TH1F *calbad = new TH1F("C16","calgood",4230,-3.5,4228.5); |
TH1F *calbad = new TH1F("C16","calgood",4230,-3.5,4228.5); |
329 |
// |
// |
330 |
gDirectory->Delete("C17"); |
gDirectory->Delete("C17"); |
444 |
incalped++; |
incalped++; |
445 |
}; |
}; |
446 |
calrms->Fill((float)j,(calib.calrms[l][m][n]/4.)); |
calrms->Fill((float)j,(calib.calrms[l][m][n]/4.)); |
447 |
if ( (calib.calrms[l][m][n]/4.) > 7. || (calib.calrms[l][m][n]/4.) < 1. ){ |
if ( (((calib.calrms[l][m][n]/4.) > 7. || (calib.calrms[l][m][n]/4.) < 1.) && (j < 3440 && j > 3550)) || ( (j > 3439 && j < 3551) && ((calib.calrms[l][m][n]/4.) > 150. || (calib.calrms[l][m][n]/4.) < 1.)) ){ |
448 |
outcalrms++; |
outcalrms++; |
449 |
} else { |
} else { |
450 |
incalrms++; |
incalrms++; |
454 |
// |
// |
455 |
if ( n < 6 ){ |
if ( n < 6 ){ |
456 |
calthr->Fill((float)g,(float)calib.calthr[l][m][n]); |
calthr->Fill((float)g,(float)calib.calthr[l][m][n]); |
457 |
if ( calib.calthr[l][m][n] > 21. || calib.calthr[l][m][n] < 12. ){ |
if ( (calib.calthr[l][m][n] > 21. || calib.calthr[l][m][n] < 12.) && (g < 215 && g > 221) ){ |
458 |
outcalthr++; |
outcalthr++; |
459 |
} else { |
} else { |
460 |
incalthr++; |
incalthr++; |
461 |
}; |
}; |
462 |
calvar->Fill((float)g,(float)calib.calvar[l][m][n]); |
calvar->Fill((float)g,(float)calib.calvar[l][m][n]); |
463 |
if ( calib.calvar[l][m][n] > 8. || calib.calvar[l][m][n] < 1. ){ |
if ( (calib.calvar[l][m][n] > 8. || calib.calvar[l][m][n] < 1. ) && (g < 215 && g > 221) ){ |
464 |
outcalvar++; |
outcalvar++; |
465 |
} else { |
} else { |
466 |
incalvar++; |
incalvar++; |
647 |
calped->GetXaxis()->SetNdivisions(322); |
calped->GetXaxis()->SetNdivisions(322); |
648 |
calped->SetXTitle("strip"); |
calped->SetXTitle("strip"); |
649 |
calped->SetYTitle("ADC channels"); |
calped->SetYTitle("ADC channels"); |
650 |
|
calped->SetMaximum(3000.); |
651 |
|
calped->SetMinimum(-3000.); |
652 |
calped->Draw(); |
calped->Draw(); |
653 |
TPolyLine *banda1; |
TPolyLine *banda1; |
654 |
Double_t xc[4] = {0.,4224.,4224.,0.}; |
Double_t xc[4] = {0.,4224.,4224.,0.}; |
660 |
banda1->Draw("fSAME"); |
banda1->Draw("fSAME"); |
661 |
TPolyLine *banda2; |
TPolyLine *banda2; |
662 |
Double_t xc2[4] = {4031.5,4047.5,4047.5,4031.5}; |
Double_t xc2[4] = {4031.5,4047.5,4047.5,4031.5}; |
663 |
Double_t yc2[4] = {-2500.,-2500.,28000.,28000.}; |
// Double_t yc2[4] = {-2500.,-2500.,28000.,28000.}; |
664 |
|
Double_t yc2[4] = {-3000.,-3000.,3000.,3000.}; |
665 |
banda2 = new TPolyLine(4,xc2,yc2); |
banda2 = new TPolyLine(4,xc2,yc2); |
666 |
banda2->SetLineColor(5); |
banda2->SetLineColor(5); |
667 |
banda2->SetFillColor(5); |
banda2->SetFillColor(5); |
679 |
banda1->SetFillColor(5); |
banda1->SetFillColor(5); |
680 |
banda1->SetLineWidth(1); |
banda1->SetLineWidth(1); |
681 |
banda1->Draw("fSAME"); |
banda1->Draw("fSAME"); |
682 |
|
Float_t minrm = calrms->GetMinimum(); |
683 |
|
Float_t maxrm = calrms->GetMaximum(); |
684 |
|
Double_t xrm2[4] = {3449.,3551.,3551.,3449.}; |
685 |
|
Double_t yrm2[4] = {minrm,minrm,maxrm,maxrm}; |
686 |
|
banda2 = new TPolyLine(4,xrm2,yrm2); |
687 |
|
banda2->SetLineColor(5); |
688 |
|
banda2->SetFillColor(5); |
689 |
|
banda2->SetLineWidth(1); |
690 |
|
banda2->Draw("fSAME"); |
691 |
calrms->SetXTitle("strip"); |
calrms->SetXTitle("strip"); |
692 |
calrms->SetYTitle("ADC channels"); |
calrms->SetYTitle("ADC channels"); |
693 |
calrms->Draw("SAME"); |
calrms->Draw("SAME"); |
729 |
banda1->SetFillColor(5); |
banda1->SetFillColor(5); |
730 |
banda1->SetLineWidth(1); |
banda1->SetLineWidth(1); |
731 |
banda1->Draw("fSAME"); |
banda1->Draw("fSAME"); |
732 |
|
// |
733 |
|
minrm = calthr->GetMinimum(); |
734 |
|
maxrm = 1.05*calthr->GetMaximum(); |
735 |
|
Double_t xth2[4] = {215.,221.,221.,215.}; |
736 |
|
Double_t yth2[4] = {minrm,minrm,maxrm,maxrm}; |
737 |
|
banda2 = new TPolyLine(4,xth2,yth2); |
738 |
|
banda2->SetLineColor(5); |
739 |
|
banda2->SetFillColor(5); |
740 |
|
banda2->SetLineWidth(1); |
741 |
|
banda2->Draw("fSAME"); |
742 |
|
// |
743 |
calthr->Draw("SAME"); |
calthr->Draw("SAME"); |
744 |
f3pd2->cd(); |
f3pd2->cd(); |
745 |
|
// gPad->SetLogy(); |
746 |
calvar->GetXaxis()->SetNdivisions(644); |
calvar->GetXaxis()->SetNdivisions(644); |
747 |
calvar->SetXTitle("pre-amplifier"); |
calvar->SetXTitle("pre-amplifier"); |
748 |
calvar->SetYTitle("ADC channels"); |
calvar->SetYTitle("ADC channels"); |
754 |
banda1->SetFillColor(5); |
banda1->SetFillColor(5); |
755 |
banda1->SetLineWidth(1); |
banda1->SetLineWidth(1); |
756 |
banda1->Draw("fSAME"); |
banda1->Draw("fSAME"); |
757 |
|
// |
758 |
|
minrm = calvar->GetMinimum(); |
759 |
|
maxrm = 1.05*calvar->GetMaximum(); |
760 |
|
Double_t xva2[4] = {215.,221.,221.,215.}; |
761 |
|
Double_t yva2[4] = {minrm,minrm,maxrm,maxrm}; |
762 |
|
banda2 = new TPolyLine(4,xva2,yva2); |
763 |
|
banda2->SetLineColor(5); |
764 |
|
banda2->SetFillColor(5); |
765 |
|
banda2->SetLineWidth(1); |
766 |
|
banda2->Draw("fSAME"); |
767 |
|
// |
768 |
calvar->Draw("SAME"); |
calvar->Draw("SAME"); |
769 |
f3pd3->cd(); |
f3pd3->cd(); |
770 |
calbase->GetXaxis()->SetNdivisions(644); |
calbase->GetXaxis()->SetNdivisions(644); |
985 |
if ( ci == minev ) { |
if ( ci == minev ) { |
986 |
figsave.str(""); |
figsave.str(""); |
987 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
988 |
figsave << figrec << "_chkcalib."; |
figsave << figrec << "_CaloCHKCALIB."; |
989 |
figsave << format; |
figsave << format; |
990 |
figsave << "("; |
figsave << "("; |
991 |
}; |
}; |
994 |
if ( ci == minev ) { |
if ( ci == minev ) { |
995 |
figsave.str(""); |
figsave.str(""); |
996 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
997 |
figsave << figrec << "_chkcalib."; |
figsave << figrec << "_CaloCHKCALIB."; |
998 |
figsave << format; |
figsave << format; |
999 |
}; |
}; |
1000 |
}; |
}; |
1003 |
if ( ci == minev ) { |
if ( ci == minev ) { |
1004 |
figsave.str(""); |
figsave.str(""); |
1005 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
1006 |
figsave << figrec << "_chkcalib."; |
figsave << figrec << "_CaloCHKCALIB."; |
1007 |
figsave << format; |
figsave << format; |
1008 |
}; |
}; |
1009 |
// |
// |
1012 |
if ( ci == maxev-4 ) { |
if ( ci == maxev-4 ) { |
1013 |
figsave.str(""); |
figsave.str(""); |
1014 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
1015 |
figsave << figrec << "_chkcalib."; |
figsave << figrec << "_CaloCHKCALIB."; |
1016 |
figsave << format; |
figsave << format; |
1017 |
figsave << ")"; |
figsave << ")"; |
1018 |
rapporto->Print(figsave.str().c_str(),"Portrait"); |
rapporto->Print(figsave.str().c_str(),"Portrait"); |
1021 |
if ( figmatra ) { |
if ( figmatra ) { |
1022 |
figsave.str(""); |
figsave.str(""); |
1023 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
1024 |
figsave << figrec << "_chkcalib1_"; |
figsave << figrec << "_CaloCHKCALIB1_"; |
1025 |
figsave << (i+1) << "."; |
figsave << (i+1) << "."; |
1026 |
figsave << format; |
figsave << format; |
1027 |
figura2->SaveAs(figsave.str().c_str()); |
figura2->SaveAs(figsave.str().c_str()); |
1029 |
// |
// |
1030 |
figsave1.str(""); |
figsave1.str(""); |
1031 |
figsave1 << outdir << "/" ; |
figsave1 << outdir << "/" ; |
1032 |
figsave1 << figrec << "_chkcalib2_"; |
figsave1 << figrec << "_CaloCHKCALIB2_"; |
1033 |
figsave1 << (i+1) << "."; |
figsave1 << (i+1) << "."; |
1034 |
figsave1 << format; |
figsave1 << format; |
1035 |
figura1->SaveAs(figsave1.str().c_str()); |
figura1->SaveAs(figsave1.str().c_str()); |
1036 |
// |
// |
1037 |
figsave2.str(""); |
figsave2.str(""); |
1038 |
figsave2 << outdir << "/" ; |
figsave2 << outdir << "/" ; |
1039 |
figsave2 << figrec << "_chkcalib3_"; |
figsave2 << figrec << "_CaloCHKCALIB3_"; |
1040 |
figsave2 << (i+1) << "."; |
figsave2 << (i+1) << "."; |
1041 |
figsave2 << format; |
figsave2 << format; |
1042 |
figura3->SaveAs(figsave2.str().c_str()); |
figura3->SaveAs(figsave2.str().c_str()); |
1044 |
if ( ci == maxev-4 ) { |
if ( ci == maxev-4 ) { |
1045 |
figsave.str(""); |
figsave.str(""); |
1046 |
figsave << outdir << "/" ; |
figsave << outdir << "/" ; |
1047 |
figsave << figrec << "_chkcalib_report."; |
figsave << figrec << "_CaloCHKCALIB_report."; |
1048 |
figsave << format; |
figsave << format; |
1049 |
rapporto->SaveAs(figsave.str().c_str()); |
rapporto->SaveAs(figsave.str().c_str()); |
1050 |
}; |
}; |