ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.133
Committed: Wed Apr 17 23:59:55 2013 UTC (12 years ago) by sdas
Content type: text/plain
Branch: MAIN
CVS Tags: EDMV42_Step2_V8, HEAD
Changes since 1.132: +4 -1 lines
Log Message:
Added extra information to aJets for b-jet regression in the H(bb)H(bb) analysis.

File Contents

# User Rev Content
1 arizzi 1.1 #include <TH1F.h>
2 arizzi 1.62 #include <TH3F.h>
3 arizzi 1.1 #include "PhysicsTools/Utilities/interface/LumiReWeighting.h"
4 arizzi 1.103 //#include "PhysicsTools/Utilities/interface/Lumi3DReWeighting.h"
5 arizzi 1.1 #include <TH2F.h>
6     #include <TROOT.h>
7     #include <TFile.h>
8     #include <TTree.h>
9     #include <TSystem.h>
10     #include "DataFormats/FWLite/interface/Event.h"
11     #include "DataFormats/FWLite/interface/Handle.h"
12     #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
13     #include "DataFormats/MuonReco/interface/Muon.h"
14     #include "DataFormats/PatCandidates/interface/Muon.h"
15     #include "PhysicsTools/FWLite/interface/TFileService.h"
16     #include "FWCore/ParameterSet/interface/ProcessDesc.h"
17     #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
18     #include "DataFormats/Math/interface/deltaR.h"
19     #include "DataFormats/Math/interface/deltaPhi.h"
20    
21     #include "DataFormats/FWLite/interface/LuminosityBlock.h"
22     #include "DataFormats/FWLite/interface/Run.h"
23     #include "DataFormats/Luminosity/interface/LumiSummary.h"
24    
25 arizzi 1.4 #include "VHbbAnalysis/VHbbDataFormats/interface/HbbCandidateFinderAlgo.h"
26     #include "VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc"
27 arizzi 1.1
28     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h"
29     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEventAuxInfo.h"
30     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidate.h"
31     #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerReader.h"
32 nmohr 1.5 #include "VHbbAnalysis/VHbbDataFormats/interface/TopMassReco.h"
33 arizzi 1.93 #include "VHbbAnalysis/VHbbDataFormats/interface/JECFWLite.h"
34 arizzi 1.1
35 bortigno 1.30 //for IVF
36     #include "RecoBTag/SecondaryVertex/interface/SecondaryVertex.h"
37     #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
38     #include "DataFormats/GeometryVector/interface/GlobalVector.h"
39     #include "DataFormats/GeometryVector/interface/VectorUtil.h"
40     #include <DataFormats/GeometrySurface/interface/Surface.h>
41     #include "Math/SMatrix.h"
42 arizzi 1.16
43 bortigno 1.75 //for LHE info
44     #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
45    
46 arizzi 1.16 //Move class definition to Ntupler.h ?
47     //#include "VHbbAnalysis/VHbbDataFormats/interface/Ntupler.h"
48    
49 bortigno 1.74 #include "ZSV/BAnalysis/interface/SimBHadron.h"
50 bortigno 1.30 //btagging
51 arizzi 1.16 #include "VHbbAnalysis/VHbbDataFormats/interface/BTagWeight.h"
52 arizzi 1.98 #include "VHbbAnalysis/VHbbDataFormats/interface/BTagReshaping.h"
53 bortigno 1.30 //trigger
54 arizzi 1.16 #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerWeight.h"
55    
56 arizzi 1.1 #include <sstream>
57     #include <string>
58 arizzi 1.119 #include <fstream>
59     #include <iostream>
60     #include <algorithm>
61     #include <vector> // std::vector
62    
63    
64 arizzi 1.123 #define MAXPDF 100
65 arizzi 1.80 #define MAXJ 130
66     #define MAXL 110
67     #define MAXB 110
68     #define MAXT 160
69 degrutto 1.69 #define nMetUnc 24
70     //eleEnDown/Up, muEn, tauEn, JES, JER, Unclustered for type1 MET [0-11] and than type1p2 MET [12-23]
71 arizzi 1.1
72 arizzi 1.24 struct CompareDeltaR {
73 bortigno 1.30 CompareDeltaR(TLorentzVector p4dir_): p4dir(p4dir_) {}
74     bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
75     return j1.p4.DeltaR(p4dir) > j2.p4.DeltaR(p4dir);
76     }
77     TLorentzVector p4dir;
78 arizzi 1.24 };
79 arizzi 1.4
80 bortigno 1.30 const GlobalVector flightDirection(const TVector3 pv, const reco::Vertex &sv){
81     GlobalVector fdir(sv.position().X() - pv.X(),
82     sv.position().Y() - pv.Y(),
83     sv.position().Z() - pv.Z());
84     return fdir;
85     }
86    
87 arizzi 1.119 struct RLE
88     {
89     RLE(){}
90     RLE(
91     unsigned long run_,
92     unsigned long lumi_,
93     unsigned long event_
94     ) : run(run_),lumi(lumi_),event(event_) {}
95     unsigned long run;
96     unsigned long lumi;
97     unsigned long event;
98     };
99    
100     bool evcomp (RLE i,RLE j) {
101     if(i.run!=j.run) return (i.run<j.run);
102     if(i.lumi!=j.lumi) return (i.lumi<j.lumi);
103     return (i.event<j.event);
104    
105     }
106    
107 arizzi 1.125 float weightNLOEWKsignal(float pt)
108     {
109     if(pt < 50) return 1;
110 arizzi 1.127 return 0.94-(0.2-0.068)/400.*(pt-50.);
111 arizzi 1.125 }
112    
113     float weightNNLOQCDsignal(float pt,int njets)
114     {
115     /* = 0.99532 +/- 0.0705809
116     p1 = -0.000262157 +/- 0.000254908
117     */
118    
119     /*
120     p0 = 1.0064 +/- 0.353707
121     p1 = 0.000288831 +/- 0.00210877
122     */
123     // SF for jet veto
124     if(njets <=2) return 0.99532-pt*0.000262157;
125    
126    
127     return 1.0064+pt*0.0002888;
128    
129     }
130    
131 arizzi 1.119 void readBadEvents(const char * filename, vector<RLE> & badEvents)
132     {
133     string str ;
134     RLE temp;
135     ifstream myfile (filename);
136     if (myfile.is_open())
137     {
138     while ( myfile.good() )
139     {
140     getline (myfile,str);
141     replace( str.begin(), str.end(), ':', ' ' ) ;
142     istringstream stm(str) ;
143     int a, b, c ;
144     stm >> a >> b >> c ;
145     temp.run=a; temp.event=c; temp.lumi=b;
146     badEvents.push_back(temp);
147     // cout << a << '\t' << b << '\t' << c << '\n' ;
148     }
149     }
150    
151     /*d::cout << "Presort" << std::endl;
152     std::cout << std::binary_search (badEvents.begin(), badEvents.end(), RLE(1,1,1),evcomp) << endl;
153     std::cout << std::binary_search (badEvents.begin(), badEvents.end(), RLE(190456,59,3971011),evcomp) << endl;
154     std::cout << "sort" << std::endl;*/
155     std::sort (badEvents.begin(), badEvents.end(), evcomp);
156     std::cout << "sorted" << std::endl;
157     /*d::cout << std::binary_search (badEvents.begin(), badEvents.end(), RLE(1,1,1),evcomp) << endl;
158     std::cout << std::binary_search (badEvents.begin(), badEvents.end(), RLE(190456,59,3971011),evcomp) << endl;
159     */
160     myfile.close();
161     }
162    
163    
164 nmohr 1.7 bool jsonContainsEvent (const std::vector< edm::LuminosityBlockRange > &jsonVec,
165     const edm::EventBase &event)
166     {
167 bortigno 1.30 // if the jsonVec is empty, then no JSON file was provided so all
168     // events should pass
169     if (jsonVec.empty())
170     {
171 nmohr 1.7 return true;
172 bortigno 1.30 }
173     bool (* funcPtr) (edm::LuminosityBlockRange const &,
174     edm::LuminosityBlockID const &) = &edm::contains;
175     edm::LuminosityBlockID lumiID (event.id().run(),
176     event.id().luminosityBlock());
177     std::vector< edm::LuminosityBlockRange >::const_iterator iter =
178     std::find_if (jsonVec.begin(), jsonVec.end(),
179     boost::bind(funcPtr, _1, lumiID) );
180     return jsonVec.end() != iter;
181 nmohr 1.7
182     }
183    
184 arizzi 1.64 float resolutionBias(float eta)
185     {
186     // return 0;//Nominal!
187 arizzi 1.125 /* if(eta< 1.1) return 0.05;
188 arizzi 1.64 if(eta< 2.5) return 0.10;
189 arizzi 1.125 if(eta< 5) return 0.30;*/
190     //new numbers from: https://twiki.cern.ch/twiki/bin/view/CMS/JetResolution
191     if(eta< 0.5) return 0.052;
192     if(eta< 1.1) return 0.057;
193     if(eta< 1.7) return 0.096;
194     if(eta< 2.3) return 0.134;
195     if(eta< 5) return 0.28;
196    
197    
198 arizzi 1.64 return 0;
199     }
200    
201 arizzi 1.123 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
202     namespace LHAPDF {
203     void initPDFSet(int nset, int setid, int member=0);
204     void initPDFSet(int nset, const std::string& filename, int member=0);
205     int numberPDF(int nset);
206     void usePDFMember(int nset, int member);
207     double xfx(int nset, double x, double Q, int fl);
208     double getXmin(int nset, int member);
209     double getXmax(int nset, int member);
210     double getQ2min(int nset, int member);
211     double getQ2max(int nset, int member);
212     void extrapolate(bool extrapolate=true);
213     }
214    
215    
216 arizzi 1.1
217 bortigno 1.74 typedef struct
218     {
219     void set(const SimBHadron & sbhc, int i){
220     mass[i] = sbhc.mass();
221     pt[i] = sbhc.pt();
222     eta[i] = sbhc.eta();
223     phi[i] = sbhc.phi();
224     vtx_x[i] = sbhc.decPosition.x();
225     vtx_y[i] = sbhc.decPosition.y();
226     vtx_z[i] = sbhc.decPosition.z();
227     pdgId[i] = sbhc.pdgId();
228     status[i] = sbhc.status();
229     };
230     void reset(){
231     for(int i=0; i < MAXB; ++i){
232     mass[i] = -99; pt[i] = -99; eta[i] = -99; phi[i] = -99; vtx_x[i] = -99; vtx_y[i] = -99; vtx_z[i] = -99; pdgId[i] = -99; status[i] = -99;
233     }
234     };
235     float mass[MAXB];
236     float pt[MAXB];
237     float eta[MAXB];
238     float phi[MAXB];
239     float vtx_x[MAXB];
240     float vtx_y[MAXB];
241     float vtx_z[MAXB];
242     int pdgId[MAXB];
243     int status[MAXB];
244     // int quarkStatus[MAXB];
245     // int brotherStatus[MAXB];
246     // int otherId[MAXB];
247     // bool etaOk[MAXB];
248     // bool simOk[MAXB];
249     // bool trackOk[MAXB];
250     // bool cutOk[MAXB];
251     // bool cutNewOk[MAXB];
252     // bool mcMatchOk[MAXB];
253     // bool matchOk[MAXB];
254     } SimBHadronInfo;
255 bortigno 1.30
256    
257     typedef struct
258     {
259     void set( const reco::SecondaryVertex & recoSv, const TVector3 recoPv, int isv){
260     pt[isv] = recoSv.p4().Pt();
261     eta[isv] = flightDirection(recoPv,recoSv).eta();
262     phi[isv] = flightDirection(recoPv,recoSv).phi();
263     massBcand[isv] = recoSv.p4().M();
264     massSv[isv] = recoSv.p4().M();
265     dist3D[isv] = recoSv.dist3d().value();
266     distSig3D[isv] = recoSv.dist3d().significance();
267     dist2D[isv] = recoSv.dist2d().value();
268     distSig2D[isv] = recoSv.dist2d().significance();
269     dist3D_norm[isv] = recoSv.dist3d().value()/recoSv.p4().Gamma();
270     };
271     void reset(){
272     for(int i = 0; i < MAXB; ++i){
273     massBcand[i] = -99; massSv[i]= -99; pt[i] = -99; eta[i] = -99; phi[i] = -99; dist3D[i] = -99; distSig3D[i] = -99; dist2D[i] = -99; distSig2D[i] = -99; dist3D_norm[i] = -99;
274     }
275     };
276     float massBcand[MAXB];
277     float massSv[MAXB];
278     float pt[MAXB];
279     float eta[MAXB];
280     float phi[MAXB];
281     float dist3D[MAXB];
282     float distSig3D[MAXB];
283     float dist2D[MAXB];
284     float distSig2D[MAXB];
285     float dist3D_norm[MAXB];
286     } IVFInfo;
287 arizzi 1.1
288 bortigno 1.30
289     typedef struct
290     {
291 dlopes 1.73 int HiggsFlag;
292 arizzi 1.33 float mass;
293     float pt;
294     float eta;
295     float phi;
296     float dR;
297     float dPhi;
298     float dEta;
299     } HiggsInfo;
300 dlopes 1.73
301     typedef struct
302     {
303     int FatHiggsFlag;
304     float mass;
305     float pt;
306     float eta;
307     float phi;
308     float filteredmass;
309     float filteredpt;
310     float filteredeta;
311     float filteredphi;
312     // float dR;
313     // float dPhi;
314     // float dEta;
315     } FatHiggsInfo;
316    
317    
318 degrutto 1.69
319     typedef struct
320     {
321     float mass;
322     float pt;
323     float eta;
324     float phi;
325     float status;
326     float charge;
327     float momid;
328     } genParticleInfo;
329    
330 sdas 1.132 genParticleInfo returnGenParticleInfo(const reco::Candidate *p)
331     {
332     genParticleInfo pInfo;
333     TLorentzVector p_p4(p->px(), p->py(), p->pz(), p->energy());
334     pInfo.mass=p_p4.M();
335     pInfo.pt=p_p4.Pt();
336     pInfo.eta=p_p4.Eta();
337     pInfo.phi=p_p4.Phi();
338     pInfo.status=p->status();
339     pInfo.charge=p->charge();
340     pInfo.momid=p->mother(0)->pdgId();
341     return pInfo;
342     }
343 degrutto 1.69
344     typedef struct
345    
346     {
347     float bmass;
348     float bpt;
349     float beta;
350     float bphi;
351     float bstatus;
352     float wdau1mass;
353     float wdau1pt;
354     float wdau1eta;
355     float wdau1phi;
356     float wdau1id;
357     float wdau2mass;
358     float wdau2pt;
359     float wdau2eta;
360     float wdau2phi;
361     float wdau2id;
362    
363    
364     } genTopInfo;
365    
366    
367 dlopes 1.67
368    
369 malbouis 1.71 typedef struct
370     {
371     bool HiggsCSVtkSharing;
372     bool HiggsIPtkSharing;
373     bool HiggsSVtkSharing;
374     bool FatHiggsCSVtkSharing;
375     bool FatHiggsIPtkSharing;
376     bool FatHiggsSVtkSharing;
377     } TrackSharingInfo;
378    
379 arizzi 1.33 typedef struct
380     {
381 bortigno 1.30 float mass; //MT in case of W
382     float pt;
383     float eta;
384     float phi;
385     } TrackInfo;
386 arizzi 1.1
387    
388 arizzi 1.9 struct LeptonInfo
389 bortigno 1.30 {
390     void reset()
391 arizzi 1.1 {
392 arizzi 1.48 for(int i =0; i < MAXL;i++){
393 arizzi 1.64 mass[i]=-99; pt[i]=-99; eta[i]=-99; phi[i]=-99; aodCombRelIso[i]=-99; pfCombRelIso[i]=-99; photonIso[i]=-99; neutralHadIso[i]=-99; chargedHadIso[i]=-99; chargedPUIso[i]=-99; particleIso[i]=-99; dxy[i]=-99; dz[i]=-99; type[i]=-99; genPt[i]=-99; genEta[i]=-99; genPhi[i]=-99;
394     id80[i]=-99; id95[i]=-99; vbtf[i]=-99; id80NoIso[i]=-99;
395 arizzi 1.85 charge[i]=-99;wp70[i]=-99; wp80[i]=-99;wp85[i]=-99;wp90[i]=-99;wp95[i]=-99;wpHWW[i]=-99;
396 arizzi 1.128 pfCorrIso[i]=-99.; id2012tight[i]=-99; idMVAnotrig[i]=-99; idMVAtrig[i]=-99;innerHits[i]=-99.,pfCorrIsoHCP[i]=-99.;
397 msegala 1.124
398     decayModeFinding[i] =-99.;
399     byLooseCombinedIsolationDeltaBetaCorr[i] =-99.;
400     againstMuonTight[i] =-99.;
401     againstElectronLoose[i] =-99.;
402     againstElectronMedium[i] =-99.;
403     againstElectronMVA[i] =-99.;
404     NsignalPFChargedHadrCands[i] =-99;
405     NsignalPFGammaCands[i] =-99;
406     leadPFChargedHadrCandPt[i] = -99.;
407     byLooseIsolation[i] = -99.;
408     byMediumIsolation[i] = -99.;
409     byTightIsolation[i] = -99.;
410     byLooseCombinedIsolationDeltaBetaCorr3Hits[i] = -99.;
411     byMediumCombinedIsolationDeltaBetaCorr3Hits[i] = -99.;
412     byTightCombinedIsolationDeltaBetaCorr3Hits[i] = -99.;
413     againstElectronMVA3raw[i] = -99.;
414     againstElectronMVA3category[i] = -99.;
415     againstElectronLooseMVA3[i] = -99.;
416     againstElectronMediumMVA3[i] = -99.;
417     againstElectronTightMVA3[i] = -99.;
418     againstElectronVTightMVA3[i] = -99.;
419     againstElectronDeadECAL[i] = -99.;
420     byLooseIsolationMVA[i] = -99.;
421     byMediumIsolationMVA[i] = -99.;
422     byTightIsolationMVA[i] = -99.;
423     byLooseIsolationMVA2[i] = -99.;
424     byMediumIsolationMVA2[i] = -99.;
425     byTightIsolationMVA2[i] = -99.;
426     againstMuonLoose2[i] = -99.;
427     againstMuonMedium2[i] = -99.;
428     againstMuonTight2[i] = -99.;
429 arizzi 1.83
430 arizzi 1.48 }
431 bortigno 1.30 }
432 arizzi 1.1
433 arizzi 1.82 template <class Input> void set(const Input & i, int j,int t,const VHbbEventAuxInfo & aux)
434 bortigno 1.30 {
435     type[j]=t;
436     pt[j]=i.p4.Pt();
437     mass[j]=i.p4.M();
438     eta[j]=i.p4.Eta();
439     phi[j]=i.p4.Phi();
440     aodCombRelIso[j]=(i.hIso+i.eIso+i.tIso)/i.p4.Pt();
441 arizzi 1.83 pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
442 bortigno 1.30 photonIso[j]=i.pfPhoIso;
443     neutralHadIso[j]=i.pfNeuIso;
444     chargedHadIso[j]=i.pfChaIso;
445 dlopes 1.55 chargedPUIso[j]=i.pfChaPUIso;
446 degrutto 1.69 charge[j]=i.charge;
447 arizzi 1.64 if(i.mcFourMomentum.Pt() > 0)
448     {
449 msegala 1.124 genPt[j]=i.mcFourMomentum.Pt();
450     genEta[j]=i.mcFourMomentum.Eta();
451     genPhi[j]=i.mcFourMomentum.Phi();
452     }
453     setSpecific(i,j,aux);
454 bortigno 1.30 }
455 arizzi 1.82 template <class Input> void setSpecific(const Input & i, int j,const VHbbEventAuxInfo & aux)
456 bortigno 1.30 {
457     }
458 arizzi 1.4
459    
460    
461 arizzi 1.1
462 bortigno 1.30 float mass[MAXL]; //MT in case of W
463     float pt[MAXL];
464     float eta[MAXL];
465     float phi[MAXL];
466     float aodCombRelIso[MAXL];
467     float pfCombRelIso[MAXL];
468     float photonIso[MAXL];
469     float neutralHadIso[MAXL];
470     float chargedHadIso[MAXL];
471 dlopes 1.55 float chargedPUIso[MAXL];
472 bortigno 1.30 float particleIso[MAXL];
473 arizzi 1.64 float genPt[MAXL];
474     float genEta[MAXL];
475     float genPhi[MAXL];
476 bortigno 1.30 float dxy[MAXL];
477     float dz[MAXL];
478     int type[MAXL];
479     float id80[MAXL];
480     float id95[MAXL];
481 arizzi 1.48 float vbtf[MAXL];
482 arizzi 1.64 float id80NoIso[MAXL];
483 degrutto 1.69 float charge[MAXL];
484 arizzi 1.82 float pfCorrIso[MAXL];
485 arizzi 1.121 float pfCorrIsoHCP[MAXL];
486 arizzi 1.82 float id2012tight[MAXL];
487     float idMVAnotrig[MAXL];
488     float idMVAtrig[MAXL];
489 arizzi 1.95 float idMVApresel[MAXL];
490 arizzi 1.85 float wp70[MAXL];
491     float wp80[MAXL];
492     float wp85[MAXL];
493     float wp90[MAXL];
494     float wp95[MAXL];
495 arizzi 1.87 float wpHWW[MAXL];
496     float innerHits[MAXL];
497     float photonIsoDoubleCount[MAXL];
498 msegala 1.124
499     float decayModeFinding[MAXL],byLooseCombinedIsolationDeltaBetaCorr[MAXL],againstMuonTight[MAXL],againstElectronLoose[MAXL],againstElectronMedium[MAXL],againstElectronMVA[MAXL];
500     int NsignalPFChargedHadrCands[MAXL], NsignalPFGammaCands[MAXL];
501     float leadPFChargedHadrCandPt[MAXL], byLooseIsolation[MAXL], byMediumIsolation[MAXL], byTightIsolation[MAXL];
502     float byLooseCombinedIsolationDeltaBetaCorr3Hits[MAXL], byMediumCombinedIsolationDeltaBetaCorr3Hits[MAXL], byTightCombinedIsolationDeltaBetaCorr3Hits[MAXL], againstElectronMVA3raw[MAXL], againstElectronMVA3category[MAXL], againstElectronLooseMVA3[MAXL], againstElectronMediumMVA3[MAXL], againstElectronTightMVA3[MAXL], againstElectronVTightMVA3[MAXL], againstElectronDeadECAL[MAXL], byLooseIsolationMVA[MAXL], byMediumIsolationMVA[MAXL], byTightIsolationMVA[MAXL], byLooseIsolationMVA2[MAXL], byMediumIsolationMVA2[MAXL], byTightIsolationMVA2[MAXL], againstMuonLoose2[MAXL], againstMuonMedium2[MAXL], againstMuonTight2[MAXL];
503    
504    
505    
506 bortigno 1.30 };
507 arizzi 1.1
508 arizzi 1.82 template <> void LeptonInfo::setSpecific<VHbbEvent::ElectronInfo>(const VHbbEvent::ElectronInfo & i, int j,const VHbbEventAuxInfo & aux){
509 arizzi 1.87 photonIsoDoubleCount[j]=i.pfPhoIsoDoubleCounted;
510 arizzi 1.36 id80[j]=i.id80;
511     id95[j]=i.id95;
512 arizzi 1.64 id80NoIso[j]=(i.innerHits ==0 && !(fabs(i.convDist)<0.02 && fabs(i.convDcot)<0.02) &&
513     ((i.isEB && i.sihih<0.01 && fabs(i.Dphi)<0.06 && fabs(i.Deta)<0.004) || (i.isEE && i.sihih<0.03 && fabs(i.Dphi)<0.03 && fabs(i.Deta)<0.007)));
514 arizzi 1.87 innerHits[j]=i.innerHits;
515 arizzi 1.82 float mincor=0.0;
516     float minrho=0.0;
517 arizzi 1.99 float rho = std::max(aux.puInfo.rho25Iso,minrho);
518 arizzi 1.82 float eta=i.p4.Eta();
519     float areagamma=0.5;
520     float areaNH=0.5;
521     float areaComb=0.5;
522 arizzi 1.100
523 degrutto 1.113 // new EA for electrons to use for Moriond 13
524     if(fabs(eta) <= 1.0 ) {areaComb=0.21;}
525     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areaComb=0.21;}
526     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areaComb=0.11;}
527     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areaComb=0.14;}
528     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areaComb=0.18;}
529     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areaComb=0.19;}
530     if(fabs(eta) > 2.4 ) {areaComb=0.26;}
531     /*
532 arizzi 1.100 if(fabs(eta) <= 1.0 ) {areagamma=0.14; areaNH=0.044; areaComb=0.18;}
533     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.13; areaNH=0.065; areaComb=0.20;}
534     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.079; areaNH=0.068; areaComb=0.15;}
535     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.13; areaNH=0.057; areaComb=0.19;}
536     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.15; areaNH=0.058; areaComb=0.21;}
537     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.16; areaNH=0.061; areaComb=0.22;}
538     if(fabs(eta) > 2.4 ) {areagamma=0.18; areaNH=0.11; areaComb=0.29;}
539 degrutto 1.113 */
540 arizzi 1.100 /*
541 arizzi 1.82 if(fabs(eta) <= 1.0 ) {areagamma=0.081; areaNH=0.024; areaComb=0.10;}
542     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.084; areaNH=0.037; areaComb=0.12;}
543     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.048; areaNH=0.037; areaComb=0.085;}
544     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.089; areaNH=0.023; areaComb=0.11;}
545     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.092; areaNH=0.023; areaComb=0.12;}
546     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.097; areaNH=0.021; areaComb=0.12;}
547     if(fabs(eta) > 2.4 ) {areagamma=0.11; areaNH=0.021; areaComb=0.13;}
548 arizzi 1.100 */
549 arizzi 1.82
550 arizzi 1.87 float pho=i.pfPhoIso;
551     if(i.innerHits>0)
552     {
553     pho-=i.pfPhoIsoDoubleCounted;
554     }
555 arizzi 1.82
556 arizzi 1.121 pfCorrIsoHCP[j] = (i.pfChaIso+ std::max(pho-rho*areagamma,mincor )+std::max(i.pfNeuIso-rho*areaNH,mincor))/i.p4.Pt();
557 degrutto 1.113 // new definition for Moriond13
558     pfCorrIso[j] = (i.pfChaIso+ std::max(pho+i.pfNeuIso-rho*areaComb,mincor))/i.p4.Pt();
559 arizzi 1.82
560     id2012tight[j] = fabs(i.dxy) < 0.02 &&fabs(i.dz) < 0.1 &&(
561     (i.isEE &&fabs(i.Deta) < 0.005 &&fabs(i.Dphi) < 0.02 &&i.sihih < 0.03 &&i.HoE < 0.10 &&fabs(i.fMVAVar_IoEmIoP) < 0.05
562     ) ||
563     (i.isEB &&fabs(i.Deta) < 0.004 &&fabs(i.Dphi) < 0.03 &&i.sihih < 0.01 &&i.HoE < 0.12 &&fabs(i.fMVAVar_IoEmIoP) < 0.05
564     ));
565 arizzi 1.92
566     bool mvaPreSel = (
567     (i.isEE &&
568     //fabs(electrons[it].Deta) < 0.009 &&
569     //fabs(electrons[it].Dphi) < 0.1 &&
570     i.sihih < 0.03 &&
571     i.HoE < 0.10 &&
572     i.innerHits == 0 &&
573     i.tIso/i.p4.Pt() < 0.2 &&
574     i.eIso/i.p4.Pt() < 0.2 &&
575     i.hIso/i.p4.Pt() < 0.2)
576     ||
577     (i.isEB &&
578     //fabs(electrons[it].Deta) < 0.007 &&
579     //fabs(electrons[it].Dphi) < 0.015 &&
580     i.sihih < 0.01 &&
581     i.HoE < 0.12 &&
582     i.innerHits == 0 &&
583     i.tIso/i.p4.Pt() < 0.2 &&
584     i.eIso/i.p4.Pt() < 0.2 &&
585     i.hIso/i.p4.Pt() < 0.2)
586     );
587    
588 arizzi 1.85 float id=i.mvaOutTrig;
589 arizzi 1.92 if(!mvaPreSel) id=0;
590 arizzi 1.85 float iso=pfCorrIso[j];
591     wp70[j]=((fabs(eta) < 0.8 && id>0.977 && iso < 0.093) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.956 && iso < 0.095) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.966 && iso < 0.171));
592     wp80[j]=((fabs(eta) < 0.8 && id>0.913 && iso < 0.105) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.964 && iso < 0.178) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.899 && iso < 0.150));
593     wp85[j]=((fabs(eta) < 0.8 && id>0.929 && iso < 0.135) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.931 && iso < 0.159) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.805 && iso < 0.155));
594     wp90[j]=((fabs(eta) < 0.8 && id>0.877 && iso < 0.177) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.794 && iso < 0.180) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.846 && iso < 0.244));
595     wp95[j]=((fabs(eta) < 0.8 && id>0.858 && iso < 0.253) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.425 && iso < 0.225) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.759 && iso < 0.308));
596     wpHWW[j]=((fabs(eta) < 0.8 && id>0.94 && iso < 0.15) || (fabs(eta) >= 0.8 && fabs(eta) < 1.479 && id>0.85 && iso < 0.15) || (fabs(eta) >= 1.479 && fabs(eta) < 2.5 && id>0.92 && iso < 0.15));
597 arizzi 1.82
598     idMVAnotrig[j]=i.mvaOut;
599     idMVAtrig[j]=i.mvaOutTrig;
600 arizzi 1.95 idMVApresel[j]=mvaPreSel;
601 arizzi 1.82
602 bortigno 1.30 }
603 arizzi 1.82 template <> void LeptonInfo::setSpecific<VHbbEvent::MuonInfo>(const VHbbEvent::MuonInfo & i, int j,const VHbbEventAuxInfo & aux){
604 bortigno 1.30 dxy[j]=i.ipDb;
605     dz[j]=i.zPVPt;
606 arizzi 1.48 vbtf[j]=( i.globChi2<10 && i.nPixelHits>= 1 && i.globNHits != 0 && i.nHits > 10 && i.cat & 0x1 && i.cat & 0x2 && i.nMatches >=2 && i.ipDb<.2 &&
607     (i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt()<.15 && fabs(i.p4.Eta())<2.4 && i.p4.Pt()>20 ) ;
608 degrutto 1.113
609    
610    
611    
612    
613 arizzi 1.82 float mincor=0.0;
614     float minrho=0.0;
615 degrutto 1.113 float NoverCh=0.5;
616 arizzi 1.82 float rhoN = std::max(aux.puInfo.rhoNeutral,minrho);
617     float eta=i.p4.Eta();
618     float area=0.5;
619     if(fabs(eta)>0.0 && fabs(eta) <= 1.0) {area=0.674;}
620     if(fabs(eta)>1.0 && fabs(eta) <= 1.5) {area=0.565;}
621     if(fabs(eta)>1.5 && fabs(eta) <= 2.0) {area=0.442;}
622     if(fabs(eta)>2.0 && fabs(eta) <= 2.2) {area=0.515;}
623     if(fabs(eta)>2.2 && fabs(eta) <= 2.3) {area=0.821;}
624     if(fabs(eta)>2.3 && fabs(eta) <= 2.4) {area=0.660;}
625 arizzi 1.126 pfCorrIsoHCP[j] = (i.pfChaIso+ std::max(i.pfPhoIso+i.pfNeuIso-rhoN*area,mincor))/i.p4.Pt();
626 degrutto 1.113 // Moriond13: using dbeta corrections
627     pfCorrIso[j] = (i.pfChaIso+ std::max(i.pfPhoIso+i.pfNeuIso-NoverCh*i.pfChaPUIso,mincor))/i.p4.Pt();
628    
629     id2012tight[j]= i.isPF && i.globChi2<10 && i.nPixelHits>= 1 && i.globNHits != 0 && i.nValidLayers > 5 && (i.cat & 0x2) && i.nMatches >=2 && i.ipDb<.2;
630    
631 arizzi 1.82
632 arizzi 1.48
633 bortigno 1.30 }
634    
635 msegala 1.124 template <> void LeptonInfo::setSpecific<VHbbEvent::TauInfo>(const VHbbEvent::TauInfo &i, int j,const VHbbEventAuxInfo & aux) {
636     //std::cout << "In tau set specific" << std::endl;
637    
638 msegala 1.130 pt[j]=i.p4.Pt();
639     mass[j]=i.p4.M();
640     eta[j]=i.p4.Eta();
641     phi[j]=i.p4.Phi();
642     pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
643     charge[j]=i.charge;
644     if(i.mcFourMomentum.Pt() > 0)
645     {
646     genPt[j]=i.mcFourMomentum.Pt();
647     genEta[j]=i.mcFourMomentum.Eta();
648     genPhi[j]=i.mcFourMomentum.Phi();
649     }
650    
651 msegala 1.124 decayModeFinding[j] = i.decayModeFinding;
652     byLooseCombinedIsolationDeltaBetaCorr[j] =i.byLooseCombinedIsolationDeltaBetaCorr;
653     againstMuonTight[j] =i.againstMuonTight;
654     againstElectronLoose[j] =i.againstElectronLoose;
655     againstElectronMedium[j] =i.againstElectronMedium;
656     againstElectronMVA[j] =i.againstElectronMVA;
657     NsignalPFChargedHadrCands[j] =i.NsignalPFChargedHadrCands;
658     NsignalPFGammaCands[j] =i.NsignalPFGammaCands;
659     leadPFChargedHadrCandPt[j] = i.leadPFChargedHadrCandPt;
660     byLooseIsolation[j] = i.byLooseIsolation;
661     byMediumIsolation[j] = i.byMediumIsolation;
662     byTightIsolation[j] = i.byTightIsolation;
663    
664     byLooseCombinedIsolationDeltaBetaCorr3Hits[j] = i.byLooseCombinedIsolationDeltaBetaCorr3Hits;
665     byMediumCombinedIsolationDeltaBetaCorr3Hits[j] = i.byMediumCombinedIsolationDeltaBetaCorr3Hits;
666     byTightCombinedIsolationDeltaBetaCorr3Hits[j] = i.byTightCombinedIsolationDeltaBetaCorr3Hits;
667     againstElectronMVA3raw[j] = i.againstElectronMVA3raw;
668     againstElectronMVA3category[j] = i.againstElectronMVA3category;
669     againstElectronLooseMVA3[j] = i.againstElectronLooseMVA3;
670     againstElectronMediumMVA3[j] = i.againstElectronMediumMVA3;
671     againstElectronTightMVA3[j] = i.againstElectronTightMVA3;
672     againstElectronVTightMVA3[j] = i.againstElectronVTightMVA3;
673     againstElectronDeadECAL[j] = i.againstElectronDeadECAL;
674     byLooseIsolationMVA[j] = i.byLooseIsolationMVA;
675     byMediumIsolationMVA[j] = i.byMediumIsolationMVA;
676     byTightIsolationMVA[j] = i.byTightIsolationMVA;
677     byLooseIsolationMVA2[j] = i.byLooseIsolationMVA2;
678     byMediumIsolationMVA2[j] = i.byMediumIsolationMVA2;
679     byTightIsolationMVA2[j] = i.byTightIsolationMVA2;
680     againstMuonLoose2[j] = i.againstMuonLoose2;
681     againstMuonMedium2[j] = i.againstMuonMedium2;
682     againstMuonTight2[j] = i.againstMuonTight2;
683    
684     }
685 arizzi 1.4
686 bortigno 1.30 typedef struct
687     {
688     float et;
689     float sumet;
690     float sig;
691     float phi;
692     } METInfo;
693 degrutto 1.69
694    
695     typedef struct
696     {
697    
698     float et[nMetUnc]; float phi[nMetUnc]; float sumet[nMetUnc];
699     template <class Input> void set(const Input & i, int j)
700     {
701     et[j]=i.p4.Pt();
702     phi[j]=i.p4.Phi();
703     sumet[j]=i.sumEt;
704    
705     }
706     } METUncInfo ;
707    
708 arizzi 1.1
709 bortigno 1.30 typedef struct
710     {
711     float mht;
712     float ht;
713     float sig;
714     float phi;
715     } MHTInfo;
716 nmohr 1.5
717 bortigno 1.30 typedef struct
718     {
719     float mass;
720     float pt;
721     float wMass;
722     } TopInfo;
723 arizzi 1.1
724 bortigno 1.30 typedef struct
725     {
726     int run;
727     int lumi;
728     int event;
729     int json;
730     } EventInfo;
731 arizzi 1.98
732    
733     BTagShapeInterface * nominalShape=0;
734     BTagShapeInterface * downBCShape=0;
735     BTagShapeInterface * upBCShape=0;
736     BTagShapeInterface * downLShape=0;
737     BTagShapeInterface * upLShape=0;
738    
739 arizzi 1.110 BTagShapeInterface * nominalShape4p=0;
740     BTagShapeInterface * downBCShape4p=0;
741     BTagShapeInterface * upBCShape4p=0;
742 arizzi 1.115 BTagShapeInterface * nominalShape1Bin=0;
743 bortigno 1.30 typedef struct
744     {
745     void set(const VHbbEvent::SimpleJet & j, int i)
746 arizzi 1.1 {
747 bortigno 1.30 pt[i]=j.p4.Pt();
748     eta[i]=j.p4.Eta();
749     phi[i]=j.p4.Phi();
750 arizzi 1.51 e[i]=j.p4.E();
751 bortigno 1.30 csv[i]=j.csv;
752 arizzi 1.98 if(nominalShape)
753     {
754     csv_nominal[i]=nominalShape->reshape(eta[i],pt[i],j.csv,j.flavour);
755     csv_upBC[i]=upBCShape->reshape(eta[i],pt[i],j.csv,j.flavour);
756     csv_downBC[i]=downBCShape->reshape(eta[i],pt[i],j.csv,j.flavour);
757     csv_upL[i]=upLShape->reshape(eta[i],pt[i],j.csv,j.flavour);
758     csv_downL[i]=downLShape->reshape(eta[i],pt[i],j.csv,j.flavour);
759 arizzi 1.110 csv_nominal4p[i]=nominalShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
760     csv_upBC4p[i]=upBCShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
761     csv_downBC4p[i]=downBCShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
762 arizzi 1.115 csv_nominal1Bin[i]=nominalShape1Bin->reshape(eta[i],pt[i],j.csv,j.flavour);
763 arizzi 1.98 }
764     else
765     {
766     csv_nominal[i]=csv[i];
767     csv_downBC[i]=csv[i];
768     csv_upBC[i]=csv[i];
769     csv_downL[i]=csv[i];
770     csv_upL[i]=csv[i];
771 arizzi 1.110 csv_nominal4p[i]=csv[i];
772     csv_downBC4p[i]=csv[i];
773     csv_upBC4p[i]=csv[i];
774 arizzi 1.115 csv_nominal1Bin[i]=csv[i];
775 arizzi 1.98 }
776 arizzi 1.70 csvivf[i]=j.csvivf;
777     cmva[i]=j.cmva;
778     numTracksSV[i] = j.vtxNTracks;
779 bortigno 1.30 vtxMass[i]= j.vtxMass;
780 dlopes 1.73 vtxPt[i]= j.vtxP4.Pt();
781 arizzi 1.111 if(j.vtxP4.Pt() > 0) vtxEta[i]= j.vtxP4.Eta(); else vtxEta[i]=-99;
782 dlopes 1.73 vtxPhi[i]= j.vtxP4.Phi();
783     vtxE[i]= j.vtxP4.E();
784 bortigno 1.30 vtx3dL[i] = j.vtx3dL;
785     vtx3deL[i] = j.vtx3deL;
786     chf[i]=j.chargedHadronEFraction;
787     nhf[i] =j.neutralHadronEFraction;
788     cef[i] =j.chargedEmEFraction;
789     nef[i] =j.neutralEmEFraction;
790     nconstituents[i] =j.nConstituents;
791     nch[i]=j.ntracks;
792 arizzi 1.64 SF_CSVL[i]=j.SF_CSVL;
793     SF_CSVM[i]=j.SF_CSVM;
794     SF_CSVT[i]=j.SF_CSVT;
795     SF_CSVLerr[i]=j.SF_CSVLerr;
796     SF_CSVMerr[i]=j.SF_CSVMerr;
797     SF_CSVTerr[i]=j.SF_CSVTerr;
798 bortigno 1.30
799     flavour[i]=j.flavour;
800 degrutto 1.66 isSemiLeptMCtruth[i]=j.isSemiLeptMCtruth;
801     isSemiLept[i]=j.isSemiLept;
802 degrutto 1.68 SoftLeptpdgId[i] = j.SoftLeptpdgId;
803     SoftLeptIdlooseMu[i] = j.SoftLeptIdlooseMu;
804     SoftLeptId95[i] = j.SoftLeptId95;
805     SoftLeptPt[i] = j.SoftLeptPt;
806     SoftLeptdR[i] = j.SoftLeptdR;
807     SoftLeptptRel[i] = j.SoftLeptptRel;
808     SoftLeptRelCombIso[i] = j.SoftLeptRelCombIso;
809 bortigno 1.30 if(j.bestMCp4.Pt() > 0)
810     {
811     genPt[i]=j.bestMCp4.Pt();
812     genEta[i]=j.bestMCp4.Eta();
813     genPhi[i]=j.bestMCp4.Phi();
814     }
815     JECUnc[i]=j.jecunc;
816 arizzi 1.36 id[i]=jetId(i);
817 dlopes 1.73 ptRaw[i]=j.ptRaw;
818     ptLeadTrack[i]=j.ptLeadTrack;
819 degrutto 1.86 puJetIdL[i]=j.puJetIdL;
820     puJetIdM[i]=j.puJetIdM;
821     puJetIdT[i]=j.puJetIdT;
822     puJetIdMva[i]=j.puJetIdMva;
823 mooney 1.105 charge[i]=j.charge;
824 cboeser 1.107 jetArea[i]=j.jetArea;
825    
826     }
827 dlopes 1.73
828 arizzi 1.36 bool jetId(int i)
829     {
830     if(nhf[i] > 0.99) return false;
831     if(nef[i] > 0.99) return false;
832 arizzi 1.37 if(nconstituents[i] <= 1) return false;
833 arizzi 1.47 if(fabs(eta[i])<2.5) {
834 arizzi 1.36 if(cef[i] > 0.99) return false;
835 arizzi 1.37 if(chf[i] == 0) return false;
836 arizzi 1.36 if(nch[i]== 0) return false;
837 arizzi 1.37 }
838 arizzi 1.36 return true;
839 bortigno 1.30 }
840     void reset()
841     {
842     for(int i=0;i<MAXJ;i++) {
843 arizzi 1.115 pt[i]=-99; eta[i]=-99; phi[i]=-99;e[i]=-99;csv[i]=-99;csv_nominal[i]=-99.;csv_upBC[i]=-99.;csv_downBC[i]=-99.;csv_upL[i]=-99.;csv_downL[i]=-99.;csv_nominal1Bin[i]=-99.;
844 dlopes 1.73 csvivf[i]=-99; cmva[i]=-99;
845     cosTheta[i]=-99; numTracksSV[i]=-99; chf[i]=-99; nhf[i]=-99; cef[i]=-99; nef[i]=-99; nch[i]=-99; nconstituents[i]=-99; flavour[i]=-99; isSemiLeptMCtruth[i]=-99; isSemiLept[i]=-99;
846     SoftLeptpdgId[i] = -99; SoftLeptIdlooseMu[i] = -99; SoftLeptId95[i] = -99; SoftLeptPt[i] = -99; SoftLeptdR[i] = -99; SoftLeptptRel[i] = -99; SoftLeptRelCombIso[i] = -99;
847 msegala 1.124 genPt[i]=-99; genEta[i]=-99; genPhi[i]=-99; JECUnc[i]=-99; ptRaw[i]=-99.; ptLeadTrack[i]=-99.; puJetIdL[i]=-99; puJetIdM[i]=-99; puJetIdT[i]=-99; puJetIdMva[i]=-99; charge[i]=-99; jetArea[i]=-99; selectedTauDR[i] = -99.;
848 arizzi 1.1 }
849 bortigno 1.30 }
850     float pt[MAXJ];
851     float eta[MAXJ];
852     float phi[MAXJ];
853 arizzi 1.51 float e[MAXJ];
854 bortigno 1.30 float csv[MAXJ];
855 arizzi 1.98 float csv_nominal[MAXJ];
856     float csv_upBC[MAXJ];
857     float csv_downBC[MAXJ];
858     float csv_upL[MAXJ];
859     float csv_downL[MAXJ];
860 arizzi 1.110 float csv_nominal4p[MAXJ];
861     float csv_upBC4p[MAXJ];
862     float csv_downBC4p[MAXJ];
863 arizzi 1.115 float csv_nominal1Bin[MAXJ];
864 arizzi 1.70 float csvivf[MAXJ];
865     float cmva[MAXJ];
866 bortigno 1.30 float cosTheta[MAXJ];
867     int numTracksSV[MAXJ];
868     float chf[MAXJ];
869     float nhf[MAXJ];
870     float cef[MAXJ];
871     float nef[MAXJ];
872     float nch[MAXJ];
873     float nconstituents[MAXJ];
874     float flavour[MAXJ];
875 degrutto 1.68 int isSemiLept[MAXJ];
876     int isSemiLeptMCtruth[MAXJ];
877     int SoftLeptpdgId[MAXJ] ;
878     int SoftLeptIdlooseMu[MAXJ] ;
879     int SoftLeptId95[MAXJ] ;
880     float SoftLeptPt[MAXJ] ;
881     float SoftLeptdR[MAXJ] ;
882     float SoftLeptptRel[MAXJ] ;
883     float SoftLeptRelCombIso[MAXJ];
884 bortigno 1.30 float genPt[MAXJ];
885     float genEta[MAXJ];
886     float genPhi[MAXJ];
887     float JECUnc[MAXJ];
888     float vtxMass[MAXJ];
889 dlopes 1.73 float vtxPt[MAXJ];
890     float vtxEta[MAXJ];
891     float vtxPhi[MAXJ];
892     float vtxE[MAXJ];
893 bortigno 1.30 float vtx3dL [MAXJ];
894     float vtx3deL[MAXJ];
895 arizzi 1.36 bool id[MAXJ];
896 arizzi 1.64 float SF_CSVL[MAXJ];
897     float SF_CSVM[MAXJ];
898     float SF_CSVT[MAXJ];
899     float SF_CSVLerr[MAXJ];
900     float SF_CSVMerr[MAXJ];
901     float SF_CSVTerr[MAXJ];
902 dlopes 1.73 float ptRaw[MAXJ];
903     float ptLeadTrack[MAXJ];
904 degrutto 1.86 float puJetIdL[MAXJ];
905     float puJetIdM[MAXJ];
906     float puJetIdT[MAXJ];
907     float puJetIdMva[MAXJ];
908 mooney 1.105 float charge[MAXJ];
909 cboeser 1.107 float jetArea[MAXJ];
910 msegala 1.124 float selectedTauDR[MAXJ];
911 bortigno 1.30 } JetInfo;
912 arizzi 1.1
913     int main(int argc, char* argv[])
914     {
915     gROOT->Reset();
916    
917     TTree *_outTree;
918 bortigno 1.30 IVFInfo IVF;
919 bortigno 1.74 SimBHadronInfo SimBs;
920 arizzi 1.82 float rho,rho25,rhoN;
921 arizzi 1.39 int nPVs;
922 arizzi 1.9 METInfo MET;
923 arizzi 1.52 METInfo fakeMET;
924 arizzi 1.36 METInfo METnoPU;
925 arizzi 1.58 METInfo METnoPUCh;
926 degrutto 1.69 METInfo METtype1corr;
927     METInfo METtype1p2corr;
928     METInfo METnoPUtype1corr;
929     METInfo METnoPUtype1p2corr;
930 jiafulow 1.114 METInfo METtype1diff;
931 degrutto 1.69
932 arizzi 1.9 MHTInfo MHT;
933 degrutto 1.69
934     METUncInfo metUnc;
935    
936    
937 arizzi 1.9 TopInfo top;
938     EventInfo EVENT;
939 bortigno 1.30 // JetInfo jet1,jet2, addJet1, addJet2;
940 arizzi 1.9 // lepton1,lepton2;
941 dlopes 1.73 JetInfo hJets, aJets, fathFilterJets, aJetsFat;
942 msegala 1.124 LeptonInfo vLeptons, aLeptons, vLeptonsTaus;
943 dlopes 1.73 int naJets=0, nhJets=0, nfathFilterJets=0, naJetsFat=0;
944 bortigno 1.74 HiggsInfo H,SVH,SimBsH;
945 dlopes 1.67 FatHiggsInfo FatH;
946 degrutto 1.69 genParticleInfo genZ, genZstar, genWstar, genW, genH, genB, genBbar; //add here the fatjet higgs
947 sdas 1.132 genParticleInfo genX, genH1, genH1B, genH1Bbar, genH2, genH2B, genH2Bbar;
948 degrutto 1.69 genTopInfo genTop, genTbar;
949 arizzi 1.9 TrackInfo V;
950 arizzi 1.120 TrackInfo VTau;
951 msegala 1.124 int nvlep=0,nalep=0,nvlepTau=0;
952 bortigno 1.79 float lheV_pt=0; //for the Madgraph sample stitching
953 bortigno 1.90 float lheHT=0; //for the Madgraph sample stitching
954     float lheNj=0; //for the Madgraph sample stitching
955 malbouis 1.71 TrackSharingInfo TkSharing; // track sharing info;
956 arizzi 1.123 unsigned int nPdf=0; // number of pdf sets stored
957     float PDFweight[MAXPDF]; // for pdf reweighting (only madgraph)
958    
959 degrutto 1.54
960 arizzi 1.111 float HVdPhi,HVMass,HMETdPhi,VMt,deltaPullAngle,deltaPullAngleAK7,deltaPullAngle2,deltaPullAngle2AK7,gendrcc,gendrbb, genZpt, genWpt, genHpt, weightTrig, weightTrigMay,weightTrigV4, weightTrigMET, weightTrigOrMu30, minDeltaPhijetMET, jetPt_minDeltaPhijetMET , PUweight, PUweightP,PUweightM, PUweightAB, PUweight2011B,PUweight1DObs;
961 arizzi 1.115 float PU0,PUp1,PUm1,weightMCProd;
962 arizzi 1.119 bool isBadHcalEvent=false;
963 arizzi 1.60 float weightEleRecoAndId,weightEleTrigJetMETPart, weightEleTrigElePart,weightEleTrigEleAugPart;
964 arizzi 1.64 float weightTrigMET80, weightTrigMET100, weightTrig2CJet20 , weightTrigMET150 , weightTrigMET802CJet, weightTrigMET1002CJet, weightTrigMETLP ;
965 arizzi 1.24
966 arizzi 1.89 float weightTrig2012A, weightTrig2012ADiMuon, weightTrig2012ADiEle, weightTrig2012ASingleMuon, weightTrig2012AMuonPlusWCandPt, weightTrig2012ASingleEle;
967 arizzi 1.110 float weightTrig2012AB, weightTrig2012ABDiMuon, weightTrig2012ABDiEle, weightTrig2012ABSingleMuon, weightTrig2012ABMuonPlusWCandPt, weightTrig2012ABSingleEle;
968     float weightTrig2012, weightTrig2012DiMuon, weightTrig2012DiEle, weightTrig2012SingleMuon, weightTrig2012MuonPlusWCandPt, weightTrig2012SingleEle;
969 arizzi 1.89
970 arizzi 1.92 float weightTrig2012DiJet30MHT80,weightTrig2012PFMET150,weightTrig2012SumpT100MET100;
971 degrutto 1.108 float weightTrig2012APFMET150orDiJetMET, weightTrig2012BPFMET150orDiJetMET, weightTrig2012CPFMET150orDiJetMET;
972 arizzi 1.92
973 arizzi 1.125 float weightSignalEWK, weightSignalQCD;
974    
975 msegala 1.124 int tauPlusMode, tauMinusMode;
976 arizzi 1.49 int WplusMode,WminusMode;
977 arizzi 1.120 int Vtype,VtypeWithTau,nSvs=0;
978 arizzi 1.84 int nSimBs=0;
979     int numJets,numBJets,eventFlav;
980 bortigno 1.30 // bool isMET80_CJ80, ispfMHT150, isMET80_2CJ20,isMET65_2CJ20, isJETID,isIsoMu17;
981 degrutto 1.104 bool triggerFlags[500],hbhe,ecalFlag,totalKinematics, cschaloFlag, hcallaserFlag, trackingfailureFlag , eebadscFlag ;
982 degrutto 1.69
983    
984 arizzi 1.60 float btag1T2CSF=1.,btag2TSF=1.,btag1TSF=1.,btagA0CSF=1., btagA0TSF=1., btag2CSF=1., btag1TA1C=1.;
985 arizzi 1.1 // ----------------------------------------------------------------------
986     // First Part:
987     //
988     // * enable the AutoLibraryLoader
989     // * book the histograms of interest
990     // * open the input file
991     // ----------------------------------------------------------------------
992    
993     // load framework libraries
994 bortigno 1.30 gSystem->Load("libFWCoreFWLite");
995 arizzi 1.1 gSystem->Load("libDataFormatsFWLite");
996     AutoLibraryLoader::enable();
997 arizzi 1.123
998     //init the PDF set. Need to check for each sample beacuse pdfset and pdfmember info missing in AODSIM.
999    
1000     //here the list of supported set http://lhapdf.hepforge.org/manual
1001     //you can aslo call it by name
1002     //initPDFSet(int nset,const std::string &filename, int member=0) // If you want to use more than one (but not more than 3) at the same time, initialize them giving nset.
1003     //Initialise member in PDF set file filename. If filename contains a "/" character, it will be used as a path, otherwise it will be assumed to be a PDF file in the LHAPDF PDFsets directory.
1004     //LHAPDF::initPDFSet(1,_pdfset, _pdfmember);
1005     // (for Madgraph always (1,10042,0) : mctqe6l) // CTEQ6l (LO fit/NLO alphas)
1006     LHAPDF::initPDFSet(1, 10042, 0); // this should always be the first
1007    
1008     std::vector<std::string> pdfNames;
1009     //from pdf prescription from LHC PDF group http://arxiv.org/pdf/1101.0538v1.pdf
1010     // pdfNames.push_back("NNPDF20_100.LHgrid"); //NNPDF20 (Neutral Network 100/1000 sets)
1011     // pdfNames.push_back("cteq6mE.LHgrid"); //
1012     pdfNames.push_back("cteq66.LHgrid"); //
1013     // pdfNames.push_back("MSTW2008lo68cl.LHgrid"); // MSTW2008 (LO central)
1014     pdfNames.push_back("MSTW2008nlo68cl.LHgrid"); // MSTW2008 (NLO central)
1015     //Other possible examples:
1016     // pdfNames.push_back("cteq6lg.LHgrid"); // CTEQ61 (central value)
1017     // pdfNames.push_back("cteq61.LHgrid"); // CTEQ61 (central value)
1018     // pdfNames.push_back("CT10.LHgrid"); // CT10 (central value)
1019     // pdfNames.push_back("CT10nlo.LHgrid"); // CT10nlo (new fit - central value)
1020     // pdfNames.push_back("CT10nnlo.LHgrid"); // CT10nnlo (new fit - central value)
1021     // pdfNames.push_back("cteq5m1.LHgrid"); //CTEQ5m1 (updated CTEQ5m)
1022     // pdfNames.push_back("MRST2001lo.LHgrid.gz");// MRST2001lo (LO fit)
1023     // pdfNames.push_back("MRST2001nlo.LHgrid.gz"); // MRST2001nlo (Standard MSbar)
1024     // pdfNames.push_back("MRST2001nnlo.LHgrid.gz"); // MRST2001nnlo (NNLO fit)
1025     // pdfNames.push_back("NNPDF21_nnlo_as_0114.LHgrid"); // NNPDF23_nnlo_as_ (Neutral Network NNLO 0+100 replicas)
1026     // pdfNames.push_back("NNPDF21_100.LHgrid"); //NNPDF23_nlo_as_ (Neutral Network NLO 0+100 replicas)
1027     // pdfNames.push_back("MSTW2008lo68cl.LHgrid"); // MSTW2008 (LO central)
1028     // pdfNames.push_back("MSTW2008nnlo68cl.LHgrid"); // MSTW2008 (NNLO central)
1029    
1030     //initializing all the pdf sets
1031     nPdf=1; // one count the nominal PDF
1032     for (unsigned int setpdf=2; setpdf <= pdfNames.size()+1; setpdf++){
1033     // std::cout << "pdf set " << setpdf << std::endl;
1034     // LHAPDF::initPDFSet(setpdf, pdfNames[setpdf-2], 0); // the member should always be zero (if you do not know what you are doing)
1035     LHAPDF::initPDFSet(setpdf, pdfNames[setpdf-2]); // the member should always be zero (if you do not know what you are doing)
1036     nPdf+=LHAPDF::numberPDF(setpdf); // count all the members of all the pdfsets
1037     }
1038     std::cout << "pdf memebers " << nPdf << std::endl;
1039    
1040 arizzi 1.1
1041     // parse arguments
1042     if ( argc < 2 ) {
1043     return 0;
1044     }
1045    
1046 arizzi 1.4 std::vector<VHbbCandidate> * candZlocal = new std::vector<VHbbCandidate>;
1047     std::vector<VHbbCandidate> * candWlocal = new std::vector<VHbbCandidate>;
1048    
1049 arizzi 1.1 // get the python configuration
1050     PythonProcessDesc builder(argv[1]);
1051     const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
1052     const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
1053     const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
1054 bortigno 1.30
1055 nmohr 1.7 std::vector<edm::LuminosityBlockRange> jsonVector;
1056     if ( in.exists("lumisToProcess") )
1057 bortigno 1.30 {
1058     std::vector<edm::LuminosityBlockRange> const & lumisTemp =
1059     in.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> > ("lumisToProcess");
1060 nmohr 1.7 jsonVector.resize( lumisTemp.size() );
1061     copy( lumisTemp.begin(), lumisTemp.end(), jsonVector.begin() );
1062 bortigno 1.30 }
1063 arizzi 1.1
1064     // now get each parameter
1065     int maxEvents_( in.getParameter<int>("maxEvents") );
1066 nmohr 1.29 int skipEvents_( in.getParameter<int>("skipEvents") );
1067 arizzi 1.64 int runMin_( in.getParameter<int>("runMin") );
1068     int runMax_( in.getParameter<int>("runMax") );
1069 arizzi 1.1 unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
1070     std::string outputFile_( out.getParameter<std::string>("fileName" ) );
1071     std::vector<std::string> triggers( ana.getParameter<std::vector<std::string> >("triggers") );
1072 arizzi 1.6 double btagThr = ana.getParameter<double>("bJetCountThreshold" );
1073 arizzi 1.4 bool fromCandidate = ana.getParameter<bool>("readFromCandidates");
1074 arizzi 1.17 bool useHighestPtHiggsZ = ana.getParameter<bool>("useHighestPtHiggsZ");
1075     bool useHighestPtHiggsW = ana.getParameter<bool>("useHighestPtHiggsW");
1076 nmohr 1.31 HbbCandidateFinderAlgo * algoZ = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdZ"),useHighestPtHiggsZ);
1077     HbbCandidateFinderAlgo * algoW = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdW"),useHighestPtHiggsW );
1078 arizzi 1.64 HbbCandidateFinderAlgo * algoRecoverLowPt = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), 15, true);
1079 arizzi 1.4
1080 arizzi 1.16 TriggerWeight triggerWeight(ana);
1081 arizzi 1.110
1082     const edm::ParameterSet& anaAB = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer2012ABOnly");
1083     TriggerWeight triggerWeightAB(anaAB);
1084    
1085 arizzi 1.17 BTagWeight btag(2); // 2 operating points "Custom" = 0.5 and "Tight = 0.898"
1086     BTagSampleEfficiency btagEff( ana.getParameter<std::string>("btagEffFileName" ).c_str() );
1087 arizzi 1.1
1088     std::vector<std::string> inputFiles_( in.getParameter<std::vector<std::string> >("fileNames") );
1089 bortigno 1.30 // std::string inputFile( in.getParameter<std::string> ("fileName") );
1090 arizzi 1.1
1091 arizzi 1.3 std::string PUmcfileName_ = in.getParameter<std::string> ("PUmcfileName") ;
1092 degrutto 1.57 std::string PUmcfileName2011B_ = in.getParameter<std::string> ("PUmcfileName2011B") ;
1093    
1094 arizzi 1.111 std::string PUdatafileNameAB = in.getParameter<std::string> ("PUdatafileNameAB") ;
1095 arizzi 1.3 std::string PUdatafileName_ = in.getParameter<std::string> ("PUdatafileName") ;
1096 arizzi 1.110 std::string PUdatafileName_plusOneSigma = in.getParameter<std::string> ("PUdatafileNamePlus") ;
1097     std::string PUdatafileName_minusOneSigma = in.getParameter<std::string> ("PUdatafileNameMinus") ;
1098 degrutto 1.54 std::string PUdatafileName2011B_ = in.getParameter<std::string> ("PUdatafileName2011B") ;
1099 arizzi 1.63 std::string Weight3DfileName_ = in.getParameter<std::string> ("Weight3DfileName") ;
1100 arizzi 1.98
1101 arizzi 1.93 JECFWLite jec(ana.getParameter<std::string>("jecFolder"));
1102 sdas 1.132
1103     bool isZbbHbbAnalysis_(ana.getParameter<bool>("isZbbHbbAnalysis"));
1104 degrutto 1.54
1105 arizzi 1.1 bool isMC_( ana.getParameter<bool>("isMC") );
1106 msegala 1.130 TriggerReader trigger(false);
1107     TriggerReader patFilters(false);
1108 arizzi 1.119
1109     vector<RLE> badEvents;
1110 arizzi 1.121 if(!isMC_)
1111 arizzi 1.119 {
1112     readBadEvents(in.getParameter<std::string> ("badEventsFileName").c_str() ,badEvents);
1113     }
1114 arizzi 1.98 if(isMC_)
1115     {
1116     nominalShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0);
1117 arizzi 1.129 upBCShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 1.0, 0.0);
1118     downBCShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), -1.0, 0.0);
1119 arizzi 1.98 upLShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 1.0);
1120     downLShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, -1.0);
1121 arizzi 1.110 nominalShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.003,1.003);
1122     upBCShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.001,1.001);
1123     downBCShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.005,1.005);
1124 arizzi 1.115 nominalShape1Bin = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.001,1.001,1);
1125 arizzi 1.98 }
1126 arizzi 1.111 edm::LumiReWeighting lumiWeights,lumiWeightsPl,lumiWeightsMi,lumiWeightsAB;
1127 arizzi 1.89 edm::LumiReWeighting lumiWeights1DObs;
1128 arizzi 1.103 // edm::Lumi3DReWeighting lumiWeights2011B;
1129 arizzi 1.25 if(isMC_)
1130 bortigno 1.30 {
1131 arizzi 1.34 lumiWeights = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
1132 arizzi 1.110 lumiWeightsPl = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_plusOneSigma , "pileup", "pileup");
1133     lumiWeightsMi = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_minusOneSigma , "pileup", "pileup");
1134 arizzi 1.111 lumiWeightsAB = edm::LumiReWeighting(PUmcfileName_,PUdatafileNameAB , "pileup", "pileup");
1135 arizzi 1.89 lumiWeights1DObs = edm::LumiReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
1136 degrutto 1.54
1137 arizzi 1.103 // lumiWeights2011B = edm::Lumi3DReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
1138     // if(Weight3DfileName_!="")
1139     // { lumiWeights2011B.weight3D_init(Weight3DfileName_.c_str()); }
1140     // else
1141     // {
1142     // lumiWeights2011B.weight3D_init(1.0); // generate the weights the fisrt time;
1143     // }
1144 degrutto 1.54
1145 bortigno 1.30 }
1146 arizzi 1.1
1147 bortigno 1.30 // TFile *_outPUFile = new TFile((outputFile_+"_PU").c_str(), "recreate");
1148     TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
1149     TH1F * count = new TH1F("Count","Count", 1,0,2 );
1150     TH1F * countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
1151 arizzi 1.110 TH1F * countWithPUP = new TH1F("CountWithPUP","CountWithPU plus one sigma", 1,0,2 );
1152     TH1F * countWithPUM = new TH1F("CountWithPUM","CountWithPU minus one sigma", 1,0,2 );
1153 arizzi 1.111 TH1F * countWithPUAB = new TH1F("CountWithPUAB","CountWithPU 2012AB", 1,0,2 );
1154    
1155 arizzi 1.58 TH1F * countWithPU2011B = new TH1F("CountWithPU2011B","CountWithPU2011B", 1,0,2 );
1156 arizzi 1.118 TH1F * coutnWithMCProd = new TH1F("CountWithMCProd","CountWithMCProd", 1,0,2 );
1157     TH1F * countWithPUMCProd = new TH1F("CountWithPUMCProd","CountWithPUMCProd", 1,0,2 );
1158 arizzi 1.125 TH1F * countWithSignalQCDcorrections = new TH1F("countWithSignalQCDcorrections","countWithSignalQCDcorrections", 1,0,2 );
1159    
1160 arizzi 1.118
1161 arizzi 1.62 TH3F * input3DPU = new TH3F("Input3DPU","Input3DPU", 36,-0.5,35.5,36,-0.5,35.5, 36,-0.5,35.5 );
1162 arizzi 1.58
1163 arizzi 1.41 TH1F * pu = new TH1F("pileup","",51,-0.5,50.5);
1164 arizzi 1.1 _outTree = new TTree("tree", "myTree");
1165    
1166 bortigno 1.75 _outTree->Branch("H" , &H , "HiggsFlag/I:mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
1167     _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
1168 arizzi 1.120 _outTree->Branch("VTau" , &VTau , "mass/F:pt/F:eta:phi/F");
1169 bortigno 1.75 _outTree->Branch("FatH" , &FatH , "FatHiggsFlag/I:mass/F:pt/F:eta:phi/F:filteredmass/F:filteredpt/F:filteredeta/F:filteredphi/F");
1170     _outTree->Branch("lheV_pt" , &lheV_pt , "lheV_pt/F");
1171 bortigno 1.90 _outTree->Branch("lheHT" , &lheHT , "lheHT/F");
1172     _outTree->Branch("lheNj" , &lheNj , "lheNj/F");
1173 arizzi 1.123 _outTree->Branch("nPdf" , &nPdf , "nPdf/I");
1174     _outTree->Branch("PDFweight" , PDFweight , "PDFweight[nPdf]/F");
1175    
1176 degrutto 1.69 _outTree->Branch("genZ" , &genZ , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1177     _outTree->Branch("genZstar" , &genZstar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1178     _outTree->Branch("genW" , &genW , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1179     _outTree->Branch("genWstar" , &genWstar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1180     _outTree->Branch("genH" , &genH , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1181     _outTree->Branch("genB" , &genB , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1182     _outTree->Branch("genBbar" , &genBbar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1183    
1184     _outTree->Branch("genTop" , &genTop , "bmass/F:bpt/F:beta:bphi/F:bstatus/F:wdau1mass/F:wdau1pt/F:wdau1eta:wdau1phi/F:wdau1id/F:wdau2mass/F:wdau2pt/F:wdau2eta:wdau2phi/F:wdau2id/F");
1185     _outTree->Branch("genTbar" , &genTbar , "bmass/F:bpt/F:beta:bphi/F:bstatus/F:wdau1mass/F:wdau1pt/F:wdau1eta:wdau1phi/F:wdau1id/F:wdau2mass/F:wdau2pt/F:wdau2eta:wdau2phi/F:wdau2id/F");
1186    
1187 sdas 1.132 // --- Souvik's addition for HbbHbb ---
1188     _outTree->Branch("genX", &genX, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1189     _outTree->Branch("genH1", &genH1, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1190     _outTree->Branch("genH2", &genH2, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1191     _outTree->Branch("genH1B", &genH1B, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1192     _outTree->Branch("genH1Bbar", &genH1Bbar, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1193     _outTree->Branch("genH2B", &genH2B, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1194     _outTree->Branch("genH2Bbar", &genH2Bbar, "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
1195     // ------------------------------------
1196    
1197 malbouis 1.71 _outTree->Branch("TkSharing", &TkSharing, "HiggsCSVtkSharing/b:HiggsIPtkSharing:HiggsSVtkSharing:FatHiggsCSVtkSharing:FatHiggsIPtkSharing:FatHiggsSVtkSharing");
1198 degrutto 1.69
1199 arizzi 1.1 _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
1200 dlopes 1.67 _outTree->Branch("nfathFilterJets", &nfathFilterJets, "nfathFilterJets/I");
1201 arizzi 1.1 _outTree->Branch("naJets" , &naJets , "naJets/I");
1202 arizzi 1.2
1203 arizzi 1.119
1204 arizzi 1.115 _outTree->Branch("weightMCProd" , &weightMCProd , "weightMCProd/F");
1205 arizzi 1.119 _outTree->Branch("isBadHcalEvent" , &isBadHcalEvent , "isBadHcalEvent/b");
1206 degrutto 1.69
1207 arizzi 1.2 _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
1208     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
1209     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
1210 arizzi 1.51 _outTree->Branch("hJet_e",hJets.e ,"e[nhJets]/F");
1211 arizzi 1.2 _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
1212 arizzi 1.98 _outTree->Branch("hJet_csv_nominal",hJets.csv_nominal ,"csv_nominal[nhJets]/F");
1213     _outTree->Branch("hJet_csv_upBC",hJets.csv_upBC ,"csv_upBC[nhJets]/F");
1214     _outTree->Branch("hJet_csv_downBC",hJets.csv_downBC ,"csv_downBC[nhJets]/F");
1215     _outTree->Branch("hJet_csv_upL",hJets.csv_upL ,"csv_upL[nhJets]/F");
1216     _outTree->Branch("hJet_csv_downL",hJets.csv_downL ,"csv_downL[nhJets]/F");
1217 arizzi 1.110 _outTree->Branch("hJet_csv_nominal4p",hJets.csv_nominal4p ,"csv_nominal4p[nhJets]/F");
1218     _outTree->Branch("hJet_csv_upBC4p",hJets.csv_upBC4p ,"csv_upBC4p[nhJets]/F");
1219     _outTree->Branch("hJet_csv_downBC4p",hJets.csv_downBC4p ,"csv_downBC4p[nhJets]/F");
1220 arizzi 1.115 _outTree->Branch("hJet_csv_nominal1Bin",hJets.csv_nominal1Bin ,"csv_nominal1Bin[nhJets]/F");
1221 arizzi 1.98
1222 arizzi 1.70 _outTree->Branch("hJet_csvivf",hJets.csvivf ,"csvivf[nhJets]/F");
1223     _outTree->Branch("hJet_cmva",hJets.cmva ,"cmva[nhJets]/F");
1224 arizzi 1.2 _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
1225     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
1226     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
1227     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
1228     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
1229     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
1230     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
1231     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
1232     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
1233 degrutto 1.68 _outTree->Branch("hJet_isSemiLept",hJets.isSemiLept ,"isSemiLept[nhJets]/I");
1234     _outTree->Branch("hJet_isSemiLeptMCtruth",hJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[nhJets]/I");
1235     _outTree->Branch("hJet_SoftLeptpdgId", hJets.SoftLeptpdgId , "SoftLeptpdgId[nhJets]/I");
1236     _outTree->Branch("hJet_SoftLeptIdlooseMu", hJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[nhJets]/I");
1237     _outTree->Branch("hJet_SoftLeptId95", hJets.SoftLeptId95 , "SoftLeptId95[nhJets]/I");
1238     _outTree->Branch("hJet_SoftLeptPt", hJets.SoftLeptPt , "SoftLeptPt[nhJets]/F");
1239     _outTree->Branch("hJet_SoftLeptdR", hJets.SoftLeptdR , "SoftLeptdR[nhJets]/F");
1240     _outTree->Branch("hJet_SoftLeptptRel", hJets.SoftLeptptRel , "SoftLeptptRel[nhJets]/F");
1241     _outTree->Branch("hJet_SoftLeptRelCombIso", hJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[nhJets]/F");
1242 sdas 1.133 _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
1243 arizzi 1.2 _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
1244     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
1245     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
1246 arizzi 1.36 _outTree->Branch("hJet_vtxMass",hJets.vtxMass ,"vtxMass[nhJets]/F");
1247 dlopes 1.73 _outTree->Branch("hJet_vtxPt",hJets.vtxPt ,"vtxPt[nhJets]/F");
1248     _outTree->Branch("hJet_vtxEta",hJets.vtxEta ,"vtxEta[nhJets]/F");
1249     _outTree->Branch("hJet_vtxPhi",hJets.vtxPhi ,"vtxPhi[nhJets]/F");
1250     _outTree->Branch("hJet_vtxE",hJets.vtxE ,"vtxE[nhJets]/F");
1251 arizzi 1.36 _outTree->Branch("hJet_vtx3dL",hJets.vtx3dL ,"vtx3dL[nhJets]/F");
1252     _outTree->Branch("hJet_vtx3deL",hJets.vtx3deL ,"vtx3deL[nhJets]/F");
1253     _outTree->Branch("hJet_id",hJets.id ,"id[nhJets]/b");
1254 arizzi 1.64 _outTree->Branch("hJet_SF_CSVL",hJets.SF_CSVL ,"SF_CSVL[nhJets]/b");
1255     _outTree->Branch("hJet_SF_CSVM",hJets.SF_CSVM ,"SF_CSVM[nhJets]/b");
1256     _outTree->Branch("hJet_SF_CSVT",hJets.SF_CSVT ,"SF_CSVT[nhJets]/b");
1257     _outTree->Branch("hJet_SF_CSVLerr",hJets.SF_CSVLerr ,"SF_CSVLerr[nhJets]/b");
1258     _outTree->Branch("hJet_SF_CSVMerr",hJets.SF_CSVMerr ,"SF_CSVMerr[nhJets]/b");
1259     _outTree->Branch("hJet_SF_CSVTerr",hJets.SF_CSVTerr ,"SF_CSVTerr[nhJets]/b");
1260 dlopes 1.73 _outTree->Branch("hJet_ptRaw",hJets.ptRaw ,"ptRaw[nhJets]/F");
1261     _outTree->Branch("hJet_ptLeadTrack",hJets.ptLeadTrack ,"ptLeadTrack[nhJets]/F");
1262 degrutto 1.86 _outTree->Branch("hJet_puJetIdL",hJets.puJetIdL ,"puJetIdL[nhJets]/F");
1263     _outTree->Branch("hJet_puJetIdM",hJets.puJetIdM ,"puJetIdM[nhJets]/F");
1264     _outTree->Branch("hJet_puJetIdT",hJets.puJetIdT ,"puJetIdT[nhJets]/F");
1265     _outTree->Branch("hJet_puJetIdMva",hJets.puJetIdMva ,"puJetIdMva[nhJets]/F");
1266 mooney 1.105 _outTree->Branch("hJet_charge",hJets.charge ,"charge[nhJets]/F");
1267 arizzi 1.2
1268 dlopes 1.67 _outTree->Branch("fathFilterJets_pt",fathFilterJets.pt ,"pt[nfathFilterJets]/F");
1269     _outTree->Branch("fathFilterJets_eta",fathFilterJets.eta ,"eta[nfathFilterJets]/F");
1270     _outTree->Branch("fathFilterJets_phi",fathFilterJets.phi ,"phi[nfathFilterJets]/F");
1271     _outTree->Branch("fathFilterJets_e",fathFilterJets.e ,"e[nfathFilterJets]/F");
1272     _outTree->Branch("fathFilterJets_csv",fathFilterJets.csv ,"csv[nfathFilterJets]/F");
1273 dlopes 1.73 _outTree->Branch("fathFilterJets_chf",fathFilterJets.chf ,"chf[nfathFilterJets]/F");
1274     _outTree->Branch("fathFilterJets_ptRaw",fathFilterJets.ptRaw ,"ptRaw[nfathFilterJets]/F");
1275     _outTree->Branch("fathFilterJets_ptLeadTrack",fathFilterJets.ptLeadTrack ,"ptLeadTrack[nfathFilterJets]/F");
1276     _outTree->Branch("fathFilterJets_flavour",fathFilterJets.flavour ,"flavour[nfathFilterJets]/F");
1277     _outTree->Branch("fathFilterJets_isSemiLept",fathFilterJets.isSemiLept ,"isSemiLept[nfathFilterJets]/F");
1278     _outTree->Branch("fathFilterJets_isSemiLeptMCtruth",fathFilterJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[nfathFilterJets]/F");
1279     _outTree->Branch("fathFilterJets_genPt",fathFilterJets.genPt ,"genPt[nfathFilterJets]/F");
1280     _outTree->Branch("fathFilterJets_genEta",fathFilterJets.genEta ,"genEta[nfathFilterJets]/F");
1281     _outTree->Branch("fathFilterJets_genPhi",fathFilterJets.genPhi ,"genPhi[nfathFilterJets]/F");
1282     _outTree->Branch("fathFilterJets_vtxMass",fathFilterJets.vtxMass ,"vtxMass[nfathFilterJets]/F");
1283     _outTree->Branch("fathFilterJets_vtx3dL",fathFilterJets.vtx3dL ,"vtx3dL[nfathFilterJets]/F");
1284     _outTree->Branch("fathFilterJets_vtx3deL",fathFilterJets.vtx3deL ,"vtx3deL[nfathFilterJets]/F");
1285     _outTree->Branch("fathFilterJets_vtxPt",fathFilterJets.vtxPt ,"vtxPt[nfathFilterJets]/F");
1286     _outTree->Branch("fathFilterJets_vtxEta",fathFilterJets.vtxEta ,"vtxEta[nfathFilterJets]/F");
1287     _outTree->Branch("fathFilterJets_vtxPhi",fathFilterJets.vtxPhi ,"vtxPhi[nfathFilterJets]/F");
1288     _outTree->Branch("fathFilterJets_vtxE",fathFilterJets.vtxE ,"vtxE[nfathFilterJets]/F");
1289 cboeser 1.107
1290 dlopes 1.73
1291     // _outTree->Branch("fathFilterJets_pt",fathFilterJets.pt ,"pt[nfathFilterJets]/F");
1292     // _outTree->Branch("fathFilterJets_eta",fathFilterJets.eta ,"eta[nfathFilterJets]/F");
1293     // _outTree->Branch("fathFilterJets_phi",fathFilterJets.phi ,"phi[nfathFilterJets]/F");
1294     // _outTree->Branch("fathFilterJets_e",fathFilterJets.e ,"e[nfathFilterJets]/F");
1295     // _outTree->Branch("fathFilterJets_csv",fathFilterJets.csv ,"csv[nfathFilterJets]/F");
1296 arizzi 1.70 _outTree->Branch("fathFilterJets_csvivf",fathFilterJets.csvivf ,"csvivf[nfathFilterJets]/F");
1297     _outTree->Branch("fathFilterJets_cmva",fathFilterJets.cmva ,"cmva[nfathFilterJets]/F");
1298 dlopes 1.73 // _outTree->Branch("fathFilterJets_flavour",fathFilterJets.flavour ,"flavour[nfathFilterJets]/F");
1299 cboeser 1.107 _outTree->Branch("fathFilterJets_cosTheta",fathFilterJets.cosTheta ,"cosTheta[nfathFilterJets]/F");
1300     _outTree->Branch("fathFilterJets_jetArea",fathFilterJets.jetArea ,"jetArea[nfathFilterJets]/F");
1301 dlopes 1.67
1302 apana 1.112 //ccla 25Jan13
1303     _outTree->Branch("fathFilterJets_nconstituents",fathFilterJets.nconstituents ,"nconstituents[nfathFilterJets]/F");
1304     _outTree->Branch("fathFilterJets_JECUnc",fathFilterJets.JECUnc ,"JECUnc[nfathFilterJets]/F");
1305     _outTree->Branch("fathFilterJets_SoftLeptPt", fathFilterJets.SoftLeptPt , "SoftLeptPt[nfathFilterJets]/F");
1306     _outTree->Branch("fathFilterJets_SoftLeptdR", fathFilterJets.SoftLeptdR , "SoftLeptdR[nfathFilterJets]/F");
1307     _outTree->Branch("fathFilterJets_SoftLeptptRel", fathFilterJets.SoftLeptptRel , "SoftLeptptRel[nfathFilterJets]/F");
1308     _outTree->Branch("fathFilterJets_csv_nominal",fathFilterJets.csv_nominal ,"csv_nominal[nfathFilterJets]/F");
1309     _outTree->Branch("fathFilterJets_nhf",fathFilterJets.nhf ,"nhf[nfathFilterJets]/F");
1310     _outTree->Branch("fathFilterJets_cef",fathFilterJets.cef ,"cef[nfathFilterJets]/F");
1311     _outTree->Branch("fathFilterJets_nef",fathFilterJets.nef ,"nef[nfathFilterJets]/F");
1312     _outTree->Branch("fathFilterJets_nch",fathFilterJets.nch ,"nch[nfathFilterJets]/F");
1313     _outTree->Branch("fathFilterJets_id",fathFilterJets.id ,"id[nfathFilterJets]/b");
1314    
1315 arizzi 1.2 _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
1316     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
1317     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
1318 arizzi 1.51 _outTree->Branch("aJet_e",aJets.e ,"e[naJets]/F");
1319 arizzi 1.2 _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
1320 arizzi 1.98 _outTree->Branch("aJet_csv_nominal",aJets.csv_nominal ,"csv_nominal[naJets]/F");
1321     _outTree->Branch("aJet_csv_upBC",aJets.csv_upBC ,"csv_upBC[naJets]/F");
1322     _outTree->Branch("aJet_csv_downBC",aJets.csv_downBC ,"csv_downBC[naJets]/F");
1323     _outTree->Branch("aJet_csv_upL",aJets.csv_upL ,"csv_upL[naJets]/F");
1324     _outTree->Branch("aJet_csv_downL",aJets.csv_downL ,"csv_downL[naJets]/F");
1325 arizzi 1.110 _outTree->Branch("aJet_csv_nominal4p",aJets.csv_nominal4p ,"csv_nominal4p[naJets]/F");
1326     _outTree->Branch("aJet_csv_upBC4p",aJets.csv_upBC4p ,"csv_upBC4p[naJets]/F");
1327     _outTree->Branch("aJet_csv_downBC4p",aJets.csv_downBC4p ,"csv_downBC4p[naJets]/F");
1328 arizzi 1.115 _outTree->Branch("aJet_csv_nominal1Bin",aJets.csv_nominal1Bin ,"csv_nominal1Bin[naJets]/F");
1329 arizzi 1.98
1330 arizzi 1.70 _outTree->Branch("aJet_csvivf",aJets.csvivf ,"csvivf[naJets]/F");
1331     _outTree->Branch("aJet_cmva",aJets.cmva ,"cmva[naJets]/F");
1332 arizzi 1.2 _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
1333     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
1334     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
1335     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
1336     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
1337     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
1338     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
1339     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
1340     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
1341 degrutto 1.68 _outTree->Branch("aJet_isSemiLept",aJets.isSemiLept ,"isSemiLept[naJets]/I");
1342     _outTree->Branch("aJet_isSemiLeptMCtruth",aJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[naJets]/I");
1343     _outTree->Branch("aJet_SoftLeptpdgId",aJets.SoftLeptpdgId , "SoftLeptpdgId[naJets]/I");
1344     _outTree->Branch("aJet_SoftLeptIdlooseMu", aJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[naJets]/I");
1345     _outTree->Branch("aJet_SoftLeptId95", aJets.SoftLeptId95 , "SoftLeptId95[naJets]/I");
1346     _outTree->Branch("aJet_SoftLeptPt", aJets.SoftLeptPt , "SoftLeptPt[naJets]/F");
1347     _outTree->Branch("aJet_SoftLeptdR", aJets.SoftLeptdR , "SoftLeptdR[naJets]/F");
1348     _outTree->Branch("aJet_SoftLeptptRel", aJets.SoftLeptptRel , "SoftLeptptRel[naJets]/F");
1349     _outTree->Branch("aJet_SoftLeptRelCombIso", aJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[naJets]/F");
1350 degrutto 1.86 _outTree->Branch("aJet_puJetIdL", aJets.puJetIdL , "puJetIdL[naJets]/F");
1351     _outTree->Branch("aJet_puJetIdM", aJets.puJetIdM , "puJetIdM[naJets]/F");
1352     _outTree->Branch("aJet_puJetIdT", aJets.puJetIdT , "puJetIdT[naJets]/F");
1353     _outTree->Branch("aJet_puJetIdMva", aJets.puJetIdMva , "puJetIdMva[naJets]/F");
1354 mooney 1.105 _outTree->Branch("aJet_charge",aJets.charge ,"charge[naJets]/F");
1355 degrutto 1.68
1356 arizzi 1.2 _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
1357     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
1358     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
1359     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
1360 arizzi 1.24 _outTree->Branch("aJet_vtxMass",aJets.vtxMass ,"vtxMass[naJets]/F");
1361 sdas 1.133 _outTree->Branch("aJet_vtxPt",aJets.vtxPt ,"vtxPt[naJets]/F");
1362 arizzi 1.24 _outTree->Branch("aJet_vtx3dL",aJets.vtx3dL ,"vtx3dL[naJets]/F");
1363     _outTree->Branch("aJet_vtx3deL",aJets.vtx3deL ,"vtx3deL[naJets]/F");
1364 arizzi 1.36 _outTree->Branch("aJet_id",aJets.id ,"id[naJets]/b");
1365 arizzi 1.64 _outTree->Branch("aJet_SF_CSVL",aJets.SF_CSVL ,"SF_CSVL[naJets]/b");
1366     _outTree->Branch("aJet_SF_CSVM",aJets.SF_CSVM ,"SF_CSVM[naJets]/b");
1367     _outTree->Branch("aJet_SF_CSVT",aJets.SF_CSVT ,"SF_CSVT[naJets]/b");
1368     _outTree->Branch("aJet_SF_CSVLerr",aJets.SF_CSVLerr ,"SF_CSVLerr[naJets]/b");
1369     _outTree->Branch("aJet_SF_CSVMerr",aJets.SF_CSVMerr ,"SF_CSVMerr[naJets]/b");
1370     _outTree->Branch("aJet_SF_CSVTerr",aJets.SF_CSVTerr ,"SF_CSVTerr[naJets]/b");
1371 sdas 1.133 _outTree->Branch("aJet_ptRaw",aJets.ptRaw ,"ptRaw[naJets]/F");
1372     _outTree->Branch("aJet_ptLeadTrack",aJets.ptLeadTrack ,"ptLeadTrack[naJets]/F");
1373 arizzi 1.1
1374 dlopes 1.73 _outTree->Branch("naJetsFat" , &naJetsFat , "naJetsFat/I");
1375     _outTree->Branch("aJetFat_pt",aJetsFat.pt ,"pt[naJetsFat]/F");
1376     _outTree->Branch("aJetFat_eta",aJetsFat.eta ,"eta[naJetsFat]/F");
1377     _outTree->Branch("aJetFat_phi",aJetsFat.phi ,"phi[naJetsFat]/F");
1378     _outTree->Branch("aJetFat_e",aJetsFat.e ,"e[naJetsFat]/F");
1379     _outTree->Branch("aJetFat_csv",aJetsFat.csv ,"csv[naJetsFat]/F");
1380    
1381    
1382 arizzi 1.1 _outTree->Branch("numJets" , &numJets , "numJets/I" );
1383     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
1384     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
1385 arizzi 1.52 _outTree->Branch("deltaPullAngle2", &deltaPullAngle2 , "deltaPullAngle2/F");
1386 arizzi 1.1 _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
1387     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
1388     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
1389     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
1390 degrutto 1.69 _outTree->Branch("genHpt" , &genHpt , "genHpt/F");
1391 arizzi 1.125 _outTree->Branch("weightSignalEWK" , &weightSignalEWK , "weightSignalEWK/F");
1392     _outTree->Branch("weightSignalQCD" , &weightSignalQCD , "weightSignalQCD/F");
1393    
1394 arizzi 1.1 _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
1395 arizzi 1.38 _outTree->Branch("weightTrigMay" , &weightTrigMay , "weightTrigMay/F");
1396     _outTree->Branch("weightTrigV4" , &weightTrigV4 , "weightTrigV4/F");
1397 arizzi 1.22 _outTree->Branch("weightTrigMET" , &weightTrigMET , "weightTrigMET/F");
1398 arizzi 1.51 _outTree->Branch("weightTrigOrMu30" , &weightTrigOrMu30 , "weightTrigOrMu30/F");
1399 arizzi 1.24 _outTree->Branch("weightEleRecoAndId" , &weightEleRecoAndId , "weightEleRecoAndId/F");
1400     _outTree->Branch("weightEleTrigJetMETPart" , &weightEleTrigJetMETPart , "weightEleTrigJetMETPart/F");
1401     _outTree->Branch("weightEleTrigElePart" , &weightEleTrigElePart , "weightEleTrigElePart/F");
1402 arizzi 1.60 _outTree->Branch("weightEleTrigEleAugPart" , &weightEleTrigEleAugPart , "weightEleTrigEleAugPart/F");
1403 arizzi 1.24
1404 arizzi 1.89
1405 arizzi 1.64 _outTree->Branch("weightTrigMET80" , &weightTrigMET80 , "weightTrigMET80/F");
1406     _outTree->Branch("weightTrigMET100" , &weightTrigMET100 , "weightTrigMET100/F");
1407     _outTree->Branch("weightTrig2CJet20" , &weightTrig2CJet20 , "weightTrig2CJet20/F");
1408     _outTree->Branch("weightTrigMET150" , &weightTrigMET150 , "weightTrigMET150/F");
1409     _outTree->Branch("weightTrigMET802CJet" , &weightTrigMET802CJet , "weightTrigMET802CJet/F");
1410     _outTree->Branch("weightTrigMET1002CJet" , &weightTrigMET1002CJet , "weightTrigMET1002CJet/F");
1411     _outTree->Branch("weightTrigMETLP" , &weightTrigMETLP , "weightTrigMETLP/F");
1412    
1413 arizzi 1.89 _outTree->Branch("weightTrig2012A", &weightTrig2012A,"weightTrig2012A/F");
1414     _outTree->Branch("weightTrig2012ADiMuon", &weightTrig2012ADiMuon,"weightTrig2012ADiMuon/F");
1415     _outTree->Branch("weightTrig2012ADiEle", &weightTrig2012ADiEle,"weightTrig2012ADiEle/F");
1416     _outTree->Branch("weightTrig2012ASingleMuon", &weightTrig2012ASingleMuon,"weightTrig2012ASingleMuon/F");
1417     _outTree->Branch("weightTrig2012ASingleEle", &weightTrig2012ASingleEle,"weightTrig2012ASingleEle/F");
1418     _outTree->Branch("weightTrig2012AMuonPlusWCandPt", &weightTrig2012AMuonPlusWCandPt,"weightTrig2012AMuonPlusWCandPt/F");
1419    
1420 arizzi 1.110
1421     _outTree->Branch("weightTrig2012", &weightTrig2012,"weightTrig2012/F");
1422     _outTree->Branch("weightTrig2012DiMuon", &weightTrig2012DiMuon,"weightTrig2012DiMuon/F");
1423     _outTree->Branch("weightTrig2012DiEle", &weightTrig2012DiEle,"weightTrig2012DiEle/F");
1424     _outTree->Branch("weightTrig2012SingleMuon", &weightTrig2012SingleMuon,"weightTrig2012SingleMuon/F");
1425     _outTree->Branch("weightTrig2012SingleEle", &weightTrig2012SingleEle,"weightTrig2012SingleEle/F");
1426     _outTree->Branch("weightTrig2012MuonPlusWCandPt", &weightTrig2012MuonPlusWCandPt,"weightTrig2012MuonPlusWCandPt/F");
1427    
1428    
1429     _outTree->Branch("weightTrig2012AB", &weightTrig2012AB,"weightTrig2012AB/F");
1430     _outTree->Branch("weightTrig2012ABDiMuon", &weightTrig2012ABDiMuon,"weightTrig2012ABDiMuon/F");
1431     _outTree->Branch("weightTrig2012ABDiEle", &weightTrig2012ABDiEle,"weightTrig2012ABDiEle/F");
1432     _outTree->Branch("weightTrig2012ABSingleMuon", &weightTrig2012ABSingleMuon,"weightTrig2012ABSingleMuon/F");
1433     _outTree->Branch("weightTrig2012ABSingleEle", &weightTrig2012ABSingleEle,"weightTrig2012ABSingleEle/F");
1434     _outTree->Branch("weightTrig2012ABMuonPlusWCandPt", &weightTrig2012ABMuonPlusWCandPt,"weightTrig2012ABMuonPlusWCandPt/F");
1435    
1436 arizzi 1.92 _outTree->Branch("weightTrig2012DiJet30MHT80", &weightTrig2012DiJet30MHT80,"weightTrig2012DiJet30MHT80/F");
1437     _outTree->Branch("weightTrig2012PFMET150", &weightTrig2012PFMET150,"weightTrig2012PFMET150/F");
1438     _outTree->Branch("weightTrig2012SumpT100MET100", &weightTrig2012SumpT100MET100,"weightTrig2012SumpT100MET100/F");
1439 degrutto 1.108 _outTree->Branch("weightTrig2012APFMET150orDiJetMET", &weightTrig2012APFMET150orDiJetMET,"weightTrig2012APFMET150orDiJetMET/F");
1440     _outTree->Branch("weightTrig2012BPFMET150orDiJetMET", &weightTrig2012BPFMET150orDiJetMET,"weightTrig2012BPFMET150orDiJetMET/F");
1441     _outTree->Branch("weightTrig2012CPFMET150orDiJetMET", &weightTrig2012CPFMET150orDiJetMET,"weightTrig2012CPFMET150orDiJetMET/F");
1442    
1443    
1444 arizzi 1.92
1445 arizzi 1.24
1446 arizzi 1.1 _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
1447 arizzi 1.52 _outTree->Branch("deltaPullAngle2AK7", &deltaPullAngle2AK7 , "deltaPullAngle2AK7/F");
1448 arizzi 1.62 _outTree->Branch("PU0", &PU0 , "PU0/F");
1449     _outTree->Branch("PUm1", &PUm1 , "PUm1/F");
1450     _outTree->Branch("PUp1", &PUp1 , "PUp1/F");
1451 arizzi 1.1 _outTree->Branch("PUweight", &PUweight , "PUweight/F");
1452 arizzi 1.110 _outTree->Branch("PUweightP", &PUweightP , "PUweightP/F");
1453     _outTree->Branch("PUweightM", &PUweightM , "PUweightM/F");
1454 arizzi 1.111 _outTree->Branch("PUweightAB", &PUweightAB , "PUweightAB/F");
1455 degrutto 1.54 _outTree->Branch("PUweight2011B", &PUweight2011B , "PUweight2011B/F");
1456 arizzi 1.89 _outTree->Branch("PUweight1DObs", &PUweight1DObs , "PUweight1DObs/F");
1457 arizzi 1.3 _outTree->Branch("eventFlav", &eventFlav , "eventFlav/I");
1458 arizzi 1.1
1459    
1460    
1461    
1462     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
1463 arizzi 1.120 _outTree->Branch("VtypeWithTau" , &VtypeWithTau , "VtypeWithTau/I" );
1464 arizzi 1.1 _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
1465 arizzi 1.41 _outTree->Branch("HVMass" , &HVMass , "HVMass/F" );
1466 arizzi 1.19 _outTree->Branch("HMETdPhi" , &HMETdPhi , "HMETdPhi/F" );
1467 arizzi 1.1 _outTree->Branch("VMt" , &VMt , "VMt/F" );
1468    
1469 arizzi 1.9 _outTree->Branch("nvlep" , &nvlep , "nvlep/I");
1470 msegala 1.124 _outTree->Branch("nvlepTau" , &nvlepTau , "nvlepTau/I");
1471 arizzi 1.9 _outTree->Branch("nalep" , &nalep , "nalep/I");
1472 arizzi 1.3
1473 arizzi 1.9 _outTree->Branch("vLepton_mass",vLeptons.mass ,"mass[nvlep]/F");
1474     _outTree->Branch("vLepton_pt",vLeptons.pt ,"pt[nvlep]/F");
1475     _outTree->Branch("vLepton_eta",vLeptons.eta ,"eta[nvlep]");
1476     _outTree->Branch("vLepton_phi",vLeptons.phi ,"phi[nvlep]/F");
1477     _outTree->Branch("vLepton_aodCombRelIso",vLeptons.aodCombRelIso ,"aodCombRelIso[nvlep]/F");
1478     _outTree->Branch("vLepton_pfCombRelIso",vLeptons.pfCombRelIso ,"pfCombRelIso[nvlep]/F");
1479     _outTree->Branch("vLepton_photonIso",vLeptons.photonIso ,"photonIso[nvlep]/F");
1480     _outTree->Branch("vLepton_neutralHadIso",vLeptons.neutralHadIso ,"neutralHadIso[nvlep]/F");
1481     _outTree->Branch("vLepton_chargedHadIso",vLeptons.chargedHadIso ,"chargedHadIso[nvlep]/F");
1482 dlopes 1.55 _outTree->Branch("vLepton_chargedPUIso",vLeptons.chargedPUIso ,"chargedPUIso[nvlep]/F");
1483 arizzi 1.9 _outTree->Branch("vLepton_particleIso",vLeptons.particleIso ,"particleIso[nvlep]/F");
1484     _outTree->Branch("vLepton_dxy",vLeptons.dxy ,"dxy[nvlep]/F");
1485     _outTree->Branch("vLepton_dz",vLeptons.dz ,"dz[nvlep]/F");
1486     _outTree->Branch("vLepton_type",vLeptons.type ,"type[nvlep]/I");
1487 arizzi 1.27 _outTree->Branch("vLepton_id80",vLeptons.id80 ,"id80[nvlep]/F");
1488     _outTree->Branch("vLepton_id95",vLeptons.id95 ,"id95[nvlep]/F");
1489 arizzi 1.48 _outTree->Branch("vLepton_vbtf",vLeptons.vbtf ,"vbtf[nvlep]/F");
1490 arizzi 1.64 _outTree->Branch("vLepton_id80NoIso",vLeptons.id80NoIso ,"id80NoIso[nvlep]/F");
1491     _outTree->Branch("vLepton_genPt",vLeptons.genPt ,"genPt[nvlep]/F");
1492     _outTree->Branch("vLepton_genEta",vLeptons.genEta ,"genEta[nvlep]");
1493     _outTree->Branch("vLepton_genPhi",vLeptons.genPhi ,"genPhi[nvlep]/F");
1494 degrutto 1.69 _outTree->Branch("vLepton_charge",vLeptons.charge ,"charge[nvlep]/F");
1495 arizzi 1.82 _outTree->Branch("vLepton_pfCorrIso",vLeptons.pfCorrIso,"pfCorrIso[nvlep]/F");
1496 arizzi 1.121 _outTree->Branch("vLepton_pfCorrIsoHCP",vLeptons.pfCorrIsoHCP,"pfCorrIsoHCP[nvlep]/F");
1497 arizzi 1.82 _outTree->Branch("vLepton_id2012tight",vLeptons.id2012tight,"id2012tight[nvlep]/F");
1498     _outTree->Branch("vLepton_idMVAnotrig",vLeptons.idMVAnotrig,"idMVAnotrig[nvlep]/F");
1499     _outTree->Branch("vLepton_idMVAtrig",vLeptons.idMVAtrig,"idMVAtrig[nvlep]/F");
1500 arizzi 1.95 _outTree->Branch("vLepton_idMVApresel",vLeptons.idMVApresel,"idMVApresel[nvlep]/F");
1501 arizzi 1.87 _outTree->Branch("vLepton_innerHits",vLeptons.innerHits,"innerHits[nvlep]/F");
1502     _outTree->Branch("vLepton_photonIsoDoubleCount",vLeptons.photonIsoDoubleCount,"photonIsoDoubleCount[nvlep]/F");
1503 arizzi 1.92 _outTree->Branch("vLepton_wpHWW",vLeptons.wpHWW,"wpHWW[nvlep]/F");
1504 arizzi 1.87 _outTree->Branch("vLepton_wp95",vLeptons.wp95,"wp95[nvlep]/F");
1505     _outTree->Branch("vLepton_wp90",vLeptons.wp90,"wp90[nvlep]/F");
1506     _outTree->Branch("vLepton_wp85",vLeptons.wp85,"wp85[nvlep]/F");
1507     _outTree->Branch("vLepton_wp80",vLeptons.wp80,"wp80[nvlep]/F");
1508     _outTree->Branch("vLepton_wp70",vLeptons.wp70,"wp70[nvlep]/F");
1509    
1510 msegala 1.124 // Adding variables for tau leptons
1511 msegala 1.130 _outTree->Branch("vLeptonTaus_mass",vLeptonsTaus.mass ,"mass[nvlepTau]/F");
1512     _outTree->Branch("vLeptonTaus_pt",vLeptonsTaus.pt ,"pt[nvlepTau]/F");
1513     _outTree->Branch("vLeptonTaus_eta",vLeptonsTaus.eta ,"eta[nvlepTau]");
1514     _outTree->Branch("vLeptonTaus_phi",vLeptonsTaus.phi ,"phi[nvlepTau]/F");
1515     _outTree->Branch("vLeptonTaus_pfCombRelIso",vLeptonsTaus.pfCombRelIso ,"pfCombRelIso[nvlepTau]/F");
1516     _outTree->Branch("vLeptonTaus_genPt",vLeptonsTaus.genPt ,"genPt[nvlepTau]/F");
1517     _outTree->Branch("vLeptonTaus_genEta",vLeptonsTaus.genEta ,"genEta[nvlepTau]");
1518     _outTree->Branch("vLeptonTaus_genPhi",vLeptonsTaus.genPhi ,"genPhi[nvlepTau]/F");
1519     _outTree->Branch("vLeptonTaus_charge",vLeptonsTaus.charge ,"charge[nvlepTau]/F");
1520 msegala 1.124 _outTree->Branch("vLeptonTaus_decayModeFinding",vLeptonsTaus.decayModeFinding,"decayModeFinding[nvlepTau]/F");
1521     _outTree->Branch("vLeptonTaus_byLooseCombinedIsolationDeltaBetaCorr",vLeptonsTaus.byLooseCombinedIsolationDeltaBetaCorr,"byLooseCombinedIsolationDeltaBetaCorr[nvlepTau]/F");
1522     _outTree->Branch("vLeptonTaus_againstMuonTight",vLeptonsTaus.againstMuonTight,"againstMuonTight[nvlepTau]/F");
1523     _outTree->Branch("vLeptonTaus_againstElectronLoose",vLeptonsTaus.againstElectronLoose,"againstElectronLoose[nvlepTau]/F");
1524     _outTree->Branch("vLeptonTaus_againstElectronMedium",vLeptonsTaus.againstElectronMedium,"againstElectronMedium[nvlepTau]/F");
1525     _outTree->Branch("vLeptonTaus_againstElectronMVA",vLeptonsTaus.againstElectronMVA,"againstElectronMVA[nvlepTau]/F");
1526     _outTree->Branch("vLeptonTaus_NsignalPFChargedHadrCands",vLeptonsTaus.NsignalPFChargedHadrCands,"NsignalPFChargedHadrCands[nvlepTau]/I");
1527     _outTree->Branch("vLeptonTaus_NsignalPFGammaCands",vLeptonsTaus.NsignalPFGammaCands,"NsignalPFGammaCands[nvlepTau]/I");
1528     _outTree->Branch("vLeptonTaus_leadPFChargedHadrCandPt",vLeptonsTaus.leadPFChargedHadrCandPt,"leadPFChargedHadrCandPt[nvlepTau]/F");
1529     _outTree->Branch("vLeptonTaus_byLooseIsolation",vLeptonsTaus.byLooseIsolation,"byLooseIsolation[nvlepTau]/F");
1530     _outTree->Branch("vLeptonTaus_byMediumIsolation",vLeptonsTaus.byMediumIsolation,"byMediumIsolation[nvlepTau]/F");
1531     _outTree->Branch("vLeptonTaus_byTightIsolation",vLeptonsTaus.byTightIsolation,"byTightIsolation[nvlepTau]/F");
1532     _outTree->Branch("vLeptonTaus_byLooseCombinedIsolationDeltaBetaCorr3Hits",vLeptonsTaus.byLooseCombinedIsolationDeltaBetaCorr3Hits,"byLooseCombinedIsolationDeltaBetaCorr3Hits[nvlepTau]/F");
1533     _outTree->Branch("vLeptonTaus_byMediumCombinedIsolationDeltaBetaCorr3Hits",vLeptonsTaus.byMediumCombinedIsolationDeltaBetaCorr3Hits,"byMediumCombinedIsolationDeltaBetaCorr3Hits[nvlepTau]/F");
1534     _outTree->Branch("vLeptonTaus_byTightCombinedIsolationDeltaBetaCorr3Hits",vLeptonsTaus.byTightCombinedIsolationDeltaBetaCorr3Hits,"byTightCombinedIsolationDeltaBetaCorr3Hits[nvlepTau]/F");
1535     _outTree->Branch("vLeptonTaus_againstElectronMVA3raw",vLeptonsTaus.againstElectronMVA3raw,"againstElectronMVA3raw[nvlepTau]/F");
1536     _outTree->Branch("vLeptonTaus_againstElectronMVA3category",vLeptonsTaus.againstElectronMVA3category,"againstElectronMVA3category[nvlepTau]/F");
1537     _outTree->Branch("vLeptonTaus_againstElectronLooseMVA3",vLeptonsTaus.againstElectronLooseMVA3,"againstElectronLooseMVA3[nvlepTau]/F");
1538     _outTree->Branch("vLeptonTaus_againstElectronMediumMVA3",vLeptonsTaus.againstElectronMediumMVA3,"againstElectronMediumMVA3[nvlepTau]/F");
1539     _outTree->Branch("vLeptonTaus_againstElectronTightMVA3",vLeptonsTaus.againstElectronTightMVA3,"againstElectronTightMVA3[nvlepTau]/F");
1540     _outTree->Branch("vLeptonTaus_againstElectronVTightMVA3",vLeptonsTaus.againstElectronVTightMVA3,"againstElectronVTightMVA3[nvlepTau]/F");
1541     _outTree->Branch("vLeptonTaus_againstElectronDeadECAL",vLeptonsTaus.againstElectronDeadECAL,"againstElectronDeadECAL[nvlepTau]/F");
1542     _outTree->Branch("vLeptonTaus_byLooseIsolationMVA",vLeptonsTaus.byLooseIsolationMVA,"byLooseIsolationMVA[nvlepTau]/F");
1543     _outTree->Branch("vLeptonTaus_byMediumIsolationMVA",vLeptonsTaus.byMediumIsolationMVA,"byMediumIsolationMVA[nvlepTau]/F");
1544     _outTree->Branch("vLeptonTaus_byTightIsolationMVA",vLeptonsTaus.byTightIsolationMVA,"byTightIsolationMVA[nvlepTau]/F");
1545     _outTree->Branch("vLeptonTaus_byLooseIsolationMVA2",vLeptonsTaus.byLooseIsolationMVA2,"byLooseIsolationMVA2[nvlepTau]/F");
1546     _outTree->Branch("vLeptonTaus_byMediumIsolationMVA2",vLeptonsTaus.byMediumIsolationMVA2,"byMediumIsolationMVA2[nvlepTau]/F");
1547     _outTree->Branch("vLeptonTaus_byTightIsolationMVA2",vLeptonsTaus.byTightIsolationMVA2,"byTightIsolationMVA2[nvlepTau]/F");
1548     _outTree->Branch("vLeptonTaus_againstMuonLoose2",vLeptonsTaus.againstMuonLoose2,"againstMuonLoose2[nvlepTau]/F");
1549     _outTree->Branch("vLeptonTaus_againstMuonMedium2",vLeptonsTaus.againstMuonMedium2,"againstMuonMedium2[nvlepTau]/F");
1550     _outTree->Branch("vLeptonTaus_againstMuonTight2",vLeptonsTaus.againstMuonTight2,"againstMuonTight2[nvlepTau]/F");
1551    
1552 msegala 1.130
1553 msegala 1.124 _outTree->Branch("aJet_selectedTauDR",aJets.selectedTauDR ,"selectedTauDR[naJets]/F");
1554     _outTree->Branch("tauPlusMode" , &tauPlusMode , "tauPlusMode/I");
1555     _outTree->Branch("tauMinusMode" , &tauMinusMode , "tauMinusMode/I");
1556    
1557    
1558 arizzi 1.9 _outTree->Branch("aLepton_mass",aLeptons.mass ,"mass[nalep]/F");
1559     _outTree->Branch("aLepton_pt",aLeptons.pt ,"pt[nalep]/F");
1560     _outTree->Branch("aLepton_eta",aLeptons.eta ,"eta[nalep]");
1561     _outTree->Branch("aLepton_phi",aLeptons.phi ,"phi[nalep]/F");
1562     _outTree->Branch("aLepton_aodCombRelIso",aLeptons.aodCombRelIso ,"aodCombRelIso[nalep]/F");
1563     _outTree->Branch("aLepton_pfCombRelIso",aLeptons.pfCombRelIso ,"pfCombRelIso[nalep]/F");
1564     _outTree->Branch("aLepton_photonIso",aLeptons.photonIso ,"photonIso[nalep]/F");
1565     _outTree->Branch("aLepton_neutralHadIso",aLeptons.neutralHadIso ,"neutralHadIso[nalep]/F");
1566     _outTree->Branch("aLepton_chargedHadIso",aLeptons.chargedHadIso ,"chargedHadIso[nalep]/F");
1567 dlopes 1.55 _outTree->Branch("aLepton_chargedPUIso",aLeptons.chargedPUIso ,"chargedPUIso[nalep]/F");
1568 arizzi 1.9 _outTree->Branch("aLepton_particleIso",aLeptons.particleIso ,"particleIso[nalep]/F");
1569     _outTree->Branch("aLepton_dxy",aLeptons.dxy ,"dxy[nalep]/F");
1570     _outTree->Branch("aLepton_dz",aLeptons.dz ,"dz[nalep]/F");
1571     _outTree->Branch("aLepton_type",aLeptons.type ,"type[nalep]/I");
1572 arizzi 1.48 _outTree->Branch("aLepton_id80",aLeptons.id80 ,"id80[nalep]/F");
1573     _outTree->Branch("aLepton_id95",aLeptons.id95 ,"id95[nalep]/F");
1574     _outTree->Branch("aLepton_vbtf",aLeptons.vbtf ,"vbtf[nalep]/F");
1575 arizzi 1.64 _outTree->Branch("aLepton_id80NoIso",aLeptons.id80NoIso ,"id80NoIso[nalep]/F");
1576     _outTree->Branch("aLepton_genPt",aLeptons.genPt ,"genPt[nalep]/F");
1577     _outTree->Branch("aLepton_genEta",aLeptons.genEta ,"genEta[nalep]");
1578     _outTree->Branch("aLepton_genPhi",aLeptons.genPhi ,"genPhi[nalep]/F");
1579 degrutto 1.69 _outTree->Branch("aLepton_charge",aLeptons.charge ,"charge[nalep]/F");
1580 arizzi 1.83 _outTree->Branch("aLepton_pfCorrIso",aLeptons.pfCorrIso,"pfCorrIso[nalep]/F");
1581 arizzi 1.121 _outTree->Branch("aLepton_pfCorrIsoHCP",aLeptons.pfCorrIsoHCP,"pfCorrIsoHCP[nalep]/F");
1582 arizzi 1.83 _outTree->Branch("aLepton_id2012tight",aLeptons.id2012tight,"id2012tight[nalep]/F");
1583     _outTree->Branch("aLepton_idMVAnotrig",aLeptons.idMVAnotrig,"idMVAnotrig[nalep]/F");
1584     _outTree->Branch("aLepton_idMVAtrig",aLeptons.idMVAtrig,"idMVAtrig[nalep]/F");
1585 arizzi 1.95 _outTree->Branch("aLepton_idMVApresel",aLeptons.idMVApresel,"idMVApresel[nalep]/F");
1586 arizzi 1.87 _outTree->Branch("aLepton_innerHits",aLeptons.innerHits,"innerHits[nalep]/F");
1587     _outTree->Branch("aLepton_photonIsoDoubleCount",aLeptons.photonIsoDoubleCount,"photonIsoDoubleCount[nalep]/F");
1588 arizzi 1.92 _outTree->Branch("aLepton_wpHWW",aLeptons.wpHWW,"wpHWW[nalep]/F");
1589 arizzi 1.87 _outTree->Branch("aLepton_wp95",aLeptons.wp95,"wp95[nalep]/F");
1590     _outTree->Branch("aLepton_wp90",aLeptons.wp90,"wp90[nalep]/F");
1591     _outTree->Branch("aLepton_wp85",aLeptons.wp85,"wp85[nalep]/F");
1592     _outTree->Branch("aLepton_wp80",aLeptons.wp80,"wp80[nalep]/F");
1593     _outTree->Branch("aLepton_wp70",aLeptons.wp70,"wp70[nalep]/F");
1594    
1595 degrutto 1.69
1596 arizzi 1.8 _outTree->Branch("top" , &top , "mass/F:pt/F:wMass/F");
1597 arizzi 1.49 _outTree->Branch("WplusMode" , &WplusMode , "WplusMode/I");
1598     _outTree->Branch("WminusMode" , &WminusMode , "WminusMode/I");
1599 arizzi 1.1
1600 bortigno 1.30 //IVF
1601     _outTree->Branch("nSvs",&nSvs ,"nSvs/I");
1602 arizzi 1.33 _outTree->Branch("Sv_massBCand", &IVF.massBcand,"massBcand[nSvs]/F");
1603     _outTree->Branch("Sv_massSv", &IVF.massSv,"massSv[nSvs]/F");
1604     _outTree->Branch("Sv_pt", &IVF.pt,"pt[nSvs]/F");
1605     _outTree->Branch("Sv_eta", &IVF.eta,"eta[nSvs]/F");
1606     _outTree->Branch("Sv_phi", &IVF.phi,"phi[nSvs]/F");
1607     _outTree->Branch("Sv_dist3D", &IVF.dist3D,"dist3D[nSvs]/F");
1608     _outTree->Branch("Sv_dist2D", &IVF.dist2D,"dist2D[nSvs]/F");
1609     _outTree->Branch("Sv_distSim2D", &IVF.distSig2D,"distSig2D[nSvs]/F");
1610     _outTree->Branch("Sv_distSig3D", &IVF.distSig3D,"distSig3D[nSvs]/F");
1611     _outTree->Branch("Sv_dist3D_norm", &IVF.dist3D_norm,"dist3D_norm[nSvs]/F");
1612 bortigno 1.30 //IVF higgs candidate
1613 arizzi 1.33 _outTree->Branch("SVH" , &SVH , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
1614 bortigno 1.30
1615 dlopes 1.73
1616 bortigno 1.74
1617 bortigno 1.30 // //SimBHadron
1618 bortigno 1.74 _outTree->Branch("nSimBs",&nSimBs ,"nSimBs/I");
1619     _outTree->Branch("SimBs_mass", &SimBs.mass,"mass[nSimBs]/F");
1620     _outTree->Branch("SimBs_pt", &SimBs.pt,"pt[nSimBs]/F");
1621     _outTree->Branch("SimBs_eta", &SimBs.eta,"eta[nSimBs]/F");
1622     _outTree->Branch("SimBs_phi", &SimBs.phi,"phi[nSimBs]/F");
1623     _outTree->Branch("SimBs_vtx_x", &SimBs.vtx_x,"vtx_x[nSimBs]/F");
1624     _outTree->Branch("SimBs_vtx_y", &SimBs.vtx_y,"vtx_y[nSimBs]/F");
1625     _outTree->Branch("SimBs_vtx_z", &SimBs.vtx_z,"vtx_z[nSimBs]/F");
1626     _outTree->Branch("SimBs_pdgId", &SimBs.pdgId,"pdgId[nSimBs]/F");
1627     _outTree->Branch("SimBs_status", &SimBs.status,"status[nSimBs]/F");
1628     //SimBHadron Higgs Candidate
1629     _outTree->Branch("SimBsH" , &SimBsH , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
1630 bortigno 1.30
1631 arizzi 1.36 _outTree->Branch("rho" , &rho , "rho/F");
1632     _outTree->Branch("rho25" , &rho25 , "rho25/F");
1633 arizzi 1.82 _outTree->Branch("rhoN" , &rhoN , "rhoN/F");
1634 arizzi 1.36 _outTree->Branch("nPVs" , &nPVs , "nPVs/I");
1635     _outTree->Branch("METnoPU" , &METnoPU , "et/F:sumet:sig/F:phi/F");
1636 arizzi 1.58 _outTree->Branch("METnoPUCh" , &METnoPUCh , "et/F:sumet:sig/F:phi/F");
1637 arizzi 1.1 _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
1638 degrutto 1.69 _outTree->Branch("METtype1corr" , &METtype1corr , "et/F:sumet:sig/F:phi/F");
1639     _outTree->Branch("METtype1p2corr" , &METtype1p2corr , "et/F:sumet:sig/F:phi/F");
1640     _outTree->Branch("METnoPUtype1corr" , &METnoPUtype1corr , "et/F:sumet:sig/F:phi/F");
1641     _outTree->Branch("METnoPUtype1p2corr" , &METnoPUtype1p2corr , "et/F:sumet:sig/F:phi/F");
1642 jiafulow 1.114 _outTree->Branch("METtype1diff" , &METtype1diff , "et/F:sumet:sig/F:phi/F");
1643 degrutto 1.69
1644     _outTree->Branch("metUnc_et",&metUnc.et ,"et[24]/F");
1645     _outTree->Branch("metUnc_phi",&metUnc.phi ,"phi[24]/F");
1646     _outTree->Branch("metUnc_sumet",&metUnc.sumet ,"sumet[24]/F");
1647    
1648    
1649    
1650 arizzi 1.52 _outTree->Branch("fakeMET" , &fakeMET , "et/F:sumet:sig/F:phi/F");
1651 arizzi 1.1 _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
1652     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
1653     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
1654    
1655 bortigno 1.30 std::stringstream s;
1656     s << "triggerFlags[" << triggers.size() << "]/b";
1657     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
1658 arizzi 1.17
1659 bortigno 1.30 _outTree->Branch("EVENT" , &EVENT , "run/I:lumi/I:event/I:json/I");
1660     _outTree->Branch("hbhe" , &hbhe , "hbhe/b");
1661 arizzi 1.63 _outTree->Branch("totalKinematics" , &totalKinematics , "totalKinematics/b");
1662 arizzi 1.56 _outTree->Branch("ecalFlag" , &ecalFlag , "ecalFlag/b");
1663 degrutto 1.69 _outTree->Branch("cschaloFlag" , &cschaloFlag , "cschaloFlag/b");
1664     _outTree->Branch("hcallaserFlag" , &hcallaserFlag , "hcallaserFlag/b");
1665     _outTree->Branch("trackingfailureFlag" , &trackingfailureFlag , "trackingfailureFlag/b");
1666 degrutto 1.104 _outTree->Branch("eebadscFlag" , &eebadscFlag , "eebadscFlag/b");
1667 bortigno 1.30 _outTree->Branch("btag1TSF" , &btag1TSF , "btag1TSF/F");
1668     _outTree->Branch("btag2TSF" , &btag2TSF , "btag2TSF/F");
1669     _outTree->Branch("btag1T2CSF" , &btag1T2CSF , "btag1T2CSF/F");
1670 arizzi 1.44 _outTree->Branch("btag2CSF" , &btag2CSF , "btag2CSF/F");
1671     _outTree->Branch("btagA0CSF" , &btagA0CSF , "btagA0CSF/F");
1672 arizzi 1.60 _outTree->Branch("btagA0TSF" , &btagA0TSF , "btagA0TSF/F");
1673 arizzi 1.51 _outTree->Branch("btag1TA1C" , &btag1TA1C , "btag1TA1C/F");
1674 arizzi 1.1
1675 bortigno 1.30 int ievt=0;
1676     int totalcount=0;
1677 cboeser 1.107
1678 bortigno 1.30 // TFile* inFile = new TFile(inputFile.c_str(), "read");
1679 arizzi 1.1 for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
1680     std::cout << iFile << std::endl;
1681     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
1682 arizzi 1.85 if(inFile==0) { std::cout << "FAILED " << inputFiles_[iFile] << std::endl; continue; }
1683 arizzi 1.1
1684 bortigno 1.30 // loop the events
1685 arizzi 1.1
1686     fwlite::Event ev(inFile);
1687 arizzi 1.80 fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
1688 nmohr 1.29 for(ev.toBegin(); !ev.atEnd() ; ++ev, ++ievt)
1689 arizzi 1.1 {
1690 nmohr 1.29 if (ievt <= skipEvents_) continue;
1691     if (maxEvents_ >= 0){
1692     if (ievt > maxEvents_ + skipEvents_) break;
1693 arizzi 1.80 }
1694     const char * lab = "HbbAnalyzerNew";
1695     vhbbAuxHandle.getByLabel(ev,lab,0,0);
1696 arizzi 1.25 const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
1697 arizzi 1.84 EVENT.run = ev.id().run();
1698     EVENT.lumi = ev.id().luminosityBlock();
1699     EVENT.event = ev.id().event();
1700     EVENT.json = jsonContainsEvent (jsonVector, ev);
1701 arizzi 1.119 isBadHcalEvent = std::binary_search (badEvents.begin(), badEvents.end(), RLE( EVENT.run,EVENT.lumi,EVENT.event),evcomp);
1702 arizzi 1.115 weightMCProd = aux.weightMCProd;
1703 arizzi 1.125 weightSignalQCD=1.;
1704     weightSignalEWK=1.;
1705 arizzi 1.64
1706     if(EVENT.run < runMin_ && runMin_ > 0) continue;
1707     if(EVENT.run > runMax_ && runMax_ > 0) continue;
1708    
1709     count->Fill(1.);
1710 sdas 1.132
1711     // Fill the ntuples with H(bb)H(bb) generator level information
1712     if (isMC_)
1713     {
1714     fwlite::Handle <reco::GenParticleCollection> genParticlesHandle;
1715     genParticlesHandle.getByLabel(ev, "savedGenParticles");
1716     const reco::GenParticleCollection *genParticles=&(*genParticlesHandle.product());
1717    
1718     for (size_t i=0; i<genParticles->size(); ++i)
1719     {
1720     const reco::GenParticle *p=&((*genParticles).at(i));
1721     int id=p->pdgId();
1722     int st=p->status();
1723     if (abs(id)==35 && st==3) // H0
1724     {
1725     genX=returnGenParticleInfo(p);
1726    
1727     const reco::Candidate *H1_cand=p->daughter(0);
1728     if (H1_cand->pdgId()==25)
1729     {
1730     genH1=returnGenParticleInfo(H1_cand);
1731     const reco::Candidate *H1B_cand=H1_cand->daughter(0);
1732     if (H1B_cand->pdgId()==5)
1733     {
1734     genH1B=returnGenParticleInfo(H1B_cand);
1735     }
1736     else std::cout<<"ERROR: First h0's first daughter is not a b!"<<std::endl;
1737     const reco::Candidate *H1Bbar_cand=H1_cand->daughter(1);
1738     if (H1Bbar_cand->pdgId()==-5)
1739     {
1740     genH1Bbar=returnGenParticleInfo(H1Bbar_cand);
1741     }
1742     else std::cout<<"ERROR: First h0's second daughter is not a bbar!"<<std::endl;
1743     }
1744     else std::cout<<"ERROR: H0's first daughter is not an h0!"<<std::endl;
1745     const reco::Candidate *H2_cand=p->daughter(1);
1746     if (H2_cand->pdgId()==25)
1747     {
1748     genH2=returnGenParticleInfo(H2_cand);
1749     const reco::Candidate *H2B_cand=H2_cand->daughter(0);
1750     if (H2B_cand->pdgId()==5)
1751     {
1752     genH2B=returnGenParticleInfo(H2B_cand);
1753     }
1754     else std::cout<<"ERROR: Second h0's first daughter is not a b!"<<std::endl;
1755     const reco::Candidate *H2Bbar_cand=H2_cand->daughter(1);
1756     if (H2Bbar_cand->pdgId()==-5)
1757     {
1758     genH2Bbar=returnGenParticleInfo(H2Bbar_cand);
1759     }
1760     else std::cout<<"ERROR: Second h0's second daughter is not a bbar!"<<std::endl;
1761     } else std::cout<<"ERROR: H0's second daughter is not an h0!"<<std::endl;
1762     }
1763     }
1764     }
1765 degrutto 1.69
1766 arizzi 1.88 /*
1767     Handle<std::vector< PileupSummaryInfo > > PupInfo;
1768     event.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
1769     std::vector<PileupSummaryInfo>::const_iterator PVI;
1770     float Tnpv = -1;
1771     for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
1772     int BX = PVI->getBunchCrossing();
1773     if(BX == 0) {
1774     Tnpv = PVI->getTrueNumInteractions();
1775     continue;
1776     }
1777 degrutto 1.69
1778 arizzi 1.88 }
1779     double MyWeight = LumiWeights_.weight( Tnpv );
1780     double MyWeight = LumiWeights_.weight( (*iEventB) );
1781     */
1782 degrutto 1.69
1783    
1784 arizzi 1.25 PUweight=1.;
1785 arizzi 1.110 PUweightP=1.;
1786     PUweightM=1.;
1787 arizzi 1.111 PUweightAB=1.;
1788 degrutto 1.54 PUweight2011B=1.;
1789 arizzi 1.89 PUweight1DObs=1.;
1790 arizzi 1.125 weightSignalQCD=1;
1791 arizzi 1.1 if(isMC_){
1792 arizzi 1.41
1793 degrutto 1.54 // PU weights // Run2011A
1794 bortigno 1.30 std::map<int, unsigned int>::const_iterator puit = aux.puInfo.pus.find(0);
1795 arizzi 1.64 int npu =puit->second ;
1796 arizzi 1.89 PUweight = lumiWeights.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1797 arizzi 1.110 PUweightP = lumiWeightsPl.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1798     PUweightM = lumiWeightsMi.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1799 arizzi 1.111 PUweightAB = lumiWeightsAB.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1800 arizzi 1.41 pu->Fill(puit->second);
1801 degrutto 1.54 // PU weight Run2011B
1802     // PU weight Run2011B
1803     std::map<int, unsigned int>::const_iterator puit0 = aux.puInfo.pus.find(0);
1804     std::map<int, unsigned int>::const_iterator puitm1 = aux.puInfo.pus.find(-1);
1805     std::map<int, unsigned int>::const_iterator puitp1 = aux.puInfo.pus.find(+1);
1806 arizzi 1.62 PU0=puit0->second;
1807     PUp1=puitp1->second;
1808     PUm1=puitm1->second;
1809     input3DPU->Fill(PUm1,PU0,PUp1);
1810 arizzi 1.103 // PUweight2011B = lumiWeights2011B.weight3D( puitm1->second, puit0->second,puitp1->second);
1811 arizzi 1.89 PUweight1DObs = lumiWeights1DObs.weight( npu);
1812 bortigno 1.30 }
1813 arizzi 1.49 countWithPU->Fill(1,PUweight);
1814 arizzi 1.110 countWithPUP->Fill(1,PUweightP);
1815     countWithPUM->Fill(1,PUweightM);
1816 arizzi 1.111 countWithPUAB->Fill(1,PUweightAB);
1817 arizzi 1.58 countWithPU2011B->Fill(1,PUweight2011B);
1818 arizzi 1.118 coutnWithMCProd->Fill(1,weightMCProd);
1819     countWithPUMCProd->Fill(1,weightMCProd*PUweight);
1820 bortigno 1.75 //LHE Infos
1821     fwlite::Handle<LHEEventProduct> evt;
1822 bortigno 1.79
1823     // std::cout << "Label for lhe = " << evt.getBranchNameFor(ev,"source") << std::endl;
1824 bortigno 1.77 if( !((evt.getBranchNameFor(ev,"source")).empty()) ){
1825     evt.getByLabel(ev,"source");
1826 bortigno 1.79 //std::cout << "LHEEventProduct found!" << std::endl;
1827 bortigno 1.77 bool lCheck=false;
1828     bool lbarCheck=false;
1829     bool vlCheck=false;
1830     bool vlbarCheck=false;
1831 bortigno 1.79 int idl, idlbar;
1832 bortigno 1.91 lheHT=0.;
1833     lheNj=0;
1834 bortigno 1.77 TLorentzVector l,lbar,vl,vlbar,V_tlv;
1835 bortigno 1.75 const lhef::HEPEUP hepeup_ = evt->hepeup();
1836 bortigno 1.79 const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP; // px, py, pz, E, M
1837 arizzi 1.123
1838     //################# PDF CODE ##################
1839    
1840    
1841     //############# PDF reweighting ##################
1842     //change it if you want to rescale the energy
1843     double _newECMS = 8000; // energy in GeV
1844     double _origECMS = 8000; // energy in GeV
1845     float Q = hepeup_.SCALUP;
1846     int id1 = hepeup_.IDUP[0];
1847     double x1 = fabs(hepeup_.PUP[0][2]/(_origECMS/2));
1848     double x1prime = fabs(hepeup_.PUP[0][2]/(_newECMS/2));
1849     int id2 = hepeup_.IDUP[1];
1850     double x2 = fabs(hepeup_.PUP[1][2]/(_origECMS/2));
1851     double x2prime = fabs(hepeup_.PUP[1][2]/(_newECMS/2));
1852     // gluon is 0 in the LHAPDF numberin
1853     if (id1 == 21)
1854     id1 = 0;
1855     if (id2 == 21)
1856     id2 = 0;
1857     int _pdfmember = 0; //member = 0 is the pdf central value.
1858     //madgrpah default pdf
1859     // LHAPDF::usePDFMember(1,_pdfmember);
1860     double oldpdf1 = LHAPDF::xfx(1, x1, Q, id1)/x1;
1861     double oldpdf2 = LHAPDF::xfx(1, x2, Q, id2)/x2;
1862     double newpdf1=0;
1863     double newpdf2=0;
1864    
1865     newpdf1 = LHAPDF::xfx(1, x1prime, Q, id1)/x1prime;
1866     newpdf2 = LHAPDF::xfx(1, x2prime, Q, id2)/x2prime;
1867     PDFweight[0] = (newpdf1/oldpdf1)*(newpdf2/oldpdf2);
1868    
1869    
1870     //new pdf set
1871     for (unsigned int setpdf=2; setpdf <= pdfNames.size()+1; ++setpdf){
1872    
1873     for(int pdfmember = 0; pdfmember < LHAPDF::numberPDF(setpdf); pdfmember++){
1874    
1875     LHAPDF::usePDFMember(setpdf, pdfmember); //load the right memeber once again to be sure...
1876     newpdf1 = LHAPDF::xfx(setpdf, x1prime, Q, id1)/x1prime;
1877     newpdf2 = LHAPDF::xfx(setpdf, x2prime, Q, id2)/x2prime;
1878     int norm = (setpdf-2)*LHAPDF::numberPDF(setpdf); // normalisation
1879     PDFweight[norm+setpdf-1+pdfmember] = (newpdf1/oldpdf1)*(newpdf2/oldpdf2);
1880    
1881     }
1882    
1883     }
1884    
1885     //############### LHE stitching information ##################
1886    
1887    
1888     //################# END OF PDF CODE ##################
1889 bortigno 1.75 for(unsigned int i=0; i<pup_.size(); ++i){
1890 bortigno 1.79 int id=hepeup_.IDUP[i]; //pdgId
1891 bortigno 1.90 int status = hepeup_.ISTUP[i];
1892 bortigno 1.96 int idabs=TMath::Abs(id);
1893     if( status == 1 && ( ( idabs == 21 ) || (idabs > 0 && idabs < 7) ) ){ // gluons and quarks
1894     lheHT += TMath::Sqrt( TMath::Power(hepeup_.PUP[i][0],2) + TMath::Power(hepeup_.PUP[i][1],2) ); // first entry is px, second py
1895     lheNj++;
1896     }
1897 bortigno 1.90
1898 bortigno 1.75 if(id==11){ l.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lCheck=true;}
1899     if(id==-11){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1900     if(id==12){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1901     if(id==-12){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1902    
1903     if(id==13){ l.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lCheck=true;}
1904     if(id==-13){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1905     if(id==14){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1906     if(id==-14){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1907    
1908     if(id==15){ l.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lCheck=true;}
1909     if(id==-15){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1910     if(id==16){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1911     if(id==-16){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1912    
1913     }
1914 bortigno 1.77 if( lCheck && lbarCheck ) V_tlv = l + lbar; // ZtoLL
1915     if( vlCheck && vlbarCheck ) V_tlv = vl + vlbar; // ZtoNuNu
1916     if( lCheck && vlbarCheck ) V_tlv = l + vlbar; // WToLNu
1917     if( lbarCheck && vlCheck ) V_tlv = lbar + vl; // WToLNu
1918     lheV_pt = V_tlv.Pt();
1919     }
1920 bortigno 1.75
1921 bortigno 1.79 //std::cout << "lhe V pt = " << lheV_pt << std::endl;
1922    
1923 bortigno 1.30 //Write event info
1924 bortigno 1.74
1925     // simBHadrons
1926     const SimBHadronCollection *sbhc;
1927     if(isMC_){
1928     fwlite::Handle<SimBHadronCollection> SBHC;
1929     SBHC.getByLabel(ev, "bhadrons");
1930     sbhc = SBHC.product();
1931     }
1932 bortigno 1.30
1933 jiafulow 1.114 // adapted from PhysicsTools/PatUtils/plugins/PATPFJetMETcorrInputProducer.cc
1934     // To propagate the effect of JEC at Step 2 to METtype1corr
1935     double METtype1diff_mex=0.0, METtype1diff_mey=0.0, METtype1diff_sumet=0.0, METtype1diff_type1JetPtThreshold=10.0, METtype1diff_skipEMfractionThreshold=0.9;
1936    
1937 bortigno 1.30 const std::vector<VHbbCandidate> * candZ ;
1938     const std::vector<VHbbCandidate> * candW ;
1939 arizzi 1.64 VHbbEvent modifiedEvent;;
1940 bortigno 1.30 const VHbbEvent * iEvent =0;
1941     if(fromCandidate)
1942     {
1943     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandleZ;
1944     vhbbCandHandleZ.getByLabel(ev,"hbbBestCSVPt20Candidates");
1945     candZ = vhbbCandHandleZ.product();
1946    
1947     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
1948     vhbbCandHandle.getByLabel(ev,"hbbHighestPtHiggsPt30Candidates");
1949     candW = vhbbCandHandle.product();
1950     }
1951     else
1952     {
1953     candZlocal->clear();
1954     candWlocal->clear();
1955 degrutto 1.86 fwlite::Handle< VHbbEvent > vhbbHandle;
1956 bortigno 1.30 vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
1957 degrutto 1.86 modifiedEvent = *vhbbHandle.product();
1958 arizzi 1.125
1959     if(aux.mcH.size()>0)
1960     {
1961     float pt=aux.mcH[0].p4.Pt();
1962     int nMCJets=0;
1963     if(aux.mcW.size()>1) pt=aux.mcW[1].p4.Pt();
1964     if(aux.mcZ.size()>1) pt=aux.mcZ[1].p4.Pt();
1965     for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
1966     {
1967     //um$(VHbbEvent_HbbAnalyzerNew__VH.obj.simpleJets2.p4.Pt()>20 && abs(VHbbEvent_HbbAnalyzerNew__VH.obj.simpleJets2.p4.Eta() )< 2.5)
1968     if( modifiedEvent.simpleJets2[j].bestMCp4.Pt()>20 && fabs(modifiedEvent.simpleJets2[j].bestMCp4.Eta())<2.5) nMCJets++;
1969     }
1970     weightSignalQCD=weightNNLOQCDsignal(pt,nMCJets);
1971     weightSignalEWK=weightNLOEWKsignal(pt);
1972    
1973     }
1974     countWithSignalQCDcorrections->Fill(1,weightSignalQCD);
1975    
1976 arizzi 1.64 if(isMC_)
1977     {
1978 arizzi 1.115
1979     iEvent= &modifiedEvent;
1980    
1981 arizzi 1.116 for(size_t j=0; j< modifiedEvent.subJets.size() ; j++) modifiedEvent.subJets[j] = jec.correct( modifiedEvent.subJets[j],aux.puInfo.rho,true);
1982     for(size_t j=0; j< modifiedEvent.filterJets.size() ; j++) modifiedEvent.filterJets[j] = jec.correct( modifiedEvent.filterJets[j],aux.puInfo.rho,true);
1983    
1984    
1985 jiafulow 1.114 for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
1986     {
1987     //VHbbEvent::SimpleJet orig=modifiedEvent.simpleJets2[j];
1988     //VHbbEvent::SimpleJet origRemade = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true,true); // do ref check, can be commented out
1989     //VHbbEvent::SimpleJet corr2011 = jec.correctRight( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true,true); // do ref check, can be commented out
1990 arizzi 1.115 if (modifiedEvent.simpleJets2[j].p4.Pt() > METtype1diff_type1JetPtThreshold && (modifiedEvent.simpleJets2[j].chargedEmEFraction+modifiedEvent.simpleJets2[j].neutralEmEFraction) < METtype1diff_skipEMfractionThreshold) {
1991     METtype1diff_mex += modifiedEvent.simpleJets2[j].p4.Px();
1992     METtype1diff_mey += modifiedEvent.simpleJets2[j].p4.Py();
1993     METtype1diff_sumet -= modifiedEvent.simpleJets2[j].p4.Et();
1994     }
1995     modifiedEvent.simpleJets2[j] = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true);
1996 jiafulow 1.114 //std::cout << "Original " << orig.p4.Pt() << " == " << origRemade.p4.Pt() << " using CHS2011 " << corr2011.p4.Pt() << " final: " << modifiedEvent.simpleJets2[j].p4.Pt() << std::endl;
1997 arizzi 1.115 if (modifiedEvent.simpleJets2[j].p4.Pt() > METtype1diff_type1JetPtThreshold && (modifiedEvent.simpleJets2[j].chargedEmEFraction+modifiedEvent.simpleJets2[j].neutralEmEFraction) < METtype1diff_skipEMfractionThreshold) {
1998     METtype1diff_mex -= modifiedEvent.simpleJets2[j].p4.Px();
1999     METtype1diff_mey -= modifiedEvent.simpleJets2[j].p4.Py();
2000     METtype1diff_sumet += modifiedEvent.simpleJets2[j].p4.Et();
2001     }
2002 jiafulow 1.114 TLorentzVector & p4 = modifiedEvent.simpleJets2[j].p4;
2003     TLorentzVector & mcp4 = modifiedEvent.simpleJets2[j].bestMCp4;
2004     if ((fabs(p4.Pt() - mcp4.Pt())/ p4.Pt())<0.5) { //Limit the effect to the core
2005     float cor = (p4.Pt()+resolutionBias(fabs(p4.Eta()))*(p4.Pt()-mcp4.Pt()))/p4.Pt();
2006     p4.SetPtEtaPhiE(p4.Pt()*cor,p4.Eta(), p4.Phi(), p4.E()*cor);
2007     }
2008     }
2009     } else { // for data
2010     //iEvent = vhbbHandle.product();
2011     // modify also the real data now to apply JEC 2012
2012     iEvent= &modifiedEvent;
2013 arizzi 1.116 for(size_t j=0; j< modifiedEvent.subJets.size() ; j++) modifiedEvent.subJets[j] = jec.correct( modifiedEvent.subJets[j],aux.puInfo.rho,false);
2014     for(size_t j=0; j< modifiedEvent.filterJets.size() ; j++) modifiedEvent.filterJets[j] = jec.correct( modifiedEvent.filterJets[j],aux.puInfo.rho,false);
2015 jiafulow 1.114 for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
2016     {
2017     //jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,false,true); // do ref check, can be commented out
2018    
2019 arizzi 1.115 if (modifiedEvent.simpleJets2[j].p4.Pt() > METtype1diff_type1JetPtThreshold && (modifiedEvent.simpleJets2[j].chargedEmEFraction+modifiedEvent.simpleJets2[j].neutralEmEFraction) < METtype1diff_skipEMfractionThreshold) {
2020     METtype1diff_mex += modifiedEvent.simpleJets2[j].p4.Px();
2021     METtype1diff_mey += modifiedEvent.simpleJets2[j].p4.Py();
2022     METtype1diff_sumet -= modifiedEvent.simpleJets2[j].p4.Et();
2023     }
2024     modifiedEvent.simpleJets2[j] = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,false);
2025     if (modifiedEvent.simpleJets2[j].p4.Pt() > METtype1diff_type1JetPtThreshold && (modifiedEvent.simpleJets2[j].chargedEmEFraction+modifiedEvent.simpleJets2[j].neutralEmEFraction) < METtype1diff_skipEMfractionThreshold) {
2026     METtype1diff_mex -= modifiedEvent.simpleJets2[j].p4.Px();
2027     METtype1diff_mey -= modifiedEvent.simpleJets2[j].p4.Py();
2028     METtype1diff_sumet += modifiedEvent.simpleJets2[j].p4.Et();
2029     }
2030 jiafulow 1.114 }
2031 arizzi 1.93
2032 arizzi 1.64 }
2033    
2034 sdas 1.132 algoZ->run(iEvent,*candZlocal,aux, isZbbHbbAnalysis_);
2035 arizzi 1.81 algoW->run(iEvent,*candWlocal,aux);
2036 arizzi 1.64
2037 degrutto 1.86
2038 arizzi 1.64 if(candZlocal->size() == 0 or candZlocal->at(0).H.jets.size() < 2) //recover low pt
2039     {
2040     candZlocal->clear();
2041     candWlocal->clear();
2042 arizzi 1.81 algoRecoverLowPt->run(iEvent,*candZlocal,aux);
2043     algoRecoverLowPt->run(iEvent,*candWlocal,aux);
2044 arizzi 1.64 }
2045    
2046 bortigno 1.30 candZ= candZlocal;
2047     candW= candWlocal;
2048     /* for(size_t m=0;m<iEvent->muInfo.size();m++)
2049     {
2050    
2051     if( fabs(iEvent->muInfo[m].p4.Pt()-28.118684) < 0.0001 ||
2052     fabs(iEvent->muInfo[m].p4.Pt()-34.853199) < 0.0001 )
2053     {
2054     std::cout << "FOUND " << iEvent->muInfo[m].p4.Pt() << " " << EVENT.event << " " << candW->size() << " " << candZ->size() << std::endl;
2055     }
2056     }
2057     */
2058 arizzi 1.4
2059 bortigno 1.30 }
2060 arizzi 1.1
2061 arizzi 1.3 const std::vector<VHbbCandidate> * cand = candZ;
2062 arizzi 1.1
2063    
2064    
2065 bortigno 1.30 /* fwlite::Handle< VHbbEvent > vhbbHandle;
2066     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
2067     const VHbbEvent iEvent = *vhbbHandle.product();
2068     */
2069 arizzi 1.1
2070 bortigno 1.30 // std::clog << "Filling tree "<< std::endl;
2071     bool isW=false;
2072 arizzi 1.21
2073 degrutto 1.69 // to check how much we gain with jets subtraction
2074    
2075    
2076    
2077 msegala 1.124 tauMinusMode = -99;
2078     tauPlusMode = -99;
2079     for(unsigned int j=0; j< aux.mcTau.size();j++)
2080     {
2081     for(unsigned int k=0;k< aux.mcTau[j].dauid.size();k++)
2082     {
2083     if (ana.getParameter<bool>("verbose")) {
2084     std::cout << "(j,k,m_Tau,dauid,pt_dau,momid)=(" << j << "," << k << "," << aux.mcTau[j].p4.M() << "," << aux.mcTau[j].dauid[k] << ","
2085     << aux.mcTau[j].dauFourMomentum[k].Pt() << "," << aux.mcTau[j].momid <<")" << std::endl;
2086     }
2087     int idd=abs(aux.mcTau[j].dauid[k]);
2088     if( idd != 15 && idd!=16 /*(idd==11 || idd==13 )*/)
2089     {
2090     if(tauMinusMode==-99 && aux.mcTau[j].charge ==-1) tauMinusMode = idd;
2091     if(tauPlusMode==-99 && aux.mcTau[j].charge ==+1) tauPlusMode = idd;
2092     }
2093     }
2094     }
2095    
2096 degrutto 1.69 genHpt=aux.mcH.size() > 0 ? aux.mcH[0].p4.Pt():-99;
2097    
2098 arizzi 1.110 // if(cand->size() == 0 or cand->at(0).H.jets.size() < 2) continue;
2099 cboeser 1.107 if(cand->size() == 0 ) continue;
2100 degrutto 1.69 //std::cout << "cand->size() " << cand->size() << std::endl;
2101     //std::cout << "cand->at(0).H.jets.size() " << cand->at(0).H.jets.size() << std::endl;
2102 bortigno 1.30 if(cand->size() > 1 )
2103 arizzi 1.3 {
2104 bortigno 1.30 std::cout << "MULTIPLE CANDIDATES: " << cand->size() << std::endl;
2105 arizzi 1.3 }
2106 bortigno 1.30 if(cand->at(0).candidateType == VHbbCandidate::Wmun || cand->at(0).candidateType == VHbbCandidate::Wen ) { cand=candW; isW=true; }
2107     if(cand->size() == 0)
2108 arizzi 1.3 {
2109 bortigno 1.30 // std::cout << "W event loss due to tigther cuts" << std::endl;
2110 arizzi 1.3 continue;
2111     }
2112 arizzi 1.35
2113 degrutto 1.54
2114 arizzi 1.35 // secondary vtxs
2115     fwlite::Handle<std::vector<reco::Vertex> > SVC;
2116 arizzi 1.52 SVC.getByLabel(ev,"bcandidates");
2117 arizzi 1.35 const std::vector<reco::Vertex> svc = *(SVC.product());
2118 degrutto 1.69
2119 bortigno 1.30 const VHbbCandidate & vhCand = cand->at(0);
2120     patFilters.setEvent(&ev,"VH");
2121     hbhe = patFilters.accept("hbhe");
2122 arizzi 1.56 ecalFlag = patFilters.accept("ecalFilter");
2123 arizzi 1.63 totalKinematics = patFilters.accept("totalKinematics");
2124 degrutto 1.69 cschaloFlag = patFilters.accept("cschaloFilter");
2125     hcallaserFlag = patFilters.accept("hcallaserFilter");
2126     trackingfailureFlag = patFilters.accept("trackingfailureFilter");
2127 degrutto 1.104 eebadscFlag = patFilters.accept("eebadscFilter");
2128 arizzi 1.18
2129 bortigno 1.30 trigger.setEvent(&ev);
2130     for(size_t j=0;j < triggers.size();j++)
2131 arizzi 1.4 triggerFlags[j]=trigger.accept(triggers[j]);
2132 arizzi 1.39
2133 bortigno 1.30 eventFlav=0;
2134 degrutto 1.69
2135    
2136    
2137 bortigno 1.30 if(aux.mcBbar.size() > 0 || aux.mcB.size() > 0) eventFlav=5;
2138     else if(aux.mcC.size() > 0) eventFlav=4;
2139 degrutto 1.69
2140    
2141 arizzi 1.53 Vtype = vhCand.candidateType;
2142 msegala 1.131 VtypeWithTau=vhCand.candidateTypeWithTau;
2143 arizzi 1.3
2144 dlopes 1.73 if(vhCand.H.HiggsFlag) H.HiggsFlag=1; else H.HiggsFlag=0;
2145    
2146     if(vhCand.H.HiggsFlag){
2147 bortigno 1.30 H.mass = vhCand.H.p4.M();
2148     H.pt = vhCand.H.p4.Pt();
2149 degrutto 1.69
2150    
2151 bortigno 1.30 H.eta = vhCand.H.p4.Eta();
2152     H.phi = vhCand.H.p4.Phi();
2153 dlopes 1.73 }
2154 dlopes 1.67
2155 apana 1.112 nfathFilterJets=0;
2156 dlopes 1.73 if(vhCand.FatH.FatHiggsFlag) FatH.FatHiggsFlag =1; else FatH.FatHiggsFlag=0;
2157     fathFilterJets.reset();
2158     aJetsFat.reset();
2159     if(vhCand.FatH.FatHiggsFlag){
2160     FatH.mass= vhCand.FatH.p4.M();
2161 dlopes 1.67 FatH.pt = vhCand.FatH.p4.Pt();
2162 arizzi 1.83 if(FatH.pt!=0)
2163     {
2164     FatH.eta = vhCand.FatH.p4.Eta();
2165     }
2166     else {
2167     FatH.eta = -99.;
2168     }
2169 dlopes 1.67 FatH.phi = vhCand.FatH.p4.Phi();
2170 cboeser 1.107
2171 arizzi 1.83
2172 dlopes 1.67 // if(vhCand.FatH.FatHiggsFlag) vhCand.FatH.subjetsSize;
2173     nfathFilterJets=vhCand.FatH.subjetsSize;
2174     for( int j=0; j < nfathFilterJets; j++ ){
2175     fathFilterJets.set(vhCand.FatH.jets[j],j);
2176     }
2177 dlopes 1.73
2178 dlopes 1.67 if(nfathFilterJets==2){
2179     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).M();
2180 dlopes 1.73 FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Pt();
2181     FatH.filteredeta=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Eta();
2182     FatH.filteredphi=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Phi();
2183 cboeser 1.107 fathFilterJets.cosTheta[0]= vhCand.FatH.helicities[0];
2184     fathFilterJets.cosTheta[1]= vhCand.FatH.helicities[1];
2185     }
2186 dlopes 1.67 else if(nfathFilterJets==3){
2187     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).M();
2188 dlopes 1.73 FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Pt();
2189     FatH.filteredeta=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Eta();
2190     FatH.filteredphi=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Phi();
2191 cboeser 1.107 fathFilterJets.cosTheta[0]= vhCand.FatH.helicities[0];
2192     fathFilterJets.cosTheta[1]= vhCand.FatH.helicities[1];
2193     fathFilterJets.cosTheta[2]= vhCand.FatH.helicities[2];
2194 dlopes 1.67 }
2195 dlopes 1.73
2196     naJetsFat=vhCand.additionalJetsFat.size();
2197     for( int j=0; j < naJetsFat && j < MAXJ; j++ )
2198     {
2199     aJetsFat.set(vhCand.additionalJetsFat[j],j);
2200     }
2201 dlopes 1.67
2202 cboeser 1.107
2203 dlopes 1.73 } // FatHiggsFlag
2204 degrutto 1.69
2205 dlopes 1.73 hJets.reset();
2206     aJets.reset();
2207     if(vhCand.H.HiggsFlag){
2208 degrutto 1.69
2209 bortigno 1.30 nhJets=2;
2210     hJets.set(vhCand.H.jets[0],0);
2211     hJets.set(vhCand.H.jets[1],1);
2212 degrutto 1.69
2213 bortigno 1.30 aJets.reset();
2214 dlopes 1.73
2215 bortigno 1.30 naJets=vhCand.additionalJets.size();
2216     numBJets=0;
2217     if(vhCand.H.jets[0].csv> btagThr) numBJets++;
2218     if(vhCand.H.jets[1].csv> btagThr) numBJets++;
2219     for( int j=0; j < naJets && j < MAXJ; j++ )
2220 arizzi 1.6 {
2221 bortigno 1.30 aJets.set(vhCand.additionalJets[j],j);
2222     if(vhCand.additionalJets[j].csv> btagThr) numBJets++;
2223 msegala 1.124 if (VtypeWithTau==VHbbCandidate::Wtaun) {
2224     aJets.selectedTauDR[j] = vhCand.VTau.taus[0].p4.DeltaR(vhCand.additionalJets[j].p4);
2225     }
2226 arizzi 1.6 }
2227 bortigno 1.30 numJets = vhCand.additionalJets.size()+2;
2228 arizzi 1.33 H.dR = deltaR(vhCand.H.jets[0].p4.Eta(),vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Eta(),vhCand.H.jets[1].p4.Phi());
2229     H.dPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
2230     H.dEta= TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
2231 bortigno 1.30 HVdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ) ;
2232 arizzi 1.41 HVMass = (vhCand.H.p4 + vhCand.V.p4).M() ;
2233 bortigno 1.30 HMETdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.mets.at(0).p4.Phi()) ) ;
2234 arizzi 1.52 //eltaPullAngle = vhCand.H.deltaTheta;
2235 dlopes 1.73
2236 arizzi 1.52 deltaPullAngle = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[0],vhCand.H.jets[1]);
2237     deltaPullAngle2 = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[1],vhCand.H.jets[0]);
2238 bortigno 1.30 hJets.cosTheta[0]= vhCand.H.helicities[0];
2239     hJets.cosTheta[1]= vhCand.H.helicities[1];
2240 dlopes 1.73 } // Higgs Flag
2241    
2242     V.mass = vhCand.V.p4.M();
2243     if(isW) V.mass = vhCand.Mt();
2244     V.pt = vhCand.V.p4.Pt();
2245     V.eta = vhCand.V.p4.Eta();
2246     V.phi = vhCand.V.p4.Phi();
2247     VMt = vhCand.Mt() ;
2248 arizzi 1.122
2249 arizzi 1.120 if(VtypeWithTau==VHbbCandidate::Wtaun)
2250 msegala 1.124 {
2251     //VTau.mass = vhCand.VTau.p4.M();
2252     VTau.mass = vhCand.MtTau();
2253     VTau.pt = vhCand.VTau.p4.Pt();
2254     VTau.eta = vhCand.VTau.p4.Eta();
2255     VTau.phi = vhCand.VTau.p4.Phi();
2256     }
2257 arizzi 1.120
2258 dlopes 1.73
2259 arizzi 1.36 // METInfo calomet; METInfo tcmet; METInfo pfmet; METInfo mht; METInfo metNoPU
2260 bortigno 1.30 MET.et = vhCand.V.mets.at(0).p4.Pt();
2261     MET.phi = vhCand.V.mets.at(0).p4.Phi();
2262     MET.sumet = vhCand.V.mets.at(0).sumEt;
2263     MET.sig = vhCand.V.mets.at(0).metSig;
2264 arizzi 1.24
2265 arizzi 1.52
2266     fakeMET.sumet = 0;
2267     fakeMET.sig = 0;
2268     fakeMET.et = 0;
2269     fakeMET.phi = 0;
2270     if( Vtype == VHbbCandidate::Zmumu) {
2271     TVector3 mu1 = vhCand.V.muons[0].p4.Vect();
2272 arizzi 1.117 TVector3 mu2 = vhCand.V.muons[vhCand.V.secondLepton].p4.Vect();
2273 arizzi 1.52 // Not needed with PFMET
2274     // mu1.SetMag( mu1.Mag() - vhCand.V.muons[0].emEnergy - vhCand.V.muons[0].hadEnergy);
2275     // mu2.SetMag( mu2.Mag() - vhCand.V.muons[1].emEnergy - vhCand.V.muons[1].hadEnergy);
2276     TVector3 sum = vhCand.V.mets.at(0).p4.Vect() + mu1 + mu2;
2277     fakeMET.et = sum.Pt();
2278     fakeMET.phi = sum.Phi();
2279     fakeMET.sumet = vhCand.V.mets.at(0).sumEt - mu1.Pt() - mu2.Pt();
2280     }
2281    
2282 degrutto 1.69
2283    
2284 arizzi 1.36 METnoPU.et = iEvent->metNoPU.p4.Pt();
2285     METnoPU.phi = iEvent->metNoPU.p4.Phi();
2286     METnoPU.sumet = iEvent->metNoPU.sumEt;
2287     METnoPU.sig = iEvent->metNoPU.metSig;
2288 arizzi 1.59 METnoPUCh.et = iEvent->metCh.p4.Pt();
2289     METnoPUCh.phi = iEvent->metCh.p4.Phi();
2290     METnoPUCh.sumet = iEvent->metCh.sumEt;
2291     METnoPUCh.sig = iEvent->metCh.metSig;
2292 arizzi 1.36
2293 arizzi 1.58 METnoPUCh.et = iEvent->metCh.p4.Pt();
2294     METnoPUCh.phi = iEvent->metCh.p4.Phi();
2295     METnoPUCh.sumet = iEvent->metCh.sumEt;
2296     METnoPUCh.sig = iEvent->metCh.metSig;
2297    
2298 degrutto 1.69
2299     METtype1corr.et = iEvent->pfmetType1corr.p4.Pt();
2300     METtype1corr.phi = iEvent->pfmetType1corr.p4.Phi();
2301     METtype1corr.sumet = iEvent->pfmetType1corr.sumEt;
2302     METtype1corr.sig = iEvent->pfmetType1corr.metSig;
2303    
2304    
2305     METtype1p2corr.et = iEvent->pfmetType1p2corr.p4.Pt();
2306     METtype1p2corr.phi = iEvent->pfmetType1p2corr.p4.Phi();
2307     METtype1p2corr.sumet = iEvent->pfmetType1p2corr.sumEt;
2308     METtype1p2corr.sig = iEvent->pfmetType1p2corr.metSig;
2309    
2310    
2311     METnoPUtype1corr.et = iEvent->pfmetNoPUType1corr.p4.Pt();
2312     METnoPUtype1corr.phi = iEvent->pfmetNoPUType1corr.p4.Phi();
2313     METnoPUtype1corr.sumet = iEvent->pfmetNoPUType1corr.sumEt;
2314     METnoPUtype1corr.sig = iEvent->pfmetNoPUType1corr.metSig;
2315    
2316    
2317     METnoPUtype1p2corr.et = iEvent->pfmetNoPUType1p2corr.p4.Pt();
2318     METnoPUtype1p2corr.phi = iEvent->pfmetNoPUType1p2corr.p4.Phi();
2319     METnoPUtype1p2corr.sumet = iEvent->pfmetNoPUType1p2corr.sumEt;
2320     METnoPUtype1p2corr.sig = iEvent->pfmetNoPUType1p2corr.metSig;
2321 jiafulow 1.114
2322     TVector2 METtype1diff_vec2(METtype1diff_mex, METtype1diff_mey);
2323     METtype1diff.et = METtype1diff_vec2.Mod();
2324     METtype1diff.phi = METtype1diff_vec2.Phi();
2325     METtype1diff.sumet = METtype1diff_sumet;
2326     METnoPUtype1p2corr.sig = 0;
2327 degrutto 1.69
2328     // std::cout << " iEvent->metUncInfo.size() " << iEvent->metUncInfo.size() << std::endl;
2329     for(size_t m=0;m<iEvent->metUncInfo.size();m++)
2330     {
2331     metUnc.set(iEvent->metUncInfo[m], m );
2332     // std::cout << "metUncInfo[" << m <<" ].et = " << metUnc.et[m] << std::endl;
2333     }
2334    
2335    
2336 arizzi 1.36 rho = aux.puInfo.rho;
2337     rho25 = aux.puInfo.rho25;
2338 arizzi 1.82 rhoN = aux.puInfo.rhoNeutral;
2339 arizzi 1.36 nPVs=aux.pvInfo.nVertices;
2340    
2341 arizzi 1.24 if(!fromCandidate) {
2342     MHT.mht = iEvent->mht.p4.Pt();
2343     MHT.phi = iEvent->mht.p4.Phi();
2344     MHT.ht = iEvent->mht.sumEt;
2345     MHT.sig = iEvent->mht.metSig;
2346 bortigno 1.30 }
2347    
2348 arizzi 1.24
2349 malbouis 1.71 /////////
2350     // track sharing flags:
2351     ////////
2352     TkSharing.HiggsCSVtkSharing = TkSharing.HiggsIPtkSharing = TkSharing.HiggsSVtkSharing = TkSharing.FatHiggsCSVtkSharing = TkSharing.FatHiggsIPtkSharing = TkSharing.FatHiggsSVtkSharing = false;
2353    
2354     // csv tracks
2355 dlopes 1.73 if(vhCand.H.HiggsFlag){
2356    
2357 malbouis 1.71 if (vhCand.H.jets[0].csvNTracks > 0 && vhCand.H.jets[1].csvNTracks > 0){
2358     for (int t=0;t!=vhCand.H.jets[0].csvNTracks;t++){
2359     for (int ti=0;ti!=vhCand.H.jets[1].csvNTracks;ti++){
2360     if ((int)vhCand.H.jets[0].csvTrackIds[t] == (int)vhCand.H.jets[1].csvTrackIds[ti]){
2361     TkSharing.HiggsCSVtkSharing = true;
2362     }// same trackID
2363     }// loop tracks in second hjet
2364     }// loop tracks in first hjet
2365     }// if tracks in jet
2366    
2367     // ip tracks
2368     if (vhCand.H.jets[0].btagNTracks > 0 && vhCand.H.jets[1].btagNTracks > 0){
2369     for (int t=0;t!=vhCand.H.jets[0].btagNTracks;t++){
2370     for (int ti=0;ti!=vhCand.H.jets[1].btagNTracks;ti++){
2371     if ((int)vhCand.H.jets[0].btagTrackIds[t] == (int)vhCand.H.jets[1].btagTrackIds[ti]){
2372     TkSharing.HiggsIPtkSharing = true;
2373     }// same trackID
2374     }// loop tracks in second hjet
2375     }// loop tracks in first hjet
2376     }// if tracks in jet
2377    
2378     // sv tracks
2379     if (vhCand.H.jets[0].vtxNTracks > 0 && vhCand.H.jets[1].vtxNTracks > 0){
2380     for (int t=0;t!=vhCand.H.jets[0].vtxNTracks;t++){
2381     for (int ti=0;ti!=vhCand.H.jets[1].vtxNTracks;ti++){
2382     if ((int)vhCand.H.jets[0].vtxTrackIds[t] == (int)vhCand.H.jets[1].vtxTrackIds[ti]){
2383     TkSharing.HiggsSVtkSharing = true;
2384     }// same trackID
2385     }// loop tracks in second hjet
2386     }// loop tracks in first hjet
2387     }// if tracks in jet
2388 arizzi 1.24
2389 dlopes 1.73 } // Di-jet Higgs Flag
2390    
2391 malbouis 1.71 // tracksharing for Filtered jets:
2392     if(vhCand.FatH.FatHiggsFlag && nfathFilterJets > 1){
2393    
2394     // csv tracks
2395     if (vhCand.FatH.jets[0].csvNTracks > 0 && vhCand.FatH.jets[1].csvNTracks > 0){
2396     for (int t=0;t!=vhCand.FatH.jets[0].csvNTracks;t++){
2397     for (int ti=0;ti!=vhCand.FatH.jets[1].csvNTracks;ti++){
2398     if ((int)vhCand.FatH.jets[0].csvTrackIds[t] == (int)vhCand.FatH.jets[1].csvTrackIds[ti]){
2399     TkSharing.FatHiggsCSVtkSharing = true;
2400     }// same trackID
2401     }// loop tracks in second hjet
2402     }// loop tracks in first hjet
2403     }// if tracks in jet
2404    
2405     // ip tracks
2406     if (vhCand.FatH.jets[0].btagNTracks > 0 && vhCand.FatH.jets[1].btagNTracks > 0){
2407     for (int t=0;t!=vhCand.FatH.jets[0].btagNTracks;t++){
2408     for (int ti=0;ti!=vhCand.FatH.jets[1].btagNTracks;ti++){
2409     if ((int)vhCand.FatH.jets[0].btagTrackIds[t] == (int)vhCand.FatH.jets[1].btagTrackIds[ti]){
2410     TkSharing.FatHiggsIPtkSharing = true;
2411     }// same trackID
2412     }// loop tracks in second hjet
2413     }// loop tracks in first hjet
2414     }// if tracks in jet
2415    
2416     // sv tracks
2417     if (vhCand.FatH.jets[0].vtxNTracks > 0 && vhCand.FatH.jets[1].vtxNTracks > 0){
2418     for (int t=0;t!=vhCand.FatH.jets[0].vtxNTracks;t++){
2419     for (int ti=0;ti!=vhCand.FatH.jets[1].vtxNTracks;ti++){
2420     if ((int)vhCand.FatH.jets[0].vtxTrackIds[t] == (int)vhCand.FatH.jets[1].vtxTrackIds[ti]){
2421     TkSharing.FatHiggsSVtkSharing = true;
2422     }// same trackID
2423     }// loop tracks in second hjet
2424     }// loop tracks in first hjet
2425     }// if tracks in jet
2426    
2427     }// fatH
2428    
2429     ////////
2430     ////////
2431 arizzi 1.70
2432 bortigno 1.30 //Secondary Vertices
2433     IVF.reset();
2434     nSvs = svc.size();
2435     const TVector3 recoPv = aux.pvInfo.firstPVInPT2;
2436     const math::XYZPoint myPv(recoPv);
2437 bortigno 1.74
2438     //FAKE ERROR MATRIX
2439     // //look here for Matrix filling info http://project-mathlibs.web.cern.ch/project-mathlibs/sw/html/SMatrixDoc.html
2440     // std::vector<double> fillMatrix(6);
2441     // for (int i = 0; i<6; ++i) fillMatrix[i] = 0.;
2442     // fillMatrix[0] = TMath::Power(0.002,2);
2443     // fillMatrix[2] = TMath::Power(0.002,2);
2444     // fillMatrix[5] = TMath::Power(0.002,2);
2445     // const ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > myFakeMatrixError(fillMatrix.begin(),fillMatrix.end());
2446     // const reco::Vertex recoVtxPv(myPv, myFakeMatrixError);
2447    
2448 bortigno 1.75 // REAL ERROR MATRIX
2449 bortigno 1.74 const reco::Vertex recoVtxPv(myPv, aux.pvInfo.efirstPVInPT2);
2450 bortigno 1.30 for( int j=0; j < nSvs && j < MAXB; ++j ) {
2451     const GlobalVector flightDir = flightDirection(recoPv,svc[j]);
2452     reco::SecondaryVertex recoSv(recoVtxPv, svc[j], flightDir ,true);
2453     IVF.set( recoSv, recoPv ,j);
2454     }
2455 bortigno 1.74 if(nSvs > 1){
2456 bortigno 1.30 TLorentzVector BCands_H1, BCands_H2, BCands_H;
2457     BCands_H1.SetPtEtaPhiM(IVF.pt[0], IVF.eta[0], IVF.phi[0], IVF.massBcand[0]);
2458     BCands_H2.SetPtEtaPhiM(IVF.pt[1], IVF.eta[1], IVF.phi[1], IVF.massBcand[1]);
2459     BCands_H = BCands_H1 + BCands_H2;
2460 arizzi 1.33 SVH.dR = deltaR(IVF.eta[0], IVF.phi[0], IVF.eta[1], IVF.phi[1] );
2461     SVH.dPhi = deltaPhi(IVF.phi[0], IVF.phi[1] );
2462     SVH.dEta = TMath::Abs(IVF.eta[0] - IVF.eta[1] );
2463     SVH.mass = BCands_H.M();
2464     SVH.pt = BCands_H.Pt();
2465     SVH.eta = BCands_H.Eta();
2466     SVH.phi = BCands_H.Phi();
2467 bortigno 1.30 }
2468    
2469 bortigno 1.74 //SimBhadron
2470     SimBs.reset();
2471     if(isMC_){
2472     nSimBs = sbhc->size();
2473     for( int j=0; j < nSimBs && j < MAXB; ++j )
2474     SimBs.set( sbhc->at(j), j);
2475     if(nSimBs > 1){
2476     TLorentzVector SimBs_H1, SimBs_H2, SimBs_H;
2477     SimBs_H1.SetPtEtaPhiM(SimBs.pt[0], SimBs.eta[0], SimBs.phi[0], SimBs.mass[0]);
2478     SimBs_H2.SetPtEtaPhiM(SimBs.pt[1], SimBs.eta[1], SimBs.phi[1], SimBs.mass[1]);
2479     SimBs_H = SimBs_H1 + SimBs_H2;
2480     SimBsH.dR = deltaR(SimBs.eta[0], SimBs.phi[0], SimBs.eta[1], SimBs.phi[1] );
2481     SimBsH.dPhi = deltaPhi(SimBs.phi[0], SimBs.phi[1] );
2482     SimBsH.dEta = TMath::Abs(SimBs.eta[0] - SimBs.eta[1] );
2483     SimBsH.mass = SimBs_H.M();
2484     SimBsH.pt = SimBs_H.Pt();
2485     SimBsH.eta = SimBs_H.Eta();
2486     SimBsH.phi = SimBs_H.Phi();
2487     }
2488     }
2489 bortigno 1.30
2490     //Loop on jets
2491     double maxBtag=-99999;
2492     minDeltaPhijetMET = 999;
2493     TLorentzVector bJet;
2494     std::vector<std::vector<BTagWeight::JetInfo> > btagJetInfos;
2495 arizzi 1.64 std::vector<float> jet10eta;
2496     std::vector<float> jet10pt;
2497 bortigno 1.30 std::vector<float> jet30eta;
2498     std::vector<float> jet30pt;
2499     if(fromCandidate)
2500     {
2501     //Loop on Higgs Jets
2502     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ){
2503     if (vhCand.H.jets[j].csv > maxBtag) { bJet=vhCand.H.jets[j].p4 ; maxBtag =vhCand.H.jets[j].csv; }
2504 arizzi 1.39 if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi())) < minDeltaPhijetMET)
2505 bortigno 1.30 {
2506 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi()));
2507 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.H.jets[j].p4.Pt();
2508 bortigno 1.30 }
2509     btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
2510     }
2511     //Loop on Additional Jets
2512     for(unsigned int j=0; j < vhCand.additionalJets.size(); j++ ){
2513     if (vhCand.additionalJets[j].csv > maxBtag) { bJet=vhCand.additionalJets[j].p4 ; maxBtag =vhCand.additionalJets[j].csv; }
2514 arizzi 1.45 /* if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi())) < minDeltaPhijetMET)
2515 bortigno 1.30 {
2516 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi()));
2517 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.additionalJets[j].p4.Pt();
2518 arizzi 1.45 }*/
2519 bortigno 1.30 if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) ) // btag SF computed using only H-jets if best-H made with dijetPt rather than best CSV
2520     {
2521     if(vhCand.additionalJets[j].p4.Pt() > 20)
2522     btagJetInfos.push_back(btagEff.jetInfo(vhCand.additionalJets[j]));
2523     }
2524     }
2525     }
2526     else
2527     {
2528 arizzi 1.45 //Loop on all jets
2529 bortigno 1.30 for(unsigned int j=0; j < iEvent->simpleJets2.size(); j++ ){
2530     if (iEvent->simpleJets2[j].csv > maxBtag) { bJet=iEvent->simpleJets2[j].p4 ; maxBtag =iEvent->simpleJets2[j].csv; }
2531 arizzi 1.47 if ( iEvent->simpleJets2[j].p4.Pt() > 20 && fabs(iEvent->simpleJets2[j].p4.Eta()) < 2.5&& fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi())) < minDeltaPhijetMET)
2532 arizzi 1.46 {
2533     minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi()));
2534     jetPt_minDeltaPhijetMET=iEvent->simpleJets2[j].p4.Pt();
2535     }
2536 arizzi 1.64 if(iEvent->simpleJets2[j].p4.Pt() > 10)
2537     {
2538     jet10eta.push_back(iEvent->simpleJets2[j].p4.Eta());
2539     jet10pt.push_back(iEvent->simpleJets2[j].p4.Pt());
2540     }
2541 bortigno 1.30 if(iEvent->simpleJets2[j].p4.Pt() > 30)
2542     {
2543     jet30eta.push_back(iEvent->simpleJets2[j].p4.Eta());
2544     jet30pt.push_back(iEvent->simpleJets2[j].p4.Pt());
2545     }
2546 arizzi 1.24
2547 bortigno 1.30 //For events made with highest CSV, all jets in the event should be taken into account for "tagging" SF (anti tagging is a mess)
2548     // because for example a light jet not used for the Higgs can have in reality a higher CSV due to SF > 1 and become a higgs jet
2549     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )
2550     {
2551 arizzi 1.58 if(iEvent->simpleJets2[j].p4.Pt() > 20 && fabs(iEvent->simpleJets2[j].p4.Eta()) < 2.5)
2552 bortigno 1.30 btagJetInfos.push_back(btagEff.jetInfo(iEvent->simpleJets2[j]));
2553     }
2554     }
2555    
2556 arizzi 1.45 //Loop on Higgs jets
2557    
2558 dlopes 1.73 if(vhCand.H.HiggsFlag){
2559 arizzi 1.45 for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ) {
2560    
2561 bortigno 1.30 //if we use the highest pt pair, only the two higgs jet should be used to compute the SF because the other jets are excluded
2562     // by a criteria (pt of the dijet) that is not btag SF dependent
2563     if(!( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )) {
2564 arizzi 1.45 btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
2565 bortigno 1.30 }
2566 arizzi 1.45 }
2567 dlopes 1.73 }// HiggsFlag
2568 arizzi 1.24
2569 bortigno 1.30 }
2570     vLeptons.reset();
2571     weightTrig = 1.; // better to default to 1
2572 arizzi 1.38 weightTrigMay = -1.;
2573     weightTrigV4 = -1.;
2574 arizzi 1.51 weightTrigOrMu30 = 1.;
2575 bortigno 1.30 TLorentzVector leptonForTop;
2576     size_t firstAddMu=0;
2577     size_t firstAddEle=0;
2578 msegala 1.130 size_t firstAddTau=0;
2579 bortigno 1.30 if(Vtype == VHbbCandidate::Zmumu ){
2580 arizzi 1.82 vLeptons.set(vhCand.V.muons[0],0,13,aux);
2581 arizzi 1.117 vLeptons.set(vhCand.V.muons[vhCand.V.secondLepton],1,13,aux);
2582 bortigno 1.30 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleMuID(vLeptons.pt[1],vLeptons.eta[1]) ;
2583     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2584     float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[1],vLeptons.eta[1]);
2585     float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
2586 arizzi 1.89 //2011
2587     weightTrig = cweightID * cweightTrig;
2588    
2589 arizzi 1.110
2590     weightTrig2012DiMuon = triggerWeight.doubleMuon2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2591     float weightTrig2012SingleMuonMu1 = triggerWeight.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2592     float weightTrig2012SingleMuonMu2 = triggerWeight.singleMuon2012A(vLeptons.pt[1],vLeptons.eta[1]);
2593     weightTrig2012SingleMuon = weightTrig2012SingleMuonMu1+weightTrig2012SingleMuonMu2-weightTrig2012SingleMuonMu1*weightTrig2012SingleMuonMu2;
2594     weightTrig2012= weightTrig2012SingleMuon * triggerWeight.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.muId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2595    
2596     weightTrig2012ABDiMuon = triggerWeightAB.doubleMuon2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2597     float weightTrig2012ABSingleMuonMu1 = triggerWeightAB.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2598     float weightTrig2012ABSingleMuonMu2 = triggerWeightAB.singleMuon2012A(vLeptons.pt[1],vLeptons.eta[1]);
2599     weightTrig2012ABSingleMuon = weightTrig2012ABSingleMuonMu1+weightTrig2012ABSingleMuonMu2-weightTrig2012ABSingleMuonMu1*weightTrig2012ABSingleMuonMu2;
2600     weightTrig2012AB = weightTrig2012ABSingleMuon * triggerWeightAB.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeightAB.muId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2601    
2602     weightTrig2012A=weightTrig2012;
2603     weightTrig2012ADiMuon=weightTrig2012DiMuon;
2604     weightTrig2012ASingleMuon=weightTrig2012SingleMuon;
2605 arizzi 1.89
2606 bortigno 1.30 nvlep=2;
2607     firstAddMu=2;
2608     }
2609     if( Vtype == VHbbCandidate::Zee ){
2610 arizzi 1.82 vLeptons.set(vhCand.V.electrons[0],0,11,aux);
2611 arizzi 1.121 // std::cout << vhCand.V.secondLepton << std::endl;
2612 arizzi 1.117 vLeptons.set(vhCand.V.electrons[vhCand.V.secondLepton],1,11,aux);
2613 bortigno 1.30 nvlep=2;
2614     firstAddEle=2;
2615     std::vector<float> pt,eta;
2616     pt.push_back(vLeptons.pt[0]); eta.push_back(vLeptons.eta[0]);
2617     pt.push_back(vLeptons.pt[1]); eta.push_back(vLeptons.eta[1]);
2618     weightEleRecoAndId=triggerWeight.scaleID95Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]) *
2619     triggerWeight.scaleID95Ele(vLeptons.pt[1],vLeptons.eta[1]) * triggerWeight.scaleRecoEle(vLeptons.pt[1],vLeptons.eta[1]);
2620     weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
2621 arizzi 1.60 weightEleTrigEleAugPart = triggerWeight.scaleDoubleEle17Ele8Aug(pt,eta);
2622     weightTrig = (weightEleTrigElePart*1.14+weightEleTrigEleAugPart*0.98 )/2.12 * weightEleRecoAndId;
2623 arizzi 1.24
2624 arizzi 1.89 weightTrig2012ADiEle = triggerWeight.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2625     float weightTrig2012ASingleEle1 = triggerWeight.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2626     float weightTrig2012ASingleEle2 = triggerWeight.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2627     weightTrig2012ASingleEle = weightTrig2012ASingleEle1+weightTrig2012ASingleEle2-weightTrig2012ASingleEle1*weightTrig2012ASingleEle2;
2628 arizzi 1.101 weightTrig2012A = weightTrig2012ADiEle * triggerWeight.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2629 arizzi 1.24
2630 arizzi 1.110 weightTrig2012DiEle = triggerWeight.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2631     float weightTrig2012SingleEle1 = triggerWeight.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2632     float weightTrig2012SingleEle2 = triggerWeight.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2633     weightTrig2012SingleEle = weightTrig2012SingleEle1+weightTrig2012SingleEle2-weightTrig2012SingleEle1*weightTrig2012SingleEle2;
2634     weightTrig2012 = weightTrig2012DiEle * triggerWeight.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2635    
2636     weightTrig2012ABDiEle = triggerWeightAB.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2637     float weightTrig2012ABSingleEle1 = triggerWeightAB.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2638     float weightTrig2012ABSingleEle2 = triggerWeightAB.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2639     weightTrig2012ABSingleEle = weightTrig2012ABSingleEle1+weightTrig2012ABSingleEle2-weightTrig2012ABSingleEle1*weightTrig2012ABSingleEle2;
2640     weightTrig2012AB = weightTrig2012ABDiEle * triggerWeightAB.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeightAB.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2641 bortigno 1.30 }
2642     if(Vtype == VHbbCandidate::Wmun ){
2643     leptonForTop=vhCand.V.muons[0].p4;
2644 arizzi 1.82 vLeptons.set(vhCand.V.muons[0],0,13,aux);
2645 bortigno 1.30 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]);
2646     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2647     float cweightTrig = weightTrig1;
2648     weightTrig = cweightID * cweightTrig;
2649 arizzi 1.51 float weightTrig1OrMu30 = triggerWeight.scaleMuOr30IsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2650 dlopes 1.61 weightTrigOrMu30 = cweightID*weightTrig1OrMu30;
2651 arizzi 1.89 weightTrig2012ASingleMuon = triggerWeight.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2652     weightTrig2012AMuonPlusWCandPt = weightTrig2012ASingleMuon +
2653     triggerWeight.muPlusWCandPt2012A_legMu(vLeptons.pt[0],vLeptons.eta[0])*triggerWeight.muPlusWCandPt2012A_legW(vhCand.V.p4.Pt(),0);
2654 arizzi 1.101 weightTrig2012A = weightTrig2012ASingleMuon * triggerWeight.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) ;
2655 arizzi 1.89
2656 arizzi 1.110
2657     weightTrig2012SingleMuon = weightTrig2012ASingleMuon;
2658     weightTrig2012MuonPlusWCandPt = weightTrig2012AMuonPlusWCandPt;
2659     weightTrig2012 = weightTrig2012A;
2660    
2661    
2662    
2663     weightTrig2012ABSingleMuon = triggerWeightAB.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2664     weightTrig2012ABMuonPlusWCandPt = weightTrig2012ABSingleMuon +
2665     triggerWeightAB.muPlusWCandPt2012A_legMu(vLeptons.pt[0],vLeptons.eta[0])*triggerWeightAB.muPlusWCandPt2012A_legW(vhCand.V.p4.Pt(),0);
2666     weightTrig2012AB = weightTrig2012ABSingleMuon * triggerWeightAB.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) ;
2667    
2668    
2669    
2670 bortigno 1.30 nvlep=1;
2671     firstAddMu=1;
2672     }
2673     if( Vtype == VHbbCandidate::Wen ){
2674     leptonForTop=vhCand.V.electrons[0].p4;
2675 arizzi 1.82 vLeptons.set(vhCand.V.electrons[0],0,11,aux);
2676 bortigno 1.30 nvlep=1;
2677     firstAddEle=1;
2678 arizzi 1.38 weightTrigMay = triggerWeight.scaleSingleEleMay(vLeptons.pt[0],vLeptons.eta[0]);
2679     weightTrigV4 = triggerWeight.scaleSingleEleV4(vLeptons.pt[0],vLeptons.eta[0]);
2680 bortigno 1.30 weightEleRecoAndId=triggerWeight.scaleID80Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]);
2681 arizzi 1.59 weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30pt,jet30eta)*triggerWeight.scalePFMHTEle(MET.et);
2682 arizzi 1.38 weightEleTrigElePart= weightTrigV4; //this is for debugging only, checking only the V4 part
2683 bortigno 1.30
2684 arizzi 1.38 weightTrigMay*=weightEleRecoAndId;
2685     weightTrigV4*=weightEleRecoAndId;
2686     weightTrigV4*=weightEleTrigJetMETPart;
2687 arizzi 1.60 // weightTrig = weightTrigMay * 0.187 + weightTrigV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
2688     weightTrig = (weightTrigMay * 0.215 + weightTrigV4 * 1.915)/ 2.13; //FIXME: use proper lumi if we reload 2.fb
2689 arizzi 1.89
2690 arizzi 1.110
2691 arizzi 1.89 weightTrig2012ASingleEle = triggerWeight.singleEle2012Awp80(vLeptons.pt[0],vLeptons.eta[0]);
2692 arizzi 1.101 weightTrig2012A = weightTrig2012ASingleEle * triggerWeight.eleId2012Awp80(vLeptons.pt[0],vLeptons.eta[0]) ;
2693 arizzi 1.89
2694 arizzi 1.110 weightTrig2012SingleEle = weightTrig2012ASingleEle;
2695     weightTrig2012 = weightTrig2012A;
2696    
2697     weightTrig2012ABSingleEle = triggerWeightAB.singleEle2012Awp80(vLeptons.pt[0],vLeptons.eta[0]);
2698     weightTrig2012AB = weightTrig2012ABSingleEle * triggerWeightAB.eleId2012Awp80(vLeptons.pt[0],vLeptons.eta[0]) ;
2699 arizzi 1.89
2700 bortigno 1.30 }
2701 arizzi 1.64
2702 msegala 1.130 vLeptonsTaus.reset();
2703    
2704 msegala 1.124 if(VtypeWithTau==VHbbCandidate::Wtaun){
2705 msegala 1.130
2706 msegala 1.124 if ( vhCand.VTau.taus.size() > 0 ){
2707     vLeptonsTaus.set(vhCand.VTau.taus[0],0,15,aux);
2708     //cout << vLeptonsTaus.pt[0] << ", " << vLeptonsTaus.decayModeFinding[0] << endl;
2709     nvlepTau=1;
2710 msegala 1.130 firstAddTau=1;
2711 msegala 1.124 }
2712 msegala 1.130 }
2713 msegala 1.124
2714 arizzi 1.65 if(isMC_)
2715     {
2716 arizzi 1.64 weightTrigMET80 = triggerWeight.scaleMET80(MET.et);
2717     weightTrigMET100 = triggerWeight.scaleMET80(MET.et);
2718     weightTrig2CJet20 = triggerWeight.scale2CentralJet( jet10pt, jet10eta);
2719     weightTrigMET150 = triggerWeight.scaleMET150(MET.et);
2720     weightTrigMET802CJet= weightTrigMET80 * weightTrig2CJet20;
2721     weightTrigMET1002CJet= weightTrigMET100 * weightTrig2CJet20;
2722 degrutto 1.108 weightTrig2012DiJet30MHT80=triggerWeight.scaleDiJet30MHT80_2012A(vhCand.V.mets.at(0).p4.Pt());
2723     weightTrig2012PFMET150=triggerWeight.scalePFMET150_2012AB(vhCand.V.mets.at(0).p4.Pt()); // demonstrated to hold also for RunC (used averaged efficiency)
2724     weightTrig2012SumpT100MET100=triggerWeight.scaleSumpT100MET100_2012B(vhCand.V.mets.at(0).p4.Pt()); // demonstrated to hold also for RunC (used averaged efficiency)
2725     weightTrig2012APFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012A(vhCand.V.mets.at(0).p4.Pt());
2726     weightTrig2012BPFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012B(vhCand.V.mets.at(0).p4.Pt());
2727     weightTrig2012CPFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012C(vhCand.V.mets.at(0).p4.Pt());
2728    
2729    
2730 arizzi 1.65 }
2731 bortigno 1.30 if( Vtype == VHbbCandidate::Znn ){
2732     nvlep=0;
2733     float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
2734 arizzi 1.64 weightTrigMETLP = weightTrig1;
2735     weightTrig = weightTrigMET150 + weightTrigMET802CJet - weightTrigMET802CJet*weightTrigMET150;
2736 degrutto 1.102
2737 arizzi 1.92 // weightTrig2012A =
2738 bortigno 1.30 }
2739 arizzi 1.38
2740     if(weightTrigMay < 0) weightTrigMay=weightTrig;
2741     if(weightTrigV4 < 0) weightTrigV4=weightTrig;
2742 arizzi 1.40 if(!isMC_)
2743     {
2744     weightTrig = 1.;
2745     weightTrigMay = 1.;
2746     weightTrigV4 = 1.;
2747 arizzi 1.64 weightEleRecoAndId= 1.;
2748     weightEleTrigJetMETPart= 1.;
2749     weightEleTrigElePart= 1.;
2750     weightEleTrigEleAugPart=1.;
2751     weightTrigMET80= 1.;
2752     weightTrigMET100= 1.;
2753     weightTrig2CJet20= 1.;
2754     weightTrigMET150= 1.;
2755     weightTrigMET802CJet= 1.;
2756     weightTrigMET1002CJet= 1.;
2757     weightTrigMETLP = 1.;
2758 arizzi 1.40
2759     }
2760 bortigno 1.30 aLeptons.reset();
2761     nalep=0;
2762 arizzi 1.122 // std::cout << "Triggers" << std::endl;
2763 bortigno 1.30 if(fromCandidate)
2764 arizzi 1.21 {
2765 arizzi 1.82 for(size_t j=firstAddMu;j< vhCand.V.muons.size();j++) aLeptons.set(vhCand.V.muons[j],nalep++,13,aux);
2766     for(size_t j=firstAddEle;j< vhCand.V.electrons.size();j++) aLeptons.set(vhCand.V.electrons[j],nalep++,11,aux);
2767 arizzi 1.21 }
2768 bortigno 1.30 else
2769 arizzi 1.21 {
2770 bortigno 1.30 for(size_t j=0;j< iEvent->muInfo.size();j++)
2771     {
2772 arizzi 1.121 if((j!= vhCand.V.firstLeptonOrig && j!= vhCand.V.secondLeptonOrig) || ((Vtype != VHbbCandidate::Wmun ) && (Vtype != VHbbCandidate::Zmumu )) )
2773 arizzi 1.82 aLeptons.set(iEvent->muInfo[j],nalep++,13,aux);
2774 bortigno 1.30 }
2775     for(size_t j=0;j< iEvent->eleInfo.size();j++)
2776     {
2777 arizzi 1.121 if((j!= vhCand.V.firstLeptonOrig && j!= vhCand.V.secondLeptonOrig) || ((Vtype != VHbbCandidate::Wen ) && (Vtype != VHbbCandidate::Zee )))
2778 arizzi 1.82 aLeptons.set(iEvent->eleInfo[j],nalep++,11,aux);
2779 bortigno 1.30 }
2780 arizzi 1.8
2781 arizzi 1.21 }
2782 arizzi 1.122 // std::cout << "Leptons done" << std::endl;
2783 arizzi 1.8
2784 arizzi 1.24
2785 bortigno 1.30 if(isMC_)
2786     {
2787     //std::cout << "BTAGSF " << btagJetInfos.size() << " " << btag.weight<BTag1Tight2CustomFilter>(btagJetInfos) << std::endl;
2788     if ( btagJetInfos.size()< 10)
2789     {
2790     btag1T2CSF = btag.weight<BTag1Tight2CustomFilter>(btagJetInfos);
2791     btag2TSF = btag.weight<BTag2TightFilter>(btagJetInfos);
2792     btag1TSF = btag.weight<BTag1TightFilter>(btagJetInfos);
2793 arizzi 1.44 btagA0CSF = btag.weight<BTagAntiMax0CustomFilter>(btagJetInfos);
2794 arizzi 1.60 btagA0TSF = btag.weight<BTagAntiMax0TightFilter>(btagJetInfos);
2795 arizzi 1.44 btag2CSF = btag.weight<BTag2CustomFilter>(btagJetInfos);
2796 arizzi 1.51 btag1TA1C = btag.weight<BTag1TightAndMax1CustomFilter>(btagJetInfos);
2797 bortigno 1.30 }
2798     else
2799     {
2800     std::cout << "WARNING: combinatorics for " << btagJetInfos.size() << " jets is too high (>=10). use SF=1 " << std::endl;
2801     //TODO: revert to random throw for this cases
2802     btag1T2CSF = 1.;
2803     btag2TSF = 1.;
2804     btag1TSF = 1.;
2805 arizzi 1.51 btagA0CSF = 1.;
2806 arizzi 1.60 btagA0TSF = 1.;
2807 arizzi 1.51 btag2CSF = 1.;
2808     btag1TA1C = 1.;
2809 bortigno 1.30 }
2810     }
2811 arizzi 1.17
2812 bortigno 1.30 if(maxBtag > -99999)
2813 arizzi 1.8 {
2814 bortigno 1.30 TopHypo topQuark = TopMassReco::topMass(leptonForTop,bJet,vhCand.V.mets.at(0).p4);
2815     top.mass = topQuark.p4.M();
2816     top.pt = topQuark.p4.Pt();
2817     top.wMass = topQuark.p4W.M();
2818 arizzi 1.8 } else {
2819 bortigno 1.30 top.mass = -99;
2820     top.pt = -99;
2821     top.wMass = -99;
2822     }
2823 arizzi 1.8
2824    
2825    
2826 bortigno 1.30 //FIXME: too much warnings... figure out why
2827     // gendrcc=aux.genCCDeltaR();
2828     // gendrbb=aux.genBBDeltaR();
2829 degrutto 1.69
2830    
2831    
2832 bortigno 1.30 genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
2833     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
2834 degrutto 1.69
2835     // Z* is status=3 and Nmother=2 (q and qbar)
2836     // Z is status=2 and Ndau=2 (mup and mum)
2837     for (unsigned int i=0; i<aux.mcZ.size(); i++){
2838     if (aux.mcZ[i].status==3) {
2839     genZstar.mass = aux.mcZ[i].p4.M();
2840     genZstar.pt = aux.mcZ[i].p4.Pt();
2841 arizzi 1.111 // genZstar.eta = aux.mcZ[i].p4.Eta();
2842     if(genZstar.pt>0.1) genZstar.eta = aux.mcZ[i].p4.Eta(); else genZstar.eta=-99;
2843    
2844 degrutto 1.69 genZstar.phi = aux.mcZ[i].p4.Phi();
2845     genZstar.status = aux.mcZ[i].status;
2846     genZstar.charge = aux.mcZ[i].charge;
2847     if (aux.mcZ[i].momid!=-99) genZstar.momid = aux.mcZ[i].momid ;
2848     }
2849    
2850    
2851    
2852     if (aux.mcZ[i].dauid.size()>1) {
2853 jiafulow 1.114 if ( abs(aux.mcZ[i].dauid[0])==11 || abs(aux.mcZ[i].dauid[0])==12 ||
2854     abs(aux.mcZ[i].dauid[0])==13 || abs(aux.mcZ[i].dauid[0])==14 ||
2855     abs(aux.mcZ[i].dauid[0])==15 || abs(aux.mcZ[i].dauid[0])==16 ) {
2856 degrutto 1.69 genZ.mass = aux.mcZ[i].p4.M();
2857     genZ.pt = aux.mcZ[i].p4.Pt();
2858 arizzi 1.111 // genZ.eta = aux.mcZ[i].p4.Eta();
2859     if(genZ.pt>0.1) genZ.eta = aux.mcZ[i].p4.Eta(); else genZ.eta=-99;
2860 degrutto 1.69 genZ.phi = aux.mcZ[i].p4.Phi();
2861     genZ.status = aux.mcZ[i].status;
2862     genZ.charge = aux.mcZ[i].charge;
2863     if ( aux.mcZ[i].momid!=-99) genZ.momid = aux.mcZ[i].momid;
2864     }
2865     }
2866     }
2867    
2868    
2869    
2870     for (unsigned int i=0; i<aux.mcW.size(); i++){
2871     if ( aux.mcW[i].momid==6 && aux.mcW[i].dauid.size()>1 ){
2872     genTop.wdau1mass= aux.mcW[i].dauFourMomentum[0].M();
2873     genTop.wdau1pt= aux.mcW[i].dauFourMomentum[0].Pt();
2874 arizzi 1.122 if(genTop.wdau1pt > 0.1)
2875 degrutto 1.69 genTop.wdau1eta= aux.mcW[i].dauFourMomentum[0].Eta();
2876     genTop.wdau1phi= aux.mcW[i].dauFourMomentum[0].Phi();
2877     genTop.wdau1id= aux.mcW[i].dauid[0];
2878    
2879     genTop.wdau2mass= aux.mcW[i].dauFourMomentum[1].M();
2880     genTop.wdau2pt= aux.mcW[i].dauFourMomentum[1].Pt();
2881 arizzi 1.122 if(genTop.wdau2pt > 0.1)
2882 degrutto 1.69 genTop.wdau2eta= aux.mcW[i].dauFourMomentum[1].Eta();
2883     genTop.wdau2phi= aux.mcW[i].dauFourMomentum[1].Phi();
2884     genTop.wdau2id= aux.mcW[i].dauid[1];
2885    
2886     }
2887    
2888    
2889     if ( aux.mcW[i].momid==-6 && aux.mcW[i].dauid.size()>1 ){
2890     genTbar.wdau1mass= aux.mcW[i].dauFourMomentum[0].M();
2891     genTbar.wdau1pt= aux.mcW[i].dauFourMomentum[0].Pt();
2892 arizzi 1.122 if(genTbar.wdau1pt>0)
2893 degrutto 1.69 genTbar.wdau1eta= aux.mcW[i].dauFourMomentum[0].Eta();
2894     genTbar.wdau1phi= aux.mcW[i].dauFourMomentum[0].Phi();
2895     genTbar.wdau1id= aux.mcW[i].dauid[0];
2896     genTbar.wdau2mass= aux.mcW[i].dauFourMomentum[1].M();
2897     genTbar.wdau2pt= aux.mcW[i].dauFourMomentum[1].Pt();
2898 arizzi 1.122 if(genTbar.wdau2pt>0)
2899 degrutto 1.69 genTbar.wdau2eta= aux.mcW[i].dauFourMomentum[1].Eta();
2900     genTbar.wdau2phi= aux.mcW[i].dauFourMomentum[1].Phi();
2901     genTbar.wdau2id= aux.mcW[i].dauid[1];
2902    
2903     }
2904    
2905     if (aux.mcW[i].status==3 ) {
2906     genWstar.mass = aux.mcW[i].p4.M();
2907     genWstar.pt = aux.mcW[i].p4.Pt();
2908 arizzi 1.122 if(genWstar.pt>0.1)
2909 degrutto 1.69 genWstar.eta = aux.mcW[i].p4.Eta();
2910     genWstar.phi = aux.mcW[i].p4.Phi();
2911     genWstar.status = aux.mcW[i].status;
2912     genWstar.charge = aux.mcW[i].charge;
2913     if ( aux.mcW[i].momid!=-99) genWstar.momid = aux.mcW[i].momid;
2914     }
2915     if (aux.mcW[i].dauid.size()>1 && (abs(aux.mcW[i].dauid[0])==13 || abs(aux.mcW[i].dauid[0])==11 )) {
2916     genW.mass = aux.mcW[i].p4.M();
2917     genW.pt = aux.mcW[i].p4.Pt();
2918 arizzi 1.122 if(genW.pt>0)
2919 degrutto 1.69 genW.eta = aux.mcW[i].p4.Eta();
2920     genW.phi = aux.mcW[i].p4.Phi();
2921     genW.status = aux.mcW[i].status;
2922     genW.charge = aux.mcW[i].charge;
2923     if (aux.mcW[i].momid!=-99) genW.momid = aux.mcW[i].momid;
2924     }
2925     }
2926     // b coming from Higgs
2927     for (unsigned int i=0; i<aux.mcB.size(); i++){
2928     if (abs(aux.mcB[i].momid)!=5) {
2929     genB.mass = aux.mcB[i].p4.M();
2930     genB.pt = aux.mcB[i].p4.Pt();
2931 arizzi 1.122 if(genB.pt>0)
2932 degrutto 1.69 genB.eta = aux.mcB[i].p4.Eta();
2933     genB.phi = aux.mcB[i].p4.Phi();
2934     genB.status = aux.mcB[i].status;
2935     genB.charge = aux.mcB[i].charge;
2936     if (aux.mcB[i].momid!=-99) genB.momid = aux.mcB[i].momid;
2937     }
2938    
2939     if ( aux.mcB[i].momid==6 ){
2940     genTop.bmass = aux.mcB[i].p4.M();
2941     genTop.bpt = aux.mcB[i].p4.Pt();
2942 arizzi 1.122 if( genTop.bpt >0)
2943 degrutto 1.69 genTop.beta = aux.mcB[i].p4.Eta();
2944     genTop.bphi = aux.mcB[i].p4.Phi();
2945     genTop.bstatus = aux.mcB[i].status;
2946    
2947     }
2948     }
2949    
2950     for (unsigned int i=0; i<aux.mcBbar.size(); i++){
2951     if (abs(aux.mcBbar[i].momid)!=5 ) {
2952     genBbar.mass = aux.mcBbar[i].p4.M();
2953     genBbar.pt = aux.mcBbar[i].p4.Pt();
2954 arizzi 1.122 if(genBbar.pt >0)
2955 degrutto 1.69 genBbar.eta = aux.mcBbar[i].p4.Eta();
2956     genBbar.phi = aux.mcBbar[i].p4.Phi();
2957     genBbar.status = aux.mcBbar[i].status;
2958     if (aux.mcBbar[i].momid!=-99) genBbar.momid = aux.mcBbar[i].momid;
2959     }
2960     if ( aux.mcBbar[i].momid==-6 ){
2961     genTbar.bmass = aux.mcBbar[i].p4.M();
2962     genTbar.bpt = aux.mcBbar[i].p4.Pt();
2963 arizzi 1.122 if( genTbar.bpt>0)
2964 degrutto 1.69 genTbar.beta = aux.mcBbar[i].p4.Eta();
2965     genTbar.bphi = aux.mcBbar[i].p4.Phi();
2966     genTbar.bstatus = aux.mcBbar[i].status;
2967    
2968    
2969     }
2970    
2971     }
2972    
2973    
2974    
2975    
2976     if (aux.mcH.size()>0) {
2977     genH.mass = aux.mcH[0].p4.M();
2978     genH.pt = aux.mcH[0].p4.Pt();
2979 arizzi 1.122 if(genH.pt>0)
2980 degrutto 1.69 genH.eta = aux.mcH[0].p4.Eta();
2981     genH.phi = aux.mcH[0].p4.Phi();
2982     genH.status = aux.mcH[0].status;
2983     genH.charge = aux.mcH[0].charge;
2984     if (aux.mcH[0].momid!=-99) genH.momid = aux.mcH[0].momid;
2985     }
2986    
2987    
2988    
2989    
2990 arizzi 1.49 WminusMode=-99;
2991     WplusMode=-99;
2992 arizzi 1.50 for(unsigned int j=0; j< aux.mcW.size();j++)
2993 arizzi 1.49 {
2994 degrutto 1.66 for(unsigned int k=0;k< aux.mcW[j].dauid.size();k++)
2995     {
2996     int idd=abs(aux.mcW[j].dauid[k]);
2997     if(idd==11 || idd==13 || idd==15|| (idd<=5 && idd >=1))
2998     {
2999     if(WminusMode==-99 && aux.mcW[j].charge ==-1) WminusMode = idd;
3000     if(WplusMode==-99 && aux.mcW[j].charge ==+1) WplusMode = idd;
3001     }
3002     }
3003     /*
3004     /// now check if a semileptonic W is also in a bjets....
3005     if ( ( (WminusMode==11 || WminusMode==13 || WminusMode==15 ) || (WplusMode==11 || WplusMode==13 || WplusMode==15 )) && deltaR(vhCand.H.jets[0].p4.Eta(),vhCand.H.jets[0].p4.Phi(), aux.mcW[j].p4.Eta(), aux.mcW[j].p4.Phi())<0.3 ) hJets.isSemiLeptMCtruth[0]=1;
3006     if ( ( (WminusMode==11 || WminusMode==13 || WminusMode==15 ) || (WplusMode==11 || WplusMode==13 || WplusMode==15 )) && deltaR(vhCand.H.jets[1].p4.Eta(),vhCand.H.jets[1].p4.Phi(), aux.mcW[j].p4.Eta(), aux.mcW[j].p4.Phi())<0.3 ) hJets.isSemiLeptMCtruth[1]=1;
3007    
3008     for( int j=0; j < naJets && j < MAXJ; j++ )
3009     {
3010     if ((idd==11 || idd==13 || idd==15 ) && deltaR(vhCand.additionalJets[j].p4.Eta(),vhCand.additionalJets[j].p4.Phi(), aux.mcW[j].p4.Eta(), aux.mcW[j].p4.Phi()) <0.3) aJets.isSemiLept[j]=1;
3011    
3012     }
3013     */
3014    
3015     }
3016 arizzi 1.32 /// Compute pull angle from AK7
3017 dlopes 1.73 if(vhCand.H.HiggsFlag){
3018 arizzi 1.25 if(!fromCandidate){
3019 arizzi 1.32 std::vector<VHbbEvent::SimpleJet> ak7wrt1(iEvent->simpleJets3);
3020     std::vector<VHbbEvent::SimpleJet> ak7wrt2(iEvent->simpleJets3);
3021     if(ak7wrt1.size() > 1){
3022 arizzi 1.24 CompareDeltaR deltaRComparatorJ1(vhCand.H.jets[0].p4);
3023     CompareDeltaR deltaRComparatorJ2(vhCand.H.jets[1].p4);
3024 arizzi 1.32 std::sort( ak7wrt1.begin(),ak7wrt1.end(),deltaRComparatorJ1 );
3025     std::sort( ak7wrt2.begin(),ak7wrt2.end(),deltaRComparatorJ2 );
3026 arizzi 1.24 std::vector<VHbbEvent::SimpleJet> ak7_matched;
3027 arizzi 1.32 // if the matched are different save them
3028     if(ak7wrt1[0].p4.DeltaR(ak7wrt2[0].p4) > 0.1) {
3029     ak7_matched.push_back(ak7wrt1[0]);
3030     ak7_matched.push_back(ak7wrt2[0]);
3031     }
3032     // else look at the second best
3033     else{
3034     // ak7wrt1 is best
3035     if( ak7wrt1[1].p4.DeltaR(vhCand.H.jets[0].p4) < ak7wrt2[1].p4.DeltaR(vhCand.H.jets[1].p4))
3036     {
3037     ak7_matched.push_back(ak7wrt1[1]);
3038     ak7_matched.push_back(ak7wrt2[0]);
3039     }
3040     else
3041     {
3042     ak7_matched.push_back(ak7wrt1[0]);
3043     ak7_matched.push_back(ak7wrt2[1]);
3044     }
3045     }
3046 arizzi 1.24 CompareJetPt ptComparator;
3047     std::sort( ak7_matched.begin(),ak7_matched.end(),ptComparator );
3048     if(ak7_matched[0].p4.DeltaR(vhCand.H.jets[0].p4) < 0.5
3049 arizzi 1.32 and ak7_matched[1].p4.DeltaR(vhCand.H.jets[1].p4) < 0.5)
3050     {
3051     deltaPullAngleAK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[0],ak7_matched[1]);
3052 arizzi 1.52 deltaPullAngle2AK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[1],ak7_matched[0]);
3053 arizzi 1.32 }
3054 arizzi 1.24 }
3055     }
3056 dlopes 1.73 }//HiggsFlag
3057 arizzi 1.3
3058 arizzi 1.122 // std::cout << "Fill" << std::endl;
3059 bortigno 1.30 _outTree->Fill();
3060 arizzi 1.4
3061 degrutto 1.69 }// closed event loop
3062 arizzi 1.1
3063 bortigno 1.30 std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
3064     inFile->Close();
3065     // close input file
3066     } // loop on files
3067 arizzi 1.1
3068    
3069 bortigno 1.30 std::cout << "Events: " << ievt <<std::endl;
3070     std::cout << "TotalCount: " << totalcount <<std::endl;
3071 arizzi 1.1
3072    
3073    
3074 bortigno 1.30 _outFile->cd();
3075 arizzi 1.1
3076 bortigno 1.30 _outTree->Write();
3077     _outFile->Write();
3078     _outFile->Close();
3079     return 0;
3080 arizzi 1.1 }
3081    
3082