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

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

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

revision 1.3 by mocchiut, Thu Dec 18 21:05:53 2008 UTC revision 1.6 by mocchiut, Wed Jun 24 14:12:55 2009 UTC
# Line 459  CaloLong::CaloLong(PamLevel2 *l2p){   Line 459  CaloLong::CaloLong(PamLevel2 *l2p){  
459    //    //
460    no18x = true;    no18x = true;
461    debug = false;    debug = false;
462      maskXE = false;
463      maskXO = false;
464      maskYE = false;
465      maskYO = false;
466    //    //
467  };  };
468    
469    void CaloLong::MaskSection(TString sec){
470      sec.ToUpper();
471      if ( sec.Contains("XO") ) maskXO = true;
472      if ( sec.Contains("YO") ) maskYO = true;
473      if ( sec.Contains("XE") ) maskXE = true;
474      if ( sec.Contains("YE") ) maskYE = true;
475    }
476    
477  void CaloLong::Clear(){  void CaloLong::Clear(){
478    //    //
479    memset(eplane,0, 2*22*sizeof(Float_t));    memset(eplane,0, 2*22*sizeof(Float_t));
# Line 484  void CaloLong::Clear(){ Line 496  void CaloLong::Clear(){
496    
497  void CaloLong::Print(){  void CaloLong::Print(){
498    //    //
499    Process();    Fit();
500    //    //
501    printf("==================== Calorimeter Longitudinal Profile =======================\n");    printf("==================== Calorimeter Longitudinal Profile =======================\n");
502    printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime);    printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime);
# Line 597  void CaloLong::Process(){ Line 609  void CaloLong::Process(){
609    Int_t plane = 0;    Int_t plane = 0;
610    Int_t strip = 0;    Int_t strip = 0;
611    Float_t mip = 0.;    Float_t mip = 0.;
612      Bool_t gof = true;
613    for (Int_t i=0; i < L2->GetCaloLevel1()->istrip; i++){    for (Int_t i=0; i < L2->GetCaloLevel1()->istrip; i++){
614      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
615      eplane[view][plane] += mip;      gof = true;
616        if ( maskXE && (plane%2)==0 && view==1 ) gof = false;
617        if ( maskXO && (plane%2)!=0 && view==1 ) gof = false;
618        if ( maskYE && (plane%2)!=0 && view==0 ) gof = false;
619        if ( maskYO && (plane%2)==0 && view==0 ) gof = false;
620        if ( gof ) eplane[view][plane] += mip;
621    };    };
622    //    //
623    // inclination factor (steal from Daniele's code)    // inclination factor (stolen from Daniele's code)
624    //    //
625    Float_t ytgx = 0;    Float_t ytgx = 0;
626    Float_t ytgy = 0;    Float_t ytgy = 0;
# Line 706  void CaloLong::Fit(Bool_t draw){ Line 724  void CaloLong::Fit(Bool_t draw){
724    //  th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax);    //  th = new TH1F(thid,thid,int(NC*1.5),-0.2,xmax);
725    th = new TH1F(thid,thid,100,-0.2,xmax);    th = new TH1F(thid,thid,100,-0.2,xmax);
726    //    //
727    for (Int_t st=N;st<(N+NC);st++){    // AGH, BUG!
728      //
729      Int_t mmin = 0;
730      Int_t mmax = 0;
731      if ( cont ){
732        mmin = N;
733        mmax = NC+N;
734      } else {
735        mmin = 0;
736        mmax = NC;
737      };
738      //
739      Float_t qtotparz = 0.;
740      for (Int_t st=mmin;st<mmax+1;st++){
741      enemip = 0.;      enemip = 0.;
742      xpos = (st - N) * X0pl;      xpos = (st - mmin) * X0pl;
743      if ( st > N && st < (N+NC-1) ){            if ( st > mmin && st < mmax ){      
744        if ( no18x && ( st == 18+1 || st == mask18b+1 )){        if ( no18x && ( st == 18+1 || st == mask18b+1 )){
745          enemip = 2. * eplane[1][st];          enemip = 2. * eplane[1][st];
746        } else {        } else {
747          enemip = eplane[0][st-1] + eplane[1][st];          enemip = eplane[0][st-1] + eplane[1][st];
748        };        };
749      } else {      } else {
750        if ( st == N ) enemip = 2. * eplane[1][st];        if ( st == mmin ) enemip = 2. * eplane[1][st];
751        if ( st == (N+NC-1) ) enemip = 2. * eplane[0][st];        if ( st == mmax ) enemip = 2. * eplane[0][st-1];
752      };      };
753      //      //
754        qtotparz += enemip;
755      if ( enemip > 0. ){      if ( enemip > 0. ){
756        th->Fill(xpos,enemip);        th->Fill(xpos,enemip);
757        if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip);        if ( debug ) printf(" Filling: st %i xpos %f energy %f \n",st,xpos,enemip);
# Line 750  void CaloLong::Fit(Bool_t draw){ Line 782  void CaloLong::Fit(Bool_t draw){
782    };    };
783    //    //
784    TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3);    TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3);
785    E0 = L2->GetCaloLevel2()->qtot;    if ( debug ) printf("qtot %f qtotparz %f \n",L2->GetCaloLevel2()->qtot,qtotparz);
786      E0 = qtotparz;
787      //  E0 = L2->GetCaloLevel2()->qtot;
788    a = 5.;    a = 5.;
789    b = 0.5;    b = 0.5;
790    if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b);    if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b);
# Line 819  void CaloLong::Fit(Bool_t draw){ Line 853  void CaloLong::Fit(Bool_t draw){
853        if ( debug ) printf(" i10max == imax, asymm undefined\n");        if ( debug ) printf(" i10max == imax, asymm undefined\n");
854        asymm = -2.;        asymm = -2.;
855      };      };
856        if ( asymm != asymm ){
857          if ( debug ) printf(" asymm is nan \n");      
858          asymm = -3.;
859        };
860      //lfit->Integral(0.,tmax)/(lfit->Integral(0.,10.*tmax)-lfit->Integral(0.,tmax));      //lfit->Integral(0.,tmax)/(lfit->Integral(0.,10.*tmax)-lfit->Integral(0.,tmax));
861      if ( debug ) printf(" Asymmetry has been calculated \n");      if ( debug ) printf(" Asymmetry has been calculated \n");
862    };    };
863    //    //
864      if ( asymm < 0. || ndf <= 0. || chi2 < 0. || tmax < 0. ){
865        if ( debug ) printf(" Funny asymm||ndf||chi2||tmax values, fit failed \n");
866        fitresult = 100;
867      };
868      //
869    if ( draw ){    if ( draw ){
870      //      //
871      tc->cd();          tc->cd();    
# Line 842  void CaloLong::Fit(Bool_t draw){ Line 885  void CaloLong::Fit(Bool_t draw){
885      gStyle->SetLabelSize(0);      gStyle->SetLabelSize(0);
886      gStyle->SetNdivisions(1,"XY");      gStyle->SetNdivisions(1,"XY");
887      //      //
888      } else {
889        if ( th ) th->Delete();
890    };    };
891    //    //
892    delete lfit;    delete lfit;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23