ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/AachenCompatibility.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/AachenCompatibility.C (file contents):
Revision 1.1 by buchmann, Wed Jul 4 14:35:57 2012 UTC vs.
Revision 1.2 by buchmann, Wed Jul 4 18:38:59 2012 UTC

# Line 1 | Line 1
1 < TTree* SkimTreeAndAachifyIt(int isample) {
2 <  TTree* newTree = new TTree("newTree","FullTree");
1 > TTree* SkimTreeAndAachifyIt(TCut eventselection, string treename, int isample, string jzbexpression, samplecollection &scollection) {
2 >  TTree* newTree = new TTree(treename.c_str(),treename.c_str());
3    float AachenWeight,AachenchargeProduct,Aachenpt1,Aachenpt2;
4    
5    newTree->Branch("weight",&AachenWeight,"weight/F");
6 //  initFloatBranch( "weight" );
6    newTree->Branch("chargeProduct",&AachenchargeProduct,"chargeProduct/F");
8 //   initFloatBranch( "chargeProduct" );  
7    newTree->Branch("pt1",&Aachenpt1,"pt1/F");
10 //   initFloatBranch( "pt1" );
8    newTree->Branch("pt2",&Aachenpt2,"pt2/F");
9 < //   initFloatBranch( "pt2" );
10 <  float ETHid1,ETHid2,ETHweight,ETHpt1,ETHpt2;
11 <  allsamples.collection[isample].events->SetBranchAddress("id1",&ETHid1);
12 <  allsamples.collection[isample].events->SetBranchAddress("id2",&ETHid2);
13 <  allsamples.collection[isample].events->SetBranchAddress("weight",&ETHweight);
14 <  allsamples.collection[isample].events->SetBranchAddress("pt1",&ETHpt1);
15 <  allsamples.collection[isample].events->SetBranchAddress("pt2",&ETHpt2);
9 >  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    
19    
20    float Aacheneta1,Aacheneta2,Aachenid1,Aachenid2,Aachenjzb,Aachenht,Aachenmet;
21    newTree->Branch("eta1",&Aacheneta1,"eta1/F");
23 //   initFloatBranch( "eta1" );
22    newTree->Branch("eta2",&Aacheneta2,"eta2/F");
25 //   initFloatBranch( "eta2" );
23    newTree->Branch("id1",&Aachenid1,"id1/F");
27 //   initFloatBranch( "id1" ); // isolation
24    newTree->Branch("id2",&Aachenid2,"id2/F");
29 //   initFloatBranch( "id2" ); // isolation
25    newTree->Branch("jzb",&Aachenjzb,"jzb/F");
31 //   initFloatBranch( "jzb" );
26    newTree->Branch("ht",&Aachenht,"ht/F");
33 //   initFloatBranch( "ht" );
27    newTree->Branch("met",&Aachenmet,"met/F");
35 //   initFloatBranch( "met" );
28    
29    float ETHeta1,ETHeta2,ETHiso1,ETHiso2,ETHht;
30    float ETHjzb[30];
31    float ETHmet[30];
32 <  allsamples.collection[isample].events->SetBranchAddress("eta1",&ETHeta1);
33 <  allsamples.collection[isample].events->SetBranchAddress("eta2",&ETHeta2);
34 <  allsamples.collection[isample].events->SetBranchAddress("iso1",&ETHiso1);
35 <  allsamples.collection[isample].events->SetBranchAddress("iso2",&ETHiso2);
36 <  allsamples.collection[isample].events->SetBranchAddress("pfHT",&ETHht);
37 <  allsamples.collection[isample].events->SetBranchAddress("met",&ETHmet);
32 >  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    
39    
40    
41    float AachenpZeta,AachenpZetaVis,AachennJets,AachennBJets,AachennVertices,Aachenjet1pt,Aachenjet2pt,Aachenjet3pt,Aachenjet4pt;
42    newTree->Branch("pZeta",&AachenpZeta,"pZeta/F");
51 //   initFloatBranch( "pZeta" );
43    newTree->Branch("pZetaVis",&AachenpZetaVis,"pZetaVis/F");
53 //   initFloatBranch( "pZetaVis" );
44    newTree->Branch("nJets",&AachennJets,"nJets/F");
55 //   initIntBranch( "nJets" );
45    newTree->Branch("nBJets",&AachennBJets,"nBJets/F");
57 //   initIntBranch( "nBJets" );
46    newTree->Branch("nVertices",&AachennVertices,"nVertices/F");
59 //   initIntBranch( "nVertices" );
47    newTree->Branch("jet1pt",&Aachenjet1pt,"jet1pt/F");
61 //   initFloatBranch( "jet1pt" );
48    newTree->Branch("jet2pt",&Aachenjet2pt,"jet2pt/F");
63 //   initFloatBranch( "jet2pt" );
49    newTree->Branch("jet3pt",&Aachenjet3pt,"jet3pt/F");
65 //   initFloatBranch( "jet3pt" );
50    newTree->Branch("jet4pt",&Aachenjet4pt,"jet4pt/F");
67 //   initFloatBranch( "jet4pt" );
51    
52 <  float ETHeta,ETHnjets,ETHnBJets,ETHnVertices;
52 >  float ETHeta;
53 >  int ETHnjets,ETHnBJets,ETHnVertices;
54    float ETHjetPt[30];
55 <  allsamples.collection[isample].events->SetBranchAddress("eta",&ETHeta);
56 <  allsamples.collection[isample].events->SetBranchAddress("pfJetGoodNum",&ETHnjets);
57 <  allsamples.collection[isample].events->SetBranchAddress("pfJetGoodNumBtag",&ETHnBJets);
58 <  allsamples.collection[isample].events->SetBranchAddress("numVtx",&ETHnVertices);
59 <  allsamples.collection[isample].events->SetBranchAddress("pfJetGoodPt",&ETHjetPt);
55 >  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    
61    
62    
63    float Aachenbjet1pt;
64    int AachenrunNr,AachenlumiSec,AachenpdgId1,AachenpdgId2,AacheneventNr;
65    newTree->Branch("bjet1pt",&Aachenbjet1pt,"bjet1pt/F");
82 //   initFloatBranch( "bjet1pt" );
66    newTree->Branch("runNr",&AachenrunNr,"runNr/I");
84 //   initIntBranch( "runNr" );
67    newTree->Branch("lumiSec",&AachenlumiSec,"lumiSec/I");
86 //   initIntBranch( "lumiSec" );
68    newTree->Branch("eventNr",&AacheneventNr,"eventNr/I");
88 //   initIntBranch( "eventNr" );
69    newTree->Branch("pdgId1",&AachenpdgId1,"pdgId1/I");
90 //   initIntBranch( "pdgId1" );
70    newTree->Branch("pdgId2",&AachenpdgId2,"pdgId2/I");
92 //   initIntBranch( "pdgId2" );
71    
72 <  float ETHBJetPt;
73 <  int ETHrunNum,ETHlumi,ETHevent,ETHgenId1,ETHgenId2;
74 <  allsamples.collection[isample].events->SetBranchAddress("runNum",&ETHrunNum);
75 <  allsamples.collection[isample].events->SetBranchAddress("lumi",&ETHlumi);
76 <  allsamples.collection[isample].events->SetBranchAddress("eventNum",&ETHevent);
77 <  allsamples.collection[isample].events->SetBranchAddress("genId1",&ETHgenId1);
78 <  allsamples.collection[isample].events->SetBranchAddress("genId2",&ETHgenId2);
72 >  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    
81  
82    float ETHmll;
83 <  allsamples.collection[isample].events->SetBranchAddress("mll",&ETHmll);
105 <
106 < /*
107 < e ist pt1, mu ist pt2
108 < pt1 ist subleading lepton, pt2 leading
109 < fuege mll zu
110 < correctedJZB
111 < */
112 <
113 <  
83 >  scollection.collection[isample].events->SetBranchAddress("mll",&ETHmll);
84    
85 <  
86 < //  int id1,id2;
87 <  
88 <  TTreeFormula *select = new TTreeFormula("select", "pfJetGoodNum>4", allsamples.collection[isample].events);
89 <  for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) {
90 <   allsamples.collection[isample].events->LoadTree(entry);
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 <     allsamples.collection[isample].events->GetEntry(entry);
94 <     cout << ETHrunNum << endl;
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 >
106 >       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 >
122 >        
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       newTree->Fill();
158     }
159    }
160    
161 <  if(EdgeFitter::MarcoDebug) cout << "     Reduced tree contains " << newTree->GetEntries() << " entries " << endl;
161 >  dout << "     Reduced tree (" << newTree->GetName() << ") contains " << newTree->GetEntries() << " entries " << endl;
162    return newTree;
163   }
164  
165 < void CastETHtoAachenNtuple() {
166 <  TTree *completetree;
134 <  write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)");
135 <  TList *treelist = new TList;
136 <  int is_data=1;
137 <  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
138 <    if(!allsamples.collection[isample].is_active) continue;
139 <    if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
140 <    if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
141 <    if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC
142 <    if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it.
143 <    if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl;
144 <    treelist->Add(SkimTreeAndAachifyIt(isample));
145 <  }
146 <  completetree = TTree::MergeTrees(treelist);
147 <  if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl;
165 > void CastETHtoAachenNtuple(string jzbexpression) {
166 >  bool do_simulation=true;
167    
168 <  TFile *f = new TFile("AachenTree.root","RECREATE");
169 <  completetree->Write();
168 >  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    f->Close();
152  
192   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines