13 bool copyGammasFromPiZeros,
17 : signalConeSize_(signalConeSize),
18 minAbsPhotonSumPt_insideSignalCone_(minAbsPhotonSumPt_insideSignalCone),
19 minRelPhotonSumPt_insideSignalCone_(minRelPhotonSumPt_insideSignalCone),
20 minAbsPhotonSumPt_outsideSignalCone_(minAbsPhotonSumPt_outsideSignalCone),
21 minRelPhotonSumPt_outsideSignalCone_(minRelPhotonSumPt_outsideSignalCone),
30 &
tau_->selectedSignalChargedHadrCands_;
32 &
tau_->selectedSignalGammaCands_;
34 &
tau_->selectedSignalNeutrHadrCands_;
36 &
tau_->selectedSignalCands_;
39 &
tau_->selectedIsolationChargedHadrCands_;
41 &
tau_->selectedIsolationGammaCands_;
43 &
tau_->selectedIsolationNeutrHadrCands_;
45 &
tau_->selectedIsolationCands_;
52 new SortedListPtr::element_type);
59 LogDebug(
"TauConstructorAddPFCand") <<
" region = " << region <<
", type = " << type <<
": Pt = " << ptr->pt() <<
", eta = " << ptr->eta() <<
", phi = " << ptr->phi();
64 LogDebug(
"TauConstructorAddPFCand") <<
"--> adding PFCand to tauP4." ;
86 tau_->signalTauChargedHadronCandidatesRestricted().reserve(size);
87 tau_->selectedSignalChargedHadrCands_.reserve(size);
89 tau_->isolationTauChargedHadronCandidatesRestricted().reserve(size);
90 tau_->selectedIsolationChargedHadrCands_.reserve(size);
98 LogDebug(
"TauConstructorCheckOverlap") <<
" pfGammas: #entries = " << pfGammas.size();
99 for ( std::vector<CandidatePtr>::const_iterator
pfGamma = pfGammas.begin();
102 if ( (*pfGamma).refCore() == neutral.
refCore() && (*pfGamma).key() == neutral.
key() ) isUnique =
false;
109 LogDebug(
"TauConstructorCheckOverlap") <<
" piZeros: #entries = " << piZeros.size();
110 for ( std::vector<reco::RecoTauPiZero>::const_iterator piZero = piZeros.begin();
111 piZero != piZeros.end(); ++piZero ) {
112 size_t numPFGammas = piZero->numberOfDaughters();
113 for (
size_t iPFGamma = 0; iPFGamma < numPFGammas; ++iPFGamma ) {
115 LogDebug(
"TauConstructorCheckOverlap") <<
"pfGamma = " << pfGamma.
id() <<
":" << pfGamma.
key();
116 if ( pfGamma.
id() == neutral.
id() && pfGamma.
key() == neutral.
key() ) isUnique =
false;
124 LogDebug(
"TauConstructorAddChH") <<
" region = " << region <<
": Pt = " << chargedHadron.
pt() <<
", eta = " << chargedHadron.
eta() <<
", phi = " << chargedHadron.
phi();
127 std::vector<CandidatePtr> neutrals_cleaned;
128 for ( std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin();
129 neutral != neutrals.end(); ++neutral ) {
130 LogDebug(
"TauConstructorAddChH") <<
"neutral = " << neutral->id() <<
":" << neutral->key();
131 bool isUnique =
true;
133 else checkOverlap(*neutral,
tau_->signalPiZeroCandidatesRestricted(), isUnique);
136 else checkOverlap(*neutral,
tau_->isolationPiZeroCandidatesRestricted(), isUnique);
138 LogDebug(
"TauConstructorAddChH") <<
"--> isUnique = " << isUnique;
139 if ( isUnique ) neutrals_cleaned.push_back(*neutral);
142 if ( neutrals_cleaned.size() != neutrals.size() ) {
147 tau_->signalTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
148 p4_ += chargedHadron_cleaned.
p4();
153 for ( std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin();
154 neutral != neutrals.end(); ++neutral ) {
159 tau_->isolationTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned);
165 for ( std::vector<CandidatePtr>::const_iterator neutral = neutrals.begin();
166 neutral != neutrals.end(); ++neutral ) {
176 tau_->signalPiZeroCandidatesRestricted().reserve(size);
181 tau_->isolationPiZeroCandidatesRestricted().reserve(size);
188 LogDebug(
"TauConstructorAddPi0") <<
" region = " << region <<
": Pt = " << piZero.
pt() <<
", eta = " << piZero.
eta() <<
", phi = " << piZero.
phi();
190 tau_->signalPiZeroCandidatesRestricted().push_back(piZero);
200 tau_->isolationPiZeroCandidatesRestricted().push_back(piZero);
208 std::vector<CandidatePtr>*
226 template<
typename T1,
typename T2>
227 void checkMatchedProductIds(
const T1& t1,
const T2& t2) {
228 if (t1.id() != t2.id()) {
229 throw cms::Exception(
"MismatchedPFCandSrc") <<
"Error: the input tag" 230 <<
" for the PF candidate collection provided to the RecoTauBuilder " 231 <<
" does not match the one that was used to build the source jets." 232 <<
" Please update the pfCandSrc paramters for the PFTau builders.";
241 checkMatchedProductIds(candPtr,
pfCands_);
247 template<
typename T>
bool ptDescending(
const T&
a,
const T&
b) {
248 return a.pt() > b.pt();
250 template<
typename T>
bool ptDescendingPtr(
const T& a,
const T& b) {
251 return a->pt() > b->pt();
257 std::sort(
tau_->signalTauChargedHadronCandidatesRestricted().begin(),
258 tau_->signalTauChargedHadronCandidatesRestricted().end(),
259 ptDescending<PFRecoTauChargedHadron>);
260 std::sort(
tau_->isolationTauChargedHadronCandidatesRestricted().begin(),
261 tau_->isolationTauChargedHadronCandidatesRestricted().end(),
262 ptDescending<PFRecoTauChargedHadron>);
263 std::sort(
tau_->signalPiZeroCandidatesRestricted().begin(),
264 tau_->signalPiZeroCandidatesRestricted().end(),
265 ptDescending<RecoTauPiZero>);
266 std::sort(
tau_->isolationPiZeroCandidatesRestricted().begin(),
267 tau_->isolationPiZeroCandidatesRestricted().end(),
268 ptDescending<RecoTauPiZero>);
274 std::sort(sortedCollection->begin(),
275 sortedCollection->end(),
276 ptDescendingPtr<CandidatePtr>);
278 for ( std::vector<CandidatePtr>::const_iterator particle = sortedCollection->begin();
279 particle != sortedCollection->end(); ++particle ) {
280 colkey.second->push_back(*particle);
297 for ( std::vector<RecoTauPiZero>::const_iterator piZero = piZeros.begin();
298 piZero != piZeros.end(); ++piZero ) {
299 double photonSumPt_insideSignalCone = 0.;
300 double photonSumPt_outsideSignalCone = 0.;
301 int numPhotons = piZero->numberOfDaughters();
302 for (
int idxPhoton = 0; idxPhoton < numPhotons; ++idxPhoton ) {
305 if ( dR < dRsignalCone ) {
306 photonSumPt_insideSignalCone += photon->
pt();
308 photonSumPt_outsideSignalCone += photon->
pt();
311 if ( photonSumPt_insideSignalCone > minAbsPhotonSumPt_insideSignalCone || photonSumPt_insideSignalCone > (minRelPhotonSumPt_insideSignalCone*tau.
pt()) ||
312 photonSumPt_outsideSignalCone > minAbsPhotonSumPt_outsideSignalCone || photonSumPt_outsideSignalCone > (minRelPhotonSumPt_outsideSignalCone*tau.
pt()) ) ++
nPiZeros;
319 unsigned int trackIndex = (nCharged - 1)*(maxPiZeros + 1);
324 if ( nPiZeros > maxPiZeros ) nPiZeros =
maxPiZeros;
331 LogDebug(
"TauConstructorGet") <<
"Start getting" ;
346 double leadChargedHadronPt = 0.;
347 int leadChargedHadronCharge = 0;
348 for ( std::vector<PFRecoTauChargedHadron>::const_iterator
chargedHadron =
tau_->signalTauChargedHadronCandidatesRestricted().begin();
359 if ( nCharged == 3 )
tau_->setCharge(charge);
360 else tau_->setCharge(leadChargedHadronCharge);
363 tau_->setPdgId(
tau_->charge() < 0 ? 15 : -15);
370 tau_->setSignalConeSize(dRsignalCone);
375 tau_->setDecayMode(dm);
377 LogDebug(
"TauConstructorGet") <<
"Pt = " <<
tau_->pt() <<
", eta = " <<
tau_->eta() <<
", phi = " <<
tau_->phi() <<
", mass = " <<
tau_->mass() <<
", dm = " <<
tau_->decayMode() ;
380 tau_->setisolationPFChargedHadrCandsPtSum(
386 tau_->setisolationPFGammaCandsEtSum(
396 if ( setupLeadingObjects ) {
397 typedef std::vector<CandidatePtr>::const_iterator Iter;
404 tau_->setleadCand(*leadingCand);
412 tau_->setleadChargedHadrCand(*leadingChargedCand);
420 tau_->setleadNeutralCand(*leadingGammaCand);
void addPFCand(Region region, ParticleType type, const CandidatePtr &ptr, bool skipAddToP4=false)
Append a PFCandidateRef/Ptr to a given collection.
void addTauChargedHadron(Region region, const PFRecoTauChargedHadron &chargedHadron)
Add a ChargedHadron to the given collection.
double minRelPhotonSumPt_outsideSignalCone_
reco::Candidate::LorentzVector p4_
std::auto_ptr< reco::PFTau > get(bool setupLeadingCandidates=true)
CollectionMap collections_
void reserve(Region region, ParticleType type, size_t size)
Reserve a set amount of space for a given RefVector.
double eta() const final
momentum pseudorapidity
double sumPFCandPt(InputIterator begin, InputIterator end)
Sum the pT of a collection of PFCandidates.
std::vector< CandidatePtr > * getCollection(Region region, ParticleType type)
double pt() const final
transverse momentum
minRelPhotonSumPt_outsideSignalCone
InputIterator leadCand(InputIterator begin, InputIterator end)
virtual const daughters & daughterPtrVector() const
references to daughtes
const edm::Handle< edm::View< reco::Candidate > > & pfCands_
SortedCollectionMap sortedCollections_
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
SortedListPtr getSortedCollection(Region region, ParticleType type)
RefCore const & refCore() const
Abs< T >::type abs(const T &t)
const LorentzVector & p4() const final
four-momentum Lorentz vector
std::vector< CandidatePtr > neutralPFCandidates_
void addPFCands(Region region, ParticleType type, const InputIterator &begin, const InputIterator &end)
boost::shared_ptr< std::vector< CandidatePtr > > SortedListPtr
bool isNonnull() const
Checks for non-null.
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double minAbsPhotonSumPt_outsideSignalCone_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
virtual double pt() const =0
transverse momentum
std::auto_ptr< reco::PFTau > tau_
minAbsPhotonSumPt_insideSignalCone
void reserveTauChargedHadron(Region region, size_t size)
Reserve a set amount of space for the ChargedHadrons.
void reservePiZero(Region region, size_t size)
Reserve a set amount of space for the PiZeros.
ProductID id() const
Accessor for product ID.
double minRelPhotonSumPt_insideSignalCone_
def checkOverlap(process)
minAbsPhotonSumPt_outsideSignalCone
void sortAndCopyIntoTau()
const std::vector< PFRecoTauChargedHadron > & signalTauChargedHadronCandidates() const
Retrieve the association of signal region PF candidates into candidate PFRecoTauChargedHadrons.
minRelPhotonSumPt_insideSignalCone
void addPiZero(Region region, const RecoTauPiZero &piZero)
Add a PiZero to the given collection.
const StringObjectFunction< reco::PFTau > * signalConeSize_
double minAbsPhotonSumPt_insideSignalCone_
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
CandidatePtr convertToPtr(const PFCandidatePtr &pfPtr) const
const CandidatePtr & getChargedPFCandidate() const
reference to "charged" PFCandidate (either charged PFCandidate or PFNeutralHadron) ...
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
double phi() const final
momentum azimuthal angle
std::vector< CandidatePtr > pfGammas(const Jet &jet, bool sort=true)
Extract all pfGammas from a PFJet.
const std::vector< CandidatePtr > & getNeutralPFCandidates() const
references to additional neutral PFCandidates
RecoTauConstructor(const JetBaseRef &jetRef, const edm::Handle< edm::View< reco::Candidate > > &pfCands, bool copyGammasFromPiZeros=false, const StringObjectFunction< reco::PFTau > *signalConeSize=0, double minAbsPhotonSumPt_insideSignalCone=2.5, double minRelPhotonSumPt_insideSignalCone=0., double minAbsPhotonSumPt_outsideSignalCone=1.e+9, double minRelPhotonSumPt_outsideSignalCone=1.e+9)
Constructor with PFCandidate Handle.