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
 
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_
 
bool simulateMuons
 
edm::InputTag theBeamSpotLabel
 
edm::InputTag theGenParticleLabel
 
edm::InputTag theSourceLabel
 

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

Constructor & Destructor Documentation

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

Definition at line 36 of file FamosProducer.cc.

References famosManager_, edm::ParameterSet::getParameter(), simulateMuons, theBeamSpotLabel, theGenParticleLabel, and theSourceLabel.

37 {
38 
39  produces<edm::SimTrackContainer>();
40  produces<edm::SimVertexContainer>();
41  produces<FSimVertexTypeCollection>("VertexTypes");
42  produces<edm::PSimHitContainer>("TrackerHits");
43  produces<edm::PCaloHitContainer>("EcalHitsEB");
44  produces<edm::PCaloHitContainer>("EcalHitsEE");
45  produces<edm::PCaloHitContainer>("EcalHitsES");
46  produces<edm::PCaloHitContainer>("HcalHits");
47  // Temporary facility to allow for the crossing frame to work...
48  simulateMuons = p.getParameter<bool>("SimulateMuons");
49  if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks");
50 
51  // The generator input label
52  theSourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
53  theGenParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
54  theBeamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");
55 
57 
58 }
edm::InputTag theBeamSpotLabel
Definition: FamosProducer.h:33
FamosManager * famosManager_
Definition: FamosProducer.h:28
edm::InputTag theSourceLabel
Definition: FamosProducer.h:31
edm::InputTag theGenParticleLabel
Definition: FamosProducer.h:32
FamosProducer::~FamosProducer ( )
virtual

Definition at line 60 of file FamosProducer.cc.

References famosManager_.

61 { if ( famosManager_ ) delete famosManager_; }
FamosManager * famosManager_
Definition: FamosProducer.h:28

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 64 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

64  {
66 }
FamosManager * famosManager_
Definition: FamosProducer.h:28
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 68 of file FamosProducer.cc.

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

Implements edm::EDProducer.

Definition at line 72 of file FamosProducer.cc.

References FamosManager::calorimetryManager(), gather_cfg::cout, famosManager_, TtGenEvtProducer_cfi::genEvt, edm::EventSetup::get(), edm::Event::getByLabel(), p1, p2, p3, p4, edm::Event::put(), random, FamosManager::reconstruct(), FamosManager::simEvent(), simulateMuons, source, edm::Event::streamID(), theBeamSpotLabel, theGenParticleLabel, theSourceLabel, patCandidatesForDimuonsSequences_cff::tracker, and FamosManager::trackerManager().

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

73 {
74  using namespace edm;
75 
77 
78  // // The beam spot position
79  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
80  iEvent.getByLabel(theBeamSpotLabel,recoBeamSpotHandle);
81  math::XYZPoint BSPosition_ = recoBeamSpotHandle->position();
82 
83  //Retrieve tracker topology from geometry
85  es.get<IdealGeometryRecord>().get(tTopoHand);
86  const TrackerTopology *tTopo=tTopoHand.product();
87 
88 
89  const HepMC::GenEvent* myGenEvent = 0;
90  FSimEvent* fevt = famosManager_->simEvent();
91  // fevt->setBeamSpot(BSPosition_);
92 
93  // Get the generated event(s) from the edm::Event
94  // 1. Check if a HepMCProduct exists
95  // a. Take the VtxSmeared if it exists
96  // b. Take the source otherwise
97  // 2. Otherwise go for the CandidateCollection
98 
99  Handle<HepMCProduct> theHepMCProduct;
100 
101  PrimaryVertexGenerator* theVertexGenerator = fevt->thePrimaryVertexGenerator();
102 
103 
104  const reco::GenParticleCollection* myGenParticlesXF = 0;
105  const reco::GenParticleCollection* myGenParticles = 0;
106  const HepMC::GenEvent* thePUEvents = 0;
107 
108  Handle<CrossingFrame<HepMCProduct> > theHepMCProductCrossingFrame;
109  bool isPileUpXF = iEvent.getByLabel("mixGenPU","generator",theHepMCProductCrossingFrame);
110 
111  if (isPileUpXF){// take the GenParticle from crossingframe event collection, if it exists
113  bool genPartXF = iEvent.getByLabel("genParticlesFromMixingModule",genEvtXF);
114  if(genPartXF) myGenParticlesXF = &(*genEvtXF);
115  }
116  else{// otherwise, use the old famos PU
117  // Get the generated signal event
118  bool source = iEvent.getByLabel(theSourceLabel,theHepMCProduct);
119  if ( source ) {
120  myGenEvent = theHepMCProduct->GetEvent();
121  // First rotate in case of beam crossing angle (except if done already)
122  if ( theVertexGenerator ) {
123  TMatrixD* boost = theVertexGenerator->boost();
124  if ( boost ) theHepMCProduct->boostToLab(boost,"momentum");
125  }
126  myGenEvent = theHepMCProduct->GetEvent();
127  }
128 
129  fevt->setBeamSpot(BSPosition_);
130 
131  // In case there is no HepMCProduct, seek a genParticle Candidate Collection
132  bool genPart = false;
133  if ( !myGenEvent ) {
134  // Look for the particle CandidateCollection
136  genPart = iEvent.getByLabel(theGenParticleLabel,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  // Get the pile-up events from the pile-up producer
146  // There might be no pile-up events, by the way, in that case, just continue
147  Handle<HepMCProduct> thePileUpEvents;
148  bool isPileUp = iEvent.getByLabel("famosPileUp","PileUpEvents",thePileUpEvents);
149  thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0;
150 
151  }//end else
152 
153  // pass the event to the Famos Manager for propagation and simulation
154  if (myGenParticlesXF) {
155  famosManager_->reconstruct(myGenParticlesXF,tTopo, &random);
156  } else {
157  famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents,tTopo, &random);
158  }
159 
160  // Set the vertex back to the HepMCProduct (except if it was smeared already)
161  if ( myGenEvent ) {
162  if ( theVertexGenerator ) {
163  HepMC::FourVector theVertex(
164  (theVertexGenerator->X()-theVertexGenerator->beamSpot().X()+BSPosition_.X())*10.,
165  (theVertexGenerator->Y()-theVertexGenerator->beamSpot().Y()+BSPosition_.Y())*10.,
166  (theVertexGenerator->Z()-theVertexGenerator->beamSpot().Z()+BSPosition_.Z())*10.,
167  0.);
168  if ( fabs(theVertexGenerator->Z()) > 1E-10 ) theHepMCProduct->applyVtxGen( &theVertex );
169  }
170  }
171 
174 
175  // Save everything in the edm::Event
176  std::auto_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
177  std::auto_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer);
178  std::auto_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
179  std::auto_ptr<FSimVertexTypeCollection> v1(new FSimVertexTypeCollection);
180  std::auto_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer);
181  std::auto_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer);
182  std::auto_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer);
183  std::auto_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer);
184  std::auto_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer);
185 
186  fevt->load(*p1,*m1);
187  fevt->load(*p2);
188  fevt->load(*v1);
189  // fevt->print();
190  tracker->loadSimHits(*p3);
191 
192  // fevt->print();
193 
194  if ( calo ) {
195  calo->loadFromEcalBarrel(*p4);
196  calo->loadFromEcalEndcap(*p5);
197  calo->loadFromPreshower(*p6);
198  calo->loadFromHcal(*p7);
199  // update the muon SimTracks
200  calo->loadMuonSimTracks(*m1);
201  }
202 
203  // Write muon first, to allow tracking particles to work... (pending MixingModule fix)
204  if ( simulateMuons ) iEvent.put(m1,"MuonSimTracks");
205  iEvent.put(p1);
206  iEvent.put(p2);
207  iEvent.put(p3,"TrackerHits");
208  iEvent.put(v1,"VertexTypes");
209  iEvent.put(p4,"EcalHitsEB");
210  iEvent.put(p5,"EcalHitsEE");
211  iEvent.put(p6,"EcalHitsES");
212  iEvent.put(p7,"HcalHits");
213 
214 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::vector< PCaloHit > PCaloHitContainer
edm::InputTag theBeamSpotLabel
Definition: FamosProducer.h:33
TRandom random
Definition: MVATrainer.cc:138
FamosManager * famosManager_
Definition: FamosProducer.h:28
int iEvent
Definition: GenABIO.cc:243
double p4[4]
Definition: TauolaWrapper.h:92
edm::InputTag theSourceLabel
Definition: FamosProducer.h:31
std::vector< FSimVertexType > FSimVertexTypeCollection
collection of FSimVertexType objects
double p2[4]
Definition: TauolaWrapper.h:90
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.
edm::InputTag theGenParticleLabel
Definition: FamosProducer.h:32
CalorimetryManager * calorimetryManager() const
The calorimeter.
Definition: FamosManager.h:65
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< SimVertex > SimVertexContainer
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:62
FSimEvent * simEvent() const
The generated event.
Definition: FamosManager.h:48
std::vector< SimTrack > SimTrackContainer
static std::string const source
Definition: EdmProvDump.cc:43
double p3[4]
Definition: TauolaWrapper.h:91

Member Data Documentation

HepMC::GenEvent* FamosProducer::evt_
private

Definition at line 29 of file FamosProducer.h.

FamosManager* FamosProducer::famosManager_
private

Definition at line 28 of file FamosProducer.h.

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

bool FamosProducer::simulateMuons
private

Definition at line 30 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::theBeamSpotLabel
private

Definition at line 33 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::theGenParticleLabel
private

Definition at line 32 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().

edm::InputTag FamosProducer::theSourceLabel
private

Definition at line 31 of file FamosProducer.h.

Referenced by FamosProducer(), and produce().