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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &es) 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
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(), HLT_25ns14e33_v1_cff::InputTag, 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:42
edm::InputTag sourceLabel
Definition: FamosProducer.h:37
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken
Definition: FamosProducer.h:43
FamosManager * famosManager_
Definition: FamosProducer.h:32
edm::InputTag genParticleLabel
Definition: FamosProducer.h:38
edm::EDGetTokenT< edm::HepMCProduct > puToken
Definition: FamosProducer.h:46
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: FamosProducer.h:45
edm::EDGetTokenT< reco::GenParticleCollection > mixGenParticleToken
Definition: FamosProducer.h:49
edm::InputTag beamSpotLabel
Definition: FamosProducer.h:39
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixSourceToken
Definition: FamosProducer.h:48
FamosProducer::~FamosProducer ( )
virtual

Definition at line 69 of file FamosProducer.cc.

References famosManager_.

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

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 73 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

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

Implements edm::stream::EDProducerBase.

Definition at line 77 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().

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

Member Data Documentation

edm::InputTag FamosProducer::beamSpotLabel
private

Definition at line 39 of file FamosProducer.h.

Referenced by FamosProducer().

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

Definition at line 42 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

HepMC::GenEvent* FamosProducer::evt_
private

Definition at line 33 of file FamosProducer.h.

FamosManager* FamosProducer::famosManager_
private

Definition at line 32 of file FamosProducer.h.

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

edm::InputTag FamosProducer::genParticleLabel
private

Definition at line 38 of file FamosProducer.h.

Referenced by FamosProducer().

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

Definition at line 43 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 49 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 48 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 46 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

bool FamosProducer::simulateMuons
private

Definition at line 34 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::sourceLabel
private

Definition at line 37 of file FamosProducer.h.

Referenced by FamosProducer().

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

Definition at line 45 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().