Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:29

0001 #ifndef RecoTauTag_RecoTau_PFTauPrimaryVertexProducerBase_H_
0002 #define RecoTauTag_RecoTau_PFTauPrimaryVertexProducerBase_H_
0003 
0004 /* class PFTauPrimaryVertexProducerBase
0005  * EDProducer of the 
0006  * authors: Ian M. Nugent
0007  * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus.
0008  * The idea of the fully reconstructing the tau using a kinematic fit comes from
0009  * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This
0010  * work was continued by Ian M. Nugent and Vladimir Cherepanov.
0011  * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions.
0012  */
0013 
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/Frameworkfwd.h"
0017 #include "FWCore/Framework/interface/stream/EDProducer.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0020 
0021 #include "DataFormats/TauReco/interface/PFTau.h"
0022 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0023 #include "DataFormats/MuonReco/interface/Muon.h"
0024 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0025 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0026 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0027 #include "DataFormats/VertexReco/interface/Vertex.h"
0028 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0029 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0030 #include "DataFormats/TrackReco/interface/Track.h"
0031 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0032 
0033 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0034 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0035 
0036 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
0037 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0038 #include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h"
0039 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
0040 
0041 #include <TFormula.h>
0042 
0043 class PFTauPrimaryVertexProducerBase : public edm::stream::EDProducer<> {
0044 public:
0045   enum Alg { useInputPV = 0, useFrontPV };
0046 
0047   struct DiscCutPair {
0048     DiscCutPair() : discr_(nullptr), cutFormula_(nullptr) {}
0049     ~DiscCutPair() { delete cutFormula_; }
0050     const reco::PFTauDiscriminator* discr_;
0051     edm::EDGetTokenT<reco::PFTauDiscriminator> inputToken_;
0052     double cut_;
0053     TFormula* cutFormula_;
0054   };
0055   typedef std::vector<DiscCutPair*> DiscCutPairVec;
0056 
0057   explicit PFTauPrimaryVertexProducerBase(const edm::ParameterSet& iConfig);
0058   ~PFTauPrimaryVertexProducerBase() override;
0059   void produce(edm::Event&, const edm::EventSetup&) override;
0060 
0061   static edm::ParameterSetDescription getDescriptionsBase();
0062 
0063   // called at the beginning of every event - override if necessary
0064   virtual void beginEvent(const edm::Event&, const edm::EventSetup&) {}
0065 
0066 protected:
0067   // abstract function implemented in derived classes
0068   virtual void nonTauTracksInPV(const reco::VertexRef&,
0069                                 const std::vector<edm::Ptr<reco::TrackBase> >&,
0070                                 std::vector<const reco::Track*>&) = 0;
0071 
0072 private:
0073   edm::EDGetTokenT<std::vector<reco::PFTau> > pftauToken_;
0074   edm::EDGetTokenT<edm::View<reco::Electron> > electronToken_;
0075   edm::EDGetTokenT<edm::View<reco::Muon> > muonToken_;
0076   edm::EDGetTokenT<reco::VertexCollection> pvToken_;
0077   edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_;
0078   edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> transTrackBuilderToken_;
0079   int algorithm_;
0080   edm::ParameterSet qualityCutsPSet_;
0081   bool useBeamSpot_;
0082   bool useSelectedTaus_;
0083   bool removeMuonTracks_;
0084   bool removeElectronTracks_;
0085   DiscCutPairVec discriminators_;
0086   std::unique_ptr<StringCutObjectSelector<reco::PFTau> > cut_;
0087   std::unique_ptr<reco::tau::RecoTauVertexAssociator> vertexAssociator_;
0088 };
0089 
0090 #endif