62 #include "TLorentzVector.h" 73 enum Alg{useKalmanFit=0, useTrackHelix};
93 std::unique_ptr<StringCutObjectSelector<reco::PFTau> >
cut_;
99 PFTauTag_(iConfig.getParameter<
edm::
InputTag>(
"PFTauTag")),
100 PFTauTIPTag_(iConfig.getParameter<
edm::
InputTag>(
"PFTauTIPTag")),
101 Algorithm_(iConfig.getParameter<
int>(
"Algorithm")),
102 ndfPVT_(iConfig.getUntrackedParameter(
"ndfPVT",(
int)5))
107 for(
auto const&
pset : discriminators) {
111 else newCut->
cut_ =
pset.getParameter<
double>(
"selectionCut");
117 produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef> > >();
118 produces<PFTau3ProngSummaryCollection>(
"PFTau3ProngSummary");
136 auto AVPFTau3PS = std::make_unique<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef>>>(
PFTauRefProd(Tau));
137 auto PFTau3PSCollection_out = std::make_unique<PFTau3ProngSummaryCollection>();
151 for(
auto const&
disc : discriminators_) {
153 bool passedDisc =
true;
154 if (
disc->cutFormula_ )passedDisc = (
disc->cutFormula_->Eval((*
disc->handle_)[tau]) > 0.5);
155 else passedDisc = ((*
disc->handle_)[tau] >
disc->cut_);
156 if ( !passedDisc ){passed =
false;
break;}
158 if (passed &&
cut_.get()){passed = (*cut_)(*tau);}
165 bool SecondaryVtxOK(
false);
167 if(theTIP->hasSecondaryVertex() && primaryVertex->ndof()>
ndfPVT_){
168 const VertexRef secVtx=theTIP->secondaryVertex();
169 GlobalPoint sv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
170 double vtxchi2(0), vtxndf(1);
172 vtxchi2=secVtx->chi2();
173 vtxndf=secVtx->ndof();
174 const std::vector<reco::Track>&
selectedTracks=secVtx->refittedTracks();
175 std::vector<reco::TransientTrack> transTrkVect;
176 for(
unsigned int i = 0;
i!=selectedTracks.size();
i++) transTrkVect.push_back(transTrackBuilder->
build(selectedTracks[
i]));
178 float piMassSigma(1.
e-6), piChi(0.0), piNdf(0.0);
179 std::vector<RefCountedKinematicParticle> pions;
180 for(
unsigned int i = 0; i<transTrkVect.size();i++) pions.push_back(kinFactory.
particle(transTrkVect[i],pdgInfo.
pi_mass(),piChi,piNdf,
sv,piMassSigma));
182 jpTree->movePointerToTheTop();
184 AlgebraicSymMatrix77 cov=jpTree->currentParticle()->currentState().kinematicParametersError().matrix();
187 std::vector<reco::Track>
Tracks;
188 std::vector<LorentzVectorParticle> ReFitPions;
189 for(
unsigned int i=0;i<transTrkVect.size();i++){
190 c+=transTrkVect[
i].charge();
191 ReFitPions.push_back(ParticleBuilder::createLorentzVectorParticle(transTrkVect[i],*secVtx,
true,
true));
194 TVectorT<double> a1_par(LorentzVectorParticle::NLorentzandVertexPar);
195 TMatrixTSym<double> a1_cov(LorentzVectorParticle::NLorentzandVertexPar);
196 for(
int i = 0; i<LorentzVectorParticle::NLorentzandVertexPar; i++){
198 for(
int j = 0; j<LorentzVectorParticle::NLorentzandVertexPar; j++){
199 a1_cov(i,j)=cov(i,j);
208 std::vector<TrackParticle> pions;
209 GlobalPoint pvpoint(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
210 const std::vector<edm::Ptr<reco::PFCandidate> >
cands = tau->signalPFChargedHadrCands();
212 if(iter->get()->trackRef().isNonnull()){
214 pions.push_back(ParticleBuilder::createTrackParticle(transTrk,pvpoint,
true,
true));
216 else if(iter->get()->gsfTrackRef().isNonnull()){
221 TVector3
pv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
223 SecondaryVtxOK=chi2v.fit();
224 double c(0);
for(
unsigned int i=0;
i<pions.size();
i++){c+=pions[
i].charge();}
226 a1=chi2v.getMother(pdgid);
232 TVector3
pv(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
233 TMatrixTSym<double> pvcov(LorentzVectorParticle::NVertex);
235 primaryVertex->fill(pvCov);
236 for(
int i = 0;
i<LorentzVectorParticle::NVertex;
i++){
237 for(
int j = 0; j<LorentzVectorParticle::NVertex; j++){
238 pvcov(
i,j)=pvCov(
i,j);
241 for(
unsigned int i=0;
i<PFTau3ProngSummary::nsolutions;
i++){
243 bool isFitOK=TauA1NU.
fit();
247 std::vector<TLorentzVector> daughter_p4;
248 std::vector<int> daughter_charge,daughter_PDGID;
249 for(
unsigned int d=0;
d<daughter.size();
d++){
250 daughter_p4.push_back(daughter[
d].
p4());
251 daughter_charge.push_back((
int)daughter[
d].
charge());
252 daughter_PDGID.push_back(daughter[
d].
pdgId());
254 PFTau3PS.
AddSolution(
i,theTau.
p4(),daughter_p4,daughter_charge,daughter_PDGID,(isFitOK),0.0,-999);
260 PFTau3PSCollection_out->push_back(PFTau3PS);
261 AVPFTau3PS->setValue(iPFTau,PFTau3PSRef);
264 iEvent.
put(
std::move(PFTau3PSCollection_out),
"PFTau3ProngSummary");
std::vector< reco::PFTau3ProngSummary > PFTau3ProngSummaryCollection
collection of PFTau3ProngSummary objects
KinematicParticleVertexFitter kpvFitter_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
TLorentzVector p4() const
PFTau3ProngReco(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > cut_
reco::TransientTrack build(const reco::Track *p) const
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
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
std::vector< LorentzVectorParticle > getRefitDaughters()
LorentzVectorParticle getMother()
const MagneticField * field() const
Abs< T >::type abs(const T &t)
edm::Handle< reco::PFTauDiscriminator > handle_
DiscCutPairVec discriminators_
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &particles) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
edm::Ref< PFTau3ProngSummaryCollection > PFTau3ProngSummaryRef
presistent reference to a PFTau3ProngSummary
~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)
std::vector< DiscCutPair * > DiscCutPairVec
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