ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.68
Committed: Thu Feb 23 19:52:35 2012 UTC (13 years, 2 months ago) by degrutto
Content type: text/plain
Branch: MAIN
Changes since 1.67: +37 -8 lines
Log Message:
added soft lepton infor for semileptonic b-decays

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     //Move class definition to Ntupler.h ?
43     //#include "VHbbAnalysis/VHbbDataFormats/interface/Ntupler.h"
44    
45 bortigno 1.30 //for SimBhad: FIXME
46     //#include "VHbbAnalysis/BAnalysis/interface/SimBHadron.h"
47     //btagging
48 arizzi 1.16 #include "VHbbAnalysis/VHbbDataFormats/interface/BTagWeight.h"
49 bortigno 1.30 //trigger
50 arizzi 1.16 #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerWeight.h"
51    
52 arizzi 1.1 #include <sstream>
53     #include <string>
54    
55     #define MAXJ 30
56     #define MAXL 10
57 bortigno 1.30 #define MAXB 10
58 arizzi 1.1
59 arizzi 1.24 struct CompareDeltaR {
60 bortigno 1.30 CompareDeltaR(TLorentzVector p4dir_): p4dir(p4dir_) {}
61     bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
62     return j1.p4.DeltaR(p4dir) > j2.p4.DeltaR(p4dir);
63     }
64     TLorentzVector p4dir;
65 arizzi 1.24 };
66 arizzi 1.4
67 bortigno 1.30 const GlobalVector flightDirection(const TVector3 pv, const reco::Vertex &sv){
68     GlobalVector fdir(sv.position().X() - pv.X(),
69     sv.position().Y() - pv.Y(),
70     sv.position().Z() - pv.Z());
71     return fdir;
72     }
73    
74 nmohr 1.7 bool jsonContainsEvent (const std::vector< edm::LuminosityBlockRange > &jsonVec,
75     const edm::EventBase &event)
76     {
77 bortigno 1.30 // if the jsonVec is empty, then no JSON file was provided so all
78     // events should pass
79     if (jsonVec.empty())
80     {
81 nmohr 1.7 return true;
82 bortigno 1.30 }
83     bool (* funcPtr) (edm::LuminosityBlockRange const &,
84     edm::LuminosityBlockID const &) = &edm::contains;
85     edm::LuminosityBlockID lumiID (event.id().run(),
86     event.id().luminosityBlock());
87     std::vector< edm::LuminosityBlockRange >::const_iterator iter =
88     std::find_if (jsonVec.begin(), jsonVec.end(),
89     boost::bind(funcPtr, _1, lumiID) );
90     return jsonVec.end() != iter;
91 nmohr 1.7
92     }
93    
94 arizzi 1.64 float resolutionBias(float eta)
95     {
96     // return 0;//Nominal!
97     if(eta< 1.1) return 0.05;
98     if(eta< 2.5) return 0.10;
99     if(eta< 5) return 0.30;
100     return 0;
101     }
102    
103 arizzi 1.1
104 bortigno 1.30 //FIXME : need to update EDM ntuple with SimBhadron infos
105     // typedef struct
106     // {
107     // void set(const SimBHadron & sbhc, int i){
108     // mass[i] = sbhc.mass();
109     // pt[i] = sbhc.pt();
110     // eta[i] = sbhc.eta();
111     // phi[i] = sbhc.phi();
112     // vtx_x[i] = sbhc.decPosition.x();
113     // vtx_y[i] = sbhc.decPosition.y();
114     // vtx_z[i] = sbhc.decPosition.z();
115     // pdgId[i] = sbhc.pdgId();
116     // status[i] = sbhc.status();
117     // };
118     // void reset(){
119     // for(int i=0; i < MAXB; ++i){
120     // 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;
121     // }
122     // };
123     // float mass[MAXB];
124     // float pt[MAXB];
125     // float eta[MAXB];
126     // float phi[MAXB];
127     // float vtx_x[MAXB];
128     // float vtx_y[MAXB];
129     // float vtx_z[MAXB];
130     // int pdgId[MAXB];
131     // int status[MAXB];
132     // // int quarkStatus[MAXB];
133     // // int brotherStatus[MAXB];
134     // // int otherId[MAXB];
135     // // bool etaOk[MAXB];
136     // // bool simOk[MAXB];
137     // // bool trackOk[MAXB];
138     // // bool cutOk[MAXB];
139     // // bool cutNewOk[MAXB];
140     // // bool mcMatchOk[MAXB];
141     // // bool matchOk[MAXB];
142     // } SimBHadronInfo;
143    
144    
145     typedef struct
146     {
147     void set( const reco::SecondaryVertex & recoSv, const TVector3 recoPv, int isv){
148     pt[isv] = recoSv.p4().Pt();
149     eta[isv] = flightDirection(recoPv,recoSv).eta();
150     phi[isv] = flightDirection(recoPv,recoSv).phi();
151     massBcand[isv] = recoSv.p4().M();
152     massSv[isv] = recoSv.p4().M();
153     dist3D[isv] = recoSv.dist3d().value();
154     distSig3D[isv] = recoSv.dist3d().significance();
155     dist2D[isv] = recoSv.dist2d().value();
156     distSig2D[isv] = recoSv.dist2d().significance();
157     dist3D_norm[isv] = recoSv.dist3d().value()/recoSv.p4().Gamma();
158     };
159     void reset(){
160     for(int i = 0; i < MAXB; ++i){
161     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;
162     }
163     };
164     float massBcand[MAXB];
165     float massSv[MAXB];
166     float pt[MAXB];
167     float eta[MAXB];
168     float phi[MAXB];
169     float dist3D[MAXB];
170     float distSig3D[MAXB];
171     float dist2D[MAXB];
172     float distSig2D[MAXB];
173     float dist3D_norm[MAXB];
174     } IVFInfo;
175 arizzi 1.1
176 bortigno 1.30
177     typedef struct
178     {
179 arizzi 1.33 float mass;
180     float pt;
181     float eta;
182     float phi;
183     float dR;
184     float dPhi;
185     float dEta;
186     } HiggsInfo;
187 dlopes 1.67
188     typedef struct
189     {
190     bool FatHiggsFlag;
191     float mass;
192     float pt;
193     float eta;
194     float phi;
195     float filteredmass;
196     float filteredpt;
197     // float dR;
198     // float dPhi;
199     // float dEta;
200     } FatHiggsInfo;
201    
202    
203 arizzi 1.33 typedef struct
204     {
205 bortigno 1.30 float mass; //MT in case of W
206     float pt;
207     float eta;
208     float phi;
209     } TrackInfo;
210 arizzi 1.1
211    
212 arizzi 1.9 struct LeptonInfo
213 bortigno 1.30 {
214     void reset()
215 arizzi 1.1 {
216 arizzi 1.48 for(int i =0; i < MAXL;i++){
217 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;
218     id80[i]=-99; id95[i]=-99; vbtf[i]=-99; id80NoIso[i]=-99;
219 arizzi 1.48 }
220 bortigno 1.30 }
221 arizzi 1.1
222 bortigno 1.30 template <class Input> void set(const Input & i, int j,int t)
223     {
224     type[j]=t;
225     pt[j]=i.p4.Pt();
226     mass[j]=i.p4.M();
227     eta[j]=i.p4.Eta();
228     phi[j]=i.p4.Phi();
229     aodCombRelIso[j]=(i.hIso+i.eIso+i.tIso)/i.p4.Pt();
230     pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
231     photonIso[j]=i.pfPhoIso;
232     neutralHadIso[j]=i.pfNeuIso;
233     chargedHadIso[j]=i.pfChaIso;
234 dlopes 1.55 chargedPUIso[j]=i.pfChaPUIso;
235 arizzi 1.64 if(i.mcFourMomentum.Pt() > 0)
236     {
237     genPt[j]=i.mcFourMomentum.Pt();
238     genEta[j]=i.mcFourMomentum.Eta();
239     genPhi[j]=i.mcFourMomentum.Phi();
240     }
241     setSpecific(i,j);
242 bortigno 1.30 }
243     template <class Input> void setSpecific(const Input & i, int j)
244     {
245     }
246 arizzi 1.4
247    
248    
249 arizzi 1.1
250 bortigno 1.30 float mass[MAXL]; //MT in case of W
251     float pt[MAXL];
252     float eta[MAXL];
253     float phi[MAXL];
254     float aodCombRelIso[MAXL];
255     float pfCombRelIso[MAXL];
256     float photonIso[MAXL];
257     float neutralHadIso[MAXL];
258     float chargedHadIso[MAXL];
259 dlopes 1.55 float chargedPUIso[MAXL];
260 bortigno 1.30 float particleIso[MAXL];
261 arizzi 1.64 float genPt[MAXL];
262     float genEta[MAXL];
263     float genPhi[MAXL];
264 bortigno 1.30 float dxy[MAXL];
265     float dz[MAXL];
266     int type[MAXL];
267     float id80[MAXL];
268     float id95[MAXL];
269 arizzi 1.48 float vbtf[MAXL];
270 arizzi 1.64 float id80NoIso[MAXL];
271 bortigno 1.30 };
272 arizzi 1.1
273 bortigno 1.30 template <> void LeptonInfo::setSpecific<VHbbEvent::ElectronInfo>(const VHbbEvent::ElectronInfo & i, int j){
274 arizzi 1.36 id80[j]=i.id80;
275     id95[j]=i.id95;
276 arizzi 1.64 id80NoIso[j]=(i.innerHits ==0 && !(fabs(i.convDist)<0.02 && fabs(i.convDcot)<0.02) &&
277     ((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)));
278 bortigno 1.30 }
279     template <> void LeptonInfo::setSpecific<VHbbEvent::MuonInfo>(const VHbbEvent::MuonInfo & i, int j){
280     dxy[j]=i.ipDb;
281     dz[j]=i.zPVPt;
282 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 &&
283     (i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt()<.15 && fabs(i.p4.Eta())<2.4 && i.p4.Pt()>20 ) ;
284    
285 bortigno 1.30 }
286    
287 arizzi 1.4
288 bortigno 1.30 typedef struct
289     {
290     float et;
291     float sumet;
292     float sig;
293     float phi;
294     } METInfo;
295 arizzi 1.1
296 bortigno 1.30 typedef struct
297     {
298     float mht;
299     float ht;
300     float sig;
301     float phi;
302     } MHTInfo;
303 nmohr 1.5
304 bortigno 1.30 typedef struct
305     {
306     float mass;
307     float pt;
308     float wMass;
309     } TopInfo;
310 arizzi 1.1
311 bortigno 1.30 typedef struct
312     {
313     int run;
314     int lumi;
315     int event;
316     int json;
317     } EventInfo;
318 arizzi 1.1
319 bortigno 1.30 typedef struct
320     {
321     void set(const VHbbEvent::SimpleJet & j, int i)
322 arizzi 1.1 {
323 bortigno 1.30 pt[i]=j.p4.Pt();
324     eta[i]=j.p4.Eta();
325     phi[i]=j.p4.Phi();
326 arizzi 1.51 e[i]=j.p4.E();
327 bortigno 1.30 csv[i]=j.csv;
328     numTracksSV[i] = j.vtxMass;
329     vtxMass[i]= j.vtxMass;
330     vtx3dL[i] = j.vtx3dL;
331     vtx3deL[i] = j.vtx3deL;
332     chf[i]=j.chargedHadronEFraction;
333     nhf[i] =j.neutralHadronEFraction;
334     cef[i] =j.chargedEmEFraction;
335     nef[i] =j.neutralEmEFraction;
336     nconstituents[i] =j.nConstituents;
337     nch[i]=j.ntracks;
338 arizzi 1.64 SF_CSVL[i]=j.SF_CSVL;
339     SF_CSVM[i]=j.SF_CSVM;
340     SF_CSVT[i]=j.SF_CSVT;
341     SF_CSVLerr[i]=j.SF_CSVLerr;
342     SF_CSVMerr[i]=j.SF_CSVMerr;
343     SF_CSVTerr[i]=j.SF_CSVTerr;
344 bortigno 1.30
345     flavour[i]=j.flavour;
346 degrutto 1.66 isSemiLeptMCtruth[i]=j.isSemiLeptMCtruth;
347     isSemiLept[i]=j.isSemiLept;
348 degrutto 1.68 SoftLeptpdgId[i] = j.SoftLeptpdgId;
349     SoftLeptIdlooseMu[i] = j.SoftLeptIdlooseMu;
350     SoftLeptId95[i] = j.SoftLeptId95;
351     SoftLeptPt[i] = j.SoftLeptPt;
352     SoftLeptdR[i] = j.SoftLeptdR;
353     SoftLeptptRel[i] = j.SoftLeptptRel;
354     SoftLeptRelCombIso[i] = j.SoftLeptRelCombIso;
355 bortigno 1.30 if(j.bestMCp4.Pt() > 0)
356     {
357     genPt[i]=j.bestMCp4.Pt();
358     genEta[i]=j.bestMCp4.Eta();
359     genPhi[i]=j.bestMCp4.Phi();
360     }
361     JECUnc[i]=j.jecunc;
362 arizzi 1.36 id[i]=jetId(i);
363     }
364     bool jetId(int i)
365     {
366     if(nhf[i] > 0.99) return false;
367     if(nef[i] > 0.99) return false;
368 arizzi 1.37 if(nconstituents[i] <= 1) return false;
369 arizzi 1.47 if(fabs(eta[i])<2.5) {
370 arizzi 1.36 if(cef[i] > 0.99) return false;
371 arizzi 1.37 if(chf[i] == 0) return false;
372 arizzi 1.36 if(nch[i]== 0) return false;
373 arizzi 1.37 }
374 arizzi 1.36 return true;
375 bortigno 1.30 }
376     void reset()
377     {
378     for(int i=0;i<MAXJ;i++) {
379 degrutto 1.68 pt[i]=-99; eta[i]=-99; phi[i]=-99;e[i]=-99;csv[i]=-99; 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; SoftLeptpdgId[i] = -99; SoftLeptIdlooseMu[i] = -99; SoftLeptId95[i] = -99; SoftLeptPt[i] = -99; SoftLeptdR[i] = -99; SoftLeptptRel[i] = -99; SoftLeptRelCombIso[i] = -99; genPt[i]=-99; genEta[i]=-99; genPhi[i]=-99; JECUnc[i]=-99;
380 arizzi 1.1 }
381 bortigno 1.30 }
382     float pt[MAXJ];
383     float eta[MAXJ];
384     float phi[MAXJ];
385 arizzi 1.51 float e[MAXJ];
386 bortigno 1.30 float csv[MAXJ];
387     float cosTheta[MAXJ];
388     int numTracksSV[MAXJ];
389     float chf[MAXJ];
390     float nhf[MAXJ];
391     float cef[MAXJ];
392     float nef[MAXJ];
393     float nch[MAXJ];
394     float nconstituents[MAXJ];
395     float flavour[MAXJ];
396 degrutto 1.68 int isSemiLept[MAXJ];
397     int isSemiLeptMCtruth[MAXJ];
398     int SoftLeptpdgId[MAXJ] ;
399     int SoftLeptIdlooseMu[MAXJ] ;
400     int SoftLeptId95[MAXJ] ;
401     float SoftLeptPt[MAXJ] ;
402     float SoftLeptdR[MAXJ] ;
403     float SoftLeptptRel[MAXJ] ;
404     float SoftLeptRelCombIso[MAXJ];
405 bortigno 1.30 float genPt[MAXJ];
406     float genEta[MAXJ];
407     float genPhi[MAXJ];
408     float JECUnc[MAXJ];
409     float vtxMass[MAXJ];
410     float vtx3dL [MAXJ];
411     float vtx3deL[MAXJ];
412 arizzi 1.36 bool id[MAXJ];
413 arizzi 1.64 float SF_CSVL[MAXJ];
414     float SF_CSVM[MAXJ];
415     float SF_CSVT[MAXJ];
416     float SF_CSVLerr[MAXJ];
417     float SF_CSVMerr[MAXJ];
418     float SF_CSVTerr[MAXJ];
419 bortigno 1.30 } JetInfo;
420 arizzi 1.1
421     int main(int argc, char* argv[])
422     {
423     gROOT->Reset();
424    
425     TTree *_outTree;
426 bortigno 1.30 IVFInfo IVF;
427     //FIXME
428     // SimBHadronInfo SimBs;
429 arizzi 1.39 float rho,rho25;
430     int nPVs;
431 arizzi 1.9 METInfo MET;
432 arizzi 1.52 METInfo fakeMET;
433 arizzi 1.36 METInfo METnoPU;
434 arizzi 1.58 METInfo METnoPUCh;
435 arizzi 1.9 MHTInfo MHT;
436     TopInfo top;
437     EventInfo EVENT;
438 bortigno 1.30 // JetInfo jet1,jet2, addJet1, addJet2;
439 arizzi 1.9 // lepton1,lepton2;
440 dlopes 1.67 JetInfo hJets, aJets, fathFilterJets;
441 arizzi 1.9 LeptonInfo vLeptons, aLeptons;
442 dlopes 1.67 int naJets=0, nhJets=0, nfathFilterJets=0;
443 arizzi 1.33 HiggsInfo H,SVH; //add here the fatjet higgs
444 dlopes 1.67 FatHiggsInfo FatH;
445 arizzi 1.9 TrackInfo V;
446     int nvlep=0,nalep=0;
447 arizzi 1.1
448 degrutto 1.54
449    
450 arizzi 1.62 float HVdPhi,HVMass,HMETdPhi,VMt,deltaPullAngle,deltaPullAngleAK7,deltaPullAngle2,deltaPullAngle2AK7,gendrcc,gendrbb, genZpt, genWpt, weightTrig, weightTrigMay,weightTrigV4, weightTrigMET, weightTrigOrMu30, minDeltaPhijetMET, jetPt_minDeltaPhijetMET , PUweight, PUweight2011B;
451     float PU0,PUp1,PUm1;
452 degrutto 1.54
453 arizzi 1.60 float weightEleRecoAndId,weightEleTrigJetMETPart, weightEleTrigElePart,weightEleTrigEleAugPart;
454 arizzi 1.64 float weightTrigMET80, weightTrigMET100, weightTrig2CJet20 , weightTrigMET150 , weightTrigMET802CJet, weightTrigMET1002CJet, weightTrigMETLP ;
455 arizzi 1.24
456 bortigno 1.30 //FIXME
457     // float SimBs_dr = -99, SimBs_dEta= -99, SimBs_dPhi = -99, SimBs_Hmass = -99, SimBs_Hpt = -99, SimBs_Heta = -99, SimBs_Hphi = -99;
458 arizzi 1.49 int WplusMode,WminusMode;
459 bortigno 1.30 int Vtype,nSvs,nSimBs,numJets,numBJets,eventFlav;
460     // bool isMET80_CJ80, ispfMHT150, isMET80_2CJ20,isMET65_2CJ20, isJETID,isIsoMu17;
461 arizzi 1.63 bool triggerFlags[500],hbhe,ecalFlag,totalKinematics;
462 arizzi 1.60 float btag1T2CSF=1.,btag2TSF=1.,btag1TSF=1.,btagA0CSF=1., btagA0TSF=1., btag2CSF=1., btag1TA1C=1.;
463 arizzi 1.1 // ----------------------------------------------------------------------
464     // First Part:
465     //
466     // * enable the AutoLibraryLoader
467     // * book the histograms of interest
468     // * open the input file
469     // ----------------------------------------------------------------------
470    
471     // load framework libraries
472 bortigno 1.30 gSystem->Load("libFWCoreFWLite");
473 arizzi 1.1 gSystem->Load("libDataFormatsFWLite");
474     AutoLibraryLoader::enable();
475    
476     // parse arguments
477     if ( argc < 2 ) {
478     return 0;
479     }
480    
481 arizzi 1.4 std::vector<VHbbCandidate> * candZlocal = new std::vector<VHbbCandidate>;
482     std::vector<VHbbCandidate> * candWlocal = new std::vector<VHbbCandidate>;
483    
484 arizzi 1.1 // get the python configuration
485     PythonProcessDesc builder(argv[1]);
486     const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
487     const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
488     const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
489 bortigno 1.30
490 nmohr 1.7 std::vector<edm::LuminosityBlockRange> jsonVector;
491     if ( in.exists("lumisToProcess") )
492 bortigno 1.30 {
493     std::vector<edm::LuminosityBlockRange> const & lumisTemp =
494     in.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> > ("lumisToProcess");
495 nmohr 1.7 jsonVector.resize( lumisTemp.size() );
496     copy( lumisTemp.begin(), lumisTemp.end(), jsonVector.begin() );
497 bortigno 1.30 }
498 arizzi 1.1
499     // now get each parameter
500     int maxEvents_( in.getParameter<int>("maxEvents") );
501 nmohr 1.29 int skipEvents_( in.getParameter<int>("skipEvents") );
502 arizzi 1.64 int runMin_( in.getParameter<int>("runMin") );
503     int runMax_( in.getParameter<int>("runMax") );
504 arizzi 1.1 unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
505     std::string outputFile_( out.getParameter<std::string>("fileName" ) );
506     std::vector<std::string> triggers( ana.getParameter<std::vector<std::string> >("triggers") );
507 arizzi 1.6 double btagThr = ana.getParameter<double>("bJetCountThreshold" );
508 arizzi 1.4 bool fromCandidate = ana.getParameter<bool>("readFromCandidates");
509 arizzi 1.17 bool useHighestPtHiggsZ = ana.getParameter<bool>("useHighestPtHiggsZ");
510     bool useHighestPtHiggsW = ana.getParameter<bool>("useHighestPtHiggsW");
511 nmohr 1.31 HbbCandidateFinderAlgo * algoZ = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdZ"),useHighestPtHiggsZ);
512     HbbCandidateFinderAlgo * algoW = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdW"),useHighestPtHiggsW );
513 arizzi 1.64 HbbCandidateFinderAlgo * algoRecoverLowPt = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), 15, true);
514 arizzi 1.4
515 arizzi 1.16 TriggerWeight triggerWeight(ana);
516 arizzi 1.17 BTagWeight btag(2); // 2 operating points "Custom" = 0.5 and "Tight = 0.898"
517     BTagSampleEfficiency btagEff( ana.getParameter<std::string>("btagEffFileName" ).c_str() );
518 arizzi 1.1
519     std::vector<std::string> inputFiles_( in.getParameter<std::vector<std::string> >("fileNames") );
520 bortigno 1.30 // std::string inputFile( in.getParameter<std::string> ("fileName") );
521 arizzi 1.1
522 arizzi 1.3 std::string PUmcfileName_ = in.getParameter<std::string> ("PUmcfileName") ;
523 degrutto 1.57 std::string PUmcfileName2011B_ = in.getParameter<std::string> ("PUmcfileName2011B") ;
524    
525 arizzi 1.3 std::string PUdatafileName_ = in.getParameter<std::string> ("PUdatafileName") ;
526 degrutto 1.54 std::string PUdatafileName2011B_ = in.getParameter<std::string> ("PUdatafileName2011B") ;
527 arizzi 1.63 std::string Weight3DfileName_ = in.getParameter<std::string> ("Weight3DfileName") ;
528 degrutto 1.54
529    
530    
531 arizzi 1.1 bool isMC_( ana.getParameter<bool>("isMC") );
532     TriggerReader trigger(isMC_);
533 arizzi 1.18 TriggerReader patFilters(false);
534 arizzi 1.25
535     edm::LumiReWeighting lumiWeights;
536 arizzi 1.64 edm::Lumi3DReWeighting lumiWeights2011B;
537 arizzi 1.25 if(isMC_)
538 bortigno 1.30 {
539 arizzi 1.34 lumiWeights = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
540 degrutto 1.54
541 arizzi 1.64 lumiWeights2011B = edm::Lumi3DReWeighting(PUmcfileName2011B_,PUdatafileName2011B_ , "pileup", "pileup");
542 arizzi 1.63 if(Weight3DfileName_!="")
543     { lumiWeights2011B.weight3D_init(Weight3DfileName_.c_str()); }
544     else
545     {
546 arizzi 1.64 lumiWeights2011B.weight3D_init(1.0); // generate the weights the fisrt time;
547 arizzi 1.63 }
548 degrutto 1.54
549 bortigno 1.30 }
550 arizzi 1.1
551 bortigno 1.30 // TFile *_outPUFile = new TFile((outputFile_+"_PU").c_str(), "recreate");
552     TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
553     TH1F * count = new TH1F("Count","Count", 1,0,2 );
554     TH1F * countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
555 arizzi 1.58 TH1F * countWithPU2011B = new TH1F("CountWithPU2011B","CountWithPU2011B", 1,0,2 );
556 arizzi 1.62 TH3F * input3DPU = new TH3F("Input3DPU","Input3DPU", 36,-0.5,35.5,36,-0.5,35.5, 36,-0.5,35.5 );
557 arizzi 1.58
558 arizzi 1.41 TH1F * pu = new TH1F("pileup","",51,-0.5,50.5);
559 arizzi 1.1 _outTree = new TTree("tree", "myTree");
560    
561 arizzi 1.33 _outTree->Branch("H" , &H , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
562 arizzi 1.1 _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
563 dlopes 1.67 _outTree->Branch("FatH" , &FatH , "FatHiggsFlag/I:mass/F:pt/F:eta:phi/F:filteredmass/F:filteredpt/F");
564 arizzi 1.1 _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
565 dlopes 1.67 _outTree->Branch("nfathFilterJets", &nfathFilterJets, "nfathFilterJets/I");
566 arizzi 1.1 _outTree->Branch("naJets" , &naJets , "naJets/I");
567 arizzi 1.2
568     _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
569     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
570     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
571 arizzi 1.51 _outTree->Branch("hJet_e",hJets.e ,"e[nhJets]/F");
572 arizzi 1.2 _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
573     _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
574     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
575     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
576     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
577     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
578     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
579     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
580     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
581     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
582 degrutto 1.68 _outTree->Branch("hJet_isSemiLept",hJets.isSemiLept ,"isSemiLept[nhJets]/I");
583     _outTree->Branch("hJet_isSemiLeptMCtruth",hJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[nhJets]/I");
584     _outTree->Branch("hJet_SoftLeptpdgId", hJets.SoftLeptpdgId , "SoftLeptpdgId[nhJets]/I");
585     _outTree->Branch("hJet_SoftLeptIdlooseMu", hJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[nhJets]/I");
586     _outTree->Branch("hJet_SoftLeptId95", hJets.SoftLeptId95 , "SoftLeptId95[nhJets]/I");
587     _outTree->Branch("hJet_SoftLeptPt", hJets.SoftLeptPt , "SoftLeptPt[nhJets]/F");
588     _outTree->Branch("hJet_SoftLeptdR", hJets.SoftLeptdR , "SoftLeptdR[nhJets]/F");
589     _outTree->Branch("hJet_SoftLeptptRel", hJets.SoftLeptptRel , "SoftLeptptRel[nhJets]/F");
590     _outTree->Branch("hJet_SoftLeptRelCombIso", hJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[nhJets]/F");
591     _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
592 arizzi 1.2 _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
593     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
594     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
595 arizzi 1.36 _outTree->Branch("hJet_vtxMass",hJets.vtxMass ,"vtxMass[nhJets]/F");
596     _outTree->Branch("hJet_vtx3dL",hJets.vtx3dL ,"vtx3dL[nhJets]/F");
597     _outTree->Branch("hJet_vtx3deL",hJets.vtx3deL ,"vtx3deL[nhJets]/F");
598     _outTree->Branch("hJet_id",hJets.id ,"id[nhJets]/b");
599 arizzi 1.64 _outTree->Branch("hJet_SF_CSVL",hJets.SF_CSVL ,"SF_CSVL[nhJets]/b");
600     _outTree->Branch("hJet_SF_CSVM",hJets.SF_CSVM ,"SF_CSVM[nhJets]/b");
601     _outTree->Branch("hJet_SF_CSVT",hJets.SF_CSVT ,"SF_CSVT[nhJets]/b");
602     _outTree->Branch("hJet_SF_CSVLerr",hJets.SF_CSVLerr ,"SF_CSVLerr[nhJets]/b");
603     _outTree->Branch("hJet_SF_CSVMerr",hJets.SF_CSVMerr ,"SF_CSVMerr[nhJets]/b");
604     _outTree->Branch("hJet_SF_CSVTerr",hJets.SF_CSVTerr ,"SF_CSVTerr[nhJets]/b");
605 arizzi 1.2
606 dlopes 1.67 _outTree->Branch("fathFilterJets_pt",fathFilterJets.pt ,"pt[nfathFilterJets]/F");
607     _outTree->Branch("fathFilterJets_eta",fathFilterJets.eta ,"eta[nfathFilterJets]/F");
608     _outTree->Branch("fathFilterJets_phi",fathFilterJets.phi ,"phi[nfathFilterJets]/F");
609     _outTree->Branch("fathFilterJets_e",fathFilterJets.e ,"e[nfathFilterJets]/F");
610     _outTree->Branch("fathFilterJets_csv",fathFilterJets.csv ,"csv[nfathFilterJets]/F");
611    
612    
613 arizzi 1.2 _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
614     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
615     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
616 arizzi 1.51 _outTree->Branch("aJet_e",aJets.e ,"e[naJets]/F");
617 arizzi 1.2 _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
618     _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
619     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
620     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
621     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
622     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
623     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
624     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
625     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
626     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
627 degrutto 1.68 _outTree->Branch("aJet_isSemiLept",aJets.isSemiLept ,"isSemiLept[naJets]/I");
628     _outTree->Branch("aJet_isSemiLeptMCtruth",aJets.isSemiLeptMCtruth ,"isSemiLeptMCtruth[naJets]/I");
629     _outTree->Branch("aJet_SoftLeptpdgId",aJets.SoftLeptpdgId , "SoftLeptpdgId[naJets]/I");
630     _outTree->Branch("aJet_SoftLeptIdlooseMu", aJets.SoftLeptIdlooseMu , "SoftLeptIdlooseMu[naJets]/I");
631     _outTree->Branch("aJet_SoftLeptId95", aJets.SoftLeptId95 , "SoftLeptId95[naJets]/I");
632     _outTree->Branch("aJet_SoftLeptPt", aJets.SoftLeptPt , "SoftLeptPt[naJets]/F");
633     _outTree->Branch("aJet_SoftLeptdR", aJets.SoftLeptdR , "SoftLeptdR[naJets]/F");
634     _outTree->Branch("aJet_SoftLeptptRel", aJets.SoftLeptptRel , "SoftLeptptRel[naJets]/F");
635     _outTree->Branch("aJet_SoftLeptRelCombIso", aJets.SoftLeptRelCombIso , "SoftLeptRelCombIso[naJets]/F");
636    
637 arizzi 1.2 _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
638     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
639     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
640     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
641 arizzi 1.24 _outTree->Branch("aJet_vtxMass",aJets.vtxMass ,"vtxMass[naJets]/F");
642     _outTree->Branch("aJet_vtx3dL",aJets.vtx3dL ,"vtx3dL[naJets]/F");
643     _outTree->Branch("aJet_vtx3deL",aJets.vtx3deL ,"vtx3deL[naJets]/F");
644 arizzi 1.36 _outTree->Branch("aJet_id",aJets.id ,"id[naJets]/b");
645 arizzi 1.64 _outTree->Branch("aJet_SF_CSVL",aJets.SF_CSVL ,"SF_CSVL[naJets]/b");
646     _outTree->Branch("aJet_SF_CSVM",aJets.SF_CSVM ,"SF_CSVM[naJets]/b");
647     _outTree->Branch("aJet_SF_CSVT",aJets.SF_CSVT ,"SF_CSVT[naJets]/b");
648     _outTree->Branch("aJet_SF_CSVLerr",aJets.SF_CSVLerr ,"SF_CSVLerr[naJets]/b");
649     _outTree->Branch("aJet_SF_CSVMerr",aJets.SF_CSVMerr ,"SF_CSVMerr[naJets]/b");
650     _outTree->Branch("aJet_SF_CSVTerr",aJets.SF_CSVTerr ,"SF_CSVTerr[naJets]/b");
651 arizzi 1.1
652     _outTree->Branch("numJets" , &numJets , "numJets/I" );
653     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
654     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
655 arizzi 1.52 _outTree->Branch("deltaPullAngle2", &deltaPullAngle2 , "deltaPullAngle2/F");
656 arizzi 1.1 _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
657     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
658     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
659     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
660     _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
661 arizzi 1.38 _outTree->Branch("weightTrigMay" , &weightTrigMay , "weightTrigMay/F");
662     _outTree->Branch("weightTrigV4" , &weightTrigV4 , "weightTrigV4/F");
663 arizzi 1.22 _outTree->Branch("weightTrigMET" , &weightTrigMET , "weightTrigMET/F");
664 arizzi 1.51 _outTree->Branch("weightTrigOrMu30" , &weightTrigOrMu30 , "weightTrigOrMu30/F");
665 arizzi 1.24 _outTree->Branch("weightEleRecoAndId" , &weightEleRecoAndId , "weightEleRecoAndId/F");
666     _outTree->Branch("weightEleTrigJetMETPart" , &weightEleTrigJetMETPart , "weightEleTrigJetMETPart/F");
667     _outTree->Branch("weightEleTrigElePart" , &weightEleTrigElePart , "weightEleTrigElePart/F");
668 arizzi 1.60 _outTree->Branch("weightEleTrigEleAugPart" , &weightEleTrigEleAugPart , "weightEleTrigEleAugPart/F");
669 arizzi 1.24
670 arizzi 1.64 _outTree->Branch("weightTrigMET80" , &weightTrigMET80 , "weightTrigMET80/F");
671     _outTree->Branch("weightTrigMET100" , &weightTrigMET100 , "weightTrigMET100/F");
672     _outTree->Branch("weightTrig2CJet20" , &weightTrig2CJet20 , "weightTrig2CJet20/F");
673     _outTree->Branch("weightTrigMET150" , &weightTrigMET150 , "weightTrigMET150/F");
674     _outTree->Branch("weightTrigMET802CJet" , &weightTrigMET802CJet , "weightTrigMET802CJet/F");
675     _outTree->Branch("weightTrigMET1002CJet" , &weightTrigMET1002CJet , "weightTrigMET1002CJet/F");
676     _outTree->Branch("weightTrigMETLP" , &weightTrigMETLP , "weightTrigMETLP/F");
677    
678 arizzi 1.24
679 arizzi 1.1 _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
680 arizzi 1.52 _outTree->Branch("deltaPullAngle2AK7", &deltaPullAngle2AK7 , "deltaPullAngle2AK7/F");
681 arizzi 1.62 _outTree->Branch("PU0", &PU0 , "PU0/F");
682     _outTree->Branch("PUm1", &PUm1 , "PUm1/F");
683     _outTree->Branch("PUp1", &PUp1 , "PUp1/F");
684 arizzi 1.1 _outTree->Branch("PUweight", &PUweight , "PUweight/F");
685 degrutto 1.54 _outTree->Branch("PUweight2011B", &PUweight2011B , "PUweight2011B/F");
686 arizzi 1.3 _outTree->Branch("eventFlav", &eventFlav , "eventFlav/I");
687 arizzi 1.1
688    
689    
690    
691     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
692     _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
693 arizzi 1.41 _outTree->Branch("HVMass" , &HVMass , "HVMass/F" );
694 arizzi 1.19 _outTree->Branch("HMETdPhi" , &HMETdPhi , "HMETdPhi/F" );
695 arizzi 1.1 _outTree->Branch("VMt" , &VMt , "VMt/F" );
696    
697 arizzi 1.9 _outTree->Branch("nvlep" , &nvlep , "nvlep/I");
698     _outTree->Branch("nalep" , &nalep , "nalep/I");
699 arizzi 1.3
700 arizzi 1.9 _outTree->Branch("vLepton_mass",vLeptons.mass ,"mass[nvlep]/F");
701     _outTree->Branch("vLepton_pt",vLeptons.pt ,"pt[nvlep]/F");
702     _outTree->Branch("vLepton_eta",vLeptons.eta ,"eta[nvlep]");
703     _outTree->Branch("vLepton_phi",vLeptons.phi ,"phi[nvlep]/F");
704     _outTree->Branch("vLepton_aodCombRelIso",vLeptons.aodCombRelIso ,"aodCombRelIso[nvlep]/F");
705     _outTree->Branch("vLepton_pfCombRelIso",vLeptons.pfCombRelIso ,"pfCombRelIso[nvlep]/F");
706     _outTree->Branch("vLepton_photonIso",vLeptons.photonIso ,"photonIso[nvlep]/F");
707     _outTree->Branch("vLepton_neutralHadIso",vLeptons.neutralHadIso ,"neutralHadIso[nvlep]/F");
708     _outTree->Branch("vLepton_chargedHadIso",vLeptons.chargedHadIso ,"chargedHadIso[nvlep]/F");
709 dlopes 1.55 _outTree->Branch("vLepton_chargedPUIso",vLeptons.chargedPUIso ,"chargedPUIso[nvlep]/F");
710 arizzi 1.9 _outTree->Branch("vLepton_particleIso",vLeptons.particleIso ,"particleIso[nvlep]/F");
711     _outTree->Branch("vLepton_dxy",vLeptons.dxy ,"dxy[nvlep]/F");
712     _outTree->Branch("vLepton_dz",vLeptons.dz ,"dz[nvlep]/F");
713     _outTree->Branch("vLepton_type",vLeptons.type ,"type[nvlep]/I");
714 arizzi 1.27 _outTree->Branch("vLepton_id80",vLeptons.id80 ,"id80[nvlep]/F");
715     _outTree->Branch("vLepton_id95",vLeptons.id95 ,"id95[nvlep]/F");
716 arizzi 1.48 _outTree->Branch("vLepton_vbtf",vLeptons.vbtf ,"vbtf[nvlep]/F");
717 arizzi 1.64 _outTree->Branch("vLepton_id80NoIso",vLeptons.id80NoIso ,"id80NoIso[nvlep]/F");
718     _outTree->Branch("vLepton_genPt",vLeptons.genPt ,"genPt[nvlep]/F");
719     _outTree->Branch("vLepton_genEta",vLeptons.genEta ,"genEta[nvlep]");
720     _outTree->Branch("vLepton_genPhi",vLeptons.genPhi ,"genPhi[nvlep]/F");
721 arizzi 1.9
722     _outTree->Branch("aLepton_mass",aLeptons.mass ,"mass[nalep]/F");
723     _outTree->Branch("aLepton_pt",aLeptons.pt ,"pt[nalep]/F");
724     _outTree->Branch("aLepton_eta",aLeptons.eta ,"eta[nalep]");
725     _outTree->Branch("aLepton_phi",aLeptons.phi ,"phi[nalep]/F");
726     _outTree->Branch("aLepton_aodCombRelIso",aLeptons.aodCombRelIso ,"aodCombRelIso[nalep]/F");
727     _outTree->Branch("aLepton_pfCombRelIso",aLeptons.pfCombRelIso ,"pfCombRelIso[nalep]/F");
728     _outTree->Branch("aLepton_photonIso",aLeptons.photonIso ,"photonIso[nalep]/F");
729     _outTree->Branch("aLepton_neutralHadIso",aLeptons.neutralHadIso ,"neutralHadIso[nalep]/F");
730     _outTree->Branch("aLepton_chargedHadIso",aLeptons.chargedHadIso ,"chargedHadIso[nalep]/F");
731 dlopes 1.55 _outTree->Branch("aLepton_chargedPUIso",aLeptons.chargedPUIso ,"chargedPUIso[nalep]/F");
732 arizzi 1.9 _outTree->Branch("aLepton_particleIso",aLeptons.particleIso ,"particleIso[nalep]/F");
733     _outTree->Branch("aLepton_dxy",aLeptons.dxy ,"dxy[nalep]/F");
734     _outTree->Branch("aLepton_dz",aLeptons.dz ,"dz[nalep]/F");
735     _outTree->Branch("aLepton_type",aLeptons.type ,"type[nalep]/I");
736 arizzi 1.48 _outTree->Branch("aLepton_id80",aLeptons.id80 ,"id80[nalep]/F");
737     _outTree->Branch("aLepton_id95",aLeptons.id95 ,"id95[nalep]/F");
738     _outTree->Branch("aLepton_vbtf",aLeptons.vbtf ,"vbtf[nalep]/F");
739 arizzi 1.64 _outTree->Branch("aLepton_id80NoIso",aLeptons.id80NoIso ,"id80NoIso[nalep]/F");
740     _outTree->Branch("aLepton_genPt",aLeptons.genPt ,"genPt[nalep]/F");
741     _outTree->Branch("aLepton_genEta",aLeptons.genEta ,"genEta[nalep]");
742     _outTree->Branch("aLepton_genPhi",aLeptons.genPhi ,"genPhi[nalep]/F");
743 arizzi 1.9
744 arizzi 1.8 _outTree->Branch("top" , &top , "mass/F:pt/F:wMass/F");
745 arizzi 1.49 _outTree->Branch("WplusMode" , &WplusMode , "WplusMode/I");
746     _outTree->Branch("WminusMode" , &WminusMode , "WminusMode/I");
747 arizzi 1.1
748 bortigno 1.30 //IVF
749     _outTree->Branch("nSvs",&nSvs ,"nSvs/I");
750 arizzi 1.33 _outTree->Branch("Sv_massBCand", &IVF.massBcand,"massBcand[nSvs]/F");
751     _outTree->Branch("Sv_massSv", &IVF.massSv,"massSv[nSvs]/F");
752     _outTree->Branch("Sv_pt", &IVF.pt,"pt[nSvs]/F");
753     _outTree->Branch("Sv_eta", &IVF.eta,"eta[nSvs]/F");
754     _outTree->Branch("Sv_phi", &IVF.phi,"phi[nSvs]/F");
755     _outTree->Branch("Sv_dist3D", &IVF.dist3D,"dist3D[nSvs]/F");
756     _outTree->Branch("Sv_dist2D", &IVF.dist2D,"dist2D[nSvs]/F");
757     _outTree->Branch("Sv_distSim2D", &IVF.distSig2D,"distSig2D[nSvs]/F");
758     _outTree->Branch("Sv_distSig3D", &IVF.distSig3D,"distSig3D[nSvs]/F");
759     _outTree->Branch("Sv_dist3D_norm", &IVF.dist3D_norm,"dist3D_norm[nSvs]/F");
760 bortigno 1.30 //IVF higgs candidate
761 arizzi 1.33 _outTree->Branch("SVH" , &SVH , "mass/F:pt/F:eta:phi/F:dR/F:dPhi/F:dEta/F");
762 bortigno 1.30
763    
764     //FIXME : need to update the EDMNtuple with BHadron infos
765     // //SimBHadron
766     // _outTree->Branch("nSimBs",&nSimBs ,"nSimBs/I");
767     // _outTree->Branch("SimBs_mass", &SimBs.mass,"mass[nSvs]/F");
768     // _outTree->Branch("SimBs_pt", &SimBs.pt,"pt[nSvs]/F");
769     // _outTree->Branch("SimBs_eta", &SimBs.eta,"eta[nSvs]/F");
770     // _outTree->Branch("SimBs_phi", &SimBs.phi,"phi[nSvs]/F");
771     // _outTree->Branch("SimBs_vtx_x", &SimBs.vtx_x,"vtx_x[nSvs]/F");
772     // _outTree->Branch("SimBs_vtx_y", &SimBs.vtx_y,"vtx_y[nSvs]/F");
773     // _outTree->Branch("SimBs_vtx_z", &SimBs.vtx_z,"vtx_z[nSvs]/F");
774     // _outTree->Branch("SimBs_pdgId", &SimBs.pdgId,"pdgId[nSvs]/F");
775     // _outTree->Branch("SimBs_status", &SimBs.status,"status[nSvs]/F");
776     // //SimBHadron Higgs Candidate
777     // _outTree->Branch("SimBs_dr", &SimBs_dr,"SimBs_dr/F");
778     // _outTree->Branch("SimBs_dPhi", &SimBs_dPhi,"SimBs_dPhi/F");
779     // _outTree->Branch("SimBs_dEta", &SimBs_dEta,"SimBs_dEta/F");
780     // _outTree->Branch("SimBs_Hmass", &SimBs_Hmass,"SimBs_Hmass/F");
781     // _outTree->Branch("SimBs_Hpt", &SimBs_Hpt,"SimBs_Hpt/F");
782     // _outTree->Branch("SimBs_Heta", &SimBs_Heta,"SimBs_Heta/F");
783     // _outTree->Branch("SimBs_Hphi", &SimBs_Hphi,"SimBs_Hphi/F");
784    
785    
786 arizzi 1.36 _outTree->Branch("rho" , &rho , "rho/F");
787     _outTree->Branch("rho25" , &rho25 , "rho25/F");
788     _outTree->Branch("nPVs" , &nPVs , "nPVs/I");
789     _outTree->Branch("METnoPU" , &METnoPU , "et/F:sumet:sig/F:phi/F");
790 arizzi 1.58 _outTree->Branch("METnoPUCh" , &METnoPUCh , "et/F:sumet:sig/F:phi/F");
791 arizzi 1.1 _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
792 arizzi 1.52 _outTree->Branch("fakeMET" , &fakeMET , "et/F:sumet:sig/F:phi/F");
793 arizzi 1.1 _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
794     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
795     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
796    
797 bortigno 1.30 std::stringstream s;
798     s << "triggerFlags[" << triggers.size() << "]/b";
799     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
800 arizzi 1.17
801 bortigno 1.30 _outTree->Branch("EVENT" , &EVENT , "run/I:lumi/I:event/I:json/I");
802     _outTree->Branch("hbhe" , &hbhe , "hbhe/b");
803 arizzi 1.63 _outTree->Branch("totalKinematics" , &totalKinematics , "totalKinematics/b");
804 arizzi 1.56 _outTree->Branch("ecalFlag" , &ecalFlag , "ecalFlag/b");
805 bortigno 1.30 _outTree->Branch("btag1TSF" , &btag1TSF , "btag1TSF/F");
806     _outTree->Branch("btag2TSF" , &btag2TSF , "btag2TSF/F");
807     _outTree->Branch("btag1T2CSF" , &btag1T2CSF , "btag1T2CSF/F");
808 arizzi 1.44 _outTree->Branch("btag2CSF" , &btag2CSF , "btag2CSF/F");
809     _outTree->Branch("btagA0CSF" , &btagA0CSF , "btagA0CSF/F");
810 arizzi 1.60 _outTree->Branch("btagA0TSF" , &btagA0TSF , "btagA0TSF/F");
811 arizzi 1.51 _outTree->Branch("btag1TA1C" , &btag1TA1C , "btag1TA1C/F");
812 arizzi 1.1
813 bortigno 1.30 int ievt=0;
814     int totalcount=0;
815 arizzi 1.1
816 bortigno 1.30 // TFile* inFile = new TFile(inputFile.c_str(), "read");
817 arizzi 1.1 for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
818     std::cout << iFile << std::endl;
819     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
820     if(inFile==0) continue;
821    
822 bortigno 1.30 // loop the events
823 arizzi 1.1
824     fwlite::Event ev(inFile);
825 nmohr 1.29 for(ev.toBegin(); !ev.atEnd() ; ++ev, ++ievt)
826 arizzi 1.1 {
827 nmohr 1.29 if (ievt <= skipEvents_) continue;
828     if (maxEvents_ >= 0){
829     if (ievt > maxEvents_ + skipEvents_) break;
830     };
831 arizzi 1.1
832 arizzi 1.25 fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
833     vhbbAuxHandle.getByLabel(ev,"HbbAnalyzerNew");
834     const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
835 arizzi 1.64
836     if(EVENT.run < runMin_ && runMin_ > 0) continue;
837     if(EVENT.run > runMax_ && runMax_ > 0) continue;
838    
839     count->Fill(1.);
840    
841 arizzi 1.25 PUweight=1.;
842 degrutto 1.54 PUweight2011B=1.;
843 arizzi 1.1 if(isMC_){
844 arizzi 1.41
845 degrutto 1.54 // PU weights // Run2011A
846 bortigno 1.30 std::map<int, unsigned int>::const_iterator puit = aux.puInfo.pus.find(0);
847 arizzi 1.64 int npu =puit->second ;
848     PUweight = lumiWeights.weight( npu );
849 arizzi 1.41 pu->Fill(puit->second);
850 degrutto 1.54 // PU weight Run2011B
851     // PU weight Run2011B
852     std::map<int, unsigned int>::const_iterator puit0 = aux.puInfo.pus.find(0);
853     std::map<int, unsigned int>::const_iterator puitm1 = aux.puInfo.pus.find(-1);
854     std::map<int, unsigned int>::const_iterator puitp1 = aux.puInfo.pus.find(+1);
855 arizzi 1.62 PU0=puit0->second;
856     PUp1=puitp1->second;
857     PUm1=puitm1->second;
858     input3DPU->Fill(PUm1,PU0,PUp1);
859 degrutto 1.54 PUweight2011B = lumiWeights2011B.weight3D( puitm1->second, puit0->second,puitp1->second);
860    
861 bortigno 1.30 }
862 arizzi 1.49 countWithPU->Fill(1,PUweight);
863 arizzi 1.58 countWithPU2011B->Fill(1,PUweight2011B);
864 nmohr 1.7
865 bortigno 1.30 //Write event info
866     EVENT.run = ev.id().run();
867     EVENT.lumi = ev.id().luminosityBlock();
868     EVENT.event = ev.id().event();
869     EVENT.json = jsonContainsEvent (jsonVector, ev);
870     //FIXME : need to update EDM ntuple with BHadron infos
871     // // simBHadrons
872     // fwlite::Handle<SimBHadronCollection> SBHC;
873     // SBHC.getByLabel(ev, "bhadrons");
874     // const SimBHadronCollection sbhc = *(SBHC.product());
875    
876     const std::vector<VHbbCandidate> * candZ ;
877     const std::vector<VHbbCandidate> * candW ;
878 arizzi 1.64 VHbbEvent modifiedEvent;;
879 bortigno 1.30 const VHbbEvent * iEvent =0;
880     if(fromCandidate)
881     {
882     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandleZ;
883     vhbbCandHandleZ.getByLabel(ev,"hbbBestCSVPt20Candidates");
884     candZ = vhbbCandHandleZ.product();
885    
886     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
887     vhbbCandHandle.getByLabel(ev,"hbbHighestPtHiggsPt30Candidates");
888     candW = vhbbCandHandle.product();
889     }
890     else
891     {
892     candZlocal->clear();
893     candWlocal->clear();
894     fwlite::Handle< VHbbEvent > vhbbHandle;
895     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
896 arizzi 1.64 modifiedEvent = *vhbbHandle.product();
897     if(isMC_)
898     {
899     iEvent= &modifiedEvent;
900    
901     for(size_t j=0; j< modifiedEvent.simpleJets2.size() ; j++)
902     {
903     TLorentzVector & p4 = modifiedEvent.simpleJets2[j].p4;
904     TLorentzVector & mcp4 = modifiedEvent.simpleJets2[j].bestMCp4;
905     if ((fabs(p4.Pt() - mcp4.Pt())/ p4.Pt())<0.5) { //Limit the effect to the core
906     float cor = (p4.Pt()+resolutionBias(fabs(p4.Eta()))*(p4.Pt()-mcp4.Pt()))/p4.Pt();
907     p4.SetPtEtaPhiE(p4.Pt()*cor,p4.Eta(), p4.Phi(), p4.E()*cor);
908     }
909     }
910     } else
911     {
912     iEvent = vhbbHandle.product();
913     }
914    
915     algoZ->run(iEvent,*candZlocal);
916     algoW->run(iEvent,*candWlocal);
917    
918     if(candZlocal->size() == 0 or candZlocal->at(0).H.jets.size() < 2) //recover low pt
919     {
920     candZlocal->clear();
921     candWlocal->clear();
922     algoRecoverLowPt->run(iEvent,*candZlocal);
923     algoRecoverLowPt->run(iEvent,*candWlocal);
924     }
925    
926 bortigno 1.30 candZ= candZlocal;
927     candW= candWlocal;
928     /* for(size_t m=0;m<iEvent->muInfo.size();m++)
929     {
930    
931     if( fabs(iEvent->muInfo[m].p4.Pt()-28.118684) < 0.0001 ||
932     fabs(iEvent->muInfo[m].p4.Pt()-34.853199) < 0.0001 )
933     {
934     std::cout << "FOUND " << iEvent->muInfo[m].p4.Pt() << " " << EVENT.event << " " << candW->size() << " " << candZ->size() << std::endl;
935     }
936     }
937     */
938 arizzi 1.4
939 bortigno 1.30 }
940 arizzi 1.1
941 arizzi 1.3 const std::vector<VHbbCandidate> * cand = candZ;
942 arizzi 1.1
943    
944    
945 bortigno 1.30 /* fwlite::Handle< VHbbEvent > vhbbHandle;
946     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
947     const VHbbEvent iEvent = *vhbbHandle.product();
948     */
949 arizzi 1.1
950 bortigno 1.30 // std::clog << "Filling tree "<< std::endl;
951     bool isW=false;
952 arizzi 1.21
953 arizzi 1.17
954 bortigno 1.30 if(cand->size() == 0 or cand->at(0).H.jets.size() < 2) continue;
955     if(cand->size() > 1 )
956 arizzi 1.3 {
957 bortigno 1.30 std::cout << "MULTIPLE CANDIDATES: " << cand->size() << std::endl;
958 arizzi 1.3 }
959 bortigno 1.30 if(cand->at(0).candidateType == VHbbCandidate::Wmun || cand->at(0).candidateType == VHbbCandidate::Wen ) { cand=candW; isW=true; }
960     if(cand->size() == 0)
961 arizzi 1.3 {
962 bortigno 1.30 // std::cout << "W event loss due to tigther cuts" << std::endl;
963 arizzi 1.3 continue;
964     }
965 arizzi 1.35
966 degrutto 1.54
967 arizzi 1.35 // secondary vtxs
968     fwlite::Handle<std::vector<reco::Vertex> > SVC;
969 arizzi 1.52 SVC.getByLabel(ev,"bcandidates");
970 arizzi 1.35 const std::vector<reco::Vertex> svc = *(SVC.product());
971    
972 bortigno 1.30 const VHbbCandidate & vhCand = cand->at(0);
973     patFilters.setEvent(&ev,"VH");
974     hbhe = patFilters.accept("hbhe");
975 arizzi 1.56 ecalFlag = patFilters.accept("ecalFilter");
976 arizzi 1.63 totalKinematics = patFilters.accept("totalKinematics");
977 arizzi 1.18
978 bortigno 1.30 trigger.setEvent(&ev);
979     for(size_t j=0;j < triggers.size();j++)
980 arizzi 1.4 triggerFlags[j]=trigger.accept(triggers[j]);
981 arizzi 1.39
982 bortigno 1.30 eventFlav=0;
983     if(aux.mcBbar.size() > 0 || aux.mcB.size() > 0) eventFlav=5;
984     else if(aux.mcC.size() > 0) eventFlav=4;
985 arizzi 1.8
986 arizzi 1.53 Vtype = vhCand.candidateType;
987 arizzi 1.3
988 bortigno 1.30 H.mass = vhCand.H.p4.M();
989     H.pt = vhCand.H.p4.Pt();
990     H.eta = vhCand.H.p4.Eta();
991     H.phi = vhCand.H.p4.Phi();
992 dlopes 1.67
993     FatH.FatHiggsFlag = vhCand.FatH.FatHiggsFlag;
994     if(vhCand.FatH.FatHiggsFlag){ FatH.mass= vhCand.FatH.p4.M();
995     FatH.pt = vhCand.FatH.p4.Pt();
996     FatH.eta = vhCand.FatH.p4.Eta();
997     FatH.phi = vhCand.FatH.p4.Phi();
998    
999     // if(vhCand.FatH.FatHiggsFlag) vhCand.FatH.subjetsSize;
1000     nfathFilterJets=vhCand.FatH.subjetsSize;
1001     for( int j=0; j < nfathFilterJets; j++ ){
1002     fathFilterJets.set(vhCand.FatH.jets[j],j);
1003     }
1004    
1005     if(nfathFilterJets==2){
1006     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).M();
1007     FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4).Pt();}
1008     else if(nfathFilterJets==3){
1009     FatH.filteredmass=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).M();
1010     FatH.filteredpt=(vhCand.FatH.jets[0].p4+vhCand.FatH.jets[1].p4+vhCand.FatH.jets[2].p4).Pt();}
1011    
1012     }
1013    
1014 bortigno 1.30 V.mass = vhCand.V.p4.M();
1015 arizzi 1.36 if(isW) V.mass = vhCand.Mt();
1016 bortigno 1.30 V.pt = vhCand.V.p4.Pt();
1017     V.eta = vhCand.V.p4.Eta();
1018     V.phi = vhCand.V.p4.Phi();
1019     nhJets=2;
1020     hJets.set(vhCand.H.jets[0],0);
1021     hJets.set(vhCand.H.jets[1],1);
1022     aJets.reset();
1023     naJets=vhCand.additionalJets.size();
1024     numBJets=0;
1025     if(vhCand.H.jets[0].csv> btagThr) numBJets++;
1026     if(vhCand.H.jets[1].csv> btagThr) numBJets++;
1027     for( int j=0; j < naJets && j < MAXJ; j++ )
1028 arizzi 1.6 {
1029 bortigno 1.30 aJets.set(vhCand.additionalJets[j],j);
1030     if(vhCand.additionalJets[j].csv> btagThr) numBJets++;
1031 arizzi 1.6 }
1032 bortigno 1.30 numJets = vhCand.additionalJets.size()+2;
1033 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());
1034     H.dPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
1035     H.dEta= TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
1036 bortigno 1.30 HVdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ) ;
1037 arizzi 1.41 HVMass = (vhCand.H.p4 + vhCand.V.p4).M() ;
1038 bortigno 1.30 HMETdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.mets.at(0).p4.Phi()) ) ;
1039     VMt = vhCand.Mt() ;
1040 arizzi 1.52 //eltaPullAngle = vhCand.H.deltaTheta;
1041     deltaPullAngle = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[0],vhCand.H.jets[1]);
1042     deltaPullAngle2 = VHbbCandidateTools::getDeltaTheta(vhCand.H.jets[1],vhCand.H.jets[0]);
1043    
1044 bortigno 1.30
1045     hJets.cosTheta[0]= vhCand.H.helicities[0];
1046     hJets.cosTheta[1]= vhCand.H.helicities[1];
1047 arizzi 1.36 // METInfo calomet; METInfo tcmet; METInfo pfmet; METInfo mht; METInfo metNoPU
1048 bortigno 1.30 MET.et = vhCand.V.mets.at(0).p4.Pt();
1049     MET.phi = vhCand.V.mets.at(0).p4.Phi();
1050     MET.sumet = vhCand.V.mets.at(0).sumEt;
1051     MET.sig = vhCand.V.mets.at(0).metSig;
1052 arizzi 1.24
1053 arizzi 1.52
1054     fakeMET.sumet = 0;
1055     fakeMET.sig = 0;
1056     fakeMET.et = 0;
1057     fakeMET.phi = 0;
1058     if( Vtype == VHbbCandidate::Zmumu) {
1059     TVector3 mu1 = vhCand.V.muons[0].p4.Vect();
1060     TVector3 mu2 = vhCand.V.muons[1].p4.Vect();
1061     // Not needed with PFMET
1062     // mu1.SetMag( mu1.Mag() - vhCand.V.muons[0].emEnergy - vhCand.V.muons[0].hadEnergy);
1063     // mu2.SetMag( mu2.Mag() - vhCand.V.muons[1].emEnergy - vhCand.V.muons[1].hadEnergy);
1064     TVector3 sum = vhCand.V.mets.at(0).p4.Vect() + mu1 + mu2;
1065     fakeMET.et = sum.Pt();
1066     fakeMET.phi = sum.Phi();
1067     fakeMET.sumet = vhCand.V.mets.at(0).sumEt - mu1.Pt() - mu2.Pt();
1068     }
1069    
1070 arizzi 1.36 METnoPU.et = iEvent->metNoPU.p4.Pt();
1071     METnoPU.phi = iEvent->metNoPU.p4.Phi();
1072     METnoPU.sumet = iEvent->metNoPU.sumEt;
1073     METnoPU.sig = iEvent->metNoPU.metSig;
1074 arizzi 1.59 METnoPUCh.et = iEvent->metCh.p4.Pt();
1075     METnoPUCh.phi = iEvent->metCh.p4.Phi();
1076     METnoPUCh.sumet = iEvent->metCh.sumEt;
1077     METnoPUCh.sig = iEvent->metCh.metSig;
1078 arizzi 1.36
1079 arizzi 1.58 METnoPUCh.et = iEvent->metCh.p4.Pt();
1080     METnoPUCh.phi = iEvent->metCh.p4.Phi();
1081     METnoPUCh.sumet = iEvent->metCh.sumEt;
1082     METnoPUCh.sig = iEvent->metCh.metSig;
1083    
1084 arizzi 1.36 rho = aux.puInfo.rho;
1085     rho25 = aux.puInfo.rho25;
1086     nPVs=aux.pvInfo.nVertices;
1087    
1088 arizzi 1.24 if(!fromCandidate) {
1089     MHT.mht = iEvent->mht.p4.Pt();
1090     MHT.phi = iEvent->mht.p4.Phi();
1091     MHT.ht = iEvent->mht.sumEt;
1092     MHT.sig = iEvent->mht.metSig;
1093 bortigno 1.30 }
1094    
1095 arizzi 1.24
1096    
1097 bortigno 1.30 //Secondary Vertices
1098     IVF.reset();
1099     nSvs = svc.size();
1100     const TVector3 recoPv = aux.pvInfo.firstPVInPT2;
1101     const math::XYZPoint myPv(recoPv);
1102     //look here for Matrix filling info http://project-mathlibs.web.cern.ch/project-mathlibs/sw/html/SMatrixDoc.html
1103     std::vector<double> fillMatrix(6);
1104     for (int i = 0; i<6; ++i) fillMatrix[i] = 0.;
1105     fillMatrix[0] = TMath::Power(0.002,2);
1106     fillMatrix[2] = TMath::Power(0.002,2);
1107     fillMatrix[5] = TMath::Power(0.002,2);
1108     const ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > myFakeMatrixError(fillMatrix.begin(),fillMatrix.end());
1109     const reco::Vertex recoVtxPv(myPv, myFakeMatrixError);
1110     for( int j=0; j < nSvs && j < MAXB; ++j ) {
1111     const GlobalVector flightDir = flightDirection(recoPv,svc[j]);
1112     reco::SecondaryVertex recoSv(recoVtxPv, svc[j], flightDir ,true);
1113     IVF.set( recoSv, recoPv ,j);
1114     }
1115     if(nSvs > 2){
1116     TLorentzVector BCands_H1, BCands_H2, BCands_H;
1117     BCands_H1.SetPtEtaPhiM(IVF.pt[0], IVF.eta[0], IVF.phi[0], IVF.massBcand[0]);
1118     BCands_H2.SetPtEtaPhiM(IVF.pt[1], IVF.eta[1], IVF.phi[1], IVF.massBcand[1]);
1119     BCands_H = BCands_H1 + BCands_H2;
1120 arizzi 1.33 SVH.dR = deltaR(IVF.eta[0], IVF.phi[0], IVF.eta[1], IVF.phi[1] );
1121     SVH.dPhi = deltaPhi(IVF.phi[0], IVF.phi[1] );
1122     SVH.dEta = TMath::Abs(IVF.eta[0] - IVF.eta[1] );
1123     SVH.mass = BCands_H.M();
1124     SVH.pt = BCands_H.Pt();
1125     SVH.eta = BCands_H.Eta();
1126     SVH.phi = BCands_H.Phi();
1127 bortigno 1.30 }
1128    
1129     //FIXME : need to update EDM ntuple with simBhadron info
1130     // //SimBhadron
1131     // SimBs.reset();
1132     // nSimBs = sbhc.size();
1133     // for( int j=0; j < nSimBs && j < MAXB; ++j )
1134     // SimBs.set( sbhc.at(j), j);
1135     // if(nSimBs > 2){
1136     // TLorentzVector SimBs_H1, SimBs_H2, SimBs_H;
1137     // SimBs_H1.SetPtEtaPhiM(SimBs.pt[0], SimBs.eta[0], SimBs.phi[0], SimBs.mass[0]);
1138     // SimBs_H2.SetPtEtaPhiM(SimBs.pt[1], SimBs.eta[1], SimBs.phi[1], SimBs.mass[1]);
1139     // SimBs_H = SimBs_H1 + SimBs_H2;
1140     // SimBs_dr = deltaR(SimBs.eta[0], SimBs.phi[0], SimBs.eta[1], SimBs.phi[1] );
1141     // SimBs_dPhi = deltaPhi(SimBs.phi[0], SimBs.phi[1] );
1142     // SimBs_dEta = TMath::Abs(SimBs.eta[0] - SimBs.eta[1] );
1143     // SimBs_Hmass = SimBs_H.M();
1144     // SimBs_Hpt = SimBs_H.Pt();
1145     // SimBs_Heta = SimBs_H.Eta();
1146     // SimBs_Hphi = SimBs_H.Phi();
1147     // }
1148    
1149    
1150     //Loop on jets
1151     double maxBtag=-99999;
1152     minDeltaPhijetMET = 999;
1153     TLorentzVector bJet;
1154     std::vector<std::vector<BTagWeight::JetInfo> > btagJetInfos;
1155 arizzi 1.64 std::vector<float> jet10eta;
1156     std::vector<float> jet10pt;
1157 bortigno 1.30 std::vector<float> jet30eta;
1158     std::vector<float> jet30pt;
1159     if(fromCandidate)
1160     {
1161     //Loop on Higgs Jets
1162     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ){
1163     if (vhCand.H.jets[j].csv > maxBtag) { bJet=vhCand.H.jets[j].p4 ; maxBtag =vhCand.H.jets[j].csv; }
1164 arizzi 1.39 if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi())) < minDeltaPhijetMET)
1165 bortigno 1.30 {
1166 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi()));
1167 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.H.jets[j].p4.Pt();
1168 bortigno 1.30 }
1169     btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
1170     }
1171     //Loop on Additional Jets
1172     for(unsigned int j=0; j < vhCand.additionalJets.size(); j++ ){
1173     if (vhCand.additionalJets[j].csv > maxBtag) { bJet=vhCand.additionalJets[j].p4 ; maxBtag =vhCand.additionalJets[j].csv; }
1174 arizzi 1.45 /* if (fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi())) < minDeltaPhijetMET)
1175 bortigno 1.30 {
1176 arizzi 1.39 minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi()));
1177 arizzi 1.24 jetPt_minDeltaPhijetMET=vhCand.additionalJets[j].p4.Pt();
1178 arizzi 1.45 }*/
1179 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
1180     {
1181     if(vhCand.additionalJets[j].p4.Pt() > 20)
1182     btagJetInfos.push_back(btagEff.jetInfo(vhCand.additionalJets[j]));
1183     }
1184     }
1185     }
1186     else
1187     {
1188 arizzi 1.45 //Loop on all jets
1189 bortigno 1.30 for(unsigned int j=0; j < iEvent->simpleJets2.size(); j++ ){
1190     if (iEvent->simpleJets2[j].csv > maxBtag) { bJet=iEvent->simpleJets2[j].p4 ; maxBtag =iEvent->simpleJets2[j].csv; }
1191 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)
1192 arizzi 1.46 {
1193     minDeltaPhijetMET=fabs(deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi()));
1194     jetPt_minDeltaPhijetMET=iEvent->simpleJets2[j].p4.Pt();
1195     }
1196 arizzi 1.64 if(iEvent->simpleJets2[j].p4.Pt() > 10)
1197     {
1198     jet10eta.push_back(iEvent->simpleJets2[j].p4.Eta());
1199     jet10pt.push_back(iEvent->simpleJets2[j].p4.Pt());
1200     }
1201 bortigno 1.30 if(iEvent->simpleJets2[j].p4.Pt() > 30)
1202     {
1203     jet30eta.push_back(iEvent->simpleJets2[j].p4.Eta());
1204     jet30pt.push_back(iEvent->simpleJets2[j].p4.Pt());
1205     }
1206 arizzi 1.24
1207 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)
1208     // 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
1209     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )
1210     {
1211 arizzi 1.58 if(iEvent->simpleJets2[j].p4.Pt() > 20 && fabs(iEvent->simpleJets2[j].p4.Eta()) < 2.5)
1212 bortigno 1.30 btagJetInfos.push_back(btagEff.jetInfo(iEvent->simpleJets2[j]));
1213     }
1214     }
1215    
1216 arizzi 1.45 //Loop on Higgs jets
1217    
1218     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ) {
1219    
1220 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
1221     // by a criteria (pt of the dijet) that is not btag SF dependent
1222     if(!( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )) {
1223 arizzi 1.45 btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
1224 bortigno 1.30 }
1225 arizzi 1.45 }
1226 arizzi 1.24
1227 bortigno 1.30 }
1228     vLeptons.reset();
1229     weightTrig = 1.; // better to default to 1
1230 arizzi 1.38 weightTrigMay = -1.;
1231     weightTrigV4 = -1.;
1232 arizzi 1.51 weightTrigOrMu30 = 1.;
1233 bortigno 1.30 TLorentzVector leptonForTop;
1234     size_t firstAddMu=0;
1235     size_t firstAddEle=0;
1236     if(Vtype == VHbbCandidate::Zmumu ){
1237     vLeptons.set(vhCand.V.muons[0],0,13);
1238     vLeptons.set(vhCand.V.muons[1],1,13);
1239     float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleMuID(vLeptons.pt[1],vLeptons.eta[1]) ;
1240     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
1241     float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[1],vLeptons.eta[1]);
1242     float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
1243     weightTrig = cweightID * cweightTrig;
1244     nvlep=2;
1245     firstAddMu=2;
1246     }
1247     if( Vtype == VHbbCandidate::Zee ){
1248     vLeptons.set(vhCand.V.electrons[0],0,11);
1249     vLeptons.set(vhCand.V.electrons[1],1,11);
1250     nvlep=2;
1251     firstAddEle=2;
1252     std::vector<float> pt,eta;
1253     pt.push_back(vLeptons.pt[0]); eta.push_back(vLeptons.eta[0]);
1254     pt.push_back(vLeptons.pt[1]); eta.push_back(vLeptons.eta[1]);
1255     weightEleRecoAndId=triggerWeight.scaleID95Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]) *
1256     triggerWeight.scaleID95Ele(vLeptons.pt[1],vLeptons.eta[1]) * triggerWeight.scaleRecoEle(vLeptons.pt[1],vLeptons.eta[1]);
1257     weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
1258 arizzi 1.60 weightEleTrigEleAugPart = triggerWeight.scaleDoubleEle17Ele8Aug(pt,eta);
1259     weightTrig = (weightEleTrigElePart*1.14+weightEleTrigEleAugPart*0.98 )/2.12 * weightEleRecoAndId;
1260 arizzi 1.24
1261    
1262    
1263 bortigno 1.30 }
1264     if(Vtype == VHbbCandidate::Wmun ){
1265     leptonForTop=vhCand.V.muons[0].p4;
1266     vLeptons.set(vhCand.V.muons[0],0,13);
1267     float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]);
1268     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
1269     float cweightTrig = weightTrig1;
1270     weightTrig = cweightID * cweightTrig;
1271 arizzi 1.51 float weightTrig1OrMu30 = triggerWeight.scaleMuOr30IsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
1272 dlopes 1.61 weightTrigOrMu30 = cweightID*weightTrig1OrMu30;
1273 bortigno 1.30 nvlep=1;
1274     firstAddMu=1;
1275     }
1276     if( Vtype == VHbbCandidate::Wen ){
1277     leptonForTop=vhCand.V.electrons[0].p4;
1278     vLeptons.set(vhCand.V.electrons[0],0,11);
1279     nvlep=1;
1280     firstAddEle=1;
1281 arizzi 1.38 weightTrigMay = triggerWeight.scaleSingleEleMay(vLeptons.pt[0],vLeptons.eta[0]);
1282     weightTrigV4 = triggerWeight.scaleSingleEleV4(vLeptons.pt[0],vLeptons.eta[0]);
1283 bortigno 1.30 weightEleRecoAndId=triggerWeight.scaleID80Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]);
1284 arizzi 1.59 weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30pt,jet30eta)*triggerWeight.scalePFMHTEle(MET.et);
1285 arizzi 1.38 weightEleTrigElePart= weightTrigV4; //this is for debugging only, checking only the V4 part
1286 bortigno 1.30
1287 arizzi 1.38 weightTrigMay*=weightEleRecoAndId;
1288     weightTrigV4*=weightEleRecoAndId;
1289     weightTrigV4*=weightEleTrigJetMETPart;
1290 arizzi 1.60 // weightTrig = weightTrigMay * 0.187 + weightTrigV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
1291     weightTrig = (weightTrigMay * 0.215 + weightTrigV4 * 1.915)/ 2.13; //FIXME: use proper lumi if we reload 2.fb
1292 bortigno 1.30 }
1293 arizzi 1.64
1294 arizzi 1.65 if(isMC_)
1295     {
1296 arizzi 1.64 weightTrigMET80 = triggerWeight.scaleMET80(MET.et);
1297     weightTrigMET100 = triggerWeight.scaleMET80(MET.et);
1298     weightTrig2CJet20 = triggerWeight.scale2CentralJet( jet10pt, jet10eta);
1299     weightTrigMET150 = triggerWeight.scaleMET150(MET.et);
1300     weightTrigMET802CJet= weightTrigMET80 * weightTrig2CJet20;
1301     weightTrigMET1002CJet= weightTrigMET100 * weightTrig2CJet20;
1302 arizzi 1.65 }
1303 bortigno 1.30 if( Vtype == VHbbCandidate::Znn ){
1304     nvlep=0;
1305     float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
1306 arizzi 1.64 weightTrigMETLP = weightTrig1;
1307     weightTrig = weightTrigMET150 + weightTrigMET802CJet - weightTrigMET802CJet*weightTrigMET150;
1308 bortigno 1.30 }
1309 arizzi 1.38
1310     if(weightTrigMay < 0) weightTrigMay=weightTrig;
1311     if(weightTrigV4 < 0) weightTrigV4=weightTrig;
1312 arizzi 1.40 if(!isMC_)
1313     {
1314     weightTrig = 1.;
1315     weightTrigMay = 1.;
1316     weightTrigV4 = 1.;
1317 arizzi 1.64 weightEleRecoAndId= 1.;
1318     weightEleTrigJetMETPart= 1.;
1319     weightEleTrigElePart= 1.;
1320     weightEleTrigEleAugPart=1.;
1321     weightTrigMET80= 1.;
1322     weightTrigMET100= 1.;
1323     weightTrig2CJet20= 1.;
1324     weightTrigMET150= 1.;
1325     weightTrigMET802CJet= 1.;
1326     weightTrigMET1002CJet= 1.;
1327     weightTrigMETLP = 1.;
1328 arizzi 1.40
1329     }
1330 bortigno 1.30 aLeptons.reset();
1331     nalep=0;
1332     if(fromCandidate)
1333 arizzi 1.21 {
1334     for(size_t j=firstAddMu;j< vhCand.V.muons.size();j++) aLeptons.set(vhCand.V.muons[j],nalep++,13);
1335     for(size_t j=firstAddEle;j< vhCand.V.electrons.size();j++) aLeptons.set(vhCand.V.electrons[j],nalep++,11);
1336     }
1337 bortigno 1.30 else
1338 arizzi 1.21 {
1339 bortigno 1.30 for(size_t j=0;j< iEvent->muInfo.size();j++)
1340     {
1341 arizzi 1.21 if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wmun ) && (Vtype != VHbbCandidate::Zmumu )) )
1342 bortigno 1.30 aLeptons.set(iEvent->muInfo[j],nalep++,13);
1343     }
1344     for(size_t j=0;j< iEvent->eleInfo.size();j++)
1345     {
1346 arizzi 1.21 if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wen ) && (Vtype != VHbbCandidate::Zee )))
1347 bortigno 1.30 aLeptons.set(iEvent->eleInfo[j],nalep++,11);
1348     }
1349 arizzi 1.8
1350 arizzi 1.21 }
1351 arizzi 1.8
1352 arizzi 1.24
1353 bortigno 1.30 if(isMC_)
1354     {
1355     //std::cout << "BTAGSF " << btagJetInfos.size() << " " << btag.weight<BTag1Tight2CustomFilter>(btagJetInfos) << std::endl;
1356     if ( btagJetInfos.size()< 10)
1357     {
1358     btag1T2CSF = btag.weight<BTag1Tight2CustomFilter>(btagJetInfos);
1359     btag2TSF = btag.weight<BTag2TightFilter>(btagJetInfos);
1360     btag1TSF = btag.weight<BTag1TightFilter>(btagJetInfos);
1361 arizzi 1.44 btagA0CSF = btag.weight<BTagAntiMax0CustomFilter>(btagJetInfos);
1362 arizzi 1.60 btagA0TSF = btag.weight<BTagAntiMax0TightFilter>(btagJetInfos);
1363 arizzi 1.44 btag2CSF = btag.weight<BTag2CustomFilter>(btagJetInfos);
1364 arizzi 1.51 btag1TA1C = btag.weight<BTag1TightAndMax1CustomFilter>(btagJetInfos);
1365 bortigno 1.30 }
1366     else
1367     {
1368     std::cout << "WARNING: combinatorics for " << btagJetInfos.size() << " jets is too high (>=10). use SF=1 " << std::endl;
1369     //TODO: revert to random throw for this cases
1370     btag1T2CSF = 1.;
1371     btag2TSF = 1.;
1372     btag1TSF = 1.;
1373 arizzi 1.51 btagA0CSF = 1.;
1374 arizzi 1.60 btagA0TSF = 1.;
1375 arizzi 1.51 btag2CSF = 1.;
1376     btag1TA1C = 1.;
1377 bortigno 1.30 }
1378     }
1379 arizzi 1.17
1380 bortigno 1.30 if(maxBtag > -99999)
1381 arizzi 1.8 {
1382 bortigno 1.30 TopHypo topQuark = TopMassReco::topMass(leptonForTop,bJet,vhCand.V.mets.at(0).p4);
1383     top.mass = topQuark.p4.M();
1384     top.pt = topQuark.p4.Pt();
1385     top.wMass = topQuark.p4W.M();
1386 arizzi 1.8 } else {
1387 bortigno 1.30 top.mass = -99;
1388     top.pt = -99;
1389     top.wMass = -99;
1390     }
1391 arizzi 1.8
1392    
1393    
1394 bortigno 1.30 //FIXME: too much warnings... figure out why
1395     // gendrcc=aux.genCCDeltaR();
1396     // gendrbb=aux.genBBDeltaR();
1397     genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
1398     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
1399 arizzi 1.49 WminusMode=-99;
1400     WplusMode=-99;
1401 arizzi 1.50 for(unsigned int j=0; j< aux.mcW.size();j++)
1402 arizzi 1.49 {
1403 degrutto 1.66 for(unsigned int k=0;k< aux.mcW[j].dauid.size();k++)
1404     {
1405     int idd=abs(aux.mcW[j].dauid[k]);
1406     if(idd==11 || idd==13 || idd==15|| (idd<=5 && idd >=1))
1407     {
1408     if(WminusMode==-99 && aux.mcW[j].charge ==-1) WminusMode = idd;
1409     if(WplusMode==-99 && aux.mcW[j].charge ==+1) WplusMode = idd;
1410     }
1411     }
1412     /*
1413     /// now check if a semileptonic W is also in a bjets....
1414     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;
1415     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;
1416    
1417     for( int j=0; j < naJets && j < MAXJ; j++ )
1418     {
1419     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;
1420    
1421     }
1422     */
1423    
1424     }
1425    
1426 arizzi 1.32 /// Compute pull angle from AK7
1427 arizzi 1.25 if(!fromCandidate){
1428 arizzi 1.32 std::vector<VHbbEvent::SimpleJet> ak7wrt1(iEvent->simpleJets3);
1429     std::vector<VHbbEvent::SimpleJet> ak7wrt2(iEvent->simpleJets3);
1430     if(ak7wrt1.size() > 1){
1431 arizzi 1.24 CompareDeltaR deltaRComparatorJ1(vhCand.H.jets[0].p4);
1432     CompareDeltaR deltaRComparatorJ2(vhCand.H.jets[1].p4);
1433 arizzi 1.32 std::sort( ak7wrt1.begin(),ak7wrt1.end(),deltaRComparatorJ1 );
1434     std::sort( ak7wrt2.begin(),ak7wrt2.end(),deltaRComparatorJ2 );
1435 arizzi 1.24 std::vector<VHbbEvent::SimpleJet> ak7_matched;
1436 arizzi 1.32 // if the matched are different save them
1437     if(ak7wrt1[0].p4.DeltaR(ak7wrt2[0].p4) > 0.1) {
1438     ak7_matched.push_back(ak7wrt1[0]);
1439     ak7_matched.push_back(ak7wrt2[0]);
1440     }
1441     // else look at the second best
1442     else{
1443     // ak7wrt1 is best
1444     if( ak7wrt1[1].p4.DeltaR(vhCand.H.jets[0].p4) < ak7wrt2[1].p4.DeltaR(vhCand.H.jets[1].p4))
1445     {
1446     ak7_matched.push_back(ak7wrt1[1]);
1447     ak7_matched.push_back(ak7wrt2[0]);
1448     }
1449     else
1450     {
1451     ak7_matched.push_back(ak7wrt1[0]);
1452     ak7_matched.push_back(ak7wrt2[1]);
1453     }
1454     }
1455 arizzi 1.24 CompareJetPt ptComparator;
1456     std::sort( ak7_matched.begin(),ak7_matched.end(),ptComparator );
1457     if(ak7_matched[0].p4.DeltaR(vhCand.H.jets[0].p4) < 0.5
1458 arizzi 1.32 and ak7_matched[1].p4.DeltaR(vhCand.H.jets[1].p4) < 0.5)
1459     {
1460     deltaPullAngleAK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[0],ak7_matched[1]);
1461 arizzi 1.52 deltaPullAngle2AK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[1],ak7_matched[0]);
1462 arizzi 1.32 }
1463 arizzi 1.24 }
1464     }
1465 arizzi 1.3
1466 bortigno 1.30 _outTree->Fill();
1467 arizzi 1.4
1468 bortigno 1.30 }// closed event loop
1469 arizzi 1.1
1470 bortigno 1.30 std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
1471     inFile->Close();
1472     // close input file
1473     } // loop on files
1474 arizzi 1.1
1475    
1476 bortigno 1.30 std::cout << "Events: " << ievt <<std::endl;
1477     std::cout << "TotalCount: " << totalcount <<std::endl;
1478 arizzi 1.1
1479    
1480    
1481 bortigno 1.30 _outFile->cd();
1482 arizzi 1.1
1483 bortigno 1.30 _outTree->Write();
1484     _outFile->Write();
1485     _outFile->Close();
1486     return 0;
1487 arizzi 1.1 }
1488    
1489