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),
31  sourceLabel(pset.getParameter<edm::InputTag>("src"))
32 {
33 
35  if ( ! rng.isAvailable()) {
36  throw cms::Exception("Configuration")
37  << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
38  "which is not present in the configuration file. \n"
39  "You must add the service\n"
40  "in the configuration file or remove the modules that require it.";
41  }
42 
43  consumes<edm::HepMCProduct>(pset.getParameter<edm::InputTag>("src"));
44  produces<bool>();
45 }
46 
48 {
49  delete fVertex ;
50  if (boost_ != 0 ) delete boost_;
51  // no need since now it's done in HepMCProduct
52  // delete fEvt ;
53 }
54 
56 {
58  CLHEP::HepRandomEngine* engine = &rng->getEngine(evt.streamID());
59 
60  Handle<HepMCProduct> HepMCEvt ;
61 
62  evt.getByLabel( sourceLabel, HepMCEvt ) ;
63 
64  // generate new vertex & apply the shift
65  //
66  HepMCEvt->applyVtxGen( newVertex(engine) ) ;
67 
68  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
69  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
70  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
71 
72  // OK, create a (pseudo)product and put in into edm::Event
73  //
74  auto_ptr<bool> NewProduct(new bool(true)) ;
75  evt.put( NewProduct ) ;
76 
77  return ;
78 }
T getParameter(std::string const &) const
HepMC::FourVector * fVertex
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual HepMC::FourVector * newVertex(CLHEP::HepRandomEngine *)=0
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
return(e1-e2)*(e1-e2)+dp *dp
StreamID streamID() const
Definition: Event.h:75