CMS 3D CMS Logo

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