1 |
// -*- C++ -*-
|
2 |
//
|
3 |
// Package: HiPFCandAnalyzer
|
4 |
// Class: HiPFCandAnalyzer
|
5 |
//
|
6 |
/**\class HiPFCandAnalyzer HiPFCandAnalyzer.cc ana/HiPFCandAnalyzer/src/HiPFCandAnalyzer.cc
|
7 |
|
8 |
Description: [one line class summary]
|
9 |
|
10 |
Implementation:
|
11 |
[Notes on implementation]
|
12 |
*/
|
13 |
//
|
14 |
// Original Author: Matt, Nguyen
|
15 |
// Created: Oct 10 2010
|
16 |
//
|
17 |
//
|
18 |
//
|
19 |
|
20 |
|
21 |
// system include files
|
22 |
#include <memory>
|
23 |
|
24 |
// stl
|
25 |
#include <algorithm>
|
26 |
|
27 |
// user include files
|
28 |
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
29 |
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
30 |
|
31 |
#include "FWCore/Framework/interface/Event.h"
|
32 |
#include "FWCore/Framework/interface/MakerMacros.h"
|
33 |
|
34 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
35 |
|
36 |
// ana
|
37 |
#include "CmsHi/JetAnalysis/interface/HiPFCandAnalyzer.h"
|
38 |
|
39 |
#include "FWCore/ServiceRegistry/interface/Service.h"
|
40 |
#include "CommonTools/UtilAlgos/interface/TFileService.h"
|
41 |
#include "RecoJets/JetAlgorithms/interface/JetAlgoHelper.h"
|
42 |
#include "FWCore/Common/interface/TriggerNames.h"
|
43 |
#include "DataFormats/Common/interface/TriggerResults.h"
|
44 |
#include "DataFormats/TrackReco/interface/Track.h"
|
45 |
#include "DataFormats/VertexReco/interface/Vertex.h"
|
46 |
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
|
47 |
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
|
48 |
#include "DataFormats/Math/interface/LorentzVector.h"
|
49 |
#include "DataFormats/Math/interface/deltaR.h"
|
50 |
#include "DataFormats/Math/interface/deltaPhi.h"
|
51 |
#include "TMath.h"
|
52 |
#include "TStopwatch.h"
|
53 |
|
54 |
#include "DataFormats/HeavyIonEvent/interface/Centrality.h"
|
55 |
#include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
|
56 |
|
57 |
using namespace std;
|
58 |
using namespace edm;
|
59 |
using namespace reco;
|
60 |
|
61 |
//
|
62 |
// constructors and destructor
|
63 |
//
|
64 |
HiPFCandAnalyzer::HiPFCandAnalyzer(const edm::ParameterSet& iConfig)
|
65 |
{
|
66 |
// Event source
|
67 |
// Event Info
|
68 |
pfCandidateLabel_ = iConfig.getParameter<edm::InputTag>("pfCandidateLabel");
|
69 |
genLabel_ = iConfig.getParameter<edm::InputTag>("genLabel");
|
70 |
jetLabel_ = iConfig.getParameter<edm::InputTag>("jetLabel");
|
71 |
|
72 |
pfPtMin_ = iConfig.getParameter<double>("pfPtMin");
|
73 |
genPtMin_ = iConfig.getParameter<double>("genPtMin");
|
74 |
jetPtMin_ = iConfig.getParameter<double>("jetPtMin");
|
75 |
|
76 |
// debug
|
77 |
verbosity_ = iConfig.getUntrackedParameter<int>("verbosity", 0);
|
78 |
|
79 |
doJets_ = iConfig.getUntrackedParameter<bool>("doJets",0);
|
80 |
doMC_ = iConfig.getUntrackedParameter<bool>("doMC",0);
|
81 |
skipCharged_ = iConfig.getUntrackedParameter<bool>("skipCharged",0);
|
82 |
}
|
83 |
|
84 |
|
85 |
HiPFCandAnalyzer::~HiPFCandAnalyzer()
|
86 |
{
|
87 |
|
88 |
// do anything here that needs to be done at desctruction time
|
89 |
// (e.g. close files, deallocate resources etc.)
|
90 |
|
91 |
}
|
92 |
|
93 |
|
94 |
//
|
95 |
// member functions
|
96 |
//
|
97 |
|
98 |
// ------------ method called to for each event ------------
|
99 |
void
|
100 |
HiPFCandAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
101 |
{
|
102 |
|
103 |
pfEvt_.Clear();
|
104 |
|
105 |
// Fill PF info
|
106 |
|
107 |
edm::Handle<reco::PFCandidateCollection> pfCandidates;
|
108 |
iEvent.getByLabel(pfCandidateLabel_,pfCandidates);
|
109 |
const reco::PFCandidateCollection *pfCandidateColl = &(*pfCandidates);
|
110 |
|
111 |
|
112 |
for(unsigned icand=0;icand<pfCandidateColl->size(); icand++) {
|
113 |
const reco::PFCandidate pfCandidate = pfCandidateColl->at(icand);
|
114 |
|
115 |
double pt = pfCandidate.pt();
|
116 |
if(pt<pfPtMin_) continue;
|
117 |
|
118 |
int id = pfCandidate.particleId();
|
119 |
if(skipCharged_ && (abs(id) == 1 || abs(id) == 3)) continue;
|
120 |
|
121 |
pfEvt_.pfId_[pfEvt_.nPFpart_] = id;
|
122 |
pfEvt_.pfPt_[pfEvt_.nPFpart_] = pt;
|
123 |
pfEvt_.pfEta_[pfEvt_.nPFpart_] = pfCandidate.eta();
|
124 |
pfEvt_.pfPhi_[pfEvt_.nPFpart_] = pfCandidate.phi();
|
125 |
pfEvt_.nPFpart_++;
|
126 |
|
127 |
}
|
128 |
|
129 |
|
130 |
// Fill GEN info
|
131 |
if(doMC_){
|
132 |
edm::Handle<reco::GenParticleCollection> genParticles;
|
133 |
iEvent.getByLabel(genLabel_,genParticles);
|
134 |
const reco::GenParticleCollection* genColl= &(*genParticles);
|
135 |
|
136 |
for(unsigned igen=0;igen<genColl->size(); igen++) {
|
137 |
|
138 |
const reco::GenParticle gen = genColl->at(igen);
|
139 |
double eta = gen.eta();
|
140 |
double pt = gen.pt();
|
141 |
|
142 |
if(gen.status()==1 && fabs(eta)<3.0 && pt> genPtMin_){
|
143 |
pfEvt_.genPDGId_[pfEvt_.nGENpart_] = gen.pdgId();
|
144 |
pfEvt_.genPt_[pfEvt_.nGENpart_] = pt;
|
145 |
pfEvt_.genEta_[pfEvt_.nGENpart_] = eta;
|
146 |
pfEvt_.genPhi_[pfEvt_.nGENpart_] = gen.phi();
|
147 |
pfEvt_.nGENpart_++;
|
148 |
}
|
149 |
}
|
150 |
}
|
151 |
|
152 |
// Fill Jet info
|
153 |
if(doJets_){
|
154 |
edm::Handle<pat::JetCollection> jets;
|
155 |
iEvent.getByLabel(jetLabel_,jets);
|
156 |
const pat::JetCollection *jetColl = &(*jets);
|
157 |
|
158 |
|
159 |
for(unsigned ijet=0;ijet<jetColl->size(); ijet++) {
|
160 |
const pat::Jet jet = jetColl->at(ijet);
|
161 |
|
162 |
double pt = jet.pt();
|
163 |
|
164 |
if(pt>jetPtMin_){
|
165 |
pfEvt_.jetPt_[pfEvt_.njets_] = pt;
|
166 |
pfEvt_.jetEta_[pfEvt_.njets_] = jet.eta();
|
167 |
pfEvt_.jetPhi_[pfEvt_.njets_] = jet.phi();
|
168 |
pfEvt_.njets_++;
|
169 |
}
|
170 |
}
|
171 |
}
|
172 |
|
173 |
// All done
|
174 |
pfTree_->Fill();
|
175 |
}
|
176 |
|
177 |
/*
|
178 |
void HiPFCandAnalyzer::FillEventInfo(const edm::Event& iEvent, const edm::EventSetup& iSetup, TreePFCandEventData & tr)
|
179 |
{
|
180 |
// General Info
|
181 |
tr.run_ = iEvent.id().run();
|
182 |
tr.evt_ = iEvent.id().event();
|
183 |
tr.lumi_ = iEvent.luminosityBlock();
|
184 |
|
185 |
if(!genOnly_&&sampleType_<10){
|
186 |
// HI Event info
|
187 |
edm::Handle<reco::Centrality> cent;
|
188 |
iEvent.getByLabel(edm::InputTag("hiCentrality"),cent);
|
189 |
Double_t hf = cent->EtHFhitSum();
|
190 |
// Get Centrality bin
|
191 |
cbins_ = getCentralityBinsFromDB(iSetup);
|
192 |
tr.cent_ = cbins_->getBin(hf)*(100./cbins_->getNbins());
|
193 |
}
|
194 |
|
195 |
if (isMC_&&sampleType_<10) {
|
196 |
edm::Handle<edm::GenHIEvent> mchievt;
|
197 |
iEvent.getByLabel(edm::InputTag("heavyIon"),mchievt);
|
198 |
tr.b_ = mchievt->b();
|
199 |
tr.npart_ = mchievt->Npart();
|
200 |
tr.ncoll_ = mchievt->Ncoll();
|
201 |
}
|
202 |
}
|
203 |
*/
|
204 |
void HiPFCandAnalyzer::beginJob()
|
205 |
{
|
206 |
|
207 |
// -- trees --
|
208 |
pfTree_ = fs->make<TTree>("pfTree","dijet tree");
|
209 |
pfEvt_.SetTree(pfTree_);
|
210 |
pfEvt_.doMC = doMC_;
|
211 |
pfEvt_.doJets = doJets_;
|
212 |
|
213 |
pfEvt_.SetBranches();
|
214 |
}
|
215 |
|
216 |
// ------------ method called once each job just after ending the event loop ------------
|
217 |
void
|
218 |
HiPFCandAnalyzer::endJob() {
|
219 |
// ===== Done =====
|
220 |
/* if (verbosity_>=1) {
|
221 |
cout << endl << "================ Ana Process Summaries =============" << endl;
|
222 |
cout << " AnaJet: " << jetsrc_ << endl;
|
223 |
if (refJetType_>=0) cout << " RefJet: " << refjetsrc_ << endl;
|
224 |
cout << " AnaTrk: " << trksrc_ << endl;
|
225 |
cout << "# HI Events : "<< numHiEvtSel_<< endl;
|
226 |
cout << "# Base Events: "<< numEvtSel_ << endl;
|
227 |
cout << "# Jet Events: "<< numJetEvtSel_<< endl;
|
228 |
}
|
229 |
*/
|
230 |
}
|
231 |
|
232 |
// constructors
|
233 |
TreePFCandEventData::TreePFCandEventData(){
|
234 |
|
235 |
}
|
236 |
|
237 |
|
238 |
// set branches
|
239 |
void TreePFCandEventData::SetBranches()
|
240 |
{
|
241 |
// --event level--
|
242 |
|
243 |
// -- particle info --
|
244 |
tree_->Branch("nPFpart",&(this->nPFpart_),"nPFpart/I");
|
245 |
tree_->Branch("pfId",this->pfId_,"pfId[nPFpart]/I");
|
246 |
tree_->Branch("pfPt",this->pfPt_,"pfPt[nPFpart]/F");
|
247 |
tree_->Branch("pfEta",this->pfEta_,"pfEta[nPFpart]/F");
|
248 |
tree_->Branch("pfPhi",this->pfPhi_,"pfPhi[nPFpart]/F");
|
249 |
|
250 |
// -- jet info --
|
251 |
if(doJets){
|
252 |
tree_->Branch("njets",&(this->njets_),"njets/I");
|
253 |
tree_->Branch("jetPt",this->jetPt_,"jetPt[njets]/F");
|
254 |
tree_->Branch("jetEta",this->jetEta_,"jetEta[njets]/F");
|
255 |
tree_->Branch("jetPhi",this->jetPhi_,"jetPhi[njets]/F");
|
256 |
}
|
257 |
|
258 |
// -- gen info --
|
259 |
if(doMC){
|
260 |
tree_->Branch("nGENpart",&(this->nGENpart_),"nGENpart/I");
|
261 |
tree_->Branch("genPDGId",this->genPDGId_,"genPDGId[nGENpart]/I");
|
262 |
tree_->Branch("genPt",this->genPt_,"genPt[nGENpart]/F");
|
263 |
tree_->Branch("genEta",this->genEta_,"genEta[nGENpart]/F");
|
264 |
tree_->Branch("genPhi",this->genPhi_,"genPhi[nGENpart]/F");
|
265 |
}
|
266 |
|
267 |
}
|
268 |
void TreePFCandEventData::Clear()
|
269 |
{
|
270 |
// event
|
271 |
|
272 |
nPFpart_ = 0;
|
273 |
njets_ = 0;
|
274 |
nGENpart_ = 0;
|
275 |
}
|
276 |
|
277 |
DEFINE_FWK_MODULE(HiPFCandAnalyzer);
|