/[PAMELA software]/calo/flight/CaloEnergy/src/CaloEnergy.cpp
ViewVC logotype

Diff of /calo/flight/CaloEnergy/src/CaloEnergy.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mocchiut, Tue Aug 11 13:28:27 2009 UTC revision 1.11 by mocchiut, Mon Aug 17 15:00:53 2009 UTC
# Line 46  void CaloEnergy::UseCaloPreSampler(){ Line 46  void CaloEnergy::UseCaloPreSampler(){
46  //   cp->ForceCaloFit();  //   cp->ForceCaloFit();
47  //   cp->SetDebug(true);  //   cp->SetDebug(true);
48  //   cp->Process();  //   cp->Process();
49      if ( clong ) clong->SetCaloLevel2Pointer(cp->GetLevel2Pointer());
50  }  }
51    
52    
# Line 189  void CaloEnergy::DefineGeometry(){ Line 190  void CaloEnergy::DefineGeometry(){
190    // Use CaloStrip to determine once the position of border strips for each section    // Use CaloStrip to determine once the position of border strips for each section
191    //    //
192    //    //
193    fM = 2. + 0.096; // real position from cbar    //  fM = 2. + 0.096; // real position from cbar BUG the 0.096 is already taken into account in the border calculation made by Giovanna
194    fM1 = 2. - 0.122 - 0.096; // due to calculation of xe1 etc.    fM = 2. ; // real position from cbar
195      //  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
196      fM1 = 2. - 0.122 - 0.096 + 0.096; // due to calculation of xe1 etc.
197    if ( fM1 < 0. ) fM1 = 0.;    if ( fM1 < 0. ) fM1 = 0.;
198    //    //
199    CaloStrip *cs = new CaloStrip(fSimu);    CaloStrip *cs = new CaloStrip(fSimu);
# Line 215  void CaloEnergy::DefineGeometry(){ Line 218  void CaloEnergy::DefineGeometry(){
218    cs->Set(1,0,95);    cs->Set(1,0,95);
219    xe6= cs->GetY();    xe6= cs->GetY();
220    
221      //  printf(" xe1 %f xe2 %f xe3 %f xe4 %f xe5 %f xe6 %f \n",xe1,xe2,xe3,xe4,xe5,xe6);
222    
223    // view x plane 0 strip 0    // view x plane 0 strip 0
224    cs->Set(0,0,0);    cs->Set(0,0,0);
225    yo1= cs->GetX();    yo1= cs->GetX();
# Line 235  void CaloEnergy::DefineGeometry(){ Line 240  void CaloEnergy::DefineGeometry(){
240    cs->Set(0,0,95);    cs->Set(0,0,95);
241    yo6= cs->GetX();    yo6= cs->GetX();
242    
     
243    // view y plane 1 strip 0    // view y plane 1 strip 0
244    cs->Set(1,1,0);    cs->Set(1,1,0);
245    xo1= cs->GetY();    xo1= cs->GetY();
# Line 276  void CaloEnergy::DefineGeometry(){ Line 280  void CaloEnergy::DefineGeometry(){
280    cs->Set(0,1,95);    cs->Set(0,1,95);
281    ye6= cs->GetX();    ye6= cs->GetX();
282    
283      //printf(" ye1 %f ye2 %f ye3 %f ye4 %f ye5 %f ye6 %f \n",ye1,ye2,ye3,ye4,ye5,ye6);
284      
285    //    //
286    for (Int_t p = 0; p<22; p ++){    for (Int_t p = 0; p<22; p ++){
287      for (Int_t v = 0; v<2; v++ ){        for (Int_t v = 0; v<2; v++ ){  
# Line 314  void CaloEnergy::Clear(){ Line 320  void CaloEnergy::Clear(){
320    yomax_en= 0.;    yomax_en= 0.;
321    yemax_en= 0.;    yemax_en= 0.;
322    //    //
323   memset(enstrip,0,2*22*96*(sizeof(Float_t)));      memset(enstrip,0,2*22*96*(sizeof(Float_t)));  
324    en = 0.;    en = 0.;
325    view = 0;    view = 0;
326    plane = 0;    plane = 0;
# Line 377  void CaloEnergy::Print(){ Line 383  void CaloEnergy::Print(){
383    printf(" energyxo:.............. %f \n",energyxo);    printf(" energyxo:.............. %f \n",energyxo);
384    printf(" energyye:.............. %f \n",energyye);    printf(" energyye:.............. %f \n",energyye);
385    printf(" energyyo:.............. %f \n",energyyo);    printf(" energyyo:.............. %f \n",energyyo);
386      printf(" fXEen_maxplane:........ %f \n",fXEen_maxplane);
387      printf(" fXOen_maxplane:........ %f \n",fXOen_maxplane);
388      printf(" fYEen_maxplane:........ %f \n",fYEen_maxplane);
389      printf(" fYOen_maxplane:........ %f \n",fYOen_maxplane);
390    printf(" x0max   :.............. %f \n",x0max);    printf(" x0max   :.............. %f \n",x0max);
391    printf(" debug   :.............. %i \n",debug);    printf(" debug   :.............. %i \n",debug);
392    
# Line 453  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 463  Bool_t CaloEnergy::IsInsideAcceptance(TS
463      enstrip[view][plane][strip]=en;      enstrip[view][plane][strip]=en;
464    };    };
465    //    //
466      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));
467      //
468    // sum energy plane by plane for each sections    // sum energy plane by plane for each sections
469    //    //
470    for (Int_t i=0;i<11;i++){    for (Int_t i=0;i<11;i++){
471      for(strip=0; strip<96; strip++) {      for(strip=0; strip<96; strip++) {
472        if ( fRad < 0 ){        if ( fRad < 0 ){
473          //          //
474          // run over all the strips of the plane          // run over all the strips of the plane
475          //          //
476          en_xep[i] += enstrip[1][2*i][strip];          en_xep[i] += enstrip[1][2*i][strip];
477          en_yop[i] += enstrip[0][2*i][strip];          en_yop[i] += enstrip[0][2*i][strip];
# Line 469  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 481  Bool_t CaloEnergy::IsInsideAcceptance(TS
481          //          //
482          // use only the strips inside a cylinder of given radius fRad          // use only the strips inside a cylinder of given radius fRad
483          //          //
484          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 ( 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];
485          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 ( 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];
486          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 ( 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];
487          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][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];
488        };        };
489      };      };
490      energyxe += en_xep[i];      energyxe += en_xep[i];
# Line 538  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 550  Bool_t CaloEnergy::IsInsideAcceptance(TS
550      Int_t wpl = (Int_t)roundf(x0max/0.76);      Int_t wpl = (Int_t)roundf(x0max/0.76);
551      Bool_t isY = false;      Bool_t isY = false;
552      if ( ((x0max/0.76)-(Float_t)wpl) > 0. ) isY = true;      if ( ((x0max/0.76)-(Float_t)wpl) > 0. ) isY = true;
553        xomax_en = 0.;
554        yemax_en = 0.;
555        xemax_en = 0.;
556        yomax_en = 0.;
557        //
558      if ( !(wpl%2) ){      if ( !(wpl%2) ){
559        // 0, 2, 4, ...        // 0, 2, 4, ...
560        if ( isY ){        if ( isY ){
561          yomax_en = 1000.;          if ( section.Contains("YO") ) yomax_en = 1000.;
562          xemax_en = 500.;          if ( section.Contains("XE") ) xemax_en = 500.;
563          fMax_planeyo=wpl/2;          fMax_planeyo=wpl/2;
564          fMax_planexe=wpl/2;          fMax_planexe=wpl/2;
565            if ( section.Contains("XO") ) xomax_en = 10.;
566            if ( section.Contains("YE") ) yemax_en = 5.;
567        } else {        } else {
568          yomax_en = 500.;          if ( section.Contains("YO") ) yomax_en = 500.;
569          xemax_en = 1000.;          if ( section.Contains("XE") ) xemax_en = 1000.;
570          fMax_planeyo=wpl/2;          fMax_planeyo=wpl/2;
571          fMax_planexe=wpl/2;          fMax_planexe=wpl/2;
572            if ( section.Contains("XO") ) xomax_en = 5.;
573            if ( section.Contains("YE") ) yemax_en = 10.;
574        };        };
       xomax_en = 0.;  
       yemax_en = 0.;  
575      } else {      } else {
576        // 1, 3, 5, ...        // 1, 3, 5, ...
577        if ( isY ){        if ( isY ){
578          yemax_en = 1000.;          if ( section.Contains("YE") ) yemax_en = 1000.;
579          xomax_en = 500.;          if ( section.Contains("XO") ) xomax_en = 500.;
580          fMax_planeye=(wpl-1)/2;          fMax_planeye=(wpl-1)/2;
581          fMax_planexo=(wpl-1)/2;          fMax_planexo=(wpl-1)/2;
582            if ( section.Contains("XE") ) xemax_en = 10.;
583            if ( section.Contains("YO") ) yomax_en = 5.;
584        } else {        } else {
585          yemax_en = 500.;          if ( section.Contains("YE") ) yemax_en = 500.;
586          xomax_en = 1000.;          if ( section.Contains("XO") ) xomax_en = 1000.;
587          fMax_planeye=(wpl-1)/2;          fMax_planeye=(wpl-1)/2;
588          fMax_planexo=(wpl-1)/2;          fMax_planexo=(wpl-1)/2;
589            if ( section.Contains("XE") ) xemax_en = 5.;
590            if ( section.Contains("YO") ) yomax_en = 10.;
591        };        };
       xemax_en = 0.;  
       yomax_en = 0.;  
592      };      };
593      if ( debug ) printf(" x0max %f wpl %i isY %i yomax_en %f xemax_en %f yemax_en %f xomax_en %f fMaxplane %i %i %i %i\n",x0max,wpl,isY,yomax_en,xemax_en,yemax_en,xomax_en,fMax_planeyo,fMax_planexe,fMax_planeye,fMax_planexo);      if ( debug ) printf(" x0max %f x0max/0.76 %f wpl %i isY %i yomax_en %f xemax_en %f yemax_en %f xomax_en %f fMaxplane %i %i %i %i\n",x0max,(x0max/0.76),wpl,isY,yomax_en,xemax_en,yemax_en,xomax_en,fMax_planeyo,fMax_planexe,fMax_planeye,fMax_planexo);
594    };    };
595    //    //
596    Int_t nPl = fPl;    Int_t nPl = fPl;
# Line 641  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 662  Bool_t CaloEnergy::IsInsideAcceptance(TS
662    //    //
663    // 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    // 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
664    //    //
   Float_t  track_coordx[22][2];  
   Float_t  track_coordy[22][2];  
665    //    //
666    Float_t tgx_cl2;    Float_t tgx_cl2;
667    Float_t tgy_cl2;      Float_t tgy_cl2;  
# Line 652  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 671  Bool_t CaloEnergy::IsInsideAcceptance(TS
671    for (Int_t p=0; p<22; p++){        for (Int_t p=0; p<22; p++){    
672      track_coordy[p][1] = cl2->cbar[p][1];      track_coordy[p][1] = cl2->cbar[p][1];
673      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;
674        //    track_coordx[p][1] = cl2->cbar[p][0] + fabs(trk_z[p][1]-trk_z[p][0])*tgx_cl2;
675      track_coordx[p][0] = cl2->cbar[p][0];      track_coordx[p][0] = cl2->cbar[p][0];
676      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;
677        //    track_coordy[p][0] = cl2->cbar[p][1] + fabs(trk_z[p][1]-trk_z[p][0])*tgy_cl2;
678      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]);      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]);
679    };    };
680    //    //
# Line 712  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 733  Bool_t CaloEnergy::IsInsideAcceptance(TS
733      // event is contained (or partially contained) hence we can integrate energy up to the maximum and calculate the energy as measured by this section      // event is contained (or partially contained) hence we can integrate energy up to the maximum and calculate the energy as measured by this section
734      //      //
735      if ( fXosel ){      if ( fXosel ){
736        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++){        
737            fXOen_maxplane += en_xop[iplm];
738            if ( debug ) printf(" XO iplm %i fXOen_maxplane %f  en_xop[iplm] %f\n",iplm,fXOen_maxplane,en_xop[iplm]);
739          };
740        fEnergyxo = fXOen_maxplane/fConv_rxo;        fEnergyxo = fXOen_maxplane/fConv_rxo;
741      };      };
742    };    };
# Line 761  Bool_t CaloEnergy::IsInsideAcceptance(TS Line 785  Bool_t CaloEnergy::IsInsideAcceptance(TS
785        fXesel = true;        fXesel = true;
786      };      };
787      if ( fXesel ){      if ( fXesel ){
788        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++){
789            fXEen_maxplane += en_xep[iplm];
790            if ( debug ) printf(" XE iplm %i fXOen_maxplane %f  en_xop[iplm] %f\n",iplm,fXEen_maxplane,en_xep[iplm]);
791          };
792        fEnergyxe = fXEen_maxplane/fConv_rxe;        fEnergyxe = fXEen_maxplane/fConv_rxe;
793      };      };
794    };      };  
# Line 971  void CaloEnergy::Process(TString section Line 998  void CaloEnergy::Process(TString section
998        } else {        } else {
999          clong->Fit();          clong->Fit();
1000        };              };      
1001        fXOen_maxplane = clong->Get_E0();        if ( clong->GetLowerLimit() != 0. || clong->GetUpperLimit() != 0. ){
1002            fXOen_maxplane = clong->Get_defE0();
1003          } else {
1004            fXOen_maxplane = clong->Get_E0();
1005          };
1006          fMax_plane = clong->Get_tmax();
1007        fYOen_maxplane  = 0.;        fYOen_maxplane  = 0.;
1008        fYEen_maxplane = 0.;        fYEen_maxplane = 0.;
1009        fXEen_maxplane = 0.;        fXEen_maxplane = 0.;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23