1 |
loizides |
1.23 |
// $Id: FillerCaloJets.cc,v 1.22 2009/07/20 03:19:24 loizides Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerCaloJets.h"
|
4 |
loizides |
1.19 |
#include "DataFormats/JetReco/interface/Jet.h"
|
5 |
|
|
#include "DataFormats/BTauReco/interface/JetTag.h"
|
6 |
sixie |
1.5 |
#include "SimDataFormats/JetMatching/interface/JetFlavour.h"
|
7 |
|
|
#include "SimDataFormats/JetMatching/interface/JetFlavourMatching.h"
|
8 |
|
|
#include "SimDataFormats/JetMatching/interface/MatchedPartons.h"
|
9 |
|
|
#include "SimDataFormats/JetMatching/interface/JetMatchedPartons.h"
|
10 |
sixie |
1.11 |
#include "JetMETCorrections/Objects/interface/JetCorrector.h"
|
11 |
loizides |
1.19 |
#include "MitAna/DataTree/interface/CaloJetCol.h"
|
12 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
13 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
14 |
sixie |
1.8 |
|
15 |
loizides |
1.1 |
using namespace std;
|
16 |
|
|
using namespace edm;
|
17 |
|
|
using namespace mithep;
|
18 |
|
|
|
19 |
|
|
//--------------------------------------------------------------------------------------------------
|
20 |
|
|
FillerCaloJets::FillerCaloJets(const ParameterSet &cfg, const char *name, bool active) :
|
21 |
loizides |
1.4 |
BaseFiller(cfg,name,active),
|
22 |
sixie |
1.5 |
flavorMatchingActive_(Conf().getUntrackedParameter<bool>("flavorMatchingActive",true)),
|
23 |
sixie |
1.8 |
bTaggingActive_(Conf().getUntrackedParameter<bool>("bTaggingActive",true)),
|
24 |
sixie |
1.11 |
jetToVertexActive_(Conf().getUntrackedParameter<bool>("jetToVertexActive",true)),
|
25 |
|
|
jetCorrectionsActive_(Conf().getUntrackedParameter<bool>("jetCorrectionsActive",true)),
|
26 |
loizides |
1.2 |
edmName_(Conf().getUntrackedParameter<string>("edmName","recoCaloJets:iterativeCone5CaloJets")),
|
27 |
sixie |
1.11 |
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkCaloJetBrn)),
|
28 |
|
|
jetToVertexAlphaName_(Conf().getUntrackedParameter<string>
|
29 |
|
|
("jetToVertexAlphaName","jetToVertexAlpha")),
|
30 |
|
|
jetToVertexBetaName_(Conf().getUntrackedParameter<string>
|
31 |
|
|
("jetToVertexBetaName","jetToVertexBetaName")),
|
32 |
|
|
L2JetCorrectorName_(Conf().getUntrackedParameter<string>
|
33 |
|
|
("L2JetCorrectorName","L2JetCorrectorName")),
|
34 |
|
|
L3JetCorrectorName_(Conf().getUntrackedParameter<string>
|
35 |
|
|
("L3JetCorrectorName","L3JetCorrectorName")),
|
36 |
sixie |
1.5 |
flavorMatchingByReferenceName_(Conf().getUntrackedParameter<string>
|
37 |
sixie |
1.8 |
("flavorMatchingByReferenceName","srcByReference")),
|
38 |
sixie |
1.5 |
flavorMatchingDefinition_(Conf().getUntrackedParameter<string>
|
39 |
sixie |
1.8 |
("flavorMatchingDefinition","Algorithmic")),
|
40 |
|
|
jetProbabilityBJetTagsName_(Conf().getUntrackedParameter<string>
|
41 |
sixie |
1.11 |
("JetProbabilityBJetTagsName","jetProbabilityBJetTags")),
|
42 |
sixie |
1.8 |
jetBProbabilityBJetTagsName_(Conf().getUntrackedParameter<string>
|
43 |
sixie |
1.11 |
("JetBProbabilityBJetTagsName","jetBProbabilityBJetTags")),
|
44 |
sixie |
1.8 |
simpleSecondaryVertexBJetTagsName_(Conf().getUntrackedParameter<string>
|
45 |
sixie |
1.11 |
("SimpleSecondaryVertexBJetTagsName","simpleSecondaryVertexBJetTags")),
|
46 |
sixie |
1.8 |
combinedSecondaryVertexBJetTagsName_(Conf().getUntrackedParameter<string>
|
47 |
sixie |
1.11 |
("CombinedSecondaryVertexBJetTagsName","combinedSecondaryVertexBJetTags")),
|
48 |
sixie |
1.8 |
combinedSecondaryVertexMVABJetTagsName_(Conf().getUntrackedParameter<string>
|
49 |
sixie |
1.11 |
("CombinedSecondaryVertexMVABJetTagsName","combinedSecondaryVertexMVABJetTags")),
|
50 |
sixie |
1.8 |
trackCountingHighEffBJetTagsName_(Conf().getUntrackedParameter<string>
|
51 |
sixie |
1.11 |
("TrackCountingHighEffBJetTagsName","trackCountingHighEffBJetTags")),
|
52 |
sixie |
1.8 |
trackCountingHighPurBJetTagsName_(Conf().getUntrackedParameter<string>
|
53 |
sixie |
1.11 |
("TrackCountingHighPurBJetTagsName","trackCountingHighPurBJetTags")),
|
54 |
sixie |
1.8 |
softMuonBJetTagsName_(Conf().getUntrackedParameter<string>
|
55 |
sixie |
1.11 |
("SoftMuonBJetTagsName","softMuonBJetTags")),
|
56 |
bendavid |
1.21 |
softMuonByIP3dBJetTagsName_(Conf().getUntrackedParameter<string>
|
57 |
|
|
("SoftMuonByIP3dBJetTagsName","softMuonByIP3dBJetTags")),
|
58 |
|
|
softMuonByPtBJetTagsName_(Conf().getUntrackedParameter<string>
|
59 |
|
|
("SoftMuonByPtBJetTagsName","softMuonByPtBJetTags")),
|
60 |
|
|
softElectronByIP3dBJetTagsName_(Conf().getUntrackedParameter<string>
|
61 |
|
|
("SoftElectronByIP3dBJetTagsName","softElectronByIP3dBJetTags")),
|
62 |
|
|
softElectronByPtBJetTagsName_(Conf().getUntrackedParameter<string>
|
63 |
|
|
("SoftElectronByPtBJetTagsName","softElectronByPtBJetTags")),
|
64 |
loizides |
1.9 |
caloTowerMapName_(Conf().getUntrackedParameter<string>("caloTowerMapName","CaloTowerMap")),
|
65 |
bendavid |
1.17 |
jetMapName_(Conf().getUntrackedParameter<string>("jetMapName","CaloJetMap")),
|
66 |
bendavid |
1.7 |
caloTowerMap_(0),
|
67 |
bendavid |
1.17 |
jetMap_(new mithep::CaloJetMap),
|
68 |
bendavid |
1.15 |
jets_(new mithep::CaloJetArr(16))
|
69 |
loizides |
1.1 |
{
|
70 |
|
|
// Constructor.
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
//--------------------------------------------------------------------------------------------------
|
74 |
|
|
FillerCaloJets::~FillerCaloJets()
|
75 |
|
|
{
|
76 |
|
|
// Destructor.
|
77 |
|
|
|
78 |
|
|
delete jets_;
|
79 |
bendavid |
1.17 |
delete jetMap_;
|
80 |
loizides |
1.1 |
}
|
81 |
|
|
|
82 |
|
|
//--------------------------------------------------------------------------------------------------
|
83 |
loizides |
1.23 |
void FillerCaloJets::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
|
84 |
loizides |
1.1 |
{
|
85 |
|
|
// Add jets branch to tree.
|
86 |
|
|
|
87 |
loizides |
1.16 |
tws.AddBranch(mitName_,&jets_);
|
88 |
|
|
OS()->add<mithep::CaloJetArr>(jets_,mitName_);
|
89 |
bendavid |
1.7 |
|
90 |
loizides |
1.16 |
if (!caloTowerMapName_.empty()) {
|
91 |
|
|
caloTowerMap_ = OS()->get<CaloTowerMap>(caloTowerMapName_);
|
92 |
|
|
if (caloTowerMap_)
|
93 |
|
|
AddBranchDep(mitName_, caloTowerMap_->GetBrName());
|
94 |
|
|
}
|
95 |
bendavid |
1.17 |
if (!jetMapName_.empty()) {
|
96 |
|
|
jetMap_->SetBrName(mitName_);
|
97 |
|
|
OS()->add<CaloJetMap>(jetMap_,jetMapName_);
|
98 |
|
|
}
|
99 |
loizides |
1.1 |
}
|
100 |
|
|
|
101 |
|
|
//--------------------------------------------------------------------------------------------------
|
102 |
|
|
void FillerCaloJets::FillDataBlock(const edm::Event &event,
|
103 |
|
|
const edm::EventSetup &setup)
|
104 |
|
|
{
|
105 |
|
|
// Fill jets from edm collection into our collection.
|
106 |
|
|
|
107 |
bendavid |
1.13 |
jets_->Delete();
|
108 |
bendavid |
1.17 |
jetMap_->Reset();
|
109 |
loizides |
1.1 |
|
110 |
loizides |
1.16 |
// handle for the jet collection
|
111 |
sixie |
1.8 |
Handle<reco::CaloJetCollection> hJetProduct;
|
112 |
|
|
GetProduct(edmName_, hJetProduct, event);
|
113 |
|
|
|
114 |
loizides |
1.16 |
// handles for jet flavour matching
|
115 |
sixie |
1.6 |
Handle<reco::JetMatchedPartonsCollection> hPartonMatchingProduct;
|
116 |
|
|
if (flavorMatchingActive_)
|
117 |
|
|
GetProduct(flavorMatchingByReferenceName_, hPartonMatchingProduct, event);
|
118 |
sixie |
1.5 |
|
119 |
sixie |
1.8 |
Handle<reco::JetTagCollection> hJetProbabilityBJetTags;
|
120 |
|
|
Handle<reco::JetTagCollection> hJetBProbabilityBJetTags;
|
121 |
|
|
Handle<reco::JetTagCollection> hSimpleSecondaryVertexBJetTags;
|
122 |
|
|
Handle<reco::JetTagCollection> hCombinedSecondaryVertexBJetTags;
|
123 |
|
|
Handle<reco::JetTagCollection> hCombinedSecondaryVertexMVABJetTags;
|
124 |
|
|
Handle<reco::JetTagCollection> hTrackCountingHighEffBJetTags;
|
125 |
|
|
Handle<reco::JetTagCollection> hTrackCountingHighPurBJetTags;
|
126 |
|
|
Handle<reco::JetTagCollection> hSoftMuonBJetTags;
|
127 |
bendavid |
1.21 |
Handle<reco::JetTagCollection> hSoftMuonByIP3dBJetTags;
|
128 |
|
|
Handle<reco::JetTagCollection> hSoftMuonByPtBJetTags;
|
129 |
|
|
Handle<reco::JetTagCollection> hSoftElectronByIP3dBJetTags;
|
130 |
|
|
Handle<reco::JetTagCollection> hSoftElectronByPtBJetTags;
|
131 |
sixie |
1.8 |
|
132 |
|
|
if (bTaggingActive_) {
|
133 |
sixie |
1.11 |
GetProduct(jetProbabilityBJetTagsName_, hJetProbabilityBJetTags, event);
|
134 |
|
|
GetProduct(jetBProbabilityBJetTagsName_, hJetBProbabilityBJetTags, event);
|
135 |
|
|
GetProduct(simpleSecondaryVertexBJetTagsName_, hSimpleSecondaryVertexBJetTags, event);
|
136 |
|
|
GetProduct(combinedSecondaryVertexBJetTagsName_, hCombinedSecondaryVertexBJetTags, event);
|
137 |
loizides |
1.22 |
GetProduct(combinedSecondaryVertexMVABJetTagsName_, hCombinedSecondaryVertexMVABJetTags, event);
|
138 |
sixie |
1.11 |
GetProduct(trackCountingHighEffBJetTagsName_, hTrackCountingHighEffBJetTags, event);
|
139 |
|
|
GetProduct(trackCountingHighPurBJetTagsName_, hTrackCountingHighPurBJetTags, event);
|
140 |
|
|
GetProduct(softMuonBJetTagsName_, hSoftMuonBJetTags, event);
|
141 |
bendavid |
1.21 |
GetProduct(softMuonByIP3dBJetTagsName_, hSoftMuonByIP3dBJetTags, event);
|
142 |
|
|
GetProduct(softMuonByPtBJetTagsName_, hSoftMuonByPtBJetTags, event);
|
143 |
|
|
GetProduct(softElectronByIP3dBJetTagsName_, hSoftElectronByIP3dBJetTags, event);
|
144 |
|
|
GetProduct(softElectronByPtBJetTagsName_, hSoftElectronByPtBJetTags, event);
|
145 |
sixie |
1.11 |
}
|
146 |
|
|
|
147 |
|
|
const reco::CaloJetCollection inJets = *(hJetProduct.product());
|
148 |
|
|
|
149 |
loizides |
1.16 |
// handle to Jet to Vertex association
|
150 |
sixie |
1.11 |
Handle<std::vector<double> > JV_alpha;
|
151 |
|
|
Handle<std::vector<double> > JV_beta;
|
152 |
|
|
std::vector<double>::const_iterator it_jv_alpha;
|
153 |
|
|
std::vector<double>::const_iterator it_jv_beta;
|
154 |
|
|
|
155 |
|
|
if (jetToVertexActive_) {
|
156 |
|
|
GetProduct(jetToVertexAlphaName_, JV_alpha, event);
|
157 |
|
|
GetProduct(jetToVertexBetaName_, JV_beta, event);
|
158 |
|
|
it_jv_alpha = JV_alpha->begin();
|
159 |
|
|
it_jv_beta = JV_beta->begin();
|
160 |
sixie |
1.8 |
}
|
161 |
|
|
|
162 |
loizides |
1.16 |
// define jet correction services
|
163 |
loizides |
1.12 |
const JetCorrector* correctorL2 = 0;
|
164 |
|
|
const JetCorrector* correctorL3 = 0;
|
165 |
sixie |
1.11 |
if (jetCorrectionsActive_) {
|
166 |
|
|
correctorL2 = JetCorrector::getJetCorrector (L2JetCorrectorName_,setup);
|
167 |
|
|
correctorL3 = JetCorrector::getJetCorrector (L3JetCorrectorName_,setup);
|
168 |
|
|
}
|
169 |
loizides |
1.1 |
|
170 |
|
|
// loop through all jets
|
171 |
|
|
for (reco::CaloJetCollection::const_iterator inJet = inJets.begin();
|
172 |
|
|
inJet != inJets.end(); ++inJet) {
|
173 |
sixie |
1.8 |
|
174 |
|
|
reco::CaloJetRef jetRef(hJetProduct, inJet - inJets.begin());
|
175 |
|
|
reco::JetBaseRef jetBaseRef(jetRef);
|
176 |
|
|
|
177 |
bendavid |
1.15 |
mithep::CaloJet *jet = jets_->Allocate();
|
178 |
|
|
new (jet) mithep::CaloJet(inJet->p4().x(),
|
179 |
loizides |
1.3 |
inJet->p4().y(),
|
180 |
|
|
inJet->p4().z(),
|
181 |
|
|
inJet->p4().e());
|
182 |
|
|
|
183 |
loizides |
1.18 |
// add to map
|
184 |
bendavid |
1.17 |
edm::Ptr<reco::CaloJet> thePtr(hJetProduct, inJet - inJets.begin());
|
185 |
|
|
jetMap_->Add(thePtr, jet);
|
186 |
|
|
|
187 |
loizides |
1.16 |
// fill calojet-specific quantities
|
188 |
loizides |
1.3 |
jet->SetMaxEInEmTowers (inJet->maxEInEmTowers());
|
189 |
|
|
jet->SetMaxEInHadTowers(inJet->maxEInHadTowers());
|
190 |
|
|
jet->SetEnergyFractionH(inJet->energyFractionHadronic());
|
191 |
bendavid |
1.15 |
jet->SetEnergyFractionEm(inJet->emEnergyFraction());
|
192 |
loizides |
1.3 |
jet->SetHadEnergyInHB (inJet->hadEnergyInHB());
|
193 |
|
|
jet->SetHadEnergyInHO (inJet->hadEnergyInHO());
|
194 |
|
|
jet->SetHadEnergyInHE (inJet->hadEnergyInHE());
|
195 |
|
|
jet->SetHadEnergyInHF (inJet->hadEnergyInHF());
|
196 |
|
|
jet->SetEmEnergyInEB (inJet->emEnergyInEB());
|
197 |
|
|
jet->SetEmEnergyInEE (inJet->emEnergyInEE());
|
198 |
|
|
jet->SetEmEnergyInHF (inJet->emEnergyInHF());
|
199 |
|
|
jet->SetTowersArea (inJet->towersArea());
|
200 |
sixie |
1.11 |
|
201 |
|
|
if (jetToVertexActive_) {
|
202 |
loizides |
1.16 |
// compute alpha and beta parameter for jets
|
203 |
sixie |
1.11 |
jet->SetAlpha((*it_jv_alpha));
|
204 |
|
|
jet->SetBeta((*it_jv_beta));
|
205 |
|
|
}
|
206 |
|
|
|
207 |
loizides |
1.16 |
// jet corrections
|
208 |
sixie |
1.11 |
if (jetCorrectionsActive_) {
|
209 |
|
|
double L2Scale = correctorL2->correction(inJet->p4());
|
210 |
|
|
double L3Scale = correctorL3->correction(inJet->p4()*L2Scale);
|
211 |
|
|
jet->SetL2RelativeCorrectionScale(L2Scale);
|
212 |
bendavid |
1.14 |
jet->SetL3AbsoluteCorrectionScale(L3Scale);
|
213 |
bendavid |
1.15 |
jet->EnableCorrection(mithep::CaloJet::L2);
|
214 |
|
|
jet->EnableCorrection(mithep::CaloJet::L3);
|
215 |
sixie |
1.11 |
}
|
216 |
|
|
|
217 |
sixie |
1.8 |
if (bTaggingActive_) {
|
218 |
|
|
jet->SetJetProbabilityBJetTagsDisc((*(hJetProbabilityBJetTags.product()))[jetBaseRef]);
|
219 |
bendavid |
1.14 |
jet->SetJetBProbabilityBJetTagsDisc((*(hJetBProbabilityBJetTags.product()))[jetBaseRef]);
|
220 |
loizides |
1.16 |
jet->SetSimpleSecondaryVertexBJetTagsDisc(
|
221 |
|
|
(*(hSimpleSecondaryVertexBJetTags.product()))[jetBaseRef]);
|
222 |
|
|
jet->SetCombinedSecondaryVertexBJetTagsDisc(
|
223 |
|
|
(*(hCombinedSecondaryVertexBJetTags.product()))[jetBaseRef]);
|
224 |
|
|
jet->SetCombinedSecondaryVertexMVABJetTagsDisc(
|
225 |
|
|
(*(hCombinedSecondaryVertexMVABJetTags.product()))[jetBaseRef]);
|
226 |
|
|
jet->SetTrackCountingHighEffBJetTagsDisc(
|
227 |
|
|
(*(hTrackCountingHighEffBJetTags.product()))[jetBaseRef]);
|
228 |
|
|
jet->SetTrackCountingHighPurBJetTagsDisc(
|
229 |
|
|
(*(hTrackCountingHighPurBJetTags.product()))[jetBaseRef]);
|
230 |
sixie |
1.8 |
jet->SetSoftMuonBJetTagsDisc((*(hSoftMuonBJetTags.product()))[jetBaseRef]);
|
231 |
bendavid |
1.21 |
jet->SetSoftMuonByIP3dBJetTagsDisc((*(hSoftMuonByIP3dBJetTags.product()))[jetBaseRef]);
|
232 |
|
|
jet->SetSoftMuonByPtBJetTagsDisc((*(hSoftMuonByPtBJetTags.product()))[jetBaseRef]);
|
233 |
loizides |
1.22 |
jet->SetSoftElectronByIP3dBJetTagsDisc((*(hSoftElectronByIP3dBJetTags.product()))[jetBaseRef]);
|
234 |
bendavid |
1.21 |
jet->SetSoftElectronByPtBJetTagsDisc((*(hSoftElectronByPtBJetTags.product()))[jetBaseRef]);
|
235 |
sixie |
1.8 |
}
|
236 |
|
|
|
237 |
loizides |
1.16 |
// get the Monte Carlo flavour matching information
|
238 |
sixie |
1.6 |
if (flavorMatchingActive_) {
|
239 |
|
|
unsigned int iJet = inJet - inJets.begin();
|
240 |
|
|
const reco::JetMatchedPartonsCollection *matchedPartons = hPartonMatchingProduct.product();
|
241 |
|
|
reco::MatchedPartons matchedParton = (*matchedPartons)[matchedPartons->key(iJet)];
|
242 |
|
|
int flavorPhysDef = (matchedParton.physicsDefinitionParton().isNonnull())?
|
243 |
|
|
matchedParton.physicsDefinitionParton()->pdgId():0;
|
244 |
|
|
int flavorAlgDef = (matchedParton.algoDefinitionParton().isNonnull())?
|
245 |
|
|
matchedParton.algoDefinitionParton()->pdgId():0;
|
246 |
|
|
|
247 |
|
|
if (flavorMatchingDefinition_ == "Algorithmic") {
|
248 |
|
|
jet->SetMatchedMCFlavor(flavorAlgDef);
|
249 |
|
|
} else if(flavorMatchingDefinition_ == "Physics") {
|
250 |
|
|
jet->SetMatchedMCFlavor(flavorPhysDef);
|
251 |
|
|
} else {
|
252 |
|
|
jet->SetMatchedMCFlavor(0);
|
253 |
|
|
}
|
254 |
sixie |
1.5 |
}
|
255 |
bendavid |
1.7 |
|
256 |
loizides |
1.16 |
// add CaloTower references
|
257 |
bendavid |
1.7 |
if (caloTowerMap_) {
|
258 |
|
|
std::vector<CaloTowerDetId> ctidVector = inJet->getTowerIndices();
|
259 |
loizides |
1.12 |
for(std::vector<CaloTowerDetId>::const_iterator ctid = ctidVector.begin();
|
260 |
|
|
ctid != ctidVector.end(); ++ctid) {
|
261 |
bendavid |
1.7 |
mithep::CaloTower *caloTower = caloTowerMap_->GetMit(*ctid);
|
262 |
|
|
jet->AddTower(caloTower);
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
sixie |
1.11 |
if (jetToVertexActive_) {
|
266 |
|
|
it_jv_alpha++;
|
267 |
|
|
it_jv_beta++;
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
loizides |
1.1 |
jets_->Trim();
|
271 |
|
|
}
|