14 embeddedCaloTowers_(
false),
15 embeddedPFCandidates_(
false),
23 embeddedCaloTowers_(
false),
24 embeddedPFCandidates_(
false),
27 tryImportSpecific(aJet);
33 embeddedCaloTowers_(
false),
34 embeddedPFCandidates_(
false),
37 tryImportSpecific(*aJetRef);
43 embeddedCaloTowers_(
false),
44 embeddedPFCandidates_(
false),
47 tryImportSpecific(*aJetRef);
69 out <<
"\tpat::Jet: ";
70 out << std::setiosflags(std::ios::right);
72 out << std::setprecision(3);
73 out <<
" E/pT/eta/phi " 86 specificCalo_.push_back( (static_cast<const reco::CaloJet&>(source)).
getSpecific() );
98 edm::LogWarning(
"OptionalProductNotFound") <<
" in pat::Jet, Attempted to add Calo Specifics to JPT Jets, but failed." 99 <<
" Jet ID for JPT Jets will not be available for you." << std::endl;
102 specificPF_.push_back( (static_cast<const reco::PFJet&>(source)).
getSpecific() );
112 CaloTowerPtr Jet::getCaloConstituent (
unsigned fIndex)
const {
113 if (embeddedCaloTowers_) {
115 if ( caloTowersFwdPtr_.size() > 0 ) {
116 return (fIndex < caloTowersFwdPtr_.size() ?
121 if ( caloTowers_.size() > 0 ) {
122 return (fIndex < caloTowers_.size() ?
132 if (caloTower != 0) {
136 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
146 std::vector<CaloTowerPtr>
const & Jet::getCaloConstituents ()
const {
147 if ( !caloTowersTemp_.isSet() || caloTowers_.size() > 0 ) cacheCaloTowers();
148 return *caloTowersTemp_;
155 if (embeddedPFCandidates_) {
157 if ( pfCandidatesFwdPtr_.size() > 0 ) {
158 return (fIndex < pfCandidatesFwdPtr_.size() ?
163 if ( pfCandidates_.size() > 0 ) {
164 return (fIndex < pfCandidates_.size() ?
178 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
186 std::vector<reco::PFCandidatePtr>
const & Jet::getPFConstituents ()
const {
187 if ( !pfCandidatesTemp_.isSet() || pfCandidates_.size() > 0 ) cachePFCandidates();
188 return *pfCandidatesTemp_;
192 if (isCaloJet() || isJPTJet() ) {
193 if ( embeddedCaloTowers_ ) {
194 if ( caloTowersFwdPtr_.size() > 0 )
return caloTowersFwdPtr_[i].
get();
195 else if ( caloTowers_.size() > 0 )
return &caloTowers_[i];
200 if ( embeddedPFCandidates_ ) {
201 if ( pfCandidatesFwdPtr_.size() > 0 )
return pfCandidatesFwdPtr_[i].
get();
202 else if ( pfCandidates_.size() > 0 )
return &pfCandidates_[i];
210 if (isCaloJet() || isJPTJet()) {
211 if ( embeddedCaloTowers_ ) {
212 if ( caloTowersFwdPtr_.size() > 0 )
return caloTowersFwdPtr_.size();
213 else if ( caloTowers_.size() > 0 )
return caloTowers_.size();
218 if ( embeddedPFCandidates_ ) {
219 if ( pfCandidatesFwdPtr_.size() > 0 )
return pfCandidatesFwdPtr_.size();
220 else if ( pfCandidates_.size() > 0 )
return pfCandidates_.size();
229 if (genJet_.size())
return &(genJet_.front());
230 else if ( genJetRef_.size() )
return genJetRef_[0].
get();
231 else return genJetFwdRef_.
get();
235 int Jet::partonFlavour()
const {
236 return jetFlavourInfo_.getPartonFlavour();
240 int Jet::hadronFlavour()
const {
241 return jetFlavourInfo_.getHadronFlavour();
246 return jetFlavourInfo_;
255 currentJECLevel(level);
256 currentJECFlavor(flavor);
257 setP4(jec_[
set].correction(level, flavor)*
p4());
263 for(std::vector<pat::JetCorrFactors>::const_iterator corrFactor=jec_.begin(); corrFactor!=jec_.end(); ++corrFactor)
264 if( corrFactor->jecSet()==set ){
return (corrFactor-jec_.begin()); }
269 const std::vector<std::string> Jet::availableJECSets()
const 271 std::vector<std::string> sets;
272 for(std::vector<pat::JetCorrFactors>::const_iterator corrFactor=jec_.begin(); corrFactor!=jec_.end(); ++corrFactor)
273 sets.push_back(corrFactor->jecSet());
277 const std::vector<std::string> Jet::availableJECLevels(
const int&
set)
const 279 return set>=0 ? jec_.at(
set).correctionLabels() : std::vector<std::string>();
286 for(
unsigned int idx=0;
idx<jec_.size(); ++
idx){
287 if(
set.
empty() || jec_.at(
idx).jecSet()==
set){
288 if(jec_[
idx].jecLevel(level)>=0){
289 return jecFactor(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
292 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
296 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n" 297 <<
"for a jet energy correction set with label " <<
set <<
"\n";
302 float Jet::jecFactor(
const unsigned int& level,
const JetCorrFactors::Flavor& flavor,
const unsigned int&
set)
const 304 if(!jecSetsAvailable()){
305 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n";
307 if(!jecSetAvailable(
set)){
308 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n" 309 <<
"for a jet energy correction set with index " <<
set <<
"\n";
311 return jec_.at(
set).correction(level, flavor)/jec_.at(currentJECSet_).correction(currentJECLevel_, currentJECFlavor_);
320 for(
unsigned int idx=0;
idx<jec_.size(); ++
idx){
321 if(
set.
empty() || jec_.at(
idx).jecSet()==
set){
322 if(jec_[
idx].jecLevel(level)>=0){
323 return correctedJet(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
326 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
330 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); correctedJet.currentJECLevel(level); correctedJet.currentJECFlavor(flavor);
348 const std::vector<std::pair<std::string, float> > & Jet::getPairDiscri()
const {
349 return pairDiscriVector_;
353 float Jet::bDiscriminator(
const std::string & aLabel)
const {
355 for(
int i=(
int(pairDiscriVector_.size())-1); i>=0; i--){
356 if(pairDiscriVector_[i].
first == aLabel){
357 discriminator = pairDiscriVector_[
i].second;
365 for(
int i=(
int(tagInfoLabels_.size())-1); i>=0; i--){
366 if (tagInfoLabels_[i] == label) {
367 if ( tagInfosFwdPtr_.size() > 0 )
return tagInfosFwdPtr_[i].
get();
368 else if ( tagInfos_.size() > 0 )
return & tagInfos_[i];
377 Jet::tagInfoCandIP(
const std::string &label)
const {
378 return tagInfoByTypeOrLabel<reco::CandIPTagInfo>(
label);
382 Jet::tagInfoTrackIP(
const std::string &label)
const {
383 return tagInfoByTypeOrLabel<reco::TrackIPTagInfo>(
label);
387 Jet::tagInfoCandSoftLepton(
const std::string &label)
const {
388 return tagInfoByTypeOrLabel<reco::CandSoftLeptonTagInfo>(
label);
392 Jet::tagInfoSoftLepton(
const std::string &label)
const {
393 return tagInfoByTypeOrLabel<reco::SoftLeptonTagInfo>(
label);
397 Jet::tagInfoCandSecondaryVertex(
const std::string &label)
const {
398 return tagInfoByTypeOrLabel<reco::CandSecondaryVertexTagInfo>(
label);
402 Jet::tagInfoSecondaryVertex(
const std::string &label)
const {
403 return tagInfoByTypeOrLabel<reco::SecondaryVertexTagInfo>(
label);
407 Jet::tagInfoBoostedDoubleSV(
const std::string &label)
const {
408 return tagInfoByTypeOrLabel<reco::BoostedDoubleSVTagInfo>(
label);
415 if (idx == std::string::npos) {
416 tagInfoLabels_.push_back(label);
418 tagInfoLabels_.push_back(label.substr(0,idx));
420 tagInfosFwdPtr_.push_back(info);
426 float Jet::jetCharge()
const {
432 return associatedTracks_;
437 associatedTracks_ =
tracks;
442 caloTowersFwdPtr_.reserve(caloTowers.size());
443 for(
auto const& tower : caloTowers) {
444 caloTowersFwdPtr_.push_back( tower );
446 embeddedCaloTowers_ =
true;
447 caloTowersTemp_.reset();
453 pfCandidatesFwdPtr_.reserve(pfCandidates.size());
454 for(
auto const&
cand : pfCandidates) {
455 pfCandidatesFwdPtr_.push_back(
cand);
457 embeddedPFCandidates_ =
true;
458 pfCandidatesTemp_.reset();
471 void Jet::setPartonFlavour(
int partonFl) {
472 jetFlavourInfo_.setPartonFlavour(partonFl);
476 void Jet::setHadronFlavour(
int hadronFl) {
477 jetFlavourInfo_.setHadronFlavour(hadronFl);
482 jetFlavourInfo_ = jetFlavourInfo;
486 void Jet::addBDiscriminatorPair(
const std::pair<std::string, float> & thePair) {
487 pairDiscriVector_.push_back(thePair);
491 void Jet::setJetCharge(
float jetCharge) {
492 jetCharge_ = jetCharge;
498 void Jet::cacheCaloTowers()
const {
501 std::unique_ptr<std::vector<CaloTowerPtr>> caloTowersTemp{
new std::vector<CaloTowerPtr>{}};
502 if ( embeddedCaloTowers_ ) {
504 if ( caloTowersFwdPtr_.size() > 0 ) {
505 caloTowersTemp->reserve(caloTowersFwdPtr_.size());
506 for ( CaloTowerFwdPtrVector::const_iterator ibegin=caloTowersFwdPtr_.begin(),
507 iend = caloTowersFwdPtr_.end(),
509 icalo != iend; ++icalo ) {
510 caloTowersTemp->emplace_back( icalo->ptr() );
514 else if ( caloTowers_.size() > 0 ) {
515 caloTowersTemp->reserve(caloTowers_.size());
517 iend = caloTowers_.end(),
519 icalo != iend; ++icalo ) {
520 caloTowersTemp->emplace_back( &caloTowers_, icalo - ibegin );
527 caloTowersTemp->reserve(nDaughters);
528 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex ) {
532 caloTowersTemp->emplace_back( dau.id(), caloTower,dau.key() );
535 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
539 caloTowersTemp_.set(
std::move(caloTowersTemp));
543 void Jet::cachePFCandidates()
const {
545 std::unique_ptr<std::vector<reco::PFCandidatePtr>> pfCandidatesTemp{
new std::vector<reco::PFCandidatePtr>{}};
547 if ( embeddedPFCandidates_ ) {
549 if ( pfCandidatesFwdPtr_.size() > 0 ) {
550 pfCandidatesTemp->reserve(pfCandidatesFwdPtr_.size());
551 for ( PFCandidateFwdPtrCollection::const_iterator ibegin=pfCandidatesFwdPtr_.begin(),
552 iend = pfCandidatesFwdPtr_.end(),
554 ipf != iend; ++ipf ) {
555 pfCandidatesTemp->emplace_back( ipf->ptr() );
559 else if ( pfCandidates_.size() > 0 ) {
560 pfCandidatesTemp->reserve(pfCandidates_.size());
561 for ( reco::PFCandidateCollection::const_iterator ibegin=pfCandidates_.begin(),
562 iend = pfCandidates_.end(),
564 ipf != iend; ++ipf ) {
565 pfCandidatesTemp->emplace_back( &pfCandidates_, ipf - ibegin );
572 pfCandidatesTemp->reserve(nDaughters);
573 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex ) {
577 pfCandidatesTemp->emplace_back( dau.id(), pfCandidate,dau.key() );
580 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
585 pfCandidatesTemp_.set(
std::move(pfCandidatesTemp));
593 if ( index < subjetCollections_.size() )
594 return subjetCollections_[index];
596 throw cms::Exception(
"OutOfRange") <<
"Index " << index <<
" is out of range" << std::endl;
603 auto found =
find( subjetLabels_.begin(), subjetLabels_.end(),
label );
604 if (
found != subjetLabels_.end() ){
606 return subjetCollections_[
index];
609 throw cms::Exception(
"SubjetsNotFound") <<
"Label " << label <<
" does not match any subjet collection" << std::endl;
615 subjetCollections_.push_back( pieces );
616 subjetLabels_.push_back( label );
value_type const * get() const
virtual double pt() const final
transverse momentum
Jets made from CaloTowers.
virtual double eta() const final
momentum pseudorapidity
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
const Specific & getSpecific() const
block accessors
Base class for all types of Jets.
std::vector< CaloTower >::const_iterator const_iterator
virtual ~Jet()
Destructor.
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.
daughters dau
collection of references to daughters
virtual double phi() const final
momentum azimuthal angle
virtual size_t numberOfDaughters() const
number of 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
virtual double energy() const final
energy
Class storing the jet flavour information.
T get() const
get a component
Jets made from MC generator particles.
edm::Ptr< Candidate > Constituent
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Analysis-level calorimeter jet class.
Particle reconstructed by the particle flow algorithm.
Jet()
Default constructor.
Templated PAT object container.
edm::Ptr< CaloTower > CaloTowerPtr
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
static std::string const source
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const Specific & getSpecific() const
const Specific & getSpecific() const