--- calo/flight/CaloProfile/src/CaloProfile.cpp 2009/08/12 14:57:00 1.10 +++ calo/flight/CaloProfile/src/CaloProfile.cpp 2009/08/13 15:56:39 1.11 @@ -671,6 +671,7 @@ umax = 100.; slmax = ""; sumax = ""; + xyaverage = true; // }; @@ -1074,13 +1075,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 +1108,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 +1215,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 +1231,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); // @@ -1259,7 +1321,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 +1338,7 @@ if ( th ) th->Delete(); }; // - delete lfit; + // delete lfit; // };