1 |
/////////////////////////////////////////////////////
|
2 |
// //
|
3 |
// Original Author: Salim Cerci //
|
4 |
// Created: Sep 10 18:50:23 CET 2007 //
|
5 |
// //
|
6 |
// //
|
7 |
/////////////////////////////////////////////////////
|
8 |
|
9 |
#include <iostream>
|
10 |
#include "Analysis/ForwardJet/interface/ForwardJet.h"
|
11 |
#include "DataFormats/Common/interface/Ref.h"
|
12 |
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
|
13 |
#include "DataFormats/Common/interface/Ref.h"
|
14 |
#include "DataFormats/JetReco/interface/Jet.h"
|
15 |
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
|
16 |
#include "DataFormats/JetReco/interface/BasicJetCollection.h"
|
17 |
#include "DataFormats/JetReco/interface/GenJet.h"
|
18 |
#include "DataFormats/JetReco/interface/CaloJet.h"
|
19 |
#include "DataFormats/METReco/interface/CaloMET.h"
|
20 |
#include "DataFormats/METReco/interface/GenMET.h"
|
21 |
#include "DataFormats/JetReco/interface/GenJetfwd.h"
|
22 |
#include "DataFormats/JetReco/interface/BasicJet.h"
|
23 |
#include "DataFormats/JetReco/interface/BasicJetfwd.h"
|
24 |
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
|
25 |
#include "CLHEP/HepMC/ReadHepMC.h"
|
26 |
#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
|
27 |
#include "FWCore/Framework/interface/Handle.h"
|
28 |
#include "FWCore/Framework/interface/Event.h"
|
29 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
30 |
//Jet_correct
|
31 |
#include "JetMETCorrections/Objects/interface/JetCorrector.h"
|
32 |
//Jet_id
|
33 |
#include "RecoBTag/MCTools/interface/MCParticleInfo.h"
|
34 |
#include "RecoBTag/MCTools/interface/MCBaseParticle.h"
|
35 |
#include "RecoBTag/MCTools/interface/MCParton.h"
|
36 |
#include "DataFormats/BTauReco/interface/JetTag.h"
|
37 |
#include "RecoBTag/MCTools/interface/JetFlavourIdentifier.h"
|
38 |
//
|
39 |
|
40 |
|
41 |
#include "TFile.h"
|
42 |
#include "TTree.h"
|
43 |
#include "TH1.h"
|
44 |
#include "TH1F.h"
|
45 |
#include "TH2F.h"
|
46 |
#include "TMath.h"
|
47 |
#include "TF1.h"
|
48 |
#include "TCanvas.h"
|
49 |
#include "TGraphErrors.h"
|
50 |
#include "TProfile.h"
|
51 |
|
52 |
using namespace edm;
|
53 |
using namespace std;
|
54 |
using namespace reco;
|
55 |
|
56 |
|
57 |
int eventnum=0;
|
58 |
class GenJetSort{
|
59 |
public:
|
60 |
bool operator()(const GenJet& a, const GenJet& b) {
|
61 |
return a.et() > b.et();
|
62 |
}
|
63 |
};
|
64 |
|
65 |
class CaloJetSort{
|
66 |
public:
|
67 |
bool operator()(const CaloJet& a, const CaloJet& b) {
|
68 |
return a.et() > b.et();
|
69 |
}
|
70 |
};
|
71 |
//class CorJetSort{
|
72 |
//public:
|
73 |
//bool operator()(const CorJet& a, const CorJet& b) {
|
74 |
// return a.et() > b.et();
|
75 |
//}
|
76 |
//};
|
77 |
//ForwardJet::ForwardJet( const ParameterSet& pset )
|
78 |
//{}
|
79 |
|
80 |
ForwardJet::ForwardJet( const ParameterSet& pset ) :
|
81 |
//fOutputFileName( pset.getUntrackedParameter<string>("HistOutFile",string("OutPutFile"))),
|
82 |
fOutputFileName( pset.getParameter<string>("OutPutFile")),
|
83 |
//fOutputFileName( pset.getParameter<string>("HistOutFile",string("/data2/salim/ForwardJet/ForwardJet_QCD_pt_120_170.root"))),
|
84 |
fOutputFile(0),
|
85 |
|
86 |
CorJetAlgorithm( pset.getParameter<string>( "CorJetAlgorithm" ) )
|
87 |
|
88 |
|
89 |
{
|
90 |
jfi = JetFlavourIdentifier(pset.getParameter<edm::ParameterSet>("jetIdParameters"));
|
91 |
}
|
92 |
|
93 |
void ForwardJet::beginJob( const EventSetup& )
|
94 |
{
|
95 |
fOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
|
96 |
|
97 |
//RecGenTree = new TTree("RecJet_GenJet", "Analysis");
|
98 |
//RecGenTree->Branch("fNRecJ", &fNRecJ, "fNRecJ/I");
|
99 |
//RecGenTree->Branch("fRecJetPt", &fRecJetPt, "fRecJetPt[fNRecJ]/D");
|
100 |
|
101 |
// limits for histograms
|
102 |
int nbinspt = 200;
|
103 |
int nbinsphi = 100;
|
104 |
int nbinsE= 200;
|
105 |
int nbinsEta =100;
|
106 |
int nbinsBjoX=600;
|
107 |
double ptmin = 0; //GeV
|
108 |
double ptmax = 200; //GeV
|
109 |
double ymin = -10;
|
110 |
double ymax = 10;
|
111 |
double BjoXmin = -6;
|
112 |
double BjoXmax = 0;
|
113 |
double phimin = -TMath::Pi();
|
114 |
double phimax = TMath::Pi();
|
115 |
double Emin=0; //GeV
|
116 |
double Emax=200; //GeV
|
117 |
double ETCut=20; //GeV
|
118 |
double threshold = 0.2;
|
119 |
double threshold_1 = 0.04;// min distance between parton and GenJEt
|
120 |
double sqrts = 14000.;//Gev
|
121 |
float BjoX;//Bjorken-x
|
122 |
float Min_deltaR;// minumum distance between parton and GenJEt
|
123 |
// create histograms
|
124 |
ptGen = new TH1D("ptGen","QCD jets pT 15-120 GeV ",nbinspt,ptmin,ptmax);
|
125 |
ptGen->Sumw2();
|
126 |
yGen = new TH1D("yGen","QCD jets rapidity pT 15-120 GeV ",nbinsEta,ymin,ymax);
|
127 |
yGen->Sumw2();
|
128 |
phiGen = new TH1D("phiGen","QCD jets phi pT 15-120 GeV",nbinsphi,phimin,phimax);
|
129 |
phiGen->Sumw2();
|
130 |
EGen = new TH1D ("EGen","QCD jets energy pT 15-120 GeV ",nbinsE,Emin, Emax);
|
131 |
EGen->Sumw2();
|
132 |
|
133 |
ptCalo = new TH1D("ptCalo","QCD jets pT for pT 15-120 GeV ",nbinspt,ptmin,ptmax);
|
134 |
ptCalo->Sumw2();
|
135 |
|
136 |
corr_ptCalo = new TH1D("corr_ptCalo","Corrected Calo QCD jets pT 15-120 GeV",nbinspt,ptmin,ptmax);
|
137 |
corr_ptCalo->Sumw2();
|
138 |
|
139 |
yCalo = new TH1D("yCalo","Calo QCD jets rapidity pT 15-120 GeV ",nbinsEta,ymin,ymax);
|
140 |
yCalo->Sumw2();
|
141 |
phiCalo = new TH1D("phiCalo","Calo QCD jets phi pT 15-120 GeV ",nbinsphi,phimin,phimax);
|
142 |
phiCalo->Sumw2();
|
143 |
ECalo = new TH1D ("ECalo","Calo QCD jets energy pT 15-120 GeV",nbinsE,Emin, Emax);
|
144 |
ECalo->Sumw2();
|
145 |
corr_ECalo = new TH1D ("corr_ECalo","Corrected Calo QCD jets pT for pT 15-120 GeV ",nbinsE,Emin, Emax);
|
146 |
corr_ECalo->Sumw2();
|
147 |
|
148 |
trueRecoJet = new TH1D ("trueRecoJet","True Reco Jet for E_{T}>20 GeV ",nbinsE,Emin, Emax);
|
149 |
trueRecoJet->Sumw2();
|
150 |
|
151 |
RatioE_vs_Eta= new TProfile(" RatioE_vs_Eta","E^{reco}_{T}/E^{MC}_{T} for QCD jets pT 15-120 GeV ", (nbinsEta/2), 0.,5.);
|
152 |
|
153 |
RatioE_vs_E= new TProfile("RatioE_vs_E ","E^{reco}_{T}/E^{MC}_{T} for QCD jets pT 15-120 GeV ", nbinsE,Emin ,Emax);
|
154 |
|
155 |
|
156 |
pid_highx_parton = new TH1D("pid_highx_parton","PID of parton (jet)with x>0.1 ",30,-0.5,29.5);
|
157 |
|
158 |
pid_Allx_parton= new TH1D("pid_Allx_parton","PID of parton (jet) 10^{-6}<x<0",30,-0.5,29.5);
|
159 |
|
160 |
//DeltaR & GenJetEt-PartonEt
|
161 |
Min_DeltaR=new TH1D("Min_DeltaR","Min_deltaR for Parton and GenJet ",100,-0.01,1.);
|
162 |
|
163 |
Min_DeltaR_02=new TH2D("Min_DeltaR_02","GenJetE_{T}-PartonE_{T} for #DeltaR=0.02",nbinsE,Emin,Emax,400,-200.,200.);
|
164 |
Min_DeltaR_04=new TH2D("Min_DeltaR_04","GenJetE_{T}-PartonE_{T} for #DeltaR=0.04",nbinsE,Emin,Emax,400,-200.,200.);
|
165 |
Min_DeltaR_06=new TH2D("Min_DeltaR_06","GenJetE_{T}-PartonE_{T} for #DeltaR=0.06",nbinsE,Emin,Emax,400,-200.,200.);
|
166 |
Min_DeltaR_08=new TH2D("Min_DeltaR_08","GenJetE_{T}-PartonE_{T} for #DeltaR=0.08",nbinsE,Emin,Emax,400,-200.,200.);
|
167 |
Min_DeltaR_1=new TH2D("Min_DeltaR_1","GenJetE_{T}-PartonE_{T} for #DeltaR=0.1",nbinsE,Emin,Emax,400,-200.,200.);
|
168 |
Min_DeltaR_2=new TH2D("Min_DeltaR_2","GenJetE_{T}-PartonE_{T} for #DeltaR=0.2",nbinsE,Emin,Emax,400,-200.,200.);
|
169 |
Min_DeltaR_5=new TH2D("Min_DeltaR_5","GenJetE_{T}-PartonE_{T} for #DeltaR=0.5",nbinsE,Emin,Emax,400,-200.,200.);
|
170 |
Min_DeltaR_8=new TH2D("Min_DeltaR_8","GenJetE_{T}-PartonE_{T} for #DeltaR=0.8",nbinsE,Emin,Emax,400,-200.,200.);
|
171 |
//Creating a binning in ET and an histogram for each of the ET bin
|
172 |
unsigned int nbreBins=11;
|
173 |
//EThist [11];
|
174 |
char nameHist [50];//for Et distribution
|
175 |
char nameHist1 [50];//for reco jet phi distribution
|
176 |
char nameHist2 [50];//for reco jet eta distribution
|
177 |
char label [500];//for Et distribution
|
178 |
char label1 [500];//for reco jet phi distribution
|
179 |
char label2 [500];//for reco jet eta distribution
|
180 |
|
181 |
double limBins[] = {10,20,30,40,50,60,70,80,100.0,120.,150.,250};
|
182 |
|
183 |
ratioE = new TH1D ("ratioE", "E^{reco}_{T}/E^{MC}_{T}",nbreBins, Emin, Emax);
|
184 |
ratioE->Sumw2();
|
185 |
ratioE->SetBins(nbreBins,limBins);
|
186 |
|
187 |
sigmaErEm = new TH1D ("sigmaErEm", "sigma Ereco / Emc",nbreBins, Emin, Emax);
|
188 |
|
189 |
sigmaErEm->Sumw2();
|
190 |
sigmaErEm->SetBins(nbreBins,limBins);
|
191 |
|
192 |
for (unsigned int indexH=0;indexH<nbreBins;indexH++)
|
193 |
{
|
194 |
sprintf(nameHist,"ETdistribution%i",indexH);
|
195 |
sprintf(nameHist1,"phidistribution%i",indexH);
|
196 |
sprintf(nameHist2,"etadistribution%i",indexH);
|
197 |
|
198 |
sprintf(label,"E_{T}(reco)/E_{T}(Gen) #in #left[%f , %f #right] GeV",limBins[indexH],limBins[indexH+1]);
|
199 |
sprintf(label1,"#phi_{rec} #in #left[%f , %f #right] GeV",limBins[indexH],limBins[indexH+1]);
|
200 |
sprintf(label2,"#eta_{rec} #in #left[%f , %f #right] GeV",limBins[indexH],limBins[indexH+1]);
|
201 |
|
202 |
EThist[indexH]=new TH1D(nameHist,label,nbinsE,0.2, 1.8);
|
203 |
EThist[indexH]->Sumw2();
|
204 |
EThist[indexH]->GetXaxis()->SetTitle("E_{T}^{reco}/E_{t}^{gen}");
|
205 |
EThist[indexH]->GetYaxis()->SetTitle("#");
|
206 |
|
207 |
Phihist[indexH]=new TH1D(nameHist1,label1,480, 0.2, 1.8 );
|
208 |
Phihist[indexH]->Sumw2();
|
209 |
Phihist[indexH]->GetXaxis()->SetTitle("#phi_{rec}/#phi_{gen}");
|
210 |
Phihist[indexH]->GetYaxis()->SetTitle("#");
|
211 |
|
212 |
Etahist[indexH]=new TH1D(nameHist2,label2,400,0.8, 1.2);
|
213 |
Etahist[indexH]->Sumw2();
|
214 |
Etahist[indexH]->GetXaxis()->SetTitle("#eta_{rec}/#eta_{gen}/");
|
215 |
Etahist[indexH]->GetYaxis()->SetTitle("#");
|
216 |
}
|
217 |
|
218 |
//FOR HF
|
219 |
EGen_hf = new TH1D( "GenJetE_hf" , "GenJet E_{T} for E_{T}>20 GeV and 3<#||{#eta}<5 ", nbinsE,Emin, Emax ) ;
|
220 |
EGen_hf->Sumw2();
|
221 |
ECalo_hf = new TH1D( "CaloJetE_hf" , "CaloJet E_{T} forQCD jets pT 15-120 GeV and 3<#||{#eta}<5",nbinsE,Emin, Emax) ;
|
222 |
ECalo_hf->Sumw2();
|
223 |
|
224 |
corr_ECalo_hf = new TH1D("corr_CaloJetE_hf" , "corr_CaloJet E_{T} for E_{T}>20 GeV and 3<#||{#eta}<5",nbinsE,Emin, Emax) ;
|
225 |
corr_ECalo_hf->Sumw2();
|
226 |
|
227 |
RatioE_hf_vs_Eta= new TProfile(" RatioE_vs_Eta_hf","E^{reco}_{T}/E^{MC}_{T} for QCD jets pT 15-120 GeV and 3<#||{#eta}<5 ", 20, 3.,5.);
|
228 |
RatioE_hf_vs_E= new TProfile("RatioE_vs_E_hf","E^{reco}_{T}/E^{MC}_{T} for QCD jets pT 15-120 GeV and HF ", nbinsE,Emin ,Emax);
|
229 |
distX_hf = new TH2D("distX_hf","",nbinsBjoX,BjoXmin,BjoXmax,200,0.,200.);
|
230 |
distX_1_hf = new TH2D("distX_1_hf"," x>0.1",nbinsBjoX,BjoXmin,BjoXmax,200,0.,200.);
|
231 |
distX_Matching_parton_hf = new TH2D("distX_Matchin_parton_hf"," Matching with parton cone=0.04",nbinsBjoX,BjoXmin,BjoXmax,200,0.,200.);
|
232 |
//FOR CASTOR
|
233 |
distX_castor = new TH2D("distX_castor","",nbinsBjoX,BjoXmin,BjoXmax,200,0. ,200.);
|
234 |
|
235 |
return ;
|
236 |
}
|
237 |
|
238 |
|
239 |
|
240 |
void ForwardJet::analyze( const Event& e, const EventSetup& ){
|
241 |
|
242 |
//Constant
|
243 |
double ETCut=20.; //GeV
|
244 |
double PtCut=20.;//GeV
|
245 |
double threshold = 0.2;
|
246 |
double threshold_1 = 0.04;// min distance between parton and GenJEt
|
247 |
double sqrts = 14000.;//Gev
|
248 |
float BjoX;//Bjorken-x
|
249 |
double limBins[] = {10,20,30,40,50,60,70,80,100.0,120.,150.,200};
|
250 |
int nbreBins=11;
|
251 |
|
252 |
float min_distance=1.;//maximum values of minumum distance between parton and GenJEt
|
253 |
//cout << "Event No: " << e.id() << " started to be analyzed" << endl;
|
254 |
if(eventnum%100==0)cout<<"EventNumber====>"<<eventnum<<endl;
|
255 |
|
256 |
///iterativecone5
|
257 |
Handle< GenJetCollection > GenJetsHandle ;
|
258 |
try{
|
259 |
e.getByLabel( "iterativeCone5GenJets", GenJetsHandle );
|
260 |
}catch(cms::Exception& ex){
|
261 |
LogError("ForwardJet") << "Error! can't get collection.";
|
262 |
}
|
263 |
|
264 |
Handle< CaloJetCollection > CaloJetsHandle ;
|
265 |
try{
|
266 |
e.getByLabel( "iterativeCone5CaloJets", CaloJetsHandle );
|
267 |
}catch(cms::Exception& ex){
|
268 |
LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
269 |
}
|
270 |
// Handle<CaloJetCollection> CorJetsHandle;
|
271 |
//try{
|
272 |
// e.getByLabel( CorJetAlgorithm, CorJetsHandle );
|
273 |
//}catch(cms::Exception& ex){
|
274 |
//LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
275 |
//}
|
276 |
|
277 |
//
|
278 |
//ktJets
|
279 |
/* Handle< GenJetCollection > GenJetsHandle ;
|
280 |
try{
|
281 |
e.getByLabel( "Kt10GenJets", GenJetsHandle );
|
282 |
}catch(cms::Exception& ex){
|
283 |
LogError("ForwardJet") << "Error! can't get collection.";
|
284 |
}
|
285 |
|
286 |
Handle< CaloJetCollection > CaloJetsHandle ;
|
287 |
try{
|
288 |
e.getByLabel( "Kt10CaloJets", CaloJetsHandle );
|
289 |
}catch(cms::Exception& ex){
|
290 |
LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
291 |
}*/
|
292 |
|
293 |
|
294 |
///MidPoint
|
295 |
/*Handle< GenJetCollection > GenJetsHandle ;
|
296 |
try{
|
297 |
e.getByLabel( "midPointCone5GenJets", GenJetsHandle );
|
298 |
}catch(cms::Exception& ex){
|
299 |
LogError("ForwardJet") << "Error! can't get collection.";
|
300 |
}
|
301 |
|
302 |
Handle< CaloJetCollection > CaloJetsHandle ;
|
303 |
try{
|
304 |
e.getByLabel( "midPointCone5CaloJets", CaloJetsHandle );
|
305 |
}catch(cms::Exception& ex){
|
306 |
LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
307 |
}*/
|
308 |
|
309 |
/*************************************************/
|
310 |
// GEN JET //
|
311 |
/*************************************************/
|
312 |
|
313 |
|
314 |
vector<GenJet> tmpGenJet;
|
315 |
tmpGenJet.clear();
|
316 |
if(GenJetsHandle->size())
|
317 |
{
|
318 |
for(GenJetCollection::const_iterator it=GenJetsHandle->begin();it!=GenJetsHandle->end();it++)
|
319 |
tmpGenJet.push_back(*it);
|
320 |
std::stable_sort(tmpGenJet.begin(),tmpGenJet.end(),GenJetSort());
|
321 |
}
|
322 |
|
323 |
GenJet fGJ;
|
324 |
if(tmpGenJet.size()>0){
|
325 |
for(int g = 0; g <tmpGenJet.size();++g){
|
326 |
|
327 |
fGJ = tmpGenJet[g];
|
328 |
//fGJ.print();
|
329 |
//cout<<"particle Id=="<<fGJ.pdgId()<<endl;
|
330 |
if(fGJ.et()>ETCut)
|
331 |
{
|
332 |
ptGen->Fill(fGJ.pt());
|
333 |
yGen->Fill(fGJ.eta());
|
334 |
phiGen->Fill(fGJ.phi());
|
335 |
EGen->Fill(fGJ.et());
|
336 |
}
|
337 |
if (abs(fGJ.eta())>=3. && abs(fGJ.eta())<=5.)//Distribution BjoX and E for HF
|
338 |
{
|
339 |
|
340 |
if(fGJ.et()>ETCut)
|
341 |
{
|
342 |
|
343 |
BjoX=log10((fGJ.pt()/sqrts)*exp((-1)*(fGJ.eta())));
|
344 |
distX_hf->Fill( BjoX,fGJ.et());
|
345 |
EGen_hf->Fill(fGJ.et());
|
346 |
|
347 |
if(BjoX>=-1)
|
348 |
{
|
349 |
distX_1_hf->Fill( BjoX,fGJ.et());
|
350 |
}
|
351 |
|
352 |
}
|
353 |
}
|
354 |
|
355 |
if (abs(fGJ.eta())>=5.3 && abs(fGJ.eta())<=6.6)//Distribution BjoX for CASTOR
|
356 |
{
|
357 |
|
358 |
if(fGJ.et()>ETCut)
|
359 |
{
|
360 |
// cout<<" Castor Eta Bjr=="<<fGJ.eta()<< " GenEt=="<<fGJ.eta()<<endl;
|
361 |
BjoX=log10((fGJ.pt()/sqrts)*exp((-1)*(fGJ.eta())));
|
362 |
distX_castor->Fill( BjoX,fGJ.et());
|
363 |
|
364 |
|
365 |
|
366 |
}
|
367 |
}
|
368 |
|
369 |
}
|
370 |
}
|
371 |
/*******************************************/
|
372 |
// Matching parton dR<0.1 //
|
373 |
/******************************************/
|
374 |
|
375 |
GenJet fGenJet;
|
376 |
|
377 |
//cout <<"\n============================================================================\n";
|
378 |
//cout <<"\nNew Event\n";
|
379 |
//cout <<"\n============================================================================\n";
|
380 |
//cout<<"event id="<<e.id()<<endl;
|
381 |
|
382 |
jfi.readEvent(e);
|
383 |
|
384 |
//cout <<"\nList of partons:\n";
|
385 |
|
386 |
vector<MCParton> partonList = jfi.getListOfPartons();
|
387 |
|
388 |
if(tmpGenJet.size()>0 && partonList.size()>0)
|
389 |
{
|
390 |
|
391 |
//cout << "Found " << partonList.size() << " partons" << endl;
|
392 |
//cout << "Found " <<tmpGenJet.size() << " genjet" << endl;
|
393 |
|
394 |
|
395 |
for(int gg = 0; gg <tmpGenJet.size();++gg)
|
396 |
{
|
397 |
fGenJet= tmpGenJet[gg];
|
398 |
float GenJETEta=fGenJet.eta();
|
399 |
float GenJETPhi=fGenJet.phi();
|
400 |
|
401 |
|
402 |
for (vector<MCParton>::iterator i = partonList.begin(); i != partonList.end(); ++i) {
|
403 |
//cout << "Found Parton of flavour: "<< i->flavour() << endl;
|
404 |
//cout << " Eta/phi of parton: " << i->summedDaughterMomentum().eta()
|
405 |
//<<" , "<< i->summedDaughterMomentum().phi()<<endl;
|
406 |
|
407 |
float PartonEta=i->fourVector().eta();
|
408 |
float PartonPhi=i->fourVector().phi();
|
409 |
|
410 |
if (abs(fGenJet.eta())>=3. && abs(fGenJet.eta())<=5.)//Distribution BjoX and E for HF
|
411 |
{
|
412 |
float distance = delR(GenJETEta ,PartonEta,GenJETPhi,PartonPhi);
|
413 |
float PartonPt=i->fourVector().pt();
|
414 |
|
415 |
//*******************************************//
|
416 |
//Find Min distance between parton and GenJet//
|
417 |
//*******************************************//
|
418 |
|
419 |
if (distance < min_distance)
|
420 |
{
|
421 |
min_distance=distance ;
|
422 |
}
|
423 |
Min_deltaR=min_distance;
|
424 |
|
425 |
//Fill GenJet_Et-PartonEt for Different DeltaR
|
426 |
if (fGenJet.pt()>PtCut){
|
427 |
if(distance<0.02){ Min_DeltaR_02->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
428 |
if(distance<0.04){ Min_DeltaR_04->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
429 |
if(distance<0.06){ Min_DeltaR_06->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
430 |
if(distance<0.08){ Min_DeltaR_08->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
431 |
if(distance<0.1){ Min_DeltaR_1->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
432 |
if(distance<0.2){ Min_DeltaR_2->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
433 |
if(distance<0.5){ Min_DeltaR_5->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
434 |
if(distance<0.8){ Min_DeltaR_8->Fill(fGenJet.pt(),(fGenJet.pt()-PartonPt));}
|
435 |
}
|
436 |
//*******************************************//
|
437 |
|
438 |
|
439 |
if(fGenJet.et()>ETCut && distance<threshold_1)
|
440 |
{
|
441 |
|
442 |
BjoX=log10((fGenJet.pt()/sqrts)*exp((-1)*(fGenJet.eta())));
|
443 |
|
444 |
if(BjoX>=-1)
|
445 |
{
|
446 |
pid_highx_parton->Fill(i->flavour());
|
447 |
}
|
448 |
|
449 |
distX_Matching_parton_hf->Fill( BjoX,fGenJet.et());
|
450 |
pid_Allx_parton->Fill(i->flavour());
|
451 |
|
452 |
|
453 |
}
|
454 |
}
|
455 |
|
456 |
}
|
457 |
|
458 |
}
|
459 |
|
460 |
}
|
461 |
|
462 |
|
463 |
Min_DeltaR->Fill(Min_deltaR);
|
464 |
|
465 |
/*************************************************/
|
466 |
// REC0 JET //
|
467 |
/*************************************************/
|
468 |
|
469 |
vector<CaloJet> tmpCaloJet;
|
470 |
tmpCaloJet.clear();
|
471 |
if(CaloJetsHandle->size()){
|
472 |
for(CaloJetCollection::const_iterator it=CaloJetsHandle->begin();it!=CaloJetsHandle->end();it++)
|
473 |
tmpCaloJet.push_back(*it);
|
474 |
std::stable_sort(tmpCaloJet.begin(),tmpCaloJet.end(),CaloJetSort());
|
475 |
}
|
476 |
//cout << "There are " << tmpCaloJet.size() << " CaloJets" <<endl;
|
477 |
|
478 |
// CaloJet TotRecJet;
|
479 |
CaloJet fRJ;
|
480 |
if(tmpCaloJet.size()>0){
|
481 |
for(int r = 0; r <tmpCaloJet.size();++r)
|
482 |
{
|
483 |
fRJ = tmpCaloJet[r];
|
484 |
if(fRJ.et()>ETCut)
|
485 |
{
|
486 |
ptCalo->Fill(fRJ.pt());
|
487 |
yCalo->Fill(fRJ.eta());
|
488 |
phiCalo->Fill(fRJ.phi());
|
489 |
ECalo->Fill(fRJ.et());
|
490 |
}
|
491 |
|
492 |
if (abs(fRJ.eta())>=3. && abs(fRJ.eta())<=5.)
|
493 |
{
|
494 |
if(fRJ.et()>ETCut)
|
495 |
{
|
496 |
|
497 |
ECalo_hf->Fill(fRJ.et());
|
498 |
}
|
499 |
}
|
500 |
|
501 |
}
|
502 |
}
|
503 |
|
504 |
/*************************************************/
|
505 |
// CORRECTED REC0 JET //
|
506 |
/*************************************************/
|
507 |
Handle<CaloJetCollection> CorJets;
|
508 |
try{
|
509 |
e.getByLabel(CorJetAlgorithm, CorJets );
|
510 |
}catch(cms::Exception& ex){
|
511 |
LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
512 |
}
|
513 |
|
514 |
for(CaloJetCollection::const_iterator corjets=CorJets->begin();corjets!=CorJets->end();corjets++)
|
515 |
{
|
516 |
|
517 |
if(corjets->et()>ETCut)
|
518 |
{
|
519 |
corr_ptCalo->Fill(corjets->pt());
|
520 |
corr_ECalo->Fill(corjets->et());
|
521 |
}
|
522 |
|
523 |
if (abs(corjets->eta())>=3. && abs(corjets->eta())<=5.)
|
524 |
{
|
525 |
if(corjets->et()>ETCut)
|
526 |
{
|
527 |
|
528 |
corr_ECalo_hf->Fill(corjets->et());
|
529 |
}
|
530 |
}
|
531 |
}
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
/*******************************************/
|
537 |
// Matching dR<0.2 //
|
538 |
/******************************************/
|
539 |
|
540 |
GenJet fGJet;
|
541 |
if(tmpGenJet.size()>0 )
|
542 |
{
|
543 |
for(int gg = 0; gg <tmpGenJet.size();++gg)
|
544 |
{
|
545 |
fGJet = tmpGenJet[gg];
|
546 |
|
547 |
float GenJetEta=fGJet.eta();
|
548 |
float GenJetPhi=fGJet.phi();
|
549 |
|
550 |
|
551 |
Handle<CaloJetCollection> corjets;
|
552 |
try{
|
553 |
e.getByLabel(CorJetAlgorithm, corjets );
|
554 |
}catch(cms::Exception& ex){
|
555 |
LogError("ForwardJet") << "Error! can't get collection CaloJetsHandle";
|
556 |
}
|
557 |
|
558 |
for(CaloJetCollection::const_iterator cor=corjets->begin();cor!=corjets->end();cor++)
|
559 |
{
|
560 |
|
561 |
float CaloJetEta=cor->eta();
|
562 |
float CaloJetPhi=cor->phi();
|
563 |
|
564 |
float distance = delR(GenJetEta ,CaloJetEta,GenJetPhi,CaloJetPhi);
|
565 |
|
566 |
if (distance<=threshold && fGJet.et()>ETCut )
|
567 |
{
|
568 |
|
569 |
RatioE_vs_Eta->Fill(abs(GenJetEta), (cor->et())/fGJet.et());
|
570 |
RatioE_vs_E->Fill(fGJet.et(), (cor->et())/fGJet.et());
|
571 |
|
572 |
if (abs(cor->eta())>=3. && abs(cor->eta())<=5.)// FOR HF
|
573 |
{
|
574 |
double ESim= fGJet.et();
|
575 |
int trueIndex=determineIndex(limBins,ESim,nbreBins);
|
576 |
if(trueIndex!=-1)
|
577 |
{
|
578 |
|
579 |
|
580 |
EThist[trueIndex]->Fill((cor->et())/(fGJet.et()));
|
581 |
Phihist[trueIndex]->Fill(abs(cor->phi())/abs(fGJet.phi()));
|
582 |
Etahist[trueIndex]->Fill(abs(cor->eta())/abs(fGJet.eta()));
|
583 |
trueRecoJet->Fill(cor->et());
|
584 |
countD++;
|
585 |
}
|
586 |
RatioE_hf_vs_Eta->Fill(abs(GenJetEta), (cor->et())/fGJet.et());
|
587 |
RatioE_hf_vs_E->Fill(fGJet.et(),(cor->et()) /fGJet.et());
|
588 |
|
589 |
}
|
590 |
}
|
591 |
// for not corrected calo jet
|
592 |
|
593 |
/* for(int rr = 0; rr <tmpCaloJet.size();++rr){
|
594 |
fRJet = tmpCaloJet[rr];
|
595 |
|
596 |
float CaloJetEta=fRJet.eta();
|
597 |
float CaloJetPhi=fRJet.phi();
|
598 |
|
599 |
float distance = delR(GenJetEta ,CaloJetEta,GenJetPhi,CaloJetPhi);
|
600 |
|
601 |
// if distance < threshold , fill histogramm
|
602 |
if (distance<=threshold && fGJet.et()>ETCut )
|
603 |
{
|
604 |
|
605 |
//if(genjetused[gg] == 0)
|
606 |
//{
|
607 |
|
608 |
RatioE_vs_Eta->Fill(abs(GenJetEta), fRJet.et()/fGJet.et());
|
609 |
RatioE_vs_E->Fill(fGJet.et(), fRJet.et()/fGJet.et());
|
610 |
|
611 |
if (abs(fRJet.eta())>=3. && abs(fRJet.eta())<=5.)// FOR HF
|
612 |
{
|
613 |
double ESim= fGJet.et();
|
614 |
int trueIndex=determineIndex(limBins,ESim,nbreBins);
|
615 |
if(trueIndex!=-1)
|
616 |
{
|
617 |
cout<<"RjetEta=="<<fRJet.eta()<<" GenJetEt=="<<fGJet.et()<<endl;
|
618 |
|
619 |
EThist[trueIndex]->Fill((fRJet.et())/(fGJet.et()));
|
620 |
Phihist[trueIndex]->Fill(abs(fRJet.phi())/abs(fGJet.phi()));
|
621 |
Etahist[trueIndex]->Fill(abs(fRJet.eta())/abs(fGJet.eta()));
|
622 |
trueRecoJet->Fill(fRJet.et());
|
623 |
countD++;
|
624 |
}
|
625 |
RatioE_hf_vs_Eta->Fill(abs(GenJetEta), fRJet.et()/fGJet.et());
|
626 |
RatioE_hf_vs_E->Fill(fGJet.et(), fRJet.et()/fGJet.et());
|
627 |
|
628 |
}
|
629 |
}
|
630 |
}*/
|
631 |
}
|
632 |
}
|
633 |
}
|
634 |
|
635 |
|
636 |
//RecGenTree->Fill();
|
637 |
//cout << endl;
|
638 |
//cout << "===> " << e.id() << " finished" << endl;
|
639 |
eventnum++;
|
640 |
return ;
|
641 |
|
642 |
}
|
643 |
|
644 |
void ForwardJet::endJob(){
|
645 |
double sigma=1460000000;//pb
|
646 |
|
647 |
ptGen->Scale(sigma/(eventnum*ptGen->GetBinWidth(1)));
|
648 |
yGen->Scale(sigma/(eventnum*yGen->GetBinWidth(1)));
|
649 |
phiGen->Scale(sigma/(eventnum*phiGen->GetBinWidth(1)));
|
650 |
EGen->Scale(sigma/(eventnum* EGen->GetBinWidth(1)));
|
651 |
ptCalo->Scale(sigma/(eventnum*ptCalo->GetBinWidth(1)));
|
652 |
corr_ptCalo->Scale(sigma/(eventnum*corr_ptCalo->GetBinWidth(1)));
|
653 |
yCalo->Scale(sigma/(eventnum*yCalo->GetBinWidth(1)));
|
654 |
phiCalo->Scale(sigma/(eventnum*phiCalo->GetBinWidth(1)));
|
655 |
ECalo->Scale(sigma/(eventnum*ECalo->GetBinWidth(1)));
|
656 |
corr_ECalo->Scale(sigma/(eventnum*corr_ECalo->GetBinWidth(1)));
|
657 |
EGen_hf->Scale(sigma/(eventnum*EGen_hf->GetBinWidth(1)));
|
658 |
ECalo_hf->Scale(sigma/(eventnum*ECalo_hf->GetBinWidth(1)));
|
659 |
corr_ECalo_hf->Scale(sigma/(eventnum*corr_ECalo_hf->GetBinWidth(1)));
|
660 |
|
661 |
fOutputFile->Write() ;
|
662 |
fOutputFile->Close() ;
|
663 |
return ;
|
664 |
}
|
665 |
float ForwardJet::delR(const float& eta1,const float& eta2,const float& phi1,const float& phi2)
|
666 |
{
|
667 |
|
668 |
float Distance =sqrt((2*atan(tan((phi1-phi2)/2)))*(2*atan(tan((phi1-phi2)/2)))+(eta1-eta2)*(eta1-eta2));
|
669 |
return Distance;
|
670 |
|
671 |
}
|
672 |
int ForwardJet::determineIndex( double* limBins, double data, int nbreBins){
|
673 |
|
674 |
int result =-1;
|
675 |
if(data<limBins[0]) return result;
|
676 |
|
677 |
for(int i = 0; i<nbreBins;i++){
|
678 |
if(limBins[i]<= data && data<limBins[i+1]){
|
679 |
result=i;
|
680 |
break;}
|
681 |
result=i;
|
682 |
}
|
683 |
|
684 |
return result;
|
685 |
|
686 |
}
|
687 |
|
688 |
DEFINE_FWK_MODULE(ForwardJet);
|