49 #include <boost/foreach.hpp>
64 #include "TLorentzVector.h"
71 using namespace tauImpactParameter;
75 enum Alg{useKalmanFit=0, useTrackHelix};
95 std::auto_ptr<StringCutObjectSelector<reco::PFTau> >
cut_;
101 PFTauTag_(iConfig.getParameter<edm::
InputTag>(
"PFTauTag")),
102 PFTauTIPTag_(iConfig.getParameter<edm::
InputTag>(
"PFTauTIPTag")),
103 Algorithm_(iConfig.getParameter<int>(
"Algorithm")),
104 ndfPVT_(iConfig.getUntrackedParameter(
"ndfPVT",(int)5))
119 produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef> > >();
120 produces<PFTau3ProngSummaryCollection>(
"PFTau3ProngSummary");
139 std::auto_ptr<PFTau3ProngSummaryCollection> PFTau3PSCollection_out= std::auto_ptr<PFTau3ProngSummaryCollection>(
new PFTau3ProngSummaryCollection());
155 bool passedDisc =
true;
157 else passedDisc = ((*disc->
handle_)[tau] > disc->
cut_);
158 if ( !passedDisc ){passed =
false;
break;}
160 if (passed &&
cut_.get()){passed = (*cut_)(*tau);}
167 bool SecondaryVtxOK(
false);
169 if(theTIP->hasSecondaryVertex() && primaryVertex->ndof()>
ndfPVT_){
170 const VertexRef secVtx=theTIP->secondaryVertex();
171 GlobalPoint sv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
172 double vtxchi2(0), vtxndf(1);
174 vtxchi2=secVtx->chi2();
175 vtxndf=secVtx->ndof();
176 const std::vector<reco::Track>&
selectedTracks=secVtx->refittedTracks();
177 std::vector<reco::TransientTrack> transTrkVect;
178 for(
unsigned int i = 0;
i!=selectedTracks.size();
i++) transTrkVect.push_back(transTrackBuilder->build(selectedTracks[
i]));
180 float piMassSigma(1.
e-6), piChi(0.0), piNdf(0.0);
181 std::vector<RefCountedKinematicParticle> pions;
182 for(
unsigned int i = 0; i<transTrkVect.size();i++) pions.push_back(kinFactory.
particle(transTrkVect[i],pdgInfo.
pi_mass(),piChi,piNdf,sv,piMassSigma));
184 jpTree->movePointerToTheTop();
186 AlgebraicSymMatrix77 cov=jpTree->currentParticle()->currentState().kinematicParametersError().matrix();
189 std::vector<reco::Track> Tracks;
190 std::vector<LorentzVectorParticle> ReFitPions;
191 for(
unsigned int i=0;i<transTrkVect.size();i++){
192 c+=transTrkVect[
i].charge();
193 ReFitPions.push_back(ParticleBuilder::createLorentzVectorParticle(transTrkVect[i],*secVtx,
true,
true));
196 TVectorT<double> a1_par(LorentzVectorParticle::NLorentzandVertexPar);
197 TMatrixTSym<double> a1_cov(LorentzVectorParticle::NLorentzandVertexPar);
198 for(
int i = 0; i<LorentzVectorParticle::NLorentzandVertexPar; i++){
200 for(
int j = 0;
j<LorentzVectorParticle::NLorentzandVertexPar;
j++){
201 a1_cov(i,
j)=cov(i,
j);
210 std::vector<TrackParticle> pions;
211 GlobalPoint pvpoint(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
212 const std::vector<edm::Ptr<reco::PFCandidate> > cands = tau->signalPFChargedHadrCands();
214 if(
iter->get()->trackRef().isNonnull()){
216 pions.push_back(ParticleBuilder::createTrackParticle(transTrk,pvpoint,
true,
true));
218 else if(
iter->get()->gsfTrackRef().isNonnull()){
223 TVector3
pv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
225 SecondaryVtxOK=chi2v.fit();
226 double c(0);
for(
unsigned int i=0;
i<pions.size();
i++){c+=pions[
i].charge();}
228 a1=chi2v.getMother(pdgid);
234 TVector3
pv(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
235 TMatrixTSym<double> pvcov(LorentzVectorParticle::NVertex);
237 primaryVertex->fill(pvCov);
238 for(
int i = 0;
i<LorentzVectorParticle::NVertex;
i++){
239 for(
int j = 0;
j<LorentzVectorParticle::NVertex;
j++){
240 pvcov(
i,
j)=pvCov(
i,
j);
243 for(
unsigned int i=0;
i<PFTau3ProngSummary::nsolutions;
i++){
245 bool isFitOK=TauA1NU.
fit();
249 std::vector<TLorentzVector> daughter_p4;
250 std::vector<int> daughter_charge,daughter_PDGID;
251 for(
unsigned int d=0;
d<daughter.size();
d++){
252 daughter_p4.push_back(daughter[
d].
p4());
253 daughter_charge.push_back((
int)daughter[
d].
charge());
254 daughter_PDGID.push_back(daughter[
d].
pdgId());
256 PFTau3PS.
AddSolution(
i,theTau.
p4(),daughter_p4,daughter_charge,daughter_PDGID,(isFitOK),0.0,-999);
262 PFTau3PSCollection_out->push_back(PFTau3PS);
263 AVPFTau3PS->setValue(iPFTau,PFTau3PSRef);
266 iEvent.
put(PFTau3PSCollection_out,
"PFTau3ProngSummary");
267 iEvent.
put(AVPFTau3PS);
std::vector< reco::PFTau3ProngSummary > PFTau3ProngSummaryCollection
collection of PFTau3ProngSummary objects
KinematicParticleVertexFitter kpvFitter_
T getParameter(std::string const &) const
TLorentzVector p4() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
PFTau3ProngReco(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
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
virtual void produce(edm::Event &, const edm::EventSetup &)
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > cut_
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
std::vector< LorentzVectorParticle > getRefitDaughters()
LorentzVectorParticle getMother()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
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