CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BaseEvtVtxGenerator.cc
Go to the documentation of this file.
1 
2 /*
3 */
4 
6 
9 
11 
14 
16 
19 
20 //#include "HepMC/GenEvent.h"
21 // #include "CLHEP/Vector/ThreeVector.h"
22 // #include "HepMC/SimpleVector.h"
23 
24 using namespace edm;
25 using namespace std;
26 using namespace CLHEP;
27 //using namespace HepMC;
28 
30  : fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
31  sourceLabel(pset.getParameter<edm::InputTag>("src"))
32 {
33 
34 /* No longer needed...
35 
36  // 1st of all, check on module_label - must be VtxSmeared !
37  if ( pset.getParameter<string>("@module_label") != "VtxSmeared" )
38  {
39  throw cms::Exception("Configuration")
40  << "Module has an invalid module label. "
41  "The label of this module MUST be VtxSmeared.";
42  }
43 */
44 
46 
47  if ( ! rng.isAvailable()) {
48 
49  throw cms::Exception("Configuration")
50  << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
51  "which is not present in the configuration file. You must add the service\n"
52  "in the configuration file or remove the modules that require it.";
53  }
54 
55  CLHEP::HepRandomEngine& engine = rng->getEngine();
56  fEngine = &engine;
57 
58 
59  produces<bool>();
60 }
61 
63 {
64  delete fVertex ;
65  if (boost_ != 0 ) delete boost_;
66  // no need since now it's done in HepMCProduct
67  // delete fEvt ;
68 }
69 
71 {
72 
73 
74  Handle<HepMCProduct> HepMCEvt ;
75 
76  evt.getByLabel( sourceLabel, HepMCEvt ) ;
77 
78  // generate new vertex & apply the shift
79  //
80  HepMCEvt->applyVtxGen( newVertex() ) ;
81 
82  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
83  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
84  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
85 
86  // OK, create a (pseudo)product and put in into edm::Event
87  //
88  auto_ptr<bool> NewProduct(new bool(true)) ;
89  evt.put( NewProduct ) ;
90 
91  return ;
92 }
93 
94 CLHEP::HepRandomEngine& BaseEvtVtxGenerator::getEngine()
95 {
96  return *fEngine;
97 }
CLHEP::HepRandomEngine & getEngine()
virtual HepMC::FourVector * newVertex()=0
HepMC::FourVector * fVertex
virtual void produce(edm::Event &, const edm::EventSetup &) override
CLHEP::HepRandomEngine * fEngine
BaseEvtVtxGenerator(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool isAvailable() const
Definition: Service.h:46
virtual TMatrixD * GetInvLorentzBoost()=0
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
return(e1-e2)*(e1-e2)+dp *dp