17 #include "boost/bind.hpp" 44 namespace reco {
namespace tau {
50 double factor =
sqrt(vec.energy()*vec.energy()-mass*
mass)/vec.P();
52 vec.px()*factor,vec.py()*factor,vec.pz()*factor,vec.energy());
67 typedef std::vector<reco::CandidatePtr>
CandPtrs;
72 std::unique_ptr<RecoTauQualityCuts>
qcuts_;
101 formula = formula.ReplaceAll(
"pT",
"x");
102 std::unique_ptr<TFormula>
function(
new TFormula(functionName.data(), formula.Data()));
103 int numParameter =
function->GetNpar();
104 for (
int idxParameter = 0; idxParameter < numParameter; ++idxParameter ) {
105 std::string parameterName = Form(
"par%i", idxParameter);
107 function->SetParameter(idxParameter, parameter);
129 qcuts_pset.addParameter<
double>(
"maxTrackChi2", 1.e+9);
130 qcuts_pset.addParameter<
double>(
"maxTransverseImpactParameter", 1.e+9);
131 qcuts_pset.addParameter<
double>(
"maxDeltaZ", 1.e+9);
132 qcuts_pset.addParameter<
double>(
"minTrackVertexWeight", -1.);
133 qcuts_pset.addParameter<
unsigned>(
"minTrackPixelHits", 0);
134 qcuts_pset.addParameter<
unsigned>(
"minTrackHits", 0);
153 if ( combineStrips_ ) {
171 std::set<size_t>& candIdsCurrentStrip,
bool& isCandAdded)
const 174 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"<RecoTauPiZeroStripPlugin3::addCandsToStrip>:" ;
176 size_t numCands = cands.size();
177 for (
size_t candId = 0; candId < numCands; ++candId ) {
178 if ( (!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end() ) {
182 if ( fabs(strip.
eta() - cand->eta()) < etaAssociationDistance_value &&
185 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"--> adding PFCand #" << candId <<
" (" << cand.
id() <<
":" << cand.
key() <<
"): Et = " << cand->et() <<
", eta = " << cand->eta() <<
", phi = " << cand->phi() ;
190 candIdsCurrentStrip.insert(candId);
198 void markCandsInStrip(std::vector<bool>& candFlags,
const std::set<size_t>& candIds)
200 for ( std::set<size_t>::const_iterator candId = candIds.begin();
201 candId != candIds.end(); ++candId ) {
202 candFlags[*candId] =
true;
225 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"<RecoTauPiZeroStripPlugin3::operator()>:" ;
241 for ( CandPtrs::iterator
cand = candsVector.begin();
242 cand != candsVector.end(); ++
cand ) {
244 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"PFGamma #" << idx <<
" (" <<
cand->id() <<
":" <<
cand->key() <<
"): Et = " << (*cand)->et() <<
", eta = " << (*cand)->eta() <<
", phi = " << (*cand)->phi() ;
248 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"--> assigning seedCandId = " << seedCands.size() ;
251 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"track: Pt = " << candTrack->
pt() <<
" eta = " << candTrack->
eta() <<
", phi = " << candTrack->
phi() <<
", charge = " << candTrack->
charge() ;
254 <<
" chi2 = " << candTrack->
normalizedChi2() <<
", dPt/Pt = " << (candTrack->
ptError()/candTrack->
pt()) <<
")" ;
257 seedCands.push_back(*
cand);
260 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"--> assigning addCandId = " << addCands.size() ;
262 addCands.push_back(*
cand);
267 std::vector<bool> seedCandFlags(seedCands.size());
268 std::vector<bool> addCandFlags(addCands.size());
270 std::set<size_t> seedCandIdsCurrentStrip;
271 std::set<size_t> addCandIdsCurrentStrip;
274 while ( idxSeed < seedCands.size() ) {
277 seedCandIdsCurrentStrip.clear();
278 addCandIdsCurrentStrip.clear();
281 strip->addDaughter(seedCands[idxSeed]);
282 seedCandIdsCurrentStrip.insert(idxSeed);
285 int stripBuildIteration = 0;
290 addCandsToStrip(*strip, seedCands, seedCandFlags, seedCandIdsCurrentStrip, isCandAdded);
292 addCandsToStrip(*strip, addCands, addCandFlags, addCandIdsCurrentStrip, isCandAdded);
296 ++stripBuildIteration;
300 if (
verbosity_ >= 2 )
edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"Building strip: Et = " << strip->et() <<
", eta = " << strip->eta() <<
", phi = " << strip->phi() ;
303 if ( strip->daughterPtr(0).isNonnull() ) strip->setVertex(strip->daughterPtr(0)->vertex());
304 output.push_back(strip);
307 markCandsInStrip(seedCandFlags, seedCandIdsCurrentStrip);
308 markCandsInStrip(addCandFlags, addCandIdsCurrentStrip);
310 if (
verbosity_ >= 2 )
edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"Discarding strip: Et = " << strip->et() <<
", eta = " << strip->eta() <<
", phi = " << strip->phi() ;
314 while ( idxSeed < seedCands.size() && seedCandFlags[idxSeed] ) {
323 output.sort(output.begin(), output.end(),
331 for ( PiZeroVector::const_iterator
first = output.begin();
333 for ( PiZeroVector::const_iterator
second =
first+1;
342 std::auto_ptr<RecoTauPiZero> combinedStrips(
349 for (
auto const&
gamma :
first->daughterPtrVector()) {
350 combinedStrips->addDaughter(
gamma);
352 for (
auto const&
gamma :
second->daughterPtrVector()) {
353 combinedStrips->addDaughter(
gamma);
356 if ( combinedStrips->daughterPtr(0).isNonnull() ) {
357 combinedStrips->setVertex(combinedStrips->daughterPtr(0)->vertex());
361 stripCombinations.push_back(combinedStrips);
366 output.transfer(output.end(), stripCombinations);
371 for ( PiZeroVector::iterator
strip = output.begin();
373 double bendCorrEta = 0.;
374 double bendCorrPhi = 0.;
376 for (
auto const&
gamma :
strip->daughterPtrVector()) {
379 energySum +=
gamma->energy();
381 if ( energySum > 1.
e-2 ) {
386 strip->setBendCorrEta(bendCorrEta);
387 strip->setBendCorrPhi(bendCorrPhi);
390 return output.release();
constexpr double deltaPhi(double phi1, double phi2)
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
T getParameter(std::string const &) const
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
bool isNonnull() const
Checks for non-null.
double eta() const final
momentum pseudorapidity
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Base class for all types of Jets.
bool updateStripAfterEachDaughter_
double phi() const
azimuthal angle of momentum vector
double pt() const final
transverse momentum
void setEvent(const edm::Event &evt)
Load the vertices from the event.
bool isNonnull() const
Checks for non-null.
~RecoTauPiZeroStripPlugin3() override
reco::TrackRef trackRef() const
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double eta() const
pseudorapidity of momentum vector
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
double pt() const
track transverse momentum
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
void addCandsToStrip(RecoTauPiZero &, CandPtrs &, const std::vector< bool > &, std::set< size_t > &, bool &) const
bool applyElecTrackQcuts_
std::vector< reco::CandidatePtr > CandPtrs
void beginEvent() override
Hook called at the beginning of the event.
std::unique_ptr< const TFormula > etaAssociationDistance_
std::unique_ptr< RecoTauQualityCuts > qcuts_
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
double minGammaEtStripSeed_
const edm::Event * evt() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
ParameterSet const & getParameterSet(std::string const &) const
int maxStripBuildIterations_
double combinatoricStripMassHypo_
ProductID id() const
Accessor for product ID.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
int numberOfValidTrackerHits() const
std::auto_ptr< PiZeroVector > return_type
Particle reconstructed by the particle flow algorithm.
RecoTauPiZeroStripPlugin3(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
reco::VertexRef associatedVertex(const Jet &jet) const
boost::ptr_vector< RecoTauPiZero > PiZeroVector
reco::GsfTrackRef gsfTrackRef() const
std::unique_ptr< const TFormula > phiAssociationDistance_
RecoTauVertexAssociator vertexAssociator_
AddFourMomenta p4Builder_
void addDaughter(const CandidatePtr &)
add a daughter via a reference
int numberOfValidPixelHits() const
std::vector< int > inputParticleIds_
double minGammaEtStripAdd_
math::XYZPoint Point
point in the space
int charge() const
track electric charge
#define DEFINE_EDM_PLUGIN(factory, type, name)
void set(reco::Candidate &c) const
set up a candidate
double energySum(const DataFrame &df, int fs, int ls)
return_type operator()(const reco::Jet &) const override
Build a collection of piZeros from objects in the input jet.
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
double phi() const final
momentum azimuthal angle