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 
28 
29 #include "CLHEP/Random/RandGauss.h"
30 
31 #include <memory>
32 
33 using namespace reco;
34 using namespace edm;
35 using namespace std;
36 
37 class PFRecoTauProducer : public EDProducer {
38  public:
39  explicit PFRecoTauProducer(const edm::ParameterSet& iConfig);
40  ~PFRecoTauProducer() override;
41  void produce(edm::Event&,const edm::EventSetup&) override;
42  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
43  private:
51  double JetMinPt_;
53 };
54 
56  PFTauTagInfoProducer_ = consumes<PFTauTagInfoCollection>(iConfig.getParameter<edm::InputTag>("PFTauTagInfoProducer") );
57  ElectronPreIDProducer_ = iConfig.getParameter<edm::InputTag>("ElectronPreIDProducer");
58  PVProducer_ = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("PVProducer") );
59  Algorithm_ = iConfig.getParameter<std::string>("Algorithm");
60  smearedPVsigmaX_ = iConfig.getParameter<double>("smearedPVsigmaX");
61  smearedPVsigmaY_ = iConfig.getParameter<double>("smearedPVsigmaY");
62  smearedPVsigmaZ_ = iConfig.getParameter<double>("smearedPVsigmaZ");
63  JetMinPt_ = iConfig.getParameter<double>("JetPtMin");
64 
65  if(Algorithm_ =="ConeBased") {
66  PFRecoTauAlgo_=new PFRecoTauAlgorithm(iConfig);
67  }
68  else if(Algorithm_ =="HPS") {
69  PFRecoTauAlgo_=new HPSPFRecoTauAlgorithm(iConfig);
70  }
71  else { //Add inside out Algorithm here
72 
73  //If no Algorithm found throw exception
74  throw cms::Exception("") << "Unknown Algorithkm" << std::endl;
75  }
76 
77 
78  produces<PFTauCollection>();
79 }
81  delete PFRecoTauAlgo_;
82 }
83 
85  auto resultPFTau = std::make_unique<PFTauCollection>();
86 
87  edm::ESHandle<TransientTrackBuilder> myTransientTrackBuilder;
88  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",myTransientTrackBuilder);
89  PFRecoTauAlgo_->setTransientTrackBuilder(myTransientTrackBuilder.product());
90 
91  //edm::ESHandle<MagneticField> myMF;
92  //iSetup.get<IdealMagneticFieldRecord>().get(myMF);
93  //PFRecoTauAlgo_->setMagneticField(myMF.product());
94 
95  // Electron PreID tracks: Temporary until integrated to PFCandidate
96  /*
97  edm::Handle<PFRecTrackCollection> myPFelecTk;
98  iEvent.getByLabel(ElectronPreIDProducer_,myPFelecTk);
99  const PFRecTrackCollection theElecTkCollection=*(myPFelecTk.product());
100  */
101  // query a rec/sim PV
103  iEvent.getByToken(PVProducer_,thePVs);
104  const VertexCollection vertCollection=*(thePVs.product());
105  Vertex thePV;
106  if(!vertCollection.empty()) thePV=*(vertCollection.begin());
107  else{
108  Vertex::Error SimPVError;
109  SimPVError(0,0)=smearedPVsigmaX_*smearedPVsigmaX_;
110  SimPVError(1,1)=smearedPVsigmaY_*smearedPVsigmaY_;
111  SimPVError(2,2)=smearedPVsigmaZ_*smearedPVsigmaZ_;
112  Vertex::Point SimPVPoint(CLHEP::RandGauss::shoot(0.,smearedPVsigmaX_),
113  CLHEP::RandGauss::shoot(0.,smearedPVsigmaY_),
114  CLHEP::RandGauss::shoot(0.,smearedPVsigmaZ_));
115  thePV=Vertex(SimPVPoint,SimPVError,1,1,1);
116  }
117 
118  edm::Handle<PFTauTagInfoCollection> thePFTauTagInfoCollection;
119  iEvent.getByToken(PFTauTagInfoProducer_,thePFTauTagInfoCollection);
120  int iinfo=0;
121  for(PFTauTagInfoCollection::const_iterator i_info=thePFTauTagInfoCollection->begin();i_info!=thePFTauTagInfoCollection->end();i_info++) {
122  if((*i_info).pfjetRef()->pt()>JetMinPt_){
123  // PFTau myPFTau=PFRecoTauAlgo_->buildPFTau(Ref<PFTauTagInfoCollection>(thePFTauTagInfoCollection,iinfo),thePV,theElecTkCollection);
124  PFTau myPFTau=PFRecoTauAlgo_->buildPFTau(Ref<PFTauTagInfoCollection>(thePFTauTagInfoCollection,iinfo),thePV);
125  resultPFTau->push_back(myPFTau);
126  }
127  ++iinfo;
128  }
129  iEvent.put(std::move(resultPFTau));
130 }
131 
132 void
134  // pfRecoTauProducer
136  desc.add<double>("Rphi", 2.0);
137  desc.add<double>("LeadTrack_minPt", 0.0);
138  desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices"));
139  desc.add<std::string>("ECALSignalConeSizeFormula", "0.15");
140  desc.add<std::string>("TrackerIsolConeMetric", "DR");
141  desc.add<std::string>("TrackerSignalConeMetric", "DR");
142  desc.add<double>("EcalStripSumE_deltaPhiOverQ_minValue", -0.1);
143  desc.add<double>("smearedPVsigmaX", 0.0015);
144  desc.add<double>("smearedPVsigmaY", 0.0015);
145  desc.add<std::string>("MatchingConeMetric", "DR");
146  desc.add<std::string>("TrackerSignalConeSizeFormula", "0.07");
147  desc.add<std::string>("MatchingConeSizeFormula", "0.1");
148  desc.add<double>("TrackerIsolConeSize_min", 0.0);
149  desc.add<double>("MatchingConeSize_min", 0.0);
150  desc.add<edm::InputTag>("ElectronPreIDProducer", edm::InputTag("elecpreid"));
151  desc.add<double>("ChargedHadrCandLeadChargedHadrCand_tksmaxDZ", 1.0);
152  desc.add<double>("TrackerIsolConeSize_max", 0.6);
153  desc.add<double>("TrackerSignalConeSize_max", 0.07);
154  desc.add<std::string>("HCALIsolConeMetric", "DR");
155  desc.add<bool>("AddEllipseGammas", false);
156  desc.add<double>("maximumForElectrionPreIDOutput", -0.1);
157  desc.add<double>("TrackerSignalConeSize_min", 0.0);
158  desc.add<double>("JetPtMin", 0.0);
159  desc.add<std::string>("HCALIsolConeSizeFormula", "0.50");
160  desc.add<double>("AreaMetric_recoElements_maxabsEta", 2.5);
161  desc.add<double>("HCALIsolConeSize_max", 0.6);
162  desc.add<unsigned int>("Track_IsolAnnulus_minNhits", 3);
163  desc.add<std::string>("HCALSignalConeMetric", "DR");
164  desc.add<double>("ElecPreIDLeadTkMatch_maxDR", 0.01);
165  desc.add<edm::InputTag>("PFTauTagInfoProducer", edm::InputTag("pfRecoTauTagInfoProducer"));
166  desc.add<std::string>("ECALIsolConeMetric", "DR");
167  desc.add<std::string>("ECALIsolConeSizeFormula", "0.50");
168  desc.add<bool>("UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint", true);
169  desc.add<std::string>("Algorithm", "ConeBased");
170  desc.add<double>("ECALIsolConeSize_max", 0.6);
171  desc.add<std::string>("ECALSignalConeMetric", "DR");
172  desc.add<double>("EcalStripSumE_deltaPhiOverQ_maxValue", 0.5);
173  desc.add<double>("HCALSignalConeSize_max", 0.6);
174  desc.add<double>("ECALSignalConeSize_min", 0.0);
175  desc.add<double>("EcalStripSumE_minClusEnergy", 0.1);
176  desc.add<double>("EcalStripSumE_deltaEta", 0.03);
177  desc.add<std::string>("TrackerIsolConeSizeFormula", "0.50");
178  desc.add<double>("LeadPFCand_minPt", 5.0);
179  desc.add<double>("HCALSignalConeSize_min", 0.0);
180  desc.add<double>("ECALSignalConeSize_max", 0.6);
181  desc.add<std::string>("HCALSignalConeSizeFormula", "0.10");
182  desc.add<bool>("putNeutralHadronsInP4", false);
183  desc.add<double>("TrackLeadTrack_maxDZ", 1.0);
184  desc.add<unsigned int>("ChargedHadrCand_IsolAnnulus_minNhits", 0);
185  desc.add<double>("ECALIsolConeSize_min", 0.0);
186  desc.add<bool>("UseTrackLeadTrackDZconstraint", true);
187  desc.add<double>("MaxEtInEllipse", 2.0);
188  desc.add<std::string>("DataType", "AOD");
189  desc.add<double>("smearedPVsigmaZ", 0.005);
190  desc.add<double>("MatchingConeSize_max", 0.6);
191  desc.add<double>("HCALIsolConeSize_min", 0.0);
192  descriptions.add("pfRecoTauProducerDef", desc);
193 }
194 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:74
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::InputTag ElectronPreIDProducer_
PFRecoTauAlgorithmBase * PFRecoTauAlgo_
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< PFTauTagInfoCollection > PFTauTagInfoProducer_
~PFRecoTauProducer() override
edm::EDGetTokenT< VertexCollection > PVProducer_
def move(src, dest)
Definition: eostools.py:511