ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.24
Committed: Thu Sep 15 10:37:39 2011 UTC (13 years, 8 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: VHSept15_AR1
Changes since 1.23: +175 -50 lines
Log Message:
trigger for ele

File Contents

# User Rev Content
1 arizzi 1.1 #include <TH1F.h>
2     #include "PhysicsTools/Utilities/interface/LumiReWeighting.h"
3     #include <TH2F.h>
4     #include <TROOT.h>
5     #include <TFile.h>
6     #include <TTree.h>
7     #include <TSystem.h>
8     #include "DataFormats/FWLite/interface/Event.h"
9     #include "DataFormats/FWLite/interface/Handle.h"
10     #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
11     #include "DataFormats/MuonReco/interface/Muon.h"
12     #include "DataFormats/PatCandidates/interface/Muon.h"
13     #include "PhysicsTools/FWLite/interface/TFileService.h"
14     #include "FWCore/ParameterSet/interface/ProcessDesc.h"
15     #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
16     #include "DataFormats/Math/interface/deltaR.h"
17     #include "DataFormats/Math/interface/deltaPhi.h"
18    
19     #include "DataFormats/FWLite/interface/LuminosityBlock.h"
20     #include "DataFormats/FWLite/interface/Run.h"
21     #include "DataFormats/Luminosity/interface/LumiSummary.h"
22    
23 arizzi 1.4 #include "VHbbAnalysis/VHbbDataFormats/interface/HbbCandidateFinderAlgo.h"
24     #include "VHbbAnalysis/VHbbDataFormats/src/HbbCandidateFinderAlgo.cc"
25 arizzi 1.1
26     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h"
27     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEventAuxInfo.h"
28     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidate.h"
29     #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerReader.h"
30 nmohr 1.5 #include "VHbbAnalysis/VHbbDataFormats/interface/TopMassReco.h"
31 arizzi 1.1
32 arizzi 1.16
33     //Move class definition to Ntupler.h ?
34     //#include "VHbbAnalysis/VHbbDataFormats/interface/Ntupler.h"
35    
36     #include "VHbbAnalysis/VHbbDataFormats/interface/BTagWeight.h"
37     #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerWeight.h"
38    
39 arizzi 1.1 #include <sstream>
40     #include <string>
41    
42     #define MAXJ 30
43     #define MAXL 10
44    
45 arizzi 1.24 struct CompareDeltaR {
46     CompareDeltaR(TLorentzVector p4dir_): p4dir(p4dir_) {}
47     bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const {
48     return j1.p4.DeltaR(p4dir) > j2.p4.DeltaR(p4dir);
49     }
50     TLorentzVector p4dir;
51     };
52 arizzi 1.4
53 nmohr 1.7 bool jsonContainsEvent (const std::vector< edm::LuminosityBlockRange > &jsonVec,
54     const edm::EventBase &event)
55     {
56     // if the jsonVec is empty, then no JSON file was provided so all
57     // events should pass
58     if (jsonVec.empty())
59     {
60     return true;
61     }
62     bool (* funcPtr) (edm::LuminosityBlockRange const &,
63     edm::LuminosityBlockID const &) = &edm::contains;
64     edm::LuminosityBlockID lumiID (event.id().run(),
65     event.id().luminosityBlock());
66     std::vector< edm::LuminosityBlockRange >::const_iterator iter =
67     std::find_if (jsonVec.begin(), jsonVec.end(),
68     boost::bind(funcPtr, _1, lumiID) );
69     return jsonVec.end() != iter;
70    
71     }
72    
73 arizzi 1.1
74    
75     typedef struct
76     {
77     float mass; //MT in case of W
78     float pt;
79     float eta;
80     float phi;
81 arizzi 1.9 } TrackInfo;
82 arizzi 1.1
83    
84 arizzi 1.9 struct LeptonInfo
85 arizzi 1.1 {
86     void reset()
87     {
88     for(int i =0; i < MAXL;i++){ 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; particleIso[i]=-99; dxy[i]=-99; dz[i]=-99; type[i]=-99; }
89     }
90    
91     template <class Input> void set(const Input & i, int j,int t)
92     {
93     type[j]=t;
94     pt[j]=i.p4.Pt();
95     mass[j]=i.p4.M();
96     eta[j]=i.p4.Eta();
97     phi[j]=i.p4.Phi();
98     aodCombRelIso[j]=(i.hIso+i.eIso+i.tIso)/i.p4.Pt();
99     pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
100     photonIso[j]=i.pfPhoIso;
101     neutralHadIso[j]=i.pfNeuIso;
102     chargedHadIso[j]=i.pfChaIso;
103 arizzi 1.4 setID(i,j);
104 arizzi 1.1 }
105 arizzi 1.4 template <class Input> void setID(const Input & i, int j)
106     {
107     id[j]=-99;
108     }
109    
110    
111    
112 arizzi 1.1
113     float mass[MAXL]; //MT in case of W
114     float pt[MAXL];
115     float eta[MAXL];
116     float phi[MAXL];
117     float aodCombRelIso[MAXL];
118     float pfCombRelIso[MAXL];
119     float photonIso[MAXL];
120     float neutralHadIso[MAXL];
121     float chargedHadIso[MAXL];
122     float particleIso[MAXL];
123     float dxy[MAXL];
124     float dz[MAXL];
125     int type[MAXL];
126 arizzi 1.4 float id[MAXL];
127 arizzi 1.1 };
128    
129 arizzi 1.9 template <> void LeptonInfo::setID<VHbbEvent::ElectronInfo>(const VHbbEvent::ElectronInfo & i, int j){
130 arizzi 1.4 id[j]=i.id80r;
131     }
132    
133 arizzi 1.1 typedef struct
134     {
135     float et;
136     float sumet;
137     float sig;
138     float phi;
139 arizzi 1.9 } METInfo;
140 arizzi 1.1
141     typedef struct
142     {
143     float mht;
144     float ht;
145     float sig;
146     float phi;
147 arizzi 1.9 } MHTInfo;
148 nmohr 1.5
149     typedef struct
150     {
151     float mass;
152     float pt;
153     float wMass;
154 arizzi 1.9 } TopInfo;
155 arizzi 1.1
156 nmohr 1.7 typedef struct
157 arizzi 1.1 {
158     int run;
159     int lumi;
160     int event;
161 nmohr 1.7 int json;
162 arizzi 1.9 } EventInfo;
163 arizzi 1.1
164     typedef struct
165     {
166     void set(const VHbbEvent::SimpleJet & j, int i)
167     {
168     pt[i]=j.p4.Pt();
169     eta[i]=j.p4.Eta();
170     phi[i]=j.p4.Phi();
171     csv[i]=j.csv;
172 arizzi 1.24 numTracksSV[i] = j.vtxMass;
173     vtxMass[i]= j.vtxMass;
174     vtx3dL[i] = j.vtx3dL;
175     vtx3deL[i] = j.vtx3deL;
176     chf[i]=j.chargedHadronEFraction;
177     nhf[i] =j.neutralHadronEFraction;
178     cef[i] =j.chargedEmEFraction;
179     nef[i] =j.neutralEmEFraction;
180     nconstituents[i] =j.nConstituents;
181     nch[i]=j.ntracks;
182 arizzi 1.3
183 arizzi 1.1 flavour[i]=j.flavour;
184 arizzi 1.3 if(j.bestMCp4.Pt() > 0)
185     {
186     genPt[i]=j.bestMCp4.Pt();
187     genEta[i]=j.bestMCp4.Eta();
188     genPhi[i]=j.bestMCp4.Phi();
189     }
190 arizzi 1.24 JECUnc[i]=j.jecunc;
191 arizzi 1.3
192 arizzi 1.1 }
193     void reset()
194     {
195     for(int i=0;i<MAXJ;i++) {
196     pt[i]=-99; eta[i]=-99; phi[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; genPt[i]=-99; genEta[i]=-99; genPhi[i]=-99; JECUnc[i]=-99;
197     }
198     }
199     float pt[MAXJ];
200     float eta[MAXJ];
201     float phi[MAXJ];
202     float csv[MAXJ];
203     float cosTheta[MAXJ];
204     int numTracksSV[MAXJ];
205     float chf[MAXJ];
206     float nhf[MAXJ];
207     float cef[MAXJ];
208     float nef[MAXJ];
209     float nch[MAXJ];
210     float nconstituents[MAXJ];
211     float flavour[MAXJ];
212     float genPt[MAXJ];
213     float genEta[MAXJ];
214     float genPhi[MAXJ];
215     float JECUnc[MAXJ];
216 arizzi 1.24 float vtxMass[MAXJ];
217     float vtx3dL [MAXJ];
218     float vtx3deL[MAXJ];
219 arizzi 1.9 } JetInfo;
220 arizzi 1.1
221     int main(int argc, char* argv[])
222     {
223     gROOT->Reset();
224    
225     TTree *_outTree;
226 arizzi 1.9 METInfo MET;
227     MHTInfo MHT;
228     TopInfo top;
229     EventInfo EVENT;
230     // JetInfo jet1,jet2, addJet1, addJet2;
231     // lepton1,lepton2;
232     JetInfo hJets, aJets;
233     LeptonInfo vLeptons, aLeptons;
234 arizzi 1.1 int naJets=0, nhJets=0;
235 arizzi 1.9 TrackInfo H;
236     TrackInfo V;
237     int nvlep=0,nalep=0;
238 arizzi 1.1
239 arizzi 1.22 float jjdr,jjdPhi,jjdEta,HVdPhi,HMETdPhi,VMt,deltaPullAngle,deltaPullAngleAK7,gendrcc,gendrbb, genZpt, genWpt, weightTrig, weightTrigMET, minDeltaPhijetMET, jetPt_minDeltaPhijetMET , PUweight;
240 arizzi 1.24 float weightEleRecoAndId,weightEleTrigJetMETPart, weightEleTrigElePart;
241    
242     int Vtype,numJets,numBJets,eventFlav;
243 arizzi 1.1 // bool isMET80_CJ80, ispfMHT150, isMET80_2CJ20,isMET65_2CJ20, isJETID,isIsoMu17;
244 arizzi 1.18 bool triggerFlags[500],hbhe;
245 arizzi 1.17 float btag1T2CSF=1.,btag2TSF=1.,btag1TSF=1.;
246 arizzi 1.1 // ----------------------------------------------------------------------
247     // First Part:
248     //
249     // * enable the AutoLibraryLoader
250     // * book the histograms of interest
251     // * open the input file
252     // ----------------------------------------------------------------------
253    
254     // load framework libraries
255     gSystem->Load( "libFWCoreFWLite" );
256     gSystem->Load("libDataFormatsFWLite");
257     AutoLibraryLoader::enable();
258    
259     // parse arguments
260     if ( argc < 2 ) {
261     return 0;
262     }
263    
264 arizzi 1.4 std::vector<VHbbCandidate> * candZlocal = new std::vector<VHbbCandidate>;
265     std::vector<VHbbCandidate> * candWlocal = new std::vector<VHbbCandidate>;
266    
267 arizzi 1.1 // get the python configuration
268     PythonProcessDesc builder(argv[1]);
269     const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
270     const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
271     const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
272 nmohr 1.7 std::vector<edm::LuminosityBlockRange> jsonVector;
273     if ( in.exists("lumisToProcess") )
274     {
275     std::vector<edm::LuminosityBlockRange> const & lumisTemp =
276     in.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> > ("lumisToProcess");
277     jsonVector.resize( lumisTemp.size() );
278     copy( lumisTemp.begin(), lumisTemp.end(), jsonVector.begin() );
279     }
280 arizzi 1.1
281     // now get each parameter
282     int maxEvents_( in.getParameter<int>("maxEvents") );
283     unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
284     std::string outputFile_( out.getParameter<std::string>("fileName" ) );
285     std::vector<std::string> triggers( ana.getParameter<std::vector<std::string> >("triggers") );
286 arizzi 1.6 double btagThr = ana.getParameter<double>("bJetCountThreshold" );
287 arizzi 1.4 bool fromCandidate = ana.getParameter<bool>("readFromCandidates");
288 arizzi 1.17 bool useHighestPtHiggsZ = ana.getParameter<bool>("useHighestPtHiggsZ");
289     bool useHighestPtHiggsW = ana.getParameter<bool>("useHighestPtHiggsW");
290     HbbCandidateFinderAlgo * algoZ = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdZ"),useHighestPtHiggsZ );
291     HbbCandidateFinderAlgo * algoW = new HbbCandidateFinderAlgo(ana.getParameter<bool>("verbose"), ana.getParameter<double>("jetPtThresholdW"),useHighestPtHiggsW);
292 arizzi 1.4
293 arizzi 1.16 TriggerWeight triggerWeight(ana);
294 arizzi 1.17 BTagWeight btag(2); // 2 operating points "Custom" = 0.5 and "Tight = 0.898"
295     BTagSampleEfficiency btagEff( ana.getParameter<std::string>("btagEffFileName" ).c_str() );
296 arizzi 1.1
297     std::vector<std::string> inputFiles_( in.getParameter<std::vector<std::string> >("fileNames") );
298     // std::string inputFile( in.getParameter<std::string> ("fileName") );
299    
300    
301 arizzi 1.3 std::string PUmcfileName_ = in.getParameter<std::string> ("PUmcfileName") ;
302     std::string PUdatafileName_ = in.getParameter<std::string> ("PUdatafileName") ;
303 arizzi 1.1 bool isMC_( ana.getParameter<bool>("isMC") );
304     TriggerReader trigger(isMC_);
305 arizzi 1.18 TriggerReader patFilters(false);
306 arizzi 1.1
307 arizzi 1.6 // TFile *_outPUFile = new TFile((outputFile_+"_PU").c_str(), "recreate");
308     // TH1F * pu = new TH1F("pileup","",-0.5,24.5,25);
309 arizzi 1.1 TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
310 arizzi 1.16 TH1F * count = new TH1F("Count","Count", 1,0,2 );
311     TH1F * countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
312 arizzi 1.1 _outTree = new TTree("tree", "myTree");
313    
314     _outTree->Branch("H" , &H , "mass/F:pt/F:eta:phi/F");
315     _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
316     _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
317     _outTree->Branch("naJets" , &naJets , "naJets/I");
318 arizzi 1.2
319     _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
320     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
321     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
322     _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
323     _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
324     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
325     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
326     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
327     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
328     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
329     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
330     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
331     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
332     _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
333     _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
334     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
335     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
336 arizzi 1.24 _outTree->Branch("hJet_vtxMass",hJets.vtxMass ,"vtxMass[naJets]/F");
337     _outTree->Branch("hJet_vtx3dL",hJets.vtx3dL ,"vtx3dL[naJets]/F");
338     _outTree->Branch("hJet_vtx3deL",hJets.vtx3deL ,"vtx3deL[naJets]/F");
339 arizzi 1.2
340     _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
341     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
342     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
343     _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
344     _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
345     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
346     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
347     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
348     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
349     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
350     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
351     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
352     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
353     _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
354     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
355     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
356     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
357 arizzi 1.24 _outTree->Branch("aJet_vtxMass",aJets.vtxMass ,"vtxMass[naJets]/F");
358     _outTree->Branch("aJet_vtx3dL",aJets.vtx3dL ,"vtx3dL[naJets]/F");
359     _outTree->Branch("aJet_vtx3deL",aJets.vtx3deL ,"vtx3deL[naJets]/F");
360 arizzi 1.1
361     _outTree->Branch("jjdr" , &jjdr , "jjdr/F" );
362     _outTree->Branch("jjdPhi" , &jjdPhi , "jjdPhi/F" );
363 arizzi 1.6 _outTree->Branch("jjdEta" , &jjdEta , "jjdEta/F" );
364 arizzi 1.1 _outTree->Branch("numJets" , &numJets , "numJets/I" );
365     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
366     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
367     _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
368     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
369     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
370     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
371     _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
372 arizzi 1.22 _outTree->Branch("weightTrigMET" , &weightTrigMET , "weightTrigMET/F");
373 arizzi 1.24 _outTree->Branch("weightEleRecoAndId" , &weightEleRecoAndId , "weightEleRecoAndId/F");
374     _outTree->Branch("weightEleTrigJetMETPart" , &weightEleTrigJetMETPart , "weightEleTrigJetMETPart/F");
375     _outTree->Branch("weightEleTrigElePart" , &weightEleTrigElePart , "weightEleTrigElePart/F");
376    
377    
378 arizzi 1.1 _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
379     _outTree->Branch("PUweight", &PUweight , "PUweight/F");
380 arizzi 1.3 _outTree->Branch("eventFlav", &eventFlav , "eventFlav/I");
381 arizzi 1.1
382    
383    
384    
385     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
386     _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
387 arizzi 1.19 _outTree->Branch("HMETdPhi" , &HMETdPhi , "HMETdPhi/F" );
388 arizzi 1.1 _outTree->Branch("VMt" , &VMt , "VMt/F" );
389    
390 arizzi 1.9 _outTree->Branch("nvlep" , &nvlep , "nvlep/I");
391     _outTree->Branch("nalep" , &nalep , "nalep/I");
392 arizzi 1.3
393 arizzi 1.9 _outTree->Branch("vLepton_mass",vLeptons.mass ,"mass[nvlep]/F");
394     _outTree->Branch("vLepton_pt",vLeptons.pt ,"pt[nvlep]/F");
395     _outTree->Branch("vLepton_eta",vLeptons.eta ,"eta[nvlep]");
396     _outTree->Branch("vLepton_phi",vLeptons.phi ,"phi[nvlep]/F");
397     _outTree->Branch("vLepton_aodCombRelIso",vLeptons.aodCombRelIso ,"aodCombRelIso[nvlep]/F");
398     _outTree->Branch("vLepton_pfCombRelIso",vLeptons.pfCombRelIso ,"pfCombRelIso[nvlep]/F");
399     _outTree->Branch("vLepton_photonIso",vLeptons.photonIso ,"photonIso[nvlep]/F");
400     _outTree->Branch("vLepton_neutralHadIso",vLeptons.neutralHadIso ,"neutralHadIso[nvlep]/F");
401     _outTree->Branch("vLepton_chargedHadIso",vLeptons.chargedHadIso ,"chargedHadIso[nvlep]/F");
402     _outTree->Branch("vLepton_particleIso",vLeptons.particleIso ,"particleIso[nvlep]/F");
403     _outTree->Branch("vLepton_dxy",vLeptons.dxy ,"dxy[nvlep]/F");
404     _outTree->Branch("vLepton_dz",vLeptons.dz ,"dz[nvlep]/F");
405     _outTree->Branch("vLepton_type",vLeptons.type ,"type[nvlep]/I");
406     _outTree->Branch("vLepton_id",vLeptons.id ,"id[nvlep]/F");
407    
408     _outTree->Branch("aLepton_mass",aLeptons.mass ,"mass[nalep]/F");
409     _outTree->Branch("aLepton_pt",aLeptons.pt ,"pt[nalep]/F");
410     _outTree->Branch("aLepton_eta",aLeptons.eta ,"eta[nalep]");
411     _outTree->Branch("aLepton_phi",aLeptons.phi ,"phi[nalep]/F");
412     _outTree->Branch("aLepton_aodCombRelIso",aLeptons.aodCombRelIso ,"aodCombRelIso[nalep]/F");
413     _outTree->Branch("aLepton_pfCombRelIso",aLeptons.pfCombRelIso ,"pfCombRelIso[nalep]/F");
414     _outTree->Branch("aLepton_photonIso",aLeptons.photonIso ,"photonIso[nalep]/F");
415     _outTree->Branch("aLepton_neutralHadIso",aLeptons.neutralHadIso ,"neutralHadIso[nalep]/F");
416     _outTree->Branch("aLepton_chargedHadIso",aLeptons.chargedHadIso ,"chargedHadIso[nalep]/F");
417     _outTree->Branch("aLepton_particleIso",aLeptons.particleIso ,"particleIso[nalep]/F");
418     _outTree->Branch("aLepton_dxy",aLeptons.dxy ,"dxy[nalep]/F");
419     _outTree->Branch("aLepton_dz",aLeptons.dz ,"dz[nalep]/F");
420     _outTree->Branch("aLepton_type",aLeptons.type ,"type[nalep]/I");
421     _outTree->Branch("aLepton_id",aLeptons.id ,"id[nalep]/F");
422    
423 arizzi 1.8 _outTree->Branch("top" , &top , "mass/F:pt/F:wMass/F");
424 arizzi 1.1
425     _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
426     _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
427     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
428     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
429    
430     std::stringstream s;
431     s << "triggerFlags[" << triggers.size() << "]/b";
432     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
433 nmohr 1.7
434 arizzi 1.17
435 nmohr 1.7 _outTree->Branch("EVENT" , &EVENT , "run/I:lumi/I:event/I:json/I");
436 arizzi 1.18 _outTree->Branch("hbhe" , &hbhe , "hbhe/b");
437 arizzi 1.17 _outTree->Branch("btag1TSF" , &btag1TSF , "btag1TSF/F");
438     _outTree->Branch("btag2TSF" , &btag2TSF , "btag2TSF/F");
439     _outTree->Branch("btag1T2CSF" , &btag1T2CSF , "btag1T2CSF/F");
440 arizzi 1.1
441     int ievt=0;
442     int totalcount=0;
443    
444     // TFile* inFile = new TFile(inputFile.c_str(), "read");
445     for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
446     std::cout << iFile << std::endl;
447     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
448     if(inFile==0) continue;
449    
450     // loop the events
451    
452     fwlite::Event ev(inFile);
453     for(ev.toBegin(); !ev.atEnd(); ++ev, ++ievt)
454     {
455 arizzi 1.16 count->Fill(1.);
456 arizzi 1.1
457     if(isMC_){
458     // PU weights
459 arizzi 1.3
460 arizzi 1.9 // edm::LumiReWeighting LumiWeights_ = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
461     // double avg=0;
462 arizzi 1.3 //FIXME: PU (NEED EDM FIX)
463 arizzi 1.1 // if( PUintimeSizes.isValid() && PUouttime1minusSizes.isValid() && PUouttime1plusSizes.isValid()){
464     // avg = (double)( *PUintimeSizes );
465     // }
466 arizzi 1.3 PUweight = 1.0; // FIXME: LumiWeights_.weight3BX( avg /3.); (NEED EDM FIX)
467 arizzi 1.1 }
468 arizzi 1.16 countWithPU->Fill(PUweight);
469 nmohr 1.7
470     //Write event info
471     EVENT.run = ev.id().run();
472     EVENT.lumi = ev.id().luminosityBlock();
473     EVENT.event = ev.id().event();
474     EVENT.json = jsonContainsEvent (jsonVector, ev);
475 arizzi 1.3
476 arizzi 1.4
477     const std::vector<VHbbCandidate> * candZ ;
478     const std::vector<VHbbCandidate> * candW ;
479 arizzi 1.13 const VHbbEvent * iEvent =0;
480 arizzi 1.4 if(fromCandidate)
481     {
482 arizzi 1.3 fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandleZ;
483     vhbbCandHandleZ.getByLabel(ev,"hbbBestCSVPt20Candidates");
484 arizzi 1.4 candZ = vhbbCandHandleZ.product();
485 arizzi 1.3
486     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
487     vhbbCandHandle.getByLabel(ev,"hbbHighestPtHiggsPt30Candidates");
488 arizzi 1.4 candW = vhbbCandHandle.product();
489     }
490     else
491     {
492     candZlocal->clear();
493     candWlocal->clear();
494     fwlite::Handle< VHbbEvent > vhbbHandle;
495     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
496 arizzi 1.13 iEvent = vhbbHandle.product();
497 arizzi 1.4 algoZ->run(vhbbHandle.product(),*candZlocal);
498     algoW->run(vhbbHandle.product(),*candWlocal);
499     candZ= candZlocal;
500     candW= candWlocal;
501    
502    
503 arizzi 1.1
504 arizzi 1.4 }
505 arizzi 1.1
506 arizzi 1.3 const std::vector<VHbbCandidate> * cand = candZ;
507 arizzi 1.1
508    
509     fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
510     vhbbAuxHandle.getByLabel(ev,"HbbAnalyzerNew");
511     const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
512    
513     /* fwlite::Handle< VHbbEvent > vhbbHandle;
514     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
515     const VHbbEvent iEvent = *vhbbHandle.product();
516     */
517    
518     // std::clog << "Filling tree "<< std::endl;
519 arizzi 1.17 bool isW=false;
520 arizzi 1.21
521 arizzi 1.17
522 arizzi 1.3 if(cand->size() == 0 or cand->at(0).H.jets.size() < 2) continue;
523     if(cand->size() > 1 )
524     {
525     std::cout << "MULTIPLE CANDIDATES: " << cand->size() << std::endl;
526     }
527 arizzi 1.17 if(cand->at(0).candidateType == VHbbCandidate::Wmun || cand->at(0).candidateType == VHbbCandidate::Wen ) { cand=candW; isW=true; }
528 arizzi 1.3 if(cand->size() == 0)
529     {
530     // std::cout << "W event loss due to tigther cuts" << std::endl;
531     continue;
532     }
533     const VHbbCandidate & vhCand = cand->at(0);
534 arizzi 1.18 patFilters.setEvent(&ev,"VH");
535     hbhe = patFilters.accept("hbhe");
536    
537 arizzi 1.4 trigger.setEvent(&ev);
538     for(size_t j=0;j < triggers.size();j++)
539     triggerFlags[j]=trigger.accept(triggers[j]);
540 arizzi 1.3
541     eventFlav=0;
542     if(aux.mcBbar.size() > 0 || aux.mcB.size() > 0) eventFlav=5;
543     else if(aux.mcC.size() > 0) eventFlav=4;
544 arizzi 1.8
545 arizzi 1.3
546 arizzi 1.1 H.mass = vhCand.H.p4.M();
547     H.pt = vhCand.H.p4.Pt();
548     H.eta = vhCand.H.p4.Eta();
549     H.phi = vhCand.H.p4.Phi();
550     V.mass = vhCand.V.p4.M();
551     V.pt = vhCand.V.p4.Pt();
552     V.eta = vhCand.V.p4.Eta();
553     V.phi = vhCand.V.p4.Phi();
554     nhJets=2;
555     hJets.set(vhCand.H.jets[0],0);
556     hJets.set(vhCand.H.jets[1],1);
557     aJets.reset();
558     naJets=vhCand.additionalJets.size();
559 arizzi 1.6 numBJets=0;
560     if(vhCand.H.jets[0].csv> btagThr) numBJets++;
561     if(vhCand.H.jets[1].csv> btagThr) numBJets++;
562     for( int j=0; j < naJets && j < MAXJ; j++ )
563     {
564     aJets.set(vhCand.additionalJets[j],j);
565     if(vhCand.additionalJets[j].csv> btagThr) numBJets++;
566     }
567 arizzi 1.1 numJets = vhCand.additionalJets.size()+2;
568     jjdr = 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());
569     jjdPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
570 arizzi 1.6 jjdEta= TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
571 arizzi 1.19 HVdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ) ;
572 arizzi 1.20 HMETdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.mets.at(0).p4.Phi()) ) ;
573 nmohr 1.14 VMt = vhCand.Mt() ;
574 arizzi 1.1 deltaPullAngle = vhCand.H.deltaTheta;
575 arizzi 1.16
576 arizzi 1.1
577 arizzi 1.3 hJets.cosTheta[0]= vhCand.H.helicities[0];
578     hJets.cosTheta[1]= vhCand.H.helicities[1];
579 arizzi 1.1
580     MET.et = vhCand.V.mets.at(0).p4.Pt();
581     MET.phi = vhCand.V.mets.at(0).p4.Phi();
582     MET.sumet = vhCand.V.mets.at(0).sumEt;
583     MET.sig = vhCand.V.mets.at(0).metSig;
584 arizzi 1.24
585    
586     if(!fromCandidate) {
587     MHT.mht = iEvent->mht.p4.Pt();
588     MHT.phi = iEvent->mht.p4.Phi();
589     MHT.ht = iEvent->mht.sumEt;
590     MHT.sig = iEvent->mht.metSig;
591    
592     }
593    
594    
595 arizzi 1.1 Vtype = vhCand.candidateType;
596 arizzi 1.24
597     //Loop on jets
598     double maxBtag=-99999;
599     minDeltaPhijetMET = 999;
600     TLorentzVector bJet;
601     std::vector<std::vector<BTagWeight::JetInfo> > btagJetInfos;
602     std::vector<float> jet30eta;
603     std::vector<float> jet30pt;
604     if(fromCandidate)
605     {
606     //Loop on Higgs Jets
607     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ){
608     if (vhCand.H.jets[j].csv > maxBtag) { bJet=vhCand.H.jets[j].p4 ; maxBtag =vhCand.H.jets[j].csv; }
609     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi()) < minDeltaPhijetMET)
610     {
611     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi());
612     jetPt_minDeltaPhijetMET=vhCand.H.jets[j].p4.Pt();
613     }
614     btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
615     }
616     //Loop on Additional Jets
617     for(unsigned int j=0; j < vhCand.additionalJets.size(); j++ ){
618     if (vhCand.additionalJets[j].csv > maxBtag) { bJet=vhCand.additionalJets[j].p4 ; maxBtag =vhCand.additionalJets[j].csv; }
619     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi()) < minDeltaPhijetMET)
620     {
621     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi());
622     jetPt_minDeltaPhijetMET=vhCand.additionalJets[j].p4.Pt();
623     }
624     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) ) // btag SF computed using only H-jets if best-H made with dijetPt rather than best CSV
625     {
626     if(vhCand.additionalJets[j].p4.Pt() > 20)
627     btagJetInfos.push_back(btagEff.jetInfo(vhCand.additionalJets[j]));
628     }
629     }
630     }
631     else
632     {
633     for(unsigned int j=0; j < iEvent->simpleJets2.size(); j++ ){
634     if (iEvent->simpleJets2[j].csv > maxBtag) { bJet=iEvent->simpleJets2[j].p4 ; maxBtag =iEvent->simpleJets2[j].csv; }
635     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi()) < minDeltaPhijetMET)
636     {
637     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi());
638     jetPt_minDeltaPhijetMET=iEvent->simpleJets2[j].p4.Pt();
639     }
640     if(iEvent->simpleJets2[j].p4.Pt() > 30)
641     {
642     jet30eta.push_back(iEvent->simpleJets2[j].p4.Eta());
643     jet30pt.push_back(iEvent->simpleJets2[j].p4.Pt());
644     }
645    
646     //For events made with highest CSV, all jets in the event should be taken into account for "tagging" SF (anti tagging is a mess)
647     // 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
648     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )
649     {
650     if(iEvent->simpleJets2[j].p4.Pt() > 20)
651     btagJetInfos.push_back(btagEff.jetInfo(iEvent->simpleJets2[j]));
652     }
653     }
654    
655     //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
656     // by a criteria (pt of the dijet) that is not btag SF dependent
657     if(!( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )) {
658     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ) btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
659     }
660    
661     }
662 arizzi 1.9 vLeptons.reset();
663 arizzi 1.15 weightTrig = 1.; // better to default to 1
664 arizzi 1.8 TLorentzVector leptonForTop;
665 arizzi 1.9 size_t firstAddMu=0;
666     size_t firstAddEle=0;
667 arizzi 1.1 if(Vtype == VHbbCandidate::Zmumu ){
668 arizzi 1.13 vLeptons.set(vhCand.V.muons[0],0,13);
669     vLeptons.set(vhCand.V.muons[1],1,13);
670 arizzi 1.16 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleMuID(vLeptons.pt[1],vLeptons.eta[1]) ;
671     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
672     float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[1],vLeptons.eta[1]);
673 arizzi 1.1 float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
674     weightTrig = cweightID * cweightTrig;
675 arizzi 1.9 nvlep=2;
676     firstAddMu=2;
677 arizzi 1.1 }
678     if( Vtype == VHbbCandidate::Zee ){
679 arizzi 1.9 vLeptons.set(vhCand.V.electrons[0],0,11);
680     vLeptons.set(vhCand.V.electrons[1],1,11);
681     nvlep=2;
682     firstAddEle=2;
683 arizzi 1.24 std::vector<float> pt,eta;
684     pt.push_back(vLeptons.pt[0]); eta.push_back(vLeptons.eta[0]);
685     pt.push_back(vLeptons.pt[1]); eta.push_back(vLeptons.eta[1]);
686     weightEleRecoAndId=triggerWeight.scaleID95Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]) *
687     triggerWeight.scaleID95Ele(vLeptons.pt[1],vLeptons.eta[1]) * triggerWeight.scaleRecoEle(vLeptons.pt[1],vLeptons.eta[1]);
688     weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
689     weightTrig = weightEleTrigElePart * weightEleRecoAndId;
690    
691    
692    
693 arizzi 1.1 }
694     if(Vtype == VHbbCandidate::Wmun ){
695 arizzi 1.8 leptonForTop=vhCand.V.muons[0].p4;
696 arizzi 1.13 vLeptons.set(vhCand.V.muons[0],0,13);
697 arizzi 1.16 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]);
698     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
699 arizzi 1.1 float cweightTrig = weightTrig1;
700     weightTrig = cweightID * cweightTrig;
701 arizzi 1.9 nvlep=1;
702     firstAddMu=1;
703 arizzi 1.1 }
704     if( Vtype == VHbbCandidate::Wen ){
705 arizzi 1.8 leptonForTop=vhCand.V.electrons[0].p4;
706 arizzi 1.9 vLeptons.set(vhCand.V.electrons[0],0,11);
707     nvlep=1;
708     firstAddEle=1;
709 arizzi 1.24 float weightMay = triggerWeight.scaleSingleEleMay(vLeptons.pt[0],vLeptons.eta[0]);
710     float weightV4 = triggerWeight.scaleSingleEleV4(vLeptons.pt[0],vLeptons.eta[0]);
711     weightEleRecoAndId=triggerWeight.scaleID80Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]);
712     weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30eta,jet30pt)*triggerWeight.scalePFMHTEle(MET.et);
713     weightEleTrigElePart= weightV4; //this is for debugging only, checking only the V4 part
714    
715     weightMay*=weightEleRecoAndId;
716     weightV4*=weightEleRecoAndId;
717     weightV4*=weightEleTrigJetMETPart;
718     weightTrig = weightMay * 0.187 + weightV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
719 arizzi 1.1 }
720 arizzi 1.3 if( Vtype == VHbbCandidate::Znn ){
721 arizzi 1.9 nvlep=0;
722 arizzi 1.22 float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
723     weightTrig = weightTrig1;
724     weightTrigMET = weightTrig1;
725 arizzi 1.3 }
726 arizzi 1.9
727     aLeptons.reset();
728     nalep=0;
729 arizzi 1.21 if(fromCandidate)
730     {
731     for(size_t j=firstAddMu;j< vhCand.V.muons.size();j++) aLeptons.set(vhCand.V.muons[j],nalep++,13);
732     for(size_t j=firstAddEle;j< vhCand.V.electrons.size();j++) aLeptons.set(vhCand.V.electrons[j],nalep++,11);
733     }
734     else
735     {
736     for(size_t j=0;j< iEvent->muInfo.size();j++)
737     {
738     if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wmun ) && (Vtype != VHbbCandidate::Zmumu )) )
739     aLeptons.set(iEvent->muInfo[j],nalep++,13);
740     }
741     for(size_t j=0;j< iEvent->eleInfo.size();j++)
742     {
743     if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wen ) && (Vtype != VHbbCandidate::Zee )))
744     aLeptons.set(iEvent->eleInfo[j],nalep++,11);
745     }
746 arizzi 1.8
747 arizzi 1.21 }
748 arizzi 1.8
749 arizzi 1.24
750 arizzi 1.17 if(isMC_)
751     {
752     //std::cout << "BTAGSF " << btagJetInfos.size() << " " << btag.weight<BTag1Tight2CustomFilter>(btagJetInfos) << std::endl;
753 arizzi 1.24 if ( btagJetInfos.size()< 10)
754     {
755 arizzi 1.17 btag1T2CSF = btag.weight<BTag1Tight2CustomFilter>(btagJetInfos);
756 arizzi 1.23 btag2TSF = btag.weight<BTag2TightFilter>(btagJetInfos);
757 arizzi 1.24 btag1TSF = btag.weight<BTag1TightFilter>(btagJetInfos);
758     }
759     else
760     {
761     std::cout << "WARNING: combinatorics for " << btagJetInfos.size() << " jets is too high (>=10). use SF=1 " << std::endl;
762     //FIXME: revert to random throw for this cases
763     btag1T2CSF = 1.;
764     btag2TSF = 1.;
765     btag1TSF = 1.;
766     }
767 arizzi 1.16 }
768 arizzi 1.17
769 arizzi 1.8 if(maxBtag > -99999)
770     {
771     TopHypo topQuark = TopMassReco::topMass(leptonForTop,bJet,vhCand.V.mets.at(0).p4);
772     top.mass = topQuark.p4.M();
773     top.pt = topQuark.p4.Pt();
774     top.wMass = topQuark.p4W.M();
775     } else {
776     top.mass = -99;
777     top.pt = -99;
778     top.wMass = -99;
779     }
780    
781    
782    
783 arizzi 1.1 // if(aux.mcC.size() >=2)
784     // std::cout << "C Must not be zero and it is ... " << aux.mcC[1].p4.Pt() << std::endl;
785     // if(aux.mcB.size() >=1)
786     // std::cout << "B Must not be zero and it is ... " << aux.mcB[0].p4.Pt() << std::endl;
787    
788 arizzi 1.24 gendrcc=aux.genCCDeltaR();
789     gendrbb=aux.genBBDeltaR();
790     genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
791     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
792    
793     /* if(!fromCandidate){
794     std::vector<VHbbEvent::SimpleJet> & ak7 = iEvent.simpleJets3;
795     if(ak7.size() > 1){
796     CompareDeltaR deltaRComparatorJ1(vhCand.H.jets[0].p4);
797     CompareDeltaR deltaRComparatorJ2(vhCand.H.jets[1].p4);
798     std::vector<VHbbEvent::SimpleJet> ak7_matched;
799    
800     std::sort( ak7.begin(),ak7.end(),deltaRComparatorJ1 );
801     ak7_matched.push_back(ak7[0]);
802    
803     if(ak7[1].p4.DeltaR(vhCand.H.jets[0].p4) > 0.5)
804     ak7.erase(ak7.begin());
805    
806     std::sort( ak7.begin(),ak7.end(),deltaRComparatorJ2 );
807     ak7_matched.push_back(ak7[0]);
808    
809     CompareJetPt ptComparator;
810     std::sort( ak7_matched.begin(),ak7_matched.end(),ptComparator );
811     if(ak7_matched[0].p4.DeltaR(vhCand.H.jets[0].p4) < 0.5
812     and ak7_matched[1].p4.DeltaR(vhCand.H.jets[1].p4) < 0.5 ){
813     deltaPullAngleAK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[0],ak7_matched[1]);
814     }
815     }
816     }
817 arizzi 1.3
818 arizzi 1.1 //FIXME: _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
819 arizzi 1.24 */
820 arizzi 1.1
821    
822 arizzi 1.17
823 arizzi 1.1 _outTree->Fill();
824 arizzi 1.4
825 arizzi 1.1 }// closed event loop
826    
827     std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
828     inFile->Close();
829     // close input file
830     } // loop on files
831    
832    
833     std::cout << "Events: " << ievt <<std::endl;
834     std::cout << "TotalCount: " << totalcount <<std::endl;
835    
836    
837    
838     _outFile->cd();
839    
840     _outTree->Write();
841     _outFile->Write();
842     _outFile->Close();
843     return 0;
844     }
845    
846