ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/AachenCompatibility.C
Revision: 1.2
Committed: Wed Jul 4 18:38:59 2012 UTC (12 years, 10 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.1: +130 -91 lines
Log Message:
Added possibility to provide aachen trees, based our trees

File Contents

# User Rev Content
1 buchmann 1.2 TTree* SkimTreeAndAachifyIt(TCut eventselection, string treename, int isample, string jzbexpression, samplecollection &scollection) {
2     TTree* newTree = new TTree(treename.c_str(),treename.c_str());
3 buchmann 1.1 float AachenWeight,AachenchargeProduct,Aachenpt1,Aachenpt2;
4    
5     newTree->Branch("weight",&AachenWeight,"weight/F");
6     newTree->Branch("chargeProduct",&AachenchargeProduct,"chargeProduct/F");
7     newTree->Branch("pt1",&Aachenpt1,"pt1/F");
8     newTree->Branch("pt2",&Aachenpt2,"pt2/F");
9 buchmann 1.2 float ETHweight,ETHpt1,ETHpt2;
10     int ETHid1,ETHid2,ETHch1,ETHch2;
11     scollection.collection[isample].events->SetBranchAddress("id1",&ETHid1);
12     scollection.collection[isample].events->SetBranchAddress("id2",&ETHid2);
13     scollection.collection[isample].events->SetBranchAddress("weight",&ETHweight);
14     scollection.collection[isample].events->SetBranchAddress("pt1",&ETHpt1);
15     scollection.collection[isample].events->SetBranchAddress("pt2",&ETHpt2);
16     scollection.collection[isample].events->SetBranchAddress("ch1",&ETHch1);
17     scollection.collection[isample].events->SetBranchAddress("ch2",&ETHch2);
18 buchmann 1.1
19    
20     float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet;
21     newTree->Branch("eta1",&Aacheneta1,"eta1/F");
22     newTree->Branch("eta2",&Aacheneta2,"eta2/F");
23     newTree->Branch("id1",&Aachenid1,"id1/F");
24     newTree->Branch("id2",&Aachenid2,"id2/F");
25     newTree->Branch("jzb",&Aachenjzb,"jzb/F");
26     newTree->Branch("ht",&Aachenht,"ht/F");
27     newTree->Branch("met",&Aachenmet,"met/F");
28    
29     float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht;
30     float ETHjzb[30];
31     float ETHmet[30];
32 buchmann 1.2 scollection.collection[isample].events->SetBranchAddress("eta1",&ETHeta1);
33     scollection.collection[isample].events->SetBranchAddress("eta2",&ETHeta2);
34     scollection.collection[isample].events->SetBranchAddress("iso1",&ETHiso1);
35     scollection.collection[isample].events->SetBranchAddress("iso2",&ETHiso2);
36     scollection.collection[isample].events->SetBranchAddress("pfHT",&ETHht);
37     scollection.collection[isample].events->SetBranchAddress("met",&ETHmet);
38 buchmann 1.1
39    
40    
41     float AachenpZeta,AachenpZetaVis,AachennJets,AachennBJets,AachennVertices,Aachenjet1pt,Aachenjet2pt,Aachenjet3pt,Aachenjet4pt;
42     newTree->Branch("pZeta",&AachenpZeta,"pZeta/F");
43     newTree->Branch("pZetaVis",&AachenpZetaVis,"pZetaVis/F");
44     newTree->Branch("nJets",&AachennJets,"nJets/F");
45     newTree->Branch("nBJets",&AachennBJets,"nBJets/F");
46     newTree->Branch("nVertices",&AachennVertices,"nVertices/F");
47     newTree->Branch("jet1pt",&Aachenjet1pt,"jet1pt/F");
48     newTree->Branch("jet2pt",&Aachenjet2pt,"jet2pt/F");
49     newTree->Branch("jet3pt",&Aachenjet3pt,"jet3pt/F");
50     newTree->Branch("jet4pt",&Aachenjet4pt,"jet4pt/F");
51    
52 buchmann 1.2 float ETHeta;
53     int ETHnjets,ETHnBJets,ETHnVertices;
54 buchmann 1.1 float ETHjetPt[30];
55 buchmann 1.2 scollection.collection[isample].events->SetBranchAddress("eta",&ETHeta);
56     scollection.collection[isample].events->SetBranchAddress("pfJetGoodNum",&ETHnjets);
57     scollection.collection[isample].events->SetBranchAddress("pfJetGoodNumBtag",&ETHnBJets);
58     scollection.collection[isample].events->SetBranchAddress("numVtx",&ETHnVertices);
59     scollection.collection[isample].events->SetBranchAddress("pfJetGoodPt",&ETHjetPt);
60 buchmann 1.1
61    
62    
63     float Aachenbjet1pt;
64     int AachenrunNr,AachenlumiSec,AachenpdgId1,AachenpdgId2,AacheneventNr;
65     newTree->Branch("bjet1pt",&Aachenbjet1pt,"bjet1pt/F");
66     newTree->Branch("runNr",&AachenrunNr,"runNr/I");
67     newTree->Branch("lumiSec",&AachenlumiSec,"lumiSec/I");
68     newTree->Branch("eventNr",&AacheneventNr,"eventNr/I");
69     newTree->Branch("pdgId1",&AachenpdgId1,"pdgId1/I");
70     newTree->Branch("pdgId2",&AachenpdgId2,"pdgId2/I");
71    
72 buchmann 1.2 float ETHBJetPt[30];
73     int ETHlumi,ETHrunNum,ETHgenId1,ETHgenId2;
74     ULong64_t ETHevent;
75     scollection.collection[isample].events->SetBranchAddress("runNum",&ETHrunNum);
76     scollection.collection[isample].events->SetBranchAddress("lumi",&ETHlumi);
77     scollection.collection[isample].events->SetBranchAddress("eventNum",&ETHevent);
78     scollection.collection[isample].events->SetBranchAddress("genId1",&ETHgenId1);
79     scollection.collection[isample].events->SetBranchAddress("genId2",&ETHgenId2);
80 buchmann 1.1
81    
82     float ETHmll;
83 buchmann 1.2 scollection.collection[isample].events->SetBranchAddress("mll",&ETHmll);
84    
85     float Aachenmll;
86     newTree->Branch("inv",&Aachenmll,"inv/F");
87    
88     TTreeFormula *JZBExpression = new TTreeFormula("jzbexpression",jzbexpression.c_str(),scollection.collection[isample].events);
89     TTreeFormula *select = new TTreeFormula("select", eventselection&&"(passed_triggers||!is_data)", scollection.collection[isample].events);
90     for (Int_t entry = 0 ; entry < scollection.collection[isample].events->GetEntries() ; entry++) {
91     scollection.collection[isample].events->LoadTree(entry);
92     if (select->EvalInstance()) {
93     scollection.collection[isample].events->GetEntry(entry);
94     AachenWeight=ETHweight;
95     AachenchargeProduct=ETHch1*ETHch2;
96     if(ETHid1==ETHid2) {
97     //ee or mm event: pt1 is the subleading, pt2 the leading one (Aachen convention)
98     Aachenpt1=ETHpt2;
99     Aachenpt2=ETHpt1;
100     Aacheneta1=ETHeta2;
101     Aacheneta2=ETHeta1;
102    
103     Aachenid1=ETHiso2;
104     Aachenid2=ETHeta1;
105 buchmann 1.1
106 buchmann 1.2 AachenpdgId1=ETHgenId2;
107     AachenpdgId2=ETHgenId1;
108     } else {
109     //emu event
110     if(ETHid1==0) {
111     Aachenpt1=ETHpt1; //electron
112     Aacheneta1=ETHeta1;
113     Aachenid1=ETHiso1;
114    
115     Aachenpt2=ETHpt2;//muon
116     Aacheneta2=ETHeta2;
117     Aachenid2=ETHiso2;
118    
119     AachenpdgId1=ETHgenId1;
120     AachenpdgId2=ETHgenId2;
121 buchmann 1.1
122 buchmann 1.2
123     } else {
124     Aachenpt1=ETHpt2; //electron
125     Aacheneta1=ETHeta2;
126     Aachenid1=ETHiso2;
127    
128     Aachenpt2=ETHpt1;//muon
129     Aacheneta2=ETHeta1;
130     Aachenid2=ETHiso1;
131    
132     AachenpdgId1=ETHgenId1;
133     AachenpdgId2=ETHgenId2;
134     }
135     }
136     Aachenht=ETHht;
137     Aachenmet=ETHmet[2];
138     Aachenjzb=JZBExpression->EvalInstance();
139     if(Aachenjzb<0 && ETHid1!=ETHid2) AachenWeight=-1 * AachenWeight;
140     Aachenmll=ETHmll;
141    
142     AachenpZeta=ETHeta;
143     AachenpZetaVis=0.0;
144     AachennJets=ETHnjets;
145     AachennBJets=ETHnBJets;
146     AachennVertices=ETHnVertices;
147     Aachenjet1pt=ETHjetPt[0];
148     Aachenjet2pt=ETHjetPt[1];
149     Aachenjet3pt=ETHjetPt[2];
150     Aachenjet4pt=ETHjetPt[3];
151    
152     Aachenbjet1pt=ETHBJetPt[0];
153     AachenrunNr=ETHrunNum;
154     AachenlumiSec=ETHlumi;
155     AacheneventNr=ETHevent;
156    
157 buchmann 1.1 newTree->Fill();
158     }
159     }
160    
161 buchmann 1.2 dout << " Reduced tree (" << newTree->GetName() << ") contains " << newTree->GetEntries() << " entries " << endl;
162 buchmann 1.1 return newTree;
163     }
164    
165 buchmann 1.2 void CastETHtoAachenNtuple(string jzbexpression) {
166     bool do_simulation=true;
167 buchmann 1.1
168 buchmann 1.2 stringstream jzbcut;
169     jzbcut << "abs(" << jzbexpression << ")>100";
170     TCut basecut(("pfJetGoodNum>=3&&"+jzbcut.str()).c_str());
171    
172     TTree *eetree;
173     TTree *mmtree;
174     TTree *emtree;
175     if(do_simulation) {
176     eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree", 1,jzbexpression,signalsamples);
177     mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1" ,"MuMuDileptonTree",1,jzbexpression,signalsamples);
178     emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2" ,"EMuDileptonTree", 1,jzbexpression,signalsamples);
179     } else {
180     eetree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==0","EEDileptonTree", 0,jzbexpression,allsamples);
181     mmtree = SkimTreeAndAachifyIt(basecut&&"id1==id2&&id1==1" ,"MuMuDileptonTree",0,jzbexpression,allsamples);
182     emtree = SkimTreeAndAachifyIt(basecut&&"id1!=id2" ,"EMuDileptonTree", 0,jzbexpression,allsamples);
183     }
184    
185     TFile *f = new TFile("Aachen_Sample.root","RECREATE");
186     f->mkdir("ETH2AachenNtuples");
187     f->cd("ETH2AachenNtuples");
188     eetree->Write();
189     mmtree->Write();
190     emtree->Write();
191 buchmann 1.1 f->Close();
192     }