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