CMS 3D CMS Logo

EmbeddingVertexCorrector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TauAnalysis/EmbeddingProducer
4 // Class: EmbeddingVertexCorrector
5 //
13 //
14 // Original Author: Artur Akhmetshin
15 // Created: Sat, 23 Apr 2016 21:47:13 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
33 #include "CLHEP/Units/GlobalSystemOfUnits.h"
34 #include "CLHEP/Units/GlobalPhysicalConstants.h"
35 
41 
46 
50 
51 
52 namespace HepMC {
53  class FourVector ;
54 }
55 
56 //
57 // class declaration
58 //
59 
61  public:
63  ~EmbeddingVertexCorrector() override;
64 
65  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
66 
67  private:
68  void beginRun(const edm::Run & , const edm::EventSetup& iEventSetup) override;
69  void produce(edm::Event&, const edm::EventSetup&) override;
70 
71  // ----------member data ---------------------------
74 };
75 
76 //
77 // constructors and destructor
78 //
80 {
81  produces<edm::HepMCProduct>();
82 
83  sourceLabel = iConfig.getParameter<edm::InputTag>("src");
84  consumes<edm::HepMCProduct>(sourceLabel);
85  vertexPositionLabel = edm::InputTag("externalLHEProducer","vertexPosition");
86  consumes<math::XYZTLorentzVectorD>(vertexPositionLabel);
87 }
88 
90 {
91 }
92 
93 //
94 // member functions
95 //
96 
97 
98 void
100 {
101  // edm::ESHandle< SimBeamSpotObjects > beamhandle;
102  // iEventSetup.get<SimBeamSpotObjectsRcd>().get(beamhandle);
103 
105  iEventSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
106 
107 
108  edm::LogInfo("TauEmbedding")<<"beam handle\n"<<(*beamhandle);
109 
110 
111 }
112 // ------------ method called to produce the data ------------
113 void
115 {
116  using namespace edm;
117 
118  // Retrieving generated Z to TauTau Event
119  Handle<edm::HepMCProduct> InputGenEvent;
120  iEvent.getByLabel(sourceLabel, InputGenEvent);
121  HepMC::GenEvent* genevent = new HepMC::GenEvent(*InputGenEvent->GetEvent());
122  std::unique_ptr<edm::HepMCProduct> CorrectedGenEvent(new edm::HepMCProduct(genevent));
123 
124  //Retrieving vertex position from input and creating vertex shift
125  Handle<math::XYZTLorentzVectorD> vertex_position;
126  iEvent.getByLabel(vertexPositionLabel, vertex_position);
127  HepMC::FourVector vertex_shift(vertex_position.product()->x()*cm, vertex_position.product()->y()*cm, vertex_position.product()->z()*cm);
128 
129  // Apply vertex shift to all production vertices of the event
130  CorrectedGenEvent->applyVtxGen(&vertex_shift);
131  iEvent.put(std::move(CorrectedGenEvent));
132 
133 }
134 
135 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
136 void
138  //The following says we do not know what parameters are allowed so do no validation
139  // Please change this to state exactly what you do use, even if it is no parameters
141  desc.setUnknown();
142  descriptions.addDefault(desc);
143 }
144 
145 //define this as a plug-in
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void beginRun(const edm::Run &, const edm::EventSetup &iEventSetup) override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:74
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
T get() const
Definition: EventSetup.h:71
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
EmbeddingVertexCorrector(const edm::ParameterSet &)