| 671 |
umax = 100.; |
umax = 100.; |
| 672 |
slmax = ""; |
slmax = ""; |
| 673 |
sumax = ""; |
sumax = ""; |
| 674 |
|
xyaverage = true; |
| 675 |
// |
// |
| 676 |
}; |
}; |
| 677 |
|
|
| 1004 |
printf(" ERROR, the input formula must contain \"t\"\n"); |
printf(" ERROR, the input formula must contain \"t\"\n"); |
| 1005 |
return 0.; |
return 0.; |
| 1006 |
}; |
}; |
| 1007 |
|
if ( tmax != tmax ){ |
| 1008 |
|
printf(" ERROR, tmax is nan! \n"); |
| 1009 |
|
return 0.; |
| 1010 |
|
}; |
| 1011 |
TString g=Form("%f",tmax); |
TString g=Form("%f",tmax); |
| 1012 |
TString *ts= new TString(""); |
TString *ts= new TString(""); |
| 1013 |
ts->Prepend(s.Data()); |
ts->Prepend(s.Data()); |
| 1075 |
}; |
}; |
| 1076 |
// |
// |
| 1077 |
TString thid = Form("hlongfit"); |
TString thid = Form("hlongfit"); |
| 1078 |
TH1F *th = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); |
TH2F *th = dynamic_cast<TH2F*>(gDirectory->FindObject(thid)); |
| 1079 |
if ( th ) th->Delete(); |
if ( th ) th->Delete(); |
| 1080 |
|
// |
| 1081 |
|
TString ghid = Form("glongfit"); |
| 1082 |
|
TGraphErrors *gh = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid)); |
| 1083 |
|
if ( gh ) gh->Delete(); |
| 1084 |
|
// |
| 1085 |
Float_t xpos = 0.; |
Float_t xpos = 0.; |
| 1086 |
Float_t enemip = 0.; |
Float_t enemip = 0.; |
| 1087 |
Float_t xmax = NC * X0pl + 0.2; |
Float_t xmax = NC * X0pl + 0.2; |
| 1088 |
// th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax); |
// |
| 1089 |
th = new TH1F(thid,thid,100,-0.2,xmax); |
Double_t xxx[50]; |
| 1090 |
|
Double_t exx[50]; |
| 1091 |
|
Double_t yyy[50]; |
| 1092 |
|
Double_t eyy[50]; |
| 1093 |
|
Int_t numpo = 0; |
| 1094 |
|
memset(xxx,0,50*sizeof(Double_t)); |
| 1095 |
|
memset(exx,0,50*sizeof(Double_t)); |
| 1096 |
|
memset(yyy,0,50*sizeof(Double_t)); |
| 1097 |
|
memset(eyy,0,50*sizeof(Double_t)); |
| 1098 |
// |
// |
| 1099 |
// AGH, BUG! |
// AGH, BUG! |
| 1100 |
// |
// |
| 1108 |
mmax = NC; |
mmax = NC; |
| 1109 |
}; |
}; |
| 1110 |
// |
// |
| 1111 |
|
Float_t emax = 0.; |
| 1112 |
Float_t qtotparz = 0.; |
Float_t qtotparz = 0.; |
| 1113 |
for (Int_t st=mmin;st<mmax+1;st++){ |
for (Int_t st=mmin;st<mmax+1;st++){ |
| 1114 |
enemip = 0.; |
enemip = 0.; |
| 1115 |
xpos = (st - mmin) * X0pl; |
xpos = (st - mmin) * X0pl; |
| 1116 |
if ( st > mmin && st < mmax ){ |
// |
| 1117 |
if ( no18x && ( st == 18+1 || st == mask18b+1 )){ |
if ( xyaverage ){ |
| 1118 |
if ( !maskYO ){ |
// |
| 1119 |
enemip = 2. * eplane[1][st]; |
if ( st > mmin && st < mmax ){ |
| 1120 |
|
if ( no18x && ( st == 18+1 || st == mask18b+1 )){ |
| 1121 |
|
if ( !maskYO ){ |
| 1122 |
|
enemip = 2. * eplane[1][st]; |
| 1123 |
|
} else { |
| 1124 |
|
enemip = eplane[1][st]; |
| 1125 |
|
}; |
| 1126 |
} else { |
} else { |
| 1127 |
enemip = eplane[1][st]; |
enemip = eplane[0][st-1] + eplane[1][st]; |
| 1128 |
}; |
}; |
| 1129 |
} else { |
} else { |
| 1130 |
enemip = eplane[0][st-1] + eplane[1][st]; |
if ( st == mmin ){ |
| 1131 |
|
if ( !maskYE ){ |
| 1132 |
|
enemip = 2. * eplane[1][st]; |
| 1133 |
|
} else { |
| 1134 |
|
enemip = eplane[1][st]; |
| 1135 |
|
}; |
| 1136 |
|
}; |
| 1137 |
|
if ( st == mmax ){ |
| 1138 |
|
if ( !maskXE ){ |
| 1139 |
|
enemip = 2. * eplane[0][st-1]; |
| 1140 |
|
} else { |
| 1141 |
|
enemip = eplane[0][st-1]; |
| 1142 |
|
}; |
| 1143 |
|
}; |
| 1144 |
|
}; |
| 1145 |
|
// |
| 1146 |
|
qtotparz += enemip; |
| 1147 |
|
if ( enemip > emax ) emax = enemip; |
| 1148 |
|
if ( enemip > 0. ){ |
| 1149 |
|
xxx[numpo] = xpos; |
| 1150 |
|
exx[numpo] = 0.1; |
| 1151 |
|
yyy[numpo] = enemip; |
| 1152 |
|
eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); |
| 1153 |
|
numpo++; |
| 1154 |
|
// th->Fill(xpos,enemip); |
| 1155 |
|
if ( debug ) printf(" AVE Filling: st %i xpos %f energy %f \n",st,xpos,enemip); |
| 1156 |
}; |
}; |
| 1157 |
} else { |
} else { |
| 1158 |
if ( st == mmin ){ |
for (Int_t jj=0; jj<2; jj++){ |
| 1159 |
if ( !maskYE ){ |
if ( st > mmin && st < mmax ){ |
| 1160 |
enemip = 2. * eplane[1][st]; |
if ( jj == 0 && no18x && ( st == 18+1 || st == mask18b+1 )){ |
| 1161 |
|
enemip = eplane[1][st]; |
| 1162 |
|
} else { |
| 1163 |
|
if ( jj == 0 ){ |
| 1164 |
|
enemip = eplane[jj][st-1]; |
| 1165 |
|
} else { |
| 1166 |
|
enemip = eplane[jj][st]; |
| 1167 |
|
}; |
| 1168 |
|
}; |
| 1169 |
} else { |
} else { |
| 1170 |
enemip = eplane[1][st]; |
if ( st == mmin && jj == 1 ){ |
| 1171 |
|
enemip = eplane[jj][st]; |
| 1172 |
|
}; |
| 1173 |
|
if ( st == mmax && jj == 0){ |
| 1174 |
|
enemip = eplane[jj][st-1]; |
| 1175 |
|
}; |
| 1176 |
}; |
}; |
| 1177 |
}; |
// |
| 1178 |
if ( st == mmax ){ |
qtotparz += enemip; |
| 1179 |
if ( !maskXE ){ |
if ( enemip > emax ) emax = enemip; |
| 1180 |
enemip = 2. * eplane[0][st-1]; |
if ( enemip > 0. ){ |
| 1181 |
} else { |
xxx[numpo] = xpos; |
| 1182 |
enemip = eplane[0][st-1]; |
exx[numpo] = 0.1; |
| 1183 |
|
yyy[numpo] = enemip; |
| 1184 |
|
eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); |
| 1185 |
|
// eyy[numpo] = sqrt(enemip)/(st*0.95); |
| 1186 |
|
numpo++; |
| 1187 |
|
// th->Fill(xpos,enemip); |
| 1188 |
|
if ( debug ) printf(" XY Filling: st %i xpos %f energy %f \n",st,xpos,enemip); |
| 1189 |
}; |
}; |
| 1190 |
}; |
}; |
|
}; |
|
|
// |
|
|
qtotparz += enemip; |
|
|
if ( enemip > 0. ){ |
|
|
th->Fill(xpos,enemip); |
|
|
if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip); |
|
| 1191 |
}; |
}; |
| 1192 |
|
|
| 1193 |
// |
// |
| 1194 |
// for (Int_t v=1; v>=0;v--)// { |
// for (Int_t v=1; v>=0;v--)// { |
| 1195 |
// // |
// // |
| 1215 |
// }; |
// }; |
| 1216 |
}; |
}; |
| 1217 |
// |
// |
| 1218 |
TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); |
// th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax); |
| 1219 |
|
th = new TH2F(thid,thid,1000,-0.2,xmax,1000,0.,emax*1.2); |
| 1220 |
|
gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy); |
| 1221 |
|
TF1 *lfit = dynamic_cast<TF1*>(gDirectory->FindObject("lfit")); |
| 1222 |
|
if ( lfit ) lfit->Delete(); |
| 1223 |
|
lfit = new TF1("lfit",ccurve,0.,xmax,3); |
| 1224 |
if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); |
if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); |
| 1225 |
E0 = qtotparz; |
E0 = qtotparz; |
| 1226 |
// E0 = clp->qtot; |
// E0 = clp->qtot; |
| 1231 |
// lfit->SetParLimits(0,0.,1000.); |
// lfit->SetParLimits(0,0.,1000.); |
| 1232 |
// lfit->SetParLimits(1,-1.,80.); |
// lfit->SetParLimits(1,-1.,80.); |
| 1233 |
// lfit->SetParLimits(2,-1.,10.); |
// lfit->SetParLimits(2,-1.,10.); |
| 1234 |
TString optio; |
// TString optio = "ROW"; // "RO" |
| 1235 |
|
TString optio = "RO"; // "RO" |
| 1236 |
if ( debug ){ |
if ( debug ){ |
| 1237 |
// optio = "MERBOV"; |
optio += "NV"; |
| 1238 |
// optio = "MEROV"; |
if ( draw ) optio += "V"; |
| 1239 |
// optio = "EROV"; |
} else { |
| 1240 |
optio = "RNOV"; |
optio += "NQ"; |
| 1241 |
if ( draw ) optio = "ROV"; |
if ( draw ) optio += "Q"; |
|
} else { |
|
|
// optio = "MERNOQ"; |
|
|
// optio = "ERNOQ"; |
|
|
optio = "RNOQ"; |
|
|
if ( draw ) optio = "ROQ"; |
|
| 1242 |
}; |
}; |
| 1243 |
// |
// |
| 1244 |
if ( debug ) printf(" OK, start the fitting procedure...\n"); |
if ( debug ) printf(" OK, start the fitting procedure...\n"); |
| 1245 |
// |
// |
| 1246 |
fitresult = th->Fit("lfit",optio); |
// fitresult = th->Fit("lfit",optio); |
| 1247 |
|
fitresult = gh->Fit("lfit",optio); |
| 1248 |
// |
// |
| 1249 |
if ( debug ) printf(" the fit is done! result: %i \n",fitresult); |
if ( debug ) printf(" the fit is done! result: %i \n",fitresult); |
| 1250 |
// |
// |
| 1321 |
// axis titles |
// axis titles |
| 1322 |
th->SetXTitle("Depth [X0]"); |
th->SetXTitle("Depth [X0]"); |
| 1323 |
th->SetYTitle("Energy [MIP]"); |
th->SetYTitle("Energy [MIP]"); |
| 1324 |
th->DrawCopy("Perror"); |
// th->DrawCopy("Perror"); |
| 1325 |
|
th->DrawCopy(); |
| 1326 |
|
gh->SetMarkerSize(1.); |
| 1327 |
|
gh->SetMarkerStyle(21); |
| 1328 |
|
// gh->SetMarkerColor(kRed); |
| 1329 |
|
gh->Draw("Psame"); |
| 1330 |
lfit->Draw("same"); |
lfit->Draw("same"); |
| 1331 |
tc->Modified(); |
tc->Modified(); |
| 1332 |
tc->Update(); |
tc->Update(); |
| 1338 |
if ( th ) th->Delete(); |
if ( th ) th->Delete(); |
| 1339 |
}; |
}; |
| 1340 |
// |
// |
| 1341 |
delete lfit; |
// delete lfit; |
| 1342 |
// |
// |
| 1343 |
}; |
}; |
| 1344 |
|
|