ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.25
Committed: Thu Sep 15 14:38:51 2011 UTC (13 years, 8 months ago) by arizzi
Content type: text/plain
Branch: MAIN
Changes since 1.24: +24 -21 lines
Log Message:
add pu and  AK7 pull

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.25
304 arizzi 1.1 bool isMC_( ana.getParameter<bool>("isMC") );
305     TriggerReader trigger(isMC_);
306 arizzi 1.18 TriggerReader patFilters(false);
307 arizzi 1.25
308     edm::LumiReWeighting lumiWeights;
309     if(isMC_)
310     {
311     edm::LumiReWeighting lumiWeights = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
312    
313     }
314 arizzi 1.1
315 arizzi 1.6 // TFile *_outPUFile = new TFile((outputFile_+"_PU").c_str(), "recreate");
316     // TH1F * pu = new TH1F("pileup","",-0.5,24.5,25);
317 arizzi 1.1 TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
318 arizzi 1.16 TH1F * count = new TH1F("Count","Count", 1,0,2 );
319     TH1F * countWithPU = new TH1F("CountWithPU","CountWithPU", 1,0,2 );
320 arizzi 1.1 _outTree = new TTree("tree", "myTree");
321    
322     _outTree->Branch("H" , &H , "mass/F:pt/F:eta:phi/F");
323     _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
324     _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
325     _outTree->Branch("naJets" , &naJets , "naJets/I");
326 arizzi 1.2
327     _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
328     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
329     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
330     _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
331     _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
332     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
333     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
334     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
335     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
336     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
337     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
338     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
339     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
340     _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
341     _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
342     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
343     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
344 arizzi 1.24 _outTree->Branch("hJet_vtxMass",hJets.vtxMass ,"vtxMass[naJets]/F");
345     _outTree->Branch("hJet_vtx3dL",hJets.vtx3dL ,"vtx3dL[naJets]/F");
346     _outTree->Branch("hJet_vtx3deL",hJets.vtx3deL ,"vtx3deL[naJets]/F");
347 arizzi 1.2
348     _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
349     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
350     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
351     _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
352     _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
353     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
354     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
355     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
356     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
357     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
358     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
359     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
360     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
361     _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
362     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
363     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
364     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
365 arizzi 1.24 _outTree->Branch("aJet_vtxMass",aJets.vtxMass ,"vtxMass[naJets]/F");
366     _outTree->Branch("aJet_vtx3dL",aJets.vtx3dL ,"vtx3dL[naJets]/F");
367     _outTree->Branch("aJet_vtx3deL",aJets.vtx3deL ,"vtx3deL[naJets]/F");
368 arizzi 1.1
369     _outTree->Branch("jjdr" , &jjdr , "jjdr/F" );
370     _outTree->Branch("jjdPhi" , &jjdPhi , "jjdPhi/F" );
371 arizzi 1.6 _outTree->Branch("jjdEta" , &jjdEta , "jjdEta/F" );
372 arizzi 1.1 _outTree->Branch("numJets" , &numJets , "numJets/I" );
373     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
374     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
375     _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
376     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
377     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
378     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
379     _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
380 arizzi 1.22 _outTree->Branch("weightTrigMET" , &weightTrigMET , "weightTrigMET/F");
381 arizzi 1.24 _outTree->Branch("weightEleRecoAndId" , &weightEleRecoAndId , "weightEleRecoAndId/F");
382     _outTree->Branch("weightEleTrigJetMETPart" , &weightEleTrigJetMETPart , "weightEleTrigJetMETPart/F");
383     _outTree->Branch("weightEleTrigElePart" , &weightEleTrigElePart , "weightEleTrigElePart/F");
384    
385    
386 arizzi 1.1 _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
387     _outTree->Branch("PUweight", &PUweight , "PUweight/F");
388 arizzi 1.3 _outTree->Branch("eventFlav", &eventFlav , "eventFlav/I");
389 arizzi 1.1
390    
391    
392    
393     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
394     _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
395 arizzi 1.19 _outTree->Branch("HMETdPhi" , &HMETdPhi , "HMETdPhi/F" );
396 arizzi 1.1 _outTree->Branch("VMt" , &VMt , "VMt/F" );
397    
398 arizzi 1.9 _outTree->Branch("nvlep" , &nvlep , "nvlep/I");
399     _outTree->Branch("nalep" , &nalep , "nalep/I");
400 arizzi 1.3
401 arizzi 1.9 _outTree->Branch("vLepton_mass",vLeptons.mass ,"mass[nvlep]/F");
402     _outTree->Branch("vLepton_pt",vLeptons.pt ,"pt[nvlep]/F");
403     _outTree->Branch("vLepton_eta",vLeptons.eta ,"eta[nvlep]");
404     _outTree->Branch("vLepton_phi",vLeptons.phi ,"phi[nvlep]/F");
405     _outTree->Branch("vLepton_aodCombRelIso",vLeptons.aodCombRelIso ,"aodCombRelIso[nvlep]/F");
406     _outTree->Branch("vLepton_pfCombRelIso",vLeptons.pfCombRelIso ,"pfCombRelIso[nvlep]/F");
407     _outTree->Branch("vLepton_photonIso",vLeptons.photonIso ,"photonIso[nvlep]/F");
408     _outTree->Branch("vLepton_neutralHadIso",vLeptons.neutralHadIso ,"neutralHadIso[nvlep]/F");
409     _outTree->Branch("vLepton_chargedHadIso",vLeptons.chargedHadIso ,"chargedHadIso[nvlep]/F");
410     _outTree->Branch("vLepton_particleIso",vLeptons.particleIso ,"particleIso[nvlep]/F");
411     _outTree->Branch("vLepton_dxy",vLeptons.dxy ,"dxy[nvlep]/F");
412     _outTree->Branch("vLepton_dz",vLeptons.dz ,"dz[nvlep]/F");
413     _outTree->Branch("vLepton_type",vLeptons.type ,"type[nvlep]/I");
414     _outTree->Branch("vLepton_id",vLeptons.id ,"id[nvlep]/F");
415    
416     _outTree->Branch("aLepton_mass",aLeptons.mass ,"mass[nalep]/F");
417     _outTree->Branch("aLepton_pt",aLeptons.pt ,"pt[nalep]/F");
418     _outTree->Branch("aLepton_eta",aLeptons.eta ,"eta[nalep]");
419     _outTree->Branch("aLepton_phi",aLeptons.phi ,"phi[nalep]/F");
420     _outTree->Branch("aLepton_aodCombRelIso",aLeptons.aodCombRelIso ,"aodCombRelIso[nalep]/F");
421     _outTree->Branch("aLepton_pfCombRelIso",aLeptons.pfCombRelIso ,"pfCombRelIso[nalep]/F");
422     _outTree->Branch("aLepton_photonIso",aLeptons.photonIso ,"photonIso[nalep]/F");
423     _outTree->Branch("aLepton_neutralHadIso",aLeptons.neutralHadIso ,"neutralHadIso[nalep]/F");
424     _outTree->Branch("aLepton_chargedHadIso",aLeptons.chargedHadIso ,"chargedHadIso[nalep]/F");
425     _outTree->Branch("aLepton_particleIso",aLeptons.particleIso ,"particleIso[nalep]/F");
426     _outTree->Branch("aLepton_dxy",aLeptons.dxy ,"dxy[nalep]/F");
427     _outTree->Branch("aLepton_dz",aLeptons.dz ,"dz[nalep]/F");
428     _outTree->Branch("aLepton_type",aLeptons.type ,"type[nalep]/I");
429     _outTree->Branch("aLepton_id",aLeptons.id ,"id[nalep]/F");
430    
431 arizzi 1.8 _outTree->Branch("top" , &top , "mass/F:pt/F:wMass/F");
432 arizzi 1.1
433     _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
434     _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
435     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
436     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
437    
438     std::stringstream s;
439     s << "triggerFlags[" << triggers.size() << "]/b";
440     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
441 nmohr 1.7
442 arizzi 1.17
443 nmohr 1.7 _outTree->Branch("EVENT" , &EVENT , "run/I:lumi/I:event/I:json/I");
444 arizzi 1.18 _outTree->Branch("hbhe" , &hbhe , "hbhe/b");
445 arizzi 1.17 _outTree->Branch("btag1TSF" , &btag1TSF , "btag1TSF/F");
446     _outTree->Branch("btag2TSF" , &btag2TSF , "btag2TSF/F");
447     _outTree->Branch("btag1T2CSF" , &btag1T2CSF , "btag1T2CSF/F");
448 arizzi 1.1
449     int ievt=0;
450     int totalcount=0;
451    
452     // TFile* inFile = new TFile(inputFile.c_str(), "read");
453     for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
454     std::cout << iFile << std::endl;
455     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
456     if(inFile==0) continue;
457    
458     // loop the events
459    
460     fwlite::Event ev(inFile);
461     for(ev.toBegin(); !ev.atEnd(); ++ev, ++ievt)
462     {
463 arizzi 1.16 count->Fill(1.);
464 arizzi 1.1
465 arizzi 1.25 fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
466     vhbbAuxHandle.getByLabel(ev,"HbbAnalyzerNew");
467     const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
468     PUweight=1.;
469 arizzi 1.1 if(isMC_){
470     // PU weights
471 arizzi 1.25 std::map<int, unsigned int>::const_iterator puit = aux.puInfo.pus.find(0);
472     PUweight = lumiWeights.weight3BX( puit->second /3. );
473 arizzi 1.1 }
474 arizzi 1.16 countWithPU->Fill(PUweight);
475 nmohr 1.7
476     //Write event info
477     EVENT.run = ev.id().run();
478     EVENT.lumi = ev.id().luminosityBlock();
479     EVENT.event = ev.id().event();
480     EVENT.json = jsonContainsEvent (jsonVector, ev);
481 arizzi 1.3
482 arizzi 1.4
483     const std::vector<VHbbCandidate> * candZ ;
484     const std::vector<VHbbCandidate> * candW ;
485 arizzi 1.13 const VHbbEvent * iEvent =0;
486 arizzi 1.4 if(fromCandidate)
487     {
488 arizzi 1.3 fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandleZ;
489     vhbbCandHandleZ.getByLabel(ev,"hbbBestCSVPt20Candidates");
490 arizzi 1.4 candZ = vhbbCandHandleZ.product();
491 arizzi 1.3
492     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
493     vhbbCandHandle.getByLabel(ev,"hbbHighestPtHiggsPt30Candidates");
494 arizzi 1.4 candW = vhbbCandHandle.product();
495     }
496     else
497     {
498     candZlocal->clear();
499     candWlocal->clear();
500     fwlite::Handle< VHbbEvent > vhbbHandle;
501     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
502 arizzi 1.13 iEvent = vhbbHandle.product();
503 arizzi 1.4 algoZ->run(vhbbHandle.product(),*candZlocal);
504     algoW->run(vhbbHandle.product(),*candWlocal);
505     candZ= candZlocal;
506     candW= candWlocal;
507    
508    
509 arizzi 1.1
510 arizzi 1.4 }
511 arizzi 1.1
512 arizzi 1.3 const std::vector<VHbbCandidate> * cand = candZ;
513 arizzi 1.1
514    
515    
516     /* fwlite::Handle< VHbbEvent > vhbbHandle;
517     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
518     const VHbbEvent iEvent = *vhbbHandle.product();
519     */
520    
521     // std::clog << "Filling tree "<< std::endl;
522 arizzi 1.17 bool isW=false;
523 arizzi 1.21
524 arizzi 1.17
525 arizzi 1.3 if(cand->size() == 0 or cand->at(0).H.jets.size() < 2) continue;
526     if(cand->size() > 1 )
527     {
528     std::cout << "MULTIPLE CANDIDATES: " << cand->size() << std::endl;
529     }
530 arizzi 1.17 if(cand->at(0).candidateType == VHbbCandidate::Wmun || cand->at(0).candidateType == VHbbCandidate::Wen ) { cand=candW; isW=true; }
531 arizzi 1.3 if(cand->size() == 0)
532     {
533     // std::cout << "W event loss due to tigther cuts" << std::endl;
534     continue;
535     }
536     const VHbbCandidate & vhCand = cand->at(0);
537 arizzi 1.18 patFilters.setEvent(&ev,"VH");
538     hbhe = patFilters.accept("hbhe");
539    
540 arizzi 1.4 trigger.setEvent(&ev);
541     for(size_t j=0;j < triggers.size();j++)
542     triggerFlags[j]=trigger.accept(triggers[j]);
543 arizzi 1.3
544     eventFlav=0;
545     if(aux.mcBbar.size() > 0 || aux.mcB.size() > 0) eventFlav=5;
546     else if(aux.mcC.size() > 0) eventFlav=4;
547 arizzi 1.8
548 arizzi 1.3
549 arizzi 1.1 H.mass = vhCand.H.p4.M();
550     H.pt = vhCand.H.p4.Pt();
551     H.eta = vhCand.H.p4.Eta();
552     H.phi = vhCand.H.p4.Phi();
553     V.mass = vhCand.V.p4.M();
554     V.pt = vhCand.V.p4.Pt();
555     V.eta = vhCand.V.p4.Eta();
556     V.phi = vhCand.V.p4.Phi();
557     nhJets=2;
558     hJets.set(vhCand.H.jets[0],0);
559     hJets.set(vhCand.H.jets[1],1);
560     aJets.reset();
561     naJets=vhCand.additionalJets.size();
562 arizzi 1.6 numBJets=0;
563     if(vhCand.H.jets[0].csv> btagThr) numBJets++;
564     if(vhCand.H.jets[1].csv> btagThr) numBJets++;
565     for( int j=0; j < naJets && j < MAXJ; j++ )
566     {
567     aJets.set(vhCand.additionalJets[j],j);
568     if(vhCand.additionalJets[j].csv> btagThr) numBJets++;
569     }
570 arizzi 1.1 numJets = vhCand.additionalJets.size()+2;
571     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());
572     jjdPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
573 arizzi 1.6 jjdEta= TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
574 arizzi 1.19 HVdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ) ;
575 arizzi 1.20 HMETdPhi = fabs( deltaPhi(vhCand.H.p4.Phi(),vhCand.V.mets.at(0).p4.Phi()) ) ;
576 nmohr 1.14 VMt = vhCand.Mt() ;
577 arizzi 1.1 deltaPullAngle = vhCand.H.deltaTheta;
578 arizzi 1.16
579 arizzi 1.1
580 arizzi 1.3 hJets.cosTheta[0]= vhCand.H.helicities[0];
581     hJets.cosTheta[1]= vhCand.H.helicities[1];
582 arizzi 1.1
583     MET.et = vhCand.V.mets.at(0).p4.Pt();
584     MET.phi = vhCand.V.mets.at(0).p4.Phi();
585     MET.sumet = vhCand.V.mets.at(0).sumEt;
586     MET.sig = vhCand.V.mets.at(0).metSig;
587 arizzi 1.24
588    
589     if(!fromCandidate) {
590     MHT.mht = iEvent->mht.p4.Pt();
591     MHT.phi = iEvent->mht.p4.Phi();
592     MHT.ht = iEvent->mht.sumEt;
593     MHT.sig = iEvent->mht.metSig;
594    
595     }
596    
597    
598 arizzi 1.1 Vtype = vhCand.candidateType;
599 arizzi 1.24
600     //Loop on jets
601     double maxBtag=-99999;
602     minDeltaPhijetMET = 999;
603     TLorentzVector bJet;
604     std::vector<std::vector<BTagWeight::JetInfo> > btagJetInfos;
605     std::vector<float> jet30eta;
606     std::vector<float> jet30pt;
607     if(fromCandidate)
608     {
609     //Loop on Higgs Jets
610     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ){
611     if (vhCand.H.jets[j].csv > maxBtag) { bJet=vhCand.H.jets[j].p4 ; maxBtag =vhCand.H.jets[j].csv; }
612     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi()) < minDeltaPhijetMET)
613     {
614     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[j].p4.Phi());
615     jetPt_minDeltaPhijetMET=vhCand.H.jets[j].p4.Pt();
616     }
617     btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
618     }
619     //Loop on Additional Jets
620     for(unsigned int j=0; j < vhCand.additionalJets.size(); j++ ){
621     if (vhCand.additionalJets[j].csv > maxBtag) { bJet=vhCand.additionalJets[j].p4 ; maxBtag =vhCand.additionalJets[j].csv; }
622     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi()) < minDeltaPhijetMET)
623     {
624     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.additionalJets[j].p4.Phi());
625     jetPt_minDeltaPhijetMET=vhCand.additionalJets[j].p4.Pt();
626     }
627     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) ) // btag SF computed using only H-jets if best-H made with dijetPt rather than best CSV
628     {
629     if(vhCand.additionalJets[j].p4.Pt() > 20)
630     btagJetInfos.push_back(btagEff.jetInfo(vhCand.additionalJets[j]));
631     }
632     }
633     }
634     else
635     {
636     for(unsigned int j=0; j < iEvent->simpleJets2.size(); j++ ){
637     if (iEvent->simpleJets2[j].csv > maxBtag) { bJet=iEvent->simpleJets2[j].p4 ; maxBtag =iEvent->simpleJets2[j].csv; }
638     if (deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi()) < minDeltaPhijetMET)
639     {
640     minDeltaPhijetMET=deltaPhi( vhCand.V.mets.at(0).p4.Phi(), iEvent->simpleJets2[j].p4.Phi());
641     jetPt_minDeltaPhijetMET=iEvent->simpleJets2[j].p4.Pt();
642     }
643     if(iEvent->simpleJets2[j].p4.Pt() > 30)
644     {
645     jet30eta.push_back(iEvent->simpleJets2[j].p4.Eta());
646     jet30pt.push_back(iEvent->simpleJets2[j].p4.Pt());
647     }
648    
649     //For events made with highest CSV, all jets in the event should be taken into account for "tagging" SF (anti tagging is a mess)
650     // 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
651     if( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )
652     {
653     if(iEvent->simpleJets2[j].p4.Pt() > 20)
654     btagJetInfos.push_back(btagEff.jetInfo(iEvent->simpleJets2[j]));
655     }
656     }
657    
658     //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
659     // by a criteria (pt of the dijet) that is not btag SF dependent
660     if(!( ( isW && ! useHighestPtHiggsW ) || ( ! isW && ! useHighestPtHiggsZ ) )) {
661     for(unsigned int j=0; j < vhCand.H.jets.size(); j++ ) btagJetInfos.push_back(btagEff.jetInfo(vhCand.H.jets[j]));
662     }
663    
664     }
665 arizzi 1.9 vLeptons.reset();
666 arizzi 1.15 weightTrig = 1.; // better to default to 1
667 arizzi 1.8 TLorentzVector leptonForTop;
668 arizzi 1.9 size_t firstAddMu=0;
669     size_t firstAddEle=0;
670 arizzi 1.1 if(Vtype == VHbbCandidate::Zmumu ){
671 arizzi 1.13 vLeptons.set(vhCand.V.muons[0],0,13);
672     vLeptons.set(vhCand.V.muons[1],1,13);
673 arizzi 1.16 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleMuID(vLeptons.pt[1],vLeptons.eta[1]) ;
674     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
675     float weightTrig2 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[1],vLeptons.eta[1]);
676 arizzi 1.1 float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
677     weightTrig = cweightID * cweightTrig;
678 arizzi 1.9 nvlep=2;
679     firstAddMu=2;
680 arizzi 1.1 }
681     if( Vtype == VHbbCandidate::Zee ){
682 arizzi 1.9 vLeptons.set(vhCand.V.electrons[0],0,11);
683     vLeptons.set(vhCand.V.electrons[1],1,11);
684     nvlep=2;
685     firstAddEle=2;
686 arizzi 1.24 std::vector<float> pt,eta;
687     pt.push_back(vLeptons.pt[0]); eta.push_back(vLeptons.eta[0]);
688     pt.push_back(vLeptons.pt[1]); eta.push_back(vLeptons.eta[1]);
689     weightEleRecoAndId=triggerWeight.scaleID95Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]) *
690     triggerWeight.scaleID95Ele(vLeptons.pt[1],vLeptons.eta[1]) * triggerWeight.scaleRecoEle(vLeptons.pt[1],vLeptons.eta[1]);
691     weightEleTrigElePart = triggerWeight.scaleDoubleEle17Ele8(pt,eta);
692     weightTrig = weightEleTrigElePart * weightEleRecoAndId;
693    
694    
695    
696 arizzi 1.1 }
697     if(Vtype == VHbbCandidate::Wmun ){
698 arizzi 1.8 leptonForTop=vhCand.V.muons[0].p4;
699 arizzi 1.13 vLeptons.set(vhCand.V.muons[0],0,13);
700 arizzi 1.16 float cweightID = triggerWeight.scaleMuID(vLeptons.pt[0],vLeptons.eta[0]);
701     float weightTrig1 = triggerWeight.scaleMuIsoHLT(vLeptons.pt[0],vLeptons.eta[0]);
702 arizzi 1.1 float cweightTrig = weightTrig1;
703     weightTrig = cweightID * cweightTrig;
704 arizzi 1.9 nvlep=1;
705     firstAddMu=1;
706 arizzi 1.1 }
707     if( Vtype == VHbbCandidate::Wen ){
708 arizzi 1.8 leptonForTop=vhCand.V.electrons[0].p4;
709 arizzi 1.9 vLeptons.set(vhCand.V.electrons[0],0,11);
710     nvlep=1;
711     firstAddEle=1;
712 arizzi 1.24 float weightMay = triggerWeight.scaleSingleEleMay(vLeptons.pt[0],vLeptons.eta[0]);
713     float weightV4 = triggerWeight.scaleSingleEleV4(vLeptons.pt[0],vLeptons.eta[0]);
714     weightEleRecoAndId=triggerWeight.scaleID80Ele(vLeptons.pt[0],vLeptons.eta[0]) * triggerWeight.scaleRecoEle(vLeptons.pt[0],vLeptons.eta[0]);
715     weightEleTrigJetMETPart=triggerWeight.scaleJet30Jet25(jet30eta,jet30pt)*triggerWeight.scalePFMHTEle(MET.et);
716     weightEleTrigElePart= weightV4; //this is for debugging only, checking only the V4 part
717    
718     weightMay*=weightEleRecoAndId;
719     weightV4*=weightEleRecoAndId;
720     weightV4*=weightEleTrigJetMETPart;
721     weightTrig = weightMay * 0.187 + weightV4 * (1.-0.187); //FIXME: use proper lumi if we reload 2.fb
722 arizzi 1.1 }
723 arizzi 1.3 if( Vtype == VHbbCandidate::Znn ){
724 arizzi 1.9 nvlep=0;
725 arizzi 1.22 float weightTrig1 = triggerWeight.scaleMetHLT(vhCand.V.mets.at(0).p4.Pt());
726     weightTrig = weightTrig1;
727     weightTrigMET = weightTrig1;
728 arizzi 1.3 }
729 arizzi 1.9
730     aLeptons.reset();
731     nalep=0;
732 arizzi 1.21 if(fromCandidate)
733     {
734     for(size_t j=firstAddMu;j< vhCand.V.muons.size();j++) aLeptons.set(vhCand.V.muons[j],nalep++,13);
735     for(size_t j=firstAddEle;j< vhCand.V.electrons.size();j++) aLeptons.set(vhCand.V.electrons[j],nalep++,11);
736     }
737     else
738     {
739     for(size_t j=0;j< iEvent->muInfo.size();j++)
740     {
741     if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wmun ) && (Vtype != VHbbCandidate::Zmumu )) )
742     aLeptons.set(iEvent->muInfo[j],nalep++,13);
743     }
744     for(size_t j=0;j< iEvent->eleInfo.size();j++)
745     {
746     if((j!= vhCand.V.firstLepton && j!= vhCand.V.secondLepton) || ((Vtype != VHbbCandidate::Wen ) && (Vtype != VHbbCandidate::Zee )))
747     aLeptons.set(iEvent->eleInfo[j],nalep++,11);
748     }
749 arizzi 1.8
750 arizzi 1.21 }
751 arizzi 1.8
752 arizzi 1.24
753 arizzi 1.17 if(isMC_)
754     {
755     //std::cout << "BTAGSF " << btagJetInfos.size() << " " << btag.weight<BTag1Tight2CustomFilter>(btagJetInfos) << std::endl;
756 arizzi 1.24 if ( btagJetInfos.size()< 10)
757     {
758 arizzi 1.17 btag1T2CSF = btag.weight<BTag1Tight2CustomFilter>(btagJetInfos);
759 arizzi 1.23 btag2TSF = btag.weight<BTag2TightFilter>(btagJetInfos);
760 arizzi 1.24 btag1TSF = btag.weight<BTag1TightFilter>(btagJetInfos);
761     }
762     else
763     {
764     std::cout << "WARNING: combinatorics for " << btagJetInfos.size() << " jets is too high (>=10). use SF=1 " << std::endl;
765 arizzi 1.25 //TODO: revert to random throw for this cases
766 arizzi 1.24 btag1T2CSF = 1.;
767     btag2TSF = 1.;
768     btag1TSF = 1.;
769     }
770 arizzi 1.16 }
771 arizzi 1.17
772 arizzi 1.8 if(maxBtag > -99999)
773     {
774     TopHypo topQuark = TopMassReco::topMass(leptonForTop,bJet,vhCand.V.mets.at(0).p4);
775     top.mass = topQuark.p4.M();
776     top.pt = topQuark.p4.Pt();
777     top.wMass = topQuark.p4W.M();
778     } else {
779     top.mass = -99;
780     top.pt = -99;
781     top.wMass = -99;
782     }
783    
784    
785    
786 arizzi 1.1
787 arizzi 1.24 gendrcc=aux.genCCDeltaR();
788     gendrbb=aux.genBBDeltaR();
789     genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
790     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
791    
792 arizzi 1.25
793     /// Compute pull angle from AK7
794     if(!fromCandidate){
795     std::vector<VHbbEvent::SimpleJet> ak7 = iEvent->simpleJets3;
796 arizzi 1.24 if(ak7.size() > 1){
797     CompareDeltaR deltaRComparatorJ1(vhCand.H.jets[0].p4);
798     CompareDeltaR deltaRComparatorJ2(vhCand.H.jets[1].p4);
799     std::vector<VHbbEvent::SimpleJet> ak7_matched;
800    
801     std::sort( ak7.begin(),ak7.end(),deltaRComparatorJ1 );
802     ak7_matched.push_back(ak7[0]);
803    
804     if(ak7[1].p4.DeltaR(vhCand.H.jets[0].p4) > 0.5)
805     ak7.erase(ak7.begin());
806    
807     std::sort( ak7.begin(),ak7.end(),deltaRComparatorJ2 );
808 arizzi 1.25 if( abs(ak7[0].p4.Pt() - ak7_matched[1].p4.Pt()) > 0.1 )
809     ak7_matched.push_back(ak7[0]);
810     else
811     ak7_matched.push_back(ak7[1]);
812 arizzi 1.24
813     CompareJetPt ptComparator;
814     std::sort( ak7_matched.begin(),ak7_matched.end(),ptComparator );
815     if(ak7_matched[0].p4.DeltaR(vhCand.H.jets[0].p4) < 0.5
816     and ak7_matched[1].p4.DeltaR(vhCand.H.jets[1].p4) < 0.5 ){
817     deltaPullAngleAK7 = VHbbCandidateTools::getDeltaTheta(ak7_matched[0],ak7_matched[1]);
818     }
819     }
820     }
821 arizzi 1.3
822 arizzi 1.25
823 arizzi 1.1
824    
825 arizzi 1.17
826 arizzi 1.1 _outTree->Fill();
827 arizzi 1.4
828 arizzi 1.1 }// closed event loop
829    
830     std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
831     inFile->Close();
832     // close input file
833     } // loop on files
834    
835    
836     std::cout << "Events: " << ievt <<std::endl;
837     std::cout << "TotalCount: " << totalcount <<std::endl;
838    
839    
840    
841     _outFile->cd();
842    
843     _outTree->Write();
844     _outFile->Write();
845     _outFile->Close();
846     return 0;
847     }
848    
849