20 #include <TApplication.h> 28 #include <TPostScript.h> 32 #include <TGraphErrors.h> 41 namespace std {}
using namespace std;
45 char SMP2Name[][100]={
"SMA0",
"SMC0",
"SMA1",
"SMC1",
"SMA2",
"SMC2",
"SMA3",
"SMC3",
"SMA4",
"SMC4"};
46 char SMcalibName[][100]={
"US2",
"US1",
"EU2",
"EU1",
"US3",
"US5",
"US4",
"EU3",
"US7",
"US6"};
47 char SMnumber[][100]={
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"};
76 {
int ism,icol,irow,iScan,cmpt,cmptEye;
78 double p0,p1,p2,p1Max,p2Max;
79 double p0tab[48][24]={{0.}};
80 double p1tab[48][24]={{0.}};
81 double p2tab[48][24]={{0.}};
82 double yearTab[48][24]={{0.}};
83 double monthTab[48][24]={{0.}};
88 const int kNbHVscans=3;
89 const int kNbMaxDiscardTowers=200;
91 FILE *inFile,*outParamFile;
92 char paramFileName[200],baseName[200];
93 TString **HVscansPaths,**discardFiles;
94 HVscansPaths =
new TString*[kNbHVscans];
95 discardFiles =
new TString*[kNbHVscans];
96 int HVscansYears[kNbHVscans];
97 int HVscansMonths[kNbHVscans];
98 double discardScans[kNbHVscans][10][48][24]={{{{0.}}}};
101 sprintf(baseName,
"mergedHVscanParamsApr2013");
103 discardFiles[0] =
new TString(
"000");
104 HVscansPaths[0] =
new TString(
"/cebaf/Web/EMCALpub/biasScanP2/feb2011/Hvscan");
105 HVscansYears[0]=2011;
107 discardFiles[1] =
new TString(
"000");
108 HVscansPaths[1] =
new TString(
"/cebaf/Web/EMCALpub/biasScanP2/Mars2012/Hvscan");
109 HVscansYears[1]=2012;
111 discardFiles[2] =
new TString(
"/cebaf/faivre/recherche/calibPi0/recalculateEMCAL_HV_Apr2013/HVscanMars2013/listBadScansByEye.txt");
112 HVscansPaths[2] =
new TString(
"/cebaf/Web/EMCALpub/biasScanP2/Mars2013/Hvscan");
113 HVscansYears[2]=2013;
118 TH1F *h0 =
new TH1F(
"h0",
"h0",200,-150.,150.);
119 TH1F *h1 =
new TH1F(
"h1",
"h1",200,0.,p1Max);
120 TH1F *h2 =
new TH1F(
"h2",
"h2",200,0.,p2Max);
121 TH2F *h10 =
new TH2F(
"h10",
"h10",100,-150.,150.,100,0.,p1Max);
122 TH2F *h20 =
new TH2F(
"h20",
"h20",100,-150.,150.,100,0.,p2Max);
123 TH2F *h21 =
new TH2F(
"h21",
"h21",100,0.,p1Max,100,0.,p2Max);
134 printf(
"\nTower numbers given in Grenoble/electronic mapping convention.\n\n");
136 for (iScan=0;iScan<kNbHVscans;iScan++)
137 {inFile=fopen(discardFiles[iScan]->
Data(),
"r");
139 {printf(
"Read discard file scan %d : %s\nFound towers : ",iScan,discardFiles[iScan]->
Data());
140 while (fscanf(inFile,
" %d %d %d\n",&ism,&icol,&irow)>0)
141 {discardScans[iScan][ism][icol][irow]=1;
142 printf(
"(%d,%d,%d) ",ism,icol,irow);
146 else printf(
"By-eye discarded LED HV-scan file %s not found (HV scan %d)\n",discardFiles[iScan]->
Data(),iScan);
150 gSystem->Exec(Form(
"mkdir %s",baseName));
152 for (ism=0;ism<
kNbSM;ism++)
153 {printf(
"\n____________________________________\nDoing SM %d...\n",ism);
155 for (icol=0;icol<
kNbCol;icol++)
156 {
for (irow=0;irow<
kNbRow;irow++)
157 {p0tab[icol][irow]=0.;
158 p1tab[icol][irow]=0.;
159 p2tab[icol][irow]=0.;
162 for (iScan=kNbHVscans-1;iScan>=0;iScan--)
163 {
if (iScan==kNbHVscans-1) printf(
"*** LED scan %d (%02d/%d)",iScan+1,HVscansMonths[iScan],HVscansYears[iScan]);
164 else printf(
"*** LED scan %d (%02d/%d)\n Check scan %d : ",iScan+1,HVscansMonths[iScan],HVscansYears[iScan],iScan+2);
166 inFile=fopen(paramFileName,
"r");
170 {
while (fscanf(inFile,
" %d %d %lf %lf %lf\n",&icol,&irow,&p0,&p1,&p2)>0)
171 {
if (((p1tab[icol][irow]==0.) && (p2tab[icol][irow]==0.)) || ((p1tab[icol][irow]<=0.) || (p2tab[icol][irow]<=0.)))
172 {
if (iScan != (kNbHVscans-1)) printf(
"(%d,%d) ",icol,irow);
173 p0tab[icol][irow]=p0;
174 p1tab[icol][irow]=p1;
175 p2tab[icol][irow]=p2;
176 yearTab[icol][irow]=HVscansYears[iScan];
177 monthTab[icol][irow]=HVscansMonths[iScan];
181 {
if ((iScan < kNbHVscans-1) && (discardScans[iScan+1][ism][icol][irow] == 1))
182 {printf(
"eye(%d,%d) ",icol,irow);
183 p0tab[icol][irow]=p0;
184 p1tab[icol][irow]=p1;
185 p2tab[icol][irow]=p2;
186 yearTab[icol][irow]=HVscansYears[iScan];
187 monthTab[icol][irow]=HVscansMonths[iScan];
194 else printf(
"File %s not found\n",paramFileName);
196 if ((iScan != (kNbHVscans-1)) && (cmpt > 0)) printf(
" %d towers found with missing info.\n",cmpt);
197 if ((iScan != (kNbHVscans-1)) && (cmptEye > 0)) printf(
" %d towers tagged as bad by eye-inspection.\n",cmptEye);
200 printf(
"*** Writing to file : ");
203 for(icol=0;icol<
kNbCol;icol++)
204 {
for(irow=0;irow<
kNbRow;irow++)
206 fprintf(outParamFile,
"%2d %2d %lf %lf %lf\n",icol,irow,p0tab[icol][irow],p1tab[icol][irow],p2tab[icol][irow]);
207 if (((p1tab[icol][irow]==0.) && (p2tab[icol][irow]==0.)) || ((p1tab[icol][irow]<=0.) || (p2tab[icol][irow]<=0.)))
208 {printf(
"(%d,%d) ",icol,irow);
212 {h0->Fill(p0tab[icol][irow]);
213 h1->Fill(p1tab[icol][irow]);
214 h2->Fill(p2tab[icol][irow]);
215 h10->Fill(p0tab[icol][irow],p1tab[icol][irow]);
216 h20->Fill(p0tab[icol][irow],p2tab[icol][irow]);
217 h21->Fill(p1tab[icol][irow],p2tab[icol][irow]);
223 fclose(outParamFile);
224 printf(
"\n %d towers remain with missing info.\n",cmpt);
227 const int cWidth=500;
228 const int cHeight=(int)(500*(29./21.));
229 TCanvas *c1 =
new TCanvas(
"c1",
"EMCal cosmics analysis",cWidth,cHeight);
void MergeHVscanFilesVariousScans2(void)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)