34 #include "CLHEP/Random/RandGauss.h"
107 produces<PFTauDecayModeAssociation>();
125 if(seed == input.rend())
130 bool foundACompatibleMatch =
false;
134 for(; potentialMatch != input.rend(); ++potentialMatch)
139 combinationCandidate = seedFourVector + toAddFourVect;
140 float combinationCandidateMass = combinationCandidate.M();
142 if(combinationCandidateMass <
maxPiZeroMass_ && differenceToTruePiZeroMass < closestInvariantMassDifference)
144 closestInvariantMassDifference = differenceToTruePiZeroMass;
145 bestMatchSoFar = potentialMatch;
146 foundACompatibleMatch =
true;
153 if(bestMatchSoFar->numberOfDaughters() > 0)
156 seed->addDaughter(*photonToAdd);
160 input.erase( (++bestMatchSoFar).
base() );
183 std::vector<compCandList::iterator> gammas;
185 std::vector<gammaMatchContainer> matches;
188 for(compCandList::iterator iGamma = input.begin(); iGamma != input.end(); ++iGamma)
189 gammas.push_back(iGamma);
192 for(
size_t gammaA = 0; gammaA < gammas.size()-1; ++gammaA)
194 for(
size_t gammaB = gammaA+1; gammaB < gammas.size(); ++gammaB)
197 LorentzVector piZeroAB = gammas[gammaA]->p4() + gammas[gammaB]->p4();
199 double piZeroABMass = piZeroAB.M();
208 matches.push_back(aMatch);
217 for(std::vector<gammaMatchContainer>::iterator iMatch = matches.begin();
218 iMatch != matches.end();
221 size_t gammaA = iMatch->firstIndex;
222 size_t gammaB = iMatch->secondIndex;
224 if( gammas[gammaA] != input.end() && gammas[gammaB] != input.end() )
227 for(
size_t bDaughter = 0; bDaughter < gammas[gammaB]->numberOfDaughters(); ++bDaughter)
228 gammas[gammaA]->addDaughter( *(gammas[gammaB]->daughter(bDaughter)) );
232 input.erase(gammas[gammaB]);
234 gammas[gammaA] = input.end();
235 gammas[gammaB] = input.end();
257 size_t numberOfPFTaus = thePFTauCollection->size();
258 for(
size_t iPFTau = 0; iPFTau < numberOfPFTaus; ++iPFTau)
261 PFTauRef pfTauRef(thePFTauCollection, iPFTau);
262 PFTau myPFTau = *pfTauRef;
271 std::vector<ShallowCloneCandidate> chargedCandidates;
272 std::list<CompositeCandidate> gammaCandidates;
276 bool needToProcessTracks =
true;
279 size_t indexOfHighestPt = (theChargedHadronCandidates[0]->pt() > theChargedHadronCandidates[1]->pt()) ? 0 : 1;
280 size_t indexOfLowerPt = ( indexOfHighestPt ) ? 0 : 1;
282 double highPt = theChargedHadronCandidates[indexOfHighestPt]->pt();
283 double lowPt = theChargedHadronCandidates[indexOfLowerPt]->pt();
286 needToProcessTracks =
false;
289 totalFourVector += justAdded->
p4();
297 if(needToProcessTracks)
300 iCharged != theChargedHadronCandidates.
end();
306 totalFourVector += justAdded->
p4();
313 iGamma != theGammaCandidates.
end();
319 totalFourVector += potentialPiZero.
p4();
320 gammaCandidates.push_back(potentialPiZero);
341 bool doneFiltering =
false;
342 while(!doneFiltering && wimp != gammaCandidates.rend())
344 double ptFraction = wimp->pt()/totalFourVector.pt();
345 size_t numberOfPhotons = wimp->numberOfDaughters();
352 totalFourVector -= wimp->p4();
353 for(
size_t iDaughter = 0; iDaughter < numberOfPhotons; ++iDaughter)
363 doneFiltering =
true;
367 gammaCandidates.erase(wimp.base(), gammaCandidates.end());
372 for( std::list<CompositeCandidate>::iterator iGamma = gammaCandidates.begin();
373 iGamma != gammaCandidates.end();
378 if (iGamma->numberOfDaughters() == 1)
407 PFTauDecayMode myDecayModeTau(chargedCandsToAdd, mergedPiZerosToAdd, filteredStuff);
409 result->setValue(iPFTau, myDecayModeTau);
edm::InputTag PFTauProducer_
T getParameter(std::string const &) const
uint32_t maxPhotonsToMerge_
double minPtFractionSinglePhotons_
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
void setPFTauRef(const PFTauRef &theTau)
std::list< CompositeCandidate >::reverse_iterator compCandRevIter
#define DEFINE_FWK_MODULE(type)
math::XYZTLorentzVector LorentzVector
PFRecoTauDecayModeDeterminator(const edm::ParameterSet &iConfig)
const PFCandidateRefVector & signalPFChargedHadrCands() const
Charged hadrons in signal region.
std::list< CompositeCandidate > compCandList
const_iterator end() const
Termination of iteration.
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
virtual size_type numberOfDaughters() const
number of daughters
edm::AssociationVector< PFTauRefProd, reco::PFTauDecayModeCollection > PFTauDecayModeAssociation
const_iterator begin() const
Initialize an iterator over the RefVector.
U second(std::pair< T, U > const &p)
~PFRecoTauDecayModeDeterminator()
void mergePiZeroesByBestMatch(compCandList &)
double minPtFractionForSecondProng_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double minPtFractionPiZeroes_
TauTagTools::sortByAscendingPt< CompositeCandidate > candAscendingSorter
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
TauTagTools::sortByDescendingPt< CompositeCandidate > candDescendingSorter
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
const double chargedPionMass
PFCandCommonVertexFitterBase * vertexFitter_
bool mergeLowPtPhotonsFirst_
const PFCandidateRefVector & signalPFGammaCands() const
Gamma candidates in signal region.
T const * product() const
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const double neutralPionMass
void set(const MagneticField *bField)
edm::RefToBase< Candidate > CandidateBaseRef
persistent reference to an object in a collection of Candidate objects
static bool gammaMatchSorter(const gammaMatchContainer &first, const gammaMatchContainer &second)
size_type size() const
Size of the RefVector.
void set(reco::Candidate &c) const
set up a candidate
virtual void setMass(double m)
set particle mass
void mergePiZeroes(compCandList &, compCandRevIter)
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual void setMass(double m)=0
set particle mass
math::PtEtaPhiELorentzVectorF LorentzVector
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector