--- calo/flight/CaloProfile/src/CaloProfile.cpp 2009/06/24 14:12:55 1.6 +++ calo/flight/CaloProfile/src/CaloProfile.cpp 2009/08/11 14:23:09 1.8 @@ -451,6 +451,8 @@ PKT = 0; atime = 0; // + clp = L2->GetCaloLevel2(); + // sel = true; cont = false; N = 0; @@ -474,6 +476,18 @@ if ( sec.Contains("YE") ) maskYE = true; } +void CaloLong::UnMaskSections(){ + this->UnMaskSection("XEXOYEYO"); +} + +void CaloLong::UnMaskSection(TString sec){ + sec.ToUpper(); + if ( sec.Contains("XO") ) maskXO = false; + if ( sec.Contains("YO") ) maskYO = false; + if ( sec.Contains("XE") ) maskXE = false; + if ( sec.Contains("YE") ) maskYE = false; +} + void CaloLong::Clear(){ // memset(eplane,0, 2*22*sizeof(Float_t)); @@ -624,8 +638,8 @@ // Float_t ytgx = 0; Float_t ytgy = 0; - ytgx = 0.76 * L2->GetCaloLevel2()->tanx[0]; - ytgy = 0.76 * L2->GetCaloLevel2()->tany[0]; + ytgx = 0.76 * clp->tanx[0]; + ytgy = 0.76 * clp->tany[0]; X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) ); // // Find experimental plane of maximum @@ -653,6 +667,102 @@ // }; +void CaloLong::SetEnergies(Float_t myene[][22]){ + // + if ( !L2 ){ + printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); + printf(" ERROR: CaloHough variables not filled \n"); + return; + }; + // + Bool_t newentry = false; + // + if ( L2->IsORB() ){ + if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime ){ + newentry = true; + OBT = L2->GetOrbitalInfo()->OBT; + PKT = L2->GetOrbitalInfo()->pkt_num; + atime = L2->GetOrbitalInfo()->absTime; + }; + } else { + newentry = true; + }; + // + if ( !newentry ) return; + // + if ( debug ) printf(" SET ENERGIES Start processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); + // + Clear(); + // + // let's start + // + if ( cont ){ + for (Int_t i=0; i<22; i++){ + if ( i == (18+N) ){ + mask18b = 18 + N; + break; + }; + }; + }; + // + if ( sel ){ + for (Int_t i=0; i<22; i++){ + if ( i == (18-N) ){ + mask18b = 18 - N; + break; + }; + }; + }; + // + // if ( mask18b == 18 ) mask18b = -1; + // + Int_t view = 0; + Int_t plane = 0; + Bool_t gof = true; + for (view=0; view < 2; view++){ + for (plane=0; plane < 22; plane++){ + 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] = myene[view][plane]; + if ( debug ) printf(" XE %i XO %i YE %i YO %i eplane %i %i = %f ........... myene %i %i = %f\n", maskXE, maskXO, maskYE, maskYO,view,plane,eplane[view][plane],view,plane,myene[view][plane]); + }; + }; + // + // inclination factor (stolen from Daniele's code) + // + Float_t ytgx = 0; + Float_t ytgy = 0; + ytgx = 0.76 * clp->tanx[0]; + ytgy = 0.76 * clp->tany[0]; + X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) ); + // + // Find experimental plane of maximum + // + Int_t pmax = 0; + Int_t vmax = 0; + Float_t emax = 0.; + for (Int_t v=0; v<2; v++){ + for (Int_t i=0; i<22; i++){ + if ( eplane[v][i] > emax ){ + emax = eplane[v][i]; + vmax = v; + pmax = i; + }; + }; + }; + // + // + // + if ( vmax == 0 ) pmax++; + etmax = pmax * X0pl; + // + if ( debug ) this->Print(); + if ( debug ) printf(" exit \n"); + // +}; Double_t ccurve(Double_t *ti,Double_t *par){ // @@ -742,13 +852,29 @@ xpos = (st - mmin) * X0pl; if ( st > mmin && st < mmax ){ if ( no18x && ( st == 18+1 || st == mask18b+1 )){ - enemip = 2. * eplane[1][st]; + if ( !maskYO ){ + enemip = 2. * eplane[1][st]; + } else { + enemip = eplane[1][st]; + }; } else { enemip = eplane[0][st-1] + eplane[1][st]; }; } else { - if ( st == mmin ) enemip = 2. * eplane[1][st]; - if ( st == mmax ) enemip = 2. * eplane[0][st-1]; + 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; @@ -782,9 +908,9 @@ }; // TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); - if ( debug ) printf("qtot %f qtotparz %f \n",L2->GetCaloLevel2()->qtot,qtotparz); + if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz); E0 = qtotparz; - // E0 = L2->GetCaloLevel2()->qtot; + // E0 = clp->qtot; a = 5.; b = 0.5; if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b);