![]() |
![]() |
#include <RecoTauConstructor.h>
Public Types | |
enum | ParticleType { kChargedHadron, kGamma, kNeutralHadron, kAll } |
enum | Region { kSignal, kIsolation } |
Public Member Functions | |
void | addPFCand (Region region, ParticleType type, const PFCandidateRef &ref) |
Append a PFCandidateRef to a given collection. | |
template<typename InputIterator > | |
void | addPFCands (Region region, ParticleType type, const InputIterator &begin, const InputIterator &end) |
void | addPiZero (Region region, const RecoTauPiZero &piZero) |
Add a PiZero to the given collection. | |
template<typename InputIterator > | |
void | addPiZeros (Region region, const InputIterator &begin, const InputIterator &end) |
Add a list of pi zeros to the input collection. | |
std::auto_ptr< reco::PFTau > | get (bool setupLeadingCandidates=true) |
const reco::Candidate::LorentzVector & | p4 () const |
RecoTauConstructor (const PFJetRef &jetRef, const edm::Handle< PFCandidateCollection > &pfCands, bool copyGammasFromPiZeros=false) | |
Constructor with PFCandidate Handle. | |
void | reserve (Region region, ParticleType type, size_t size) |
Reserve a set amount of space for a given RefVector. | |
void | reservePiZero (Region region, size_t size) |
Reserve a set amount of space for the PiZeros. | |
template<typename T > | |
void | setleadPFCand (const T &cand) |
Set leading PF candidate. | |
template<typename T > | |
void | setleadPFChargedHadrCand (const T &cand) |
Set leading PFChargedHadron candidate. | |
template<typename T > | |
void | setleadPFNeutralCand (const T &cand) |
Set leading PFGamma candidate. | |
Private Types | |
typedef std::pair< Region, ParticleType > | CollectionKey |
typedef std::map < CollectionKey, PFCandidateRefVector * > | CollectionMap |
typedef std::map < CollectionKey, SortedListPtr > | SortedCollectionMap |
typedef boost::shared_ptr < std::vector< PFCandidateRef > > | SortedListPtr |
Private Member Functions | |
PFCandidateRef | convertToRef (const PFCandidatePtr &pfPtr) const |
PFCandidateRef | convertToRef (const CandidatePtr &candPtr) const |
PFCandidateRef | convertToRef (const PFCandidateRef &pfRef) const |
PFCandidateRefVector * | getCollection (Region region, ParticleType type) |
SortedListPtr | getSortedCollection (Region region, ParticleType type) |
void | sortAndCopyIntoTau () |
Private Attributes | |
CollectionMap | collections_ |
bool | copyGammas_ |
reco::Candidate::LorentzVector | p4_ |
const edm::Handle < PFCandidateCollection > & | pfCands_ |
SortedCollectionMap | sortedCollections_ |
std::auto_ptr< reco::PFTau > | tau_ |
Definition at line 36 of file RecoTauConstructor.h.
typedef std::pair<Region, ParticleType> reco::tau::RecoTauConstructor::CollectionKey [private] |
Definition at line 116 of file RecoTauConstructor.h.
typedef std::map<CollectionKey, PFCandidateRefVector*> reco::tau::RecoTauConstructor::CollectionMap [private] |
Definition at line 117 of file RecoTauConstructor.h.
typedef std::map<CollectionKey, SortedListPtr> reco::tau::RecoTauConstructor::SortedCollectionMap [private] |
Definition at line 119 of file RecoTauConstructor.h.
typedef boost::shared_ptr<std::vector<PFCandidateRef> > reco::tau::RecoTauConstructor::SortedListPtr [private] |
Definition at line 118 of file RecoTauConstructor.h.
Definition at line 43 of file RecoTauConstructor.h.
{ kChargedHadron, kGamma, kNeutralHadron, kAll };
Definition at line 38 of file RecoTauConstructor.h.
{ kSignal, kIsolation };
reco::tau::RecoTauConstructor::RecoTauConstructor | ( | const PFJetRef & | jetRef, |
const edm::Handle< PFCandidateCollection > & | pfCands, | ||
bool | copyGammasFromPiZeros = false |
||
) |
Constructor with PFCandidate Handle.
Definition at line 10 of file RecoTauConstructor.cc.
References collections_, copyGammas_, kAll, kChargedHadron, kGamma, kIsolation, kNeutralHadron, kSignal, RecoPFTauTag_cff::PFTau, sortedCollections_, and tau_.
:pfCands_(pfCands) { // Initialize tau tau_.reset(new PFTau()); copyGammas_ = copyGammasFromPiZeros; // Initialize our Accessors collections_[std::make_pair(kSignal, kChargedHadron)] = &tau_->selectedSignalPFChargedHadrCands_; collections_[std::make_pair(kSignal, kGamma)] = &tau_->selectedSignalPFGammaCands_; collections_[std::make_pair(kSignal, kNeutralHadron)] = &tau_->selectedSignalPFNeutrHadrCands_; collections_[std::make_pair(kSignal, kAll)] = &tau_->selectedSignalPFCands_; collections_[std::make_pair(kIsolation, kChargedHadron)] = &tau_->selectedIsolationPFChargedHadrCands_; collections_[std::make_pair(kIsolation, kGamma)] = &tau_->selectedIsolationPFGammaCands_; collections_[std::make_pair(kIsolation, kNeutralHadron)] = &tau_->selectedIsolationPFNeutrHadrCands_; collections_[std::make_pair(kIsolation, kAll)] = &tau_->selectedIsolationPFCands_; // Build our temporary sorted collections, since you can't use stl sorts on // RefVectors BOOST_FOREACH(const CollectionMap::value_type &colkey, collections_) { // Build an empty list for each collection sortedCollections_[colkey.first] = SortedListPtr( new SortedListPtr::element_type); } tau_->setjetRef(jet); }
void reco::tau::RecoTauConstructor::addPFCand | ( | Region | region, |
ParticleType | type, | ||
const PFCandidateRef & | ref | ||
) |
Append a PFCandidateRef to a given collection.
Definition at line 48 of file RecoTauConstructor.cc.
References copyGammas_, getSortedCollection(), kAll, kGamma, kSignal, and p4_.
Referenced by addPFCands().
{ if (region == kSignal) { // Keep track of the four vector of the signal vector products added so far. // If a photon add it if we are not using PiZeros to build the gammas if ( (type != kGamma) || !copyGammas_ ) p4_ += ref->p4(); } getSortedCollection(region, type)->push_back(ref); // Add to global collection getSortedCollection(region, kAll)->push_back(ref); }
void reco::tau::RecoTauConstructor::addPFCands | ( | Region | region, |
ParticleType | type, | ||
const InputIterator & | begin, | ||
const InputIterator & | end | ||
) | [inline] |
Definition at line 84 of file RecoTauConstructor.h.
References addPFCand(), convertToRef(), and end.
Referenced by addPiZero(), reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), and reco::tau::RecoTauBuilderConePlugin::operator()().
{ for(InputIterator iter = begin; iter != end; ++iter) { addPFCand(region, type, convertToRef(*iter)); } }
void reco::tau::RecoTauConstructor::addPiZero | ( | Region | region, |
const RecoTauPiZero & | piZero | ||
) |
Add a PiZero to the given collection.
Definition at line 85 of file RecoTauConstructor.cc.
References addPFCands(), copyGammas_, reco::CompositePtrCandidate::daughterPtrVector(), kGamma, kIsolation, kSignal, reco::LeafCandidate::p4(), p4_, and tau_.
Referenced by addPiZeros().
{ if(region == kSignal) { tau_->signalPiZeroCandidates_.push_back(piZero); // Copy the daughter gammas into the gamma collection if desired if(copyGammas_) { // If we are using the pizeros to build the gammas, make sure we update // the four vector correctly. p4_ += piZero.p4(); addPFCands(kSignal, kGamma, piZero.daughterPtrVector().begin(), piZero.daughterPtrVector().end()); } } else { tau_->isolationPiZeroCandidates_.push_back(piZero); if(copyGammas_) { addPFCands(kIsolation, kGamma, piZero.daughterPtrVector().begin(), piZero.daughterPtrVector().end()); } } }
void reco::tau::RecoTauConstructor::addPiZeros | ( | Region | region, |
const InputIterator & | begin, | ||
const InputIterator & | end | ||
) | [inline] |
Add a list of pi zeros to the input collection.
Definition at line 99 of file RecoTauConstructor.h.
References addPiZero(), and end.
Referenced by reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), and reco::tau::RecoTauBuilderConePlugin::operator()().
PFCandidateRef reco::tau::RecoTauConstructor::convertToRef | ( | const CandidatePtr & | candPtr | ) | const [private] |
Definition at line 144 of file RecoTauConstructor.cc.
References edm::Ptr< T >::isNonnull(), edm::Ptr< T >::key(), and pfCands_.
{ if(candPtr.isNonnull()) { checkMatchedProductIds(candPtr, pfCands_); return PFCandidateRef(pfCands_, candPtr.key()); } else return PFCandidateRef(); }
PFCandidateRef reco::tau::RecoTauConstructor::convertToRef | ( | const PFCandidateRef & | pfRef | ) | const [private] |
Definition at line 116 of file RecoTauConstructor.cc.
{
return pfRef;
}
PFCandidateRef reco::tau::RecoTauConstructor::convertToRef | ( | const PFCandidatePtr & | pfPtr | ) | const [private] |
Definition at line 135 of file RecoTauConstructor.cc.
References edm::Ptr< T >::isNonnull(), edm::Ptr< T >::key(), and pfCands_.
Referenced by addPFCands(), setleadPFCand(), setleadPFChargedHadrCand(), and setleadPFNeutralCand().
{ if(pfPtr.isNonnull()) { checkMatchedProductIds(pfPtr, pfCands_); return PFCandidateRef(pfCands_, pfPtr.key()); } else return PFCandidateRef(); }
std::auto_ptr< reco::PFTau > reco::tau::RecoTauConstructor::get | ( | bool | setupLeadingCandidates = true | ) |
Definition at line 184 of file RecoTauConstructor.cc.
References begin, end, getCollection(), kAll, kChargedHadron, kGamma, kIsolation, kSignal, reco::tau::leadPFCand(), p4_, sortAndCopyIntoTau(), reco::tau::sumPFCandCharge(), reco::tau::sumPFCandPt(), and tau_.
Referenced by reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), and reco::tau::RecoTauBuilderConePlugin::operator()().
{ // Copy the sorted collections into the interal tau refvectors sortAndCopyIntoTau(); // Setup all the important member variables of the tau // Set charge of tau tau_->setCharge( sumPFCandCharge(getCollection(kSignal, kChargedHadron)->begin(), getCollection(kSignal, kChargedHadron)->end())); // Set PDG id tau_->setPdgId(tau_->charge() > 0 ? 15 : -15); // Set P4 tau_->setP4(p4_); // tau_->setP4( // sumPFCandP4( // getCollection(kSignal, kAll)->begin(), // getCollection(kSignal, kAll)->end() // ) // ); // Set charged isolation quantities tau_->setisolationPFChargedHadrCandsPtSum( sumPFCandPt( getCollection(kIsolation, kChargedHadron)->begin(), getCollection(kIsolation, kChargedHadron)->end() ) ); // Set gamma isolation quantities tau_->setisolationPFGammaCandsEtSum( sumPFCandPt( getCollection(kIsolation, kGamma)->begin(), getCollection(kIsolation, kGamma)->end() ) ); // Set em fraction tau_->setemFraction(sumPFCandPt( getCollection(kSignal, kGamma)->begin(), getCollection(kSignal, kGamma)->end()) / tau_->pt()); if(setupLeadingObjects) { typedef PFCandidateRefVector::const_iterator Iter; // Find the highest PT object in the signal cone Iter leadingCand = leadPFCand( getCollection(kSignal, kAll)->begin(), getCollection(kSignal, kAll)->end() ); if(leadingCand != getCollection(kSignal, kAll)->end()) tau_->setleadPFCand(*leadingCand); // Hardest charged object in signal cone Iter leadingChargedCand = leadPFCand( getCollection(kSignal, kChargedHadron)->begin(), getCollection(kSignal, kChargedHadron)->end() ); if(leadingChargedCand != getCollection(kSignal, kChargedHadron)->end()) tau_->setleadPFChargedHadrCand(*leadingChargedCand); // Hardest gamma object in signal cone Iter leadingGammaCand = leadPFCand( getCollection(kSignal, kGamma)->begin(), getCollection(kSignal, kGamma)->end() ); if(leadingGammaCand != getCollection(kSignal, kGamma)->end()) tau_->setleadPFNeutralCand(*leadingGammaCand); } return tau_; }
PFCandidateRefVector * reco::tau::RecoTauConstructor::getCollection | ( | Region | region, |
ParticleType | type | ||
) | [private] |
Definition at line 106 of file RecoTauConstructor.cc.
References collections_.
Referenced by get(), and reserve().
{ return collections_[std::make_pair(region, type)]; }
RecoTauConstructor::SortedListPtr reco::tau::RecoTauConstructor::getSortedCollection | ( | Region | region, |
ParticleType | type | ||
) | [private] |
Definition at line 111 of file RecoTauConstructor.cc.
References sortedCollections_.
Referenced by addPFCand(), and reserve().
{ return sortedCollections_[std::make_pair(region, type)]; }
const reco::Candidate::LorentzVector& reco::tau::RecoTauConstructor::p4 | ( | ) | const [inline] |
Definition at line 112 of file RecoTauConstructor.h.
References p4_.
Referenced by reco::tau::RecoTauBuilderCombinatoricPlugin::operator()().
{ return p4_; }
void reco::tau::RecoTauConstructor::reserve | ( | Region | region, |
ParticleType | type, | ||
size_t | size | ||
) |
Reserve a set amount of space for a given RefVector.
Definition at line 61 of file RecoTauConstructor.cc.
References getCollection(), getSortedCollection(), kAll, edm::RefVector< C, T, F >::reserve(), and findQualityFiles::size.
Referenced by reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), and reservePiZero().
{ getSortedCollection(region, type)->reserve(size); getCollection(region, type)->reserve(size); // Reserve global collection as well getSortedCollection(region, kAll)->reserve( getSortedCollection(region, kAll)->size() + size); getCollection(region, kAll)->reserve( getCollection(region, kAll)->size() + size); }
void reco::tau::RecoTauConstructor::reservePiZero | ( | Region | region, |
size_t | size | ||
) |
Reserve a set amount of space for the PiZeros.
Definition at line 71 of file RecoTauConstructor.cc.
References copyGammas_, kGamma, kIsolation, kSignal, reserve(), and tau_.
Referenced by reco::tau::RecoTauBuilderCombinatoricPlugin::operator()().
{ if(region == kSignal) { tau_->signalPiZeroCandidates_.reserve(size); // If we are building the gammas with the pizeros, resize that // vector as well if(copyGammas_) reserve(kSignal, kGamma, 2*size); } else { tau_->isolationPiZeroCandidates_.reserve(size); if(copyGammas_) reserve(kIsolation, kGamma, 2*size); } }
void reco::tau::RecoTauConstructor::setleadPFCand | ( | const T & | cand | ) | [inline] |
Set leading PF candidate.
Definition at line 72 of file RecoTauConstructor.h.
References convertToRef(), and tau_.
Referenced by reco::tau::RecoTauBuilderConePlugin::operator()().
{ tau_->setleadPFCand(convertToRef(cand)); }
void reco::tau::RecoTauConstructor::setleadPFChargedHadrCand | ( | const T & | cand | ) | [inline] |
Set leading PFChargedHadron candidate.
Definition at line 62 of file RecoTauConstructor.h.
References convertToRef(), and tau_.
Referenced by reco::tau::RecoTauBuilderConePlugin::operator()().
{ tau_->setleadPFChargedHadrCand(convertToRef(cand)); }
void reco::tau::RecoTauConstructor::setleadPFNeutralCand | ( | const T & | cand | ) | [inline] |
Set leading PFGamma candidate.
Definition at line 67 of file RecoTauConstructor.h.
References convertToRef(), and tau_.
Referenced by reco::tau::RecoTauBuilderConePlugin::operator()().
{ tau_->setleadPFNeutralCand(convertToRef(cand)); }
void reco::tau::RecoTauConstructor::sortAndCopyIntoTau | ( | ) | [private] |
Definition at line 161 of file RecoTauConstructor.cc.
References collections_, edm::RefVector< PFCandidateCollection >::push_back(), python::multivaluedict::sort(), sortedCollections_, and tau_.
Referenced by get().
{ // The pizeros are a special case, as we can sort them in situ std::sort(tau_->signalPiZeroCandidates_.begin(), tau_->signalPiZeroCandidates_.end(), ptDescending<RecoTauPiZero>); std::sort(tau_->isolationPiZeroCandidates_.begin(), tau_->isolationPiZeroCandidates_.end(), ptDescending<RecoTauPiZero>); // Sort each of our sortable collections, and copy them into the final // tau RefVector. BOOST_FOREACH(const CollectionMap::value_type &colkey, collections_) { SortedListPtr sortedCollection = sortedCollections_[colkey.first]; std::sort(sortedCollection->begin(), sortedCollection->end(), ptDescendingRef<PFCandidateRef>); // Copy into the real tau collection std::for_each( sortedCollection->begin(), sortedCollection->end(), boost::bind(&PFCandidateRefVector::push_back, colkey.second, _1)); } }
Definition at line 136 of file RecoTauConstructor.h.
Referenced by getCollection(), RecoTauConstructor(), and sortAndCopyIntoTau().
bool reco::tau::RecoTauConstructor::copyGammas_ [private] |
Definition at line 121 of file RecoTauConstructor.h.
Referenced by addPFCand(), addPiZero(), RecoTauConstructor(), and reservePiZero().
Definition at line 142 of file RecoTauConstructor.h.
Referenced by addPFCand(), addPiZero(), get(), and p4().
const edm::Handle<PFCandidateCollection>& reco::tau::RecoTauConstructor::pfCands_ [private] |
Definition at line 134 of file RecoTauConstructor.h.
Referenced by convertToRef().
Definition at line 139 of file RecoTauConstructor.h.
Referenced by getSortedCollection(), RecoTauConstructor(), and sortAndCopyIntoTau().
std::auto_ptr<reco::PFTau> reco::tau::RecoTauConstructor::tau_ [private] |
Definition at line 135 of file RecoTauConstructor.h.
Referenced by addPiZero(), get(), RecoTauConstructor(), reservePiZero(), setleadPFCand(), setleadPFChargedHadrCand(), setleadPFNeutralCand(), and sortAndCopyIntoTau().