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