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 33 of file FamosProducer.cc.

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

34 {
35 
36  produces<edm::SimTrackContainer>();
37  produces<edm::SimVertexContainer>();
38  produces<FSimVertexTypeCollection>("VertexTypes");
39  produces<edm::PSimHitContainer>("TrackerHits");
40  produces<edm::PCaloHitContainer>("EcalHitsEB");
41  produces<edm::PCaloHitContainer>("EcalHitsEE");
42  produces<edm::PCaloHitContainer>("EcalHitsES");
43  produces<edm::PCaloHitContainer>("HcalHits");
44  // Temporary facility to allow for the crossing frame to work...
45  simulateMuons = p.getParameter<bool>("SimulateMuons");
46  if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks");
47 
48  // The generator input label
49  sourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
50  genParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
51  beamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");
52 
53  // consume declarations
54  beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
55  genParticleToken = consumes<reco::GenParticleCollection>(genParticleLabel);
56  // FUTURE OBSOLETE CODE
57  sourceToken = consumes<edm::HepMCProduct>(sourceLabel);
58  edm::InputTag _label = edm::InputTag("famosPileUp","PileUpEvents");
59  puToken = consumes<edm::HepMCProduct>(_label);
60  // OBSOLETE CODE
61  _label = edm::InputTag("mixGenPU","generator");
62  mixSourceToken = consumes<CrossingFrame<edm::HepMCProduct> >(_label);
63  _label = edm::InputTag("genParticlesFromMixingModule");
64  mixGenParticleToken = consumes<reco::GenParticleCollection>(_label);
65 
66  // famos manager
68 }
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 70 of file FamosProducer.cc.

References famosManager_.

71 { 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 74 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

74  {
76 }
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:91
void FamosProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 78 of file FamosProducer.cc.

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

Implements edm::EDProducer.

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

83 {
85  using namespace edm;
86 
88 
89  // // The beam spot position
90  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
91  iEvent.getByToken(beamSpotToken,recoBeamSpotHandle);
92  math::XYZPoint BSPosition_ = recoBeamSpotHandle->position();
93 
94  //Retrieve tracker topology from geometry
96  es.get<IdealGeometryRecord>().get(tTopoHand);
97  const TrackerTopology *tTopo=tTopoHand.product();
98 
99 
100  const HepMC::GenEvent* myGenEvent = 0;
101  FSimEvent* fevt = famosManager_->simEvent();
102  // fevt->setBeamSpot(BSPosition_);
103 
104  // Get the generated event(s) from the edm::Event
105  // 1. Check if a HepMCProduct exists
106  // a. Take the VtxSmeared if it exists
107  // b. Take the source otherwise
108  // 2. Otherwise go for the CandidateCollection
109 
110  Handle<HepMCProduct> theHepMCProduct;
111 
112  PrimaryVertexGenerator* theVertexGenerator = fevt->thePrimaryVertexGenerator();
113 
114 
115  const reco::GenParticleCollection* myGenParticlesXF = 0; //OBSOLETE
116  const reco::GenParticleCollection* myGenParticles = 0;
117  const HepMC::GenEvent* thePUEvents = 0;
118 
119  // BEGIN OBSOLETE CODE
120  Handle<CrossingFrame<HepMCProduct> > theHepMCProductCrossingFrame;
121  bool isPileUpXF = iEvent.getByToken(mixSourceToken,theHepMCProductCrossingFrame);
122  if (isPileUpXF){// take the GenParticle from crossingframe event collection, if it exists
124  bool genPartXF = iEvent.getByToken(mixGenParticleToken,genEvtXF);
125  if(genPartXF) myGenParticlesXF = &(*genEvtXF);
126  }
127  else{// otherwise, use the old famos PU
128  // END OBSOLETE CODE
129  // Get the generated signal event
130  // BEGIN FUTURE OBSOLETE CODE
131  bool source = iEvent.getByToken(sourceToken,theHepMCProduct);
132  if ( source ) {
133  myGenEvent = theHepMCProduct->GetEvent();
134  // First rotate in case of beam crossing angle (except if done already)
135  if ( theVertexGenerator ) {
136  TMatrixD* boost = theVertexGenerator->boost();
137  if ( boost ) theHepMCProduct->boostToLab(boost,"momentum");
138  }
139  myGenEvent = theHepMCProduct->GetEvent();
140  }
141 
142  fevt->setBeamSpot(BSPosition_);
143  // GEN LEVEL INFO NOT IN HEPMC FORMAT
144  // In case there is no HepMCProduct, seek a genParticle Candidate Collection
145  bool genPart = false;
146  if ( !myGenEvent ) {
147  //END FUTURE OBSOLETE CODE
148  // Look for the particle CandidateCollection
150  genPart = iEvent.getByToken(genParticleToken,genEvt);
151  if ( genPart ) myGenParticles = &(*genEvt);
152  }
153 
154  if ( !myGenEvent && !genPart )
155  std::cout << "There is no generator input for this event, under "
156  << "any form (HepMCProduct, genParticles)" << std::endl
157  << "Please check SourceLabel or GenParticleLabel" << std::endl;
158 
159  // BEGIN FUTURE OBSOLETE CODE
160  // Get the pile-up events from the pile-up producer
161  // There might be no pile-up events, by the way, in that case, just continue
162  Handle<HepMCProduct> thePileUpEvents;
163  bool isPileUp = iEvent.getByToken(puToken,thePileUpEvents);
164  thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0;
165  // END FUTURE OBSOLETE CODE
166  }//end else
167 
168 
169  // pass the event to the Famos Manager for propagation and simulation
170  if (myGenParticlesXF) {// OBSOLETE OPTION
171  famosManager_->reconstruct(myGenParticlesXF,tTopo, &random);
172  } else {
173  famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents,tTopo, &random); // FUTURE OBSOLETE ARGUMENTS: myGenEvents, thePUEvents
174  }
175 
176  // BEGIN FUTURE OBSOLETE CODE
177  // Set the vertex back to the HepMCProduct (except if it was smeared already)
178  if ( myGenEvent ) {
179  if ( theVertexGenerator ) {
180  HepMC::FourVector theVertex(
181  (theVertexGenerator->X()-theVertexGenerator->beamSpot().X()+BSPosition_.X())*10.,
182  (theVertexGenerator->Y()-theVertexGenerator->beamSpot().Y()+BSPosition_.Y())*10.,
183  (theVertexGenerator->Z()-theVertexGenerator->beamSpot().Z()+BSPosition_.Z())*10.,
184  0.);
185  if ( fabs(theVertexGenerator->Z()) > 1E-10 ) theHepMCProduct->applyVtxGen( &theVertex );
186  }
187  }
188  // END FUTURE OBSOLETE CODE
189 
192 
193  // Save everything in the edm::Event
194  std::auto_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
195  std::auto_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer);
196  std::auto_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
197  std::auto_ptr<FSimVertexTypeCollection> v1(new FSimVertexTypeCollection);
198  std::auto_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer);
199  std::auto_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer);
200  std::auto_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer);
201  std::auto_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer);
202  std::auto_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer);
203 
204  fevt->load(*p1,*m1);
205  fevt->load(*p2);
206  fevt->load(*v1);
207  // fevt->print();
208  tracker->loadSimHits(*p3);
209 
210  // fevt->print();
211 
212  if ( calo ) {
213  calo->loadFromEcalBarrel(*p4);
214  calo->loadFromEcalEndcap(*p5);
215  calo->loadFromPreshower(*p6);
216  calo->loadFromHcal(*p7);
217  // update the muon SimTracks
218  calo->loadMuonSimTracks(*m1);
219  }
220 
221  // Write muon first, to allow tracking particles to work... (pending MixingModule fix)
222  if ( simulateMuons ) iEvent.put(m1,"MuonSimTracks");
223  iEvent.put(p1);
224  iEvent.put(p2);
225  iEvent.put(p3,"TrackerHits");
226  iEvent.put(v1,"VertexTypes");
227  iEvent.put(p4,"EcalHitsEB");
228  iEvent.put(p5,"EcalHitsEE");
229  iEvent.put(p6,"EcalHitsES");
230  iEvent.put(p7,"HcalHits");
231 
232 }
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:63
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().