3 TChain *all =
new TChain(treename.c_str());
5 for (
int i = 0;
i < filecount; ++
i)
10 temp = name+
string(s.str())+extension;
11 all->Add(temp.c_str());
22 TEfficiency*
makepTRes(TFile* out_file,TChain* ttree=NULL,TTree* allTree=NULL){
24 out_file->ReOpen(
"READ");
25 if(out_file->Get(
"converted_photon_truth_pT")&&out_file->Get(
"all_photon_truth_pT"))
26 return new TEfficiency(*(TH1F*)out_file->Get(
"converted_photon_truth_pT"),*(TH1F*)out_file->Get(
"all_photon_truth_pT"));
28 else if(!ttree||!allTree){
31 out_file->ReOpen(
"UPDATE");
35 ttree->SetBranchAddress(
"photon_pT",&pT);
36 ttree->SetBranchAddress(
"tphoton_pT",&tpT);
38 vector<float> *allpT=NULL;
39 allTree->SetBranchAddress(
"photon_pT",&allpT);
41 TH1F *pTeffPlot =
new TH1F(
"#frac{#it{p}^{T}}{#it{p}_{#it{truth}}^{T}}",
"",40,-2,2);
42 TH2F *pTefffuncPlot =
new TH2F(
"pT_resolution_to_truthpt",
"",40,1,35,40,-1.5,1.5);
43 TH1F *converted_pTspec =
new TH1F(
"converted_photon_truth_pT",
"",20,5,25);
44 TH1F *all_pTspec =
new TH1F(
"all_photon_truth_pT",
"",20,5,25);
47 converted_pTspec->Sumw2();
49 pTefffuncPlot->Sumw2();
52 for (
int event = 0;
event < ttree->GetEntries(); ++
event)
54 ttree->GetEvent(
event);
55 if(pT>0)pTeffPlot->Fill(pT/tpT);
56 converted_pTspec->Fill(tpT);
57 if(pT>0)pTefffuncPlot->Fill(tpT,pT/tpT);
61 for (
int event = 0;
event < allTree->GetEntries(); ++
event)
63 allTree->GetEvent(
event);
69 TEfficiency* uni_rate =
new TEfficiency(*converted_pTspec,*all_pTspec);
70 uni_rate->SetName(
"uni_rate");
72 pTeffPlot->Scale(1./ttree->GetEntries(),
"width");
73 pTefffuncPlot->Scale(1./ttree->GetEntries());
74 TProfile* resProfile = pTefffuncPlot->ProfileX(
"func_prof",5,30);
78 ttree->ResetBranchAddresses();
84 TFile *hardFile=
new TFile(name.c_str(),
"READ");
86 TFile *softFile=
new TFile(name.c_str(),
"READ");
87 TTree* noPhoton = (TTree*) softFile->Get(
"nophotonTree");
88 unsigned r=noPhoton->GetEntries()*2000000;
89 noPhoton = (TTree*) hardFile->Get(
"nophotonTree");
90 r+=noPhoton->GetEntries()*2000000;
99 TH1F* conversion_rate = (TH1F*)((TH1F*) file->Get(
"combinedpythia"))->Clone(
"rate");
101 TH1* uni_rate = (TH1F*)rate->GetPassedHistogram()->Clone(
"uni_rate");
102 uni_rate->Divide(rate->GetTotalHistogram());
103 conversion_rate->Multiply(uni_rate);
104 conversion_rate->Scale(1./nMB);
105 file->ReOpen(
"UPDATE");
106 conversion_rate->Write();
107 return conversion_rate;
111 TH1F *dplot =
new TH1F(
"derivative",
"",finalrate->GetNbinsX(),5,25);
112 for (
int i = 1;
i < finalrate->GetNbinsX(); ++
i)
115 dplot->SetBinContent(
i,finalrate->IntegralAndError(
i,finalrate->GetNbinsX(),
error));
116 dplot->SetBinError(
i,error);
122 TFile *out_file =
new TFile(
"effplots.root",
"UPDATE");
123 TEfficiency* uni_rate=
makepTRes(out_file);
124 string treeExtension =
".root";
126 string treePath =
"/sphenix/user/vassalli/gammasample/truthconversiononlineanalysis";
127 unsigned int nFiles=200;
128 TChain *ttree =
handleFile(treePath,treeExtension,
"cutTreeSignal",nFiles);
129 TChain *observations =
handleFile(treePath,treeExtension,
"observTree",nFiles);
130 cout<<
"Got tree: "<<ttree->GetName()<<
" and "<<ttree->GetEntries()<<
" entries"<<endl;
131 cout<<
"Got tree: "<<observations->GetName()<<
" and "<<observations->GetEntries()<<
" entries"<<endl;
132 uni_rate=
makepTRes(out_file,ttree,observations);
134 out_file->ReOpen(
"READ");
135 string treePath=
"/sphenix/user/vassalli/minBiasPythia/";
136 string softname =
"softana";
137 string hardname =
"hard4ana";
138 auto conversion_rate=
calculateRate(uni_rate,out_file,
totalMB(treePath,treeExtension,softname,hardname));