50 double factor =
sqrt(vec.energy() * vec.energy() - mass *
mass) / vec.P();
65 typedef std::vector<reco::CandidatePtr>
CandPtrs;
70 std::unique_ptr<RecoTauQualityCuts>
qcuts_;
97 formula = formula.ReplaceAll(
"pT",
"x");
98 std::unique_ptr<TFormula>
function(
new TFormula(functionName.data(), formula.Data()));
99 int numParameter =
function->GetNpar();
100 for (
int idxParameter = 0; idxParameter < numParameter; ++idxParameter) {
101 std::string parameterName = Form(
"par%i", idxParameter);
102 double parameter = pset.
getParameter<
double>(parameterName);
103 function->SetParameter(idxParameter, parameter);
111 vertexAssociator_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts"), std::
move(iC)),
113 etaAssociationDistance_(nullptr),
114 phiAssociationDistance_(nullptr) {
127 qcuts_pset.addParameter<
double>(
"maxTrackChi2", 1.e+9);
128 qcuts_pset.addParameter<
double>(
"maxTransverseImpactParameter", 1.e+9);
129 qcuts_pset.addParameter<
double>(
"maxDeltaZ", 1.e+9);
130 qcuts_pset.addParameter<
double>(
"minTrackVertexWeight", -1.);
131 qcuts_pset.addParameter<
unsigned>(
"minTrackPixelHits", 0);
132 qcuts_pset.addParameter<
unsigned>(
"minTrackHits", 0);
139 qcuts_ = std::make_unique<RecoTauQualityCuts>(qcuts_pset);
151 if (combineStrips_) {
165 const std::vector<bool>& candFlags,
166 std::set<size_t>& candIdsCurrentStrip,
167 bool& isCandAdded)
const {
169 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"<RecoTauPiZeroStripPlugin3::addCandsToStrip>:";
171 size_t numCands = cands.size();
172 for (
size_t candId = 0; candId < numCands; ++candId) {
173 if ((!candFlags[candId]) &&
174 candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end()) {
176 double etaAssociationDistance_value =
178 double phiAssociationDistance_value =
180 if (fabs(strip.
eta() - cand->eta()) <
181 etaAssociationDistance_value &&
185 <<
"--> adding PFCand #" << candId <<
" (" << cand.
id() <<
":" << cand.
key()
186 <<
"): Et = " << cand->et() <<
", eta = " << cand->eta() <<
", phi = " << cand->phi();
192 candIdsCurrentStrip.insert(candId);
199 void markCandsInStrip(std::vector<bool>& candFlags,
const std::set<size_t>& candIds) {
200 for (std::set<size_t>::const_iterator candId = candIds.begin(); candId != candIds.end(); ++candId) {
201 candFlags[*candId] =
true;
209 const PFCandidate* pfCandPtr =
dynamic_cast<const PFCandidate*
>(&cand);
211 if (pfCandPtr->trackRef().isNonnull())
213 else if (pfCandPtr->gsfTrackRef().isNonnull())
225 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"<RecoTauPiZeroStripPlugin3::operator()>:";
241 for (CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand) {
244 <<
"PFGamma #" << idx <<
" (" << cand->id() <<
":" << cand->key() <<
"): Et = " << (*cand)->et()
245 <<
", eta = " << (*cand)->eta() <<
", phi = " << (*cand)->phi();
249 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"--> assigning seedCandId = " << seedCands.size();
253 <<
"track: Pt = " << candTrack->
pt() <<
" eta = " << candTrack->
eta()
254 <<
", phi = " << candTrack->
phi() <<
", charge = " << candTrack->
charge();
261 <<
", dPt/Pt = " << (candTrack->
ptError() / candTrack->
pt()) <<
")";
264 seedCands.push_back(*cand);
267 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"--> assigning addCandId = " << addCands.size();
269 addCands.push_back(*cand);
274 std::vector<bool> seedCandFlags(seedCands.size());
275 std::vector<bool> addCandFlags(addCands.size());
277 std::set<size_t> seedCandIdsCurrentStrip;
278 std::set<size_t> addCandIdsCurrentStrip;
281 while (idxSeed < seedCands.size()) {
283 edm::LogPrint(
"RecoTauPiZeroStripPlugin3") <<
"processing seed #" << idxSeed;
285 seedCandIdsCurrentStrip.clear();
286 addCandIdsCurrentStrip.clear();
289 strip->addDaughter(seedCands[idxSeed]);
290 seedCandIdsCurrentStrip.insert(idxSeed);
293 int stripBuildIteration = 0;
298 addCandsToStrip(*strip, seedCands, seedCandFlags, seedCandIdsCurrentStrip, isCandAdded);
300 addCandsToStrip(*strip, addCands, addCandFlags, addCandIdsCurrentStrip, isCandAdded);
305 ++stripBuildIteration;
311 <<
"Building strip: Et = " << strip->et() <<
", eta = " << strip->eta() <<
", phi = " << strip->phi();
314 if (strip->daughterPtr(0).isNonnull())
315 strip->setVertex(strip->daughterPtr(0)->vertex());
319 markCandsInStrip(seedCandFlags, seedCandIdsCurrentStrip);
320 markCandsInStrip(addCandFlags, addCandIdsCurrentStrip);
324 <<
"Discarding strip: Et = " << strip->et() <<
", eta = " << strip->eta() <<
", phi = " << strip->phi();
328 while (idxSeed < seedCands.size() && seedCandFlags[idxSeed]) {
337 std::sort(output.begin(), output.end(), [&](
auto& arg1,
auto& arg2) {
return arg1->pt() > arg2->pt(); });
342 for (PiZeroVector::const_iterator firstIter = output.begin(); firstIter != end_iter - 1; ++firstIter) {
343 for (PiZeroVector::const_iterator secondIter = firstIter + 1; secondIter != end_iter; ++secondIter) {
344 auto const&
first = *firstIter;
345 auto const&
second = *secondIter;
353 auto combinedStrips =
354 std::make_unique<RecoTauPiZero>(0,
364 for (
auto const& gamma :
first->daughterPtrVector()) {
365 combinedStrips->addDaughter(gamma);
367 for (
auto const& gamma :
second->daughterPtrVector()) {
368 combinedStrips->addDaughter(gamma);
371 if (combinedStrips->daughterPtr(0).isNonnull()) {
372 combinedStrips->setVertex(combinedStrips->daughterPtr(0)->vertex());
376 stripCombinations.push_back(
std::move(combinedStrips));
381 std::move(stripCombinations.begin(), stripCombinations.end(), std::back_inserter(output));
386 for (
auto const&
strip : output) {
387 double bendCorrEta = 0.;
388 double bendCorrPhi = 0.;
390 for (
auto const& gamma :
strip->daughterPtrVector()) {
393 energySum += gamma->energy();
395 if (energySum > 1.
e-2) {
400 strip->setBendCorrEta(bendCorrEta);
401 strip->setBendCorrPhi(bendCorrPhi);
constexpr double deltaPhi(double phi1, double phi2)
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
double pt() const final
transverse momentum
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
void setEvent(const edm::Event &evt)
Load the vertices from the event.
bool isNonnull() const
Checks for non-null.
return_type operator()(const reco::Jet &) const override
Build a collection of piZeros from objects in the input jet.
~RecoTauPiZeroStripPlugin3() override
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_
Log< level::Warning, true > LogPrint
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_
T getParameter(std::string const &) const
std::vector< std::unique_ptr< RecoTauPiZero > > PiZeroVector
double combinatoricStripMassHypo_
ProductID id() const
Accessor for product ID.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
int numberOfValidTrackerHits() const
RecoTauPiZeroStripPlugin3(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
reco::VertexRef associatedVertex(const Jet &jet) 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)
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
double eta() const final
momentum pseudorapidity