CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Alignment/LaserAlignmentSimulation/plugins/LaserAlignmentProducer.cc

Go to the documentation of this file.
00001 
00010 // system include files
00011 #include "FWCore/Framework/interface/Event.h"
00012 
00013 // user include files
00014 #include "Alignment/LaserAlignmentSimulation/plugins/LaserAlignmentProducer.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h" 
00016 
00017 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00018 
00019 //
00020 // constructors and destructor
00021 //
00022 LaserAlignmentProducer::LaserAlignmentProducer(const edm::ParameterSet&) :
00023   EDProducer(),
00024   theEvent(0)
00025 {
00026   //register your products
00027   produces<edm::HepMCProduct>();
00028 
00029   //now do what ever other initialization is needed
00030 }
00031 
00032 
00033 LaserAlignmentProducer::~LaserAlignmentProducer()
00034 {
00035   // no need to cleanup theEvent since it's done in HepMCProduct
00036 }
00037 
00038 // ------------ method called to produce the event  ------------
00039 void LaserAlignmentProducer::produce(edm::Event& iEvent, const edm::EventSetup&)
00040 {
00041   // create the event
00042   theEvent = new HepMC::GenEvent();
00043 
00044   // create a primary vertex
00045   HepMC::GenVertex * theVtx = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
00046 
00047   // add a particle to the vertex; this is needed to avoid crashes in OscarProducer. Use a 
00048   // electron neutrino, with zero energy and mass
00049   HepMC::GenParticle * theParticle = new HepMC::GenParticle(HepMC::FourVector(0.,0.,0.,0.),12,1);
00050   
00051   theVtx->add_particle_out(theParticle);
00052 
00053   // add the vertex to the event
00054   theEvent->add_vertex(theVtx);
00055 
00056   // set the event number
00057   theEvent->set_event_number(iEvent.id().event());
00058   // set the signal process id
00059   theEvent->set_signal_process_id(20);
00060 
00061   // create an empty output collection
00062   std::auto_ptr<edm::HepMCProduct> theOutput(new edm::HepMCProduct());
00063   theOutput->addHepMCData(theEvent);
00064    
00065   // put the output to the event
00066   iEvent.put(theOutput);
00067 }
00068 
00069 //define this as a plug-in
00070 
00071 DEFINE_FWK_MODULE(LaserAlignmentProducer);