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
40 #include <iostream>
41 #include <memory>
42 #include <vector>
43 
44 using namespace HepMC;
45 
47  : iEvent(0),
48  myCalorimetry(0),
49  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
50  m_Tracking(p.getParameter<bool>("SimulateTracking")),
51  m_Calorimetry(p.getParameter<bool>("SimulateCalorimetry")),
52  m_Alignment(p.getParameter<bool>("ApplyAlignment")),
53  m_pRunNumber(p.getUntrackedParameter<int>("RunNumber",1)),
54  m_pVerbose(p.getUntrackedParameter<int>("Verbosity",1))
55 {
56  // Initialize the FSimEvent
57  mySimEvent =
58  new FSimEvent(p.getParameter<edm::ParameterSet>("ParticleFilter"));
59 
63  p.getParameter<edm::ParameterSet>("MaterialEffects"),
64  p.getParameter<edm::ParameterSet>("TrackerSimHits"),
65  p.getParameter<edm::ParameterSet>("ActivateDecays"));
66 
67  // Initialize Calorimetry Fast Simulation (if requested)
68  if ( m_Calorimetry)
69  myCalorimetry =
71  p.getParameter<edm::ParameterSet>("Calorimetry"),
72  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInECAL"),
73  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInHCAL"),
74  p.getParameter<edm::ParameterSet>("GFlash"));
75 }
76 
78 {
79  if ( mySimEvent ) delete mySimEvent;
81  if ( myCalorimetry) delete myCalorimetry;
82 }
83 
84 void
86 {
87  // Particle data table (from Pythia)
89  es.getData(pdt);
90  mySimEvent->initializePdt(&(*pdt));
91 
92  // Initialize the full (misaligned) tracker geometry
93  // (only if tracking is requested)
94  std::string misAligned = m_Alignment ? "MisAligned" : "";
95  // 1) By default, the aligned geometry is chosen (m_Alignment = false)
96  // 2) By default, the misaligned geometry is aligned
98  es.get<TrackerDigiGeometryRecord>().get(misAligned,tracker);
100 
101  // Initialize the tracker misaligned reco geometry (always needed)
102  // By default, the misaligned geometry is aligned
103  edm::ESHandle<GeometricSearchTracker> theGeomSearchTracker;
104  es.get<TrackerRecoGeometryRecord>().get(misAligned, theGeomSearchTracker );
105 
106  // Initialize the misaligned tracker interaction geometry
107  edm::ESHandle<TrackerInteractionGeometry> theTrackerInteractionGeometry;
108  es.get<TrackerInteractionGeometryRecord>().get(misAligned, theTrackerInteractionGeometry );
109 
110  // Initialize the magnetic field
111  double bField000 = 0.;
112  if (m_pUseMagneticField) {
113  edm::ESHandle<MagneticFieldMap> theMagneticFieldMap;
114  es.get<MagneticFieldMapRecord>().get(misAligned, theMagneticFieldMap);
115  const GlobalPoint g(0.,0.,0.);
116  bField000 = theMagneticFieldMap->inTeslaZ(g);
117  myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker),
118  &(*theTrackerInteractionGeometry),
119  &(*theMagneticFieldMap));
120  } else {
121  myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker),
122  &(*theTrackerInteractionGeometry),
123  0);
124  bField000 = 4.0;
125  }
126  // The following should be on LogInfo
127  //std::cout << "B-field(T) at (0,0,0)(cm): " << bField000 << std::endl;
128 
129  // Initialize the calorimeter geometry
130  if ( myCalorimetry ) {
132  es.get<CaloGeometryRecord>().get(pG);
134 
135  edm::ESHandle<CaloTopology> theCaloTopology;
136  es.get<CaloTopologyRecord>().get(theCaloTopology);
137  myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology);
138  myCalorimetry->getCalorimeter()->initialize(bField000);
139 
141  }
142 
143  m_pRunNumber = run.run();
144 
145 }
146 
147 
148 void
149 FamosManager::reconstruct(const HepMC::GenEvent* evt,
150  const TrackerTopology *tTopo,
152 {
153  // myGenEvent = evt;
154 
155  iEvent++;
157 
158 
159  // Fill the event from the original generated event
160  mySimEvent->fill(*evt,id);
161 
162  // And propagate the particles through the detector
163  myTrajectoryManager->reconstruct(tTopo, random);
164 
165  if ( myCalorimetry ) myCalorimetry->reconstruct(random);
166 
167  edm::LogInfo("FamosManager") << " saved : Event " << iEvent
168  << " of weight " << mySimEvent->weight()
169  << " with " << mySimEvent->nTracks()
170  << " tracks and " << mySimEvent->nVertices()
171  << " vertices, generated by "
172  << mySimEvent->nGenParts() << " particles " << std::endl;
173 }
void reconstruct(const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
Does the real job.
T getParameter(std::string const &) const
bool m_pUseMagneticField
Definition: FamosManager.h:69
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:77
FSimEvent * mySimEvent
Definition: FamosManager.h:63
bool m_Alignment
Definition: FamosManager.h:72
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
CaloGeometryHelper * getCalorimeter() const
TRandom random
Definition: MVATrainer.cc:138
TrajectoryManager * myTrajectoryManager
Definition: FamosManager.h:64
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
void getData(T &iHolder) const
Definition: EventSetup.h:78
int iEvent
Definition: GenABIO.cc:230
void reconstruct(RandomEngineAndDistribution const *)
FastHFShowerLibrary * getHFShowerLibrary() const
CalorimetryManager * myCalorimetry
Definition: FamosManager.h:65
FamosManager(edm::ParameterSet const &p)
Constructor.
Definition: FamosManager.cc:46
bool m_Calorimetry
Definition: FamosManager.h:71
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
const T & get() const
Definition: EventSetup.h:55
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.
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:85
Definition: Run.h:42