CMS 3D CMS Logo

FamosProducer.cc
Go to the documentation of this file.
6 
9 
11 
15 
24 
25 #include "HepMC/GenVertex.h"
26 #include "HepMC/GenEvent.h"
27 
28 #include <iostream>
29 #include <memory>
30 #include <vector>
31 
33 {
34 
35  produces<edm::SimTrackContainer>();
36  produces<edm::SimVertexContainer>();
37  produces<FSimVertexTypeCollection>("VertexTypes");
38  produces<edm::PSimHitContainer>("TrackerHits");
39  produces<edm::PCaloHitContainer>("EcalHitsEB");
40  produces<edm::PCaloHitContainer>("EcalHitsEE");
41  produces<edm::PCaloHitContainer>("EcalHitsES");
42  produces<edm::PCaloHitContainer>("HcalHits");
43  // Temporary facility to allow for the crossing frame to work...
44  simulateMuons = p.getParameter<bool>("SimulateMuons");
45  if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks");
46 
47  // hepmc event from signal event
48  edm::InputTag sourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
49  sourceToken = consumes<edm::HepMCProduct>(sourceLabel);
50 
51  // famos manager
52  famosManager_ = new FamosManager(p);
53 }
54 
56 { delete famosManager_; }
57 
58 void
61 }
62 
64 {
65  using namespace edm;
66 
68 
69  //Retrieve tracker topology from geometry
71  es.get<TrackerTopologyRcd>().get(tTopoHand);
72  const TrackerTopology *tTopo=tTopoHand.product();
73 
74  // get the signal event
75  Handle<HepMCProduct> theHepMCProduct;
76  iEvent.getByToken(sourceToken,theHepMCProduct);
77  const HepMC::GenEvent * myGenEvent = theHepMCProduct->GetEvent();
78 
79  // do the simulation
80  famosManager_->reconstruct(myGenEvent,tTopo, &random);
81 
82  // get the hits, simtracks and simvertices and put in the event
85 
86  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
87  std::unique_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer);
88  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
89  std::unique_ptr<FSimVertexTypeCollection> v1(new FSimVertexTypeCollection);
90  std::unique_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer);
91  std::unique_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer);
92  std::unique_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer);
93  std::unique_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer);
94  std::unique_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer);
95 
96  FSimEvent* fevt = famosManager_->simEvent();
97  fevt->load(*p1,*m1);
98  fevt->load(*p2);
99  fevt->load(*v1);
100  tracker->loadSimHits(*p3);
101 
102 
103  if ( calo ) {
104  calo->loadFromEcalBarrel(*p4);
105  calo->loadFromEcalEndcap(*p5);
106  calo->loadFromPreshower(*p6);
107  calo->loadFromHcal(*p7);
108  calo->loadMuonSimTracks(*m1);
109  }
110 
111  if ( simulateMuons ) iEvent.put(std::move(m1),"MuonSimTracks");
112  iEvent.put(std::move(p1));
113  iEvent.put(std::move(p2));
114  iEvent.put(std::move(p3),"TrackerHits");
115  iEvent.put(std::move(v1),"VertexTypes");
116  iEvent.put(std::move(p4),"EcalHitsEB");
117  iEvent.put(std::move(p5),"EcalHitsEE");
118  iEvent.put(std::move(p6),"EcalHitsES");
119  iEvent.put(std::move(p7),"HcalHits");
120 }
121 
T getParameter(std::string const &) const
void reconstruct(const HepMC::GenEvent *evt, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
The real thing is done here.
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
~FamosProducer() override
void load(edm::SimTrackContainer &c, edm::SimTrackContainer &m) const
Load containers of tracks (and muons) and vertices for the edm::Event.
Definition: FSimEvent.cc:51
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void loadFromPreshower(edm::PCaloHitContainer &c) const
TRandom random
Definition: MVATrainer.cc:138
FamosManager * famosManager_
Definition: FamosProducer.h:29
void beginRun(edm::Run const &run, const edm::EventSetup &es) override
FamosProducer(edm::ParameterSet const &p)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double p4[4]
Definition: TauolaWrapper.h:92
void loadFromEcalEndcap(edm::PCaloHitContainer &c) const
std::vector< FSimVertexType > FSimVertexTypeCollection
collection of FSimVertexType objects
void loadMuonSimTracks(edm::SimTrackContainer &m) const
double p2[4]
Definition: TauolaWrapper.h:90
void loadFromHcal(edm::PCaloHitContainer &c) const
CalorimetryManager * calorimetryManager() const
The calorimeter.
Definition: FamosManager.h:55
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: FamosProducer.h:35
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
void loadSimHits(edm::PSimHitContainer &c) const
std::vector< SimVertex > SimVertexContainer
void produce(edm::Event &e, const edm::EventSetup &c) override
HLT enums.
double p1[4]
Definition: TauolaWrapper.h:89
T get() const
Definition: EventSetup.h:71
StreamID streamID() const
Definition: Event.h:95
std::vector< PSimHit > PSimHitContainer
TrajectoryManager * trackerManager() const
The tracker.
Definition: FamosManager.h:52
FSimEvent * simEvent() const
The simulated event.
Definition: FamosManager.h:44
std::vector< SimTrack > SimTrackContainer
void setupGeometryAndField(edm::Run const &run, const edm::EventSetup &es)
Get information from the Event Setup.
Definition: FamosManager.cc:84
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
double p3[4]
Definition: TauolaWrapper.h:91
void loadFromEcalBarrel(edm::PCaloHitContainer &c) const