/[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.11 by mocchiut, Thu Aug 13 15:56:39 2009 UTC revision 1.15 by mocchiut, Mon Sep 14 13:56:50 2009 UTC
# Line 281  CaloLat::CaloLat(PamLevel2 *l2p){   Line 281  CaloLat::CaloLat(PamLevel2 *l2p){  
281    PKT = 0;    PKT = 0;
282    atime = 0;    atime = 0;
283    //    //
284      suf = "";
285    debug = false;    debug = false;
286    //    //
287  };  };
# Line 297  Calo2D::Calo2D(PamLevel2 *l2p){   Line 298  Calo2D::Calo2D(PamLevel2 *l2p){  
298    PKT = 0;    PKT = 0;
299    atime = 0;    atime = 0;
300    //    //
301      suf = "";
302    debug = false;    debug = false;
303    //    //
304  };  };
# Line 375  void CaloLat::Draw(Int_t view,Int_t plan Line 377  void CaloLat::Draw(Int_t view,Int_t plan
377    //    //
378    for (Int_t v=minv; v<maxv;v++){    for (Int_t v=minv; v<maxv;v++){
379       for (Int_t p=minp; p<maxp;p++){       for (Int_t p=minp; p<maxp;p++){
380          TString hid = Form("clatv%ip%i",v,p);           TString hid = Form("clatv%ip%i%s",v,p,suf.Data());      
381          TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));          TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
382          if ( tc ){          if ( tc ){
383  //       tc->Clear();  //       tc->Clear();
# Line 383  void CaloLat::Draw(Int_t view,Int_t plan Line 385  void CaloLat::Draw(Int_t view,Int_t plan
385           tc = new TCanvas(hid,hid);           tc = new TCanvas(hid,hid);
386          };          };
387          //          //
388          TString thid = Form("hlatv%ip%i",v,p);            TString thid = Form("hlatv%ip%i%s",v,p,suf.Data());    
389          TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));          TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));
390          if ( th ) th->Delete();          if ( th ) th->Delete();
391  //       th->Clear();  //       th->Clear();
# Line 426  void Calo2D::Draw(Int_t plane){ Line 428  void Calo2D::Draw(Int_t plane){
428    gStyle->SetNdivisions(510,"XY");    gStyle->SetNdivisions(510,"XY");
429    //    //
430    for (Int_t p=minp; p<maxp;p++){    for (Int_t p=minp; p<maxp;p++){
431      TString hid = Form("c2dp%i",p);          TString hid = Form("c2dp%i%s",p,suf.Data());        
432      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
433      if ( tc ){      if ( tc ){
434        //         tc->Clear();        //         tc->Clear();
# Line 434  void Calo2D::Draw(Int_t plane){ Line 436  void Calo2D::Draw(Int_t plane){
436        tc = new TCanvas(hid,hid);        tc = new TCanvas(hid,hid);
437      };      };
438      //      //
439      TString thid = Form("h2dp%i",p);          TString thid = Form("h2dp%i%s",p,suf.Data());      
440      TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));      TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));
441      if ( th ) th->Delete();      if ( th ) th->Delete();
442      //   th->Clear();      //   th->Clear();
# Line 671  CaloLong::CaloLong(PamLevel2 *l2p){   Line 673  CaloLong::CaloLong(PamLevel2 *l2p){  
673    umax = 100.;    umax = 100.;
674    slmax = "";    slmax = "";
675    sumax = "";    sumax = "";
676      suf = "";
677    xyaverage = true;    xyaverage = true;
678    //    //
679      letmax = -1;
680      heavytail = false;
681      lmipth = 100.;
682      //
683  };  };
684    
685  void CaloLong::MaskSection(TString sec){  void CaloLong::MaskSection(TString sec){
# Line 697  void CaloLong::UnMaskSection(TString sec Line 704  void CaloLong::UnMaskSection(TString sec
704    
705  void CaloLong::Clear(){  void CaloLong::Clear(){
706    //    //
707      if ( debug ) printf(" Clear called \n");
708      //
709    memset(eplane,0, 2*22*sizeof(Float_t));    memset(eplane,0, 2*22*sizeof(Float_t));
710    //    //
711    chi2 = 0.;    chi2 = 0.;
# Line 849  void CaloLong::Process(){ Line 858  void CaloLong::Process(){
858    //    //
859    // inclination factor (stolen from Daniele's code)    // inclination factor (stolen from Daniele's code)
860    //    //
861    Float_t ytgx = 0;    Float_t ytgx = 0.;
862    Float_t ytgy = 0;    Float_t ytgy = 0.;
863    ytgx = 0.76 * clp->tanx[0];    ytgx = 0.76 * clp->tanx[0];
864    ytgy = 0.76 * clp->tany[0];      ytgy = 0.76 * clp->tany[0];  
865    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );
# Line 944  void CaloLong::SetEnergies(Float_t myene Line 953  void CaloLong::SetEnergies(Float_t myene
953      };      };
954    };    };
955    //    //
956      if ( !clp && debug ) printf(" ERROR!! no CaloLevel2 obj!!\n");
957      //
958    // inclination factor (stolen from Daniele's code)    // inclination factor (stolen from Daniele's code)
959    //    //
960    Float_t ytgx = 0;    Float_t ytgx = 0.;
961    Float_t ytgy = 0;    Float_t ytgy = 0.;
962    ytgx = 0.76 * clp->tanx[0];    ytgx = 0.76 * clp->tanx[0];
963    ytgy = 0.76 * clp->tany[0];      ytgy = 0.76 * clp->tany[0];  
964    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );
965      if ( debug ) printf(" X0pl %f tanx %f tany %f \n",X0pl,ytgx,ytgy);
966    //    //
967    // Find experimental plane of maximum    // Find experimental plane of maximum
968    //    //
# Line 971  void CaloLong::SetEnergies(Float_t myene Line 983  void CaloLong::SetEnergies(Float_t myene
983    //    //
984    if ( vmax == 0 ) pmax++;    if ( vmax == 0 ) pmax++;
985    etmax = pmax * X0pl;    etmax = pmax * X0pl;
986      letmax = etmax;
987    //    //
988    if ( debug ) this->Print();    if ( debug ) this->Print();
989    if ( debug ) printf(" exit \n");    if ( debug ) printf(" exit \n");
# Line 995  void CaloLong::Fit(){ Line 1008  void CaloLong::Fit(){
1008    this->Fit(false);    this->Fit(false);
1009  };  };
1010    
1011  Float_t CaloLong::Evaluate(TString s, Float_t tmax){  Float_t CaloLong::Evaluate(TString s, Float_t tmax, Float_t X0pl){
1012    /* SAMPLE OUTPUT:    /* SAMPLE OUTPUT:
1013       Enter Infix Expression : A + B + C / (E - F)       Enter Infix Expression : A + B + C / (E - F)
1014       Postfix Expression is : A B + C E F - / +         Postfix Expression is : A B + C E F - / +  
1015    */      */  
1016    if ( !s.Contains("t") ){    if ( !s.Contains("tmax") && !s.Contains("X0pl") ){
1017      printf(" ERROR, the input formula must contain \"t\"\n");      printf(" ERROR, the input formula must contain \"t\"\n");
1018      return 0.;      return 0.;
1019    };    };
# Line 1009  Float_t CaloLong::Evaluate(TString s, Fl Line 1022  Float_t CaloLong::Evaluate(TString s, Fl
1022      return 0.;      return 0.;
1023    };    };
1024    TString g=Form("%f",tmax);    TString g=Form("%f",tmax);
1025      TString h=Form("%f",X0pl);
1026    TString *ts= new TString("");    TString *ts= new TString("");
1027    ts->Prepend(s.Data());    ts->Prepend(s.Data());
1028    ts->ReplaceAll("t",1,g.Data(),g.Capacity());    ts->ReplaceAll("tmax",4,g.Data(),g.Capacity());
1029      ts->ReplaceAll("X0pl",4,h.Data(),h.Capacity());
1030    ts->Prepend("(");    ts->Prepend("(");
1031    ts->Append(")");    ts->Append(")");
1032    if ( debug )  printf(" ts %s tssize %i capac %i s %s g %s \n",ts->Data(),ts->Sizeof(),ts->Capacity(),s.Data(),g.Data());    if ( debug )  printf(" ts %s tssize %i capac %i s %s g %s \n",ts->Data(),ts->Sizeof(),ts->Capacity(),s.Data(),g.Data());
# Line 1064  void CaloLong::Fit(Bool_t draw){ Line 1079  void CaloLong::Fit(Bool_t draw){
1079      gStyle->SetNdivisions(510,"XY");      gStyle->SetNdivisions(510,"XY");
1080    };    };
1081    //    //
1082    TString hid = Form("clongfit");          TString hid = Form("clongfit%s",suf.Data());  
1083    TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));    TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1084    //  if ( tc ) tc->Delete();    //  if ( tc ) tc->Delete();
1085    //  if ( tc ) tc->Close();    //  if ( tc ) tc->Close();
# Line 1074  void CaloLong::Fit(Bool_t draw){ Line 1089  void CaloLong::Fit(Bool_t draw){
1089      if ( tc ) tc->cd();      if ( tc ) tc->cd();
1090    };    };
1091    //    //
1092    TString thid = Form("hlongfit");          TString thid = Form("hlongfit%s",suf.Data());
1093    TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));    TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));
1094    if ( th ) th->Delete();    if ( th ) th->Delete();
1095    //    //
1096    TString ghid = Form("glongfit");          TString ghid = Form("glongfit%s",suf.Data());
1097    TGraphErrors *gh  = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid));    TGraphErrors *gh  = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid));
1098    if ( gh ) gh->Delete();    if ( gh ) gh->Delete();
1099    //    //
# Line 1150  void CaloLong::Fit(Bool_t draw){ Line 1165  void CaloLong::Fit(Bool_t draw){
1165          exx[numpo] = 0.1;          exx[numpo] = 0.1;
1166          yyy[numpo] = enemip;          yyy[numpo] = enemip;
1167          eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);          eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);
1168            if ( xpos > letmax && enemip > lmipth && heavytail) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo;
1169          numpo++;          numpo++;
1170          //      th->Fill(xpos,enemip);          //      th->Fill(xpos,enemip);
1171          if ( debug ) printf(" AVE Filling: st %i xpos %f energy %f \n",st,xpos,enemip);          if ( debug ) printf(" AVE Filling: st %i xpos %f energy %f error %f letmax %f lmpith %f \n",st,xpos,enemip,eyy[numpo-1],letmax,lmipth);
1172        };        };
1173      } else {      } else {
1174        for (Int_t jj=0; jj<2; jj++){        for (Int_t jj=0; jj<2; jj++){
# Line 1182  void CaloLong::Fit(Bool_t draw){ Line 1198  void CaloLong::Fit(Bool_t draw){
1198            exx[numpo] = 0.1;            exx[numpo] = 0.1;
1199            yyy[numpo] = enemip;            yyy[numpo] = enemip;
1200            eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);            eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);
1201            if ( xpos > letmax && enemip > lmipth && heavytail ) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo;
1202            //      eyy[numpo] = sqrt(enemip)/(st*0.95);            //      eyy[numpo] = sqrt(enemip)/(st*0.95);
1203            numpo++;            numpo++;
1204            //      th->Fill(xpos,enemip);            //      th->Fill(xpos,enemip);
# Line 1218  void CaloLong::Fit(Bool_t draw){ Line 1235  void CaloLong::Fit(Bool_t draw){
1235    //  th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax);    //  th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax);
1236    th = new TH2F(thid,thid,1000,-0.2,xmax,1000,0.,emax*1.2);    th = new TH2F(thid,thid,1000,-0.2,xmax,1000,0.,emax*1.2);
1237    gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy);    gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy);
1238    TF1 *lfit  = dynamic_cast<TF1*>(gDirectory->FindObject("lfit"));    TString fnam=Form("lfit%s",suf.Data());
1239      TF1 *lfit  = dynamic_cast<TF1*>(gDirectory->FindObject(fnam));
1240    if ( lfit ) lfit->Delete();    if ( lfit ) lfit->Delete();
1241    lfit = new TF1("lfit",ccurve,0.,xmax,3);    lfit = new TF1(fnam,ccurve,0.,xmax,3);
1242    //   if ( !lfit ){
1243    //     lfit = new TF1(fnam,ccurve,0.,xmax,3);
1244    //   };
1245    //   lfit->Clear();
1246    //   lfit->SetName(fnam);
1247    //   lfit->SetRange(0.,xmax);
1248    //  lfit->Print();
1249      //
1250    if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz);    if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz);
1251    E0 = qtotparz;    E0 = qtotparz;
1252    //  E0 = clp->qtot;    //  E0 = clp->qtot;
# Line 1231  void CaloLong::Fit(Bool_t draw){ Line 1257  void CaloLong::Fit(Bool_t draw){
1257    //  lfit->SetParLimits(0,0.,1000.);    //  lfit->SetParLimits(0,0.,1000.);
1258    //  lfit->SetParLimits(1,-1.,80.);    //  lfit->SetParLimits(1,-1.,80.);
1259    //  lfit->SetParLimits(2,-1.,10.);    //  lfit->SetParLimits(2,-1.,10.);
1260    //  TString optio = "ROW"; // "RO"    // TString optio = "ROW"; // "RO"
1261    TString optio = "RO"; // "RO"    TString optio = "RO"; // "RO"
1262    if ( debug ){    if ( debug ){
1263      optio += "NV";      optio += "NV";
# Line 1241  void CaloLong::Fit(Bool_t draw){ Line 1267  void CaloLong::Fit(Bool_t draw){
1267      if ( draw ) optio += "Q";      if ( draw ) optio += "Q";
1268    };    };
1269    //    //
1270    if ( debug ) printf(" OK, start the fitting procedure...\n");    if ( debug ) printf(" OK, start the fitting procedure... options: %s \n",optio.Data());
1271    //    //
1272    //  fitresult = th->Fit("lfit",optio);    //  fitresult = th->Fit("lfit",optio);
1273      //  lfit->Update();
1274    fitresult = gh->Fit("lfit",optio);    fitresult = gh->Fit("lfit",optio);
1275      //  fitresult = gh->Fit("lfit","ROQW");
1276    //    //
1277    if ( debug ) printf(" the fit is done! result: %i \n",fitresult);    if ( debug ) printf(" the fit is done! result: %i \n",fitresult);
1278    //    //
# Line 1265  void CaloLong::Fit(Bool_t draw){ Line 1293  void CaloLong::Fit(Bool_t draw){
1293      asymm = -1.;      asymm = -1.;
1294      defE0 = -1.;      defE0 = -1.;
1295    } else {    } else {
1296      if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax);      if ( slmax.MaybeRegexp() ) lmax = this->Evaluate(slmax,tmax,X0pl);
1297      if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax);      if ( sumax.MaybeRegexp() ) umax = this->Evaluate(sumax,tmax,X0pl);
1298      Int_t npp = 1000;      Int_t npp = 1000;
1299      double *xpp=new double[npp];      double *xpp=new double[npp];
1300      double *wpp=new double[npp];      double *wpp=new double[npp];
# Line 1288  void CaloLong::Fit(Bool_t draw){ Line 1316  void CaloLong::Fit(Bool_t draw){
1316      delete w;      delete w;
1317      delete xp;      delete xp;
1318      delete wp;      delete wp;
1319        delete xpp;
1320        delete wpp;
1321      //    Float_t i10max = lfit->Integral(0.,10.*tmax);      //    Float_t i10max = lfit->Integral(0.,10.*tmax);
1322      if ( debug ) printf(" Integral: %f \n",i10max);      if ( debug ) printf(" Integral: %f \n",i10max);
1323      //      //
# Line 1338  void CaloLong::Fit(Bool_t draw){ Line 1368  void CaloLong::Fit(Bool_t draw){
1368      if ( th ) th->Delete();      if ( th ) th->Delete();
1369    };    };
1370    //    //
1371    //   gMinuit->SetPrintLevel(1);
1372    //   gMinuit->mnamin();
1373    //   //  gMinuit->mnfree(0);
1374    //   gMinuit->mncler();
1375    //   gMinuit->mnrset(1);
1376      //  gMinuit->Delete();
1377      //ROOT::Math::Minimizer::Clear();
1378      //  gMinuit->mnhelp("*");
1379      //
1380    //  delete lfit;    //  delete lfit;
1381    //    //
1382  };  };
# Line 1367  void CaloLong::Draw(Int_t view){ Line 1406  void CaloLong::Draw(Int_t view){
1406    //    //
1407    if ( maxv != -1 ){    if ( maxv != -1 ){
1408      for (Int_t v=minv; v<maxv;v++){      for (Int_t v=minv; v<maxv;v++){
1409        TString hid = Form("clongv%i",v);        TString hid = Form("clongv%i%s",v,suf.Data());    
1410        TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));        TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1411        if ( tc ){        if ( tc ){
1412          //       tc->Clear();          //       tc->Clear();
# Line 1375  void CaloLong::Draw(Int_t view){ Line 1414  void CaloLong::Draw(Int_t view){
1414          tc = new TCanvas(hid,hid);          tc = new TCanvas(hid,hid);
1415        };        };
1416        //        //
1417        TString thid = Form("hlongv%i",v);                TString thid = Form("hlongv%i%s",v,suf.Data());  
1418        TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));        TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));
1419        if ( th ) th->Delete();        if ( th ) th->Delete();
1420        //         th->Clear();        //         th->Clear();
# Line 1394  void CaloLong::Draw(Int_t view){ Line 1433  void CaloLong::Draw(Int_t view){
1433      };      };
1434    } else {    } else {
1435      //      //
1436      TString hid = Form("clongvyvx");          TString hid = Form("clongvyvx%s",suf.Data());      
1437      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1438      if ( tc ){      if ( tc ){
1439      } else {      } else {
1440        tc = new TCanvas(hid,hid);        tc = new TCanvas(hid,hid);
1441      };      };
1442      //      //
1443      TString thid = Form("hlongvyvx");        TString thid = Form("hlongvyvx%s",suf.Data());      
1444      TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));      TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));
1445      if ( th ) th->Delete();      if ( th ) th->Delete();
1446      th = new TH1F(thid,thid,44,-0.5,43.5);      th = new TH1F(thid,thid,44,-0.5,43.5);

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

  ViewVC Help
Powered by ViewVC 1.1.23