ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc
Revision: 1.2
Committed: Wed Sep 7 10:07:45 2011 UTC (13 years, 8 months ago) by arizzi
Content type: text/plain
Branch: MAIN
Changes since 1.1: +53 -3 lines
Log Message:
split branchs

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    
24     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h"
25     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEventAuxInfo.h"
26     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbCandidate.h"
27     #include "VHbbAnalysis/VHbbDataFormats/interface/TriggerReader.h"
28    
29     #include <sstream>
30     #include <string>
31    
32     #define MAXJ 30
33     #define MAXL 10
34    
35     float ScaleCSV(float CSV)
36     {
37     if(CSV < 0.68) return 1.0;
38     if(CSV < 0.9) return 0.96;
39     else return 0.94;
40     }
41    
42    
43     float ScaleIsoHLT(float pt1, float eta1)
44     {
45     //FIXME: get the files for HLT
46     return 1;
47     float ptMin,ptMax,etaMin,etaMax,scale,error;
48     float s1 = 0;
49    
50     TFile *scaleFile = new TFile ("IsoToHLT42.root","read");
51     TTree *tscale = (TTree*) scaleFile->Get("tree");
52     int count = 0;
53     tscale->SetBranchAddress("ptMin",&ptMin);
54     tscale->SetBranchAddress("ptMax",&ptMax);
55     tscale->SetBranchAddress("etaMin",&etaMin);
56     tscale->SetBranchAddress("etaMax",&etaMax);
57     tscale->SetBranchAddress("scale",&scale);
58     tscale->SetBranchAddress("error",&error);
59    
60     for(int jentry = 0; jentry < tscale->GetEntries(); jentry++)
61     {
62     tscale->GetEntry(jentry);
63     if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
64     {
65     s1 = scale;
66     count++;
67     }
68     }
69    
70     if(count == 0 || s1 == 0)
71     {
72     scaleFile->Close();
73     return 1;
74     }
75    
76    
77     scaleFile->Close();
78     return (s1);
79     }
80    
81    
82    
83     float ScaleID(float pt1, float eta1)
84     {
85     //FIXME: get the files for ID
86     return 1;
87    
88     float ptMin,ptMax,etaMin,etaMax,scale,error;
89     float s1 = 0;
90    
91     TFile *scaleFile = new TFile ("ScaleEffs42.root","read");
92     TTree *tscale = (TTree*) scaleFile->Get("tree");
93     int count = 0;
94     tscale->SetBranchAddress("ptMin",&ptMin);
95     tscale->SetBranchAddress("ptMax",&ptMax);
96     tscale->SetBranchAddress("etaMin",&etaMin);
97     tscale->SetBranchAddress("etaMax",&etaMax);
98     tscale->SetBranchAddress("scale",&scale);
99     tscale->SetBranchAddress("error",&error);
100    
101     for(int jentry = 0; jentry < tscale->GetEntries(); jentry++)
102     {
103    
104     tscale->GetEntry(jentry);
105     if((pt1 > ptMin) && (pt1 < ptMax) && (eta1 > etaMin) && (eta1 < etaMax))
106     {
107     s1 = scale;
108     count++;
109     }
110     }
111    
112     if(count == 0 || s1 == 0)
113     {
114     scaleFile->Close();
115     return 1;
116     }
117    
118     scaleFile->Close();
119     return (s1);
120    
121     }
122    
123    
124    
125     typedef struct
126     {
127     float mass; //MT in case of W
128     float pt;
129     float eta;
130     float phi;
131     } _TrackInfo;
132    
133    
134     struct _LeptonInfo
135     {
136     void reset()
137     {
138     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; }
139     }
140    
141     template <class Input> void set(const Input & i, int j,int t)
142     {
143     type[j]=t;
144     pt[j]=i.p4.Pt();
145     mass[j]=i.p4.M();
146     eta[j]=i.p4.Eta();
147     phi[j]=i.p4.Phi();
148     aodCombRelIso[j]=(i.hIso+i.eIso+i.tIso)/i.p4.Pt();
149     pfCombRelIso[j]=(i.pfChaIso+i.pfPhoIso+i.pfNeuIso)/i.p4.Pt();
150     photonIso[j]=i.pfPhoIso;
151     neutralHadIso[j]=i.pfNeuIso;
152     chargedHadIso[j]=i.pfChaIso;
153     //FIXME: whats this? particleIso;
154     }
155    
156     float mass[MAXL]; //MT in case of W
157     float pt[MAXL];
158     float eta[MAXL];
159     float phi[MAXL];
160     float aodCombRelIso[MAXL];
161     float pfCombRelIso[MAXL];
162     float photonIso[MAXL];
163     float neutralHadIso[MAXL];
164     float chargedHadIso[MAXL];
165     float particleIso[MAXL];
166     float dxy[MAXL];
167     float dz[MAXL];
168     int type[MAXL];
169     };
170    
171     typedef struct
172     {
173     float et;
174     float sumet;
175     float sig;
176     float phi;
177     } _METInfo;
178    
179     typedef struct
180     {
181     float mht;
182     float ht;
183     float sig;
184     float phi;
185     } _MHTInfo;
186    
187     struct
188     {
189     int run;
190     int lumi;
191     int event;
192     } _EventInfo;
193    
194    
195     typedef struct
196     {
197     void set(const VHbbEvent::SimpleJet & j, int i)
198     {
199     pt[i]=j.p4.Pt();
200     eta[i]=j.p4.Eta();
201     phi[i]=j.p4.Phi();
202     csv[i]=j.csv;
203     //FIXME: cosTheta=tVector;
204     //FIXME: numTracksSV
205     //FIXME: chf; float nhf; float cef; float nef; float nch; nconstituents;
206     flavour[i]=j.flavour;
207     //FIXME: genPt parton or genjet?
208     /* genPt=j.bestMCp4.Pt();
209     genEta=j.bestMCp4.Eta();
210     genPhi=j.bestMCp4.Phi();*/
211     //FIXME JECUnc
212     }
213     void reset()
214     {
215     for(int i=0;i<MAXJ;i++) {
216     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;
217     }
218     }
219     float pt[MAXJ];
220     float eta[MAXJ];
221     float phi[MAXJ];
222     float csv[MAXJ];
223     float cosTheta[MAXJ];
224     int numTracksSV[MAXJ];
225     float chf[MAXJ];
226     float nhf[MAXJ];
227     float cef[MAXJ];
228     float nef[MAXJ];
229     float nch[MAXJ];
230     float nconstituents[MAXJ];
231     float flavour[MAXJ];
232     float genPt[MAXJ];
233     float genEta[MAXJ];
234     float genPhi[MAXJ];
235     float JECUnc[MAXJ];
236    
237     } _JetInfo;
238    
239     int main(int argc, char* argv[])
240     {
241     gROOT->Reset();
242    
243     TTree *_outTree;
244     _METInfo MET;
245     _MHTInfo MHT;
246     // _JetInfo jet1,jet2, addJet1, addJet2;
247     _JetInfo hJets, aJets;
248     int naJets=0, nhJets=0;
249     _TrackInfo H;
250     _TrackInfo V;
251     _LeptonInfo leptons; // lepton1,lepton2;
252     int nlep=0;
253    
254     float jjdr,jjdPhi,HVdPhi,VMt,deltaPullAngle,deltaPullAngleAK7,gendrcc,gendrbb, genZpt, genWpt, weightTrig,addJet3Pt, minDeltaPhijetMET, jetPt_minDeltaPhijetMET , PUweight;
255     int nofLeptons15,nofLeptons20, Vtype,numJets,numBJets;
256     // bool isMET80_CJ80, ispfMHT150, isMET80_2CJ20,isMET65_2CJ20, isJETID,isIsoMu17;
257     bool triggerFlags[500];
258     // ----------------------------------------------------------------------
259     // First Part:
260     //
261     // * enable the AutoLibraryLoader
262     // * book the histograms of interest
263     // * open the input file
264     // ----------------------------------------------------------------------
265    
266     // load framework libraries
267     gSystem->Load( "libFWCoreFWLite" );
268     gSystem->Load("libDataFormatsFWLite");
269     AutoLibraryLoader::enable();
270    
271     // parse arguments
272     if ( argc < 2 ) {
273     return 0;
274     }
275    
276     // get the python configuration
277     PythonProcessDesc builder(argv[1]);
278     const edm::ParameterSet& in = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteInput" );
279     const edm::ParameterSet& out = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("fwliteOutput");
280     const edm::ParameterSet& ana = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("Analyzer");
281    
282     // now get each parameter
283     int maxEvents_( in.getParameter<int>("maxEvents") );
284     unsigned int outputEvery_( in.getParameter<unsigned int>("outputEvery") );
285     std::string outputFile_( out.getParameter<std::string>("fileName" ) );
286    
287    
288     std::vector<std::string> triggers( ana.getParameter<std::vector<std::string> >("triggers") );
289    
290     std::vector<std::string> inputFiles_( in.getParameter<std::vector<std::string> >("fileNames") );
291     // std::string inputFile( in.getParameter<std::string> ("fileName") );
292    
293    
294     std::string PUmcfileName_;//FIXME ( in.getParameter<std::string> ("PUmcfileName") );
295     std::string PUdatafileName_;//FIXME ( in.getParameter<std::string> ("PUdatafileName") );
296     bool isMC_( ana.getParameter<bool>("isMC") );
297     TriggerReader trigger(isMC_);
298    
299     TFile *_outFile = new TFile(outputFile_.c_str(), "recreate");
300     _outTree = new TTree("tree", "myTree");
301    
302     _outTree->Branch("H" , &H , "mass/F:pt/F:eta:phi/F");
303     _outTree->Branch("V" , &V , "mass/F:pt/F:eta:phi/F");
304     _outTree->Branch("nhJets" , &nhJets , "nhJets/I");
305     _outTree->Branch("naJets" , &naJets , "naJets/I");
306 arizzi 1.2 // _outTree->Branch("hJet_" , &hJets , "pt[nhJets]/F:eta[nhJets]/F:phi[nhJets]/F:csv[nhJets]/F:cosTheta[nhJets]/F:numTracksSV[nhJets]/I:chf[nhJets]/F:nhf[nhJets]:cef[nhJets]:nef[nhJets]:nch[nhJets]:nconstituents[nhJets]:flavour[nhJets]:genPt[nhJets]:genEta[nhJets]:genPhi[nhJets]:JECUnc[nhJets]/F");
307     // _outTree->Branch("aJet_" , &aJets , "pt[naJets]/F:eta[naJets]/F:phi[naJets]/F:csv[naJets]/F:cosTheta[naJets]/F:numTracksSV[naJets]/I:chf[naJets]/F:nhf[naJets]:cef[naJets]:nef[naJets]:nch[naJets]:nconstituents[naJets]:flavour[naJets]:genPt[naJets]:genEta[naJets]:genPhi[naJets]:JECUnc[naJets]/F");
308    
309     _outTree->Branch("hJet_pt",hJets.pt ,"pt[nhJets]/F");
310     _outTree->Branch("hJet_eta",hJets.eta ,"eta[nhJets]/F");
311     _outTree->Branch("hJet_phi",hJets.phi ,"phi[nhJets]/F");
312     _outTree->Branch("hJet_csv",hJets.csv ,"csv[nhJets]/F");
313     _outTree->Branch("hJet_cosTheta",hJets.cosTheta ,"cosTheta[nhJets]/F");
314     _outTree->Branch("hJet_numTracksSV",hJets.numTracksSV ,"numTracksSV[nhJets]/I");
315     _outTree->Branch("hJet_chf",hJets.chf ,"chf[nhJets]/F");
316     _outTree->Branch("hJet_nhf",hJets.nhf ,"nhf[nhJets]/F");
317     _outTree->Branch("hJet_cef",hJets.cef ,"cef[nhJets]/F");
318     _outTree->Branch("hJet_nef",hJets.nef ,"nef[nhJets]/F");
319     _outTree->Branch("hJet_nch",hJets.nch ,"nch[nhJets]/F");
320     _outTree->Branch("hJet_nconstituents",hJets.nconstituents ,"nconstituents[nhJets]");
321     _outTree->Branch("hJet_flavour",hJets.flavour ,"flavour[nhJets]/F");
322     _outTree->Branch("hJet_genPt",hJets.genPt ,"genPt[nhJets]/F");
323     _outTree->Branch("hJet_genEta",hJets.genEta ,"genEta[nhJets]/F");
324     _outTree->Branch("hJet_genPhi",hJets.genPhi ,"genPhi[nhJets]/F");
325     _outTree->Branch("hJet_JECUnc",hJets.JECUnc ,"JECUnc[nhJets]/F");
326    
327     _outTree->Branch("aJet_pt",aJets.pt ,"pt[naJets]/F");
328     _outTree->Branch("aJet_eta",aJets.eta ,"eta[naJets]/F");
329     _outTree->Branch("aJet_phi",aJets.phi ,"phi[naJets]/F");
330     _outTree->Branch("aJet_csv",aJets.csv ,"csv[naJets]/F");
331     _outTree->Branch("aJet_cosTheta",aJets.cosTheta ,"cosTheta[naJets]/F");
332     _outTree->Branch("aJet_numTracksSV",aJets.numTracksSV ,"numTracksSV[naJets]/I");
333     _outTree->Branch("aJet_chf",aJets.chf ,"chf[naJets]/F");
334     _outTree->Branch("aJet_nhf",aJets.nhf ,"nhf[naJets]/F");
335     _outTree->Branch("aJet_cef",aJets.cef ,"cef[naJets]/F");
336     _outTree->Branch("aJet_nef",aJets.nef ,"nef[naJets]/F");
337     _outTree->Branch("aJet_nch",aJets.nch ,"nch[naJets]/F");
338     _outTree->Branch("aJet_nconstituents",aJets.nconstituents ,"nconstituents[naJets]");
339     _outTree->Branch("aJet_flavour",aJets.flavour ,"flavour[naJets]/F");
340     _outTree->Branch("aJet_genPt",aJets.genPt ,"genPt[naJets]/F");
341     _outTree->Branch("aJet_genEta",aJets.genEta ,"genEta[naJets]/F");
342     _outTree->Branch("aJet_genPhi",aJets.genPhi ,"genPhi[naJets]/F");
343     _outTree->Branch("aJet_JECUnc",aJets.JECUnc ,"JECUnc[naJets]/F");
344    
345 arizzi 1.1
346     _outTree->Branch("addJet3Pt", &addJet3Pt , "addJet3Pt/F");
347     _outTree->Branch("jjdr" , &jjdr , "jjdr/F" );
348     _outTree->Branch("jjdPhi" , &jjdPhi , "jjdPhi/F" );
349     _outTree->Branch("numJets" , &numJets , "numJets/I" );
350     _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
351     _outTree->Branch("nofLeptons15" , &nofLeptons15 , "nofLeptons15/I" );
352     _outTree->Branch("nofLeptons20" , &nofLeptons20 , "nofLeptons20/I" );
353     _outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
354     _outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
355     _outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
356     _outTree->Branch("genZpt" , &genZpt , "genZpt/F");
357     _outTree->Branch("genWpt" , &genWpt , "genWpt/F");
358     _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
359     _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
360     _outTree->Branch("PUweight", &PUweight , "PUweight/F");
361    
362    
363    
364    
365     _outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
366     _outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
367     _outTree->Branch("VMt" , &VMt , "VMt/F" );
368    
369     _outTree->Branch("nlep" , &nlep , "nlep/I");
370 arizzi 1.2 //_outTree->Branch("leptons" , &leptons , "mass[nlep]/F:pt[nlep]/F:eta[nlep]:phi[nlep]/F:aodCombRelIso[nlep]/F:pfCombRelIso[nlep]/F:photonIso[nlep]/F:neutralHadIso[nlep]/F:chargedHadIso[nlep]/F:particleIso[nlep]/F:dxy[nlep]/F:dz[nlep]/F:type[nlep]/I");
371     _outTree->Branch("lepton_mass",leptons.mass ,"mass[nlep]/F");
372     _outTree->Branch("lepton_pt",leptons.pt ,"pt[nlep]/F");
373     _outTree->Branch("lepton_eta",leptons.eta ,"eta[nlep]");
374     _outTree->Branch("lepton_phi",leptons.phi ,"phi[nlep]/F");
375     _outTree->Branch("lepton_aodCombRelIso",leptons.aodCombRelIso ,"aodCombRelIso[nlep]/F");
376     _outTree->Branch("lepton_pfCombRelIso",leptons.pfCombRelIso ,"pfCombRelIso[nlep]/F");
377     _outTree->Branch("lepton_photonIso",leptons.photonIso ,"photonIso[nlep]/F");
378     _outTree->Branch("lepton_neutralHadIso",leptons.neutralHadIso ,"neutralHadIso[nlep]/F");
379     _outTree->Branch("lepton_chargedHadIso",leptons.chargedHadIso ,"chargedHadIso[nlep]/F");
380     _outTree->Branch("lepton_particleIso",leptons.particleIso ,"particleIso[nlep]/F");
381     _outTree->Branch("lepton_dxy",leptons.dxy ,"dxy[nlep]/F");
382     _outTree->Branch("lepton_dz",leptons.dz ,"dz[nlep]/F");
383     _outTree->Branch("lepton_type",leptons.type ,"type[nlep]/I");
384 arizzi 1.1
385     //_outTree->Branch("lepton1" , &lepton1 , "mass/F:pt/F:eta:phi/F:aodCombRelIso/F:pfCombRelIso/F:photonIso/F:neutralHadIso/F:chargedHadIso/F:particleIso/F:dxy/F:dz/F:type/I");
386     //_outTree->Branch("lepton2" , &lepton2 , "mass/F:pt/F:eta:phi/F:aodCombRelIso/F:pfCombRelIso/F:photonIso/F:neutralHadIso/F:chargedHadIso/F:particleIso/F:dxy/F:dz/F:type/I");
387    
388     //FIXME: add something about ELE id
389     _outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
390     _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
391     _outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
392     _outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
393    
394    
395    
396     /*for(size_t j=0;j<triggers.size();j++)
397     {
398     _outTree->Branch(triggers[j].c_str(), &triggerFlags+j, (triggers[j]+"/b".c_str()));
399     }
400     */
401     std::stringstream s;
402     s << "triggerFlags[" << triggers.size() << "]/b";
403     _outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
404    
405    
406     /* FIXME: - trigger bits
407     FIXME - top event reco
408     FIXME - electrons id ?
409     FIXME - add B/C/Light classification
410     */
411    
412     int ievt=0;
413     int totalcount=0;
414    
415     // TFile* inFile = new TFile(inputFile.c_str(), "read");
416     for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
417     std::cout << iFile << std::endl;
418     TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
419     if(inFile==0) continue;
420    
421     // loop the events
422    
423     // ----------------------------------------------------------------------
424     // Second Part:
425     //
426     // * loop the events in the input file
427     // * receive the collections of interest via fwlite::Handle
428     // * fill the histograms
429     // * after the loop close the input file
430     // ----------------------------------------------------------------------
431     fwlite::Event ev(inFile);
432     for(ev.toBegin(); !ev.atEnd(); ++ev, ++ievt)
433     {
434    
435     if(isMC_){
436     // PU weights
437     edm::LumiReWeighting LumiWeights_ = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
438     double avg=0;
439     //FIXME
440     // if( PUintimeSizes.isValid() && PUouttime1minusSizes.isValid() && PUouttime1plusSizes.isValid()){
441     // avg = (double)( *PUintimeSizes );
442     // }
443     PUweight = 1.0; // FIXME: LumiWeights_.weight3BX( avg /3.);
444     }
445    
446    
447     fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
448     vhbbCandHandle.getByLabel(ev,"hbbBestCSVPt20Candidates");
449     const std::vector<VHbbCandidate> & cand = *vhbbCandHandle.product();
450    
451    
452     fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
453     vhbbAuxHandle.getByLabel(ev,"HbbAnalyzerNew");
454     const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
455    
456     /* fwlite::Handle< VHbbEvent > vhbbHandle;
457     vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
458     const VHbbEvent iEvent = *vhbbHandle.product();
459     */
460     trigger.setEvent(&ev);
461     for(size_t j=0;j < triggers.size();j++)
462     triggerFlags[j]=trigger.accept(triggers[j]);
463    
464     // std::clog << "Filling tree "<< std::endl;
465    
466     if(cand.size() == 0 or cand.at(0).H.jets.size() < 2) continue;
467     const VHbbCandidate & vhCand = cand.at(0);
468     H.mass = vhCand.H.p4.M();
469     H.pt = vhCand.H.p4.Pt();
470     H.eta = vhCand.H.p4.Eta();
471     H.phi = vhCand.H.p4.Phi();
472     V.mass = vhCand.V.p4.M();
473     V.pt = vhCand.V.p4.Pt();
474     V.eta = vhCand.V.p4.Eta();
475     V.phi = vhCand.V.p4.Phi();
476     nhJets=2;
477     hJets.set(vhCand.H.jets[0],0);
478     hJets.set(vhCand.H.jets[1],1);
479     aJets.reset();
480     naJets=vhCand.additionalJets.size();
481     for( int j=0; j < naJets && j < MAXJ; j++ ) aJets.set(vhCand.additionalJets[j],j);
482     numJets = vhCand.additionalJets.size()+2;
483     //FIXME: _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
484     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());
485     jjdPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
486     HVdPhi = deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ;
487     deltaPullAngle = vhCand.H.deltaTheta;
488     float deltaPhipfMETjet1 = deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[0].p4.Phi() );
489     float deltaPhipfMETjet2 = deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[1].p4.Phi() );
490     if(deltaPhipfMETjet1 <= deltaPhipfMETjet2)
491     {
492     minDeltaPhijetMET=deltaPhipfMETjet1;
493     jetPt_minDeltaPhijetMET=vhCand.H.jets[0].p4.Pt();
494     }
495     else
496     {
497     minDeltaPhijetMET=deltaPhipfMETjet2;
498     jetPt_minDeltaPhijetMET=vhCand.H.jets[1].p4.Pt();
499     }
500    
501     //FIXME: should we add? DeltaEtabb = TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
502     //FIXME: should we add? helicity = vhCand.H.helicities[0];
503    
504     MET.et = vhCand.V.mets.at(0).p4.Pt();
505     MET.phi = vhCand.V.mets.at(0).p4.Phi();
506     MET.sumet = vhCand.V.mets.at(0).sumEt;
507     MET.sig = vhCand.V.mets.at(0).metSig;
508     //FIXME add MHT _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
509     Vtype = vhCand.candidateType;
510     leptons.reset();
511    
512     if(Vtype == VHbbCandidate::Zmumu ){
513     leptons.set(vhCand.V.muons[0],0,12); //FIXME set the type
514     leptons.set(vhCand.V.muons[1],1,12);
515     float cweightID = ScaleID(leptons.pt[0],leptons.eta[0]) * ScaleID(leptons.pt[1],leptons.eta[1]) ;
516     float weightTrig1 = ScaleIsoHLT(leptons.pt[0],leptons.eta[0]);
517     float weightTrig2 = ScaleIsoHLT(leptons.pt[1],leptons.eta[1]);
518     float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
519     weightTrig = cweightID * cweightTrig;
520     nlep=2;
521     }
522     if( Vtype == VHbbCandidate::Zee ){
523     leptons.set(vhCand.V.electrons[0],0,11);
524     leptons.set(vhCand.V.electrons[1],1,11);
525     nlep=2;
526     }
527     if(Vtype == VHbbCandidate::Wmun ){
528     leptons.set(vhCand.V.muons[0],0,12); //FIXME set the type
529     float cweightID = ScaleID(leptons.pt[0],leptons.eta[0]);
530     float weightTrig1 = ScaleIsoHLT(leptons.pt[0],leptons.eta[0]);
531     float cweightTrig = weightTrig1;
532     weightTrig = cweightID * cweightTrig;
533     nlep=1;
534     }
535     if( Vtype == VHbbCandidate::Wen ){
536     leptons.set(vhCand.V.electrons[0],0,11);
537     nlep=1;
538     }
539     //FIXME _outTree->Branch("nofLeptons15" , &nofLeptons15 , "nofLeptons15/I" );
540     nofLeptons20= vhCand.additionalLeptons();
541     // if(aux.mcC.size() >=2)
542     // std::cout << "C Must not be zero and it is ... " << aux.mcC[1].p4.Pt() << std::endl;
543     // if(aux.mcB.size() >=1)
544     // std::cout << "B Must not be zero and it is ... " << aux.mcB[0].p4.Pt() << std::endl;
545    
546     // FIXME gendrcc=aux.genCCDeltaR();
547     // FIXME gendrbb=aux.genBBDeltaR();
548     genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
549     genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
550     //FIXME: _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
551     //FIXME: _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
552    
553    
554    
555     _outTree->Fill();
556     }// closed event loop
557    
558     std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
559     inFile->Close();
560     // close input file
561     } // loop on files
562    
563    
564     std::cout << "Events: " << ievt <<std::endl;
565     std::cout << "TotalCount: " << totalcount <<std::endl;
566    
567    
568    
569     _outFile->cd();
570    
571     _outTree->Write();
572     _outFile->Write();
573     _outFile->Close();
574     return 0;
575     }
576    
577