ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Updater.cc
Revision: 1.3
Committed: Thu Nov 10 00:01:39 2011 UTC (13 years, 6 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: AR_Nov10Ntuple
Changes since 1.2: +206 -6 lines
Log Message:
- 3D PU reweighting with latest recipe and targetting the full 2011B run period
- PU reweight fixed in 2011A against Fall11 MC
- run boundary handling to properly handle the two periods of 2011B
- factorized MET triggers
- events failing the "at least 2 jets pt > 20" are recovered with a pt15 cut (NB: the election of higest dijet is first done with 20GeV threshold, the 15 GeV is consiered only if the 20 fails)
- apply JER smearing by default
- add leptons generator info
- add jet by jet btag SF info
- add electron id80NoIso

File Contents

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