#include <FastSimulation/EventProducer/interface/FamosProducer.h>
Public Member Functions | |
virtual void | beginRun (edm::Run &run, const edm::EventSetup &es) |
virtual void | endJob () |
FamosProducer (edm::ParameterSet const &p) | |
virtual void | produce (edm::Event &e, const edm::EventSetup &c) |
virtual | ~FamosProducer () |
Private Attributes | |
HepMC::GenEvent * | evt_ |
FamosManager * | famosManager_ |
bool | simulateMuons |
edm::InputTag | theBeamSpotLabel |
edm::InputTag | theGenParticleLabel |
edm::InputTag | theSourceLabel |
Definition at line 15 of file FamosProducer.h.
FamosProducer::FamosProducer | ( | edm::ParameterSet const & | p | ) | [explicit] |
Definition at line 31 of file FamosProducer.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), famosManager_, edm::ParameterSet::getParameter(), simulateMuons, theBeamSpotLabel, theGenParticleLabel, and theSourceLabel.
00032 { 00033 00034 std::cout << " FamosProducer initializing " << std::endl; 00035 00036 produces<edm::SimTrackContainer>(); 00037 produces<edm::SimVertexContainer>(); 00038 produces<edm::PSimHitContainer>("TrackerHits"); 00039 produces<edm::PCaloHitContainer>("EcalHitsEB"); 00040 produces<edm::PCaloHitContainer>("EcalHitsEE"); 00041 produces<edm::PCaloHitContainer>("EcalHitsES"); 00042 produces<edm::PCaloHitContainer>("HcalHits"); 00043 // Temporary facility to allow for the crossing frame to work... 00044 simulateMuons = p.getParameter<bool>("SimulateMuons"); 00045 if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks"); 00046 00047 // The generator input label 00048 theSourceLabel = p.getParameter<edm::InputTag>("SourceLabel"); 00049 theGenParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel"); 00050 theBeamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel"); 00051 00052 famosManager_ = new FamosManager(p); 00053 00054 }
FamosProducer::~FamosProducer | ( | ) | [virtual] |
Definition at line 56 of file FamosProducer.cc.
References famosManager_.
00057 { if ( famosManager_ ) delete famosManager_; }
void FamosProducer::beginRun | ( | edm::Run & | run, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 60 of file FamosProducer.cc.
References famosManager_, and FamosManager::setupGeometryAndField().
00060 { 00061 famosManager_->setupGeometryAndField(run,es); 00062 }
Reimplemented from edm::EDProducer.
Definition at line 64 of file FamosProducer.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
void FamosProducer::produce | ( | edm::Event & | e, | |
const edm::EventSetup & | c | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 69 of file FamosProducer.cc.
References PrimaryVertexGenerator::beamSpot(), PrimaryVertexGenerator::boost(), FamosManager::calorimetryManager(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), famosManager_, TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), FSimEvent::load(), CalorimetryManager::loadFromEcalBarrel(), CalorimetryManager::loadFromEcalEndcap(), CalorimetryManager::loadFromHcal(), CalorimetryManager::loadFromPreshower(), TrajectoryManager::loadSimHits(), m1, p1, p2, p3, p4, p5, p6, p7, edm::Event::put(), FamosManager::reconstruct(), FBaseSimEvent::setBeamSpot(), FamosManager::simEvent(), simulateMuons, source, theBeamSpotLabel, theGenParticleLabel, FBaseSimEvent::thePrimaryVertexGenerator(), theSourceLabel, and FamosManager::trackerManager().
00070 { 00071 using namespace edm; 00072 00073 // The beam spot position 00074 edm::Handle<reco::BeamSpot> recoBeamSpotHandle; 00075 iEvent.getByLabel(theBeamSpotLabel,recoBeamSpotHandle); 00076 math::XYZPoint BSPosition_ = recoBeamSpotHandle->position(); 00077 00078 // Get the generated event(s) from the edm::Event 00079 // 1. Check if a HepMCProduct exists 00080 // a. Take the VtxSmeared if it exists 00081 // b. Take the source otherwise 00082 // 2. Otherwise go for the CandidateCollection 00083 Handle<HepMCProduct> theHepMCProduct; 00084 00085 const HepMC::GenEvent* myGenEvent = 0; 00086 FSimEvent* fevt = famosManager_->simEvent(); 00087 fevt->setBeamSpot(BSPosition_); 00088 PrimaryVertexGenerator* theVertexGenerator = fevt->thePrimaryVertexGenerator(); 00089 00090 // Get the generated signal event 00091 bool source = iEvent.getByLabel(theSourceLabel,theHepMCProduct); 00092 if ( source ) { 00093 myGenEvent = theHepMCProduct->GetEvent(); 00094 // First rotate in case of beam crossing angle (except if done already) 00095 if ( theVertexGenerator ) { 00096 TMatrixD* boost = theVertexGenerator->boost(); 00097 if ( boost ) theHepMCProduct->boostToLab(boost,"momentum"); 00098 } 00099 myGenEvent = theHepMCProduct->GetEvent(); 00100 } 00101 00102 // In case there is no HepMCProduct, seek a genParticle Candidate Collection 00103 bool genPart = false; 00104 const reco::GenParticleCollection* myGenParticles = 0; 00105 if ( !myGenEvent ) { 00106 // Look for the particle CandidateCollection 00107 Handle<reco::GenParticleCollection> genEvt; 00108 genPart = iEvent.getByLabel(theGenParticleLabel,genEvt); 00109 if ( genPart ) myGenParticles = &(*genEvt); 00110 } 00111 00112 if ( !myGenEvent && !genPart ) 00113 std::cout << "There is no generator input for this event, under " 00114 << "any form (HepMCProduct, genParticles)" << std::endl 00115 << "Please check SourceLabel or GenParticleLabel" << std::endl; 00116 00117 // Get the pile-up events from the pile-up producer 00118 // There might be no pile-up events, by the way, in that case, just continue 00119 00120 Handle<HepMCProduct> thePileUpEvents; 00121 bool isPileUp = iEvent.getByLabel("famosPileUp","PileUpEvents",thePileUpEvents); 00122 const HepMC::GenEvent* thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0; 00123 00124 // .and pass the event to the Famos Manager for propagation and simulation 00125 if ( myGenEvent || myGenParticles ) 00126 famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents); 00127 00128 // Set the vertex back to the HepMCProduct (except if it was smeared already) 00129 if ( myGenEvent ) { 00130 if ( theVertexGenerator ) { 00131 HepMC::FourVector theVertex( 00132 (theVertexGenerator->X()-theVertexGenerator->beamSpot().X()+BSPosition_.X())*10., 00133 (theVertexGenerator->Y()-theVertexGenerator->beamSpot().Y()+BSPosition_.Y())*10., 00134 (theVertexGenerator->Z()-theVertexGenerator->beamSpot().Z()+BSPosition_.Z())*10., 00135 0.); 00136 if ( fabs(theVertexGenerator->Z()) > 1E-10 ) theHepMCProduct->applyVtxGen( &theVertex ); 00137 } 00138 } 00139 00140 CalorimetryManager * calo = famosManager_->calorimetryManager(); 00141 TrajectoryManager * tracker = famosManager_->trackerManager(); 00142 00143 // Save everything in the edm::Event 00144 std::auto_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer); 00145 std::auto_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer); 00146 std::auto_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer); 00147 std::auto_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer); 00148 std::auto_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer); 00149 std::auto_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer); 00150 std::auto_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer); 00151 std::auto_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer); 00152 00153 fevt->load(*p1,*m1); 00154 fevt->load(*p2); 00155 // fevt->print(); 00156 tracker->loadSimHits(*p3); 00157 00158 if ( calo ) { 00159 calo->loadFromEcalBarrel(*p4); 00160 calo->loadFromEcalEndcap(*p5); 00161 calo->loadFromPreshower(*p6); 00162 calo->loadFromHcal(*p7); 00163 } 00164 00165 // Write muon first, to allow tracking particles to work... (pending MixingModule fix) 00166 if ( simulateMuons ) iEvent.put(m1,"MuonSimTracks"); 00167 iEvent.put(p1); 00168 iEvent.put(p2); 00169 iEvent.put(p3,"TrackerHits"); 00170 iEvent.put(p4,"EcalHitsEB"); 00171 iEvent.put(p5,"EcalHitsEE"); 00172 iEvent.put(p6,"EcalHitsES"); 00173 iEvent.put(p7,"HcalHits"); 00174 00175 }
HepMC::GenEvent* FamosProducer::evt_ [private] |
Definition at line 29 of file FamosProducer.h.
FamosManager* FamosProducer::famosManager_ [private] |
Definition at line 28 of file FamosProducer.h.
Referenced by beginRun(), FamosProducer(), produce(), and ~FamosProducer().
bool FamosProducer::simulateMuons [private] |
edm::InputTag FamosProducer::theBeamSpotLabel [private] |
edm::InputTag FamosProducer::theSourceLabel [private] |