| 281 | PKT = 0; | PKT = 0; | 
| 282 | atime = 0; | atime = 0; | 
| 283 | // | // | 
| 284 |  | suf = ""; | 
| 285 | debug = false; | debug = false; | 
| 286 | // | // | 
| 287 | }; | }; | 
| 298 | PKT = 0; | PKT = 0; | 
| 299 | atime = 0; | atime = 0; | 
| 300 | // | // | 
| 301 |  | suf = ""; | 
| 302 | debug = false; | debug = false; | 
| 303 | // | // | 
| 304 | }; | }; | 
| 377 | // | // | 
| 378 | for (Int_t v=minv; v<maxv;v++){ | for (Int_t v=minv; v<maxv;v++){ | 
| 379 | for (Int_t p=minp; p<maxp;p++){ | for (Int_t p=minp; p<maxp;p++){ | 
| 380 | TString hid = Form("clatv%ip%i",v,p); | TString hid = Form("clatv%ip%i%s",v,p,suf.Data()); | 
| 381 | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | 
| 382 | if ( tc ){ | if ( tc ){ | 
| 383 | //       tc->Clear(); | //       tc->Clear(); | 
| 385 | tc = new TCanvas(hid,hid); | tc = new TCanvas(hid,hid); | 
| 386 | }; | }; | 
| 387 | // | // | 
| 388 | TString thid = Form("hlatv%ip%i",v,p); | TString thid = Form("hlatv%ip%i%s",v,p,suf.Data()); | 
| 389 | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | 
| 390 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 391 | //       th->Clear(); | //       th->Clear(); | 
| 428 | gStyle->SetNdivisions(510,"XY"); | gStyle->SetNdivisions(510,"XY"); | 
| 429 | // | // | 
| 430 | for (Int_t p=minp; p<maxp;p++){ | for (Int_t p=minp; p<maxp;p++){ | 
| 431 | TString hid = Form("c2dp%i",p); | TString hid = Form("c2dp%i%s",p,suf.Data()); | 
| 432 | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | 
| 433 | if ( tc ){ | if ( tc ){ | 
| 434 | //         tc->Clear(); | //         tc->Clear(); | 
| 436 | tc = new TCanvas(hid,hid); | tc = new TCanvas(hid,hid); | 
| 437 | }; | }; | 
| 438 | // | // | 
| 439 | TString thid = Form("h2dp%i",p); | TString thid = Form("h2dp%i%s",p,suf.Data()); | 
| 440 | TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid)); | TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid)); | 
| 441 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 442 | //   th->Clear(); | //   th->Clear(); | 
| 673 | umax = 100.; | umax = 100.; | 
| 674 | slmax = ""; | slmax = ""; | 
| 675 | sumax = ""; | sumax = ""; | 
| 676 |  | suf = ""; | 
| 677 |  | xyaverage = true; | 
| 678 |  | // | 
| 679 |  | letmax = -1; | 
| 680 |  | heavytail = false; | 
| 681 |  | lmipth = 100.; | 
| 682 | // | // | 
| 683 | }; | }; | 
| 684 |  |  | 
| 978 | // | // | 
| 979 | if ( vmax == 0 ) pmax++; | if ( vmax == 0 ) pmax++; | 
| 980 | etmax = pmax * X0pl; | etmax = pmax * X0pl; | 
| 981 |  | if ( letmax < 0. ) letmax = etmax; | 
| 982 | // | // | 
| 983 | if ( debug ) this->Print(); | if ( debug ) this->Print(); | 
| 984 | if ( debug ) printf(" exit \n"); | if ( debug ) printf(" exit \n"); | 
| 1003 | this->Fit(false); | this->Fit(false); | 
| 1004 | }; | }; | 
| 1005 |  |  | 
| 1006 | Float_t CaloLong::Evaluate(TString s, Float_t tmax){ | Float_t CaloLong::Evaluate(TString s, Float_t tmax, Float_t X0pl){ | 
| 1007 | /* SAMPLE OUTPUT: | /* SAMPLE OUTPUT: | 
| 1008 | Enter Infix Expression : A + B + C / (E - F) | Enter Infix Expression : A + B + C / (E - F) | 
| 1009 | Postfix Expression is : A B + C E F - / + | Postfix Expression is : A B + C E F - / + | 
| 1010 | */ | */ | 
| 1011 | if ( !s.Contains("t") ){ | if ( !s.Contains("tmax") && !s.Contains("X0pl") ){ | 
| 1012 | printf(" ERROR, the input formula must contain \"t\"\n"); | printf(" ERROR, the input formula must contain \"t\"\n"); | 
| 1013 | return 0.; | return 0.; | 
| 1014 | }; | }; | 
| 1017 | return 0.; | return 0.; | 
| 1018 | }; | }; | 
| 1019 | TString g=Form("%f",tmax); | TString g=Form("%f",tmax); | 
| 1020 |  | TString h=Form("%f",X0pl); | 
| 1021 | TString *ts= new TString(""); | TString *ts= new TString(""); | 
| 1022 | ts->Prepend(s.Data()); | ts->Prepend(s.Data()); | 
| 1023 | ts->ReplaceAll("t",1,g.Data(),g.Capacity()); | ts->ReplaceAll("tmax",4,g.Data(),g.Capacity()); | 
| 1024 |  | ts->ReplaceAll("X0pl",4,h.Data(),h.Capacity()); | 
| 1025 | ts->Prepend("("); | ts->Prepend("("); | 
| 1026 | ts->Append(")"); | ts->Append(")"); | 
| 1027 | if ( debug )  printf(" ts %s tssize %i capac %i s %s g %s \n",ts->Data(),ts->Sizeof(),ts->Capacity(),s.Data(),g.Data()); | if ( debug )  printf(" ts %s tssize %i capac %i s %s g %s \n",ts->Data(),ts->Sizeof(),ts->Capacity(),s.Data(),g.Data()); | 
| 1074 | gStyle->SetNdivisions(510,"XY"); | gStyle->SetNdivisions(510,"XY"); | 
| 1075 | }; | }; | 
| 1076 | // | // | 
| 1077 | TString hid = Form("clongfit"); | TString hid = Form("clongfit%s",suf.Data()); | 
| 1078 | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | 
| 1079 | //  if ( tc ) tc->Delete(); | //  if ( tc ) tc->Delete(); | 
| 1080 | //  if ( tc ) tc->Close(); | //  if ( tc ) tc->Close(); | 
| 1084 | if ( tc ) tc->cd(); | if ( tc ) tc->cd(); | 
| 1085 | }; | }; | 
| 1086 | // | // | 
| 1087 | TString thid = Form("hlongfit"); | TString thid = Form("hlongfit%s",suf.Data()); | 
| 1088 | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid)); | 
| 1089 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 1090 |  | // | 
| 1091 |  | TString ghid = Form("glongfit%s",suf.Data()); | 
| 1092 |  | TGraphErrors *gh  = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid)); | 
| 1093 |  | if ( gh ) gh->Delete(); | 
| 1094 |  | // | 
| 1095 | Float_t xpos = 0.; | Float_t xpos = 0.; | 
| 1096 | Float_t enemip = 0.; | Float_t enemip = 0.; | 
| 1097 | Float_t xmax = NC * X0pl + 0.2; | Float_t xmax = NC * X0pl + 0.2; | 
| 1098 | //  th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax); | // | 
| 1099 | th = new TH1F(thid,thid,100,-0.2,xmax); | Double_t xxx[50]; | 
| 1100 |  | Double_t exx[50]; | 
| 1101 |  | Double_t yyy[50]; | 
| 1102 |  | Double_t eyy[50]; | 
| 1103 |  | Int_t numpo = 0; | 
| 1104 |  | memset(xxx,0,50*sizeof(Double_t)); | 
| 1105 |  | memset(exx,0,50*sizeof(Double_t)); | 
| 1106 |  | memset(yyy,0,50*sizeof(Double_t)); | 
| 1107 |  | memset(eyy,0,50*sizeof(Double_t)); | 
| 1108 | // | // | 
| 1109 | // AGH, BUG! | // AGH, BUG! | 
| 1110 | // | // | 
| 1118 | mmax = NC; | mmax = NC; | 
| 1119 | }; | }; | 
| 1120 | // | // | 
| 1121 |  | Float_t emax = 0.; | 
| 1122 | Float_t qtotparz = 0.; | Float_t qtotparz = 0.; | 
| 1123 | for (Int_t st=mmin;st<mmax+1;st++){ | for (Int_t st=mmin;st<mmax+1;st++){ | 
| 1124 | enemip = 0.; | enemip = 0.; | 
| 1125 | xpos = (st - mmin) * X0pl; | xpos = (st - mmin) * X0pl; | 
| 1126 | if ( st > mmin && st < mmax ){ | // | 
| 1127 | if ( no18x && ( st == 18+1 || st == mask18b+1 )){ | if ( xyaverage ){ | 
| 1128 | if ( !maskYO ){ | // | 
| 1129 | enemip = 2. * eplane[1][st]; | if ( st > mmin && st < mmax ){ | 
| 1130 |  | if ( no18x && ( st == 18+1 || st == mask18b+1 )){ | 
| 1131 |  | if ( !maskYO ){ | 
| 1132 |  | enemip = 2. * eplane[1][st]; | 
| 1133 |  | } else { | 
| 1134 |  | enemip = eplane[1][st]; | 
| 1135 |  | }; | 
| 1136 | } else { | } else { | 
| 1137 | enemip = eplane[1][st]; | enemip = eplane[0][st-1] + eplane[1][st]; | 
| 1138 | }; | }; | 
| 1139 | } else { | } else { | 
| 1140 | enemip = eplane[0][st-1] + eplane[1][st]; | if ( st == mmin ){ | 
| 1141 |  | if ( !maskYE ){ | 
| 1142 |  | enemip = 2. * eplane[1][st]; | 
| 1143 |  | } else { | 
| 1144 |  | enemip = eplane[1][st]; | 
| 1145 |  | }; | 
| 1146 |  | }; | 
| 1147 |  | if ( st == mmax ){ | 
| 1148 |  | if ( !maskXE ){ | 
| 1149 |  | enemip = 2. * eplane[0][st-1]; | 
| 1150 |  | } else { | 
| 1151 |  | enemip = eplane[0][st-1]; | 
| 1152 |  | }; | 
| 1153 |  | }; | 
| 1154 |  | }; | 
| 1155 |  | // | 
| 1156 |  | qtotparz += enemip; | 
| 1157 |  | if ( enemip > emax ) emax = enemip; | 
| 1158 |  | if ( enemip > 0. ){ | 
| 1159 |  | xxx[numpo] = xpos; | 
| 1160 |  | exx[numpo] = 0.1; | 
| 1161 |  | yyy[numpo] = enemip; | 
| 1162 |  | eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); | 
| 1163 |  | if ( xpos > letmax && enemip > lmipth && heavytail) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo; | 
| 1164 |  | numpo++; | 
| 1165 |  | //      th->Fill(xpos,enemip); | 
| 1166 |  | if ( debug ) printf(" AVE Filling: st %i xpos %f energy %f \n",st,xpos,enemip); | 
| 1167 | }; | }; | 
| 1168 | } else { | } else { | 
| 1169 | if ( st == mmin ){ | for (Int_t jj=0; jj<2; jj++){ | 
| 1170 | if ( !maskYE ){ | if ( st > mmin && st < mmax ){ | 
| 1171 | enemip = 2. * eplane[1][st]; | if ( jj == 0 && no18x && ( st == 18+1 || st == mask18b+1 )){ | 
| 1172 |  | enemip = eplane[1][st]; | 
| 1173 |  | } else { | 
| 1174 |  | if ( jj == 0 ){ | 
| 1175 |  | enemip = eplane[jj][st-1]; | 
| 1176 |  | } else { | 
| 1177 |  | enemip = eplane[jj][st]; | 
| 1178 |  | }; | 
| 1179 |  | }; | 
| 1180 | } else { | } else { | 
| 1181 | enemip = eplane[1][st]; | if ( st == mmin && jj == 1 ){ | 
| 1182 |  | enemip = eplane[jj][st]; | 
| 1183 |  | }; | 
| 1184 |  | if ( st == mmax && jj == 0){ | 
| 1185 |  | enemip = eplane[jj][st-1]; | 
| 1186 |  | }; | 
| 1187 | }; | }; | 
| 1188 | }; | // | 
| 1189 | if ( st == mmax ){ | qtotparz += enemip; | 
| 1190 | if ( !maskXE ){ | if ( enemip > emax ) emax = enemip; | 
| 1191 | enemip = 2. * eplane[0][st-1]; | if ( enemip > 0. ){ | 
| 1192 | } else { | xxx[numpo] = xpos; | 
| 1193 | enemip = eplane[0][st-1]; | exx[numpo] = 0.1; | 
| 1194 |  | yyy[numpo] = enemip; | 
| 1195 |  | eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); | 
| 1196 |  | if ( xpos > letmax && enemip > lmipth && heavytail ) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo; | 
| 1197 |  | //      eyy[numpo] = sqrt(enemip)/(st*0.95); | 
| 1198 |  | numpo++; | 
| 1199 |  | //      th->Fill(xpos,enemip); | 
| 1200 |  | if ( debug ) printf(" XY Filling: st %i xpos %f energy %f \n",st,xpos,enemip); | 
| 1201 | }; | }; | 
| 1202 | }; | }; | 
|  | }; |  | 
|  | // |  | 
|  | qtotparz += enemip; |  | 
|  | if ( enemip > 0. ){ |  | 
|  | th->Fill(xpos,enemip); |  | 
|  | if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip); |  | 
| 1203 | }; | }; | 
| 1204 |  |  | 
| 1205 | // | // | 
| 1206 | //    for (Int_t v=1; v>=0;v--)// { | //    for (Int_t v=1; v>=0;v--)// { | 
| 1207 | //       // | //       // | 
| 1227 | //     }; | //     }; | 
| 1228 | }; | }; | 
| 1229 | // | // | 
| 1230 | TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); | //  th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax); | 
| 1231 |  | th = new TH2F(thid,thid,1000,-0.2,xmax,1000,0.,emax*1.2); | 
| 1232 |  | gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy); | 
| 1233 |  | TString fnam=Form("lfit%s",suf.Data()); | 
| 1234 |  | TF1 *lfit  = dynamic_cast<TF1*>(gDirectory->FindObject(fnam)); | 
| 1235 |  | if ( lfit ) lfit->Delete(); | 
| 1236 |  | lfit = new TF1(fnam,ccurve,0.,xmax,3); | 
| 1237 | if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); | if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); | 
| 1238 | E0 = qtotparz; | E0 = qtotparz; | 
| 1239 | //  E0 = clp->qtot; | //  E0 = clp->qtot; | 
| 1244 | //  lfit->SetParLimits(0,0.,1000.); | //  lfit->SetParLimits(0,0.,1000.); | 
| 1245 | //  lfit->SetParLimits(1,-1.,80.); | //  lfit->SetParLimits(1,-1.,80.); | 
| 1246 | //  lfit->SetParLimits(2,-1.,10.); | //  lfit->SetParLimits(2,-1.,10.); | 
| 1247 | TString optio; | // TString optio = "ROW"; // "RO" | 
| 1248 |  | TString optio = "RO"; // "RO" | 
| 1249 | if ( debug ){ | if ( debug ){ | 
| 1250 | //    optio = "MERBOV"; | optio += "NV"; | 
| 1251 | //    optio = "MEROV"; | if ( draw ) optio += "V"; | 
|  | //    optio = "EROV"; |  | 
|  | optio = "RNOV"; |  | 
|  | if ( draw ) optio = "ROV"; |  | 
| 1252 | } else { | } else { | 
| 1253 | //    optio = "MERNOQ"; | optio += "NQ"; | 
| 1254 | //    optio = "ERNOQ"; | if ( draw ) optio += "Q"; | 
|  | optio = "RNOQ"; |  | 
|  | if ( draw ) optio = "ROQ"; |  | 
| 1255 | }; | }; | 
| 1256 | // | // | 
| 1257 | if ( debug ) printf(" OK, start the fitting procedure...\n"); | if ( debug ) printf(" OK, start the fitting procedure... options: %s \n",optio.Data()); | 
| 1258 | // | // | 
| 1259 | fitresult = th->Fit("lfit",optio); | //  fitresult = th->Fit("lfit",optio); | 
| 1260 |  | fitresult = gh->Fit("lfit",optio); | 
| 1261 | // | // | 
| 1262 | if ( debug ) printf(" the fit is done! result: %i \n",fitresult); | if ( debug ) printf(" the fit is done! result: %i \n",fitresult); | 
| 1263 | // | // | 
| 1278 | asymm = -1.; | asymm = -1.; | 
| 1279 | defE0 = -1.; | defE0 = -1.; | 
| 1280 | } else { | } else { | 
| 1281 | if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax); | if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax,X0pl); | 
| 1282 | if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax); | if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax,X0pl); | 
| 1283 | Int_t npp = 1000; | Int_t npp = 1000; | 
| 1284 | double *xpp=new double[npp]; | double *xpp=new double[npp]; | 
| 1285 | double *wpp=new double[npp]; | double *wpp=new double[npp]; | 
| 1334 | // axis titles | // axis titles | 
| 1335 | th->SetXTitle("Depth [X0]"); | th->SetXTitle("Depth [X0]"); | 
| 1336 | th->SetYTitle("Energy [MIP]"); | th->SetYTitle("Energy [MIP]"); | 
| 1337 | th->DrawCopy("Perror"); | //    th->DrawCopy("Perror"); | 
| 1338 |  | th->DrawCopy(); | 
| 1339 |  | gh->SetMarkerSize(1.); | 
| 1340 |  | gh->SetMarkerStyle(21); | 
| 1341 |  | //    gh->SetMarkerColor(kRed); | 
| 1342 |  | gh->Draw("Psame"); | 
| 1343 | lfit->Draw("same"); | lfit->Draw("same"); | 
| 1344 | tc->Modified(); | tc->Modified(); | 
| 1345 | tc->Update(); | tc->Update(); | 
| 1351 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 1352 | }; | }; | 
| 1353 | // | // | 
| 1354 | delete lfit; | //  delete lfit; | 
| 1355 | // | // | 
| 1356 | }; | }; | 
| 1357 |  |  | 
| 1380 | // | // | 
| 1381 | if ( maxv != -1 ){ | if ( maxv != -1 ){ | 
| 1382 | for (Int_t v=minv; v<maxv;v++){ | for (Int_t v=minv; v<maxv;v++){ | 
| 1383 | TString hid = Form("clongv%i",v); | TString hid = Form("clongv%i%s",v,suf.Data()); | 
| 1384 | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | 
| 1385 | if ( tc ){ | if ( tc ){ | 
| 1386 | //       tc->Clear(); | //       tc->Clear(); | 
| 1388 | tc = new TCanvas(hid,hid); | tc = new TCanvas(hid,hid); | 
| 1389 | }; | }; | 
| 1390 | // | // | 
| 1391 | TString thid = Form("hlongv%i",v); | TString thid = Form("hlongv%i%s",v,suf.Data()); | 
| 1392 | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | 
| 1393 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 1394 | //         th->Clear(); | //         th->Clear(); | 
| 1407 | }; | }; | 
| 1408 | } else { | } else { | 
| 1409 | // | // | 
| 1410 | TString hid = Form("clongvyvx"); | TString hid = Form("clongvyvx%s",suf.Data()); | 
| 1411 | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid)); | 
| 1412 | if ( tc ){ | if ( tc ){ | 
| 1413 | } else { | } else { | 
| 1414 | tc = new TCanvas(hid,hid); | tc = new TCanvas(hid,hid); | 
| 1415 | }; | }; | 
| 1416 | // | // | 
| 1417 | TString thid = Form("hlongvyvx"); | TString thid = Form("hlongvyvx%s",suf.Data()); | 
| 1418 | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid)); | 
| 1419 | if ( th ) th->Delete(); | if ( th ) th->Delete(); | 
| 1420 | th = new TH1F(thid,thid,44,-0.5,43.5); | th = new TH1F(thid,thid,44,-0.5,43.5); |