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 * $Date: 2009/05/25 12:46:03 $
4 * $Revision: 1.14 $
5 */
6 
8 
11 
13 
16 
18 
21 
22 //#include "HepMC/GenEvent.h"
23 // #include "CLHEP/Vector/ThreeVector.h"
24 // #include "HepMC/SimpleVector.h"
25 
26 using namespace edm;
27 using namespace std;
28 using namespace CLHEP;
29 //using namespace HepMC;
30 
32  : fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
33  sourceLabel(pset.getParameter<edm::InputTag>("src"))
34 {
35 
36 /* No longer needed...
37 
38  // 1st of all, check on module_label - must be VtxSmeared !
39  if ( pset.getParameter<string>("@module_label") != "VtxSmeared" )
40  {
41  throw cms::Exception("Configuration")
42  << "Module has an invalid module label. "
43  "The label of this module MUST be VtxSmeared.";
44  }
45 */
46 
48 
49  if ( ! rng.isAvailable()) {
50 
51  throw cms::Exception("Configuration")
52  << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
53  "which is not present in the configuration file. You must add the service\n"
54  "in the configuration file or remove the modules that require it.";
55  }
56 
57  CLHEP::HepRandomEngine& engine = rng->getEngine();
58  fEngine = &engine;
59 
60 
61  produces<bool>();
62 }
63 
65 {
66  delete fVertex ;
67  if (boost_ != 0 ) delete boost_;
68  // no need since now it's done in HepMCProduct
69  // delete fEvt ;
70 }
71 
73 {
74 
75 
76  Handle<HepMCProduct> HepMCEvt ;
77 
78  evt.getByLabel( sourceLabel, HepMCEvt ) ;
79 
80  // generate new vertex & apply the shift
81  //
82  HepMCEvt->applyVtxGen( newVertex() ) ;
83 
84  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
85  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
86  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
87 
88  // OK, create a (pseudo)product and put in into edm::Event
89  //
90  auto_ptr<bool> NewProduct(new bool(true)) ;
91  evt.put( NewProduct ) ;
92 
93  return ;
94 }
95 
96 CLHEP::HepRandomEngine& BaseEvtVtxGenerator::getEngine()
97 {
98  return *fEngine;
99 }
CLHEP::HepRandomEngine & getEngine()
virtual HepMC::FourVector * newVertex()=0
HepMC::FourVector * fVertex
CLHEP::HepRandomEngine * fEngine
BaseEvtVtxGenerator(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
bool isAvailable() const
Definition: Service.h:47
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:356