CMS 3D CMS Logo

FamosManager.cc
Go to the documentation of this file.
1 // CMSSW Header
10 
12 
14 
15 //#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
16 //#include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
21 
25 //#include "Geometry/CaloTopology/interface/CaloTopology.h"
26 
27 // HepMC headers
28 //#include "HepMC/GenEvent.h"
29 
30 // FAMOS Header
39 #include <iostream>
40 #include <memory>
41 #include <vector>
42 
43 using namespace HepMC;
44 
46  : iEvent(0),
47  myCalorimetry(nullptr),
48  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
49  m_Tracking(p.getParameter<bool>("SimulateTracking")),
50  m_Calorimetry(p.getParameter<bool>("SimulateCalorimetry")),
51  m_Alignment(p.getParameter<bool>("ApplyAlignment")),
52  m_pRunNumber(p.getUntrackedParameter<int>("RunNumber",1)),
53  m_pVerbose(p.getUntrackedParameter<int>("Verbosity",1))
54 {
55  // Initialize the FSimEvent
56  mySimEvent =
57  new FSimEvent(p.getParameter<edm::ParameterSet>("ParticleFilter"));
58 
62  p.getParameter<edm::ParameterSet>("MaterialEffects"),
63  p.getParameter<edm::ParameterSet>("TrackerSimHits"),
64  p.getParameter<edm::ParameterSet>("ActivateDecays"));
65 
66  // Initialize Calorimetry Fast Simulation (if requested)
67  if ( m_Calorimetry)
68  myCalorimetry =
70  p.getParameter<edm::ParameterSet>("Calorimetry"),
71  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInECAL"),
72  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInHCAL"),
73  p.getParameter<edm::ParameterSet>("GFlash"));
74 }
75 
77 {
78  if ( mySimEvent ) delete mySimEvent;
80  if ( myCalorimetry) delete myCalorimetry;
81 }
82 
83 void
85 {
86  // Particle data table (from Pythia)
88  es.getData(pdt);
89  mySimEvent->initializePdt(&(*pdt));
90 
91  // Initialize the full (misaligned) tracker geometry
92  // (only if tracking is requested)
93  std::string misAligned = m_Alignment ? "MisAligned" : "";
94  // 1) By default, the aligned geometry is chosen (m_Alignment = false)
95  // 2) By default, the misaligned geometry is aligned
97  es.get<TrackerDigiGeometryRecord>().get(misAligned,tracker);
99 
100  // Initialize the tracker misaligned reco geometry (always needed)
101  // By default, the misaligned geometry is aligned
102  edm::ESHandle<GeometricSearchTracker> theGeomSearchTracker;
103  es.get<TrackerRecoGeometryRecord>().get(misAligned, theGeomSearchTracker );
104 
105  // Initialize the misaligned tracker interaction geometry
106  edm::ESHandle<TrackerInteractionGeometry> theTrackerInteractionGeometry;
107  es.get<TrackerInteractionGeometryRecord>().get(misAligned, theTrackerInteractionGeometry );
108 
109  // Initialize the magnetic field
110  double bField000 = 0.;
111  if (m_pUseMagneticField) {
112  edm::ESHandle<MagneticFieldMap> theMagneticFieldMap;
113  es.get<MagneticFieldMapRecord>().get(misAligned, theMagneticFieldMap);
114  const GlobalPoint g(0.,0.,0.);
115  bField000 = theMagneticFieldMap->inTeslaZ(g);
116  myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker),
117  &(*theTrackerInteractionGeometry),
118  &(*theMagneticFieldMap));
119  } else {
120  myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker),
121  &(*theTrackerInteractionGeometry),
122  nullptr);
123  bField000 = 4.0;
124  }
125  // The following should be on LogInfo
126  //std::cout << "B-field(T) at (0,0,0)(cm): " << bField000 << std::endl;
127 
128  // Initialize the calorimeter geometry
129  if ( myCalorimetry ) {
131  es.get<CaloGeometryRecord>().get(pG);
133 
134  edm::ESHandle<CaloTopology> theCaloTopology;
135  es.get<CaloTopologyRecord>().get(theCaloTopology);
136  myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology);
137  myCalorimetry->getCalorimeter()->initialize(bField000);
138 
140  }
141 
142  m_pRunNumber = run.run();
143 
144 }
145 
146 
147 void
149  const TrackerTopology *tTopo,
151 {
152  // myGenEvent = evt;
153 
154  iEvent++;
156 
157 
158  // Fill the event from the original generated event
159  mySimEvent->fill(*evt,id);
160 
161  // And propagate the particles through the detector
162  myTrajectoryManager->reconstruct(tTopo, random);
163 
164  if ( myCalorimetry ) myCalorimetry->reconstruct(random);
165 
166  edm::LogInfo("FamosManager") << " saved : Event " << iEvent
167  << " of weight " << mySimEvent->weight()
168  << " with " << mySimEvent->nTracks()
169  << " tracks and " << mySimEvent->nVertices()
170  << " vertices, generated by "
171  << mySimEvent->nGenParts() << " particles " << std::endl;
172 }
void reconstruct(const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
Does the real job.
T getParameter(std::string const &) const
bool m_pUseMagneticField
Definition: FamosManager.h:68
void reconstruct(const HepMC::GenEvent *evt, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
The real thing is done here.
void initializeTrackerGeometry(const TrackerGeometry *geomTracker)
Initialize the full Tracker Geometry.
RunNumber_t run() const
Definition: RunBase.h:40
double inTeslaZ(const GlobalPoint &) const
~FamosManager()
Destructor.
Definition: FamosManager.cc:76
FSimEvent * mySimEvent
Definition: FamosManager.h:62
bool m_Alignment
Definition: FamosManager.h:71
void setupTopology(const CaloTopology &)
Definition: Calorimeter.cc:128
void initializeRecoGeometry(const GeometricSearchTracker *geomSearchTracker, const TrackerInteractionGeometry *interactionGeometry, const MagneticFieldMap *aFieldMap)
Initialize the Reconstruction Geometry.
void fill(const HepMC::GenEvent &hev, edm::EventID &Id)
fill the FBaseSimEvent from the current HepMC::GenEvent
Definition: FSimEvent.cc:14
#define nullptr
CaloGeometryHelper * getCalorimeter() const
TRandom random
Definition: MVATrainer.cc:138
TrajectoryManager * myTrajectoryManager
Definition: FamosManager.h:63
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
bool getData(T &iHolder) const
Definition: EventSetup.h:111
int iEvent
Definition: GenABIO.cc:224
void reconstruct(RandomEngineAndDistribution const *)
FastHFShowerLibrary * getHFShowerLibrary() const
CalorimetryManager * myCalorimetry
Definition: FamosManager.h:64
FamosManager(edm::ParameterSet const &p)
Constructor.
Definition: FamosManager.cc:45
bool m_Calorimetry
Definition: FamosManager.h:70
unsigned int nTracks() const
Number of tracks.
Definition: FSimEvent.cc:36
void setupGeometry(const CaloGeometry &pG)
Definition: Calorimeter.cc:118
unsigned int nGenParts() const
Number of MC particles.
Definition: FSimEvent.cc:46
unsigned int nVertices() const
Number of vertices.
Definition: FSimEvent.cc:41
float weight() const
Method to return the event weight.
Definition: FSimEvent.cc:31
void initializePdt(const HepPDT::ParticleDataTable *aPdt)
Initialize the particle data table.
T get() const
Definition: EventSetup.h:71
void const initHFShowerLibrary(const edm::EventSetup &)
void initialize(double bField)
void setupGeometryAndField(edm::Run const &run, const edm::EventSetup &es)
Get information from the Event Setup.
Definition: FamosManager.cc:84
Definition: Run.h:45