--- calo/flight/CaloProfile/src/CaloProfile.cpp 2008/12/18 21:05:53 1.3 +++ calo/flight/CaloProfile/src/CaloProfile.cpp 2009/06/10 13:00:23 1.4 @@ -602,7 +602,7 @@ eplane[view][plane] += mip; }; // - // inclination factor (steal from Daniele's code) + // inclination factor (stolen from Daniele's code) // Float_t ytgx = 0; Float_t ytgy = 0; @@ -706,20 +706,34 @@ // th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax); th = new TH1F(thid,thid,100,-0.2,xmax); // - for (Int_t st=N;st<(N+NC);st++){ + // AGH, BUG! + // + Int_t mmin = 0; + Int_t mmax = 0; + if ( cont ){ + mmin = N; + mmax = NC+N; + } else { + mmin = 0; + mmax = NC; + }; + // + Float_t qtotparz = 0.; + for (Int_t st=mmin;st N && st < (N+NC-1) ){ + xpos = (st - mmin) * X0pl; + if ( st > mmin && st < mmax ){ if ( no18x && ( st == 18+1 || st == mask18b+1 )){ enemip = 2. * eplane[1][st]; } else { enemip = eplane[0][st-1] + eplane[1][st]; }; } else { - if ( st == N ) enemip = 2. * eplane[1][st]; - if ( st == (N+NC-1) ) enemip = 2. * eplane[0][st]; + if ( st == mmin ) enemip = 2. * eplane[1][st]; + if ( st == mmax ) enemip = 2. * eplane[0][st-1]; }; // + qtotparz += enemip; if ( enemip > 0. ){ th->Fill(xpos,enemip); if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip); @@ -750,7 +764,9 @@ }; // TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); - E0 = L2->GetCaloLevel2()->qtot; + if ( debug ) printf("qtot %f qtotparz %f \n",L2->GetCaloLevel2()->qtot,qtotparz); + E0 = qtotparz; + // E0 = L2->GetCaloLevel2()->qtot; a = 5.; b = 0.5; if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b); @@ -819,10 +835,19 @@ if ( debug ) printf(" i10max == imax, asymm undefined\n"); asymm = -2.; }; + if ( asymm != asymm ){ + if ( debug ) printf(" asymm is nan \n"); + asymm = -3.; + }; //lfit->Integral(0.,tmax)/(lfit->Integral(0.,10.*tmax)-lfit->Integral(0.,tmax)); if ( debug ) printf(" Asymmetry has been calculated \n"); }; // + if ( asymm < 0. || ndf <= 0. || chi2 < 0. || tmax < 0. ){ + if ( debug ) printf(" Funny asymm||ndf||chi2||tmax values, fit failed \n"); + fitresult = 100; + }; + // if ( draw ){ // tc->cd(); @@ -842,6 +867,8 @@ gStyle->SetLabelSize(0); gStyle->SetNdivisions(1,"XY"); // + } else { + if ( th ) th->Delete(); }; // delete lfit;