ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Updater.cc
Revision: 1.4
Committed: Mon Nov 14 18:44:27 2011 UTC (13 years, 6 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: V21TauCand_0, EdmV40alpha, V21emuCand, EdmV33Jun12v2_consistent, Step2ForV33_v2, Step2ForV33_v1, EdmV33Jun12v2, EdmV33Jun12v1, EdmV33Jun12v0, Step2ForV32_v2, Step2ForV32_v1, Step2ForV32_v0, Step2ForV31_v0, EdmV32May24v0, EdmV31May21v1, EdmV31May17v0, EdmV30Apr10, EdmV21Apr10v2, EdmV22May9, EdmV21Apr06, EdmV21Apr10, EdmV21Apr04, EdmV21Apr03, EdmV21Apr2, EdmV21Mar30, EdmV20Mar12
Branch point for: V21TauCand, V21emuCandidate
Changes since 1.3: +38 -10 lines
Log Message:
update the updater as used to fix the PU if someone, e.g. Niklas, want to run locally rather than copying all updated diles

File Contents

# Content
1 #include <TH1F.h>
2 #include <TH3F.h>
3 #include <TH2F.h>
4 #include "PhysicsTools/Utilities/interface/LumiReWeighting.h"
5 #include "PhysicsTools/Utilities/interface/Lumi3DReWeighting.h"
6
7 #include <TROOT.h>
8 #include <TFile.h>
9 #include <TTree.h>
10 #include <TSystem.h>
11 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
12 #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
13 #include "DataFormats/Math/interface/deltaR.h"
14 #include "DataFormats/Math/interface/deltaPhi.h"
15
16 //btagging
17 #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h"
18 //#include "VHbbAnalysis/VHbbDataFormats/interface/BTagWeight.h"
19 #include "VHbbAnalysis/VHbbDataFormats/interface/HbbCandidateFinderAlgo.h"
20 #include "VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc"
21 #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidateTools.h"
22 #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerWeight.h"
23
24 #include <sstream>
25 #include <string>
26 #define nhJets_MAX 2
27 #define naJets_MAX 20
28
29 #define MAXJ 30
30 #define MAXL 10
31 #define MAXB 10
32 typedef struct
33 {
34 float et;
35 float sumet;
36 float sig;
37 float phi;
38 } METInfo;
39
40
41 int main(int argc, char* argv[])
42 {
43 gROOT->Reset();
44
45 // parse arguments
46 if ( argc < 2 ) {
47 return 0;
48 }
49 // get the python configuration
50 PythonProcessDesc builder(argv[1]);
51 const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
52 const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
53 const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
54 // now get each parameter
55 // int maxEvents_( in.getParameter<int>("maxEvents") );
56 // int skipEvents_( in.getParameter<int>("skipEvents") );
57 // unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
58 std::string outputFile_( out.getParameter<std::string>("fileName" ) );
59 std::string inputFile_( in.getParameter<std::string>("fileName" ) );
60 bool replaceWeights( ana.getParameter<bool>("replaceWeights" ) );
61 bool redoPU( ana.getParameter<bool>("redoPU" ) );
62 bool redoTrigger( ana.getParameter<bool>("redoTrigger" ) );
63 bool redoHiggs( ana.getParameter<bool>("redoHiggs" ) );
64
65 std::string Weight3DfileName_ = in.getParameter<std::string> ("Weight3DfileName") ;
66
67 TriggerWeight triggerWeight(ana);
68
69 edm::LumiReWeighting lumiWeights;
70 edm::Lumi3DReWeighting lumiWeights2011B;
71
72 HbbCandidateFinderAlgo finder(false, 20, true);
73 VHbbCandidateTools selector(false);
74
75
76 if(redoPU)
77 {
78 std::string PUmcfileName_ = in.getParameter<std::string> ("PUmcfileName") ;
79 std::string PUmcfileName2011B_ = in.getParameter<std::string> ("PUmcfileName2011B") ;
80 std::string PUdatafileName_ = in.getParameter<std::string> ("PUdatafileName") ;
81 std::string PUdatafileName2011B_ = in.getParameter<std::string> ("PUdatafileName2011B") ;
82 lumiWeights = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
83 lumiWeights2011B = edm::Lumi3DReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
84
85
86 //lumiWeights2011B.weight3D_init(); // generate the weights the fisrt time;
87 if(Weight3DfileName_!="")
88 { lumiWeights2011B.weight3D_init(Weight3DfileName_.c_str()); }
89 else
90 {
91 lumiWeights2011B.weight3D_init(73.5/68.); // generate the weights the fisrt time;
92 }
93
94
95 }
96
97
98
99 //Get old file, old tree and set top branch address
100 TFile *oldfile = new TFile(inputFile_.c_str());
101 TTree *oldtree = (TTree*)oldfile->Get("tree");
102 TH1F * count = (TH1F*)oldfile->Get("Count");
103 TH1F * countWithPU = (TH1F*)oldfile->Get("CountWithPU");
104 TH1F * countWithPU2011B = (TH1F*)oldfile->Get("CountWithPU2011B");
105 TH3F * input3DPU = (TH3F*)oldfile->Get("Input3DPU");
106
107
108 Int_t nentries = (Int_t)oldtree->GetEntries();
109 Int_t nvlep;
110 Float_t vLepton_pt[50];
111 Float_t vLepton_eta[50];
112 /* Int_t nhJets;
113 Float_t hJet_pt[50];
114 Float_t hJet_eta[50];
115 Int_t naJets;
116 Float_t aJet_pt[50];
117 Float_t aJet_eta[50];
118 */ Int_t Vtype;
119 METInfo MET;
120 Int_t nhJets;
121 Int_t naJets;
122 Float_t hJet_pt[nhJets_MAX];
123 Float_t hJet_eta[nhJets_MAX];
124 Float_t hJet_phi[nhJets_MAX];
125 Float_t hJet_e[nhJets_MAX];
126 Float_t hJet_csv[nhJets_MAX];
127 Float_t hJet_cosTheta[nhJets_MAX];
128 Int_t hJet_numTracksSV[nhJets_MAX];
129 Float_t hJet_chf[nhJets_MAX];
130 Float_t hJet_nhf[nhJets_MAX];
131 Float_t hJet_cef[nhJets_MAX];
132 Float_t hJet_nef[nhJets_MAX];
133 Float_t hJet_nch[nhJets_MAX];
134 Float_t hJet_nconstituents[nhJets_MAX];
135 Float_t hJet_flavour[nhJets_MAX];
136 Float_t hJet_genPt[nhJets_MAX];
137 Float_t hJet_genEta[nhJets_MAX];
138 Float_t hJet_genPhi[nhJets_MAX];
139 Float_t hJet_JECUnc[nhJets_MAX];
140 Float_t hJet_vtxMass[nhJets_MAX];
141 Float_t hJet_vtx3dL[nhJets_MAX];
142 Float_t hJet_vtx3deL[nhJets_MAX];
143 UChar_t hJet_id[nhJets_MAX];
144 Float_t aJet_pt[naJets_MAX];
145 Float_t aJet_eta[naJets_MAX];
146 Float_t aJet_phi[naJets_MAX];
147 Float_t aJet_e[naJets_MAX];
148 Float_t aJet_csv[naJets_MAX];
149 Float_t aJet_cosTheta[naJets_MAX];
150 Int_t aJet_numTracksSV[naJets_MAX];
151 Float_t aJet_chf[naJets_MAX];
152 Float_t aJet_nhf[naJets_MAX];
153 Float_t aJet_cef[naJets_MAX];
154 Float_t aJet_nef[naJets_MAX];
155 Float_t aJet_nch[naJets_MAX];
156 Float_t aJet_nconstituents[naJets_MAX];
157 Float_t aJet_flavour[naJets_MAX];
158 Float_t aJet_genPt[naJets_MAX];
159 Float_t aJet_genEta[naJets_MAX];
160 Float_t aJet_genPhi[naJets_MAX];
161 Float_t aJet_JECUnc[naJets_MAX];
162 Float_t aJet_vtxMass[naJets_MAX];
163 Float_t aJet_vtx3dL[naJets_MAX];
164 Float_t aJet_vtx3deL[naJets_MAX];
165 UChar_t aJet_id[naJets_MAX];
166
167 oldtree->SetBranchAddress("nvlep", &nvlep);
168 oldtree->SetBranchAddress("nhJets", &nhJets);
169 oldtree->SetBranchAddress("naJets", &naJets);
170
171 oldtree->SetBranchAddress("vLepton_pt", vLepton_pt);
172 oldtree->SetBranchAddress("vLepton_eta", vLepton_eta);
173
174 oldtree->SetBranchAddress("hJet_pt", hJet_pt);
175 oldtree->SetBranchAddress("hJet_eta", hJet_eta);
176
177 oldtree->SetBranchAddress("aJet_pt", aJet_pt);
178 oldtree->SetBranchAddress("aJet_eta", aJet_eta);
179
180 oldtree->SetBranchAddress("Vtype", &Vtype);
181 oldtree->SetBranchAddress("MET", &MET);
182
183 // Trigger weights
184 Float_t weightTrig;
185 Float_t weightTrigMay;
186 Float_t weightTrigV4;
187 Float_t weightTrigMET;
188 Float_t weightTrigOrMu30;
189 Float_t weightEleRecoAndId;
190 Float_t weightEleTrigJetMETPart;
191 Float_t weightEleTrigElePart;
192 if(replaceWeights)
193 {
194 std::cout << "Replacing the weights in the same branch names" << std::endl;
195 oldtree->SetBranchAddress("weightTrig", &weightTrig);
196 oldtree->SetBranchAddress("weightTrigMay", &weightTrigMay);
197 oldtree->SetBranchAddress("weightTrigV4", &weightTrigV4);
198 oldtree->SetBranchAddress("weightTrigMET", &weightTrigMET);
199 oldtree->SetBranchAddress("weightTrigOrMu30", &weightTrigOrMu30);
200 oldtree->SetBranchAddress("weightEleRecoAndId", &weightEleRecoAndId);
201 oldtree->SetBranchAddress("weightEleTrigJetMETPart", &weightEleTrigJetMETPart);
202 oldtree->SetBranchAddress("weightEleTrigElePart", &weightEleTrigElePart);
203 }
204 //Jet variables
205 // bool redoHiggs = true;
206 if(redoHiggs)
207 {
208 // oldtree->SetBranchAddress("nhJets", &nhJets);
209 // oldtree->SetBranchAddress("naJets", &naJets);
210 // oldtree->SetBranchAddress("hJet_pt", hJet_pt);
211 // oldtree->SetBranchAddress("hJet_eta", hJet_eta);
212 oldtree->SetBranchAddress("hJet_phi", hJet_phi);
213 oldtree->SetBranchAddress("hJet_e", hJet_e);
214 oldtree->SetBranchAddress("hJet_csv", hJet_csv);
215 oldtree->SetBranchAddress("hJet_cosTheta", hJet_cosTheta);
216 oldtree->SetBranchAddress("hJet_numTracksSV", hJet_numTracksSV);
217 oldtree->SetBranchAddress("hJet_chf", hJet_chf);
218 oldtree->SetBranchAddress("hJet_nhf", hJet_nhf);
219 oldtree->SetBranchAddress("hJet_cef", hJet_cef);
220 oldtree->SetBranchAddress("hJet_nef", hJet_nef);
221 oldtree->SetBranchAddress("hJet_nch", hJet_nch);
222 oldtree->SetBranchAddress("hJet_nconstituents", hJet_nconstituents);
223 oldtree->SetBranchAddress("hJet_flavour", hJet_flavour);
224 oldtree->SetBranchAddress("hJet_genPt", hJet_genPt);
225 oldtree->SetBranchAddress("hJet_genEta", hJet_genEta);
226 oldtree->SetBranchAddress("hJet_genPhi", hJet_genPhi);
227 oldtree->SetBranchAddress("hJet_JECUnc", hJet_JECUnc);
228 oldtree->SetBranchAddress("hJet_vtxMass", hJet_vtxMass);
229 oldtree->SetBranchAddress("hJet_vtx3dL", hJet_vtx3dL);
230 oldtree->SetBranchAddress("hJet_vtx3deL", hJet_vtx3deL);
231 oldtree->SetBranchAddress("hJet_id", hJet_id);
232
233 // oldtree->SetBranchAddress("aJet_pt", aJet_pt);
234 // oldtree->SetBranchAddress("aJet_eta", aJet_eta);
235 oldtree->SetBranchAddress("aJet_phi", aJet_phi);
236 oldtree->SetBranchAddress("aJet_e", aJet_e);
237 oldtree->SetBranchAddress("aJet_csv", aJet_csv);
238 oldtree->SetBranchAddress("aJet_cosTheta", aJet_cosTheta);
239 oldtree->SetBranchAddress("aJet_numTracksSV", aJet_numTracksSV);
240 oldtree->SetBranchAddress("aJet_chf", aJet_chf);
241 oldtree->SetBranchAddress("aJet_nhf", aJet_nhf);
242 oldtree->SetBranchAddress("aJet_cef", aJet_cef);
243 oldtree->SetBranchAddress("aJet_nef", aJet_nef);
244 oldtree->SetBranchAddress("aJet_nch", aJet_nch);
245 oldtree->SetBranchAddress("aJet_nconstituents", aJet_nconstituents);
246 oldtree->SetBranchAddress("aJet_flavour", aJet_flavour);
247 oldtree->SetBranchAddress("aJet_genPt", aJet_genPt);
248 oldtree->SetBranchAddress("aJet_genEta", aJet_genEta);
249 oldtree->SetBranchAddress("aJet_genPhi", aJet_genPhi);
250 oldtree->SetBranchAddress("aJet_JECUnc", aJet_JECUnc);
251 oldtree->SetBranchAddress("aJet_vtxMass", aJet_vtxMass);
252 oldtree->SetBranchAddress("aJet_vtx3dL", aJet_vtx3dL);
253 oldtree->SetBranchAddress("aJet_vtx3deL", aJet_vtx3deL);
254 oldtree->SetBranchAddress("aJet_id", aJet_id);
255
256 }
257
258 //Pileup Info
259 Float_t PUweight;
260 Float_t PUweight2011B;
261 Float_t PU0,PUp1,PUm1;
262 if(redoPU)
263 {
264 oldtree->SetBranchAddress("PU0", &PU0);
265 oldtree->SetBranchAddress("PUp1", &PUp1);
266 oldtree->SetBranchAddress("PUm1", &PUm1);
267 oldtree->SetBranchAddress("PUweight", &PUweight);
268 oldtree->SetBranchAddress("PUweight2011B", &PUweight2011B);
269 }
270
271
272 //Create a new file + a clone of old tree in new file + clone of the histos + additional/updated weights
273
274 TFile *newfile = new TFile(outputFile_.c_str(),"RECREATE");
275 TTree *newtree = oldtree->CloneTree(0);
276 if(count) count->Clone()->Write();
277 if(input3DPU) input3DPU->Clone()->Write();
278
279 if(redoPU)
280 {
281 if(countWithPU) countWithPU->Clone("CountWithPU_OLD")->Write();
282 if(countWithPU2011B) countWithPU2011B->Clone("CountWithPU2011B_OLD")->Write();
283
284 //recompute the normalization
285 countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
286 countWithPU2011B = new TH1F("CountWithPU2011B","CountWithPU2011B", 1,0,2 );
287 for(int ix=1;ix<=input3DPU->GetNbinsX();ix++)
288 for(int iy=1;iy<=input3DPU->GetNbinsY();iy++)
289 for(int iz=1;iz<=input3DPU->GetNbinsZ();iz++)
290 {
291 Float_t nev=input3DPU->GetBinContent(ix,iy,iz);
292 PUweight = lumiWeights.weight( iy-1 ); // bin 1 is [-0.5,0.5]
293 PUweight2011B = lumiWeights2011B.weight3D( ix-1, iy-1, iz-1);
294 countWithPU->Fill(1,PUweight*nev);
295 countWithPU2011B->Fill(1,PUweight2011B*nev);
296 }
297
298 countWithPU->Write();
299 countWithPU2011B->Write();
300
301 }
302 else
303 { //Just clone the old ones
304 if(countWithPU) countWithPU->Clone()->Write();
305 if(countWithPU2011B) countWithPU2011B->Clone()->Write();
306 }
307
308 if(!replaceWeights)
309 {
310 std::cout << "Creating new branch names with _up postfix" << std::endl;
311 newtree->Branch("weightTrig_up", &weightTrig, "weightTrig_up/F");
312 newtree->Branch("weightTrigMay_up", &weightTrigMay,"weightTrigMay/F");
313 newtree->Branch("weightTrigV4_up", &weightTrigV4,"weightTrigV4/F");
314 newtree->Branch("weightTrigMET_up", &weightTrigMET,"weightTrigMET/F");
315 newtree->Branch("weightTrigOrMu30_up", &weightTrigOrMu30,"weightTrigOrMu30/F");
316 newtree->Branch("weightEleRecoAndId_up", &weightEleRecoAndId,"weightEleRecoAndId/F");
317 newtree->Branch("weightEleTrigJetMETPart_up", &weightEleTrigJetMETPart,"weightEleTrigJetMETPart/F");
318 newtree->Branch("weightEleTrigElePart_up", &weightEleTrigElePart,"weightEleTrigElePart/F");
319
320 /* TODO:
321 _outTree->Branch("weightEleTrigEleAugPart" , &weightEleTrigEleAugPart , "weightEleTrigEleAugPart/F");
322
323 _outTree->Branch("weightTrigMET80" , &weightTrigMET80 , "weightTrigMET80/F");
324 _outTree->Branch("weightTrigMET100" , &weightTrigMET100 , "weightTrigMET100/F");
325 _outTree->Branch("weightTrig2CJet20" , &weightTrig2CJet20 , "weightTrig2CJet20/F");
326 _outTree->Branch("weightTrigMET150" , &weightTrigMET150 , "weightTrigMET150/F");
327 _outTree->Branch("weightTrigMET802CJet" , &weightTrigMET802CJet , "weightTrigMET802CJet/F");
328 _outTree->Branch("weightTrigMET1002CJet" , &weightTrigMET1002CJet , "weightTrigMET1002CJet/F");
329 _outTree->Branch("weightTrigMETLP" , &weightTrigMETLP , "weightTrigMETLP/F");
330 */
331
332
333 }
334
335
336
337 // Float_t weightTrigUpdate;
338 // newtree->Branch("weightTrigUpdate" , &weightTrigUpdate , "weightTrigUpdate/F");
339
340 for (Int_t i=0;i<nentries; i++) {
341 oldtree->GetEntry(i);
342
343 if(redoPU) {
344 PUweight = lumiWeights.weight( PU0 );
345 PUweight2011B = lumiWeights2011B.weight3D( PUm1, PU0, PUp1);
346 }
347
348 if(redoHiggs)
349 {
350
351 std::vector<VHbbEvent::SimpleJet> jets;
352 for(int i =0; i < nhJets; i++)
353 {
354 VHbbEvent::SimpleJet j;
355 float scale=1.0;
356 j.p4.SetPtEtaPhiE(hJet_pt[i]*scale,hJet_eta[i],hJet_phi[i],hJet_e[i]*scale);
357 j.csv=hJet_csv[i];
358 j.vtxMass=hJet_numTracksSV[i] ;
359 j.vtxMass=hJet_vtxMass[i];
360 j.vtx3dL=hJet_vtx3dL[i] ;
361 j.vtx3deL=hJet_vtx3deL[i] ;
362 j.chargedHadronEFraction=hJet_chf[i];
363 j.neutralHadronEFraction=hJet_nhf[i] ;
364 j.chargedEmEFraction=hJet_cef[i] ;
365 j.neutralEmEFraction=hJet_nef[i] ;
366 j.nConstituents=hJet_nconstituents[i] ;
367 j.ntracks=hJet_nch[i];
368 /* j.SF_CSVL=hJet_SF_CSVL[i];
369 j.SF_CSVM=hJet_SF_CSVM[i];
370 j.SF_CSVT=hJet_SF_CSVT[i];
371 j.SF_CSVLerr=hJet_SF_CSVLerr[i];
372 j.SF_CSVMerr=hJet_SF_CSVMerr[i];
373 j.SF_CSVTerr=hJet_SF_CSVTerr[i];
374 */
375 j.flavour=hJet_flavour[i];
376 j.bestMCp4.SetPtEtaPhiE(hJet_genPt[i], hJet_genEta[i], hJet_genPhi[i], hJet_genPt[i]); //E not saved!
377 //j.bestMCp4.Phi()=hJet_genPhi[i];
378 j.jecunc=hJet_JECUnc[i];
379 jets.push_back(j);
380 }
381
382
383 for(int i =0; i < naJets; i++)
384 {
385 VHbbEvent::SimpleJet j;
386 float scale=1.0;
387 j.p4.SetPtEtaPhiE(aJet_pt[i]*scale,aJet_eta[i],aJet_phi[i],aJet_e[i]*scale);
388 j.csv=aJet_csv[i];
389 j.vtxMass=aJet_numTracksSV[i] ;
390 j.vtxMass=aJet_vtxMass[i];
391 j.vtx3dL=aJet_vtx3dL[i] ;
392 j.vtx3deL=aJet_vtx3deL[i] ;
393 j.chargedHadronEFraction=aJet_chf[i];
394 j.neutralHadronEFraction=aJet_nhf[i] ;
395 j.chargedEmEFraction=aJet_cef[i] ;
396 j.neutralEmEFraction=aJet_nef[i] ;
397 j.nConstituents=aJet_nconstituents[i] ;
398 j.ntracks=aJet_nch[i];
399 /* j.SF_CSVL=aJet_SF_CSVL[i];
400 j.SF_CSVM=aJet_SF_CSVM[i];
401 j.SF_CSVT=aJet_SF_CSVT[i];
402 j.SF_CSVLerr=aJet_SF_CSVLerr[i];
403 j.SF_CSVMerr=aJet_SF_CSVMerr[i];
404 j.SF_CSVTerr=aJet_SF_CSVTerr[i];
405 */
406 j.flavour=aJet_flavour[i];
407 j.bestMCp4.SetPtEtaPhiE(aJet_genPt[i],aJet_genEta[i],aJet_genPhi[i],aJet_genPt[i]);
408 j.jecunc=aJet_JECUnc[i];
409 jets.push_back(j);
410 }
411
412 /*if (useHighestPtHiggs == false){
413 foundJets = findDiJets(jets,j1,j2,addJets) ;
414 }else{*/
415 std::vector<VHbbEvent::SimpleJet> addJets;
416 VHbbEvent::SimpleJet j1;
417 VHbbEvent::SimpleJet j2;
418
419 bool foundJets = finder.findDiJetsHighestPt(jets,j1,j2,addJets) ;
420 /* TVector3 higgsBoost;
421 higgsBoost = (temp.H.p4).BoostVector();
422 temp.H.helicities.clear();
423 temp.H.helicities.push_back(selector.getHelicity(j1,higgsBoost));
424 temp.H.helicities.push_back(selector.getHelicity(j2,higgsBoost));
425 temp.H.deltaTheta = selector.getDeltaTheta(j1,j2);
426 temp.additionalJets = addJets;
427 hJets.cosTheta[0]= vhCand.H.helicities[0];
428 hJets.cosTheta[1]= vhCand.H.helicities[1];*/
429
430 }
431
432 if(redoTrigger)
433 {
434 std::vector<float> jet30eta;
435 std::vector<float> jet30pt;
436 for( int j = 0 ; j < nhJets; j++) if(hJet_pt[j]>30 ) { jet30eta.push_back(hJet_eta[j]); jet30pt.push_back(hJet_pt[j]); }
437 for( int j = 0 ; j < naJets; j++) if(aJet_pt[j]>30 ) { jet30eta.push_back(aJet_eta[j]); jet30pt.push_back(aJet_pt[j]); }
438
439 if(Vtype == 0 ){
440 float cweightID = triggerWeight.scaleMuID(vLepton_pt[0],vLepton_eta[0]) * triggerWeight.scaleMuID(vLepton_pt[1],vLepton_eta[1]) ;
441 float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLepton_pt[0],vLepton_eta[0]);
442 float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLepton_pt[1],vLepton_eta[1]);
443 float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
444 weightTrig = cweightID * cweightTrig;
445
446 }
447 if( Vtype == 1 ){
448 std::vector<float> pt,eta;
449 pt.push_back(vLepton_pt[0]); eta.push_back(vLepton_eta[0]);
450 pt.push_back(vLepton_pt[1]); eta.push_back(vLepton_eta[1]);
451 weightEleRecoAndId=triggerWeight.scaleID95Ele(vLepton_pt[0],vLepton_eta[0]) * triggerWeight.scaleRecoEle(vLepton_pt[0],vLepton_eta[0]) *
452 triggerWeight.scaleID95Ele(vLepton_pt[1],vLepton_eta[1]) * triggerWeight.scaleRecoEle(vLepton_pt[1],vLepton_eta[1]);
453 weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
454 //REMOVE FOR "float" for newer ntupler and add branch
455 float weightEleTrigEleAugPart = triggerWeight.scaleDoubleEle17Ele8Aug(pt,eta);
456 weightTrig = (weightEleTrigElePart*1.14+weightEleTrigEleAugPart*0.98 )/2.12 * weightEleRecoAndId;
457
458
459
460 }
461 if(Vtype == 2 ){
462 float cweightID = triggerWeight.scaleMuID(vLepton_pt[0],vLepton_eta[0]);
463 float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLepton_pt[0],vLepton_eta[0]);
464 float cweightTrig = weightTrig1;
465 weightTrig = cweightID * cweightTrig;
466 float weightTrig1OrMu30 = triggerWeight.scaleMuOr30IsoHLT(vLepton_pt[0],vLepton_eta[0]);
467 weightTrigOrMu30 = cweightID*weightTrig1OrMu30;
468
469 }
470 if( Vtype == 3 ){
471 weightTrigMay = triggerWeight.scaleSingleEleMay(vLepton_pt[0],vLepton_eta[0]);
472 weightTrigV4 = triggerWeight.scaleSingleEleV4(vLepton_pt[0],vLepton_eta[0]);
473 weightEleRecoAndId=triggerWeight.scaleID80Ele(vLepton_pt[0],vLepton_eta[0]) * triggerWeight.scaleRecoEle(vLepton_pt[0],vLepton_eta[0]);
474 weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30pt,jet30eta)*triggerWeight.scalePFMHTEle(MET.et);
475 weightEleTrigElePart= weightTrigV4; //this is for debugging only, checking only the V4 part
476
477 weightTrigMay*=weightEleRecoAndId;
478 weightTrigV4*=weightEleRecoAndId;
479 weightTrigV4*=weightEleTrigJetMETPart;
480 // weightTrig = weightTrigMay * 0.187 + weightTrigV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
481 weightTrig = (weightTrigMay * 0.215 + weightTrigV4 * 1.915)/ 2.13; //FIXME: use proper lumi if we reload 2.fb
482
483
484 }
485 /* TODO
486 if(isMC_)
487 {
488 weightTrigMET80 = triggerWeight.scaleMET80(MET.et);
489 weightTrigMET100 = triggerWeight.scaleMET80(MET.et);
490 weightTrig2CJet20 = triggerWeight.scale2CentralJet( jet10pt, jet10eta);
491 weightTrigMET150 = triggerWeight.scaleMET150(MET.et);
492 weightTrigMET802CJet= weightTrigMET80 * weightTrig2CJet20;
493 weightTrigMET1002CJet= weightTrigMET100 * weightTrig2CJet20;
494 }
495 if( Vtype == VHbbCandidate::Znn ){
496 nvlep=0;
497 float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
498 weightTrigMETLP = weightTrig1;
499 weightTrig = weightTrigMET150 + weightTrigMET802CJet - weightTrigMET802CJet*weightTrigMET150;
500 }
501 */
502
503 }
504
505
506 newtree->Fill();
507 }
508 newtree->Print();
509 newtree->AutoSave();
510 delete oldfile;
511 delete newfile;
512 }