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);
55 out <<
"\tpat::Jet: ";
56 out << std::setiosflags(std::ios::right);
57 out << std::setiosflags(std::ios::fixed);
58 out << std::setprecision(3);
59 out <<
" E/pT/eta/phi "
72 specificCalo_.push_back( (static_cast<const reco::CaloJet&>(source)).getSpecific() );
84 edm::LogWarning(
"OptionalProductNotFound") <<
" in pat::Jet, Attempted to add Calo Specifics to JPT Jets, but failed."
85 <<
" Jet ID for JPT Jets will not be available for you." << std::endl;
88 specificPF_.push_back( (static_cast<const reco::PFJet&>(source)).getSpecific() );
98 CaloTowerPtr Jet::getCaloConstituent (
unsigned fIndex)
const {
99 if (embeddedCaloTowers_) {
101 if ( caloTowersFwdPtr_.size() > 0 ) {
102 return (fIndex < caloTowersFwdPtr_.size() ?
107 if ( caloTowers_.size() > 0 ) {
108 return (fIndex < caloTowers_.size() ?
116 Constituent dau = daughterPtr (fIndex);
118 if (caloTower != 0) {
122 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
132 std::vector<CaloTowerPtr>
const & Jet::getCaloConstituents ()
const {
133 if ( !caloTowersTemp_.isSet() || caloTowers_.size() > 0 ) cacheCaloTowers();
134 return *caloTowersTemp_;
141 if (embeddedPFCandidates_) {
143 if ( pfCandidatesFwdPtr_.size() > 0 ) {
144 return (fIndex < pfCandidatesFwdPtr_.size() ?
149 if ( pfCandidates_.size() > 0 ) {
150 return (fIndex < pfCandidates_.size() ?
158 Constituent dau = daughterPtr (fIndex);
164 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
172 std::vector<reco::PFCandidatePtr>
const & Jet::getPFConstituents ()
const {
173 if ( !pfCandidatesTemp_.isSet() || pfCandidates_.size() > 0 ) cachePFCandidates();
174 return *pfCandidatesTemp_;
178 if (isCaloJet() || isJPTJet() ) {
179 if ( embeddedCaloTowers_ ) {
180 if ( caloTowersFwdPtr_.size() > 0 )
return caloTowersFwdPtr_[i].
get();
181 else if ( caloTowers_.size() > 0 )
return &caloTowers_[i];
186 if ( embeddedPFCandidates_ ) {
187 if ( pfCandidatesFwdPtr_.size() > 0 )
return pfCandidatesFwdPtr_[i].
get();
188 else if ( pfCandidates_.size() > 0 )
return &pfCandidates_[i];
196 if (isCaloJet() || isJPTJet()) {
197 if ( embeddedCaloTowers_ ) {
198 if ( caloTowersFwdPtr_.size() > 0 )
return caloTowersFwdPtr_.size();
199 else if ( caloTowers_.size() > 0 )
return caloTowers_.size();
204 if ( embeddedPFCandidates_ ) {
205 if ( pfCandidatesFwdPtr_.size() > 0 )
return pfCandidatesFwdPtr_.size();
206 else if ( pfCandidates_.size() > 0 )
return pfCandidates_.size();
215 if (genJet_.size())
return &(genJet_.front());
216 else if ( genJetRef_.size() )
return genJetRef_[0].
get();
217 else return genJetFwdRef_.
get();
221 int Jet::partonFlavour()
const {
222 return jetFlavourInfo_.getPartonFlavour();
226 int Jet::hadronFlavour()
const {
227 return jetFlavourInfo_.getHadronFlavour();
232 return jetFlavourInfo_;
241 currentJECLevel(level);
242 currentJECFlavor(flavor);
243 setP4(jec_[set].correction(level, flavor)*
p4());
249 for(std::vector<pat::JetCorrFactors>::const_iterator corrFactor=jec_.begin(); corrFactor!=jec_.end(); ++corrFactor)
250 if( corrFactor->jecSet()==set ){
return (corrFactor-jec_.begin()); }
255 const std::vector<std::string> Jet::availableJECSets()
const
257 std::vector<std::string> sets;
258 for(std::vector<pat::JetCorrFactors>::const_iterator corrFactor=jec_.begin(); corrFactor!=jec_.end(); ++corrFactor)
259 sets.push_back(corrFactor->jecSet());
263 const std::vector<std::string> Jet::availableJECLevels(
const int& set)
const
265 return set>=0 ? jec_.at(set).correctionLabels() : std::vector<std::string>();
272 for(
unsigned int idx=0;
idx<jec_.size(); ++
idx){
273 if(set.empty() || jec_.at(
idx).jecSet()==set){
274 if(jec_[
idx].jecLevel(level)>=0){
275 return jecFactor(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
278 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
282 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n"
283 <<
"for a jet energy correction set with label " << set <<
"\n";
288 float Jet::jecFactor(
const unsigned int& level,
const JetCorrFactors::Flavor& flavor,
const unsigned int& set)
const
290 if(!jecSetsAvailable()){
291 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n";
293 if(!jecSetAvailable(set)){
294 throw cms::Exception(
"InvalidRequest") <<
"This jet does not carry any jet energy correction factor information \n"
295 <<
"for a jet energy correction set with index " << set <<
"\n";
297 return jec_.at(set).correction(level, flavor)/jec_.at(currentJECSet_).correction(currentJECLevel_, currentJECFlavor_);
306 for(
unsigned int idx=0;
idx<jec_.size(); ++
idx){
307 if(set.empty() || jec_.at(
idx).jecSet()==set){
308 if(jec_[
idx].jecLevel(level)>=0){
309 return correctedJet(jec_[
idx].jecLevel(level), jec_[
idx].jecFlavor(flavor),
idx);
312 throw cms::Exception(
"InvalidRequest") <<
"This JEC level " << level <<
" does not exist. \n";
316 throw cms::Exception(
"InvalidRequest") <<
"This JEC set " << set <<
" does not exist. \n";
323 Jet correctedJet(*
this);
325 correctedJet.setP4(jecFactor(level, flavor, set)*
p4());
327 correctedJet.currentJECSet(set); correctedJet.currentJECLevel(level); correctedJet.currentJECFlavor(flavor);
334 const std::vector<std::pair<std::string, float> > & Jet::getPairDiscri()
const {
335 return pairDiscriVector_;
339 float Jet::bDiscriminator(
const std::string & aLabel)
const {
340 float discriminator = -1000.;
341 const std::string & theLabel = ((aLabel ==
"" || aLabel ==
"default")) ?
"trackCountingHighEffBJetTags" : aLabel;
342 for(
unsigned int i=0; i!=pairDiscriVector_.size(); i++){
343 if(pairDiscriVector_[i].
first == theLabel){
344 discriminator = pairDiscriVector_[
i].second;
347 return discriminator;
351 std::vector<std::string>::const_iterator it =
std::find(tagInfoLabels_.begin(), tagInfoLabels_.end(),
label);
352 if (it != tagInfoLabels_.end()) {
353 if ( tagInfosFwdPtr_.size() > 0 )
return tagInfosFwdPtr_[it - tagInfoLabels_.begin()].get();
354 else if ( tagInfos_.size() > 0 )
return & tagInfos_[it - tagInfoLabels_.begin()];
362 Jet::tagInfoCandIP(
const std::string &label)
const {
363 return tagInfoByTypeOrLabel<reco::CandIPTagInfo>(
label);
367 Jet::tagInfoTrackIP(
const std::string &label)
const {
368 return tagInfoByTypeOrLabel<reco::TrackIPTagInfo>(
label);
372 Jet::tagInfoCandSoftLepton(
const std::string &label)
const {
373 return tagInfoByTypeOrLabel<reco::CandSoftLeptonTagInfo>(
label);
377 Jet::tagInfoSoftLepton(
const std::string &label)
const {
378 return tagInfoByTypeOrLabel<reco::SoftLeptonTagInfo>(
label);
382 Jet::tagInfoCandSecondaryVertex(
const std::string &label)
const {
383 return tagInfoByTypeOrLabel<reco::CandSecondaryVertexTagInfo>(
label);
387 Jet::tagInfoSecondaryVertex(
const std::string &label)
const {
388 return tagInfoByTypeOrLabel<reco::SecondaryVertexTagInfo>(
label);
395 if (idx == std::string::npos) {
396 tagInfoLabels_.push_back(label);
398 tagInfoLabels_.push_back(label.substr(0,idx));
400 tagInfosFwdPtr_.push_back(info);
406 float Jet::jetCharge()
const {
412 return associatedTracks_;
417 associatedTracks_ =
tracks;
422 caloTowersFwdPtr_.reserve(caloTowers.size());
423 for(
auto const& tower : caloTowers) {
424 caloTowersFwdPtr_.push_back( tower );
426 embeddedCaloTowers_ =
true;
427 caloTowersTemp_.reset();
433 pfCandidatesFwdPtr_.reserve(pfCandidates.size());
434 for(
auto const& cand : pfCandidates) {
435 pfCandidatesFwdPtr_.push_back(cand);
437 embeddedPFCandidates_ =
true;
438 pfCandidatesTemp_.reset();
451 void Jet::setPartonFlavour(
int partonFl) {
452 jetFlavourInfo_.setPartonFlavour(partonFl);
456 void Jet::setHadronFlavour(
int hadronFl) {
457 jetFlavourInfo_.setHadronFlavour(hadronFl);
462 jetFlavourInfo_ = jetFlavourInfo;
466 void Jet::addBDiscriminatorPair(
const std::pair<std::string, float> & thePair) {
467 pairDiscriVector_.push_back(thePair);
471 void Jet::setJetCharge(
float jetCharge) {
472 jetCharge_ = jetCharge;
478 void Jet::cacheCaloTowers()
const {
481 std::unique_ptr<std::vector<CaloTowerPtr>> caloTowersTemp{
new std::vector<CaloTowerPtr>{}};
482 if ( embeddedCaloTowers_ ) {
484 if ( caloTowersFwdPtr_.size() > 0 ) {
485 caloTowersTemp->reserve(caloTowersFwdPtr_.size());
486 for ( CaloTowerFwdPtrVector::const_iterator ibegin=caloTowersFwdPtr_.begin(),
487 iend = caloTowersFwdPtr_.end(),
489 icalo != iend; ++icalo ) {
490 caloTowersTemp->emplace_back( icalo->ptr() );
494 else if ( caloTowers_.size() > 0 ) {
495 caloTowersTemp->reserve(caloTowers_.size());
497 iend = caloTowers_.end(),
499 icalo != iend; ++icalo ) {
500 caloTowersTemp->emplace_back( &caloTowers_, icalo - ibegin );
507 caloTowersTemp->reserve(nDaughters);
508 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex ) {
509 Constituent
const & dau = daughterPtr (fIndex);
512 caloTowersTemp->emplace_back( dau.id(), caloTower,dau.key() );
515 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
519 caloTowersTemp_.set(std::move(caloTowersTemp));
523 void Jet::cachePFCandidates()
const {
525 std::unique_ptr<std::vector<reco::PFCandidatePtr>> pfCandidatesTemp{
new std::vector<reco::PFCandidatePtr>{}};
527 if ( embeddedPFCandidates_ ) {
529 if ( pfCandidatesFwdPtr_.size() > 0 ) {
530 pfCandidatesTemp->reserve(pfCandidatesFwdPtr_.size());
531 for ( PFCandidateFwdPtrCollection::const_iterator ibegin=pfCandidatesFwdPtr_.begin(),
532 iend = pfCandidatesFwdPtr_.end(),
534 ipf != iend; ++ipf ) {
535 pfCandidatesTemp->emplace_back( ipf->ptr() );
539 else if ( pfCandidates_.size() > 0 ) {
540 pfCandidatesTemp->reserve(pfCandidates_.size());
541 for ( reco::PFCandidateCollection::const_iterator ibegin=pfCandidates_.begin(),
542 iend = pfCandidates_.end(),
544 ipf != iend; ++ipf ) {
545 pfCandidatesTemp->emplace_back( &pfCandidates_, ipf - ibegin );
552 pfCandidatesTemp->reserve(nDaughters);
553 for (
unsigned fIndex = 0; fIndex < nDaughters; ++fIndex ) {
554 Constituent
const & dau = daughterPtr (fIndex);
557 pfCandidatesTemp->emplace_back( dau.id(), pfCandidate,dau.key() );
560 throw cms::Exception(
"Invalid Constituent") <<
"PFJet constituent is not of PFCandidate type";
565 pfCandidatesTemp_.set(std::move(pfCandidatesTemp));
value_type const * get() const
Jets made from CaloTowers.
virtual float pt() const
transverse momentum
const Specific & getSpecific() const
block accessors
virtual float phi() const
momentum azimuthal angle
Base class for all types of Jets.
std::vector< CaloTower >::const_iterator const_iterator
virtual void setP4(const LorentzVector &p4)
set 4-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.
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual size_t numberOfDaughters() const
number of daughters
virtual double energy() const
energy
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position (throws an exception)
std::ostream & operator<<(std::ostream &, BeamSpot beam)
virtual float eta() const
momentum pseudorapidity
Jets made from CaloJets corrected for ZSP and tracks.
edm::Ptr< CaloTower > CaloTowerPtr
Class storing the jet flavour information.
T get() const
get a component
Jets made from MC generator particles.
Container::value_type value_type
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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.
Templated PAT object container.
volatile std::atomic< bool > shutdown_flag false
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
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