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::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run &run, const edm::EventSetup &es)
 
virtual void endJob ()
 
 FamosProducer (edm::ParameterSet const &p)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~FamosProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 15 of file FamosProducer.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file FamosProducer.cc.

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

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  theSourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
50  theGenParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
51  theBeamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");
52 
54 
55 }
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 57 of file FamosProducer.cc.

References famosManager_.

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

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 61 of file FamosProducer.cc.

References famosManager_, and FamosManager::setupGeometryAndField().

61  {
63 }
void setupGeometryAndField(edm::Run &run, const edm::EventSetup &es)
Get information from the Event Setup.
FamosManager * famosManager_
Definition: FamosProducer.h:28
void FamosProducer::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 65 of file FamosProducer.cc.

66 {
67 }
void FamosProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 69 of file FamosProducer.cc.

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

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

70 {
71  using namespace edm;
72 
73  // The beam spot position
74  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
75  iEvent.getByLabel(theBeamSpotLabel,recoBeamSpotHandle);
76  math::XYZPoint BSPosition_ = recoBeamSpotHandle->position();
77 
78  // Get the generated event(s) from the edm::Event
79  // 1. Check if a HepMCProduct exists
80  // a. Take the VtxSmeared if it exists
81  // b. Take the source otherwise
82  // 2. Otherwise go for the CandidateCollection
83  Handle<HepMCProduct> theHepMCProduct;
84 
85  const HepMC::GenEvent* myGenEvent = 0;
86  FSimEvent* fevt = famosManager_->simEvent();
87  fevt->setBeamSpot(BSPosition_);
88  PrimaryVertexGenerator* theVertexGenerator = fevt->thePrimaryVertexGenerator();
89 
90  // Get the generated signal event
91  bool source = iEvent.getByLabel(theSourceLabel,theHepMCProduct);
92  if ( source ) {
93  myGenEvent = theHepMCProduct->GetEvent();
94  // First rotate in case of beam crossing angle (except if done already)
95  if ( theVertexGenerator ) {
96  TMatrixD* boost = theVertexGenerator->boost();
97  if ( boost ) theHepMCProduct->boostToLab(boost,"momentum");
98  }
99  myGenEvent = theHepMCProduct->GetEvent();
100  }
101 
102  // In case there is no HepMCProduct, seek a genParticle Candidate Collection
103  bool genPart = false;
104  const reco::GenParticleCollection* myGenParticles = 0;
105  if ( !myGenEvent ) {
106  // Look for the particle CandidateCollection
108  genPart = iEvent.getByLabel(theGenParticleLabel,genEvt);
109  if ( genPart ) myGenParticles = &(*genEvt);
110  }
111 
112  if ( !myGenEvent && !genPart )
113  std::cout << "There is no generator input for this event, under "
114  << "any form (HepMCProduct, genParticles)" << std::endl
115  << "Please check SourceLabel or GenParticleLabel" << std::endl;
116 
117  // Get the pile-up events from the pile-up producer
118  // There might be no pile-up events, by the way, in that case, just continue
119 
120  Handle<HepMCProduct> thePileUpEvents;
121  bool isPileUp = iEvent.getByLabel("famosPileUp","PileUpEvents",thePileUpEvents);
122  const HepMC::GenEvent* thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0;
123 
124  // .and pass the event to the Famos Manager for propagation and simulation
125  if ( myGenEvent || myGenParticles )
126  famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents);
127 
128  // Set the vertex back to the HepMCProduct (except if it was smeared already)
129  if ( myGenEvent ) {
130  if ( theVertexGenerator ) {
131  HepMC::FourVector theVertex(
132  (theVertexGenerator->X()-theVertexGenerator->beamSpot().X()+BSPosition_.X())*10.,
133  (theVertexGenerator->Y()-theVertexGenerator->beamSpot().Y()+BSPosition_.Y())*10.,
134  (theVertexGenerator->Z()-theVertexGenerator->beamSpot().Z()+BSPosition_.Z())*10.,
135  0.);
136  if ( fabs(theVertexGenerator->Z()) > 1E-10 ) theHepMCProduct->applyVtxGen( &theVertex );
137  }
138  }
139 
142 
143  // Save everything in the edm::Event
144  std::auto_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
145  std::auto_ptr<edm::SimTrackContainer> m1(new edm::SimTrackContainer);
146  std::auto_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
147  std::auto_ptr<FSimVertexTypeCollection> v1(new FSimVertexTypeCollection);
148  std::auto_ptr<edm::PSimHitContainer> p3(new edm::PSimHitContainer);
149  std::auto_ptr<edm::PCaloHitContainer> p4(new edm::PCaloHitContainer);
150  std::auto_ptr<edm::PCaloHitContainer> p5(new edm::PCaloHitContainer);
151  std::auto_ptr<edm::PCaloHitContainer> p6(new edm::PCaloHitContainer);
152  std::auto_ptr<edm::PCaloHitContainer> p7(new edm::PCaloHitContainer);
153 
154  fevt->load(*p1,*m1);
155  fevt->load(*p2);
156  fevt->load(*v1);
157  // fevt->print();
158  tracker->loadSimHits(*p3);
159 
160  // fevt->print();
161 
162  if ( calo ) {
163  calo->loadFromEcalBarrel(*p4);
164  calo->loadFromEcalEndcap(*p5);
165  calo->loadFromPreshower(*p6);
166  calo->loadFromHcal(*p7);
167  // update the muon SimTracks
168  calo->loadMuonSimTracks(*m1);
169  }
170 
171  // Write muon first, to allow tracking particles to work... (pending MixingModule fix)
172  if ( simulateMuons ) iEvent.put(m1,"MuonSimTracks");
173  iEvent.put(p1);
174  iEvent.put(p2);
175  iEvent.put(p3,"TrackerHits");
176  iEvent.put(v1,"VertexTypes");
177  iEvent.put(p4,"EcalHitsEB");
178  iEvent.put(p5,"EcalHitsEE");
179  iEvent.put(p6,"EcalHitsES");
180  iEvent.put(p7,"HcalHits");
181 
182 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::vector< PCaloHit > PCaloHitContainer
void reconstruct(const HepMC::GenEvent *evt, const reco::GenParticleCollection *particles, const HepMC::GenEvent *pu)
The real thing is done here.
edm::InputTag theBeamSpotLabel
Definition: FamosProducer.h:33
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 setBeamSpot(const math::XYZPoint &aBeamSpot)
Set the beam spot position.
edm::InputTag theGenParticleLabel
Definition: FamosProducer.h:32
CalorimetryManager * calorimetryManager() const
The calorimeter.
Definition: FamosManager.h:57
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
std::vector< SimVertex > SimVertexContainer
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:41
std::vector< PSimHit > PSimHitContainer
TrajectoryManager * trackerManager() const
The tracker.
Definition: FamosManager.h:54
FSimEvent * simEvent() const
The generated event.
Definition: FamosManager.h:46
std::vector< SimTrack > SimTrackContainer
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().