ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Updater.cc
Revision: 1.5.2.1
Committed: Tue Nov 27 05:04:17 2012 UTC (12 years, 5 months ago) by ntran
Content type: text/plain
Branch: hbbsubstructDevPostHCP
CVS Tags: hbbsubstructDev_11, hbbsubstructDev_10, hbbsubstructDev_9, hbbsubstructDev_8, hbbsubstructDev_7, hbbsubstructDev_6, hbbsubstructDev_5
Changes since 1.5: +1 -0 lines
Log Message:
major update, including new proposal for FJ3 inputs to step 2

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