CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
FamosProducer Class Reference

#include <FamosProducer.h>

Inheritance diagram for FamosProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &es) override
 
virtual void endJob () override
 
 FamosProducer (edm::ParameterSet const &p)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
virtual ~FamosProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::InputTag beamSpotLabel
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotToken
 
HepMC::GenEvent * evt_
 
FamosManagerfamosManager_
 
edm::InputTag genParticleLabel
 
edm::EDGetTokenT
< reco::GenParticleCollection
genParticleToken
 
edm::EDGetTokenT
< reco::GenParticleCollection
mixGenParticleToken
 
edm::EDGetTokenT
< CrossingFrame
< edm::HepMCProduct > > 
mixSourceToken
 
edm::EDGetTokenT
< edm::HepMCProduct
puToken
 
bool simulateMuons
 
edm::InputTag sourceLabel
 
edm::EDGetTokenT
< edm::HepMCProduct
sourceToken
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file FamosProducer.h.

Constructor & Destructor Documentation

FamosProducer::FamosProducer ( edm::ParameterSet const &  p)
explicit

Definition at line 32 of file FamosProducer.cc.

References beamSpotLabel, beamSpotToken, famosManager_, genParticleLabel, genParticleToken, edm::ParameterSet::getParameter(), mixGenParticleToken, mixSourceToken, puToken, simulateMuons, sourceLabel, and sourceToken.

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  // The generator input label
48  sourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
49  genParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
50  beamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");
51 
52  // consume declarations
53  beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
54  genParticleToken = consumes<reco::GenParticleCollection>(genParticleLabel);
55  // FUTURE OBSOLETE CODE
56  sourceToken = consumes<edm::HepMCProduct>(sourceLabel);
57  edm::InputTag _label = edm::InputTag("famosPileUp","PileUpEvents");
58  puToken = consumes<edm::HepMCProduct>(_label);
59  // OBSOLETE CODE
60  _label = edm::InputTag("mixGenPU","generator");
61  mixSourceToken = consumes<CrossingFrame<edm::HepMCProduct> >(_label);
62  _label = edm::InputTag("genParticlesFromMixingModule");
63  mixGenParticleToken = consumes<reco::GenParticleCollection>(_label);
64 
65  // famos manager
67 }
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: FamosProducer.h:43
edm::InputTag sourceLabel
Definition: FamosProducer.h:38
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken
Definition: FamosProducer.h:44
FamosManager * famosManager_
Definition: FamosProducer.h:33
edm::InputTag genParticleLabel
Definition: FamosProducer.h:39
edm::EDGetTokenT< edm::HepMCProduct > puToken
Definition: FamosProducer.h:47
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: FamosProducer.h:46
edm::EDGetTokenT< reco::GenParticleCollection > mixGenParticleToken
Definition: FamosProducer.h:50
edm::InputTag beamSpotLabel
Definition: FamosProducer.h:40
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixSourceToken
Definition: FamosProducer.h:49
FamosProducer::~FamosProducer ( )
virtual

Definition at line 69 of file FamosProducer.cc.

References famosManager_.

70 { if ( famosManager_ ) delete famosManager_; }
FamosManager * famosManager_
Definition: FamosProducer.h:33

Member Function Documentation

void FamosProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup es 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

73  {
75 }
FamosManager * famosManager_
Definition: FamosProducer.h:33
void setupGeometryAndField(edm::Run const &run, const edm::EventSetup &es)
Get information from the Event Setup.
Definition: FamosManager.cc:90
void FamosProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 77 of file FamosProducer.cc.

78 {
79 }
void FamosProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 81 of file FamosProducer.cc.

References beamSpotToken, FamosManager::calorimetryManager(), gather_cfg::cout, famosManager_, TtGenEvtProducer_cfi::genEvt, genParticleToken, edm::EventSetup::get(), edm::Event::getByToken(), mixGenParticleToken, mixSourceToken, p1, p2, p3, p4, edm::Event::put(), puToken, random, FamosManager::reconstruct(), FamosManager::simEvent(), simulateMuons, source, sourceToken, edm::Event::streamID(), FBaseSimEvent::theTable(), patCandidatesForDimuonsSequences_cff::tracker, and FamosManager::trackerManager().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

82 {
84  using namespace edm;
85 
87 
88  // // The beam spot position
89  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
90  iEvent.getByToken(beamSpotToken,recoBeamSpotHandle);
91  math::XYZPoint BSPosition_ = recoBeamSpotHandle->position();
92 
93  //Retrieve tracker topology from geometry
95  es.get<IdealGeometryRecord>().get(tTopoHand);
96  const TrackerTopology *tTopo=tTopoHand.product();
97 
98 
99  const HepMC::GenEvent* myGenEvent = 0;
100  FSimEvent* fevt = famosManager_->simEvent();
101  // fevt->setBeamSpot(BSPosition_);
102 
103  // Get the generated event(s) from the edm::Event
104  // 1. Check if a HepMCProduct exists
105  // a. Take the VtxSmeared if it exists
106  // b. Take the source otherwise
107  // 2. Otherwise go for the CandidateCollection
108 
109  Handle<HepMCProduct> theHepMCProduct;
110 
111  const reco::GenParticleCollection* myGenParticlesXF = 0; //OBSOLETE
112  const reco::GenParticleCollection* myGenParticles = 0;
113  const HepMC::GenEvent* thePUEvents = 0;
114 
115  // BEGIN OBSOLETE CODE
116  Handle<CrossingFrame<HepMCProduct> > theHepMCProductCrossingFrame;
117  bool isPileUpXF = iEvent.getByToken(mixSourceToken,theHepMCProductCrossingFrame);
118  if (isPileUpXF){// take the GenParticle from crossingframe event collection, if it exists
120  bool genPartXF = iEvent.getByToken(mixGenParticleToken,genEvtXF);
121  if(genPartXF) myGenParticlesXF = &(*genEvtXF);
122  }
123  else{// otherwise, use the old famos PU
124  // END OBSOLETE CODE
125  // Get the generated signal event
126  // BEGIN FUTURE OBSOLETE CODE
127  bool source = iEvent.getByToken(sourceToken,theHepMCProduct);
128  if ( source ) {
129  myGenEvent = theHepMCProduct->GetEvent();
130  }
131 
132  fevt->setBeamSpot(BSPosition_);
133  // GEN LEVEL INFO NOT IN HEPMC FORMAT
134  // In case there is no HepMCProduct, seek a genParticle Candidate Collection
135  bool genPart = false;
136  if ( !myGenEvent ) {
137  //END FUTURE OBSOLETE CODE
138  // Look for the particle CandidateCollection
140  genPart = iEvent.getByToken(genParticleToken,genEvt);
141  if ( genPart ) myGenParticles = &(*genEvt);
142  }
143 
144  if ( !myGenEvent && !genPart )
145  std::cout << "There is no generator input for this event, under "
146  << "any form (HepMCProduct, genParticles)" << std::endl
147  << "Please check SourceLabel or GenParticleLabel" << std::endl;
148 
149  // BEGIN FUTURE OBSOLETE CODE
150  // Get the pile-up events from the pile-up producer
151  // There might be no pile-up events, by the way, in that case, just continue
152  Handle<HepMCProduct> thePileUpEvents;
153  bool isPileUp = iEvent.getByToken(puToken,thePileUpEvents);
154  thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0;
155  // END FUTURE OBSOLETE CODE
156  }//end else
157 
158 
159  // pass the event to the Famos Manager for propagation and simulation
160  if (myGenParticlesXF) {// OBSOLETE OPTION
161  famosManager_->reconstruct(myGenParticlesXF,tTopo, &random);
162  } else {
163  famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents,tTopo, &random); // FUTURE OBSOLETE ARGUMENTS: myGenEvents, thePUEvents
164  }
165 
168 
169  // Save everything in the edm::Event
170  std::auto_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
171  std::auto_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer);
172  std::auto_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
173  std::auto_ptr<FSimVertexTypeCollection> v1(new FSimVertexTypeCollection);
174  std::auto_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer);
175  std::auto_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer);
176  std::auto_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer);
177  std::auto_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer);
178  std::auto_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer);
179 
180  fevt->load(*p1,*m1);
181  fevt->load(*p2);
182  fevt->load(*v1);
183  // fevt->print();
184  tracker->loadSimHits(*p3);
185 
186  // fevt->print();
187 
188  if ( calo ) {
189  calo->loadFromEcalBarrel(*p4);
190  calo->loadFromEcalEndcap(*p5);
191  calo->loadFromPreshower(*p6);
192  calo->loadFromHcal(*p7);
193  // update the muon SimTracks
194  calo->loadMuonSimTracks(*m1);
195  }
196 
197  // Write muon first, to allow tracking particles to work... (pending MixingModule fix)
198  if ( simulateMuons ) iEvent.put(m1,"MuonSimTracks");
199  iEvent.put(p1);
200  iEvent.put(p2);
201  iEvent.put(p3,"TrackerHits");
202  iEvent.put(v1,"VertexTypes");
203  iEvent.put(p4,"EcalHitsEB");
204  iEvent.put(p5,"EcalHitsEE");
205  iEvent.put(p6,"EcalHitsES");
206  iEvent.put(p7,"HcalHits");
207 
208 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: FamosProducer.h:43
std::vector< PCaloHit > PCaloHitContainer
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
Definition: FBaseSimEvent.h:57
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken
Definition: FamosProducer.h:44
TRandom random
Definition: MVATrainer.cc:138
FamosManager * famosManager_
Definition: FamosProducer.h:33
int iEvent
Definition: GenABIO.cc:230
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< FSimVertexType > FSimVertexTypeCollection
collection of FSimVertexType objects
double p2[4]
Definition: TauolaWrapper.h:90
edm::EDGetTokenT< edm::HepMCProduct > puToken
Definition: FamosProducer.h:47
void reconstruct(const HepMC::GenEvent *evt, const reco::GenParticleCollection *particles, const HepMC::GenEvent *pu, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
The real thing is done here.
CalorimetryManager * calorimetryManager() const
The calorimeter.
Definition: FamosManager.h:66
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: FamosProducer.h:46
edm::EDGetTokenT< reco::GenParticleCollection > mixGenParticleToken
Definition: FamosProducer.h:50
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< SimVertex > SimVertexContainer
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixSourceToken
Definition: FamosProducer.h:49
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:121
std::vector< PSimHit > PSimHitContainer
TrajectoryManager * trackerManager() const
The tracker.
Definition: FamosManager.h:63
FSimEvent * simEvent() const
The generated event.
Definition: FamosManager.h:49
std::vector< SimTrack > SimTrackContainer
static std::string const source
Definition: EdmProvDump.cc:43
double p3[4]
Definition: TauolaWrapper.h:91

Member Data Documentation

edm::InputTag FamosProducer::beamSpotLabel
private

Definition at line 40 of file FamosProducer.h.

Referenced by FamosProducer().

edm::EDGetTokenT<reco::BeamSpot> FamosProducer::beamSpotToken
private

Definition at line 43 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

HepMC::GenEvent* FamosProducer::evt_
private

Definition at line 34 of file FamosProducer.h.

FamosManager* FamosProducer::famosManager_
private

Definition at line 33 of file FamosProducer.h.

Referenced by beginRun(), FamosProducer(), produce(), and ~FamosProducer().

edm::InputTag FamosProducer::genParticleLabel
private

Definition at line 39 of file FamosProducer.h.

Referenced by FamosProducer().

edm::EDGetTokenT<reco::GenParticleCollection> FamosProducer::genParticleToken
private

Definition at line 44 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::EDGetTokenT<reco::GenParticleCollection> FamosProducer::mixGenParticleToken
private

Definition at line 50 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > FamosProducer::mixSourceToken
private

Definition at line 49 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::EDGetTokenT<edm::HepMCProduct> FamosProducer::puToken
private

Definition at line 47 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

bool FamosProducer::simulateMuons
private

Definition at line 35 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::sourceLabel
private

Definition at line 38 of file FamosProducer.h.

Referenced by FamosProducer().

edm::EDGetTokenT<edm::HepMCProduct> FamosProducer::sourceToken
private

Definition at line 46 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().