--- calo/flight/CaloProfile/src/CaloProfile.cpp 2009/08/12 14:57:00 1.10 +++ calo/flight/CaloProfile/src/CaloProfile.cpp 2009/08/17 15:00:36 1.12 @@ -671,6 +671,7 @@ umax = 100.; slmax = ""; sumax = ""; + xyaverage = true; // }; @@ -994,12 +995,12 @@ this->Fit(false); }; -Float_t CaloLong::Evaluate(TString s, Float_t tmax){ +Float_t CaloLong::Evaluate(TString s, Float_t tmax, Float_t X0pl){ /* SAMPLE OUTPUT: Enter Infix Expression : A + B + C / (E - F) Postfix Expression is : A B + C E F - / + */ - if ( !s.Contains("t") ){ + if ( !s.Contains("tmax") && !s.Contains("X0pl") ){ printf(" ERROR, the input formula must contain \"t\"\n"); return 0.; }; @@ -1008,9 +1009,11 @@ return 0.; }; TString g=Form("%f",tmax); + TString h=Form("%f",X0pl); TString *ts= new TString(""); ts->Prepend(s.Data()); - ts->ReplaceAll("t",1,g.Data(),g.Capacity()); + ts->ReplaceAll("tmax",4,g.Data(),g.Capacity()); + ts->ReplaceAll("X0pl",4,h.Data(),h.Capacity()); ts->Prepend("("); ts->Append(")"); 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,13 +1077,26 @@ }; // TString thid = Form("hlongfit"); - TH1F *th = dynamic_cast(gDirectory->FindObject(thid)); + TH2F *th = dynamic_cast(gDirectory->FindObject(thid)); if ( th ) th->Delete(); + // + TString ghid = Form("glongfit"); + TGraphErrors *gh = dynamic_cast(gDirectory->FindObject(ghid)); + if ( gh ) gh->Delete(); + // Float_t xpos = 0.; Float_t enemip = 0.; Float_t xmax = NC * X0pl + 0.2; - // th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax); - th = new TH1F(thid,thid,100,-0.2,xmax); + // + Double_t xxx[50]; + Double_t exx[50]; + Double_t yyy[50]; + Double_t eyy[50]; + Int_t numpo = 0; + memset(xxx,0,50*sizeof(Double_t)); + memset(exx,0,50*sizeof(Double_t)); + memset(yyy,0,50*sizeof(Double_t)); + memset(eyy,0,50*sizeof(Double_t)); // // AGH, BUG! // @@ -1094,42 +1110,88 @@ mmax = NC; }; // + Float_t emax = 0.; Float_t qtotparz = 0.; for (Int_t st=mmin;st mmin && st < mmax ){ - if ( no18x && ( st == 18+1 || st == mask18b+1 )){ - if ( !maskYO ){ - enemip = 2. * eplane[1][st]; + // + if ( xyaverage ){ + // + if ( st > mmin && st < mmax ){ + if ( no18x && ( st == 18+1 || st == mask18b+1 )){ + if ( !maskYO ){ + enemip = 2. * eplane[1][st]; + } else { + enemip = eplane[1][st]; + }; } else { - enemip = eplane[1][st]; + enemip = eplane[0][st-1] + eplane[1][st]; }; } else { - enemip = eplane[0][st-1] + eplane[1][st]; + if ( st == mmin ){ + if ( !maskYE ){ + enemip = 2. * eplane[1][st]; + } else { + enemip = eplane[1][st]; + }; + }; + if ( st == mmax ){ + if ( !maskXE ){ + enemip = 2. * eplane[0][st-1]; + } else { + enemip = eplane[0][st-1]; + }; + }; + }; + // + qtotparz += enemip; + if ( enemip > emax ) emax = enemip; + if ( enemip > 0. ){ + xxx[numpo] = xpos; + exx[numpo] = 0.1; + yyy[numpo] = enemip; + eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); + numpo++; + // th->Fill(xpos,enemip); + if ( debug ) printf(" AVE Filling: st %i xpos %f energy %f \n",st,xpos,enemip); }; } else { - if ( st == mmin ){ - if ( !maskYE ){ - enemip = 2. * eplane[1][st]; + for (Int_t jj=0; jj<2; jj++){ + if ( st > mmin && st < mmax ){ + if ( jj == 0 && no18x && ( st == 18+1 || st == mask18b+1 )){ + enemip = eplane[1][st]; + } else { + if ( jj == 0 ){ + enemip = eplane[jj][st-1]; + } else { + enemip = eplane[jj][st]; + }; + }; } else { - enemip = eplane[1][st]; + if ( st == mmin && jj == 1 ){ + enemip = eplane[jj][st]; + }; + if ( st == mmax && jj == 0){ + enemip = eplane[jj][st-1]; + }; }; - }; - if ( st == mmax ){ - if ( !maskXE ){ - enemip = 2. * eplane[0][st-1]; - } else { - enemip = eplane[0][st-1]; + // + qtotparz += enemip; + if ( enemip > emax ) emax = enemip; + if ( enemip > 0. ){ + xxx[numpo] = xpos; + exx[numpo] = 0.1; + yyy[numpo] = enemip; + eyy[numpo] = sqrt(enemip*3.)+sqrt(5.); + // eyy[numpo] = sqrt(enemip)/(st*0.95); + numpo++; + // th->Fill(xpos,enemip); + if ( debug ) printf(" XY Filling: st %i xpos %f energy %f \n",st,xpos,enemip); }; - }; - }; - // - qtotparz += enemip; - if ( enemip > 0. ){ - th->Fill(xpos,enemip); - if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip); + }; }; + // // for (Int_t v=1; v>=0;v--)// { // // @@ -1155,7 +1217,12 @@ // }; }; // - TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); + // th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax); + th = new TH2F(thid,thid,1000,-0.2,xmax,1000,0.,emax*1.2); + gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy); + TF1 *lfit = dynamic_cast(gDirectory->FindObject("lfit")); + if ( lfit ) lfit->Delete(); + lfit = new TF1("lfit",ccurve,0.,xmax,3); if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); E0 = qtotparz; // E0 = clp->qtot; @@ -1166,23 +1233,20 @@ // lfit->SetParLimits(0,0.,1000.); // lfit->SetParLimits(1,-1.,80.); // lfit->SetParLimits(2,-1.,10.); - TString optio; + // TString optio = "ROW"; // "RO" + TString optio = "RO"; // "RO" if ( debug ){ - // optio = "MERBOV"; - // optio = "MEROV"; - // optio = "EROV"; - optio = "RNOV"; - if ( draw ) optio = "ROV"; - } else { - // optio = "MERNOQ"; - // optio = "ERNOQ"; - optio = "RNOQ"; - if ( draw ) optio = "ROQ"; + optio += "NV"; + if ( draw ) optio += "V"; + } else { + optio += "NQ"; + if ( draw ) optio += "Q"; }; // if ( debug ) printf(" OK, start the fitting procedure...\n"); // - fitresult = th->Fit("lfit",optio); + // fitresult = th->Fit("lfit",optio); + fitresult = gh->Fit("lfit",optio); // if ( debug ) printf(" the fit is done! result: %i \n",fitresult); // @@ -1203,8 +1267,8 @@ asymm = -1.; defE0 = -1.; } else { - if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax); - if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax); + if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax,X0pl); + if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax,X0pl); Int_t npp = 1000; double *xpp=new double[npp]; double *wpp=new double[npp]; @@ -1259,7 +1323,12 @@ // axis titles th->SetXTitle("Depth [X0]"); th->SetYTitle("Energy [MIP]"); - th->DrawCopy("Perror"); + // th->DrawCopy("Perror"); + th->DrawCopy(); + gh->SetMarkerSize(1.); + gh->SetMarkerStyle(21); + // gh->SetMarkerColor(kRed); + gh->Draw("Psame"); lfit->Draw("same"); tc->Modified(); tc->Update(); @@ -1271,7 +1340,7 @@ if ( th ) th->Delete(); }; // - delete lfit; + // delete lfit; // };