--- calo/flight/CaloEnergy/src/CaloEnergy.cpp 2009/08/12 14:54:52 1.8 +++ calo/flight/CaloEnergy/src/CaloEnergy.cpp 2009/08/21 07:06:37 1.14 @@ -35,6 +35,21 @@ // } +void CaloEnergy::Delete(){ + Clear(); + delete this; +} + +void CaloEnergy::UseLevel2(){ + if ( clong ){ + delete clong; + clong = new CaloLong(L2); + clong->SplitInto(0,22); + }; + if ( cp ) delete cp; + cp = NULL; +} + void CaloEnergy::UseCaloPreSampler(){ // // use the presampler setting forcefitmode to 1000 means to force the DV routine to find the track inside the calorimeter using the "shower" approach developed for electrons @@ -79,6 +94,7 @@ // indep = false; // + fAllpl = true; fLong = false; fPl = 1; fRad = -1; @@ -86,6 +102,8 @@ clong = NULL; x0max = -1.; // + multicol = false; + // this->DefineGeometry(); fXosel =true; fXesel = true; @@ -99,99 +117,18 @@ fXemin = 1000; fYomin = 1000; fYemin = 1000; + // + this->UseCaloPreSampler(); // use it by default, to go back to "standard" mode use CaloEnergy::UseLevel2(). + // } - -void CaloEnergy::SetMinimumContainment(TString section, Int_t plane){ - section.ToUpper(); - if ( section.Contains("XO") ) fXomin = plane; - if ( section.Contains("XE") ) fXemin = plane; - if ( section.Contains("YO") ) fYomin = plane; - if ( section.Contains("YE") ) fYemin = plane; -} - -void CaloEnergy::SetMinimumContainment(Int_t plane){ - this->SetMinimumContainment("XEXOYEYO",plane); -} - -Int_t CaloEnergy::GetMinimumContainment(TString section){ - section.ToUpper(); - if ( section.Contains("XO") ) return(fXomin); - if ( section.Contains("XE") ) return(fXemin); - if ( section.Contains("YE") ) return(fYemin); - if ( section.Contains("YO") ) return(fYomin); - printf(" ERROR: section not recognized \n"); - return(-1000); -} - -void CaloEnergy::SetConversionFactor(TString section, Float_t conv){ - section.ToUpper(); - if ( section.Contains("XO") ) fConv_rxo = conv; - if ( section.Contains("XE") ) fConv_rxe = conv; - if ( section.Contains("YO") ) fConv_ryo = conv; - if ( section.Contains("YE") ) fConv_rye = conv; -} - -void CaloEnergy::SetConversionFactor(Float_t conv){ - this->SetConversionFactor("XEXOYEYO",conv); -} - -Float_t CaloEnergy::GetConversionFactor(TString section){ - section.ToUpper(); - if ( section.Contains("XO") ) return(fConv_rxo); - if ( section.Contains("XE") ) return(fConv_rxe); - if ( section.Contains("YO") ) return(fConv_ryo); - if ( section.Contains("YE") ) return(fConv_rye); - printf(" ERROR: section not recognized \n"); - return(-1000.); -} - -Int_t CaloEnergy::GetMaxplane(TString section){ - section.ToUpper(); - if ( section.Contains("XO") ) return fMax_planexo; - if ( section.Contains("XE") ) return fMax_planexe; - if ( section.Contains("YO") ) return fMax_planeyo; - if ( section.Contains("YE") ) return fMax_planeye; - return(-1); -} - -Float_t CaloEnergy::GetEnergyAtMaxplane(TString section){ - section.ToUpper(); - if ( section.Contains("XO") ) return xomax_en; - if ( section.Contains("XE") ) return xemax_en; - if ( section.Contains("YO") ) return yomax_en; - if ( section.Contains("YE") ) return yemax_en; - return(-1); -} - -Float_t CaloEnergy::GetMaxEnergy(TString section){ - section.ToUpper(); - if ( fLong ){ - this->Process(section); - return fXOen_maxplane; - } else { - if ( section.Contains("XO") ) return fXOen_maxplane; - if ( section.Contains("XE") ) return fXEen_maxplane; - if ( section.Contains("YO") ) return fYOen_maxplane; - if ( section.Contains("YE") ) return fYEen_maxplane; - }; - return(-1); -} - -Float_t CaloEnergy::GetMaxEnergy(){ - if ( fLong ){ - if ( debug ) printf(" oh! call process! with asntr %s and sntr %s \n",asntr.Data(),sntr.Data()); - this->Process(asntr); - }; - return((fXEen_maxplane+fYOen_maxplane+fYEen_maxplane+fXOen_maxplane)); -} - void CaloEnergy::DefineGeometry(){ // // Use CaloStrip to determine once the position of border strips for each section // - // - fM = 2. + 0.096; // real position from cbar - fM1 = 2. - 0.122 - 0.096; // due to calculation of xe1 etc. + // fM = 2. + 0.096; // real position from cbar BUG the 0.096 is already taken into account in the border calculation made by Giovanna + fM = 2. ; // real position from cbar + // fM1 = 2. - 0.122 - 0.096; // due to calculation of xe1 etc. BUG! this way we count from the silicon border not from the silicon sensitive area + fM1 = 2. - 0.122 - 0.096 + 0.096; // due to calculation of xe1 etc. if ( fM1 < 0. ) fM1 = 0.; // CaloStrip *cs = new CaloStrip(fSimu); @@ -199,7 +136,6 @@ // view y plane 0 strip 0 cs->Set(1,0,0); xe1= cs->GetY(); - // z1= cs->GetZ(); // view y plane 0 strip 31 cs->Set(1,0,31); xe2= cs->GetY(); @@ -215,11 +151,9 @@ // view y plane 0 strip 95 cs->Set(1,0,95); xe6= cs->GetY(); - // view x plane 0 strip 0 cs->Set(0,0,0); yo1= cs->GetX(); - // z2= cs->GetZ(); // view x plane 0 strip 31 cs->Set(0,0,31); yo2= cs->GetX(); @@ -235,12 +169,9 @@ // view x plane 0 strip 95 cs->Set(0,0,95); yo6= cs->GetX(); - - // view y plane 1 strip 0 cs->Set(1,1,0); xo1= cs->GetY(); - // z3= cs->GetZ(); // view y plane 1 strip 31 cs->Set(1,1,31); xo2= cs->GetY(); @@ -255,12 +186,10 @@ xo5= cs->GetY(); // view y plane 1 strip 95 cs->Set(1,1,95); - xo6= cs->GetY(); - + xo6= cs->GetY(); // view x plane 1 strip 0 cs->Set(0,1,0); ye1= cs->GetX(); - // z4= cs->GetZ(); // view x plane 1 strip 31 cs->Set(0,1,31); ye2= cs->GetX(); @@ -276,7 +205,6 @@ // view x plane 1 strip 95 cs->Set(0,1,95); ye6= cs->GetX(); - // for (Int_t p = 0; p<22; p ++){ for (Int_t v = 0; v<2; v++ ){ @@ -315,7 +243,7 @@ yomax_en= 0.; yemax_en= 0.; // - memset(enstrip,0,2*22*96*(sizeof(Float_t))); + memset(enstrip,0,2*22*96*(sizeof(Float_t))); en = 0.; view = 0; plane = 0; @@ -337,6 +265,15 @@ memset(en_xop,0,11*sizeof(Float_t)); memset(en_yop,0,11*sizeof(Float_t)); // + fColumn = -1; + fColXE = -1; + fColXO = -1; + fColYE = -1; + fColYO = -1; + memset(encol,0,2*3*sizeof(Float_t)); + entot[0] = 0.; + entot[1] = 0.; + // } void CaloEnergy::Print(){ @@ -369,6 +306,16 @@ printf(" fM1 :.............. %f \n",fM1); printf(" fRad :.............. %i \n",fRad); printf(" fPl :.............. %i \n",fPl); + printf(" fColumn :.............. %i \n",fColumn); + printf(" multicol:.............. %i \n",multicol); + printf(" encol x :.............. %f \n",this->GetEncol(0)); + printf(" encol y :.............. %f \n",this->GetEncol(1)); + printf(" entot x :.............. %f \n",this->GetEntot(0)); + printf(" entot y :.............. %f \n",this->GetEntot(1)); + printf(" fColXE :.............. %i \n",fColXE); + printf(" fColXO :.............. %i \n",fColXO); + printf(" fColYE :.............. %i \n",fColYE); + printf(" fColYO :.............. %i \n",fColYO); printf(" fConv_rxe ............. %f \n",fConv_rxe); printf(" fConv_rxo ............. %f \n",fConv_rxo); printf(" fConv_ryo ............. %f \n",fConv_ryo); @@ -378,6 +325,10 @@ printf(" energyxo:.............. %f \n",energyxo); printf(" energyye:.............. %f \n",energyye); printf(" energyyo:.............. %f \n",energyyo); + printf(" fXEen_maxplane:........ %f \n",fXEen_maxplane); + printf(" fXOen_maxplane:........ %f \n",fXOen_maxplane); + printf(" fYEen_maxplane:........ %f \n",fYEen_maxplane); + printf(" fYOen_maxplane:........ %f \n",fYOen_maxplane); printf(" x0max :.............. %f \n",x0max); printf(" debug :.............. %i \n",debug); @@ -385,9 +336,130 @@ // } -void CaloEnergy::Delete(){ - Clear(); - delete this; +void CaloEnergy::SetMinimumContainment(TString section, Int_t plane){ + section.ToUpper(); + if ( section.Contains("XO") ) fXomin = plane; + if ( section.Contains("XE") ) fXemin = plane; + if ( section.Contains("YO") ) fYomin = plane; + if ( section.Contains("YE") ) fYemin = plane; +} + +void CaloEnergy::SetMinimumContainment(Int_t plane){ + this->SetMinimumContainment("XEXOYEYO",plane); +} + +void CaloEnergy::SetConversionFactor(TString section, Float_t conv){ + section.ToUpper(); + if ( section.Contains("XO") ) fConv_rxo = conv; + if ( section.Contains("XE") ) fConv_rxe = conv; + if ( section.Contains("YO") ) fConv_ryo = conv; + if ( section.Contains("YE") ) fConv_rye = conv; +} + +void CaloEnergy::SetConversionFactor(Float_t conv){ + this->SetConversionFactor("XEXOYEYO",conv); +} + +Int_t CaloEnergy::GetMinimumContainment(TString section){ + section.ToUpper(); + if ( section.Contains("XO") ) return(fXomin); + if ( section.Contains("XE") ) return(fXemin); + if ( section.Contains("YE") ) return(fYemin); + if ( section.Contains("YO") ) return(fYomin); + printf(" ERROR: section not recognized \n"); + return(-1000); +} + +Float_t CaloEnergy::GetConversionFactor(TString section){ + section.ToUpper(); + if ( section.Contains("XO") ) return(fConv_rxo); + if ( section.Contains("XE") ) return(fConv_rxe); + if ( section.Contains("YO") ) return(fConv_ryo); + if ( section.Contains("YE") ) return(fConv_rye); + printf(" ERROR: section not recognized \n"); + return(-1000.); +} + +Int_t CaloEnergy::GetMaxplane(TString section){ + section.ToUpper(); + if ( section.Contains("XO") ) return fMax_planexo; + if ( section.Contains("XE") ) return fMax_planexe; + if ( section.Contains("YO") ) return fMax_planeyo; + if ( section.Contains("YE") ) return fMax_planeye; + return(-1); +} + +Int_t CaloEnergy::GetColumn(TString section){ + section.ToUpper(); + if ( section.Contains("XO") ) return fColXO; + if ( section.Contains("XE") ) return fColXE; + if ( section.Contains("YO") ) return fColYO; + if ( section.Contains("YE") ) return fColYE; + return(-1); +} + +Float_t CaloEnergy::GetMipEnergyAtMaxplane(TString section){ + printf(" WARNING: OBSOLETE METHOD, use GetMipEnergyAtMaxplane(TString) instead! \n"); + return (this->GetEnergyAtMaxplane(section)); +} + +Float_t CaloEnergy::GetEnergyAtMaxplane(TString section){ + section.ToUpper(); + if ( section.Contains("XO") ) return xomax_en; + if ( section.Contains("XE") ) return xemax_en; + if ( section.Contains("YO") ) return yomax_en; + if ( section.Contains("YE") ) return yemax_en; + return(-1); +} + +Float_t CaloEnergy::GetMaxEnergy(TString section){ + printf(" WARNING: OBSOLETE METHOD, use GetMipEnergy(TString) instead! \n"); + return (this->GetMipEnergy(section)); +} + +Float_t CaloEnergy::GetMipEnergy(TString section){ + section.ToUpper(); + if ( fLong ){ + this->Process(section); + return fXOen_maxplane; + } else { + if ( section.Contains("XO") ) return fXOen_maxplane; + if ( section.Contains("XE") ) return fXEen_maxplane; + if ( section.Contains("YO") ) return fYOen_maxplane; + if ( section.Contains("YE") ) return fYEen_maxplane; + }; + return(-1); +} + +Float_t CaloEnergy::GetEncol(Int_t i){ + if ( fColumn > -1 && (((fXesel || fXosel)&&i==1) || ((fYesel || fYosel)&&i==0)) ){ + Int_t t = -1; + if ( i == 0 ){ + if ( fColumn == 0 || fColumn == 3 || fColumn == 6 ) t = 0; + if ( fColumn == 1 || fColumn == 4 || fColumn == 7 ) t = 1; + if ( fColumn == 2 || fColumn == 5 || fColumn == 8 ) t = 2; + } else { + if ( fColumn == 0 || fColumn == 1 || fColumn == 2 ) t = 0; + if ( fColumn == 3 || fColumn == 4 || fColumn == 5 ) t = 1; + if ( fColumn == 6 || fColumn == 7 || fColumn == 8 ) t = 2; + }; + if ( debug ) printf(" encol: i %i t %i encol %f \n",i,t,encol[i][t]); + return encol[i][t]; + }; + return(-1.); +} + +Float_t CaloEnergy::GetMaxEnergy(){ + printf(" WARNING: OBSOLETE METHOD, use GetMipEnergy() instead! \n"); + return (this->GetMipEnergy()); +} + +Float_t CaloEnergy::GetMipEnergy(){ + if ( fLong ){ + if ( debug ) printf(" oh! call process! with asntr %s and sntr %s \n",asntr.Data(),sntr.Data()); + this->Process(asntr); + }; + return((fXEen_maxplane+fYOen_maxplane+fYEen_maxplane+fXOen_maxplane)); } @@ -454,13 +526,28 @@ enstrip[view][plane][strip]=en; }; // + if ( debug && ((fM1+0.122-0.244*(Float_t)fRad) < 0.) ) printf("Error: (fM1+0.122-0.244*(Float_t)fRad) < 0. fM1 %f fRad %i %f \n",fM1,fRad,(fM1+0.122-0.244*(Float_t)fRad)); + // // sum energy plane by plane for each sections // + Float_t fen_xep[11]; + Float_t fen_xop[11]; + Float_t fen_yep[11]; + Float_t fen_yop[11]; + memset(fen_xep,0,11*sizeof(Float_t)); + memset(fen_xop,0,11*sizeof(Float_t)); + memset(fen_yep,0,11*sizeof(Float_t)); + memset(fen_yop,0,11*sizeof(Float_t)); + // for (Int_t i=0;i<11;i++){ for(strip=0; strip<96; strip++) { + fen_xep[i] += enstrip[1][2*i][strip]; + fen_yop[i] += enstrip[0][2*i][strip]; + fen_xop[i] += enstrip[1][(2*i)+1][strip]; + fen_yep[i] += enstrip[0][(2*i)+1][strip]; if ( fRad < 0 ){ // - // run over all the strips of the plane + // run over all the strips of the plane // en_xep[i] += enstrip[1][2*i][strip]; en_yop[i] += enstrip[0][2*i][strip]; @@ -470,12 +557,23 @@ // // use only the strips inside a cylinder of given radius fRad // - if ( strip >= cl2->cibar[2*i][1]-1-fRad && strip <= cl2->cibar[2*i][1]-1+fRad ) en_xep[i] += enstrip[1][2*i][strip]; - if ( strip >= cl2->cibar[2*i][0]-1-fRad && strip <= cl2->cibar[2*i][0]-1+fRad ) en_yop[i] += enstrip[0][2*i][strip]; - if ( strip >= cl2->cibar[(2*i)+1][1]-1-fRad && strip <= cl2->cibar[(2*i)+1][1]-1+fRad ) en_xop[i] += enstrip[1][(2*i)+1][strip]; - if ( strip >= cl2->cibar[(2*i)+1][0]-1-fRad && strip <= cl2->cibar[(2*i)+1][0]-1+fRad ) en_yep[i] += enstrip[0][(2*i)+1][strip]; + if ( cl2->cibar[2*i][1] >= 1 && cl2->cibar[2*i][1] <= 96 && + (strip >= (cl2->cibar[2*i][1]-1-fRad)) && (strip <= (cl2->cibar[2*i][1]-1+fRad)) ) en_xep[i] += enstrip[1][2*i][strip]; + + if ( cl2->cibar[2*i][0] >= 1 && cl2->cibar[2*i][0] <= 96 && + (strip >= (cl2->cibar[2*i][0]-1-fRad)) && (strip <= (cl2->cibar[2*i][0]-1+fRad)) ) en_yop[i] += enstrip[0][2*i][strip]; + + if ( cl2->cibar[(2*i)+1][1] >= 1 && cl2->cibar[(2*i)+1][1] <= 96 && + (strip >= (cl2->cibar[(2*i)+1][1]-1-fRad)) && (strip <= (cl2->cibar[(2*i)+1][1]-1+fRad)) ) en_xop[i] += enstrip[1][(2*i)+1][strip]; + + if ( cl2->cibar[(2*i)+1][0] >= 1 && cl2->cibar[(2*i)+1][0] <= 96 && + (strip >= (cl2->cibar[(2*i)+1][0]-1-fRad)) && (strip <= (cl2->cibar[(2*i)+1][0]-1+fRad)) ) en_yep[i] += enstrip[0][(2*i)+1][strip]; }; }; + if ( debug ) printf(" ex_xep[%i] %f cibar %i \n",i,en_xep[i],cl2->cibar[2*i][1]); + if ( debug ) printf(" ex_xop[%i] %f cibar %i \n",i,en_xop[i],cl2->cibar[(2*i)+1][1]); + if ( debug ) printf(" ex_yep[%i] %f cibar %i \n",i,en_yep[i],cl2->cibar[(2*i)+1][0]); + if ( debug ) printf(" ex_yop[%i] %f cibar %i \n",i,en_yop[i],cl2->cibar[2*i][0]); energyxe += en_xep[i]; energyyo += en_yop[i]; energyxo += en_xop[i]; @@ -489,14 +587,17 @@ Int_t yon = 0; Int_t xon = 0; Int_t yen = 0; + Float_t en = 0.; // if ( section.Contains("XE") ){ yon++; xon++; yen++; for (Int_t ipl =0; ipl < 11; ipl ++) { - if(en_xep[ipl] > xemax_en) { - xemax_en = en_xep[ipl]; + en = fen_xep[ipl]; + if ( !fAllpl ) en = en_xep[ipl]; + if(en > xemax_en) { + xemax_en = en; fMax_planexe = ipl; }; }; @@ -506,8 +607,10 @@ xon++; yen++; for (Int_t ipl =0; ipl < 11; ipl ++) { - if(en_yop[ipl] > yomax_en) { - yomax_en = en_yop[ipl]; + en = fen_yop[ipl]; + if ( !fAllpl ) en = en_yop[ipl]; + if(en > yomax_en) { + yomax_en = en; fMax_planeyo = ipl; }; }; @@ -516,8 +619,10 @@ if ( section.Contains("XO") ){ yen++; for (Int_t ipl =0; ipl < 11; ipl ++) { - if(en_xop[ipl] > xomax_en) { - xomax_en = en_xop[ipl]; + en = fen_xop[ipl]; + if ( !fAllpl ) en = en_xop[ipl]; + if(en > xomax_en) { + xomax_en = en; fMax_planexo = ipl; }; }; @@ -525,8 +630,10 @@ // if ( section.Contains("YE") ){ for (Int_t ipl =0; ipl < 11; ipl ++) { - if(en_yep[ipl] > yemax_en) { - yemax_en = en_yep[ipl]; + en = fen_yep[ipl]; + if ( !fAllpl ) en = en_yep[ipl]; + if(en > yemax_en) { + yemax_en = en; fMax_planeye = ipl; }; }; @@ -651,8 +758,6 @@ // // for each plane of the calorimeter find the position of the track in the direction along the strip (where we do not have a measurement from the selected plane) by looking at the plane above/below of the other view and extrapolating the trajectory to the given plane // - Float_t track_coordx[22][2]; - Float_t track_coordy[22][2]; // Float_t tgx_cl2; Float_t tgy_cl2; @@ -662,8 +767,10 @@ for (Int_t p=0; p<22; p++){ track_coordy[p][1] = cl2->cbar[p][1]; track_coordx[p][1] = cl2->cbar[p][0] - fabs(trk_z[p][1]-trk_z[p][0])*tgx_cl2; + // track_coordx[p][1] = cl2->cbar[p][0] + fabs(trk_z[p][1]-trk_z[p][0])*tgx_cl2; track_coordx[p][0] = cl2->cbar[p][0]; track_coordy[p][0] = cl2->cbar[p][1] - fabs(trk_z[p][1]-trk_z[p][0])*tgy_cl2; + // track_coordy[p][0] = cl2->cbar[p][1] + fabs(trk_z[p][1]-trk_z[p][0])*tgy_cl2; if ( debug ) printf(" p %i track_coordy[p][1] %f track_coordx[p][1] %f track_coordx[p][0] %f track_coordy[p][0] %f \n",p,track_coordy[p][1],track_coordx[p][1],track_coordx[p][0],track_coordy[p][0]); }; // @@ -671,38 +778,30 @@ // if ( section.Contains("XO") ){ // - // check event is inside XO acceptance + // find the column hit in the first plane + // + Int_t ix = -1; + Int_t iy = -1; + if ( track_coordx[(2*0)+1][1] >= (-12.054+fM) && track_coordx[(2*0)+1][1] <= (-4.246-fM) ) ix = 0; + if ( track_coordx[(2*0)+1][1] >= ( -4.004+fM) && track_coordx[(2*0)+1][1] <= ( 3.804-fM) ) ix = 1; + if ( track_coordx[(2*0)+1][1] >= ( 4.046+fM) && track_coordx[(2*0)+1][1] <= (11.854-fM) ) ix = 2; + if ( cl2->cbar[(2*0)+1][1] >= (xo1 + fM1) && cl2->cbar[(2*0)+1][1] <= (xo2 - fM1) ) iy = 0; + if ( cl2->cbar[(2*0)+1][1] >= (xo3 + fM1) && cl2->cbar[(2*0)+1][1] <= (xo4 - fM1) ) iy = 1; + if ( cl2->cbar[(2*0)+1][1] >= (xo5 + fM1) && cl2->cbar[(2*0)+1][1] <= (xo6 - fM1) ) iy = 2; + if ( ix > -1 && iy > -1 ) fColXO = ix + iy*3; + // + // check event is inside XO acceptance, if multicol is false (SingleColumn mode) then the track must be contained in a column. // for (Int_t i=0; i<11; i++) { - if - ( - (((track_coordx[(2*i)+1][1]>=(-12.054+fM))&& - (track_coordx[(2*i)+1][1]<=(-4.246-fM)))&& - (((cl2->cbar[(2*i)+1][1]>=xo1 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo2 - fM1 ))|| - ((cl2->cbar[(2*i)+1][1]>=xo3 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo4 - fM1 ))|| - ((cl2->cbar[(2*i)+1][1]>=xo5 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo6 - fM1 ))))|| - - (((track_coordx[(2*i)+1][1]>=(-4.004+fM))&& - (track_coordx[(2*i)+1][1]<=(3.804-fM)))&& - (((cl2->cbar[(2*i)+1][1]>=xo1 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo2 - fM1 ))|| - ((cl2->cbar[(2*i)+1][1]>=xo3 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo4 - fM1))|| - ((cl2->cbar[(2*i)+1][1]>=xo5 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo6 - fM1 ))))|| - - (((track_coordx[(2*i)+1][1]>=(4.046+fM))&& - (track_coordx[(2*i)+1][1]<=(11.854-fM)))&& - (((cl2->cbar[(2*i)+1][1]>=xo1 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo2 - fM1))|| - ((cl2->cbar[(2*i)+1][1]>=xo3 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo4 - fM1 ))|| - ((cl2->cbar[(2*i)+1][1]>=xo5 + fM1)&& - (cl2->cbar[(2*i)+1][1]<=xo6 - fM1 )))) - ){ + if (( + ( track_coordx[(2*i)+1][1] >= (-12.054+fM) && track_coordx[(2*i)+1][1] <= (-4.246-fM) && (ix == 0 || multicol) ) || + ( track_coordx[(2*i)+1][1] >= ( -4.004+fM) && track_coordx[(2*i)+1][1] <= ( 3.804-fM) && (ix == 1 || multicol) ) || + ( track_coordx[(2*i)+1][1] >= ( 4.046+fM) && track_coordx[(2*i)+1][1] <= (11.854-fM) && (ix == 2 || multicol) ) + ) && ( + ( cl2->cbar[(2*i)+1][1] >= (xo1 + fM1) && cl2->cbar[(2*i)+1][1] <= (xo2 - fM1) && (iy == 0 || multicol) ) || + ( cl2->cbar[(2*i)+1][1] >= (xo3 + fM1) && cl2->cbar[(2*i)+1][1] <= (xo4 - fM1) && (iy == 1 || multicol) ) || + ( cl2->cbar[(2*i)+1][1] >= (xo5 + fM1) && cl2->cbar[(2*i)+1][1] <= (xo6 - fM1) && (iy == 2 || multicol) ) + )){ fXosel = true; fXoout = i; } else { @@ -722,42 +821,53 @@ // event is contained (or partially contained) hence we can integrate energy up to the maximum and calculate the energy as measured by this section // if ( fXosel ){ - for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexo+nPl)) ;iplm++) fXOen_maxplane += en_xop[iplm]; + for (Int_t iplm=0; iplm<=TMath::Min(10,(Int_t)(fMax_planexo+nPl)); iplm++){ + fXOen_maxplane += en_xop[iplm]; + if ( debug ) printf(" XO iplm %i fXOen_maxplane %f en_xop[iplm] %f\n",iplm,fXOen_maxplane,en_xop[iplm]); + }; fEnergyxo = fXOen_maxplane/fConv_rxo; + // + for (Int_t i=0;i<11;i++){ + for(strip=0; strip<96; strip++) { + // + // run over all the strips of the plane + // + if ( strip >= 0 && strip < 32 ) encol[1][0] += enstrip[1][(2*i)+1][strip]; + if ( strip >= 32 && strip < 64 ) encol[1][1] += enstrip[1][(2*i)+1][strip]; + if ( strip >= 64 && strip < 96 ) encol[1][2] += enstrip[1][(2*i)+1][strip]; + entot[1] += enstrip[1][(2*i)+1][strip]; + // + }; + }; }; }; // if ( section.Contains("XE") ){ + // + // find the column hit in the first plane + // + Int_t ix = -1; + Int_t iy = -1; + if ( track_coordx[(2*0)][1] >= (-11.854+fM) && track_coordx[(2*0)][1] <= (-4.046-fM) ) ix = 0; + if ( track_coordx[(2*0)][1] >= ( -3.804+fM) && track_coordx[(2*0)][1] <= ( 4.004-fM) ) ix = 1; + if ( track_coordx[(2*0)][1] >= ( 4.246+fM) && track_coordx[(2*0)][1] <= (12.054-fM) ) ix = 2; + if ( cl2->cbar[(2*0)][1] >= (xe1 + fM1) && cl2->cbar[(2*0)][1] <= (xe2 - fM1) ) iy = 0; + if ( cl2->cbar[(2*0)][1] >= (xe3 + fM1) && cl2->cbar[(2*0)][1] <= (xe4 - fM1) ) iy = 1; + if ( cl2->cbar[(2*0)][1] >= (xe5 + fM1) && cl2->cbar[(2*0)][1] <= (xe6 - fM1) ) iy = 2; + if ( ix > -1 && iy > -1 ) fColXE = ix + iy*3; + // + // check event is inside XO acceptance + // for (Int_t i=0; i<11; i++) { - if - ( - (((track_coordx[2*i][1]>=(-11.854+fM))&& - (track_coordx[2*i][1]<=(-4.046-fM)))&& - (((cl2->cbar[2*i][1]>=xe1 + fM1)&& - (cl2->cbar[2*i][1]<=xe2 - fM1 ))|| - ((cl2->cbar[2*i][1]>=xe3 + fM1)&& - (cl2->cbar[2*i][1]<=xe4 - fM1 ))|| - ((cl2->cbar[2*i][1]>=xe5 + fM1)&& - (cl2->cbar[2*i][1]<=xe6 - fM1 ))))|| - - (((track_coordx[2*i][1]>=(-3.804+fM))&& - (track_coordx[2*i][1]<=(4.004-fM)))&& - (((cl2->cbar[2*i][1]>=xe1 + fM1)&& - (cl2->cbar[2*i][1]<=xe2 - fM1 ))|| - ((cl2->cbar[2*i][1]>=xe3 + fM1)&& - (cl2->cbar[2*i][1]<=xe4 - fM1))|| - ((cl2->cbar[2*i][1]>=xe5 + fM1)&& - (cl2->cbar[2*i][1]<=xe6 - fM1 ))))|| - - (((track_coordx[2*i][1]>=(4.246+fM))&& - (track_coordx[2*i][1]<=(12.054-fM)))&& - (((cl2->cbar[2*i][1]>=xe1 + fM1)&& - (cl2->cbar[2*i][1]<=xe2 - fM1))|| - ((cl2->cbar[2*i][1]>=xe3 + fM1)&& - (cl2->cbar[2*i][1]<=xe4 - fM1 ))|| - ((cl2->cbar[2*i][1]>=xe5 + fM1)&& - (cl2->cbar[2*i][1]<=xe6 - fM1 )))) - ){ + if (( + ( track_coordx[(2*i)][1] >= (-11.854+fM) && track_coordx[(2*i)][1] <= (-4.046-fM) && (ix == 0 || multicol) ) || + ( track_coordx[(2*i)][1] >= ( -3.804+fM) && track_coordx[(2*i)][1] <= ( 4.004-fM) && (ix == 1 || multicol) ) || + ( track_coordx[(2*i)][1] >= ( 4.246+fM) && track_coordx[(2*i)][1] <= (12.054-fM) && (ix == 2 || multicol) ) + ) && ( + ( cl2->cbar[(2*i)][1] >= (xe1 + fM1) && cl2->cbar[(2*i)][1] <= (xe2 - fM1) && (iy == 0 || multicol) ) || + ( cl2->cbar[(2*i)][1] >= (xe3 + fM1) && cl2->cbar[(2*i)][1] <= (xe4 - fM1) && (iy == 1 || multicol) ) || + ( cl2->cbar[(2*i)][1] >= (xe5 + fM1) && cl2->cbar[(2*i)][1] <= (xe6 - fM1) && (iy == 2 || multicol) ) + )){ fXesel = true; fXeout = i; } else { @@ -765,48 +875,60 @@ break; }; }; + // if ( !fXesel && fXeout >= fXemin && fXeout >= (Int_t)(fMax_planexe+nPl) ){ if ( debug ) printf(" XE: this event is only partially contained: fXeout %i fXemin %i fMax_planexe + nPl %i \n",fXeout,fXemin,(Int_t)(fMax_planexe+nPl)); fPartsel = true; fXesel = true; }; if ( fXesel ){ - for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexe+nPl)) ;iplm++) fXEen_maxplane += en_xep[iplm]; + for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexe+nPl)) ;iplm++){ + fXEen_maxplane += en_xep[iplm]; + if ( debug ) printf(" XE iplm %i fXOen_maxplane %f en_xop[iplm] %f\n",iplm,fXEen_maxplane,en_xep[iplm]); + }; fEnergyxe = fXEen_maxplane/fConv_rxe; + // + for (Int_t i=0;i<11;i++){ + for(strip=0; strip<96; strip++) { + // + // run over all the strips of the plane + // + if ( strip >= 0 && strip < 32 ) encol[1][0] += enstrip[1][(2*i)][strip]; + if ( strip >= 32 && strip < 64 ) encol[1][1] += enstrip[1][(2*i)][strip]; + if ( strip >= 64 && strip < 96 ) encol[1][2] += enstrip[1][(2*i)][strip]; + entot[1] += enstrip[1][(2*i)][strip]; + // + }; + }; }; }; // if ( section.Contains("YE") ){ + // + // find the column hit in the first plane + // + Int_t ix = -1; + Int_t iy = -1; + if ( track_coordy[(2*0)+1][0] >= (-12.154+fM) && track_coordy[(2*0)+1][0] <= (-4.346-fM) ) iy = 0; + if ( track_coordy[(2*0)+1][0] >= ( -4.104+fM) && track_coordy[(2*0)+1][0] <= ( 3.704-fM) ) iy = 1; + if ( track_coordy[(2*0)+1][0] >= ( 3.946+fM) && track_coordy[(2*0)+1][0] <= (11.754-fM) ) iy = 2; + if ( cl2->cbar[(2*0)+1][0] >= (ye1 + fM1) && cl2->cbar[(2*0)+1][0] <= (ye2 - fM1) ) ix = 0; + if ( cl2->cbar[(2*0)+1][0] >= (ye3 + fM1) && cl2->cbar[(2*0)+1][0] <= (ye4 - fM1) ) ix = 1; + if ( cl2->cbar[(2*0)+1][0] >= (ye5 + fM1) && cl2->cbar[(2*0)+1][0] <= (ye6 - fM1) ) ix = 2; + if ( ix > -1 && iy > -1 ) fColYE = ix + iy*3; + // + // check event is inside XO acceptance + // for (Int_t i=0; i<11; i++) { - if - ( - (((track_coordy[(2*i)+1][0]>=(-12.154+fM))&& - (track_coordy[(2*i)+1][0]<=(-4.346-fM)))&& - (((cl2->cbar[(2*i)+1][0]>=ye1 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye2 - fM1 ))|| - ((cl2->cbar[(2*i)+1][0]>=ye3 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye4 - fM1 ))|| - ((cl2->cbar[(2*i)+1][0]>=ye5 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye6 - fM1 ))))|| - - (((track_coordy[(2*i)+1][0]>=(-4.104+fM))&& - (track_coordy[(2*i)+1][0]<=(3.704-fM)))&& - (((cl2->cbar[(2*i)+1][0]>=ye1 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye2 - fM1 ))|| - ((cl2->cbar[(2*i)+1][0]>=ye3 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye4 - fM1))|| - ((cl2->cbar[(2*i)+1][0]>=ye5 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye6 - fM1 ))))|| - - (((track_coordy[(2*i)+1][0]>=(3.946+fM))&& - (track_coordy[(2*i)+1][0]<=(11.754-fM)))&& - (((cl2->cbar[(2*i)+1][0]>=ye1 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye2 - fM1))|| - ((cl2->cbar[(2*i)+1][0]>=ye3 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye4 - fM1 ))|| - ((cl2->cbar[(2*i)+1][0]>=ye5 + fM1)&& - (cl2->cbar[(2*i)+1][0]<=ye6 - fM1 )))) - ){ + if (( + ( track_coordy[(2*i)+1][0] >= (-12.154+fM) && track_coordy[(2*i)+1][0] <= (-4.346-fM) && (iy == 0 || multicol) ) || + ( track_coordy[(2*i)+1][0] >= ( -4.104+fM) && track_coordy[(2*i)+1][0] <= ( 3.704-fM) && (iy == 1 || multicol) ) || + ( track_coordy[(2*i)+1][0] >= ( 3.946+fM) && track_coordy[(2*i)+1][0] <= (11.754-fM) && (iy == 2 || multicol) ) + ) && ( + ( cl2->cbar[(2*i)+1][0] >= (ye1 + fM1) && cl2->cbar[(2*i)+1][0] <= (ye2 - fM1) && (ix == 0 || multicol) ) || + ( cl2->cbar[(2*i)+1][0] >= (ye3 + fM1) && cl2->cbar[(2*i)+1][0] <= (ye4 - fM1) && (ix == 1 || multicol) ) || + ( cl2->cbar[(2*i)+1][0] >= (ye5 + fM1) && cl2->cbar[(2*i)+1][0] <= (ye6 - fM1) && (ix == 2 || multicol) ) + )){ fYesel = true; fYeout = i; } else { @@ -814,6 +936,7 @@ break; }; }; + // if ( !fYesel && fYeout >= fYemin && fYeout >= (Int_t)(fMax_planeye+nPl) ){ if ( debug ) printf(" YE: this event is only partially contained: fYeout %i fYemin %i fMax_planeye + nPl %i \n",fYeout,fYemin,(Int_t)(fMax_planeye+nPl)); fPartsel = true; @@ -822,42 +945,49 @@ if ( fYesel ){ for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeye+nPl)) ;iplm++) fYEen_maxplane += en_yep[iplm]; fEnergyye = fYEen_maxplane/fConv_rye; + // + for (Int_t i=0;i<11;i++){ + for(strip=0; strip<96; strip++) { + // + // run over all the strips of the plane + // + if ( strip >= 0 && strip < 32 ) encol[0][0] += enstrip[0][(2*i)+1][strip]; + if ( strip >= 32 && strip < 64 ) encol[0][1] += enstrip[0][(2*i)+1][strip]; + if ( strip >= 64 && strip < 96 ) encol[0][2] += enstrip[0][(2*i)+1][strip]; + entot[0] += enstrip[0][(2*i)+1][strip]; + // + }; + }; + // }; }; // if ( section.Contains("YO") ){ + // + // find the column hit in the first plane + // + Int_t ix = -1; + Int_t iy = -1; + if ( track_coordy[(2*0)][0] >= (-11.954+fM) && track_coordy[(2*0)][0] <= (-4.146-fM) ) iy = 0; + if ( track_coordy[(2*0)][0] >= ( -3.904+fM) && track_coordy[(2*0)][0] <= ( 3.904-fM) ) iy = 1; + if ( track_coordy[(2*0)][0] >= ( 4.146+fM) && track_coordy[(2*0)][0] <= (11.954-fM) ) iy = 2; + if ( cl2->cbar[(2*0)][0] >= (yo1 + fM1) && cl2->cbar[(2*0)][0] <= (yo2 - fM1) ) ix = 0; + if ( cl2->cbar[(2*0)][0] >= (yo3 + fM1) && cl2->cbar[(2*0)][0] <= (yo4 - fM1) ) ix = 1; + if ( cl2->cbar[(2*0)][0] >= (yo5 + fM1) && cl2->cbar[(2*0)][0] <= (yo6 - fM1) ) ix = 2; + if ( ix > -1 && iy > -1 ) fColYO = ix + iy*3; + // + // check event is inside XO acceptance + // for (Int_t i=0; i<11; i++) { - if ( debug ) printf(" i %i track_coordy[2*i][0] %f cl2->cbar[2*i][0] %f \n",i,track_coordy[2*i][0],cl2->cbar[2*i][0]); - if ( debug ) printf(" i %i fm %f fm1 %f yo1 %g yo2 %f yo3 %f yo4 %f yo5 %f yo6 %f \n",i,fM,fM1,yo1,yo2,yo3,yo4,yo5,yo6); - if - ( - (((track_coordy[2*i][0]>=(-11.954+fM))&& - (track_coordy[2*i][0]<=(-4.146-fM)))&& - (((cl2->cbar[2*i][0]>=yo1 + fM1)&& - (cl2->cbar[2*i][0]<=yo2 - fM1 ))|| - ((cl2->cbar[2*i][0]>=yo3 + fM1)&& - (cl2->cbar[2*i][0]<=yo4 - fM1 ))|| - ((cl2->cbar[2*i][0]>=yo5 + fM1)&& - (cl2->cbar[2*i][0]<=yo6 - fM1 ))))|| - - (((track_coordy[2*i][0]>=(-3.904+fM))&& - (track_coordy[2*i][0]<=(+3.904-fM)))&& - (((cl2->cbar[2*i][0]>=yo1 + fM1)&& - (cl2->cbar[2*i][0]<=yo2 - fM1 ))|| - ((cl2->cbar[2*i][0]>=yo3 + fM1)&& - (cl2->cbar[2*i][0]<=yo4 - fM1))|| - ((cl2->cbar[2*i][0]>=yo5 + fM1)&& - (cl2->cbar[2*i][0]<=yo6 - fM1 ))))|| - - (((track_coordy[2*i][0]>=(4.146+fM))&& - (track_coordy[2*i][0]<=(11.954-fM)))&& - (((cl2->cbar[2*i][0]>=yo1 + fM1)&& - (cl2->cbar[2*i][0]<=yo2 - fM1))|| - ((cl2->cbar[2*i][0]>=yo3 + fM1)&& - (cl2->cbar[2*i][0]<=yo4 - fM1 ))|| - ((cl2->cbar[2*i][0]>=yo5 + fM1)&& - (cl2->cbar[2*i][0]<=yo6 - fM1 )))) - ){ + if (( + ( track_coordy[(2*i)][0] >= (-11.954+fM) && track_coordy[(2*i)][0] <= (-4.146-fM) && (iy == 0 || multicol) ) || + ( track_coordy[(2*i)][0] >= ( -3.904+fM) && track_coordy[(2*i)][0] <= ( 3.904-fM) && (iy == 1 || multicol) ) || + ( track_coordy[(2*i)][0] >= ( 4.146+fM) && track_coordy[(2*i)][0] <= (11.954-fM) && (iy == 2 || multicol) ) + ) && ( + ( cl2->cbar[(2*i)][0] >= (yo1 + fM1) && cl2->cbar[(2*i)][0] <= (yo2 - fM1) && (ix == 0 || multicol) ) || + ( cl2->cbar[(2*i)][0] >= (yo3 + fM1) && cl2->cbar[(2*i)][0] <= (yo4 - fM1) && (ix == 1 || multicol) ) || + ( cl2->cbar[(2*i)][0] >= (yo5 + fM1) && cl2->cbar[(2*i)][0] <= (yo6 - fM1) && (ix == 2 || multicol) ) + )){ fYosel = true; fYoout = i; } else { @@ -865,6 +995,7 @@ break; }; }; + // if ( !fYosel && fYoout >= fYomin && fYoout >= (Int_t)(fMax_planeyo+nPl) ){ if ( debug ) printf(" YO: this event is only partially contained: fYoout %i fYomin %i fMax_planeyo + nPl %i \n",fYoout,fYomin,(Int_t)(fMax_planeyo+nPl)); fPartsel = true; @@ -873,6 +1004,19 @@ if ( fYosel ){ for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeyo+nPl)) ;iplm++) fYOen_maxplane += en_yop[iplm]; fEnergyyo = fYOen_maxplane/fConv_ryo; + // + for (Int_t i=0;i<11;i++){ + for(strip=0; strip<96; strip++) { + // + // run over all the strips of the plane + // + if ( strip >= 0 && strip < 32 ) encol[0][0] += enstrip[0][(2*i)][strip]; + if ( strip >= 32 && strip < 64 ) encol[0][1] += enstrip[0][(2*i)][strip]; + if ( strip >= 64 && strip < 96 ) encol[0][2] += enstrip[0][(2*i)][strip]; + entot[0] += enstrip[0][(2*i)][strip]; + // + }; + }; }; }; // @@ -898,6 +1042,30 @@ fSel = true; }; fEnergy = (fXEen_maxplane+fYOen_maxplane+fYEen_maxplane+fXOen_maxplane)/fConv_rxo; + if ( fSel ){ + if ( fXesel ) fColumn = fColXE; + if ( fXosel ){ + if ( fColXO != fColumn && fColumn > -1 ){ + printf(" ERROR! mismatch in column number between different sections! fColumn %i fColXO %i \n",fColumn,fColXO); + } else { + fColumn = fColXO; + }; + }; + if ( fYesel ){ + if ( fColYE != fColumn && fColumn > -1 ){ + printf(" ERROR! mismatch in column number between different sections! fColumn %i fColYE %i \n",fColumn,fColYE); + } else { + fColumn = fColYE; + }; + }; + if ( fYosel ){ + if ( fColYO != fColumn && fColumn > -1 ){ + printf(" ERROR! mismatch in column number between different sections! fColumn %i fColYO %i \n",fColumn,fColYO); + } else { + fColumn = fColYO; + }; + }; + }; }; // if ( debug ) printf("sel %i indep %i fMax_plane %f conv_r %f en_maxplane %f encalo %f \n",fSel,indep,fMax_plane,fConv_rxo,fXOen_maxplane,fEnergy); @@ -986,6 +1154,7 @@ } else { fXOen_maxplane = clong->Get_E0(); }; + fMax_plane = clong->Get_tmax(); fYOen_maxplane = 0.; fYEen_maxplane = 0.; fXEen_maxplane = 0.;