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 |
|
|
_outTree->Branch("hJets" , &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("aJets" , &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("addJet3Pt", &addJet3Pt , "addJet3Pt/F");
|
310 |
|
|
_outTree->Branch("jjdr" , &jjdr , "jjdr/F" );
|
311 |
|
|
_outTree->Branch("jjdPhi" , &jjdPhi , "jjdPhi/F" );
|
312 |
|
|
_outTree->Branch("numJets" , &numJets , "numJets/I" );
|
313 |
|
|
_outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
|
314 |
|
|
_outTree->Branch("nofLeptons15" , &nofLeptons15 , "nofLeptons15/I" );
|
315 |
|
|
_outTree->Branch("nofLeptons20" , &nofLeptons20 , "nofLeptons20/I" );
|
316 |
|
|
_outTree->Branch("deltaPullAngle", &deltaPullAngle , "deltaPullAngle/F");
|
317 |
|
|
_outTree->Branch("gendrcc" , &gendrcc , "gendrcc/F");
|
318 |
|
|
_outTree->Branch("gendrbb" , &gendrbb , "gendrbb/F");
|
319 |
|
|
_outTree->Branch("genZpt" , &genZpt , "genZpt/F");
|
320 |
|
|
_outTree->Branch("genWpt" , &genWpt , "genWpt/F");
|
321 |
|
|
_outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
|
322 |
|
|
_outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
|
323 |
|
|
_outTree->Branch("PUweight", &PUweight , "PUweight/F");
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
_outTree->Branch("Vtype" , &Vtype , "Vtype/I" );
|
329 |
|
|
_outTree->Branch("HVdPhi" , &HVdPhi , "HVdPhi/F" );
|
330 |
|
|
_outTree->Branch("VMt" , &VMt , "VMt/F" );
|
331 |
|
|
|
332 |
|
|
_outTree->Branch("nlep" , &nlep , "nlep/I");
|
333 |
|
|
_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");
|
334 |
|
|
|
335 |
|
|
//_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");
|
336 |
|
|
//_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");
|
337 |
|
|
|
338 |
|
|
//FIXME: add something about ELE id
|
339 |
|
|
_outTree->Branch("MET" , &MET , "et/F:sumet:sig/F:phi/F");
|
340 |
|
|
_outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
|
341 |
|
|
_outTree->Branch("minDeltaPhijetMET" , &minDeltaPhijetMET , "minDeltaPhijetMET/F");
|
342 |
|
|
_outTree->Branch("jetPt_minDeltaPhijetMET" , &jetPt_minDeltaPhijetMET , "jetPt_minDeltaPhijetMET/F");
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
/*for(size_t j=0;j<triggers.size();j++)
|
347 |
|
|
{
|
348 |
|
|
_outTree->Branch(triggers[j].c_str(), &triggerFlags+j, (triggers[j]+"/b".c_str()));
|
349 |
|
|
}
|
350 |
|
|
*/
|
351 |
|
|
std::stringstream s;
|
352 |
|
|
s << "triggerFlags[" << triggers.size() << "]/b";
|
353 |
|
|
_outTree->Branch("triggerFlags", triggerFlags, s.str().c_str());
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
/* FIXME: - trigger bits
|
357 |
|
|
FIXME - top event reco
|
358 |
|
|
FIXME - electrons id ?
|
359 |
|
|
FIXME - add B/C/Light classification
|
360 |
|
|
*/
|
361 |
|
|
|
362 |
|
|
int ievt=0;
|
363 |
|
|
int totalcount=0;
|
364 |
|
|
|
365 |
|
|
// TFile* inFile = new TFile(inputFile.c_str(), "read");
|
366 |
|
|
for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile) {
|
367 |
|
|
std::cout << iFile << std::endl;
|
368 |
|
|
TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
|
369 |
|
|
if(inFile==0) continue;
|
370 |
|
|
|
371 |
|
|
// loop the events
|
372 |
|
|
|
373 |
|
|
// ----------------------------------------------------------------------
|
374 |
|
|
// Second Part:
|
375 |
|
|
//
|
376 |
|
|
// * loop the events in the input file
|
377 |
|
|
// * receive the collections of interest via fwlite::Handle
|
378 |
|
|
// * fill the histograms
|
379 |
|
|
// * after the loop close the input file
|
380 |
|
|
// ----------------------------------------------------------------------
|
381 |
|
|
fwlite::Event ev(inFile);
|
382 |
|
|
for(ev.toBegin(); !ev.atEnd(); ++ev, ++ievt)
|
383 |
|
|
{
|
384 |
|
|
|
385 |
|
|
if(isMC_){
|
386 |
|
|
// PU weights
|
387 |
|
|
edm::LumiReWeighting LumiWeights_ = edm::LumiReWeighting(PUmcfileName_,PUdatafileName_ , "pileup", "pileup");
|
388 |
|
|
double avg=0;
|
389 |
|
|
//FIXME
|
390 |
|
|
// if( PUintimeSizes.isValid() && PUouttime1minusSizes.isValid() && PUouttime1plusSizes.isValid()){
|
391 |
|
|
// avg = (double)( *PUintimeSizes );
|
392 |
|
|
// }
|
393 |
|
|
PUweight = 1.0; // FIXME: LumiWeights_.weight3BX( avg /3.);
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
fwlite::Handle< std::vector<VHbbCandidate> > vhbbCandHandle;
|
398 |
|
|
vhbbCandHandle.getByLabel(ev,"hbbBestCSVPt20Candidates");
|
399 |
|
|
const std::vector<VHbbCandidate> & cand = *vhbbCandHandle.product();
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
fwlite::Handle< VHbbEventAuxInfo > vhbbAuxHandle;
|
403 |
|
|
vhbbAuxHandle.getByLabel(ev,"HbbAnalyzerNew");
|
404 |
|
|
const VHbbEventAuxInfo & aux = *vhbbAuxHandle.product();
|
405 |
|
|
|
406 |
|
|
/* fwlite::Handle< VHbbEvent > vhbbHandle;
|
407 |
|
|
vhbbHandle.getByLabel(ev,"HbbAnalyzerNew");
|
408 |
|
|
const VHbbEvent iEvent = *vhbbHandle.product();
|
409 |
|
|
*/
|
410 |
|
|
trigger.setEvent(&ev);
|
411 |
|
|
for(size_t j=0;j < triggers.size();j++)
|
412 |
|
|
triggerFlags[j]=trigger.accept(triggers[j]);
|
413 |
|
|
|
414 |
|
|
// std::clog << "Filling tree "<< std::endl;
|
415 |
|
|
|
416 |
|
|
if(cand.size() == 0 or cand.at(0).H.jets.size() < 2) continue;
|
417 |
|
|
const VHbbCandidate & vhCand = cand.at(0);
|
418 |
|
|
H.mass = vhCand.H.p4.M();
|
419 |
|
|
H.pt = vhCand.H.p4.Pt();
|
420 |
|
|
H.eta = vhCand.H.p4.Eta();
|
421 |
|
|
H.phi = vhCand.H.p4.Phi();
|
422 |
|
|
V.mass = vhCand.V.p4.M();
|
423 |
|
|
V.pt = vhCand.V.p4.Pt();
|
424 |
|
|
V.eta = vhCand.V.p4.Eta();
|
425 |
|
|
V.phi = vhCand.V.p4.Phi();
|
426 |
|
|
nhJets=2;
|
427 |
|
|
hJets.set(vhCand.H.jets[0],0);
|
428 |
|
|
hJets.set(vhCand.H.jets[1],1);
|
429 |
|
|
aJets.reset();
|
430 |
|
|
naJets=vhCand.additionalJets.size();
|
431 |
|
|
for( int j=0; j < naJets && j < MAXJ; j++ ) aJets.set(vhCand.additionalJets[j],j);
|
432 |
|
|
numJets = vhCand.additionalJets.size()+2;
|
433 |
|
|
//FIXME: _outTree->Branch("numBJets" , &numBJets , "numBJets/I" );
|
434 |
|
|
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());
|
435 |
|
|
jjdPhi = deltaPhi(vhCand.H.jets[0].p4.Phi(),vhCand.H.jets[1].p4.Phi());
|
436 |
|
|
HVdPhi = deltaPhi(vhCand.H.p4.Phi(),vhCand.V.p4.Phi()) ;
|
437 |
|
|
deltaPullAngle = vhCand.H.deltaTheta;
|
438 |
|
|
float deltaPhipfMETjet1 = deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[0].p4.Phi() );
|
439 |
|
|
float deltaPhipfMETjet2 = deltaPhi( vhCand.V.mets.at(0).p4.Phi(), vhCand.H.jets[1].p4.Phi() );
|
440 |
|
|
if(deltaPhipfMETjet1 <= deltaPhipfMETjet2)
|
441 |
|
|
{
|
442 |
|
|
minDeltaPhijetMET=deltaPhipfMETjet1;
|
443 |
|
|
jetPt_minDeltaPhijetMET=vhCand.H.jets[0].p4.Pt();
|
444 |
|
|
}
|
445 |
|
|
else
|
446 |
|
|
{
|
447 |
|
|
minDeltaPhijetMET=deltaPhipfMETjet2;
|
448 |
|
|
jetPt_minDeltaPhijetMET=vhCand.H.jets[1].p4.Pt();
|
449 |
|
|
}
|
450 |
|
|
|
451 |
|
|
//FIXME: should we add? DeltaEtabb = TMath::Abs( vhCand.H.jets[0].p4.Eta() - vhCand.H.jets[1].p4.Eta() );
|
452 |
|
|
//FIXME: should we add? helicity = vhCand.H.helicities[0];
|
453 |
|
|
|
454 |
|
|
MET.et = vhCand.V.mets.at(0).p4.Pt();
|
455 |
|
|
MET.phi = vhCand.V.mets.at(0).p4.Phi();
|
456 |
|
|
MET.sumet = vhCand.V.mets.at(0).sumEt;
|
457 |
|
|
MET.sig = vhCand.V.mets.at(0).metSig;
|
458 |
|
|
//FIXME add MHT _outTree->Branch("MHT" , &MHT , "mht/F:ht:sig/F:phi/F");
|
459 |
|
|
Vtype = vhCand.candidateType;
|
460 |
|
|
leptons.reset();
|
461 |
|
|
|
462 |
|
|
if(Vtype == VHbbCandidate::Zmumu ){
|
463 |
|
|
leptons.set(vhCand.V.muons[0],0,12); //FIXME set the type
|
464 |
|
|
leptons.set(vhCand.V.muons[1],1,12);
|
465 |
|
|
float cweightID = ScaleID(leptons.pt[0],leptons.eta[0]) * ScaleID(leptons.pt[1],leptons.eta[1]) ;
|
466 |
|
|
float weightTrig1 = ScaleIsoHLT(leptons.pt[0],leptons.eta[0]);
|
467 |
|
|
float weightTrig2 = ScaleIsoHLT(leptons.pt[1],leptons.eta[1]);
|
468 |
|
|
float cweightTrig = weightTrig1 + weightTrig2 - weightTrig1*weightTrig2;
|
469 |
|
|
weightTrig = cweightID * cweightTrig;
|
470 |
|
|
nlep=2;
|
471 |
|
|
}
|
472 |
|
|
if( Vtype == VHbbCandidate::Zee ){
|
473 |
|
|
leptons.set(vhCand.V.electrons[0],0,11);
|
474 |
|
|
leptons.set(vhCand.V.electrons[1],1,11);
|
475 |
|
|
nlep=2;
|
476 |
|
|
}
|
477 |
|
|
if(Vtype == VHbbCandidate::Wmun ){
|
478 |
|
|
leptons.set(vhCand.V.muons[0],0,12); //FIXME set the type
|
479 |
|
|
float cweightID = ScaleID(leptons.pt[0],leptons.eta[0]);
|
480 |
|
|
float weightTrig1 = ScaleIsoHLT(leptons.pt[0],leptons.eta[0]);
|
481 |
|
|
float cweightTrig = weightTrig1;
|
482 |
|
|
weightTrig = cweightID * cweightTrig;
|
483 |
|
|
nlep=1;
|
484 |
|
|
}
|
485 |
|
|
if( Vtype == VHbbCandidate::Wen ){
|
486 |
|
|
leptons.set(vhCand.V.electrons[0],0,11);
|
487 |
|
|
nlep=1;
|
488 |
|
|
}
|
489 |
|
|
//FIXME _outTree->Branch("nofLeptons15" , &nofLeptons15 , "nofLeptons15/I" );
|
490 |
|
|
nofLeptons20= vhCand.additionalLeptons();
|
491 |
|
|
// if(aux.mcC.size() >=2)
|
492 |
|
|
// std::cout << "C Must not be zero and it is ... " << aux.mcC[1].p4.Pt() << std::endl;
|
493 |
|
|
// if(aux.mcB.size() >=1)
|
494 |
|
|
// std::cout << "B Must not be zero and it is ... " << aux.mcB[0].p4.Pt() << std::endl;
|
495 |
|
|
|
496 |
|
|
// FIXME gendrcc=aux.genCCDeltaR();
|
497 |
|
|
// FIXME gendrbb=aux.genBBDeltaR();
|
498 |
|
|
genZpt=aux.mcZ.size() > 0 ? aux.mcZ[0].p4.Pt():-99;
|
499 |
|
|
genWpt=aux.mcW.size() > 0 ? aux.mcW[0].p4.Pt():-99;
|
500 |
|
|
//FIXME: _outTree->Branch("weightTrig" , &weightTrig , "weightTrig/F");
|
501 |
|
|
//FIXME: _outTree->Branch("deltaPullAngleAK7", &deltaPullAngleAK7 , "deltaPullAngleAK7/F");
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
_outTree->Fill();
|
506 |
|
|
}// closed event loop
|
507 |
|
|
|
508 |
|
|
std::cout << "closing the file: " << inputFiles_[iFile] << std::endl;
|
509 |
|
|
inFile->Close();
|
510 |
|
|
// close input file
|
511 |
|
|
} // loop on files
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
std::cout << "Events: " << ievt <<std::endl;
|
515 |
|
|
std::cout << "TotalCount: " << totalcount <<std::endl;
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
_outFile->cd();
|
520 |
|
|
|
521 |
|
|
_outTree->Write();
|
522 |
|
|
_outFile->Write();
|
523 |
|
|
_outFile->Close();
|
524 |
|
|
return 0;
|
525 |
|
|
}
|
526 |
|
|
|
527 |
|
|
|