CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecoTauProducer.cc
Go to the documentation of this file.
1 /* class CaloRecoTauProducer
2  * EDProducer of the CaloTauCollection, starting from the CaloTauTagInfoCollection,
3  * authors: Simone Gennai (simone.gennai@cern.ch), Ludovic Houchu (Ludovic.Houchu@cern.ch)
4  */
5 
14 
18 
21 
23 
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 
35  public:
36  explicit CaloRecoTauProducer(const edm::ParameterSet& iConfig);
38  virtual void produce(edm::Event&,const edm::EventSetup&) override;
39  private:
45  double JetMinPt_;
47 };
48 
50  CaloRecoTauTagInfoProducer_ = iConfig.getParameter<edm::InputTag>("CaloRecoTauTagInfoProducer");
51  PVProducer_ = iConfig.getParameter<edm::InputTag>("PVProducer");
52  smearedPVsigmaX_ = iConfig.getParameter<double>("smearedPVsigmaX");
53  smearedPVsigmaY_ = iConfig.getParameter<double>("smearedPVsigmaY");
54  smearedPVsigmaZ_ = iConfig.getParameter<double>("smearedPVsigmaZ");
55  JetMinPt_ = iConfig.getParameter<double>("JetPtMin");
56  CaloRecoTauAlgo_=new CaloRecoTauAlgorithm(iConfig);
57  produces<CaloTauCollection>();
58  produces<DetIdCollection>();
59 }
61  delete CaloRecoTauAlgo_;
62 }
63 
65 
66  auto_ptr<CaloTauCollection> resultCaloTau(new CaloTauCollection);
67  auto_ptr<DetIdCollection> selectedDetIds(new DetIdCollection);
68 
69  edm::ESHandle<TransientTrackBuilder> myTransientTrackBuilder;
70  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",myTransientTrackBuilder);
71  CaloRecoTauAlgo_->setTransientTrackBuilder(myTransientTrackBuilder.product());
72 
74  iSetup.get<IdealMagneticFieldRecord>().get(myMF);
75  CaloRecoTauAlgo_->setMagneticField(myMF.product());
76 
77  // query a rec/sim PV
79  iEvent.getByLabel(PVProducer_,thePVs);
80  const VertexCollection vertCollection=*(thePVs.product());
81  Vertex thePV;
82  if(vertCollection.size()) thePV=*(vertCollection.begin());
83  else{
84  Vertex::Error SimPVError;
85  SimPVError(0,0)=smearedPVsigmaX_*smearedPVsigmaX_;
86  SimPVError(1,1)=smearedPVsigmaY_*smearedPVsigmaY_;
87  SimPVError(2,2)=smearedPVsigmaZ_*smearedPVsigmaZ_;
88  Vertex::Point SimPVPoint(CLHEP::RandGauss::shoot(0.,smearedPVsigmaX_),
89  CLHEP::RandGauss::shoot(0.,smearedPVsigmaY_),
90  CLHEP::RandGauss::shoot(0.,smearedPVsigmaZ_));
91  thePV=Vertex(SimPVPoint,SimPVError,1,1,1);
92  }
93 
94  edm::Handle<CaloTauTagInfoCollection> theCaloTauTagInfoCollection;
95  iEvent.getByLabel(CaloRecoTauTagInfoProducer_,theCaloTauTagInfoCollection);
96  int iinfo=0;
97  for(CaloTauTagInfoCollection::const_iterator i_info=theCaloTauTagInfoCollection->begin();i_info!=theCaloTauTagInfoCollection->end();i_info++) {
98  if(i_info->jetRef()->pt()>JetMinPt_){
99  CaloTau myCaloTau=CaloRecoTauAlgo_->buildCaloTau(iEvent,iSetup,Ref<CaloTauTagInfoCollection>(theCaloTauTagInfoCollection,iinfo),thePV);
100  resultCaloTau->push_back(myCaloTau);
101  }
102  ++iinfo;
103  }
104  for(unsigned int i =0;i<CaloRecoTauAlgo_->mySelectedDetId_.size();i++)
105  selectedDetIds->push_back(CaloRecoTauAlgo_->mySelectedDetId_[i]);
106 
107 
108  iEvent.put(resultCaloTau);
109  iEvent.put(selectedDetIds);
110 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
CaloRecoTauProducer(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
CaloRecoTauAlgorithm * CaloRecoTauAlgo_
std::vector< CaloTau > CaloTauCollection
collection of CaloTau objects
Definition: CaloTauFwd.h:9
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::InputTag CaloRecoTauTagInfoProducer_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86