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

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 19 of file FamosProducer.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file FamosProducer.cc.

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

32 {
33 
34  produces<edm::SimTrackContainer>();
35  produces<edm::SimVertexContainer>();
36  produces<FSimVertexTypeCollection>("VertexTypes");
37  produces<edm::PSimHitContainer>("TrackerHits");
38  produces<edm::PCaloHitContainer>("EcalHitsEB");
39  produces<edm::PCaloHitContainer>("EcalHitsEE");
40  produces<edm::PCaloHitContainer>("EcalHitsES");
41  produces<edm::PCaloHitContainer>("HcalHits");
42  // Temporary facility to allow for the crossing frame to work...
43  simulateMuons = p.getParameter<bool>("SimulateMuons");
44  if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks");
45 
46  // The generator input label
47  sourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
48  genParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
49 
50  // consume declarations
51  genParticleToken = consumes<reco::GenParticleCollection>(genParticleLabel);
52  // FUTURE OBSOLETE CODE
53  sourceToken = consumes<edm::HepMCProduct>(sourceLabel);
54  edm::InputTag _label = edm::InputTag("famosPileUp","PileUpEvents");
55  puToken = consumes<edm::HepMCProduct>(_label);
56  // OBSOLETE CODE
57  _label = edm::InputTag("mixGenPU","generator");
58  mixSourceToken = consumes<CrossingFrame<edm::HepMCProduct> >(_label);
59  _label = edm::InputTag("genParticlesFromMixingModule");
60  mixGenParticleToken = consumes<reco::GenParticleCollection>(_label);
61 
62  // famos manager
64 }
edm::InputTag sourceLabel
Definition: FamosProducer.h:36
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken
Definition: FamosProducer.h:40
FamosManager * famosManager_
Definition: FamosProducer.h:31
edm::InputTag genParticleLabel
Definition: FamosProducer.h:37
edm::EDGetTokenT< edm::HepMCProduct > puToken
Definition: FamosProducer.h:43
edm::EDGetTokenT< edm::HepMCProduct > sourceToken
Definition: FamosProducer.h:42
edm::EDGetTokenT< reco::GenParticleCollection > mixGenParticleToken
Definition: FamosProducer.h:46
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixSourceToken
Definition: FamosProducer.h:45
FamosProducer::~FamosProducer ( )
virtual

Definition at line 66 of file FamosProducer.cc.

References famosManager_.

67 { if ( famosManager_ ) delete famosManager_; }
FamosManager * famosManager_
Definition: FamosProducer.h:31

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 70 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

70  {
72 }
FamosManager * famosManager_
Definition: FamosProducer.h:31
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 74 of file FamosProducer.cc.

References 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().

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

HepMC::GenEvent* FamosProducer::evt_
private

Definition at line 32 of file FamosProducer.h.

FamosManager* FamosProducer::famosManager_
private

Definition at line 31 of file FamosProducer.h.

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

edm::InputTag FamosProducer::genParticleLabel
private

Definition at line 37 of file FamosProducer.h.

Referenced by FamosProducer().

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

Definition at line 40 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 46 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 45 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

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

Definition at line 43 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

bool FamosProducer::simulateMuons
private

Definition at line 33 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::sourceLabel
private

Definition at line 36 of file FamosProducer.h.

Referenced by FamosProducer().

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

Definition at line 42 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().