--- calo/flight/CaloProfile/src/CaloProfile.cpp 2008/09/22 20:08:25 1.2 +++ calo/flight/CaloProfile/src/CaloProfile.cpp 2009/06/24 14:12:55 1.6 @@ -459,9 +459,21 @@ // no18x = true; debug = false; + maskXE = false; + maskXO = false; + maskYE = false; + maskYO = false; // }; +void CaloLong::MaskSection(TString sec){ + sec.ToUpper(); + if ( sec.Contains("XO") ) maskXO = true; + if ( sec.Contains("YO") ) maskYO = true; + if ( sec.Contains("XE") ) maskXE = true; + if ( sec.Contains("YE") ) maskYE = true; +} + void CaloLong::Clear(){ // memset(eplane,0, 2*22*sizeof(Float_t)); @@ -484,7 +496,7 @@ void CaloLong::Print(){ // - Process(); + Fit(); // printf("==================== Calorimeter Longitudinal Profile =======================\n"); printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime); @@ -532,6 +544,18 @@ }; } +void CaloLong::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ + this->SetNoWpreSampler(0); + this->SetNoWcalo(0); + if ( NoWpreSampler < NoWcalo ){ + this->SetNoWpreSampler(NoWpreSampler); + this->SetNoWcalo(NoWcalo); + } else { + this->SetNoWcalo(NoWcalo); + this->SetNoWpreSampler(NoWpreSampler); + }; +} + void CaloLong::Process(){ // if ( !L2 ){ @@ -585,12 +609,18 @@ Int_t plane = 0; Int_t strip = 0; Float_t mip = 0.; + Bool_t gof = true; for (Int_t i=0; i < L2->GetCaloLevel1()->istrip; i++){ mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); - eplane[view][plane] += mip; + gof = true; + if ( maskXE && (plane%2)==0 && view==1 ) gof = false; + if ( maskXO && (plane%2)!=0 && view==1 ) gof = false; + if ( maskYE && (plane%2)!=0 && view==0 ) gof = false; + if ( maskYO && (plane%2)==0 && view==0 ) gof = false; + if ( gof ) 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; @@ -694,20 +724,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); @@ -738,7 +782,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); @@ -807,10 +853,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(); @@ -830,6 +885,8 @@ gStyle->SetLabelSize(0); gStyle->SetNdivisions(1,"XY"); // + } else { + if ( th ) th->Delete(); }; // delete lfit;