CMS 3D CMS Logo

PFRecoTauProducer.cc
Go to the documentation of this file.
1 /* class PFRecoTauProducer
2  * EDProducer of the PFTauCollection, starting from the PFTauTagInfoCollection,
3  * authors: Simone Gennai (simone.gennai@cern.ch), Ludovic Houchu (Ludovic.Houchu@cern.ch)
4  */
5 
9 
19 
22 
25 
26 #include "CLHEP/Random/RandGauss.h"
27 
28 #include <memory>
29 
30 using namespace reco;
31 using namespace edm;
32 using namespace std;
33 
34 class PFRecoTauProducer : public EDProducer {
35  public:
36  explicit PFRecoTauProducer(const edm::ParameterSet& iConfig);
37  ~PFRecoTauProducer() override;
38  void produce(edm::Event&,const edm::EventSetup&) override;
39  private:
47  double JetMinPt_;
49 };
50 
52  PFTauTagInfoProducer_ = consumes<PFTauTagInfoCollection>(iConfig.getParameter<edm::InputTag>("PFTauTagInfoProducer") );
53  ElectronPreIDProducer_ = iConfig.getParameter<edm::InputTag>("ElectronPreIDProducer");
54  PVProducer_ = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("PVProducer") );
55  Algorithm_ = iConfig.getParameter<std::string>("Algorithm");
56  smearedPVsigmaX_ = iConfig.getParameter<double>("smearedPVsigmaX");
57  smearedPVsigmaY_ = iConfig.getParameter<double>("smearedPVsigmaY");
58  smearedPVsigmaZ_ = iConfig.getParameter<double>("smearedPVsigmaZ");
59  JetMinPt_ = iConfig.getParameter<double>("JetPtMin");
60 
61  if(Algorithm_ =="ConeBased") {
62  PFRecoTauAlgo_=new PFRecoTauAlgorithm(iConfig);
63  }
64  else if(Algorithm_ =="HPS") {
65  PFRecoTauAlgo_=new HPSPFRecoTauAlgorithm(iConfig);
66  }
67  else { //Add inside out Algorithm here
68 
69  //If no Algorithm found throw exception
70  throw cms::Exception("") << "Unknown Algorithkm" << std::endl;
71  }
72 
73 
74  produces<PFTauCollection>();
75 }
77  delete PFRecoTauAlgo_;
78 }
79 
81  auto resultPFTau = std::make_unique<PFTauCollection>();
82 
83  edm::ESHandle<TransientTrackBuilder> myTransientTrackBuilder;
84  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",myTransientTrackBuilder);
85  PFRecoTauAlgo_->setTransientTrackBuilder(myTransientTrackBuilder.product());
86 
87  //edm::ESHandle<MagneticField> myMF;
88  //iSetup.get<IdealMagneticFieldRecord>().get(myMF);
89  //PFRecoTauAlgo_->setMagneticField(myMF.product());
90 
91  // Electron PreID tracks: Temporary until integrated to PFCandidate
92  /*
93  edm::Handle<PFRecTrackCollection> myPFelecTk;
94  iEvent.getByLabel(ElectronPreIDProducer_,myPFelecTk);
95  const PFRecTrackCollection theElecTkCollection=*(myPFelecTk.product());
96  */
97  // query a rec/sim PV
99  iEvent.getByToken(PVProducer_,thePVs);
100  const VertexCollection vertCollection=*(thePVs.product());
101  Vertex thePV;
102  if(!vertCollection.empty()) thePV=*(vertCollection.begin());
103  else{
104  Vertex::Error SimPVError;
105  SimPVError(0,0)=smearedPVsigmaX_*smearedPVsigmaX_;
106  SimPVError(1,1)=smearedPVsigmaY_*smearedPVsigmaY_;
107  SimPVError(2,2)=smearedPVsigmaZ_*smearedPVsigmaZ_;
108  Vertex::Point SimPVPoint(CLHEP::RandGauss::shoot(0.,smearedPVsigmaX_),
109  CLHEP::RandGauss::shoot(0.,smearedPVsigmaY_),
110  CLHEP::RandGauss::shoot(0.,smearedPVsigmaZ_));
111  thePV=Vertex(SimPVPoint,SimPVError,1,1,1);
112  }
113 
114  edm::Handle<PFTauTagInfoCollection> thePFTauTagInfoCollection;
115  iEvent.getByToken(PFTauTagInfoProducer_,thePFTauTagInfoCollection);
116  int iinfo=0;
117  for(PFTauTagInfoCollection::const_iterator i_info=thePFTauTagInfoCollection->begin();i_info!=thePFTauTagInfoCollection->end();i_info++) {
118  if((*i_info).pfjetRef()->pt()>JetMinPt_){
119  // PFTau myPFTau=PFRecoTauAlgo_->buildPFTau(Ref<PFTauTagInfoCollection>(thePFTauTagInfoCollection,iinfo),thePV,theElecTkCollection);
120  PFTau myPFTau=PFRecoTauAlgo_->buildPFTau(Ref<PFTauTagInfoCollection>(thePFTauTagInfoCollection,iinfo),thePV);
121  resultPFTau->push_back(myPFTau);
122  }
123  ++iinfo;
124  }
125  iEvent.put(std::move(resultPFTau));
126 }
127 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
PFRecoTauProducer(const edm::ParameterSet &iConfig)
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:230
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
edm::InputTag ElectronPreIDProducer_
PFRecoTauAlgorithmBase * PFRecoTauAlgo_
fixed size matrix
HLT enums.
edm::EDGetTokenT< PFTauTagInfoCollection > PFTauTagInfoProducer_
~PFRecoTauProducer() override
edm::EDGetTokenT< VertexCollection > PVProducer_
def move(src, dest)
Definition: eostools.py:510