• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/cern-oct11/go4/AnalysisMacros/plotSpectra.cxx (r4864/r2323)

Go to the documentation of this file.
00001 #ifndef __CINT__
00002 #include "Riostream.h"
00003 #include "TRint.h"
00004 #include "TROOT.h"
00005 #include "TStyle.h"
00006 #include "Riostream.h"
00007 
00008 
00009 #include "TH2.h"
00010 #include "TH1.h"
00011 #include "TF1.h"
00012 
00013 #include "TGraph.h"
00014 #include "TMultiGraph.h"
00015 #include "TCanvas.h"
00016 #include "TProfile.h"
00017 #include "TStopwatch.h"
00018 
00019 #include "TFile.h"
00020 #include "TTree.h"
00021 #include "TBranch.h"
00022 #include "TMath.h"
00023 #include "TLegend.h"
00024 #include "TColor.h"
00025 #include "TText.h"
00026 #include "TKey.h"
00027 #include "TLatex.h"
00028 #include "TCanvas.h"
00029 #include "TLine.h"
00030 
00031 #endif
00032 
00033 using namespace std;
00034 
00035 void plotSpectra( Bool_t debug) {
00036   TString ifname;
00037   TString folder = "data2011/Analysis/";
00038   TString title, newtitle;
00039   const Int_t settings = 13;
00040   TString file[settings] = {
00041     "MS_HVScan_1",
00042     "MS_HVScan_2",
00043     "MS_HVScan_3",
00044     "MS_HVScan_4",
00045     "MS_HVScan_5",
00046     "MS_RadiatorScan_1",
00047     "MS_RadiatorScan_2",
00048     "MS_RadiatorScan_3",
00049     "MS_RadiatorScan_4",
00050     "MS_RadiatorScan_5",
00051     "MS_RadiatorScan_6",
00052     "MS_RadiatorScan_7",
00053     "MS_RadiatorScan_8"
00054   };
00055   Int_t lcolor[settings] = {    1,    2,    3,    4,    6,    1,    2,    3,    4,    6,    7,    8,    9  };
00056   Int_t lstyle[settings] = {    1,    1,    2,    2,    2,    1,    1,    1,    1,    1,    1,    1,    1  };
00057   const Int_t usedSusibos = 8;
00058   const Int_t recoSets = 9;
00059   Int_t usedSuId[usedSusibos] = {         2,         12,        6,        18,         4,         5,        16,        17  };
00060   TString recoSetName[recoSets] = {"ClusterInteg","3PadInteg","1PadInteg","ClusterIntegWindow","3PadIntegWindow","1PadIntegWindow","ClusterAmpl","3PadAmpl","1PadAmpl"};
00061   Double_t y_max[recoSets] =      {          0.03,       0.03,       0.05,         0.12,        0.12,         0.12,         0.07,        0.07,        0.07};
00062 
00063 
00064   TH1D* hElectronSpectra[usedSusibos][recoSets][settings];
00065   TH1D* hPionSpectra[usedSusibos][recoSets][settings];
00066 
00067   Int_t xRes(12000), yRes(4000);
00068   if (debug) {
00069     xRes = 1200;
00070     yRes = 400;
00071   }
00072 
00073   TCanvas *e = new TCanvas("e","e",xRes,yRes);
00074   e->Divide(usedSusibos,recoSets);
00075 
00076   TCanvas *p = new TCanvas("p","p",xRes,yRes);
00077   p->Divide(usedSusibos,recoSets);
00078 
00079   TCanvas *c = new TCanvas("c","c",xRes/10,yRes);
00080   c->Divide(2,recoSets);
00081 
00082 
00083 
00084   //for (Int_t set = 0; set < settings; set++) {/*settings*/
00085   for (Int_t iset = 0; iset < settings; iset++) {
00086     ifname = file[iset];
00087     TFile inputFile(folder + ifname.Append(".root"));
00088     if (!inputFile.IsOpen()) {
00089       cout << "Error: " << TString(folder + TString(ifname(0,ifname.Sizeof()-5)).Append(".root")).Data() << " not found." << endl;
00090       return;
00091     } 
00092 
00093 
00094    
00095     // -------------------------------------------------------------------   clone spectra from readtree_spadic() output file
00096     for (Int_t suid = 0; suid < usedSusibos; suid++){
00097       for (Int_t rs = 0; rs < recoSets; rs++) {
00098         
00099         title.Form("preCompSpectra%sEl_%i",recoSetName[rs].Data(),usedSuId[suid]);
00100         newtitle.Form("Spectra_%s_%sEl_%i",file[iset].Data(),recoSetName[rs].Data(),usedSuId[suid]);
00101         hElectronSpectra[suid][rs][iset] = (TH1D*)inputFile.Get(title)->Clone(newtitle);
00102         if (rs < 3) {
00103           //hElectronSpectra[suid][rs][iset]->Rebin(5);
00104           hElectronSpectra[suid][rs][iset]->GetXaxis()->SetRangeUser(0,2000);
00105           hElectronSpectra[suid][rs][iset]->GetYaxis()->SetRangeUser(1e-6,y_max[rs]);
00106         }
00107         else {
00108           hElectronSpectra[suid][rs][iset]->GetXaxis()->SetRangeUser(0,1000);
00109           hElectronSpectra[suid][rs][iset]->GetYaxis()->SetRangeUser(1e-6,y_max[rs]);
00110         }
00111         hElectronSpectra[suid][rs][iset]->SetLineColor(lcolor[iset]);
00112         hElectronSpectra[suid][rs][iset]->SetLineStyle(lstyle[iset]);
00113       
00114         e->cd(rs * usedSusibos + suid + 1);
00115         if (iset==0 || iset == 5)
00116           hElectronSpectra[suid][rs][iset]->DrawCopy();
00117         else
00118           hElectronSpectra[suid][rs][iset]->DrawCopy("same");
00119         e->Update();
00120 
00121         c->cd(rs * 2 + 1);
00122         if (iset==0 || iset == 5)
00123           hElectronSpectra[suid][rs][iset]->DrawCopy();
00124         else
00125           hElectronSpectra[suid][rs][iset]->DrawCopy("same");
00126         c->Update();
00127 
00128 
00129         title.Form("preCompSpectra%sPi_%i",recoSetName[rs].Data(),usedSuId[suid]);
00130         newtitle.Form("Spectra_%s_%sPi_%i",file[iset].Data(),recoSetName[rs].Data(),usedSuId[suid]);
00131         hPionSpectra[suid][rs][iset] = (TH1D*)inputFile.Get(title)->Clone(newtitle);
00132         if (rs < 3) {
00133           //hPionSpectra[suid][rs][iset]->Rebin(5);
00134           hPionSpectra[suid][rs][iset]->GetXaxis()->SetRangeUser(0,2000);
00135           hPionSpectra[suid][rs][iset]->GetYaxis()->SetRangeUser(1e-6,y_max[rs]);
00136         }
00137         else {
00138           hPionSpectra[suid][rs][iset]->GetXaxis()->SetRangeUser(0,1000);
00139           hPionSpectra[suid][rs][iset]->GetYaxis()->SetRangeUser(1e-6,y_max[rs]);
00140         }
00141         hPionSpectra[suid][rs][iset]->SetLineColor(lcolor[iset]);
00142         hPionSpectra[suid][rs][iset]->SetLineStyle(lstyle[iset]);
00143 
00144         p->cd(rs * usedSusibos + suid + 1);
00145         if (iset==0 || iset == 5)
00146           hPionSpectra[suid][rs][iset]->DrawCopy();
00147         else
00148           hPionSpectra[suid][rs][iset]->DrawCopy("same");
00149         p->Update();
00150 
00151         c->cd(rs * 2 + 2);
00152         if (iset==0 || iset == 5)
00153           hPionSpectra[suid][rs][iset]->DrawCopy();
00154         else
00155           hPionSpectra[suid][rs][iset]->DrawCopy("same");
00156         c->Update();
00157 
00158       }
00159     }
00160     if (iset == 4) {
00161       e->SaveAs(folder + "Pics/HV_Scan_ESpectra" + ".png");
00162       p->SaveAs(folder + "Pics/HV_Scan_PSpectra" + ".png");
00163     }
00164     if (iset == 12) {
00165       e->SaveAs(folder + "Pics/Radiator_Scan_ESpectra" + ".png");
00166       p->SaveAs(folder + "Pics/Radiator_Scan_PSpectra" + ".png");
00167     }
00168   }  
00169   //e->SaveAs(folder + "Pics/" + TString(ifname(0,ifname.Sizeof()-5)) + "_ESpectra" + ".png");
00170   //p->SaveAs(folder + "Pics/" + TString(ifname(0,ifname.Sizeof()-5)) + "_PSpectra" + ".png");
00171 }

Generated on Tue Dec 10 2013 04:52:16 for ROCsoft by  doxygen 1.7.1