62 #include "TLorentzVector.h"
69 using namespace tauImpactParameter;
73 enum Alg { useKalmanFit = 0, useTrackHelix };
94 std::unique_ptr<StringCutObjectSelector<reco::PFTau>>
cut_;
100 : PFTauTag_(iConfig.getParameter<edm::
InputTag>(
"PFTauTag")),
101 PFTauTIPTag_(iConfig.getParameter<edm::
InputTag>(
"PFTauTIPTag")),
102 Algorithm_(iConfig.getParameter<int>(
"Algorithm")),
103 ndfPVT_(iConfig.getUntrackedParameter(
"ndfPVT", (int)5)) {
106 iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"discriminators");
108 for (
auto const&
pset : discriminators) {
114 newCut->
cut_ =
pset.getParameter<
double>(
"selectionCut");
118 if (iConfig.
exists(
"cut"))
121 produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef>>>();
122 produces<PFTau3ProngSummaryCollection>(
"PFTau3ProngSummary");
139 if (packedCand !=
nullptr)
157 auto AVPFTau3PS = std::make_unique<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef>>>(
159 auto PFTau3PSCollection_out = std::make_unique<PFTau3ProngSummaryCollection>();
165 iEvent.
getByLabel(disc->inputTag_, disc->handle_);
176 for (
auto const& disc : discriminators_) {
178 bool passedDisc =
true;
179 if (disc->cutFormula_)
180 passedDisc = (disc->cutFormula_->Eval((*disc->handle_)[tau]) > 0.5);
182 passedDisc = ((*disc->handle_)[tau] > disc->cut_);
188 if (passed &&
cut_.get()) {
189 passed = (*cut_)(*tau);
197 bool SecondaryVtxOK(
false);
199 if (theTIP->hasSecondaryVertex() && primaryVertex->ndof() >
ndfPVT_) {
200 const VertexRef secVtx = theTIP->secondaryVertex();
201 GlobalPoint sv(secVtx->position().x(), secVtx->position().y(), secVtx->position().z());
202 double vtxchi2(0), vtxndf(1);
204 vtxchi2 = secVtx->chi2();
205 vtxndf = secVtx->ndof();
206 const std::vector<reco::Track>&
selectedTracks = secVtx->refittedTracks();
207 std::vector<reco::TransientTrack> transTrkVect;
208 for (
unsigned int i = 0;
i != selectedTracks.size();
i++)
209 transTrkVect.push_back(transTrackBuilder->build(selectedTracks[
i]));
211 float piMassSigma(1.
e-6), piChi(0.0), piNdf(0.0);
212 std::vector<RefCountedKinematicParticle> pions;
213 for (
unsigned int i = 0; i < transTrkVect.size(); i++)
214 pions.push_back(kinFactory.
particle(transTrkVect[i], pdgInfo.
pi_mass(), piChi, piNdf, sv, piMassSigma));
216 jpTree->movePointerToTheTop();
218 AlgebraicSymMatrix77 cov = jpTree->currentParticle()->currentState().kinematicParametersError().matrix();
221 std::vector<reco::Track>
Tracks;
222 std::vector<LorentzVectorParticle> ReFitPions;
223 for (
unsigned int i = 0; i < transTrkVect.size(); i++) {
224 c += transTrkVect[
i].charge();
225 ReFitPions.push_back(ParticleBuilder::createLorentzVectorParticle(transTrkVect[i], *secVtx,
true,
true));
228 TVectorT<double> a1_par(LorentzVectorParticle::NLorentzandVertexPar);
229 TMatrixTSym<double> a1_cov(LorentzVectorParticle::NLorentzandVertexPar);
230 for (
int i = 0; i < LorentzVectorParticle::NLorentzandVertexPar; i++) {
232 for (
int j = 0;
j < LorentzVectorParticle::NLorentzandVertexPar;
j++) {
233 a1_cov(i,
j) = cov(i,
j);
238 SecondaryVtxOK =
true;
242 std::vector<TrackParticle> pions;
244 primaryVertex->position().x(), primaryVertex->position().y(), primaryVertex->position().z());
245 const std::vector<edm::Ptr<reco::Candidate>>
cands = tau->signalChargedHadrCands();
249 if (track !=
nullptr) {
251 pions.push_back(ParticleBuilder::createTrackParticle(transTrk, pvpoint,
true,
true));
254 TVector3
pv(secVtx->position().x(), secVtx->position().y(), secVtx->position().z());
256 SecondaryVtxOK = chi2v.fit();
258 for (
unsigned int i = 0;
i < pions.size();
i++) {
259 c += pions[
i].charge();
262 a1 = chi2v.getMother(pdgid);
266 if (SecondaryVtxOK) {
268 TVector3
pv(primaryVertex->position().x(), primaryVertex->position().y(), primaryVertex->position().z());
269 TMatrixTSym<double> pvcov(LorentzVectorParticle::NVertex);
271 primaryVertex->fill(pvCov);
272 for (
int i = 0;
i < LorentzVectorParticle::NVertex;
i++) {
273 for (
int j = 0;
j < LorentzVectorParticle::NVertex;
j++) {
274 pvcov(
i,
j) = pvCov(
i,
j);
277 for (
unsigned int i = 0;
i < PFTau3ProngSummary::nsolutions;
i++) {
279 bool isFitOK = TauA1NU.
fit();
283 std::vector<TLorentzVector> daughter_p4;
284 std::vector<int> daughter_charge, daughter_PDGID;
285 for (
unsigned int d = 0;
d < daughter.size();
d++) {
286 daughter_p4.push_back(daughter[
d].p4());
287 daughter_charge.push_back((
int)daughter[
d].
charge());
288 daughter_PDGID.push_back(daughter[
d].pdgId());
290 PFTau3PS.
AddSolution(
i, theTau.
p4(), daughter_p4, daughter_charge, daughter_PDGID, (isFitOK), 0.0, -999);
297 PFTau3PSCollection_out->push_back(PFTau3PS);
298 AVPFTau3PS->setValue(iPFTau, PFTau3PSRef);
301 iEvent.
put(
std::move(PFTau3PSCollection_out),
"PFTau3ProngSummary");
std::vector< reco::PFTau3ProngSummary > PFTau3ProngSummaryCollection
collection of PFTau3ProngSummary objects
KinematicParticleVertexFitter kpvFitter_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
TLorentzVector p4() const
bool isNonnull() const
Checks for non-null.
PFTau3ProngReco(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > cut_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::InputTag PFTauTIPTag_
key_type key() const
Accessor for product key.
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
reco::TrackRef trackRef() const
std::vector< LorentzVectorParticle > getRefitDaughters()
LorentzVectorParticle getMother()
Abs< T >::type abs(const T &t)
edm::Handle< reco::PFTauDiscriminator > handle_
T const * get() const
Returns C++ pointer to the item.
DiscCutPairVec discriminators_
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &particles) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
edm::Ref< PFTau3ProngSummaryCollection > PFTau3ProngSummaryRef
presistent reference to a PFTau3ProngSummary
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
~PFTau3ProngReco() override
virtual bool AddSolution(unsigned int solution, const TLorentzVector &tau, const std::vector< TLorentzVector > &daughter_p4, const std::vector< int > &daughter_charge, const std::vector< int > &daughter_PDGID, bool has3ProngSolution, double solutionChi2, double thetaGJsig)
T getParameter(std::string const &) const
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
std::vector< DiscCutPair * > DiscCutPairVec
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
RefCountedKinematicParticle particle(const reco::TransientTrack &initialTrack, const ParticleMass &massGuess, float chiSquared, float degreesOfFr, float &m_sigma) const
void produce(edm::Event &, const edm::EventSetup &) override