test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauSecondaryVertexProducer.cc
Go to the documentation of this file.
1 /* class PFTauSecondaryVertexProducer
2  * EDProducer of the
3  * authors: Ian M. Nugent
4  * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus.
5  * The idea of the fully reconstructing the tau using a kinematic fit comes from
6  * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This
7  * work was continued by Ian M. Nugent and Vladimir Cherepanov.
8  * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions.
9  */
10 
14 
24 
29 
39 
43 
44 #include <memory>
45 
46 using namespace reco;
47 using namespace edm;
48 using namespace std;
49 
51  public:
52  enum Alg{useInputPV=0, usePVwithMaxSumPt, useTauPV};
53 
54  explicit PFTauSecondaryVertexProducer(const edm::ParameterSet& iConfig);
56  virtual void produce(edm::Event&,const edm::EventSetup&);
57  private:
60 };
61 
63  PFTauToken_(consumes<std::vector<reco::PFTau> >(iConfig.getParameter<edm::InputTag>("PFTauTag")))
64 {
65  produces<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > > >();
66  produces<VertexCollection>("PFTauSecondaryVertices");
67 }
68 
70 
71 }
72 
74  // Obtain
75  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
76  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
77 
79  iEvent.getByToken(PFTauToken_,Tau);
80 
81  // Set Association Map
82  auto_ptr<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > > > AVPFTauSV(new edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > >(PFTauRefProd(Tau)));
83  std::auto_ptr<VertexCollection> VertexCollection_out= std::auto_ptr<VertexCollection>(new VertexCollection);
84  reco::VertexRefProd VertexRefProd_out = iEvent.getRefBeforePut<reco::VertexCollection>("PFTauSecondaryVertices");
85 
86  // For each Tau Run Algorithim
87  if(Tau.isValid()) {
88  for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
89  reco::PFTauRef RefPFTau(Tau, iPFTau);
90  std::vector<reco::VertexRef> SV;
91  if(RefPFTau->decayMode()==10){
93  // Get tracks form PFTau daugthers
94  std::vector<reco::TransientTrack> transTrk;
95  TransientVertex transVtx;
96  const std::vector<edm::Ptr<reco::PFCandidate> > cands = RefPFTau->signalPFChargedHadrCands();
97  for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) {
98  if(iter->get()->trackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->trackRef()));
99  else if(iter->get()->gsfTrackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->gsfTrackRef()));
100  }
102  // Fit the secondary vertex
103  bool FitOk(true);
104  KalmanVertexFitter kvf(true);
105  try{
106  transVtx = kvf.vertex(transTrk); //KalmanVertexFitter
107  }catch(...){
108  FitOk=false;
109  }
110  if(!transVtx.hasRefittedTracks()) FitOk=false;
111  if(transVtx.refittedTracks().size()!=transTrk.size()) FitOk=false;
112  if(FitOk){
113  SV.push_back(reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()));
114  VertexCollection_out->push_back(transVtx);
115  }
116  }
117  AVPFTauSV->setValue(iPFTau, SV);
118  }
119  }
120  iEvent.put(VertexCollection_out,"PFTauSecondaryVertices");
121  iEvent.put(AVPFTauSV);
122 }
123 
PFTauSecondaryVertexProducer(const edm::ParameterSet &iConfig)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool hasRefittedTracks() const
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
Definition: PFTauFwd.h:15
uint16_t size_type
edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool isValid() const
Definition: HandleBase.h:76
RefProd< PROD > getRefBeforePut()
Definition: Event.h:128
const T & get() const
Definition: EventSetup.h:55
std::vector< reco::TransientTrack > const & refittedTracks() const