ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.112
Committed: Fri Jan 25 22:02:53 2013 UTC (12 years, 3 months ago) by apana
Content type: text/plain
Branch: MAIN
Changes since 1.111: +14 -0 lines
Log Message:
Initialize nfathFilterJets variable properly; add additional filterjet variables

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    
59 arizzi 1.80 #define MAXJ 130
60     #define MAXL 110
61     #define MAXB 110
62     #define MAXT 160
63 degrutto 1.69 #define nMetUnc 24
64     //eleEnDown/Up, muEn, tauEn, JES, JER, Unclustered for type1 MET [0-11] and than type1p2 MET [12-23]
65 arizzi 1.1
66 arizzi 1.24 struct CompareDeltaR {
67 bortigno 1.30 CompareDeltaR(TLorentzVector p4dir_): p4dir(p4dir_) {}
68     bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
69     return j1.p4.DeltaR(p4dir) > j2.p4.DeltaR(p4dir);
70     }
71     TLorentzVector p4dir;
72 arizzi 1.24 };
73 arizzi 1.4
74 bortigno 1.30 const GlobalVector flightDirection(const TVector3 pv, const reco::Vertex &sv){
75     GlobalVector fdir(sv.position().X() - pv.X(),
76     sv.position().Y() - pv.Y(),
77     sv.position().Z() - pv.Z());
78     return fdir;
79     }
80    
81 nmohr 1.7 bool jsonContainsEvent (const std::vector< edm::LuminosityBlockRange > &jsonVec,
82     const edm::EventBase &event)
83     {
84 bortigno 1.30 // if the jsonVec is empty, then no JSON file was provided so all
85     // events should pass
86     if (jsonVec.empty())
87     {
88 nmohr 1.7 return true;
89 bortigno 1.30 }
90     bool (* funcPtr) (edm::LuminosityBlockRange const &,
91     edm::LuminosityBlockID const &) = &edm::contains;
92     edm::LuminosityBlockID lumiID (event.id().run(),
93     event.id().luminosityBlock());
94     std::vector< edm::LuminosityBlockRange >::const_iterator iter =
95     std::find_if (jsonVec.begin(), jsonVec.end(),
96     boost::bind(funcPtr, _1, lumiID) );
97     return jsonVec.end() != iter;
98 nmohr 1.7
99     }
100    
101 arizzi 1.64 float resolutionBias(float eta)
102     {
103     // return 0;//Nominal!
104     if(eta< 1.1) return 0.05;
105     if(eta< 2.5) return 0.10;
106     if(eta< 5) return 0.30;
107     return 0;
108     }
109    
110 arizzi 1.1
111 bortigno 1.74 typedef struct
112     {
113     void set(const SimBHadron & sbhc, int i){
114     mass[i] = sbhc.mass();
115     pt[i] = sbhc.pt();
116     eta[i] = sbhc.eta();
117     phi[i] = sbhc.phi();
118     vtx_x[i] = sbhc.decPosition.x();
119     vtx_y[i] = sbhc.decPosition.y();
120     vtx_z[i] = sbhc.decPosition.z();
121     pdgId[i] = sbhc.pdgId();
122     status[i] = sbhc.status();
123     };
124     void reset(){
125     for(int i=0; i < MAXB; ++i){
126     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;
127     }
128     };
129     float mass[MAXB];
130     float pt[MAXB];
131     float eta[MAXB];
132     float phi[MAXB];
133     float vtx_x[MAXB];
134     float vtx_y[MAXB];
135     float vtx_z[MAXB];
136     int pdgId[MAXB];
137     int status[MAXB];
138     // int quarkStatus[MAXB];
139     // int brotherStatus[MAXB];
140     // int otherId[MAXB];
141     // bool etaOk[MAXB];
142     // bool simOk[MAXB];
143     // bool trackOk[MAXB];
144     // bool cutOk[MAXB];
145     // bool cutNewOk[MAXB];
146     // bool mcMatchOk[MAXB];
147     // bool matchOk[MAXB];
148     } SimBHadronInfo;
149 bortigno 1.30
150    
151     typedef struct
152     {
153     void set( const reco::SecondaryVertex & recoSv, const TVector3 recoPv, int isv){
154     pt[isv] = recoSv.p4().Pt();
155     eta[isv] = flightDirection(recoPv,recoSv).eta();
156     phi[isv] = flightDirection(recoPv,recoSv).phi();
157     massBcand[isv] = recoSv.p4().M();
158     massSv[isv] = recoSv.p4().M();
159     dist3D[isv] = recoSv.dist3d().value();
160     distSig3D[isv] = recoSv.dist3d().significance();
161     dist2D[isv] = recoSv.dist2d().value();
162     distSig2D[isv] = recoSv.dist2d().significance();
163     dist3D_norm[isv] = recoSv.dist3d().value()/recoSv.p4().Gamma();
164     };
165     void reset(){
166     for(int i = 0; i < MAXB; ++i){
167     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;
168     }
169     };
170     float massBcand[MAXB];
171     float massSv[MAXB];
172     float pt[MAXB];
173     float eta[MAXB];
174     float phi[MAXB];
175     float dist3D[MAXB];
176     float distSig3D[MAXB];
177     float dist2D[MAXB];
178     float distSig2D[MAXB];
179     float dist3D_norm[MAXB];
180     } IVFInfo;
181 arizzi 1.1
182 bortigno 1.30
183     typedef struct
184     {
185 dlopes 1.73 int HiggsFlag;
186 arizzi 1.33 float mass;
187     float pt;
188     float eta;
189     float phi;
190     float dR;
191     float dPhi;
192     float dEta;
193     } HiggsInfo;
194 dlopes 1.73
195     typedef struct
196     {
197     int FatHiggsFlag;
198     float mass;
199     float pt;
200     float eta;
201     float phi;
202     float filteredmass;
203     float filteredpt;
204     float filteredeta;
205     float filteredphi;
206     // float dR;
207     // float dPhi;
208     // float dEta;
209     } FatHiggsInfo;
210    
211    
212 degrutto 1.69
213     typedef struct
214     {
215     float mass;
216     float pt;
217     float eta;
218     float phi;
219     float status;
220     float charge;
221     float momid;
222     } genParticleInfo;
223    
224    
225    
226     typedef struct
227    
228     {
229     float bmass;
230     float bpt;
231     float beta;
232     float bphi;
233     float bstatus;
234     float wdau1mass;
235     float wdau1pt;
236     float wdau1eta;
237     float wdau1phi;
238     float wdau1id;
239     float wdau2mass;
240     float wdau2pt;
241     float wdau2eta;
242     float wdau2phi;
243     float wdau2id;
244    
245    
246     } genTopInfo;
247    
248    
249 dlopes 1.67
250    
251 malbouis 1.71 typedef struct
252     {
253     bool HiggsCSVtkSharing;
254     bool HiggsIPtkSharing;
255     bool HiggsSVtkSharing;
256     bool FatHiggsCSVtkSharing;
257     bool FatHiggsIPtkSharing;
258     bool FatHiggsSVtkSharing;
259     } TrackSharingInfo;
260    
261 arizzi 1.33 typedef struct
262     {
263 bortigno 1.30 float mass; //MT in case of W
264     float pt;
265     float eta;
266     float phi;
267     } TrackInfo;
268 arizzi 1.1
269    
270 arizzi 1.9 struct LeptonInfo
271 bortigno 1.30 {
272     void reset()
273 arizzi 1.1 {
274 arizzi 1.48 for(int i =0; i < MAXL;i++){
275 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;
276     id80[i]=-99; id95[i]=-99; vbtf[i]=-99; id80NoIso[i]=-99;
277 arizzi 1.85 charge[i]=-99;wp70[i]=-99; wp80[i]=-99;wp85[i]=-99;wp90[i]=-99;wp95[i]=-99;wpHWW[i]=-99;
278 arizzi 1.87 pfCorrIso[i]=-99.; id2012tight[i]=-99; idMVAnotrig[i]=-99; idMVAtrig[i]=-99;innerHits[i]=-99.;
279 arizzi 1.83
280 arizzi 1.48 }
281 bortigno 1.30 }
282 arizzi 1.1
283 arizzi 1.82 template <class Input> void set(const Input & i, int j,int t,const VHbbEventAuxInfo & aux)
284 bortigno 1.30 {
285     type[j]=t;
286     pt[j]=i.p4.Pt();
287     mass[j]=i.p4.M();
288     eta[j]=i.p4.Eta();
289     phi[j]=i.p4.Phi();
290     aodCombRelIso[j]=(i.hIso+i.eIso+i.tIso)/i.p4.Pt();
291 arizzi 1.83 pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
292 bortigno 1.30 photonIso[j]=i.pfPhoIso;
293     neutralHadIso[j]=i.pfNeuIso;
294     chargedHadIso[j]=i.pfChaIso;
295 dlopes 1.55 chargedPUIso[j]=i.pfChaPUIso;
296 degrutto 1.69 charge[j]=i.charge;
297 arizzi 1.64 if(i.mcFourMomentum.Pt() > 0)
298     {
299     genPt[j]=i.mcFourMomentum.Pt();
300     genEta[j]=i.mcFourMomentum.Eta();
301     genPhi[j]=i.mcFourMomentum.Phi();
302     }
303 arizzi 1.82 setSpecific(i,j,aux);
304 bortigno 1.30 }
305 arizzi 1.82 template <class Input> void setSpecific(const Input & i, int j,const VHbbEventAuxInfo & aux)
306 bortigno 1.30 {
307     }
308 arizzi 1.4
309    
310    
311 arizzi 1.1
312 bortigno 1.30 float mass[MAXL]; //MT in case of W
313     float pt[MAXL];
314     float eta[MAXL];
315     float phi[MAXL];
316     float aodCombRelIso[MAXL];
317     float pfCombRelIso[MAXL];
318     float photonIso[MAXL];
319     float neutralHadIso[MAXL];
320     float chargedHadIso[MAXL];
321 dlopes 1.55 float chargedPUIso[MAXL];
322 bortigno 1.30 float particleIso[MAXL];
323 arizzi 1.64 float genPt[MAXL];
324     float genEta[MAXL];
325     float genPhi[MAXL];
326 bortigno 1.30 float dxy[MAXL];
327     float dz[MAXL];
328     int type[MAXL];
329     float id80[MAXL];
330     float id95[MAXL];
331 arizzi 1.48 float vbtf[MAXL];
332 arizzi 1.64 float id80NoIso[MAXL];
333 degrutto 1.69 float charge[MAXL];
334 arizzi 1.82 float pfCorrIso[MAXL];
335     float id2012tight[MAXL];
336     float idMVAnotrig[MAXL];
337     float idMVAtrig[MAXL];
338 arizzi 1.95 float idMVApresel[MAXL];
339 arizzi 1.85 float wp70[MAXL];
340     float wp80[MAXL];
341     float wp85[MAXL];
342     float wp90[MAXL];
343     float wp95[MAXL];
344 arizzi 1.87 float wpHWW[MAXL];
345     float innerHits[MAXL];
346     float photonIsoDoubleCount[MAXL];
347 bortigno 1.30 };
348 arizzi 1.1
349 arizzi 1.82 template <> void LeptonInfo::setSpecific<VHbbEvent::ElectronInfo>(const VHbbEvent::ElectronInfo & i, int j,const VHbbEventAuxInfo & aux){
350 arizzi 1.87 photonIsoDoubleCount[j]=i.pfPhoIsoDoubleCounted;
351 arizzi 1.36 id80[j]=i.id80;
352     id95[j]=i.id95;
353 arizzi 1.64 id80NoIso[j]=(i.innerHits ==0 && !(fabs(i.convDist)<0.02 && fabs(i.convDcot)<0.02) &&
354     ((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)));
355 arizzi 1.87 innerHits[j]=i.innerHits;
356 arizzi 1.82 float mincor=0.0;
357     float minrho=0.0;
358 arizzi 1.99 float rho = std::max(aux.puInfo.rho25Iso,minrho);
359 arizzi 1.82 float eta=i.p4.Eta();
360     float areagamma=0.5;
361     float areaNH=0.5;
362     float areaComb=0.5;
363 arizzi 1.100
364     if(fabs(eta) <= 1.0 ) {areagamma=0.14; areaNH=0.044; areaComb=0.18;}
365     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.13; areaNH=0.065; areaComb=0.20;}
366     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.079; areaNH=0.068; areaComb=0.15;}
367     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.13; areaNH=0.057; areaComb=0.19;}
368     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.15; areaNH=0.058; areaComb=0.21;}
369     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.16; areaNH=0.061; areaComb=0.22;}
370     if(fabs(eta) > 2.4 ) {areagamma=0.18; areaNH=0.11; areaComb=0.29;}
371     /*
372 arizzi 1.82 if(fabs(eta) <= 1.0 ) {areagamma=0.081; areaNH=0.024; areaComb=0.10;}
373     if(fabs(eta) > 1.0 && fabs(eta) <= 1.479 ) {areagamma=0.084; areaNH=0.037; areaComb=0.12;}
374     if(fabs(eta) > 1.479 && fabs(eta) <= 2.0 ) {areagamma=0.048; areaNH=0.037; areaComb=0.085;}
375     if(fabs(eta) > 2.0 && fabs(eta) <= 2.2 ) {areagamma=0.089; areaNH=0.023; areaComb=0.11;}
376     if(fabs(eta) > 2.2 && fabs(eta) <= 2.3 ) {areagamma=0.092; areaNH=0.023; areaComb=0.12;}
377     if(fabs(eta) > 2.3 && fabs(eta) <= 2.4 ) {areagamma=0.097; areaNH=0.021; areaComb=0.12;}
378     if(fabs(eta) > 2.4 ) {areagamma=0.11; areaNH=0.021; areaComb=0.13;}
379 arizzi 1.100 */
380 arizzi 1.82
381 arizzi 1.87 float pho=i.pfPhoIso;
382     if(i.innerHits>0)
383     {
384     pho-=i.pfPhoIsoDoubleCounted;
385     }
386 arizzi 1.82
387 sethzenz 1.97 pfCorrIso[j] = (i.pfChaIso+ std::max(pho-rho*areagamma,mincor )+std::max(i.pfNeuIso-rho*areaNH,mincor))/i.p4.Pt();
388 arizzi 1.82
389     id2012tight[j] = fabs(i.dxy) < 0.02 &&fabs(i.dz) < 0.1 &&(
390     (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
391     ) ||
392     (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
393     ));
394 arizzi 1.92
395     bool mvaPreSel = (
396     (i.isEE &&
397     //fabs(electrons[it].Deta) < 0.009 &&
398     //fabs(electrons[it].Dphi) < 0.1 &&
399     i.sihih < 0.03 &&
400     i.HoE < 0.10 &&
401     i.innerHits == 0 &&
402     i.tIso/i.p4.Pt() < 0.2 &&
403     i.eIso/i.p4.Pt() < 0.2 &&
404     i.hIso/i.p4.Pt() < 0.2)
405     ||
406     (i.isEB &&
407     //fabs(electrons[it].Deta) < 0.007 &&
408     //fabs(electrons[it].Dphi) < 0.015 &&
409     i.sihih < 0.01 &&
410     i.HoE < 0.12 &&
411     i.innerHits == 0 &&
412     i.tIso/i.p4.Pt() < 0.2 &&
413     i.eIso/i.p4.Pt() < 0.2 &&
414     i.hIso/i.p4.Pt() < 0.2)
415     );
416    
417 arizzi 1.85 float id=i.mvaOutTrig;
418 arizzi 1.92 if(!mvaPreSel) id=0;
419 arizzi 1.85 float iso=pfCorrIso[j];
420     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));
421     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));
422     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));
423     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));
424     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));
425     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));
426 arizzi 1.82
427     idMVAnotrig[j]=i.mvaOut;
428     idMVAtrig[j]=i.mvaOutTrig;
429 arizzi 1.95 idMVApresel[j]=mvaPreSel;
430 arizzi 1.82
431 bortigno 1.30 }
432 arizzi 1.82 template <> void LeptonInfo::setSpecific<VHbbEvent::MuonInfo>(const VHbbEvent::MuonInfo & i, int j,const VHbbEventAuxInfo & aux){
433 bortigno 1.30 dxy[j]=i.ipDb;
434     dz[j]=i.zPVPt;
435 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 &&
436     (i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt()<.15 && fabs(i.p4.Eta())<2.4 && i.p4.Pt()>20 ) ;
437 arizzi 1.82 float mincor=0.0;
438     float minrho=0.0;
439     float rhoN = std::max(aux.puInfo.rhoNeutral,minrho);
440     float eta=i.p4.Eta();
441     float area=0.5;
442     if(fabs(eta)>0.0 && fabs(eta) <= 1.0) {area=0.674;}
443     if(fabs(eta)>1.0 && fabs(eta) <= 1.5) {area=0.565;}
444     if(fabs(eta)>1.5 && fabs(eta) <= 2.0) {area=0.442;}
445     if(fabs(eta)>2.0 && fabs(eta) <= 2.2) {area=0.515;}
446     if(fabs(eta)>2.2 && fabs(eta) <= 2.3) {area=0.821;}
447     if(fabs(eta)>2.3 && fabs(eta) <= 2.4) {area=0.660;}
448 arizzi 1.83 pfCorrIso[j] = (i.pfChaIso+ std::max(i.pfPhoIso+i.pfNeuIso-rhoN*area,mincor))/i.p4.Pt();
449 arizzi 1.82 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;
450    
451 arizzi 1.48
452 bortigno 1.30 }
453    
454 arizzi 1.4
455 bortigno 1.30 typedef struct
456     {
457     float et;
458     float sumet;
459     float sig;
460     float phi;
461     } METInfo;
462 degrutto 1.69
463    
464     typedef struct
465     {
466    
467     float et[nMetUnc]; float phi[nMetUnc]; float sumet[nMetUnc];
468     template <class Input> void set(const Input & i, int j)
469     {
470     et[j]=i.p4.Pt();
471     phi[j]=i.p4.Phi();
472     sumet[j]=i.sumEt;
473    
474     }
475     } METUncInfo ;
476    
477 arizzi 1.1
478 bortigno 1.30 typedef struct
479     {
480     float mht;
481     float ht;
482     float sig;
483     float phi;
484     } MHTInfo;
485 nmohr 1.5
486 bortigno 1.30 typedef struct
487     {
488     float mass;
489     float pt;
490     float wMass;
491     } TopInfo;
492 arizzi 1.1
493 bortigno 1.30 typedef struct
494     {
495     int run;
496     int lumi;
497     int event;
498     int json;
499     } EventInfo;
500 arizzi 1.98
501    
502     BTagShapeInterface * nominalShape=0;
503     BTagShapeInterface * downBCShape=0;
504     BTagShapeInterface * upBCShape=0;
505     BTagShapeInterface * downLShape=0;
506     BTagShapeInterface * upLShape=0;
507    
508 arizzi 1.110 BTagShapeInterface * nominalShape4p=0;
509     BTagShapeInterface * downBCShape4p=0;
510     BTagShapeInterface * upBCShape4p=0;
511 bortigno 1.30 typedef struct
512     {
513     void set(const VHbbEvent::SimpleJet & j, int i)
514 arizzi 1.1 {
515 bortigno 1.30 pt[i]=j.p4.Pt();
516     eta[i]=j.p4.Eta();
517     phi[i]=j.p4.Phi();
518 arizzi 1.51 e[i]=j.p4.E();
519 bortigno 1.30 csv[i]=j.csv;
520 arizzi 1.98 if(nominalShape)
521     {
522     csv_nominal[i]=nominalShape->reshape(eta[i],pt[i],j.csv,j.flavour);
523     csv_upBC[i]=upBCShape->reshape(eta[i],pt[i],j.csv,j.flavour);
524     csv_downBC[i]=downBCShape->reshape(eta[i],pt[i],j.csv,j.flavour);
525     csv_upL[i]=upLShape->reshape(eta[i],pt[i],j.csv,j.flavour);
526     csv_downL[i]=downLShape->reshape(eta[i],pt[i],j.csv,j.flavour);
527 arizzi 1.110 csv_nominal4p[i]=nominalShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
528     csv_upBC4p[i]=upBCShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
529     csv_downBC4p[i]=downBCShape4p->reshape(eta[i],pt[i],j.csv,j.flavour);
530 arizzi 1.98 }
531     else
532     {
533     csv_nominal[i]=csv[i];
534     csv_downBC[i]=csv[i];
535     csv_upBC[i]=csv[i];
536     csv_downL[i]=csv[i];
537     csv_upL[i]=csv[i];
538 arizzi 1.110 csv_nominal4p[i]=csv[i];
539     csv_downBC4p[i]=csv[i];
540     csv_upBC4p[i]=csv[i];
541 arizzi 1.98 }
542 arizzi 1.70 csvivf[i]=j.csvivf;
543     cmva[i]=j.cmva;
544     numTracksSV[i] = j.vtxNTracks;
545 bortigno 1.30 vtxMass[i]= j.vtxMass;
546 dlopes 1.73 vtxPt[i]= j.vtxP4.Pt();
547 arizzi 1.111 if(j.vtxP4.Pt() > 0) vtxEta[i]= j.vtxP4.Eta(); else vtxEta[i]=-99;
548 dlopes 1.73 vtxPhi[i]= j.vtxP4.Phi();
549     vtxE[i]= j.vtxP4.E();
550 bortigno 1.30 vtx3dL[i] = j.vtx3dL;
551     vtx3deL[i] = j.vtx3deL;
552     chf[i]=j.chargedHadronEFraction;
553     nhf[i] =j.neutralHadronEFraction;
554     cef[i] =j.chargedEmEFraction;
555     nef[i] =j.neutralEmEFraction;
556     nconstituents[i] =j.nConstituents;
557     nch[i]=j.ntracks;
558 arizzi 1.64 SF_CSVL[i]=j.SF_CSVL;
559     SF_CSVM[i]=j.SF_CSVM;
560     SF_CSVT[i]=j.SF_CSVT;
561     SF_CSVLerr[i]=j.SF_CSVLerr;
562     SF_CSVMerr[i]=j.SF_CSVMerr;
563     SF_CSVTerr[i]=j.SF_CSVTerr;
564 bortigno 1.30
565     flavour[i]=j.flavour;
566 degrutto 1.66 isSemiLeptMCtruth[i]=j.isSemiLeptMCtruth;
567     isSemiLept[i]=j.isSemiLept;
568 degrutto 1.68 SoftLeptpdgId[i] = j.SoftLeptpdgId;
569     SoftLeptIdlooseMu[i] = j.SoftLeptIdlooseMu;
570     SoftLeptId95[i] = j.SoftLeptId95;
571     SoftLeptPt[i] = j.SoftLeptPt;
572     SoftLeptdR[i] = j.SoftLeptdR;
573     SoftLeptptRel[i] = j.SoftLeptptRel;
574     SoftLeptRelCombIso[i] = j.SoftLeptRelCombIso;
575 bortigno 1.30 if(j.bestMCp4.Pt() > 0)
576     {
577     genPt[i]=j.bestMCp4.Pt();
578     genEta[i]=j.bestMCp4.Eta();
579     genPhi[i]=j.bestMCp4.Phi();
580     }
581     JECUnc[i]=j.jecunc;
582 arizzi 1.36 id[i]=jetId(i);
583 dlopes 1.73 ptRaw[i]=j.ptRaw;
584     ptLeadTrack[i]=j.ptLeadTrack;
585 degrutto 1.86 puJetIdL[i]=j.puJetIdL;
586     puJetIdM[i]=j.puJetIdM;
587     puJetIdT[i]=j.puJetIdT;
588     puJetIdMva[i]=j.puJetIdMva;
589 mooney 1.105 charge[i]=j.charge;
590 cboeser 1.107 jetArea[i]=j.jetArea;
591    
592     }
593 dlopes 1.73
594 arizzi 1.36 bool jetId(int i)
595     {
596     if(nhf[i] > 0.99) return false;
597     if(nef[i] > 0.99) return false;
598 arizzi 1.37 if(nconstituents[i] <= 1) return false;
599 arizzi 1.47 if(fabs(eta[i])<2.5) {
600 arizzi 1.36 if(cef[i] > 0.99) return false;
601 arizzi 1.37 if(chf[i] == 0) return false;
602 arizzi 1.36 if(nch[i]== 0) return false;
603 arizzi 1.37 }
604 arizzi 1.36 return true;
605 bortigno 1.30 }
606     void reset()
607     {
608     for(int i=0;i<MAXJ;i++) {
609 arizzi 1.98 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.;
610 dlopes 1.73 csvivf[i]=-99; cmva[i]=-99;
611     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;
612     SoftLeptpdgId[i] = -99; SoftLeptIdlooseMu[i] = -99; SoftLeptId95[i] = -99; SoftLeptPt[i] = -99; SoftLeptdR[i] = -99; SoftLeptptRel[i] = -99; SoftLeptRelCombIso[i] = -99;
613 cboeser 1.107 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;
614 arizzi 1.1 }
615 bortigno 1.30 }
616     float pt[MAXJ];
617     float eta[MAXJ];
618     float phi[MAXJ];
619 arizzi 1.51 float e[MAXJ];
620 bortigno 1.30 float csv[MAXJ];
621 arizzi 1.98 float csv_nominal[MAXJ];
622     float csv_upBC[MAXJ];
623     float csv_downBC[MAXJ];
624     float csv_upL[MAXJ];
625     float csv_downL[MAXJ];
626 arizzi 1.110 float csv_nominal4p[MAXJ];
627     float csv_upBC4p[MAXJ];
628     float csv_downBC4p[MAXJ];
629 arizzi 1.70 float csvivf[MAXJ];
630     float cmva[MAXJ];
631 bortigno 1.30 float cosTheta[MAXJ];
632     int numTracksSV[MAXJ];
633     float chf[MAXJ];
634     float nhf[MAXJ];
635     float cef[MAXJ];
636     float nef[MAXJ];
637     float nch[MAXJ];
638     float nconstituents[MAXJ];
639     float flavour[MAXJ];
640 degrutto 1.68 int isSemiLept[MAXJ];
641     int isSemiLeptMCtruth[MAXJ];
642     int SoftLeptpdgId[MAXJ] ;
643     int SoftLeptIdlooseMu[MAXJ] ;
644     int SoftLeptId95[MAXJ] ;
645     float SoftLeptPt[MAXJ] ;
646     float SoftLeptdR[MAXJ] ;
647     float SoftLeptptRel[MAXJ] ;
648     float SoftLeptRelCombIso[MAXJ];
649 bortigno 1.30 float genPt[MAXJ];
650     float genEta[MAXJ];
651     float genPhi[MAXJ];
652     float JECUnc[MAXJ];
653     float vtxMass[MAXJ];
654 dlopes 1.73 float vtxPt[MAXJ];
655     float vtxEta[MAXJ];
656     float vtxPhi[MAXJ];
657     float vtxE[MAXJ];
658 bortigno 1.30 float vtx3dL [MAXJ];
659     float vtx3deL[MAXJ];
660 arizzi 1.36 bool id[MAXJ];
661 arizzi 1.64 float SF_CSVL[MAXJ];
662     float SF_CSVM[MAXJ];
663     float SF_CSVT[MAXJ];
664     float SF_CSVLerr[MAXJ];
665     float SF_CSVMerr[MAXJ];
666     float SF_CSVTerr[MAXJ];
667 dlopes 1.73 float ptRaw[MAXJ];
668     float ptLeadTrack[MAXJ];
669 degrutto 1.86 float puJetIdL[MAXJ];
670     float puJetIdM[MAXJ];
671     float puJetIdT[MAXJ];
672     float puJetIdMva[MAXJ];
673 mooney 1.105 float charge[MAXJ];
674 cboeser 1.107 float jetArea[MAXJ];
675 bortigno 1.30 } JetInfo;
676 arizzi 1.1
677     int main(int argc, char* argv[])
678     {
679     gROOT->Reset();
680    
681     TTree *_outTree;
682 bortigno 1.30 IVFInfo IVF;
683 bortigno 1.74 SimBHadronInfo SimBs;
684 arizzi 1.82 float rho,rho25,rhoN;
685 arizzi 1.39 int nPVs;
686 arizzi 1.9 METInfo MET;
687 arizzi 1.52 METInfo fakeMET;
688 arizzi 1.36 METInfo METnoPU;
689 arizzi 1.58 METInfo METnoPUCh;
690 degrutto 1.69 METInfo METtype1corr;
691     METInfo METtype1p2corr;
692     METInfo METnoPUtype1corr;
693     METInfo METnoPUtype1p2corr;
694    
695 arizzi 1.9 MHTInfo MHT;
696 degrutto 1.69
697     METUncInfo metUnc;
698    
699    
700 arizzi 1.9 TopInfo top;
701     EventInfo EVENT;
702 bortigno 1.30 // JetInfo jet1,jet2, addJet1, addJet2;
703 arizzi 1.9 // lepton1,lepton2;
704 dlopes 1.73 JetInfo hJets, aJets, fathFilterJets, aJetsFat;
705 arizzi 1.9 LeptonInfo vLeptons, aLeptons;
706 dlopes 1.73 int naJets=0, nhJets=0, nfathFilterJets=0, naJetsFat=0;
707 bortigno 1.74 HiggsInfo H,SVH,SimBsH;
708 dlopes 1.67 FatHiggsInfo FatH;
709 degrutto 1.69 genParticleInfo genZ, genZstar, genWstar, genW, genH, genB, genBbar; //add here the fatjet higgs
710     genTopInfo genTop, genTbar;
711 arizzi 1.9 TrackInfo V;
712     int nvlep=0,nalep=0;
713 bortigno 1.79 float lheV_pt=0; //for the Madgraph sample stitching
714 bortigno 1.90 float lheHT=0; //for the Madgraph sample stitching
715     float lheNj=0; //for the Madgraph sample stitching
716 malbouis 1.71 TrackSharingInfo TkSharing; // track sharing info;
717 degrutto 1.54
718 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;
719 arizzi 1.62 float PU0,PUp1,PUm1;
720 degrutto 1.54
721 arizzi 1.60 float weightEleRecoAndId,weightEleTrigJetMETPart, weightEleTrigElePart,weightEleTrigEleAugPart;
722 arizzi 1.64 float weightTrigMET80, weightTrigMET100, weightTrig2CJet20 , weightTrigMET150 , weightTrigMET802CJet, weightTrigMET1002CJet, weightTrigMETLP ;
723 arizzi 1.24
724 arizzi 1.89 float weightTrig2012A, weightTrig2012ADiMuon, weightTrig2012ADiEle, weightTrig2012ASingleMuon, weightTrig2012AMuonPlusWCandPt, weightTrig2012ASingleEle;
725 arizzi 1.110 float weightTrig2012AB, weightTrig2012ABDiMuon, weightTrig2012ABDiEle, weightTrig2012ABSingleMuon, weightTrig2012ABMuonPlusWCandPt, weightTrig2012ABSingleEle;
726     float weightTrig2012, weightTrig2012DiMuon, weightTrig2012DiEle, weightTrig2012SingleMuon, weightTrig2012MuonPlusWCandPt, weightTrig2012SingleEle;
727 arizzi 1.89
728 arizzi 1.92 float weightTrig2012DiJet30MHT80,weightTrig2012PFMET150,weightTrig2012SumpT100MET100;
729 degrutto 1.108 float weightTrig2012APFMET150orDiJetMET, weightTrig2012BPFMET150orDiJetMET, weightTrig2012CPFMET150orDiJetMET;
730 arizzi 1.92
731    
732 arizzi 1.49 int WplusMode,WminusMode;
733 arizzi 1.84 int Vtype,nSvs=0;
734     int nSimBs=0;
735     int numJets,numBJets,eventFlav;
736 bortigno 1.30 // bool isMET80_CJ80, ispfMHT150, isMET80_2CJ20,isMET65_2CJ20, isJETID,isIsoMu17;
737 degrutto 1.104 bool triggerFlags[500],hbhe,ecalFlag,totalKinematics, cschaloFlag, hcallaserFlag, trackingfailureFlag , eebadscFlag ;
738 degrutto 1.69
739    
740 arizzi 1.60 float btag1T2CSF=1.,btag2TSF=1.,btag1TSF=1.,btagA0CSF=1., btagA0TSF=1., btag2CSF=1., btag1TA1C=1.;
741 arizzi 1.1 // ----------------------------------------------------------------------
742     // First Part:
743     //
744     // * enable the AutoLibraryLoader
745     // * book the histograms of interest
746     // * open the input file
747     // ----------------------------------------------------------------------
748    
749     // load framework libraries
750 bortigno 1.30 gSystem->Load("libFWCoreFWLite");
751 arizzi 1.1 gSystem->Load("libDataFormatsFWLite");
752     AutoLibraryLoader::enable();
753    
754     // parse arguments
755     if ( argc < 2 ) {
756     return 0;
757     }
758    
759 arizzi 1.4 std::vector<VHbbCandidate> * candZlocal = new std::vector<VHbbCandidate>;
760     std::vector<VHbbCandidate> * candWlocal = new std::vector<VHbbCandidate>;
761    
762 arizzi 1.1 // get the python configuration
763     PythonProcessDesc builder(argv[1]);
764     const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
765     const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
766     const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
767 bortigno 1.30
768 nmohr 1.7 std::vector<edm::LuminosityBlockRange> jsonVector;
769     if ( in.exists("lumisToProcess") )
770 bortigno 1.30 {
771     std::vector<edm::LuminosityBlockRange> const & lumisTemp =
772     in.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> > ("lumisToProcess");
773 nmohr 1.7 jsonVector.resize( lumisTemp.size() );
774     copy( lumisTemp.begin(), lumisTemp.end(), jsonVector.begin() );
775 bortigno 1.30 }
776 arizzi 1.1
777     // now get each parameter
778     int maxEvents_( in.getParameter<int>("maxEvents") );
779 nmohr 1.29 int skipEvents_( in.getParameter<int>("skipEvents") );
780 arizzi 1.64 int runMin_( in.getParameter<int>("runMin") );
781     int runMax_( in.getParameter<int>("runMax") );
782 arizzi 1.1 unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
783     std::string outputFile_( out.getParameter<std::string>("fileName" ) );
784     std::vector<std::string> triggers( ana.getParameter<std::vector<std::string> >("triggers") );
785 arizzi 1.6 double btagThr = ana.getParameter<double>("bJetCountThreshold" );
786 arizzi 1.4 bool fromCandidate = ana.getParameter<bool>("readFromCandidates");
787 arizzi 1.17 bool useHighestPtHiggsZ = ana.getParameter<bool>("useHighestPtHiggsZ");
788     bool useHighestPtHiggsW = ana.getParameter<bool>("useHighestPtHiggsW");
789 nmohr 1.31 HbbCandidateFinderAlgo * algoZ = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdZ"),useHighestPtHiggsZ);
790     HbbCandidateFinderAlgo * algoW = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdW"),useHighestPtHiggsW );
791 arizzi 1.64 HbbCandidateFinderAlgo * algoRecoverLowPt = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), 15, true);
792 arizzi 1.4
793 arizzi 1.16 TriggerWeight triggerWeight(ana);
794 arizzi 1.110
795     const edm::ParameterSet& anaAB = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer2012ABOnly");
796     TriggerWeight triggerWeightAB(anaAB);
797    
798 arizzi 1.17 BTagWeight btag(2); // 2 operating points "Custom" = 0.5 and "Tight = 0.898"
799     BTagSampleEfficiency btagEff( ana.getParameter<std::string>("btagEffFileName" ).c_str() );
800 arizzi 1.1
801     std::vector<std::string> inputFiles_( in.getParameter<std::vector<std::string> >("fileNames") );
802 bortigno 1.30 // std::string inputFile( in.getParameter<std::string> ("fileName") );
803 arizzi 1.1
804 arizzi 1.3 std::string PUmcfileName_ = in.getParameter<std::string> ("PUmcfileName") ;
805 degrutto 1.57 std::string PUmcfileName2011B_ = in.getParameter<std::string> ("PUmcfileName2011B") ;
806    
807 arizzi 1.111 std::string PUdatafileNameAB = in.getParameter<std::string> ("PUdatafileNameAB") ;
808 arizzi 1.3 std::string PUdatafileName_ = in.getParameter<std::string> ("PUdatafileName") ;
809 arizzi 1.110 std::string PUdatafileName_plusOneSigma = in.getParameter<std::string> ("PUdatafileNamePlus") ;
810     std::string PUdatafileName_minusOneSigma = in.getParameter<std::string> ("PUdatafileNameMinus") ;
811 degrutto 1.54 std::string PUdatafileName2011B_ = in.getParameter<std::string> ("PUdatafileName2011B") ;
812 arizzi 1.63 std::string Weight3DfileName_ = in.getParameter<std::string> ("Weight3DfileName") ;
813 arizzi 1.98
814 arizzi 1.93 JECFWLite jec(ana.getParameter<std::string>("jecFolder"));
815 degrutto 1.54
816 arizzi 1.1 bool isMC_( ana.getParameter<bool>("isMC") );
817 arizzi 1.109 TriggerReader trigger(false);
818 degrutto 1.86 TriggerReader patFilters(false);
819 arizzi 1.98 if(isMC_)
820     {
821     nominalShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0);
822     upBCShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 1.5, 0.0);
823     downBCShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), -1.5, 0.0);
824     upLShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 1.0);
825     downLShape = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, -1.0);
826 arizzi 1.110 nominalShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.003,1.003);
827     upBCShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.001,1.001);
828     downBCShape4p = new BTagShapeInterface(ana.getParameter<std::string>("csvDiscr").c_str(), 0.0, 0.0,true,1.005,1.005);
829 arizzi 1.98 }
830 arizzi 1.111 edm::LumiReWeighting lumiWeights,lumiWeightsPl,lumiWeightsMi,lumiWeightsAB;
831 arizzi 1.89 edm::LumiReWeighting lumiWeights1DObs;
832 arizzi 1.103 // edm::Lumi3DReWeighting lumiWeights2011B;
833 arizzi 1.25 if(isMC_)
834 bortigno 1.30 {
835 arizzi 1.34 lumiWeights = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
836 arizzi 1.110 lumiWeightsPl = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_plusOneSigma , "pileup", "pileup");
837     lumiWeightsMi = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_minusOneSigma , "pileup", "pileup");
838 arizzi 1.111 lumiWeightsAB = edm::LumiReWeighting(PUmcfileName_,PUdatafileNameAB , "pileup", "pileup");
839 arizzi 1.89 lumiWeights1DObs = edm::LumiReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
840 degrutto 1.54
841 arizzi 1.103 // lumiWeights2011B = edm::Lumi3DReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
842     // if(Weight3DfileName_!="")
843     // { lumiWeights2011B.weight3D_init(Weight3DfileName_.c_str()); }
844     // else
845     // {
846     // lumiWeights2011B.weight3D_init(1.0); // generate the weights the fisrt time;
847     // }
848 degrutto 1.54
849 bortigno 1.30 }
850 arizzi 1.1
851 bortigno 1.30 // TFile *_outPUFile = new TFile((outputFile_+"_PU").c_str(), "recreate");
852     TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
853     TH1F * count = new TH1F("Count","Count", 1,0,2 );
854     TH1F * countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
855 arizzi 1.110 TH1F * countWithPUP = new TH1F("CountWithPUP","CountWithPU plus one sigma", 1,0,2 );
856     TH1F * countWithPUM = new TH1F("CountWithPUM","CountWithPU minus one sigma", 1,0,2 );
857 arizzi 1.111 TH1F * countWithPUAB = new TH1F("CountWithPUAB","CountWithPU 2012AB", 1,0,2 );
858    
859 arizzi 1.58 TH1F * countWithPU2011B = new TH1F("CountWithPU2011B","CountWithPU2011B", 1,0,2 );
860 arizzi 1.62 TH3F * input3DPU = new TH3F("Input3DPU","Input3DPU", 36,-0.5,35.5,36,-0.5,35.5, 36,-0.5,35.5 );
861 arizzi 1.58
862 arizzi 1.41 TH1F * pu = new TH1F("pileup","",51,-0.5,50.5);
863 arizzi 1.1 _outTree = new TTree("tree", "myTree");
864    
865 bortigno 1.75 _outTree->Branch("H" , &H , "HiggsFlag/I:mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
866     _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
867     _outTree->Branch("FatH" , &FatH , "FatHiggsFlag/I:mass/F:pt/F:eta:phi/F:filteredmass/F:filteredpt/F:filteredeta/F:filteredphi/F");
868     _outTree->Branch("lheV_pt" , &lheV_pt , "lheV_pt/F");
869 bortigno 1.90 _outTree->Branch("lheHT" , &lheHT , "lheHT/F");
870     _outTree->Branch("lheNj" , &lheNj , "lheNj/F");
871 degrutto 1.69 _outTree->Branch("genZ" , &genZ , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
872     _outTree->Branch("genZstar" , &genZstar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
873     _outTree->Branch("genW" , &genW , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
874     _outTree->Branch("genWstar" , &genWstar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
875     _outTree->Branch("genH" , &genH , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
876     _outTree->Branch("genB" , &genB , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
877     _outTree->Branch("genBbar" , &genBbar , "mass/F:pt/F:eta:phi/F:status/F:charge:momid/F");
878    
879     _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");
880     _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");
881    
882 malbouis 1.71 _outTree->Branch("TkSharing", &TkSharing, "HiggsCSVtkSharing/b:HiggsIPtkSharing:HiggsSVtkSharing:FatHiggsCSVtkSharing:FatHiggsIPtkSharing:FatHiggsSVtkSharing");
883 degrutto 1.69
884 arizzi 1.1 _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
885 dlopes 1.67 _outTree->Branch("nfathFilterJets", &nfathFilterJets, "nfathFilterJets/I");
886 arizzi 1.1 _outTree->Branch("naJets" , &naJets , "naJets/I");
887 arizzi 1.2
888 degrutto 1.69
889    
890 arizzi 1.2 _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
891     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
892     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
893 arizzi 1.51 _outTree->Branch("hJet_e",hJets.e ,"e[nhJets]/F");
894 arizzi 1.2 _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
895 arizzi 1.98 _outTree->Branch("hJet_csv_nominal",hJets.csv_nominal ,"csv_nominal[nhJets]/F");
896     _outTree->Branch("hJet_csv_upBC",hJets.csv_upBC ,"csv_upBC[nhJets]/F");
897     _outTree->Branch("hJet_csv_downBC",hJets.csv_downBC ,"csv_downBC[nhJets]/F");
898     _outTree->Branch("hJet_csv_upL",hJets.csv_upL ,"csv_upL[nhJets]/F");
899     _outTree->Branch("hJet_csv_downL",hJets.csv_downL ,"csv_downL[nhJets]/F");
900 arizzi 1.110 _outTree->Branch("hJet_csv_nominal4p",hJets.csv_nominal4p ,"csv_nominal4p[nhJets]/F");
901     _outTree->Branch("hJet_csv_upBC4p",hJets.csv_upBC4p ,"csv_upBC4p[nhJets]/F");
902     _outTree->Branch("hJet_csv_downBC4p",hJets.csv_downBC4p ,"csv_downBC4p[nhJets]/F");
903 arizzi 1.98
904 arizzi 1.70 _outTree->Branch("hJet_csvivf",hJets.csvivf ,"csvivf[nhJets]/F");
905     _outTree->Branch("hJet_cmva",hJets.cmva ,"cmva[nhJets]/F");
906 arizzi 1.2 _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
907     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
908     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
909     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
910     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
911     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
912     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
913     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
914     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
915 degrutto 1.68 _outTree->Branch("hJet_isSemiLept",hJets.isSemiLept ,"isSemiLept[nhJets]/I");
916     _outTree->Branch("hJet_isSemiLeptMCtruth",hJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[nhJets]/I");
917     _outTree->Branch("hJet_SoftLeptpdgId", hJets.SoftLeptpdgId , "SoftLeptpdgId[nhJets]/I");
918     _outTree->Branch("hJet_SoftLeptIdlooseMu", hJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[nhJets]/I");
919     _outTree->Branch("hJet_SoftLeptId95", hJets.SoftLeptId95 , "SoftLeptId95[nhJets]/I");
920     _outTree->Branch("hJet_SoftLeptPt", hJets.SoftLeptPt , "SoftLeptPt[nhJets]/F");
921     _outTree->Branch("hJet_SoftLeptdR", hJets.SoftLeptdR , "SoftLeptdR[nhJets]/F");
922     _outTree->Branch("hJet_SoftLeptptRel", hJets.SoftLeptptRel , "SoftLeptptRel[nhJets]/F");
923     _outTree->Branch("hJet_SoftLeptRelCombIso", hJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[nhJets]/F");
924     _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
925 arizzi 1.2 _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
926     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
927     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
928 arizzi 1.36 _outTree->Branch("hJet_vtxMass",hJets.vtxMass ,"vtxMass[nhJets]/F");
929 dlopes 1.73 _outTree->Branch("hJet_vtxPt",hJets.vtxPt ,"vtxPt[nhJets]/F");
930     _outTree->Branch("hJet_vtxEta",hJets.vtxEta ,"vtxEta[nhJets]/F");
931     _outTree->Branch("hJet_vtxPhi",hJets.vtxPhi ,"vtxPhi[nhJets]/F");
932     _outTree->Branch("hJet_vtxE",hJets.vtxE ,"vtxE[nhJets]/F");
933 arizzi 1.36 _outTree->Branch("hJet_vtx3dL",hJets.vtx3dL ,"vtx3dL[nhJets]/F");
934     _outTree->Branch("hJet_vtx3deL",hJets.vtx3deL ,"vtx3deL[nhJets]/F");
935     _outTree->Branch("hJet_id",hJets.id ,"id[nhJets]/b");
936 arizzi 1.64 _outTree->Branch("hJet_SF_CSVL",hJets.SF_CSVL ,"SF_CSVL[nhJets]/b");
937     _outTree->Branch("hJet_SF_CSVM",hJets.SF_CSVM ,"SF_CSVM[nhJets]/b");
938     _outTree->Branch("hJet_SF_CSVT",hJets.SF_CSVT ,"SF_CSVT[nhJets]/b");
939     _outTree->Branch("hJet_SF_CSVLerr",hJets.SF_CSVLerr ,"SF_CSVLerr[nhJets]/b");
940     _outTree->Branch("hJet_SF_CSVMerr",hJets.SF_CSVMerr ,"SF_CSVMerr[nhJets]/b");
941     _outTree->Branch("hJet_SF_CSVTerr",hJets.SF_CSVTerr ,"SF_CSVTerr[nhJets]/b");
942 dlopes 1.73 _outTree->Branch("hJet_ptRaw",hJets.ptRaw ,"ptRaw[nhJets]/F");
943     _outTree->Branch("hJet_ptLeadTrack",hJets.ptLeadTrack ,"ptLeadTrack[nhJets]/F");
944 degrutto 1.86 _outTree->Branch("hJet_puJetIdL",hJets.puJetIdL ,"puJetIdL[nhJets]/F");
945     _outTree->Branch("hJet_puJetIdM",hJets.puJetIdM ,"puJetIdM[nhJets]/F");
946     _outTree->Branch("hJet_puJetIdT",hJets.puJetIdT ,"puJetIdT[nhJets]/F");
947     _outTree->Branch("hJet_puJetIdMva",hJets.puJetIdMva ,"puJetIdMva[nhJets]/F");
948 mooney 1.105 _outTree->Branch("hJet_charge",hJets.charge ,"charge[nhJets]/F");
949 arizzi 1.2
950 dlopes 1.67 _outTree->Branch("fathFilterJets_pt",fathFilterJets.pt ,"pt[nfathFilterJets]/F");
951     _outTree->Branch("fathFilterJets_eta",fathFilterJets.eta ,"eta[nfathFilterJets]/F");
952     _outTree->Branch("fathFilterJets_phi",fathFilterJets.phi ,"phi[nfathFilterJets]/F");
953     _outTree->Branch("fathFilterJets_e",fathFilterJets.e ,"e[nfathFilterJets]/F");
954     _outTree->Branch("fathFilterJets_csv",fathFilterJets.csv ,"csv[nfathFilterJets]/F");
955 dlopes 1.73 _outTree->Branch("fathFilterJets_chf",fathFilterJets.chf ,"chf[nfathFilterJets]/F");
956     _outTree->Branch("fathFilterJets_ptRaw",fathFilterJets.ptRaw ,"ptRaw[nfathFilterJets]/F");
957     _outTree->Branch("fathFilterJets_ptLeadTrack",fathFilterJets.ptLeadTrack ,"ptLeadTrack[nfathFilterJets]/F");
958     _outTree->Branch("fathFilterJets_flavour",fathFilterJets.flavour ,"flavour[nfathFilterJets]/F");
959     _outTree->Branch("fathFilterJets_isSemiLept",fathFilterJets.isSemiLept ,"isSemiLept[nfathFilterJets]/F");
960     _outTree->Branch("fathFilterJets_isSemiLeptMCtruth",fathFilterJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[nfathFilterJets]/F");
961     _outTree->Branch("fathFilterJets_genPt",fathFilterJets.genPt ,"genPt[nfathFilterJets]/F");
962     _outTree->Branch("fathFilterJets_genEta",fathFilterJets.genEta ,"genEta[nfathFilterJets]/F");
963     _outTree->Branch("fathFilterJets_genPhi",fathFilterJets.genPhi ,"genPhi[nfathFilterJets]/F");
964     _outTree->Branch("fathFilterJets_vtxMass",fathFilterJets.vtxMass ,"vtxMass[nfathFilterJets]/F");
965     _outTree->Branch("fathFilterJets_vtx3dL",fathFilterJets.vtx3dL ,"vtx3dL[nfathFilterJets]/F");
966     _outTree->Branch("fathFilterJets_vtx3deL",fathFilterJets.vtx3deL ,"vtx3deL[nfathFilterJets]/F");
967     _outTree->Branch("fathFilterJets_vtxPt",fathFilterJets.vtxPt ,"vtxPt[nfathFilterJets]/F");
968     _outTree->Branch("fathFilterJets_vtxEta",fathFilterJets.vtxEta ,"vtxEta[nfathFilterJets]/F");
969     _outTree->Branch("fathFilterJets_vtxPhi",fathFilterJets.vtxPhi ,"vtxPhi[nfathFilterJets]/F");
970     _outTree->Branch("fathFilterJets_vtxE",fathFilterJets.vtxE ,"vtxE[nfathFilterJets]/F");
971 cboeser 1.107
972 dlopes 1.73
973     // _outTree->Branch("fathFilterJets_pt",fathFilterJets.pt ,"pt[nfathFilterJets]/F");
974     // _outTree->Branch("fathFilterJets_eta",fathFilterJets.eta ,"eta[nfathFilterJets]/F");
975     // _outTree->Branch("fathFilterJets_phi",fathFilterJets.phi ,"phi[nfathFilterJets]/F");
976     // _outTree->Branch("fathFilterJets_e",fathFilterJets.e ,"e[nfathFilterJets]/F");
977     // _outTree->Branch("fathFilterJets_csv",fathFilterJets.csv ,"csv[nfathFilterJets]/F");
978 arizzi 1.70 _outTree->Branch("fathFilterJets_csvivf",fathFilterJets.csvivf ,"csvivf[nfathFilterJets]/F");
979     _outTree->Branch("fathFilterJets_cmva",fathFilterJets.cmva ,"cmva[nfathFilterJets]/F");
980 dlopes 1.73 // _outTree->Branch("fathFilterJets_flavour",fathFilterJets.flavour ,"flavour[nfathFilterJets]/F");
981 cboeser 1.107 _outTree->Branch("fathFilterJets_cosTheta",fathFilterJets.cosTheta ,"cosTheta[nfathFilterJets]/F");
982     _outTree->Branch("fathFilterJets_jetArea",fathFilterJets.jetArea ,"jetArea[nfathFilterJets]/F");
983 dlopes 1.67
984 apana 1.112 //ccla 25Jan13
985     _outTree->Branch("fathFilterJets_nconstituents",fathFilterJets.nconstituents ,"nconstituents[nfathFilterJets]/F");
986     _outTree->Branch("fathFilterJets_JECUnc",fathFilterJets.JECUnc ,"JECUnc[nfathFilterJets]/F");
987     _outTree->Branch("fathFilterJets_SoftLeptPt", fathFilterJets.SoftLeptPt , "SoftLeptPt[nfathFilterJets]/F");
988     _outTree->Branch("fathFilterJets_SoftLeptdR", fathFilterJets.SoftLeptdR , "SoftLeptdR[nfathFilterJets]/F");
989     _outTree->Branch("fathFilterJets_SoftLeptptRel", fathFilterJets.SoftLeptptRel , "SoftLeptptRel[nfathFilterJets]/F");
990     _outTree->Branch("fathFilterJets_csv_nominal",fathFilterJets.csv_nominal ,"csv_nominal[nfathFilterJets]/F");
991     _outTree->Branch("fathFilterJets_nhf",fathFilterJets.nhf ,"nhf[nfathFilterJets]/F");
992     _outTree->Branch("fathFilterJets_cef",fathFilterJets.cef ,"cef[nfathFilterJets]/F");
993     _outTree->Branch("fathFilterJets_nef",fathFilterJets.nef ,"nef[nfathFilterJets]/F");
994     _outTree->Branch("fathFilterJets_nch",fathFilterJets.nch ,"nch[nfathFilterJets]/F");
995     _outTree->Branch("fathFilterJets_id",fathFilterJets.id ,"id[nfathFilterJets]/b");
996    
997 arizzi 1.2 _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
998     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
999     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
1000 arizzi 1.51 _outTree->Branch("aJet_e",aJets.e ,"e[naJets]/F");
1001 arizzi 1.2 _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
1002 arizzi 1.98 _outTree->Branch("aJet_csv_nominal",aJets.csv_nominal ,"csv_nominal[naJets]/F");
1003     _outTree->Branch("aJet_csv_upBC",aJets.csv_upBC ,"csv_upBC[naJets]/F");
1004     _outTree->Branch("aJet_csv_downBC",aJets.csv_downBC ,"csv_downBC[naJets]/F");
1005     _outTree->Branch("aJet_csv_upL",aJets.csv_upL ,"csv_upL[naJets]/F");
1006     _outTree->Branch("aJet_csv_downL",aJets.csv_downL ,"csv_downL[naJets]/F");
1007 arizzi 1.110 _outTree->Branch("aJet_csv_nominal4p",aJets.csv_nominal4p ,"csv_nominal4p[naJets]/F");
1008     _outTree->Branch("aJet_csv_upBC4p",aJets.csv_upBC4p ,"csv_upBC4p[naJets]/F");
1009     _outTree->Branch("aJet_csv_downBC4p",aJets.csv_downBC4p ,"csv_downBC4p[naJets]/F");
1010 arizzi 1.98
1011 arizzi 1.70 _outTree->Branch("aJet_csvivf",aJets.csvivf ,"csvivf[naJets]/F");
1012     _outTree->Branch("aJet_cmva",aJets.cmva ,"cmva[naJets]/F");
1013 arizzi 1.2 _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
1014     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
1015     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
1016     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
1017     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
1018     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
1019     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
1020     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
1021     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
1022 degrutto 1.68 _outTree->Branch("aJet_isSemiLept",aJets.isSemiLept ,"isSemiLept[naJets]/I");
1023     _outTree->Branch("aJet_isSemiLeptMCtruth",aJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[naJets]/I");
1024     _outTree->Branch("aJet_SoftLeptpdgId",aJets.SoftLeptpdgId , "SoftLeptpdgId[naJets]/I");
1025     _outTree->Branch("aJet_SoftLeptIdlooseMu", aJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[naJets]/I");
1026     _outTree->Branch("aJet_SoftLeptId95", aJets.SoftLeptId95 , "SoftLeptId95[naJets]/I");
1027     _outTree->Branch("aJet_SoftLeptPt", aJets.SoftLeptPt , "SoftLeptPt[naJets]/F");
1028     _outTree->Branch("aJet_SoftLeptdR", aJets.SoftLeptdR , "SoftLeptdR[naJets]/F");
1029     _outTree->Branch("aJet_SoftLeptptRel", aJets.SoftLeptptRel , "SoftLeptptRel[naJets]/F");
1030     _outTree->Branch("aJet_SoftLeptRelCombIso", aJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[naJets]/F");
1031 degrutto 1.86 _outTree->Branch("aJet_puJetIdL", aJets.puJetIdL , "puJetIdL[naJets]/F");
1032     _outTree->Branch("aJet_puJetIdM", aJets.puJetIdM , "puJetIdM[naJets]/F");
1033     _outTree->Branch("aJet_puJetIdT", aJets.puJetIdT , "puJetIdT[naJets]/F");
1034     _outTree->Branch("aJet_puJetIdMva", aJets.puJetIdMva , "puJetIdMva[naJets]/F");
1035 mooney 1.105 _outTree->Branch("aJet_charge",aJets.charge ,"charge[naJets]/F");
1036 degrutto 1.68
1037 arizzi 1.2 _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
1038     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
1039     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
1040     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
1041 arizzi 1.24 _outTree->Branch("aJet_vtxMass",aJets.vtxMass ,"vtxMass[naJets]/F");
1042     _outTree->Branch("aJet_vtx3dL",aJets.vtx3dL ,"vtx3dL[naJets]/F");
1043     _outTree->Branch("aJet_vtx3deL",aJets.vtx3deL ,"vtx3deL[naJets]/F");
1044 arizzi 1.36 _outTree->Branch("aJet_id",aJets.id ,"id[naJets]/b");
1045 arizzi 1.64 _outTree->Branch("aJet_SF_CSVL",aJets.SF_CSVL ,"SF_CSVL[naJets]/b");
1046     _outTree->Branch("aJet_SF_CSVM",aJets.SF_CSVM ,"SF_CSVM[naJets]/b");
1047     _outTree->Branch("aJet_SF_CSVT",aJets.SF_CSVT ,"SF_CSVT[naJets]/b");
1048     _outTree->Branch("aJet_SF_CSVLerr",aJets.SF_CSVLerr ,"SF_CSVLerr[naJets]/b");
1049     _outTree->Branch("aJet_SF_CSVMerr",aJets.SF_CSVMerr ,"SF_CSVMerr[naJets]/b");
1050     _outTree->Branch("aJet_SF_CSVTerr",aJets.SF_CSVTerr ,"SF_CSVTerr[naJets]/b");
1051 arizzi 1.1
1052 dlopes 1.73 _outTree->Branch("naJetsFat" , &naJetsFat , "naJetsFat/I");
1053     _outTree->Branch("aJetFat_pt",aJetsFat.pt ,"pt[naJetsFat]/F");
1054     _outTree->Branch("aJetFat_eta",aJetsFat.eta ,"eta[naJetsFat]/F");
1055     _outTree->Branch("aJetFat_phi",aJetsFat.phi ,"phi[naJetsFat]/F");
1056     _outTree->Branch("aJetFat_e",aJetsFat.e ,"e[naJetsFat]/F");
1057     _outTree->Branch("aJetFat_csv",aJetsFat.csv ,"csv[naJetsFat]/F");
1058    
1059    
1060 arizzi 1.1 _outTree->Branch("numJets" , &numJets , "numJets/I" );
1061     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
1062     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
1063 arizzi 1.52 _outTree->Branch("deltaPullAngle2", &deltaPullAngle2 , "deltaPullAngle2/F");
1064 arizzi 1.1 _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
1065     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
1066     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
1067     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
1068 degrutto 1.69 _outTree->Branch("genHpt" , &genHpt , "genHpt/F");
1069 arizzi 1.1 _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
1070 arizzi 1.38 _outTree->Branch("weightTrigMay" , &weightTrigMay , "weightTrigMay/F");
1071     _outTree->Branch("weightTrigV4" , &weightTrigV4 , "weightTrigV4/F");
1072 arizzi 1.22 _outTree->Branch("weightTrigMET" , &weightTrigMET , "weightTrigMET/F");
1073 arizzi 1.51 _outTree->Branch("weightTrigOrMu30" , &weightTrigOrMu30 , "weightTrigOrMu30/F");
1074 arizzi 1.24 _outTree->Branch("weightEleRecoAndId" , &weightEleRecoAndId , "weightEleRecoAndId/F");
1075     _outTree->Branch("weightEleTrigJetMETPart" , &weightEleTrigJetMETPart , "weightEleTrigJetMETPart/F");
1076     _outTree->Branch("weightEleTrigElePart" , &weightEleTrigElePart , "weightEleTrigElePart/F");
1077 arizzi 1.60 _outTree->Branch("weightEleTrigEleAugPart" , &weightEleTrigEleAugPart , "weightEleTrigEleAugPart/F");
1078 arizzi 1.24
1079 arizzi 1.89
1080 arizzi 1.64 _outTree->Branch("weightTrigMET80" , &weightTrigMET80 , "weightTrigMET80/F");
1081     _outTree->Branch("weightTrigMET100" , &weightTrigMET100 , "weightTrigMET100/F");
1082     _outTree->Branch("weightTrig2CJet20" , &weightTrig2CJet20 , "weightTrig2CJet20/F");
1083     _outTree->Branch("weightTrigMET150" , &weightTrigMET150 , "weightTrigMET150/F");
1084     _outTree->Branch("weightTrigMET802CJet" , &weightTrigMET802CJet , "weightTrigMET802CJet/F");
1085     _outTree->Branch("weightTrigMET1002CJet" , &weightTrigMET1002CJet , "weightTrigMET1002CJet/F");
1086     _outTree->Branch("weightTrigMETLP" , &weightTrigMETLP , "weightTrigMETLP/F");
1087    
1088 arizzi 1.89 _outTree->Branch("weightTrig2012A", &weightTrig2012A,"weightTrig2012A/F");
1089     _outTree->Branch("weightTrig2012ADiMuon", &weightTrig2012ADiMuon,"weightTrig2012ADiMuon/F");
1090     _outTree->Branch("weightTrig2012ADiEle", &weightTrig2012ADiEle,"weightTrig2012ADiEle/F");
1091     _outTree->Branch("weightTrig2012ASingleMuon", &weightTrig2012ASingleMuon,"weightTrig2012ASingleMuon/F");
1092     _outTree->Branch("weightTrig2012ASingleEle", &weightTrig2012ASingleEle,"weightTrig2012ASingleEle/F");
1093     _outTree->Branch("weightTrig2012AMuonPlusWCandPt", &weightTrig2012AMuonPlusWCandPt,"weightTrig2012AMuonPlusWCandPt/F");
1094    
1095 arizzi 1.110
1096     _outTree->Branch("weightTrig2012", &weightTrig2012,"weightTrig2012/F");
1097     _outTree->Branch("weightTrig2012DiMuon", &weightTrig2012DiMuon,"weightTrig2012DiMuon/F");
1098     _outTree->Branch("weightTrig2012DiEle", &weightTrig2012DiEle,"weightTrig2012DiEle/F");
1099     _outTree->Branch("weightTrig2012SingleMuon", &weightTrig2012SingleMuon,"weightTrig2012SingleMuon/F");
1100     _outTree->Branch("weightTrig2012SingleEle", &weightTrig2012SingleEle,"weightTrig2012SingleEle/F");
1101     _outTree->Branch("weightTrig2012MuonPlusWCandPt", &weightTrig2012MuonPlusWCandPt,"weightTrig2012MuonPlusWCandPt/F");
1102    
1103    
1104     _outTree->Branch("weightTrig2012AB", &weightTrig2012AB,"weightTrig2012AB/F");
1105     _outTree->Branch("weightTrig2012ABDiMuon", &weightTrig2012ABDiMuon,"weightTrig2012ABDiMuon/F");
1106     _outTree->Branch("weightTrig2012ABDiEle", &weightTrig2012ABDiEle,"weightTrig2012ABDiEle/F");
1107     _outTree->Branch("weightTrig2012ABSingleMuon", &weightTrig2012ABSingleMuon,"weightTrig2012ABSingleMuon/F");
1108     _outTree->Branch("weightTrig2012ABSingleEle", &weightTrig2012ABSingleEle,"weightTrig2012ABSingleEle/F");
1109     _outTree->Branch("weightTrig2012ABMuonPlusWCandPt", &weightTrig2012ABMuonPlusWCandPt,"weightTrig2012ABMuonPlusWCandPt/F");
1110    
1111 arizzi 1.92 _outTree->Branch("weightTrig2012DiJet30MHT80", &weightTrig2012DiJet30MHT80,"weightTrig2012DiJet30MHT80/F");
1112     _outTree->Branch("weightTrig2012PFMET150", &weightTrig2012PFMET150,"weightTrig2012PFMET150/F");
1113     _outTree->Branch("weightTrig2012SumpT100MET100", &weightTrig2012SumpT100MET100,"weightTrig2012SumpT100MET100/F");
1114 degrutto 1.108 _outTree->Branch("weightTrig2012APFMET150orDiJetMET", &weightTrig2012APFMET150orDiJetMET,"weightTrig2012APFMET150orDiJetMET/F");
1115     _outTree->Branch("weightTrig2012BPFMET150orDiJetMET", &weightTrig2012BPFMET150orDiJetMET,"weightTrig2012BPFMET150orDiJetMET/F");
1116     _outTree->Branch("weightTrig2012CPFMET150orDiJetMET", &weightTrig2012CPFMET150orDiJetMET,"weightTrig2012CPFMET150orDiJetMET/F");
1117    
1118    
1119 arizzi 1.92
1120 arizzi 1.24
1121 arizzi 1.1 _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
1122 arizzi 1.52 _outTree->Branch("deltaPullAngle2AK7", &deltaPullAngle2AK7 , "deltaPullAngle2AK7/F");
1123 arizzi 1.62 _outTree->Branch("PU0", &PU0 , "PU0/F");
1124     _outTree->Branch("PUm1", &PUm1 , "PUm1/F");
1125     _outTree->Branch("PUp1", &PUp1 , "PUp1/F");
1126 arizzi 1.1 _outTree->Branch("PUweight", &PUweight , "PUweight/F");
1127 arizzi 1.110 _outTree->Branch("PUweightP", &PUweightP , "PUweightP/F");
1128     _outTree->Branch("PUweightM", &PUweightM , "PUweightM/F");
1129 arizzi 1.111 _outTree->Branch("PUweightAB", &PUweightAB , "PUweightAB/F");
1130 degrutto 1.54 _outTree->Branch("PUweight2011B", &PUweight2011B , "PUweight2011B/F");
1131 arizzi 1.89 _outTree->Branch("PUweight1DObs", &PUweight1DObs , "PUweight1DObs/F");
1132 arizzi 1.3 _outTree->Branch("eventFlav", &eventFlav , "eventFlav/I");
1133 arizzi 1.1
1134    
1135    
1136    
1137     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
1138     _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
1139 arizzi 1.41 _outTree->Branch("HVMass" , &HVMass , "HVMass/F" );
1140 arizzi 1.19 _outTree->Branch("HMETdPhi" , &HMETdPhi , "HMETdPhi/F" );
1141 arizzi 1.1 _outTree->Branch("VMt" , &VMt , "VMt/F" );
1142    
1143 arizzi 1.9 _outTree->Branch("nvlep" , &nvlep , "nvlep/I");
1144     _outTree->Branch("nalep" , &nalep , "nalep/I");
1145 arizzi 1.3
1146 arizzi 1.9 _outTree->Branch("vLepton_mass",vLeptons.mass ,"mass[nvlep]/F");
1147     _outTree->Branch("vLepton_pt",vLeptons.pt ,"pt[nvlep]/F");
1148     _outTree->Branch("vLepton_eta",vLeptons.eta ,"eta[nvlep]");
1149     _outTree->Branch("vLepton_phi",vLeptons.phi ,"phi[nvlep]/F");
1150     _outTree->Branch("vLepton_aodCombRelIso",vLeptons.aodCombRelIso ,"aodCombRelIso[nvlep]/F");
1151     _outTree->Branch("vLepton_pfCombRelIso",vLeptons.pfCombRelIso ,"pfCombRelIso[nvlep]/F");
1152     _outTree->Branch("vLepton_photonIso",vLeptons.photonIso ,"photonIso[nvlep]/F");
1153     _outTree->Branch("vLepton_neutralHadIso",vLeptons.neutralHadIso ,"neutralHadIso[nvlep]/F");
1154     _outTree->Branch("vLepton_chargedHadIso",vLeptons.chargedHadIso ,"chargedHadIso[nvlep]/F");
1155 dlopes 1.55 _outTree->Branch("vLepton_chargedPUIso",vLeptons.chargedPUIso ,"chargedPUIso[nvlep]/F");
1156 arizzi 1.9 _outTree->Branch("vLepton_particleIso",vLeptons.particleIso ,"particleIso[nvlep]/F");
1157     _outTree->Branch("vLepton_dxy",vLeptons.dxy ,"dxy[nvlep]/F");
1158     _outTree->Branch("vLepton_dz",vLeptons.dz ,"dz[nvlep]/F");
1159     _outTree->Branch("vLepton_type",vLeptons.type ,"type[nvlep]/I");
1160 arizzi 1.27 _outTree->Branch("vLepton_id80",vLeptons.id80 ,"id80[nvlep]/F");
1161     _outTree->Branch("vLepton_id95",vLeptons.id95 ,"id95[nvlep]/F");
1162 arizzi 1.48 _outTree->Branch("vLepton_vbtf",vLeptons.vbtf ,"vbtf[nvlep]/F");
1163 arizzi 1.64 _outTree->Branch("vLepton_id80NoIso",vLeptons.id80NoIso ,"id80NoIso[nvlep]/F");
1164     _outTree->Branch("vLepton_genPt",vLeptons.genPt ,"genPt[nvlep]/F");
1165     _outTree->Branch("vLepton_genEta",vLeptons.genEta ,"genEta[nvlep]");
1166     _outTree->Branch("vLepton_genPhi",vLeptons.genPhi ,"genPhi[nvlep]/F");
1167 degrutto 1.69 _outTree->Branch("vLepton_charge",vLeptons.charge ,"charge[nvlep]/F");
1168 arizzi 1.82 _outTree->Branch("vLepton_pfCorrIso",vLeptons.pfCorrIso,"pfCorrIso[nvlep]/F");
1169     _outTree->Branch("vLepton_id2012tight",vLeptons.id2012tight,"id2012tight[nvlep]/F");
1170     _outTree->Branch("vLepton_idMVAnotrig",vLeptons.idMVAnotrig,"idMVAnotrig[nvlep]/F");
1171     _outTree->Branch("vLepton_idMVAtrig",vLeptons.idMVAtrig,"idMVAtrig[nvlep]/F");
1172 arizzi 1.95 _outTree->Branch("vLepton_idMVApresel",vLeptons.idMVApresel,"idMVApresel[nvlep]/F");
1173 arizzi 1.87 _outTree->Branch("vLepton_innerHits",vLeptons.innerHits,"innerHits[nvlep]/F");
1174     _outTree->Branch("vLepton_photonIsoDoubleCount",vLeptons.photonIsoDoubleCount,"photonIsoDoubleCount[nvlep]/F");
1175 arizzi 1.92 _outTree->Branch("vLepton_wpHWW",vLeptons.wpHWW,"wpHWW[nvlep]/F");
1176 arizzi 1.87 _outTree->Branch("vLepton_wp95",vLeptons.wp95,"wp95[nvlep]/F");
1177     _outTree->Branch("vLepton_wp90",vLeptons.wp90,"wp90[nvlep]/F");
1178     _outTree->Branch("vLepton_wp85",vLeptons.wp85,"wp85[nvlep]/F");
1179     _outTree->Branch("vLepton_wp80",vLeptons.wp80,"wp80[nvlep]/F");
1180     _outTree->Branch("vLepton_wp70",vLeptons.wp70,"wp70[nvlep]/F");
1181    
1182 arizzi 1.9 _outTree->Branch("aLepton_mass",aLeptons.mass ,"mass[nalep]/F");
1183     _outTree->Branch("aLepton_pt",aLeptons.pt ,"pt[nalep]/F");
1184     _outTree->Branch("aLepton_eta",aLeptons.eta ,"eta[nalep]");
1185     _outTree->Branch("aLepton_phi",aLeptons.phi ,"phi[nalep]/F");
1186     _outTree->Branch("aLepton_aodCombRelIso",aLeptons.aodCombRelIso ,"aodCombRelIso[nalep]/F");
1187     _outTree->Branch("aLepton_pfCombRelIso",aLeptons.pfCombRelIso ,"pfCombRelIso[nalep]/F");
1188     _outTree->Branch("aLepton_photonIso",aLeptons.photonIso ,"photonIso[nalep]/F");
1189     _outTree->Branch("aLepton_neutralHadIso",aLeptons.neutralHadIso ,"neutralHadIso[nalep]/F");
1190     _outTree->Branch("aLepton_chargedHadIso",aLeptons.chargedHadIso ,"chargedHadIso[nalep]/F");
1191 dlopes 1.55 _outTree->Branch("aLepton_chargedPUIso",aLeptons.chargedPUIso ,"chargedPUIso[nalep]/F");
1192 arizzi 1.9 _outTree->Branch("aLepton_particleIso",aLeptons.particleIso ,"particleIso[nalep]/F");
1193     _outTree->Branch("aLepton_dxy",aLeptons.dxy ,"dxy[nalep]/F");
1194     _outTree->Branch("aLepton_dz",aLeptons.dz ,"dz[nalep]/F");
1195     _outTree->Branch("aLepton_type",aLeptons.type ,"type[nalep]/I");
1196 arizzi 1.48 _outTree->Branch("aLepton_id80",aLeptons.id80 ,"id80[nalep]/F");
1197     _outTree->Branch("aLepton_id95",aLeptons.id95 ,"id95[nalep]/F");
1198     _outTree->Branch("aLepton_vbtf",aLeptons.vbtf ,"vbtf[nalep]/F");
1199 arizzi 1.64 _outTree->Branch("aLepton_id80NoIso",aLeptons.id80NoIso ,"id80NoIso[nalep]/F");
1200     _outTree->Branch("aLepton_genPt",aLeptons.genPt ,"genPt[nalep]/F");
1201     _outTree->Branch("aLepton_genEta",aLeptons.genEta ,"genEta[nalep]");
1202     _outTree->Branch("aLepton_genPhi",aLeptons.genPhi ,"genPhi[nalep]/F");
1203 degrutto 1.69 _outTree->Branch("aLepton_charge",aLeptons.charge ,"charge[nalep]/F");
1204 arizzi 1.83 _outTree->Branch("aLepton_pfCorrIso",aLeptons.pfCorrIso,"pfCorrIso[nalep]/F");
1205     _outTree->Branch("aLepton_id2012tight",aLeptons.id2012tight,"id2012tight[nalep]/F");
1206     _outTree->Branch("aLepton_idMVAnotrig",aLeptons.idMVAnotrig,"idMVAnotrig[nalep]/F");
1207     _outTree->Branch("aLepton_idMVAtrig",aLeptons.idMVAtrig,"idMVAtrig[nalep]/F");
1208 arizzi 1.95 _outTree->Branch("aLepton_idMVApresel",aLeptons.idMVApresel,"idMVApresel[nalep]/F");
1209 arizzi 1.87 _outTree->Branch("aLepton_innerHits",aLeptons.innerHits,"innerHits[nalep]/F");
1210     _outTree->Branch("aLepton_photonIsoDoubleCount",aLeptons.photonIsoDoubleCount,"photonIsoDoubleCount[nalep]/F");
1211 arizzi 1.92 _outTree->Branch("aLepton_wpHWW",aLeptons.wpHWW,"wpHWW[nalep]/F");
1212 arizzi 1.87 _outTree->Branch("aLepton_wp95",aLeptons.wp95,"wp95[nalep]/F");
1213     _outTree->Branch("aLepton_wp90",aLeptons.wp90,"wp90[nalep]/F");
1214     _outTree->Branch("aLepton_wp85",aLeptons.wp85,"wp85[nalep]/F");
1215     _outTree->Branch("aLepton_wp80",aLeptons.wp80,"wp80[nalep]/F");
1216     _outTree->Branch("aLepton_wp70",aLeptons.wp70,"wp70[nalep]/F");
1217    
1218 degrutto 1.69
1219 arizzi 1.8 _outTree->Branch("top" , &top , "mass/F:pt/F:wMass/F");
1220 arizzi 1.49 _outTree->Branch("WplusMode" , &WplusMode , "WplusMode/I");
1221     _outTree->Branch("WminusMode" , &WminusMode , "WminusMode/I");
1222 arizzi 1.1
1223 bortigno 1.30 //IVF
1224     _outTree->Branch("nSvs",&nSvs ,"nSvs/I");
1225 arizzi 1.33 _outTree->Branch("Sv_massBCand", &IVF.massBcand,"massBcand[nSvs]/F");
1226     _outTree->Branch("Sv_massSv", &IVF.massSv,"massSv[nSvs]/F");
1227     _outTree->Branch("Sv_pt", &IVF.pt,"pt[nSvs]/F");
1228     _outTree->Branch("Sv_eta", &IVF.eta,"eta[nSvs]/F");
1229     _outTree->Branch("Sv_phi", &IVF.phi,"phi[nSvs]/F");
1230     _outTree->Branch("Sv_dist3D", &IVF.dist3D,"dist3D[nSvs]/F");
1231     _outTree->Branch("Sv_dist2D", &IVF.dist2D,"dist2D[nSvs]/F");
1232     _outTree->Branch("Sv_distSim2D", &IVF.distSig2D,"distSig2D[nSvs]/F");
1233     _outTree->Branch("Sv_distSig3D", &IVF.distSig3D,"distSig3D[nSvs]/F");
1234     _outTree->Branch("Sv_dist3D_norm", &IVF.dist3D_norm,"dist3D_norm[nSvs]/F");
1235 bortigno 1.30 //IVF higgs candidate
1236 arizzi 1.33 _outTree->Branch("SVH" , &SVH , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
1237 bortigno 1.30
1238 dlopes 1.73
1239 bortigno 1.74
1240 bortigno 1.30 // //SimBHadron
1241 bortigno 1.74 _outTree->Branch("nSimBs",&nSimBs ,"nSimBs/I");
1242     _outTree->Branch("SimBs_mass", &SimBs.mass,"mass[nSimBs]/F");
1243     _outTree->Branch("SimBs_pt", &SimBs.pt,"pt[nSimBs]/F");
1244     _outTree->Branch("SimBs_eta", &SimBs.eta,"eta[nSimBs]/F");
1245     _outTree->Branch("SimBs_phi", &SimBs.phi,"phi[nSimBs]/F");
1246     _outTree->Branch("SimBs_vtx_x", &SimBs.vtx_x,"vtx_x[nSimBs]/F");
1247     _outTree->Branch("SimBs_vtx_y", &SimBs.vtx_y,"vtx_y[nSimBs]/F");
1248     _outTree->Branch("SimBs_vtx_z", &SimBs.vtx_z,"vtx_z[nSimBs]/F");
1249     _outTree->Branch("SimBs_pdgId", &SimBs.pdgId,"pdgId[nSimBs]/F");
1250     _outTree->Branch("SimBs_status", &SimBs.status,"status[nSimBs]/F");
1251     //SimBHadron Higgs Candidate
1252     _outTree->Branch("SimBsH" , &SimBsH , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
1253 bortigno 1.30
1254 arizzi 1.36 _outTree->Branch("rho" , &rho , "rho/F");
1255     _outTree->Branch("rho25" , &rho25 , "rho25/F");
1256 arizzi 1.82 _outTree->Branch("rhoN" , &rhoN , "rhoN/F");
1257 arizzi 1.36 _outTree->Branch("nPVs" , &nPVs , "nPVs/I");
1258     _outTree->Branch("METnoPU" , &METnoPU , "et/F:sumet:sig/F:phi/F");
1259 arizzi 1.58 _outTree->Branch("METnoPUCh" , &METnoPUCh , "et/F:sumet:sig/F:phi/F");
1260 arizzi 1.1 _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
1261 degrutto 1.69 _outTree->Branch("METtype1corr" , &METtype1corr , "et/F:sumet:sig/F:phi/F");
1262     _outTree->Branch("METtype1p2corr" , &METtype1p2corr , "et/F:sumet:sig/F:phi/F");
1263     _outTree->Branch("METnoPUtype1corr" , &METnoPUtype1corr , "et/F:sumet:sig/F:phi/F");
1264     _outTree->Branch("METnoPUtype1p2corr" , &METnoPUtype1p2corr , "et/F:sumet:sig/F:phi/F");
1265    
1266     _outTree->Branch("metUnc_et",&metUnc.et ,"et[24]/F");
1267     _outTree->Branch("metUnc_phi",&metUnc.phi ,"phi[24]/F");
1268     _outTree->Branch("metUnc_sumet",&metUnc.sumet ,"sumet[24]/F");
1269    
1270    
1271    
1272 arizzi 1.52 _outTree->Branch("fakeMET" , &fakeMET , "et/F:sumet:sig/F:phi/F");
1273 arizzi 1.1 _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
1274     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
1275     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
1276    
1277 bortigno 1.30 std::stringstream s;
1278     s << "triggerFlags[" << triggers.size() << "]/b";
1279     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
1280 arizzi 1.17
1281 bortigno 1.30 _outTree->Branch("EVENT" , &EVENT , "run/I:lumi/I:event/I:json/I");
1282     _outTree->Branch("hbhe" , &hbhe , "hbhe/b");
1283 arizzi 1.63 _outTree->Branch("totalKinematics" , &totalKinematics , "totalKinematics/b");
1284 arizzi 1.56 _outTree->Branch("ecalFlag" , &ecalFlag , "ecalFlag/b");
1285 degrutto 1.69 _outTree->Branch("cschaloFlag" , &cschaloFlag , "cschaloFlag/b");
1286     _outTree->Branch("hcallaserFlag" , &hcallaserFlag , "hcallaserFlag/b");
1287     _outTree->Branch("trackingfailureFlag" , &trackingfailureFlag , "trackingfailureFlag/b");
1288 degrutto 1.104 _outTree->Branch("eebadscFlag" , &eebadscFlag , "eebadscFlag/b");
1289 bortigno 1.30 _outTree->Branch("btag1TSF" , &btag1TSF , "btag1TSF/F");
1290     _outTree->Branch("btag2TSF" , &btag2TSF , "btag2TSF/F");
1291     _outTree->Branch("btag1T2CSF" , &btag1T2CSF , "btag1T2CSF/F");
1292 arizzi 1.44 _outTree->Branch("btag2CSF" , &btag2CSF , "btag2CSF/F");
1293     _outTree->Branch("btagA0CSF" , &btagA0CSF , "btagA0CSF/F");
1294 arizzi 1.60 _outTree->Branch("btagA0TSF" , &btagA0TSF , "btagA0TSF/F");
1295 arizzi 1.51 _outTree->Branch("btag1TA1C" , &btag1TA1C , "btag1TA1C/F");
1296 arizzi 1.1
1297 bortigno 1.30 int ievt=0;
1298     int totalcount=0;
1299 cboeser 1.107
1300 bortigno 1.30 // TFile* inFile = new TFile(inputFile.c_str(), "read");
1301 arizzi 1.1 for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
1302     std::cout << iFile << std::endl;
1303     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
1304 arizzi 1.85 if(inFile==0) { std::cout << "FAILED " << inputFiles_[iFile] << std::endl; continue; }
1305 arizzi 1.1
1306 bortigno 1.30 // loop the events
1307 arizzi 1.1
1308     fwlite::Event ev(inFile);
1309 arizzi 1.80 fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
1310 nmohr 1.29 for(ev.toBegin(); !ev.atEnd() ; ++ev, ++ievt)
1311 arizzi 1.1 {
1312 nmohr 1.29 if (ievt <= skipEvents_) continue;
1313     if (maxEvents_ >= 0){
1314     if (ievt > maxEvents_ + skipEvents_) break;
1315 arizzi 1.80 }
1316     const char * lab = "HbbAnalyzerNew";
1317     vhbbAuxHandle.getByLabel(ev,lab,0,0);
1318 arizzi 1.25 const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
1319 arizzi 1.84 EVENT.run = ev.id().run();
1320     EVENT.lumi = ev.id().luminosityBlock();
1321     EVENT.event = ev.id().event();
1322     EVENT.json = jsonContainsEvent (jsonVector, ev);
1323 arizzi 1.64
1324     if(EVENT.run < runMin_ && runMin_ > 0) continue;
1325     if(EVENT.run > runMax_ && runMax_ > 0) continue;
1326    
1327     count->Fill(1.);
1328    
1329 degrutto 1.69
1330    
1331 arizzi 1.88 /*
1332     Handle<std::vector< PileupSummaryInfo > > PupInfo;
1333     event.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
1334     std::vector<PileupSummaryInfo>::const_iterator PVI;
1335     float Tnpv = -1;
1336     for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
1337     int BX = PVI->getBunchCrossing();
1338     if(BX == 0) {
1339     Tnpv = PVI->getTrueNumInteractions();
1340     continue;
1341     }
1342 degrutto 1.69
1343 arizzi 1.88 }
1344     double MyWeight = LumiWeights_.weight( Tnpv );
1345     double MyWeight = LumiWeights_.weight( (*iEventB) );
1346     */
1347 degrutto 1.69
1348    
1349 arizzi 1.25 PUweight=1.;
1350 arizzi 1.110 PUweightP=1.;
1351     PUweightM=1.;
1352 arizzi 1.111 PUweightAB=1.;
1353 degrutto 1.54 PUweight2011B=1.;
1354 arizzi 1.89 PUweight1DObs=1.;
1355 arizzi 1.1 if(isMC_){
1356 arizzi 1.41
1357 degrutto 1.54 // PU weights // Run2011A
1358 bortigno 1.30 std::map<int, unsigned int>::const_iterator puit = aux.puInfo.pus.find(0);
1359 arizzi 1.64 int npu =puit->second ;
1360 arizzi 1.89 PUweight = lumiWeights.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1361 arizzi 1.110 PUweightP = lumiWeightsPl.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1362     PUweightM = lumiWeightsMi.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1363 arizzi 1.111 PUweightAB = lumiWeightsAB.weight( (int) aux.puInfo.truePU ); //use new method with "true PU"
1364 arizzi 1.41 pu->Fill(puit->second);
1365 degrutto 1.54 // PU weight Run2011B
1366     // PU weight Run2011B
1367     std::map<int, unsigned int>::const_iterator puit0 = aux.puInfo.pus.find(0);
1368     std::map<int, unsigned int>::const_iterator puitm1 = aux.puInfo.pus.find(-1);
1369     std::map<int, unsigned int>::const_iterator puitp1 = aux.puInfo.pus.find(+1);
1370 arizzi 1.62 PU0=puit0->second;
1371     PUp1=puitp1->second;
1372     PUm1=puitm1->second;
1373     input3DPU->Fill(PUm1,PU0,PUp1);
1374 arizzi 1.103 // PUweight2011B = lumiWeights2011B.weight3D( puitm1->second, puit0->second,puitp1->second);
1375 arizzi 1.89 PUweight1DObs = lumiWeights1DObs.weight( npu);
1376 degrutto 1.54
1377 bortigno 1.30 }
1378 arizzi 1.49 countWithPU->Fill(1,PUweight);
1379 arizzi 1.110 countWithPUP->Fill(1,PUweightP);
1380     countWithPUM->Fill(1,PUweightM);
1381 arizzi 1.111 countWithPUAB->Fill(1,PUweightAB);
1382 arizzi 1.58 countWithPU2011B->Fill(1,PUweight2011B);
1383 nmohr 1.7
1384 bortigno 1.75 //LHE Infos
1385     fwlite::Handle<LHEEventProduct> evt;
1386 bortigno 1.79
1387     // std::cout << "Label for lhe = " << evt.getBranchNameFor(ev,"source") << std::endl;
1388 bortigno 1.77 if( !((evt.getBranchNameFor(ev,"source")).empty()) ){
1389     evt.getByLabel(ev,"source");
1390 bortigno 1.79 //std::cout << "LHEEventProduct found!" << std::endl;
1391 bortigno 1.77 bool lCheck=false;
1392     bool lbarCheck=false;
1393     bool vlCheck=false;
1394     bool vlbarCheck=false;
1395 bortigno 1.79 int idl, idlbar;
1396 bortigno 1.91 lheHT=0.;
1397     lheNj=0;
1398 bortigno 1.77 TLorentzVector l,lbar,vl,vlbar,V_tlv;
1399 bortigno 1.75 const lhef::HEPEUP hepeup_ = evt->hepeup();
1400 bortigno 1.79 const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP; // px, py, pz, E, M
1401 bortigno 1.75 for(unsigned int i=0; i<pup_.size(); ++i){
1402 bortigno 1.79 int id=hepeup_.IDUP[i]; //pdgId
1403 bortigno 1.90 int status = hepeup_.ISTUP[i];
1404 bortigno 1.96 int idabs=TMath::Abs(id);
1405     if( status == 1 && ( ( idabs == 21 ) || (idabs > 0 && idabs < 7) ) ){ // gluons and quarks
1406     lheHT += TMath::Sqrt( TMath::Power(hepeup_.PUP[i][0],2) + TMath::Power(hepeup_.PUP[i][1],2) ); // first entry is px, second py
1407     lheNj++;
1408     }
1409 bortigno 1.90
1410 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;}
1411     if(id==-11){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1412     if(id==12){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1413     if(id==-12){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1414    
1415     if(id==13){ l.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lCheck=true;}
1416     if(id==-13){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1417     if(id==14){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1418     if(id==-14){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1419    
1420     if(id==15){ l.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lCheck=true;}
1421     if(id==-15){ lbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); lbarCheck=true;}
1422     if(id==16){ vl.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlCheck=true;}
1423     if(id==-16){ vlbar.SetPxPyPzE(hepeup_.PUP[i][0],hepeup_.PUP[i][1],hepeup_.PUP[i][2],hepeup_.PUP[i][3]); vlbarCheck=true;}
1424    
1425     }
1426 bortigno 1.77 if( lCheck && lbarCheck ) V_tlv = l + lbar; // ZtoLL
1427     if( vlCheck && vlbarCheck ) V_tlv = vl + vlbar; // ZtoNuNu
1428     if( lCheck && vlbarCheck ) V_tlv = l + vlbar; // WToLNu
1429     if( lbarCheck && vlCheck ) V_tlv = lbar + vl; // WToLNu
1430     lheV_pt = V_tlv.Pt();
1431     }
1432 bortigno 1.75
1433 bortigno 1.79 //std::cout << "lhe V pt = " << lheV_pt << std::endl;
1434    
1435 bortigno 1.30 //Write event info
1436 bortigno 1.74
1437     // simBHadrons
1438     const SimBHadronCollection *sbhc;
1439     if(isMC_){
1440     fwlite::Handle<SimBHadronCollection> SBHC;
1441     SBHC.getByLabel(ev, "bhadrons");
1442     sbhc = SBHC.product();
1443     }
1444 bortigno 1.30
1445     const std::vector<VHbbCandidate> * candZ ;
1446     const std::vector<VHbbCandidate> * candW ;
1447 arizzi 1.64 VHbbEvent modifiedEvent;;
1448 bortigno 1.30 const VHbbEvent * iEvent =0;
1449     if(fromCandidate)
1450     {
1451     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandleZ;
1452     vhbbCandHandleZ.getByLabel(ev,"hbbBestCSVPt20Candidates");
1453     candZ = vhbbCandHandleZ.product();
1454    
1455     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
1456     vhbbCandHandle.getByLabel(ev,"hbbHighestPtHiggsPt30Candidates");
1457     candW = vhbbCandHandle.product();
1458     }
1459     else
1460     {
1461     candZlocal->clear();
1462     candWlocal->clear();
1463 degrutto 1.86 fwlite::Handle< VHbbEvent > vhbbHandle;
1464 bortigno 1.30 vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
1465 degrutto 1.86 modifiedEvent = *vhbbHandle.product();
1466 arizzi 1.64 if(isMC_)
1467     {
1468     iEvent= &modifiedEvent;
1469    
1470     for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
1471     {
1472 arizzi 1.94 // VHbbEvent::SimpleJet orig=modifiedEvent.simpleJets2[j];
1473     // VHbbEvent::SimpleJet origRemade = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true,true); // do ref check, can be commented out
1474     // VHbbEvent::SimpleJet corr2011 = jec.correctRight( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true,true); // do ref check, can be commented out
1475 arizzi 1.106 //REMOVE JEC modifiedEvent.simpleJets2[j] = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,true);
1476 arizzi 1.94 // std::cout << "Original " << orig.p4.Pt() << " == " << origRemade.p4.Pt() << " using CHS2011 " << corr2011.p4.Pt() << " final: " << modifiedEvent.simpleJets2[j].p4.Pt() << std::endl;
1477 arizzi 1.64 TLorentzVector & p4 = modifiedEvent.simpleJets2[j].p4;
1478     TLorentzVector & mcp4 = modifiedEvent.simpleJets2[j].bestMCp4;
1479     if ((fabs(p4.Pt() - mcp4.Pt())/ p4.Pt())<0.5) { //Limit the effect to the core
1480     float cor = (p4.Pt()+resolutionBias(fabs(p4.Eta()))*(p4.Pt()-mcp4.Pt()))/p4.Pt();
1481     p4.SetPtEtaPhiE(p4.Pt()*cor,p4.Eta(), p4.Phi(), p4.E()*cor);
1482     }
1483     }
1484     } else
1485     {
1486 arizzi 1.93 // iEvent = vhbbHandle.product();
1487     // modify also the real data now to apply JEC 2012
1488     iEvent= &modifiedEvent;
1489    
1490     for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
1491     {
1492     // jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,false,true); // do ref check, can be commented out
1493 arizzi 1.106 //REMOVE JEC modifiedEvent.simpleJets2[j] = jec.correct( modifiedEvent.simpleJets2[j],aux.puInfo.rho,false);
1494 arizzi 1.93 }
1495    
1496 arizzi 1.64 }
1497    
1498 arizzi 1.81 algoZ->run(iEvent,*candZlocal,aux);
1499     algoW->run(iEvent,*candWlocal,aux);
1500 arizzi 1.64
1501 degrutto 1.86
1502 arizzi 1.64 if(candZlocal->size() == 0 or candZlocal->at(0).H.jets.size() < 2) //recover low pt
1503     {
1504     candZlocal->clear();
1505     candWlocal->clear();
1506 arizzi 1.81 algoRecoverLowPt->run(iEvent,*candZlocal,aux);
1507     algoRecoverLowPt->run(iEvent,*candWlocal,aux);
1508 arizzi 1.64 }
1509    
1510 bortigno 1.30 candZ= candZlocal;
1511     candW= candWlocal;
1512     /* for(size_t m=0;m<iEvent->muInfo.size();m++)
1513     {
1514    
1515     if( fabs(iEvent->muInfo[m].p4.Pt()-28.118684) < 0.0001 ||
1516     fabs(iEvent->muInfo[m].p4.Pt()-34.853199) < 0.0001 )
1517     {
1518     std::cout << "FOUND " << iEvent->muInfo[m].p4.Pt() << " " << EVENT.event << " " << candW->size() << " " << candZ->size() << std::endl;
1519     }
1520     }
1521     */
1522 arizzi 1.4
1523 bortigno 1.30 }
1524 arizzi 1.1
1525 arizzi 1.3 const std::vector<VHbbCandidate> * cand = candZ;
1526 arizzi 1.1
1527    
1528    
1529 bortigno 1.30 /* fwlite::Handle< VHbbEvent > vhbbHandle;
1530     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
1531     const VHbbEvent iEvent = *vhbbHandle.product();
1532     */
1533 arizzi 1.1
1534 bortigno 1.30 // std::clog << "Filling tree "<< std::endl;
1535     bool isW=false;
1536 arizzi 1.21
1537 degrutto 1.69 // to check how much we gain with jets subtraction
1538    
1539    
1540    
1541     genHpt=aux.mcH.size() > 0 ? aux.mcH[0].p4.Pt():-99;
1542    
1543 arizzi 1.110 // if(cand->size() == 0 or cand->at(0).H.jets.size() < 2) continue;
1544 cboeser 1.107 if(cand->size() == 0 ) continue;
1545 degrutto 1.69 //std::cout << "cand->size() " << cand->size() << std::endl;
1546     //std::cout << "cand->at(0).H.jets.size() " << cand->at(0).H.jets.size() << std::endl;
1547 bortigno 1.30 if(cand->size() > 1 )
1548 arizzi 1.3 {
1549 bortigno 1.30 std::cout << "MULTIPLE CANDIDATES: " << cand->size() << std::endl;
1550 arizzi 1.3 }
1551 bortigno 1.30 if(cand->at(0).candidateType == VHbbCandidate::Wmun || cand->at(0).candidateType == VHbbCandidate::Wen ) { cand=candW; isW=true; }
1552     if(cand->size() == 0)
1553 arizzi 1.3 {
1554 bortigno 1.30 // std::cout << "W event loss due to tigther cuts" << std::endl;
1555 arizzi 1.3 continue;
1556     }
1557 arizzi 1.35
1558 degrutto 1.54
1559 arizzi 1.35 // secondary vtxs
1560     fwlite::Handle<std::vector<reco::Vertex> > SVC;
1561 arizzi 1.52 SVC.getByLabel(ev,"bcandidates");
1562 arizzi 1.35 const std::vector<reco::Vertex> svc = *(SVC.product());
1563 degrutto 1.69
1564 bortigno 1.30 const VHbbCandidate & vhCand = cand->at(0);
1565     patFilters.setEvent(&ev,"VH");
1566     hbhe = patFilters.accept("hbhe");
1567 arizzi 1.56 ecalFlag = patFilters.accept("ecalFilter");
1568 arizzi 1.63 totalKinematics = patFilters.accept("totalKinematics");
1569 degrutto 1.69 cschaloFlag = patFilters.accept("cschaloFilter");
1570     hcallaserFlag = patFilters.accept("hcallaserFilter");
1571     trackingfailureFlag = patFilters.accept("trackingfailureFilter");
1572 degrutto 1.104 eebadscFlag = patFilters.accept("eebadscFilter");
1573 arizzi 1.18
1574 bortigno 1.30 trigger.setEvent(&ev);
1575     for(size_t j=0;j < triggers.size();j++)
1576 arizzi 1.4 triggerFlags[j]=trigger.accept(triggers[j]);
1577 arizzi 1.39
1578 bortigno 1.30 eventFlav=0;
1579 degrutto 1.69
1580    
1581    
1582 bortigno 1.30 if(aux.mcBbar.size() > 0 || aux.mcB.size() > 0) eventFlav=5;
1583     else if(aux.mcC.size() > 0) eventFlav=4;
1584 degrutto 1.69
1585    
1586 arizzi 1.53 Vtype = vhCand.candidateType;
1587 arizzi 1.3
1588 dlopes 1.73 if(vhCand.H.HiggsFlag) H.HiggsFlag=1; else H.HiggsFlag=0;
1589    
1590     if(vhCand.H.HiggsFlag){
1591 bortigno 1.30 H.mass = vhCand.H.p4.M();
1592     H.pt = vhCand.H.p4.Pt();
1593 degrutto 1.69
1594    
1595 bortigno 1.30 H.eta = vhCand.H.p4.Eta();
1596     H.phi = vhCand.H.p4.Phi();
1597 dlopes 1.73 }
1598 dlopes 1.67
1599 apana 1.112 nfathFilterJets=0;
1600 dlopes 1.73 if(vhCand.FatH.FatHiggsFlag) FatH.FatHiggsFlag =1; else FatH.FatHiggsFlag=0;
1601     fathFilterJets.reset();
1602     aJetsFat.reset();
1603     if(vhCand.FatH.FatHiggsFlag){
1604     FatH.mass= vhCand.FatH.p4.M();
1605 dlopes 1.67 FatH.pt = vhCand.FatH.p4.Pt();
1606 arizzi 1.83 if(FatH.pt!=0)
1607     {
1608     FatH.eta = vhCand.FatH.p4.Eta();
1609     }
1610     else {
1611     FatH.eta = -99.;
1612     }
1613 dlopes 1.67 FatH.phi = vhCand.FatH.p4.Phi();
1614 cboeser 1.107
1615 arizzi 1.83
1616 dlopes 1.67 // if(vhCand.FatH.FatHiggsFlag) vhCand.FatH.subjetsSize;
1617     nfathFilterJets=vhCand.FatH.subjetsSize;
1618     for( int j=0; j < nfathFilterJets; j++ ){
1619     fathFilterJets.set(vhCand.FatH.jets[j],j);
1620     }
1621 dlopes 1.73
1622 dlopes 1.67 if(nfathFilterJets==2){
1623     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).M();
1624 dlopes 1.73 FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Pt();
1625     FatH.filteredeta=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Eta();
1626     FatH.filteredphi=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Phi();
1627 cboeser 1.107 fathFilterJets.cosTheta[0]= vhCand.FatH.helicities[0];
1628     fathFilterJets.cosTheta[1]= vhCand.FatH.helicities[1];
1629     }
1630 dlopes 1.67 else if(nfathFilterJets==3){
1631     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).M();
1632 dlopes 1.73 FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Pt();
1633     FatH.filteredeta=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Eta();
1634     FatH.filteredphi=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Phi();
1635 cboeser 1.107 fathFilterJets.cosTheta[0]= vhCand.FatH.helicities[0];
1636     fathFilterJets.cosTheta[1]= vhCand.FatH.helicities[1];
1637     fathFilterJets.cosTheta[2]= vhCand.FatH.helicities[2];
1638 dlopes 1.67 }
1639 dlopes 1.73
1640     naJetsFat=vhCand.additionalJetsFat.size();
1641     for( int j=0; j < naJetsFat && j < MAXJ; j++ )
1642     {
1643     aJetsFat.set(vhCand.additionalJetsFat[j],j);
1644     }
1645 dlopes 1.67
1646 cboeser 1.107
1647 dlopes 1.73 } // FatHiggsFlag
1648 degrutto 1.69
1649 dlopes 1.73 hJets.reset();
1650     aJets.reset();
1651     if(vhCand.H.HiggsFlag){
1652 degrutto 1.69
1653 bortigno 1.30 nhJets=2;
1654     hJets.set(vhCand.H.jets[0],0);
1655     hJets.set(vhCand.H.jets[1],1);
1656 degrutto 1.69
1657    
1658 bortigno 1.30 aJets.reset();
1659 dlopes 1.73
1660 bortigno 1.30 naJets=vhCand.additionalJets.size();
1661     numBJets=0;
1662     if(vhCand.H.jets[0].csv> btagThr) numBJets++;
1663     if(vhCand.H.jets[1].csv> btagThr) numBJets++;
1664     for( int j=0; j < naJets && j < MAXJ; j++ )
1665 arizzi 1.6 {
1666 bortigno 1.30 aJets.set(vhCand.additionalJets[j],j);
1667     if(vhCand.additionalJets[j].csv> btagThr) numBJets++;
1668 arizzi 1.6 }
1669 bortigno 1.30 numJets = vhCand.additionalJets.size()+2;
1670 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());
1671     H.dPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
1672     H.dEta= TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
1673 bortigno 1.30 HVdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ) ;
1674 arizzi 1.41 HVMass = (vhCand.H.p4 + vhCand.V.p4).M() ;
1675 bortigno 1.30 HMETdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.mets.at(0).p4.Phi()) ) ;
1676 arizzi 1.52 //eltaPullAngle = vhCand.H.deltaTheta;
1677 dlopes 1.73
1678 arizzi 1.52 deltaPullAngle = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[0],vhCand.H.jets[1]);
1679     deltaPullAngle2 = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[1],vhCand.H.jets[0]);
1680 bortigno 1.30 hJets.cosTheta[0]= vhCand.H.helicities[0];
1681     hJets.cosTheta[1]= vhCand.H.helicities[1];
1682 dlopes 1.73 } // Higgs Flag
1683    
1684     V.mass = vhCand.V.p4.M();
1685     if(isW) V.mass = vhCand.Mt();
1686     V.pt = vhCand.V.p4.Pt();
1687     V.eta = vhCand.V.p4.Eta();
1688     V.phi = vhCand.V.p4.Phi();
1689     VMt = vhCand.Mt() ;
1690    
1691    
1692 arizzi 1.36 // METInfo calomet; METInfo tcmet; METInfo pfmet; METInfo mht; METInfo metNoPU
1693 bortigno 1.30 MET.et = vhCand.V.mets.at(0).p4.Pt();
1694     MET.phi = vhCand.V.mets.at(0).p4.Phi();
1695     MET.sumet = vhCand.V.mets.at(0).sumEt;
1696     MET.sig = vhCand.V.mets.at(0).metSig;
1697 arizzi 1.24
1698 arizzi 1.52
1699     fakeMET.sumet = 0;
1700     fakeMET.sig = 0;
1701     fakeMET.et = 0;
1702     fakeMET.phi = 0;
1703     if( Vtype == VHbbCandidate::Zmumu) {
1704     TVector3 mu1 = vhCand.V.muons[0].p4.Vect();
1705     TVector3 mu2 = vhCand.V.muons[1].p4.Vect();
1706     // Not needed with PFMET
1707     // mu1.SetMag( mu1.Mag() - vhCand.V.muons[0].emEnergy - vhCand.V.muons[0].hadEnergy);
1708     // mu2.SetMag( mu2.Mag() - vhCand.V.muons[1].emEnergy - vhCand.V.muons[1].hadEnergy);
1709     TVector3 sum = vhCand.V.mets.at(0).p4.Vect() + mu1 + mu2;
1710     fakeMET.et = sum.Pt();
1711     fakeMET.phi = sum.Phi();
1712     fakeMET.sumet = vhCand.V.mets.at(0).sumEt - mu1.Pt() - mu2.Pt();
1713     }
1714    
1715 degrutto 1.69
1716    
1717 arizzi 1.36 METnoPU.et = iEvent->metNoPU.p4.Pt();
1718     METnoPU.phi = iEvent->metNoPU.p4.Phi();
1719     METnoPU.sumet = iEvent->metNoPU.sumEt;
1720     METnoPU.sig = iEvent->metNoPU.metSig;
1721 arizzi 1.59 METnoPUCh.et = iEvent->metCh.p4.Pt();
1722     METnoPUCh.phi = iEvent->metCh.p4.Phi();
1723     METnoPUCh.sumet = iEvent->metCh.sumEt;
1724     METnoPUCh.sig = iEvent->metCh.metSig;
1725 arizzi 1.36
1726 arizzi 1.58 METnoPUCh.et = iEvent->metCh.p4.Pt();
1727     METnoPUCh.phi = iEvent->metCh.p4.Phi();
1728     METnoPUCh.sumet = iEvent->metCh.sumEt;
1729     METnoPUCh.sig = iEvent->metCh.metSig;
1730    
1731 degrutto 1.69
1732     METtype1corr.et = iEvent->pfmetType1corr.p4.Pt();
1733     METtype1corr.phi = iEvent->pfmetType1corr.p4.Phi();
1734     METtype1corr.sumet = iEvent->pfmetType1corr.sumEt;
1735     METtype1corr.sig = iEvent->pfmetType1corr.metSig;
1736    
1737    
1738     METtype1p2corr.et = iEvent->pfmetType1p2corr.p4.Pt();
1739     METtype1p2corr.phi = iEvent->pfmetType1p2corr.p4.Phi();
1740     METtype1p2corr.sumet = iEvent->pfmetType1p2corr.sumEt;
1741     METtype1p2corr.sig = iEvent->pfmetType1p2corr.metSig;
1742    
1743    
1744     METnoPUtype1corr.et = iEvent->pfmetNoPUType1corr.p4.Pt();
1745     METnoPUtype1corr.phi = iEvent->pfmetNoPUType1corr.p4.Phi();
1746     METnoPUtype1corr.sumet = iEvent->pfmetNoPUType1corr.sumEt;
1747     METnoPUtype1corr.sig = iEvent->pfmetNoPUType1corr.metSig;
1748    
1749    
1750     METnoPUtype1p2corr.et = iEvent->pfmetNoPUType1p2corr.p4.Pt();
1751     METnoPUtype1p2corr.phi = iEvent->pfmetNoPUType1p2corr.p4.Phi();
1752     METnoPUtype1p2corr.sumet = iEvent->pfmetNoPUType1p2corr.sumEt;
1753     METnoPUtype1p2corr.sig = iEvent->pfmetNoPUType1p2corr.metSig;
1754    
1755     // std::cout << " iEvent->metUncInfo.size() " << iEvent->metUncInfo.size() << std::endl;
1756     for(size_t m=0;m<iEvent->metUncInfo.size();m++)
1757     {
1758     metUnc.set(iEvent->metUncInfo[m], m );
1759     // std::cout << "metUncInfo[" << m <<" ].et = " << metUnc.et[m] << std::endl;
1760     }
1761    
1762    
1763 arizzi 1.36 rho = aux.puInfo.rho;
1764     rho25 = aux.puInfo.rho25;
1765 arizzi 1.82 rhoN = aux.puInfo.rhoNeutral;
1766 arizzi 1.36 nPVs=aux.pvInfo.nVertices;
1767    
1768 arizzi 1.24 if(!fromCandidate) {
1769     MHT.mht = iEvent->mht.p4.Pt();
1770     MHT.phi = iEvent->mht.p4.Phi();
1771     MHT.ht = iEvent->mht.sumEt;
1772     MHT.sig = iEvent->mht.metSig;
1773 bortigno 1.30 }
1774    
1775 arizzi 1.24
1776 malbouis 1.71 /////////
1777     // track sharing flags:
1778     ////////
1779     TkSharing.HiggsCSVtkSharing = TkSharing.HiggsIPtkSharing = TkSharing.HiggsSVtkSharing = TkSharing.FatHiggsCSVtkSharing = TkSharing.FatHiggsIPtkSharing = TkSharing.FatHiggsSVtkSharing = false;
1780    
1781     // csv tracks
1782 dlopes 1.73 if(vhCand.H.HiggsFlag){
1783    
1784 malbouis 1.71 if (vhCand.H.jets[0].csvNTracks > 0 && vhCand.H.jets[1].csvNTracks > 0){
1785     for (int t=0;t!=vhCand.H.jets[0].csvNTracks;t++){
1786     for (int ti=0;ti!=vhCand.H.jets[1].csvNTracks;ti++){
1787     if ((int)vhCand.H.jets[0].csvTrackIds[t] == (int)vhCand.H.jets[1].csvTrackIds[ti]){
1788     TkSharing.HiggsCSVtkSharing = true;
1789     }// same trackID
1790     }// loop tracks in second hjet
1791     }// loop tracks in first hjet
1792     }// if tracks in jet
1793    
1794     // ip tracks
1795     if (vhCand.H.jets[0].btagNTracks > 0 && vhCand.H.jets[1].btagNTracks > 0){
1796     for (int t=0;t!=vhCand.H.jets[0].btagNTracks;t++){
1797     for (int ti=0;ti!=vhCand.H.jets[1].btagNTracks;ti++){
1798     if ((int)vhCand.H.jets[0].btagTrackIds[t] == (int)vhCand.H.jets[1].btagTrackIds[ti]){
1799     TkSharing.HiggsIPtkSharing = true;
1800     }// same trackID
1801     }// loop tracks in second hjet
1802     }// loop tracks in first hjet
1803     }// if tracks in jet
1804    
1805     // sv tracks
1806     if (vhCand.H.jets[0].vtxNTracks > 0 && vhCand.H.jets[1].vtxNTracks > 0){
1807     for (int t=0;t!=vhCand.H.jets[0].vtxNTracks;t++){
1808     for (int ti=0;ti!=vhCand.H.jets[1].vtxNTracks;ti++){
1809     if ((int)vhCand.H.jets[0].vtxTrackIds[t] == (int)vhCand.H.jets[1].vtxTrackIds[ti]){
1810     TkSharing.HiggsSVtkSharing = true;
1811     }// same trackID
1812     }// loop tracks in second hjet
1813     }// loop tracks in first hjet
1814     }// if tracks in jet
1815 arizzi 1.24
1816 dlopes 1.73 } // Di-jet Higgs Flag
1817    
1818 malbouis 1.71 // tracksharing for Filtered jets:
1819     if(vhCand.FatH.FatHiggsFlag && nfathFilterJets > 1){
1820    
1821     // csv tracks
1822     if (vhCand.FatH.jets[0].csvNTracks > 0 && vhCand.FatH.jets[1].csvNTracks > 0){
1823     for (int t=0;t!=vhCand.FatH.jets[0].csvNTracks;t++){
1824     for (int ti=0;ti!=vhCand.FatH.jets[1].csvNTracks;ti++){
1825     if ((int)vhCand.FatH.jets[0].csvTrackIds[t] == (int)vhCand.FatH.jets[1].csvTrackIds[ti]){
1826     TkSharing.FatHiggsCSVtkSharing = true;
1827     }// same trackID
1828     }// loop tracks in second hjet
1829     }// loop tracks in first hjet
1830     }// if tracks in jet
1831    
1832     // ip tracks
1833     if (vhCand.FatH.jets[0].btagNTracks > 0 && vhCand.FatH.jets[1].btagNTracks > 0){
1834     for (int t=0;t!=vhCand.FatH.jets[0].btagNTracks;t++){
1835     for (int ti=0;ti!=vhCand.FatH.jets[1].btagNTracks;ti++){
1836     if ((int)vhCand.FatH.jets[0].btagTrackIds[t] == (int)vhCand.FatH.jets[1].btagTrackIds[ti]){
1837     TkSharing.FatHiggsIPtkSharing = true;
1838     }// same trackID
1839     }// loop tracks in second hjet
1840     }// loop tracks in first hjet
1841     }// if tracks in jet
1842    
1843     // sv tracks
1844     if (vhCand.FatH.jets[0].vtxNTracks > 0 && vhCand.FatH.jets[1].vtxNTracks > 0){
1845     for (int t=0;t!=vhCand.FatH.jets[0].vtxNTracks;t++){
1846     for (int ti=0;ti!=vhCand.FatH.jets[1].vtxNTracks;ti++){
1847     if ((int)vhCand.FatH.jets[0].vtxTrackIds[t] == (int)vhCand.FatH.jets[1].vtxTrackIds[ti]){
1848     TkSharing.FatHiggsSVtkSharing = true;
1849     }// same trackID
1850     }// loop tracks in second hjet
1851     }// loop tracks in first hjet
1852     }// if tracks in jet
1853    
1854     }// fatH
1855    
1856     ////////
1857     ////////
1858 arizzi 1.70
1859 bortigno 1.30 //Secondary Vertices
1860     IVF.reset();
1861     nSvs = svc.size();
1862     const TVector3 recoPv = aux.pvInfo.firstPVInPT2;
1863     const math::XYZPoint myPv(recoPv);
1864 bortigno 1.74
1865     //FAKE ERROR MATRIX
1866     // //look here for Matrix filling info http://project-mathlibs.web.cern.ch/project-mathlibs/sw/html/SMatrixDoc.html
1867     // std::vector<double> fillMatrix(6);
1868     // for (int i = 0; i<6; ++i) fillMatrix[i] = 0.;
1869     // fillMatrix[0] = TMath::Power(0.002,2);
1870     // fillMatrix[2] = TMath::Power(0.002,2);
1871     // fillMatrix[5] = TMath::Power(0.002,2);
1872     // const ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > myFakeMatrixError(fillMatrix.begin(),fillMatrix.end());
1873     // const reco::Vertex recoVtxPv(myPv, myFakeMatrixError);
1874    
1875 bortigno 1.75 // REAL ERROR MATRIX
1876 bortigno 1.74 const reco::Vertex recoVtxPv(myPv, aux.pvInfo.efirstPVInPT2);
1877 bortigno 1.30 for( int j=0; j < nSvs && j < MAXB; ++j ) {
1878     const GlobalVector flightDir = flightDirection(recoPv,svc[j]);
1879     reco::SecondaryVertex recoSv(recoVtxPv, svc[j], flightDir ,true);
1880     IVF.set( recoSv, recoPv ,j);
1881     }
1882 bortigno 1.74 if(nSvs > 1){
1883 bortigno 1.30 TLorentzVector BCands_H1, BCands_H2, BCands_H;
1884     BCands_H1.SetPtEtaPhiM(IVF.pt[0], IVF.eta[0], IVF.phi[0], IVF.massBcand[0]);
1885     BCands_H2.SetPtEtaPhiM(IVF.pt[1], IVF.eta[1], IVF.phi[1], IVF.massBcand[1]);
1886     BCands_H = BCands_H1 + BCands_H2;
1887 arizzi 1.33 SVH.dR = deltaR(IVF.eta[0], IVF.phi[0], IVF.eta[1], IVF.phi[1] );
1888     SVH.dPhi = deltaPhi(IVF.phi[0], IVF.phi[1] );
1889     SVH.dEta = TMath::Abs(IVF.eta[0] - IVF.eta[1] );
1890     SVH.mass = BCands_H.M();
1891     SVH.pt = BCands_H.Pt();
1892     SVH.eta = BCands_H.Eta();
1893     SVH.phi = BCands_H.Phi();
1894 bortigno 1.30 }
1895    
1896 bortigno 1.74 //SimBhadron
1897     SimBs.reset();
1898     if(isMC_){
1899     nSimBs = sbhc->size();
1900     for( int j=0; j < nSimBs && j < MAXB; ++j )
1901     SimBs.set( sbhc->at(j), j);
1902     if(nSimBs > 1){
1903     TLorentzVector SimBs_H1, SimBs_H2, SimBs_H;
1904     SimBs_H1.SetPtEtaPhiM(SimBs.pt[0], SimBs.eta[0], SimBs.phi[0], SimBs.mass[0]);
1905     SimBs_H2.SetPtEtaPhiM(SimBs.pt[1], SimBs.eta[1], SimBs.phi[1], SimBs.mass[1]);
1906     SimBs_H = SimBs_H1 + SimBs_H2;
1907     SimBsH.dR = deltaR(SimBs.eta[0], SimBs.phi[0], SimBs.eta[1], SimBs.phi[1] );
1908     SimBsH.dPhi = deltaPhi(SimBs.phi[0], SimBs.phi[1] );
1909     SimBsH.dEta = TMath::Abs(SimBs.eta[0] - SimBs.eta[1] );
1910     SimBsH.mass = SimBs_H.M();
1911     SimBsH.pt = SimBs_H.Pt();
1912     SimBsH.eta = SimBs_H.Eta();
1913     SimBsH.phi = SimBs_H.Phi();
1914     }
1915     }
1916 bortigno 1.30
1917     //Loop on jets
1918     double maxBtag=-99999;
1919     minDeltaPhijetMET = 999;
1920     TLorentzVector bJet;
1921     std::vector<std::vector<BTagWeight::JetInfo> > btagJetInfos;
1922 arizzi 1.64 std::vector<float> jet10eta;
1923     std::vector<float> jet10pt;
1924 bortigno 1.30 std::vector<float> jet30eta;
1925     std::vector<float> jet30pt;
1926     if(fromCandidate)
1927     {
1928     //Loop on Higgs Jets
1929     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ){
1930     if (vhCand.H.jets[j].csv > maxBtag) { bJet=vhCand.H.jets[j].p4 ; maxBtag =vhCand.H.jets[j].csv; }
1931 arizzi 1.39 if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi())) < minDeltaPhijetMET)
1932 bortigno 1.30 {
1933 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi()));
1934 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.H.jets[j].p4.Pt();
1935 bortigno 1.30 }
1936     btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
1937     }
1938     //Loop on Additional Jets
1939     for(unsigned int j=0; j < vhCand.additionalJets.size(); j++ ){
1940     if (vhCand.additionalJets[j].csv > maxBtag) { bJet=vhCand.additionalJets[j].p4 ; maxBtag =vhCand.additionalJets[j].csv; }
1941 arizzi 1.45 /* if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi())) < minDeltaPhijetMET)
1942 bortigno 1.30 {
1943 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi()));
1944 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.additionalJets[j].p4.Pt();
1945 arizzi 1.45 }*/
1946 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
1947     {
1948     if(vhCand.additionalJets[j].p4.Pt() > 20)
1949     btagJetInfos.push_back(btagEff.jetInfo(vhCand.additionalJets[j]));
1950     }
1951     }
1952     }
1953     else
1954     {
1955 arizzi 1.45 //Loop on all jets
1956 bortigno 1.30 for(unsigned int j=0; j < iEvent->simpleJets2.size(); j++ ){
1957     if (iEvent->simpleJets2[j].csv > maxBtag) { bJet=iEvent->simpleJets2[j].p4 ; maxBtag =iEvent->simpleJets2[j].csv; }
1958 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)
1959 arizzi 1.46 {
1960     minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi()));
1961     jetPt_minDeltaPhijetMET=iEvent->simpleJets2[j].p4.Pt();
1962     }
1963 arizzi 1.64 if(iEvent->simpleJets2[j].p4.Pt() > 10)
1964     {
1965     jet10eta.push_back(iEvent->simpleJets2[j].p4.Eta());
1966     jet10pt.push_back(iEvent->simpleJets2[j].p4.Pt());
1967     }
1968 bortigno 1.30 if(iEvent->simpleJets2[j].p4.Pt() > 30)
1969     {
1970     jet30eta.push_back(iEvent->simpleJets2[j].p4.Eta());
1971     jet30pt.push_back(iEvent->simpleJets2[j].p4.Pt());
1972     }
1973 arizzi 1.24
1974 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)
1975     // 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
1976     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )
1977     {
1978 arizzi 1.58 if(iEvent->simpleJets2[j].p4.Pt() > 20 && fabs(iEvent->simpleJets2[j].p4.Eta()) < 2.5)
1979 bortigno 1.30 btagJetInfos.push_back(btagEff.jetInfo(iEvent->simpleJets2[j]));
1980     }
1981     }
1982    
1983 arizzi 1.45 //Loop on Higgs jets
1984    
1985 dlopes 1.73 if(vhCand.H.HiggsFlag){
1986 arizzi 1.45 for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ) {
1987    
1988 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
1989     // by a criteria (pt of the dijet) that is not btag SF dependent
1990     if(!( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )) {
1991 arizzi 1.45 btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
1992 bortigno 1.30 }
1993 arizzi 1.45 }
1994 dlopes 1.73 }// HiggsFlag
1995 arizzi 1.24
1996 bortigno 1.30 }
1997     vLeptons.reset();
1998     weightTrig = 1.; // better to default to 1
1999 arizzi 1.38 weightTrigMay = -1.;
2000     weightTrigV4 = -1.;
2001 arizzi 1.51 weightTrigOrMu30 = 1.;
2002 bortigno 1.30 TLorentzVector leptonForTop;
2003     size_t firstAddMu=0;
2004     size_t firstAddEle=0;
2005     if(Vtype == VHbbCandidate::Zmumu ){
2006 arizzi 1.82 vLeptons.set(vhCand.V.muons[0],0,13,aux);
2007     vLeptons.set(vhCand.V.muons[1],1,13,aux);
2008 bortigno 1.30 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleMuID(vLeptons.pt[1],vLeptons.eta[1]) ;
2009     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2010     float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[1],vLeptons.eta[1]);
2011     float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
2012 arizzi 1.89 //2011
2013     weightTrig = cweightID * cweightTrig;
2014    
2015 arizzi 1.110
2016     weightTrig2012DiMuon = triggerWeight.doubleMuon2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2017     float weightTrig2012SingleMuonMu1 = triggerWeight.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2018     float weightTrig2012SingleMuonMu2 = triggerWeight.singleMuon2012A(vLeptons.pt[1],vLeptons.eta[1]);
2019     weightTrig2012SingleMuon = weightTrig2012SingleMuonMu1+weightTrig2012SingleMuonMu2-weightTrig2012SingleMuonMu1*weightTrig2012SingleMuonMu2;
2020     weightTrig2012= weightTrig2012SingleMuon * triggerWeight.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.muId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2021    
2022     weightTrig2012ABDiMuon = triggerWeightAB.doubleMuon2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2023     float weightTrig2012ABSingleMuonMu1 = triggerWeightAB.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2024     float weightTrig2012ABSingleMuonMu2 = triggerWeightAB.singleMuon2012A(vLeptons.pt[1],vLeptons.eta[1]);
2025     weightTrig2012ABSingleMuon = weightTrig2012ABSingleMuonMu1+weightTrig2012ABSingleMuonMu2-weightTrig2012ABSingleMuonMu1*weightTrig2012ABSingleMuonMu2;
2026     weightTrig2012AB = weightTrig2012ABSingleMuon * triggerWeightAB.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeightAB.muId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2027    
2028     weightTrig2012A=weightTrig2012;
2029     weightTrig2012ADiMuon=weightTrig2012DiMuon;
2030     weightTrig2012ASingleMuon=weightTrig2012SingleMuon;
2031 arizzi 1.89
2032 bortigno 1.30 nvlep=2;
2033     firstAddMu=2;
2034     }
2035     if( Vtype == VHbbCandidate::Zee ){
2036 arizzi 1.82 vLeptons.set(vhCand.V.electrons[0],0,11,aux);
2037     vLeptons.set(vhCand.V.electrons[1],1,11,aux);
2038 bortigno 1.30 nvlep=2;
2039     firstAddEle=2;
2040     std::vector<float> pt,eta;
2041     pt.push_back(vLeptons.pt[0]); eta.push_back(vLeptons.eta[0]);
2042     pt.push_back(vLeptons.pt[1]); eta.push_back(vLeptons.eta[1]);
2043     weightEleRecoAndId=triggerWeight.scaleID95Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]) *
2044     triggerWeight.scaleID95Ele(vLeptons.pt[1],vLeptons.eta[1]) * triggerWeight.scaleRecoEle(vLeptons.pt[1],vLeptons.eta[1]);
2045     weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
2046 arizzi 1.60 weightEleTrigEleAugPart = triggerWeight.scaleDoubleEle17Ele8Aug(pt,eta);
2047     weightTrig = (weightEleTrigElePart*1.14+weightEleTrigEleAugPart*0.98 )/2.12 * weightEleRecoAndId;
2048 arizzi 1.24
2049 arizzi 1.89 weightTrig2012ADiEle = triggerWeight.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2050     float weightTrig2012ASingleEle1 = triggerWeight.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2051     float weightTrig2012ASingleEle2 = triggerWeight.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2052     weightTrig2012ASingleEle = weightTrig2012ASingleEle1+weightTrig2012ASingleEle2-weightTrig2012ASingleEle1*weightTrig2012ASingleEle2;
2053 arizzi 1.101 weightTrig2012A = weightTrig2012ADiEle * triggerWeight.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2054 arizzi 1.24
2055 arizzi 1.110 weightTrig2012DiEle = triggerWeight.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2056     float weightTrig2012SingleEle1 = triggerWeight.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2057     float weightTrig2012SingleEle2 = triggerWeight.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2058     weightTrig2012SingleEle = weightTrig2012SingleEle1+weightTrig2012SingleEle2-weightTrig2012SingleEle1*weightTrig2012SingleEle2;
2059     weightTrig2012 = weightTrig2012DiEle * triggerWeight.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2060    
2061     weightTrig2012ABDiEle = triggerWeightAB.doubleEle2012A(vLeptons.pt[0],vLeptons.eta[0],vLeptons.pt[1],vLeptons.eta[1]);
2062     float weightTrig2012ABSingleEle1 = triggerWeightAB.singleEle2012Awp95(vLeptons.pt[0],vLeptons.eta[0]);
2063     float weightTrig2012ABSingleEle2 = triggerWeightAB.singleEle2012Awp95(vLeptons.pt[1],vLeptons.eta[1]);
2064     weightTrig2012ABSingleEle = weightTrig2012ABSingleEle1+weightTrig2012ABSingleEle2-weightTrig2012ABSingleEle1*weightTrig2012ABSingleEle2;
2065     weightTrig2012AB = weightTrig2012ABDiEle * triggerWeightAB.eleId2012A(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeightAB.eleId2012A(vLeptons.pt[1],vLeptons.eta[1]) ;
2066 bortigno 1.30 }
2067     if(Vtype == VHbbCandidate::Wmun ){
2068     leptonForTop=vhCand.V.muons[0].p4;
2069 arizzi 1.82 vLeptons.set(vhCand.V.muons[0],0,13,aux);
2070 bortigno 1.30 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]);
2071     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2072     float cweightTrig = weightTrig1;
2073     weightTrig = cweightID * cweightTrig;
2074 arizzi 1.51 float weightTrig1OrMu30 = triggerWeight.scaleMuOr30IsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
2075 dlopes 1.61 weightTrigOrMu30 = cweightID*weightTrig1OrMu30;
2076 arizzi 1.89 weightTrig2012ASingleMuon = triggerWeight.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2077     weightTrig2012AMuonPlusWCandPt = weightTrig2012ASingleMuon +
2078     triggerWeight.muPlusWCandPt2012A_legMu(vLeptons.pt[0],vLeptons.eta[0])*triggerWeight.muPlusWCandPt2012A_legW(vhCand.V.p4.Pt(),0);
2079 arizzi 1.101 weightTrig2012A = weightTrig2012ASingleMuon * triggerWeight.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) ;
2080 arizzi 1.89
2081 arizzi 1.110
2082     weightTrig2012SingleMuon = weightTrig2012ASingleMuon;
2083     weightTrig2012MuonPlusWCandPt = weightTrig2012AMuonPlusWCandPt;
2084     weightTrig2012 = weightTrig2012A;
2085    
2086    
2087    
2088     weightTrig2012ABSingleMuon = triggerWeightAB.singleMuon2012A(vLeptons.pt[0],vLeptons.eta[0]);
2089     weightTrig2012ABMuonPlusWCandPt = weightTrig2012ABSingleMuon +
2090     triggerWeightAB.muPlusWCandPt2012A_legMu(vLeptons.pt[0],vLeptons.eta[0])*triggerWeightAB.muPlusWCandPt2012A_legW(vhCand.V.p4.Pt(),0);
2091     weightTrig2012AB = weightTrig2012ABSingleMuon * triggerWeightAB.muId2012A(vLeptons.pt[0],vLeptons.eta[0]) ;
2092    
2093    
2094    
2095 bortigno 1.30 nvlep=1;
2096     firstAddMu=1;
2097     }
2098     if( Vtype == VHbbCandidate::Wen ){
2099     leptonForTop=vhCand.V.electrons[0].p4;
2100 arizzi 1.82 vLeptons.set(vhCand.V.electrons[0],0,11,aux);
2101 bortigno 1.30 nvlep=1;
2102     firstAddEle=1;
2103 arizzi 1.38 weightTrigMay = triggerWeight.scaleSingleEleMay(vLeptons.pt[0],vLeptons.eta[0]);
2104     weightTrigV4 = triggerWeight.scaleSingleEleV4(vLeptons.pt[0],vLeptons.eta[0]);
2105 bortigno 1.30 weightEleRecoAndId=triggerWeight.scaleID80Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]);
2106 arizzi 1.59 weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30pt,jet30eta)*triggerWeight.scalePFMHTEle(MET.et);
2107 arizzi 1.38 weightEleTrigElePart= weightTrigV4; //this is for debugging only, checking only the V4 part
2108 bortigno 1.30
2109 arizzi 1.38 weightTrigMay*=weightEleRecoAndId;
2110     weightTrigV4*=weightEleRecoAndId;
2111     weightTrigV4*=weightEleTrigJetMETPart;
2112 arizzi 1.60 // weightTrig = weightTrigMay * 0.187 + weightTrigV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
2113     weightTrig = (weightTrigMay * 0.215 + weightTrigV4 * 1.915)/ 2.13; //FIXME: use proper lumi if we reload 2.fb
2114 arizzi 1.89
2115 arizzi 1.110
2116 arizzi 1.89 weightTrig2012ASingleEle = triggerWeight.singleEle2012Awp80(vLeptons.pt[0],vLeptons.eta[0]);
2117 arizzi 1.101 weightTrig2012A = weightTrig2012ASingleEle * triggerWeight.eleId2012Awp80(vLeptons.pt[0],vLeptons.eta[0]) ;
2118 arizzi 1.89
2119 arizzi 1.110 weightTrig2012SingleEle = weightTrig2012ASingleEle;
2120     weightTrig2012 = weightTrig2012A;
2121    
2122     weightTrig2012ABSingleEle = triggerWeightAB.singleEle2012Awp80(vLeptons.pt[0],vLeptons.eta[0]);
2123     weightTrig2012AB = weightTrig2012ABSingleEle * triggerWeightAB.eleId2012Awp80(vLeptons.pt[0],vLeptons.eta[0]) ;
2124 arizzi 1.89
2125 bortigno 1.30 }
2126 arizzi 1.64
2127 arizzi 1.65 if(isMC_)
2128     {
2129 arizzi 1.64 weightTrigMET80 = triggerWeight.scaleMET80(MET.et);
2130     weightTrigMET100 = triggerWeight.scaleMET80(MET.et);
2131     weightTrig2CJet20 = triggerWeight.scale2CentralJet( jet10pt, jet10eta);
2132     weightTrigMET150 = triggerWeight.scaleMET150(MET.et);
2133     weightTrigMET802CJet= weightTrigMET80 * weightTrig2CJet20;
2134     weightTrigMET1002CJet= weightTrigMET100 * weightTrig2CJet20;
2135 degrutto 1.108 weightTrig2012DiJet30MHT80=triggerWeight.scaleDiJet30MHT80_2012A(vhCand.V.mets.at(0).p4.Pt());
2136     weightTrig2012PFMET150=triggerWeight.scalePFMET150_2012AB(vhCand.V.mets.at(0).p4.Pt()); // demonstrated to hold also for RunC (used averaged efficiency)
2137     weightTrig2012SumpT100MET100=triggerWeight.scaleSumpT100MET100_2012B(vhCand.V.mets.at(0).p4.Pt()); // demonstrated to hold also for RunC (used averaged efficiency)
2138     weightTrig2012APFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012A(vhCand.V.mets.at(0).p4.Pt());
2139     weightTrig2012BPFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012B(vhCand.V.mets.at(0).p4.Pt());
2140     weightTrig2012CPFMET150orDiJetMET=triggerWeight.scalePFMET150orDiJetMET_2012C(vhCand.V.mets.at(0).p4.Pt());
2141    
2142    
2143 arizzi 1.65 }
2144 bortigno 1.30 if( Vtype == VHbbCandidate::Znn ){
2145     nvlep=0;
2146     float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
2147 arizzi 1.64 weightTrigMETLP = weightTrig1;
2148     weightTrig = weightTrigMET150 + weightTrigMET802CJet - weightTrigMET802CJet*weightTrigMET150;
2149 degrutto 1.102
2150 arizzi 1.92 // weightTrig2012A =
2151 bortigno 1.30 }
2152 arizzi 1.38
2153     if(weightTrigMay < 0) weightTrigMay=weightTrig;
2154     if(weightTrigV4 < 0) weightTrigV4=weightTrig;
2155 arizzi 1.40 if(!isMC_)
2156     {
2157     weightTrig = 1.;
2158     weightTrigMay = 1.;
2159     weightTrigV4 = 1.;
2160 arizzi 1.64 weightEleRecoAndId= 1.;
2161     weightEleTrigJetMETPart= 1.;
2162     weightEleTrigElePart= 1.;
2163     weightEleTrigEleAugPart=1.;
2164     weightTrigMET80= 1.;
2165     weightTrigMET100= 1.;
2166     weightTrig2CJet20= 1.;
2167     weightTrigMET150= 1.;
2168     weightTrigMET802CJet= 1.;
2169     weightTrigMET1002CJet= 1.;
2170     weightTrigMETLP = 1.;
2171 arizzi 1.40
2172     }
2173 bortigno 1.30 aLeptons.reset();
2174     nalep=0;
2175     if(fromCandidate)
2176 arizzi 1.21 {
2177 arizzi 1.82 for(size_t j=firstAddMu;j< vhCand.V.muons.size();j++) aLeptons.set(vhCand.V.muons[j],nalep++,13,aux);
2178     for(size_t j=firstAddEle;j< vhCand.V.electrons.size();j++) aLeptons.set(vhCand.V.electrons[j],nalep++,11,aux);
2179 arizzi 1.21 }
2180 bortigno 1.30 else
2181 arizzi 1.21 {
2182 bortigno 1.30 for(size_t j=0;j< iEvent->muInfo.size();j++)
2183     {
2184 arizzi 1.21 if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wmun ) && (Vtype != VHbbCandidate::Zmumu )) )
2185 arizzi 1.82 aLeptons.set(iEvent->muInfo[j],nalep++,13,aux);
2186 bortigno 1.30 }
2187     for(size_t j=0;j< iEvent->eleInfo.size();j++)
2188     {
2189 arizzi 1.21 if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wen ) && (Vtype != VHbbCandidate::Zee )))
2190 arizzi 1.82 aLeptons.set(iEvent->eleInfo[j],nalep++,11,aux);
2191 bortigno 1.30 }
2192 arizzi 1.8
2193 arizzi 1.21 }
2194 arizzi 1.8
2195 arizzi 1.24
2196 bortigno 1.30 if(isMC_)
2197     {
2198     //std::cout << "BTAGSF " << btagJetInfos.size() << " " << btag.weight<BTag1Tight2CustomFilter>(btagJetInfos) << std::endl;
2199     if ( btagJetInfos.size()< 10)
2200     {
2201     btag1T2CSF = btag.weight<BTag1Tight2CustomFilter>(btagJetInfos);
2202     btag2TSF = btag.weight<BTag2TightFilter>(btagJetInfos);
2203     btag1TSF = btag.weight<BTag1TightFilter>(btagJetInfos);
2204 arizzi 1.44 btagA0CSF = btag.weight<BTagAntiMax0CustomFilter>(btagJetInfos);
2205 arizzi 1.60 btagA0TSF = btag.weight<BTagAntiMax0TightFilter>(btagJetInfos);
2206 arizzi 1.44 btag2CSF = btag.weight<BTag2CustomFilter>(btagJetInfos);
2207 arizzi 1.51 btag1TA1C = btag.weight<BTag1TightAndMax1CustomFilter>(btagJetInfos);
2208 bortigno 1.30 }
2209     else
2210     {
2211     std::cout << "WARNING: combinatorics for " << btagJetInfos.size() << " jets is too high (>=10). use SF=1 " << std::endl;
2212     //TODO: revert to random throw for this cases
2213     btag1T2CSF = 1.;
2214     btag2TSF = 1.;
2215     btag1TSF = 1.;
2216 arizzi 1.51 btagA0CSF = 1.;
2217 arizzi 1.60 btagA0TSF = 1.;
2218 arizzi 1.51 btag2CSF = 1.;
2219     btag1TA1C = 1.;
2220 bortigno 1.30 }
2221     }
2222 arizzi 1.17
2223 bortigno 1.30 if(maxBtag > -99999)
2224 arizzi 1.8 {
2225 bortigno 1.30 TopHypo topQuark = TopMassReco::topMass(leptonForTop,bJet,vhCand.V.mets.at(0).p4);
2226     top.mass = topQuark.p4.M();
2227     top.pt = topQuark.p4.Pt();
2228     top.wMass = topQuark.p4W.M();
2229 arizzi 1.8 } else {
2230 bortigno 1.30 top.mass = -99;
2231     top.pt = -99;
2232     top.wMass = -99;
2233     }
2234 arizzi 1.8
2235    
2236    
2237 bortigno 1.30 //FIXME: too much warnings... figure out why
2238     // gendrcc=aux.genCCDeltaR();
2239     // gendrbb=aux.genBBDeltaR();
2240 degrutto 1.69
2241    
2242    
2243 bortigno 1.30 genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
2244     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
2245 degrutto 1.69
2246     // Z* is status=3 and Nmother=2 (q and qbar)
2247     // Z is status=2 and Ndau=2 (mup and mum)
2248     for (unsigned int i=0; i<aux.mcZ.size(); i++){
2249     if (aux.mcZ[i].status==3) {
2250     genZstar.mass = aux.mcZ[i].p4.M();
2251     genZstar.pt = aux.mcZ[i].p4.Pt();
2252 arizzi 1.111 // genZstar.eta = aux.mcZ[i].p4.Eta();
2253     if(genZstar.pt>0.1) genZstar.eta = aux.mcZ[i].p4.Eta(); else genZstar.eta=-99;
2254    
2255 degrutto 1.69 genZstar.phi = aux.mcZ[i].p4.Phi();
2256     genZstar.status = aux.mcZ[i].status;
2257     genZstar.charge = aux.mcZ[i].charge;
2258     if (aux.mcZ[i].momid!=-99) genZstar.momid = aux.mcZ[i].momid ;
2259     }
2260    
2261    
2262    
2263     if (aux.mcZ[i].dauid.size()>1) {
2264     if ( abs(aux.mcZ[i].dauid[0])==13 || abs(aux.mcZ[i].dauid[0])==11 ) {
2265     genZ.mass = aux.mcZ[i].p4.M();
2266     genZ.pt = aux.mcZ[i].p4.Pt();
2267 arizzi 1.111 // genZ.eta = aux.mcZ[i].p4.Eta();
2268     if(genZ.pt>0.1) genZ.eta = aux.mcZ[i].p4.Eta(); else genZ.eta=-99;
2269 degrutto 1.69 genZ.phi = aux.mcZ[i].p4.Phi();
2270     genZ.status = aux.mcZ[i].status;
2271     genZ.charge = aux.mcZ[i].charge;
2272     if ( aux.mcZ[i].momid!=-99) genZ.momid = aux.mcZ[i].momid;
2273     }
2274     }
2275     }
2276    
2277    
2278    
2279     for (unsigned int i=0; i<aux.mcW.size(); i++){
2280     if ( aux.mcW[i].momid==6 && aux.mcW[i].dauid.size()>1 ){
2281     genTop.wdau1mass= aux.mcW[i].dauFourMomentum[0].M();
2282     genTop.wdau1pt= aux.mcW[i].dauFourMomentum[0].Pt();
2283     genTop.wdau1eta= aux.mcW[i].dauFourMomentum[0].Eta();
2284     genTop.wdau1phi= aux.mcW[i].dauFourMomentum[0].Phi();
2285     genTop.wdau1id= aux.mcW[i].dauid[0];
2286    
2287     genTop.wdau2mass= aux.mcW[i].dauFourMomentum[1].M();
2288     genTop.wdau2pt= aux.mcW[i].dauFourMomentum[1].Pt();
2289     genTop.wdau2eta= aux.mcW[i].dauFourMomentum[1].Eta();
2290     genTop.wdau2phi= aux.mcW[i].dauFourMomentum[1].Phi();
2291     genTop.wdau2id= aux.mcW[i].dauid[1];
2292    
2293     }
2294    
2295    
2296     if ( aux.mcW[i].momid==-6 && aux.mcW[i].dauid.size()>1 ){
2297     genTbar.wdau1mass= aux.mcW[i].dauFourMomentum[0].M();
2298     genTbar.wdau1pt= aux.mcW[i].dauFourMomentum[0].Pt();
2299     genTbar.wdau1eta= aux.mcW[i].dauFourMomentum[0].Eta();
2300     genTbar.wdau1phi= aux.mcW[i].dauFourMomentum[0].Phi();
2301     genTbar.wdau1id= aux.mcW[i].dauid[0];
2302    
2303     genTbar.wdau2mass= aux.mcW[i].dauFourMomentum[1].M();
2304     genTbar.wdau2pt= aux.mcW[i].dauFourMomentum[1].Pt();
2305     genTbar.wdau2eta= aux.mcW[i].dauFourMomentum[1].Eta();
2306     genTbar.wdau2phi= aux.mcW[i].dauFourMomentum[1].Phi();
2307     genTbar.wdau2id= aux.mcW[i].dauid[1];
2308    
2309     }
2310    
2311     if (aux.mcW[i].status==3 ) {
2312     genWstar.mass = aux.mcW[i].p4.M();
2313     genWstar.pt = aux.mcW[i].p4.Pt();
2314     genWstar.eta = aux.mcW[i].p4.Eta();
2315     genWstar.phi = aux.mcW[i].p4.Phi();
2316     genWstar.status = aux.mcW[i].status;
2317     genWstar.charge = aux.mcW[i].charge;
2318     if ( aux.mcW[i].momid!=-99) genWstar.momid = aux.mcW[i].momid;
2319     }
2320     if (aux.mcW[i].dauid.size()>1 && (abs(aux.mcW[i].dauid[0])==13 || abs(aux.mcW[i].dauid[0])==11 )) {
2321     genW.mass = aux.mcW[i].p4.M();
2322     genW.pt = aux.mcW[i].p4.Pt();
2323     genW.eta = aux.mcW[i].p4.Eta();
2324     genW.phi = aux.mcW[i].p4.Phi();
2325     genW.status = aux.mcW[i].status;
2326     genW.charge = aux.mcW[i].charge;
2327     if (aux.mcW[i].momid!=-99) genW.momid = aux.mcW[i].momid;
2328     }
2329     }
2330     // b coming from Higgs
2331     for (unsigned int i=0; i<aux.mcB.size(); i++){
2332     if (abs(aux.mcB[i].momid)!=5) {
2333     genB.mass = aux.mcB[i].p4.M();
2334     genB.pt = aux.mcB[i].p4.Pt();
2335     genB.eta = aux.mcB[i].p4.Eta();
2336     genB.phi = aux.mcB[i].p4.Phi();
2337     genB.status = aux.mcB[i].status;
2338     genB.charge = aux.mcB[i].charge;
2339     if (aux.mcB[i].momid!=-99) genB.momid = aux.mcB[i].momid;
2340     }
2341    
2342     if ( aux.mcB[i].momid==6 ){
2343     genTop.bmass = aux.mcB[i].p4.M();
2344     genTop.bpt = aux.mcB[i].p4.Pt();
2345     genTop.beta = aux.mcB[i].p4.Eta();
2346     genTop.bphi = aux.mcB[i].p4.Phi();
2347     genTop.bstatus = aux.mcB[i].status;
2348    
2349     }
2350     }
2351    
2352     for (unsigned int i=0; i<aux.mcBbar.size(); i++){
2353     if (abs(aux.mcBbar[i].momid)!=5 ) {
2354     genBbar.mass = aux.mcBbar[i].p4.M();
2355     genBbar.pt = aux.mcBbar[i].p4.Pt();
2356     genBbar.eta = aux.mcBbar[i].p4.Eta();
2357     genBbar.phi = aux.mcBbar[i].p4.Phi();
2358     genBbar.status = aux.mcBbar[i].status;
2359     if (aux.mcBbar[i].momid!=-99) genBbar.momid = aux.mcBbar[i].momid;
2360     }
2361     if ( aux.mcBbar[i].momid==-6 ){
2362     genTbar.bmass = aux.mcBbar[i].p4.M();
2363     genTbar.bpt = aux.mcBbar[i].p4.Pt();
2364     genTbar.beta = aux.mcBbar[i].p4.Eta();
2365     genTbar.bphi = aux.mcBbar[i].p4.Phi();
2366     genTbar.bstatus = aux.mcBbar[i].status;
2367    
2368    
2369     }
2370    
2371     }
2372    
2373    
2374    
2375    
2376     if (aux.mcH.size()>0) {
2377     genH.mass = aux.mcH[0].p4.M();
2378     genH.pt = aux.mcH[0].p4.Pt();
2379     genH.eta = aux.mcH[0].p4.Eta();
2380     genH.phi = aux.mcH[0].p4.Phi();
2381     genH.status = aux.mcH[0].status;
2382     genH.charge = aux.mcH[0].charge;
2383     if (aux.mcH[0].momid!=-99) genH.momid = aux.mcH[0].momid;
2384     }
2385    
2386    
2387    
2388    
2389 arizzi 1.49 WminusMode=-99;
2390     WplusMode=-99;
2391 arizzi 1.50 for(unsigned int j=0; j< aux.mcW.size();j++)
2392 arizzi 1.49 {
2393 degrutto 1.66 for(unsigned int k=0;k< aux.mcW[j].dauid.size();k++)
2394     {
2395     int idd=abs(aux.mcW[j].dauid[k]);
2396     if(idd==11 || idd==13 || idd==15|| (idd<=5 && idd >=1))
2397     {
2398     if(WminusMode==-99 && aux.mcW[j].charge ==-1) WminusMode = idd;
2399     if(WplusMode==-99 && aux.mcW[j].charge ==+1) WplusMode = idd;
2400     }
2401     }
2402     /*
2403     /// now check if a semileptonic W is also in a bjets....
2404     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;
2405     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;
2406    
2407     for( int j=0; j < naJets && j < MAXJ; j++ )
2408     {
2409     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;
2410    
2411     }
2412     */
2413    
2414     }
2415 arizzi 1.32 /// Compute pull angle from AK7
2416 dlopes 1.73 if(vhCand.H.HiggsFlag){
2417 arizzi 1.25 if(!fromCandidate){
2418 arizzi 1.32 std::vector<VHbbEvent::SimpleJet> ak7wrt1(iEvent->simpleJets3);
2419     std::vector<VHbbEvent::SimpleJet> ak7wrt2(iEvent->simpleJets3);
2420     if(ak7wrt1.size() > 1){
2421 arizzi 1.24 CompareDeltaR deltaRComparatorJ1(vhCand.H.jets[0].p4);
2422     CompareDeltaR deltaRComparatorJ2(vhCand.H.jets[1].p4);
2423 arizzi 1.32 std::sort( ak7wrt1.begin(),ak7wrt1.end(),deltaRComparatorJ1 );
2424     std::sort( ak7wrt2.begin(),ak7wrt2.end(),deltaRComparatorJ2 );
2425 arizzi 1.24 std::vector<VHbbEvent::SimpleJet> ak7_matched;
2426 arizzi 1.32 // if the matched are different save them
2427     if(ak7wrt1[0].p4.DeltaR(ak7wrt2[0].p4) > 0.1) {
2428     ak7_matched.push_back(ak7wrt1[0]);
2429     ak7_matched.push_back(ak7wrt2[0]);
2430     }
2431     // else look at the second best
2432     else{
2433     // ak7wrt1 is best
2434     if( ak7wrt1[1].p4.DeltaR(vhCand.H.jets[0].p4) < ak7wrt2[1].p4.DeltaR(vhCand.H.jets[1].p4))
2435     {
2436     ak7_matched.push_back(ak7wrt1[1]);
2437     ak7_matched.push_back(ak7wrt2[0]);
2438     }
2439     else
2440     {
2441     ak7_matched.push_back(ak7wrt1[0]);
2442     ak7_matched.push_back(ak7wrt2[1]);
2443     }
2444     }
2445 arizzi 1.24 CompareJetPt ptComparator;
2446     std::sort( ak7_matched.begin(),ak7_matched.end(),ptComparator );
2447     if(ak7_matched[0].p4.DeltaR(vhCand.H.jets[0].p4) < 0.5
2448 arizzi 1.32 and ak7_matched[1].p4.DeltaR(vhCand.H.jets[1].p4) < 0.5)
2449     {
2450     deltaPullAngleAK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[0],ak7_matched[1]);
2451 arizzi 1.52 deltaPullAngle2AK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[1],ak7_matched[0]);
2452 arizzi 1.32 }
2453 arizzi 1.24 }
2454     }
2455 dlopes 1.73 }//HiggsFlag
2456 arizzi 1.3
2457 bortigno 1.30 _outTree->Fill();
2458 arizzi 1.4
2459 degrutto 1.69 }// closed event loop
2460 arizzi 1.1
2461 bortigno 1.30 std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
2462     inFile->Close();
2463     // close input file
2464     } // loop on files
2465 arizzi 1.1
2466    
2467 bortigno 1.30 std::cout << "Events: " << ievt <<std::endl;
2468     std::cout << "TotalCount: " << totalcount <<std::endl;
2469 arizzi 1.1
2470    
2471    
2472 bortigno 1.30 _outFile->cd();
2473 arizzi 1.1
2474 bortigno 1.30 _outTree->Write();
2475     _outFile->Write();
2476     _outFile->Close();
2477     return 0;
2478 arizzi 1.1 }
2479    
2480