18 tryImportSpecific(aJet);
24 tryImportSpecific(*aJetRef);
30 tryImportSpecific(*aJetRef);
45 out <<
"\tpat::Jet: ";
46 out << std::setiosflags(std::ios::right);
48 out << std::setprecision(3);
49 out <<
" E/pT/eta/phi " << obj.
energy() <<
"/" << obj.
pt() <<
"/" << obj.
eta() <<
"/" << obj.
phi();
57 specificCalo_.push_back((static_cast<const reco::CaloJet&>(source)).
getSpecific());
65 if (caloJet !=
nullptr) {
69 <<
" in pat::Jet, Attempted to add Calo Specifics to JPT Jets, but failed." 70 <<
" Jet ID for JPT Jets will not be available for you." << std::endl;
73 specificPF_.push_back((static_cast<const reco::PFJet&>(source)).
getSpecific());
82 CaloTowerPtr Jet::getCaloConstituent(
unsigned fIndex)
const {
83 if (embeddedCaloTowers_) {
85 if (!caloTowersFwdPtr_.empty()) {
86 return (fIndex < caloTowersFwdPtr_.size() ? caloTowersFwdPtr_[fIndex].ptr() :
CaloTowerPtr());
90 if (!caloTowers_.empty()) {
99 if (caloTower !=
nullptr) {
102 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
109 std::vector<CaloTowerPtr>
const& Jet::getCaloConstituents()
const {
110 if (!caloTowersTemp_.isSet() || !caloTowers_.empty())
112 return *caloTowersTemp_;
118 if (embeddedPFCandidates_) {
120 if (!pfCandidatesFwdPtr_.empty()) {
121 return (fIndex < pfCandidatesFwdPtr_.size() ? pfCandidatesFwdPtr_[fIndex].ptr() :
reco::PFCandidatePtr());
125 if (!pfCandidates_.empty()) {
137 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
144 std::vector<reco::PFCandidatePtr>
const& Jet::getPFConstituents()
const {
145 if (!pfCandidatesTemp_.isSet() || !pfCandidates_.empty())
147 return *pfCandidatesTemp_;
151 if (isCaloJet() || isJPTJet()) {
152 if (embeddedCaloTowers_) {
153 if (!caloTowersFwdPtr_.empty())
154 return caloTowersFwdPtr_[i].
get();
155 else if (!caloTowers_.empty())
156 return &caloTowers_[i];
162 if (embeddedPFCandidates_) {
163 if (!pfCandidatesFwdPtr_.empty())
164 return pfCandidatesFwdPtr_[i].
get();
165 else if (!pfCandidates_.empty())
166 return &pfCandidates_[i];
171 if (!subjetCollections_.empty()) {
172 if (!daughtersTemp_.isSet())
174 return daughtersTemp_->at(i).get();
180 if (!subjetCollections_.empty()) {
181 if (!daughtersTemp_.isSet())
183 return daughtersTemp_->at(i);
189 if (!subjetCollections_.empty()) {
190 if (!daughtersTemp_.isSet())
192 return *daughtersTemp_;
198 if (isCaloJet() || isJPTJet()) {
199 if (embeddedCaloTowers_) {
200 if (!caloTowersFwdPtr_.empty())
201 return caloTowersFwdPtr_.size();
202 else if (!caloTowers_.empty())
203 return caloTowers_.size();
209 if (embeddedPFCandidates_) {
210 if (!pfCandidatesFwdPtr_.empty())
211 return pfCandidatesFwdPtr_.size();
212 else if (!pfCandidates_.empty())
213 return pfCandidates_.size();
218 if (!subjetCollections_.empty()) {
219 if (!daughtersTemp_.isSet())
221 return daughtersTemp_->size();
228 if (!genJet_.empty())
229 return &(genJet_.front());
230 else if (!genJetRef_.empty())
231 return genJetRef_[0].
get();
233 return genJetFwdRef_.
get();
249 if (jecSetsAvailable()) {
251 jec_[0].insertFactor(0, std::make_pair(level, factors));
259 currentJECLevel(level);
260 currentJECFlavor(flavor);
266 for (std::vector<pat::JetCorrFactors>::const_iterator corrFactor = jec_.begin(); corrFactor != jec_.end();
268 if (corrFactor->jecSet() ==
set) {
269 return (corrFactor - jec_.begin());
275 const std::vector<std::string> Jet::availableJECSets()
const {
276 std::vector<std::string> sets;
277 for (std::vector<pat::JetCorrFactors>::const_iterator corrFactor = jec_.begin(); corrFactor != jec_.end();
279 sets.push_back(corrFactor->jecSet());
283 const std::vector<std::string> Jet::availableJECLevels(
const int&
set)
const {
284 return set >= 0 ? jec_.at(
set).correctionLabels() : std::vector<std::string>();
290 for (
unsigned int idx = 0;
idx < jec_.size(); ++
idx) {
291 if (
set.
empty() || jec_.at(
idx).jecSet() ==
set) {
292 if (jec_[
idx].jecLevel(level) >= 0) {
293 return jecFactor(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
295 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
299 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n" 300 <<
"for a jet energy correction set with label " <<
set <<
"\n";
305 float Jet::jecFactor(
const unsigned int& level,
const JetCorrFactors::Flavor& flavor,
const unsigned int&
set)
const {
306 if (!jecSetsAvailable()) {
307 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n";
309 if (!jecSetAvailable(
set)) {
310 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n" 311 <<
"for a jet energy correction set with index " <<
set <<
"\n";
313 return jec_.at(
set).correction(level, flavor) /
314 jec_.at(currentJECSet_).correction(currentJECLevel_, currentJECFlavor_);
322 for (
unsigned int idx = 0;
idx < jec_.size(); ++
idx) {
323 if (
set.
empty() || jec_.at(
idx).jecSet() ==
set) {
324 if (jec_[
idx].jecLevel(level) >= 0) {
325 return correctedJet(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
327 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
331 throw cms::Exception(
"InvalidRequest") <<
"This JEC set " <<
set <<
" does not exist. \n";
337 Jet correctedJet(*
this);
339 correctedJet.
setP4(jecFactor(level, flavor,
set) *
p4());
341 correctedJet.currentJECSet(
set);
342 correctedJet.currentJECLevel(level);
343 correctedJet.currentJECFlavor(flavor);
349 const std::vector<std::pair<std::string, float>>& Jet::getPairDiscri()
const {
return pairDiscriVector_; }
352 float Jet::bDiscriminator(
const std::string& aLabel)
const {
354 for (
int i = (
int(pairDiscriVector_.size()) - 1); i >= 0; i--) {
355 if (pairDiscriVector_[i].
first == aLabel) {
356 discriminator = pairDiscriVector_[
i].second;
364 for (
int i = (
int(tagInfoLabels_.size()) - 1); i >= 0; i--) {
365 if (tagInfoLabels_[i] == label) {
366 if (!tagInfosFwdPtr_.empty())
367 return tagInfosFwdPtr_[i].
get();
368 else if (!tagInfos_.empty())
369 return &tagInfos_[i];
377 return tagInfoByTypeOrLabel<reco::CandIPTagInfo>(
label);
381 return tagInfoByTypeOrLabel<reco::TrackIPTagInfo>(
label);
385 return tagInfoByTypeOrLabel<reco::CandSoftLeptonTagInfo>(
label);
389 return tagInfoByTypeOrLabel<reco::SoftLeptonTagInfo>(
label);
393 return tagInfoByTypeOrLabel<reco::CandSecondaryVertexTagInfo>(
label);
397 return tagInfoByTypeOrLabel<reco::SecondaryVertexTagInfo>(
label);
401 return tagInfoByTypeOrLabel<reco::BoostedDoubleSVTagInfo>(
label);
405 return tagInfoByTypeOrLabel<reco::PixelClusterTagInfo>(
label);
410 if (idx == std::string::npos) {
411 tagInfoLabels_.push_back(label);
413 tagInfoLabels_.push_back(label.substr(0, idx));
415 tagInfosFwdPtr_.push_back(info);
419 float Jet::jetCharge()
const {
return jetCharge_; }
429 caloTowersFwdPtr_.reserve(caloTowers.size());
430 for (
auto const&
tower : caloTowers) {
431 caloTowersFwdPtr_.push_back(
tower);
433 embeddedCaloTowers_ =
true;
434 caloTowersTemp_.reset();
439 pfCandidatesFwdPtr_.reserve(pfCandidates.size());
440 for (
auto const&
cand : pfCandidates) {
441 pfCandidatesFwdPtr_.push_back(
cand);
443 embeddedPFCandidates_ =
true;
444 pfCandidatesTemp_.reset();
451 void Jet::setPartonFlavour(
int partonFl) { jetFlavourInfo_.setPartonFlavour(partonFl); }
454 void Jet::setHadronFlavour(
int hadronFl) { jetFlavourInfo_.setHadronFlavour(hadronFl); }
457 void Jet::setJetFlavourInfo(
const reco::JetFlavourInfo& jetFlavourInfo) { jetFlavourInfo_ = jetFlavourInfo; }
460 void Jet::addBDiscriminatorPair(
const std::pair<std::string, float>& thePair) { pairDiscriVector_.push_back(thePair); }
463 void Jet::setJetCharge(
float jetCharge) { jetCharge_ = jetCharge; }
466 void Jet::cacheCaloTowers()
const {
469 std::unique_ptr<std::vector<CaloTowerPtr>> caloTowersTemp{
new std::vector<CaloTowerPtr>{}};
470 if (embeddedCaloTowers_) {
472 if (!caloTowersFwdPtr_.empty()) {
473 caloTowersTemp->reserve(caloTowersFwdPtr_.size());
474 for (CaloTowerFwdPtrVector::const_iterator ibegin = caloTowersFwdPtr_.begin(),
475 iend = caloTowersFwdPtr_.end(),
479 caloTowersTemp->emplace_back(icalo->ptr());
483 else if (!caloTowers_.empty()) {
484 caloTowersTemp->reserve(caloTowers_.size());
488 caloTowersTemp->emplace_back(&caloTowers_, icalo - ibegin);
495 caloTowersTemp->reserve(nDaughters);
496 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex) {
500 caloTowersTemp->emplace_back(dau.id(), caloTower, dau.key());
502 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
506 caloTowersTemp_.set(
std::move(caloTowersTemp));
510 void Jet::cachePFCandidates()
const {
511 std::unique_ptr<std::vector<reco::PFCandidatePtr>> pfCandidatesTemp{
new std::vector<reco::PFCandidatePtr>{}};
513 if (embeddedPFCandidates_) {
515 if (!pfCandidatesFwdPtr_.empty()) {
516 pfCandidatesTemp->reserve(pfCandidatesFwdPtr_.size());
517 for (PFCandidateFwdPtrCollection::const_iterator ibegin = pfCandidatesFwdPtr_.begin(),
518 iend = pfCandidatesFwdPtr_.end(),
522 pfCandidatesTemp->emplace_back(ipf->ptr());
526 else if (!pfCandidates_.empty()) {
527 pfCandidatesTemp->reserve(pfCandidates_.size());
528 for (reco::PFCandidateCollection::const_iterator ibegin = pfCandidates_.begin(),
529 iend = pfCandidates_.end(),
533 pfCandidatesTemp->emplace_back(&pfCandidates_, ipf - ibegin);
540 pfCandidatesTemp->reserve(nDaughters);
541 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex) {
545 pfCandidatesTemp->emplace_back(dau.id(), pfCandidate, dau.key());
547 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
552 pfCandidatesTemp_.set(
std::move(pfCandidatesTemp));
556 void Jet::cacheDaughters()
const {
558 std::unique_ptr<std::vector<reco::CandidatePtr>> daughtersTemp{
new std::vector<reco::CandidatePtr>{}};
565 daughtersTemp->insert(daughtersTemp->end(), sjdaus.begin(), sjdaus.end());
568 daughtersTemp->push_back(
dau);
570 daughtersTemp_.set(
std::move(daughtersTemp));
575 if (index < subjetCollections_.size())
576 return subjetCollections_[index];
578 throw cms::Exception(
"OutOfRange") <<
"Index " << index <<
" is out of range" << std::endl;
584 auto found =
find(subjetLabels_.begin(), subjetLabels_.end(),
label);
585 if (
found != subjetLabels_.end()) {
587 return subjetCollections_[
index];
590 <<
"Label " << label <<
" does not match any subjet collection" << std::endl;
596 subjetCollections_.push_back(pieces);
597 subjetLabels_.push_back(label);
value_type const * get() const
double eta() const final
momentum pseudorapidity
Jets made from CaloTowers.
virtual void scaleEnergy(double fScale)
scale energy of the jet
const Specific & getSpecific() const
block accessors
Base class for all types of Jets.
std::vector< CaloTower >::const_iterator const_iterator
double pt() const final
transverse momentum
bool isNonnull() const
Checks for non-null.
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Jets made from PFObjects.
virtual const daughters & daughterPtrVector() const
references to daughtes
size_t numberOfDaughters() const override
number of daughters
daughters dau
collection of references to daughters
Container::value_type value_type
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Jets made from CaloJets corrected for ZSP and tracks.
std::vector< edm::Ptr< pat::Jet > > JetPtrCollection
Class storing the jet flavour information.
double energy() const final
energy
T get() const
get a component
Jets made from MC generator particles.
const LorentzVector & p4() const final
four-momentum Lorentz vector
~Jet() override
Destructor.
edm::Ptr< Candidate > Constituent
std::vector< CandidatePtr > daughters
collection of references to daughters
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
Analysis-level calorimeter jet class.
Particle reconstructed by the particle flow algorithm.
Jet()
Default constructor.
Templated PAT object container.
edm::Ptr< CaloTower > CaloTowerPtr
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
double phi() const final
momentum azimuthal angle
static std::string const source
void setP4(const LorentzVector &p4) final
set 4-momentum
const Specific & getSpecific() const
const Specific & getSpecific() const