1 |
demattia |
1.1 |
#include <TH2.h>
|
2 |
|
|
#include <TStyle.h>
|
3 |
|
|
#include <TCanvas.h>
|
4 |
|
|
#include <TF1.h>
|
5 |
|
|
#include "tdr_style.C"
|
6 |
|
|
#include <TMath.h>
|
7 |
|
|
#include <iostream.h>
|
8 |
|
|
|
9 |
|
|
#include "RooRealVar.h"
|
10 |
|
|
#include "RooDataSet.h"
|
11 |
|
|
#include "RooAddPdf.h"
|
12 |
|
|
#include "RooGaussian.h"
|
13 |
|
|
#include "RooChebychev.h"
|
14 |
|
|
#include "RooCBShape.h"
|
15 |
|
|
#include "RooPlot.h"
|
16 |
|
|
#include "RooMCStudy.h"
|
17 |
|
|
#include "RooFitResult.h"
|
18 |
|
|
#include "RooThresholdCategory.h"
|
19 |
|
|
#include "RooBinningCategory.h"
|
20 |
|
|
#include "RooWorkspace.h"
|
21 |
|
|
#include "RooAbsData.h"
|
22 |
|
|
|
23 |
|
|
using namespace RooFit;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
void Loop_dataset_maker(TString finput = "TTree_Onia2MuMu_V9_PromptReco_v4.root", TString foutput ="Trigger_data_tree.root")
|
27 |
|
|
{
|
28 |
|
|
//RooRealVar* JpsiType = new RooRealVar("JpsiType","JpsiType",-5,5);
|
29 |
|
|
//RooRealVar* JpsiCharge = new RooRealVar("JpsiCharge","JpsiCharge",0,0);
|
30 |
|
|
//RooRealVar* Jpsict = new RooRealVar("Jpsict","Jpsict",-100,100);
|
31 |
|
|
//RooRealVar* JpsictErr = new RooRealVar("JpsictErr","JpsictErr",-100,100);
|
32 |
|
|
//RooRealVar* Jpsict_Gen = new RooRealVar("Jpsict_Gen","Jpsict_Gen",-100,100);
|
33 |
|
|
|
34 |
|
|
//RooRealVar* mag = new RooRealVar("Mag()","mag",0,10);
|
35 |
|
|
//RooRealVar* pt = new RooRealVar("Pt()","pt",0,60);
|
36 |
|
|
//RooRealVar* rap = new RooRealVar("Rapidity()","rap",-3,3);
|
37 |
|
|
|
38 |
|
|
Int_t JpsiType, JpsiCharge;
|
39 |
|
|
Double_t Jpsict, JpsictErr, Jpsict_Gen;
|
40 |
|
|
Double_t mag, pt, rap;
|
41 |
|
|
Double_t JpsiTypeout, JpsiChargeout, Jpsictout, JpsictErrout, Jpsict_Genout;
|
42 |
|
|
Int_t HLT_Mu5_Track2_Jpsi_v4;
|
43 |
|
|
|
44 |
|
|
//char MCType = "NP";
|
45 |
|
|
|
46 |
|
|
cout<<"made doubles"<<endl;
|
47 |
|
|
|
48 |
|
|
//RooArgSet s(*JpsiType, *JpsiCharge, *Jpsict, *JpsictErr, *Jpsict_Gen, *mag, *pt, *rap);
|
49 |
|
|
|
50 |
|
|
//RooDataSet* datatree = new RooDataSet("treedata","treedata",s);
|
51 |
|
|
|
52 |
|
|
Double_t JpsiP_x;
|
53 |
|
|
Double_t JpsiP_y;
|
54 |
|
|
Double_t JpsiP_z;
|
55 |
|
|
Double_t JpsiP_t;
|
56 |
|
|
|
57 |
|
|
TLorentzVector* JpsiP = new TLorentzVector(JpsiP_x,JpsiP_y,JpsiP_z,JpsiP_t);
|
58 |
|
|
|
59 |
|
|
cout<<"TLorentzVector ok"<<endl;
|
60 |
|
|
|
61 |
|
|
Long64_t maxEvents = 10000000;
|
62 |
|
|
|
63 |
|
|
TFile * file = new TFile(finput, "READ");//define file and open it
|
64 |
|
|
TFile * outfile = new TFile(foutput, "RECREATE");//opens a new file
|
65 |
|
|
|
66 |
|
|
cout<<"files defined"<<endl;
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
if( file->IsOpen() && outfile->IsOpen() ) //if the files have opened properly
|
70 |
|
|
{
|
71 |
|
|
TTree * intree = (TTree*)file->Get("data");//get the tree "data" into the pointer *tree
|
72 |
|
|
TTree * outtree = new TTree("outtree", "tree with branches for each Jpsi var");
|
73 |
|
|
|
74 |
|
|
outtree->Branch("Type",&JpsiType,"JpsiType/I");
|
75 |
|
|
outtree->Branch("Charge",&JpsiCharge,"JpsiCharge/I");
|
76 |
|
|
outtree->Branch("Ct",&Jpsict,"Jpsict/D");
|
77 |
|
|
outtree->Branch("CtErr",&JpsictErr,"JpsictErr/D");
|
78 |
|
|
outtree->Branch("CtTrue",&Jpsict_Gen,"Jpsict_Gen/D");
|
79 |
|
|
outtree->Branch("Mass",&mag,"mag/D");
|
80 |
|
|
outtree->Branch("Pt",&pt,"pt/D");
|
81 |
|
|
outtree->Branch("Y",&rap,"rap/D");
|
82 |
|
|
outtree->Branch("HLT_Mu5_Track2_Jpsi_v4",&HLT_Mu5_Track2_Jpsi_v4,"HLT_Mu5_Track2_Jpsi_v4/I");
|
83 |
|
|
//outtree->Branch("MCType",&MCType,"MCType/C");
|
84 |
|
|
|
85 |
|
|
cout<<"branches defined"<<endl;
|
86 |
|
|
|
87 |
|
|
intree->SetBranchAddress("JpsiP",&JpsiP);//links values of "JpsiP" in the tree to the TLorentzVector JpsiP defined above.
|
88 |
|
|
intree->SetBranchAddress("JpsiType",&JpsiType);
|
89 |
|
|
intree->SetBranchAddress("JpsiCharge",&JpsiCharge);
|
90 |
|
|
intree->SetBranchAddress("Jpsict",&Jpsict);
|
91 |
|
|
intree->SetBranchAddress("JpsictErr",&JpsictErr);
|
92 |
|
|
intree->SetBranchAddress("Jpsict_Gen",&Jpsict_Gen);
|
93 |
|
|
intree->SetBranchAddress("HLT_Mu5_Track2_Jpsi_v4",&HLT_Mu5_Track2_Jpsi_v4);
|
94 |
|
|
|
95 |
|
|
cout<<"branch addresses set"<<endl;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
Long64_t nentries = intree->GetEntries();//number of entries in the tree
|
99 |
|
|
if( (maxEvents != -1) && (nentries > maxEvents) ) nentries = maxEvents;//makes nentries to be read same as maxEvents. If maxEvents == -1, full tree is read
|
100 |
|
|
for( Long64_t i=0; i<nentries; ++i )//starts loop
|
101 |
|
|
{
|
102 |
|
|
intree->GetEntry(i);
|
103 |
|
|
|
104 |
|
|
mag = JpsiP->Mag();
|
105 |
|
|
pt = JpsiP->Pt();
|
106 |
|
|
rap = JpsiP->Rapidity();
|
107 |
|
|
|
108 |
|
|
outtree->Fill();
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
file->Close();
|
113 |
|
|
|
114 |
|
|
outfile->Write();
|
115 |
|
|
outfile->Close();
|
116 |
|
|
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|