/[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.12 by mocchiut, Mon Aug 17 15:00:36 2009 UTC revision 1.16 by mocchiut, Fri Nov 27 10:30:29 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      lmipth = 0.;
683      //
684  };  };
685    
686  void CaloLong::MaskSection(TString sec){  void CaloLong::MaskSection(TString sec){
# Line 697  void CaloLong::UnMaskSection(TString sec Line 705  void CaloLong::UnMaskSection(TString sec
705    
706  void CaloLong::Clear(){  void CaloLong::Clear(){
707    //    //
708      if ( debug ) printf(" Clear called \n");
709      //
710    memset(eplane,0, 2*22*sizeof(Float_t));    memset(eplane,0, 2*22*sizeof(Float_t));
711    //    //
712    chi2 = 0.;    chi2 = 0.;
# Line 849  void CaloLong::Process(){ Line 859  void CaloLong::Process(){
859    //    //
860    // inclination factor (stolen from Daniele's code)    // inclination factor (stolen from Daniele's code)
861    //    //
862    Float_t ytgx = 0;    Float_t ytgx = 0.;
863    Float_t ytgy = 0;    Float_t ytgy = 0.;
864    ytgx = 0.76 * clp->tanx[0];    ytgx = 0.76 * clp->tanx[0];
865    ytgy = 0.76 * clp->tany[0];      ytgy = 0.76 * clp->tany[0];  
866    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 954  void CaloLong::SetEnergies(Float_t myene
954      };      };
955    };    };
956    //    //
957      if ( !clp && debug ) printf(" ERROR!! no CaloLevel2 obj!!\n");
958      //
959    // inclination factor (stolen from Daniele's code)    // inclination factor (stolen from Daniele's code)
960    //    //
961    Float_t ytgx = 0;    Float_t ytgx = 0.;
962    Float_t ytgy = 0;    Float_t ytgy = 0.;
963    ytgx = 0.76 * clp->tanx[0];    ytgx = 0.76 * clp->tanx[0];
964    ytgy = 0.76 * clp->tany[0];      ytgy = 0.76 * clp->tany[0];  
965    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );    X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) );
966      if ( debug ) printf(" X0pl %f tanx %f tany %f \n",X0pl,ytgx,ytgy);
967    //    //
968    // Find experimental plane of maximum    // Find experimental plane of maximum
969    //    //
# Line 971  void CaloLong::SetEnergies(Float_t myene Line 984  void CaloLong::SetEnergies(Float_t myene
984    //    //
985    if ( vmax == 0 ) pmax++;    if ( vmax == 0 ) pmax++;
986    etmax = pmax * X0pl;    etmax = pmax * X0pl;
987      letmax = etmax;
988    //    //
989    if ( debug ) this->Print();    if ( debug ) this->Print();
990    if ( debug ) printf(" exit \n");    if ( debug ) printf(" exit \n");
# Line 1066  void CaloLong::Fit(Bool_t draw){ Line 1080  void CaloLong::Fit(Bool_t draw){
1080      gStyle->SetNdivisions(510,"XY");      gStyle->SetNdivisions(510,"XY");
1081    };    };
1082    //    //
1083    TString hid = Form("clongfit");          TString hid = Form("clongfit%s",suf.Data());  
1084    TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));    TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1085    //  if ( tc ) tc->Delete();    //  if ( tc ) tc->Delete();
1086    //  if ( tc ) tc->Close();    //  if ( tc ) tc->Close();
# Line 1076  void CaloLong::Fit(Bool_t draw){ Line 1090  void CaloLong::Fit(Bool_t draw){
1090      if ( tc ) tc->cd();      if ( tc ) tc->cd();
1091    };    };
1092    //    //
1093    TString thid = Form("hlongfit");          TString thid = Form("hlongfit%s",suf.Data());
1094    TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));    TH2F *th  = dynamic_cast<TH2F*>(gDirectory->FindObject(thid));
1095    if ( th ) th->Delete();    if ( th ) th->Delete();
1096    //    //
1097    TString ghid = Form("glongfit");          TString ghid = Form("glongfit%s",suf.Data());
1098    TGraphErrors *gh  = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid));    TGraphErrors *gh  = dynamic_cast<TGraphErrors*>(gDirectory->FindObject(ghid));
1099    if ( gh ) gh->Delete();    if ( gh ) gh->Delete();
1100    //    //
# Line 1152  void CaloLong::Fit(Bool_t draw){ Line 1166  void CaloLong::Fit(Bool_t draw){
1166          exx[numpo] = 0.1;          exx[numpo] = 0.1;
1167          yyy[numpo] = enemip;          yyy[numpo] = enemip;
1168          eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);          eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);
1169            //      if ( xpos > letmax && enemip > lmipth && heavytail) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo;
1170            if ( xpos > letmax && enemip > lmipth && heavytail) eyy[numpo] = sqrt(enemip)/5.;
1171            if ( xpos > letmax-1 && xpos < letmax+1 && heavytail ) eyy[numpo] /= 5.;
1172            //if ( xpos > letmax-2 && xpos < letmax+1 && heavytail ) eyy[numpo] /= 7.;
1173            if ( xpos < 3. && heavytail ) eyy[numpo] /= 5.;
1174          numpo++;          numpo++;
1175          //      th->Fill(xpos,enemip);          //      th->Fill(xpos,enemip);
1176          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);
1177        };        };
1178      } else {      } else {
1179        for (Int_t jj=0; jj<2; jj++){        for (Int_t jj=0; jj<2; jj++){
# Line 1184  void CaloLong::Fit(Bool_t draw){ Line 1203  void CaloLong::Fit(Bool_t draw){
1203            exx[numpo] = 0.1;            exx[numpo] = 0.1;
1204            yyy[numpo] = enemip;            yyy[numpo] = enemip;
1205            eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);            eyy[numpo] = sqrt(enemip*3.)+sqrt(5.);
1206            if ( xpos > letmax && enemip > lmipth && heavytail ) eyy[numpo] = (sqrt(enemip*3.)+sqrt(5.))/numpo;
1207            //      eyy[numpo] = sqrt(enemip)/(st*0.95);            //      eyy[numpo] = sqrt(enemip)/(st*0.95);
1208            numpo++;            numpo++;
1209            //      th->Fill(xpos,enemip);            //      th->Fill(xpos,enemip);
# Line 1220  void CaloLong::Fit(Bool_t draw){ Line 1240  void CaloLong::Fit(Bool_t draw){
1240    //  th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax);    //  th = new TH2F(thid,thid,int(NC*1.5),-0.2,xmax);
1241    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);
1242    gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy);    gh = new TGraphErrors(numpo,xxx,yyy,exx,eyy);
1243    TF1 *lfit  = dynamic_cast<TF1*>(gDirectory->FindObject("lfit"));    TString fnam=Form("lfit%s",suf.Data());
1244      TF1 *lfit  = dynamic_cast<TF1*>(gDirectory->FindObject(fnam));
1245    if ( lfit ) lfit->Delete();    if ( lfit ) lfit->Delete();
1246    lfit = new TF1("lfit",ccurve,0.,xmax,3);    lfit = new TF1(fnam,ccurve,0.,xmax,3);
1247    //   if ( !lfit ){
1248    //     lfit = new TF1(fnam,ccurve,0.,xmax,3);
1249    //   };
1250    //   lfit->Clear();
1251    //   lfit->SetName(fnam);
1252    //   lfit->SetRange(0.,xmax);
1253    //  lfit->Print();
1254      //
1255    if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz);    if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz);
1256    E0 = qtotparz;    E0 = qtotparz;
1257    //  E0 = clp->qtot;    //  E0 = clp->qtot;
# Line 1233  void CaloLong::Fit(Bool_t draw){ Line 1262  void CaloLong::Fit(Bool_t draw){
1262    //  lfit->SetParLimits(0,0.,1000.);    //  lfit->SetParLimits(0,0.,1000.);
1263    //  lfit->SetParLimits(1,-1.,80.);    //  lfit->SetParLimits(1,-1.,80.);
1264    //  lfit->SetParLimits(2,-1.,10.);    //  lfit->SetParLimits(2,-1.,10.);
1265    //  TString optio = "ROW"; // "RO"    // TString optio = "ROW"; // "RO"
1266    TString optio = "RO"; // "RO"    TString optio = "RO"; // "RO"
1267    if ( debug ){    if ( debug ){
1268      optio += "NV";      optio += "NV";
# Line 1243  void CaloLong::Fit(Bool_t draw){ Line 1272  void CaloLong::Fit(Bool_t draw){
1272      if ( draw ) optio += "Q";      if ( draw ) optio += "Q";
1273    };    };
1274    //    //
1275    if ( debug ) printf(" OK, start the fitting procedure...\n");    if ( debug ) printf(" OK, start the fitting procedure... options: %s \n",optio.Data());
1276    //    //
1277    //  fitresult = th->Fit("lfit",optio);    //  fitresult = th->Fit("lfit",optio);
1278      //  lfit->Update();
1279    fitresult = gh->Fit("lfit",optio);    fitresult = gh->Fit("lfit",optio);
1280      //  fitresult = gh->Fit("lfit","ROQW");
1281    //    //
1282    if ( debug ) printf(" the fit is done! result: %i \n",fitresult);    if ( debug ) printf(" the fit is done! result: %i \n",fitresult);
1283    //    //
# Line 1290  void CaloLong::Fit(Bool_t draw){ Line 1321  void CaloLong::Fit(Bool_t draw){
1321      delete w;      delete w;
1322      delete xp;      delete xp;
1323      delete wp;      delete wp;
1324        delete xpp;
1325        delete wpp;
1326      //    Float_t i10max = lfit->Integral(0.,10.*tmax);      //    Float_t i10max = lfit->Integral(0.,10.*tmax);
1327      if ( debug ) printf(" Integral: %f \n",i10max);      if ( debug ) printf(" Integral: %f \n",i10max);
1328      //      //
# Line 1340  void CaloLong::Fit(Bool_t draw){ Line 1373  void CaloLong::Fit(Bool_t draw){
1373      if ( th ) th->Delete();      if ( th ) th->Delete();
1374    };    };
1375    //    //
1376    //   gMinuit->SetPrintLevel(1);
1377    //   gMinuit->mnamin();
1378    //   //  gMinuit->mnfree(0);
1379    //   gMinuit->mncler();
1380    //   gMinuit->mnrset(1);
1381      //  gMinuit->Delete();
1382      //ROOT::Math::Minimizer::Clear();
1383      //  gMinuit->mnhelp("*");
1384      //
1385    //  delete lfit;    //  delete lfit;
1386    //    //
1387  };  };
# Line 1369  void CaloLong::Draw(Int_t view){ Line 1411  void CaloLong::Draw(Int_t view){
1411    //    //
1412    if ( maxv != -1 ){    if ( maxv != -1 ){
1413      for (Int_t v=minv; v<maxv;v++){      for (Int_t v=minv; v<maxv;v++){
1414        TString hid = Form("clongv%i",v);        TString hid = Form("clongv%i%s",v,suf.Data());    
1415        TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));        TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1416        if ( tc ){        if ( tc ){
1417          //       tc->Clear();          //       tc->Clear();
# Line 1377  void CaloLong::Draw(Int_t view){ Line 1419  void CaloLong::Draw(Int_t view){
1419          tc = new TCanvas(hid,hid);          tc = new TCanvas(hid,hid);
1420        };        };
1421        //        //
1422        TString thid = Form("hlongv%i",v);                TString thid = Form("hlongv%i%s",v,suf.Data());  
1423        TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));        TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));
1424        if ( th ) th->Delete();        if ( th ) th->Delete();
1425        //         th->Clear();        //         th->Clear();
# Line 1396  void CaloLong::Draw(Int_t view){ Line 1438  void CaloLong::Draw(Int_t view){
1438      };      };
1439    } else {    } else {
1440      //      //
1441      TString hid = Form("clongvyvx");          TString hid = Form("clongvyvx%s",suf.Data());      
1442      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));      TCanvas *tc  = dynamic_cast<TCanvas*>(gDirectory->FindObject(hid));
1443      if ( tc ){      if ( tc ){
1444      } else {      } else {
1445        tc = new TCanvas(hid,hid);        tc = new TCanvas(hid,hid);
1446      };      };
1447      //      //
1448      TString thid = Form("hlongvyvx");        TString thid = Form("hlongvyvx%s",suf.Data());      
1449      TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));      TH1F *th  = dynamic_cast<TH1F*>(gDirectory->FindObject(thid));
1450      if ( th ) th->Delete();      if ( th ) th->Delete();
1451      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.12  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.23