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  // Initialize the FSimEvent
55  mySimEvent = new FSimEvent(p.getParameter<edm::ParameterSet>("ParticleFilter"));
56 
59  p.getParameter<edm::ParameterSet>("MaterialEffects"),
60  p.getParameter<edm::ParameterSet>("TrackerSimHits"),
61  p.getParameter<edm::ParameterSet>("ActivateDecays"));
62 
63  // Initialize Calorimetry Fast Simulation (if requested)
64  if (m_Calorimetry)
66  p.getParameter<edm::ParameterSet>("Calorimetry"),
67  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInECAL"),
68  p.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInHCAL"),
69  p.getParameter<edm::ParameterSet>("GFlash"));
70 }
71 
73  if (mySimEvent)
74  delete mySimEvent;
76  delete myTrajectoryManager;
77  if (myCalorimetry)
78  delete myCalorimetry;
79 }
80 
82  // Particle data table (from Pythia)
84  es.getData(pdt);
85  mySimEvent->initializePdt(&(*pdt));
86 
87  // Initialize the full (misaligned) tracker geometry
88  // (only if tracking is requested)
89  std::string misAligned = m_Alignment ? "MisAligned" : "";
90  // 1) By default, the aligned geometry is chosen (m_Alignment = false)
91  // 2) By default, the misaligned geometry is aligned
93  es.get<TrackerDigiGeometryRecord>().get(misAligned, tracker);
94  if (m_Tracking)
96 
97  // Initialize the tracker misaligned reco geometry (always needed)
98  // By default, the misaligned geometry is aligned
99  edm::ESHandle<GeometricSearchTracker> theGeomSearchTracker;
100  es.get<TrackerRecoGeometryRecord>().get(misAligned, theGeomSearchTracker);
101 
102  // Initialize the misaligned tracker interaction geometry
103  edm::ESHandle<TrackerInteractionGeometry> theTrackerInteractionGeometry;
104  es.get<TrackerInteractionGeometryRecord>().get(misAligned, theTrackerInteractionGeometry);
105 
106  // Initialize the magnetic field
107  double bField000 = 0.;
108  if (m_pUseMagneticField) {
109  edm::ESHandle<MagneticFieldMap> theMagneticFieldMap;
110  es.get<MagneticFieldMapRecord>().get(misAligned, theMagneticFieldMap);
111  const GlobalPoint g(0., 0., 0.);
112  bField000 = theMagneticFieldMap->inTeslaZ(g);
114  &(*theGeomSearchTracker), &(*theTrackerInteractionGeometry), &(*theMagneticFieldMap));
115  } else {
116  myTrajectoryManager->initializeRecoGeometry(&(*theGeomSearchTracker), &(*theTrackerInteractionGeometry), nullptr);
117  bField000 = 4.0;
118  }
119  // The following should be on LogInfo
120  //std::cout << "B-field(T) at (0,0,0)(cm): " << bField000 << std::endl;
121 
122  // Initialize the calorimeter geometry
123  if (myCalorimetry) {
125  es.get<CaloGeometryRecord>().get(pG);
127 
128  edm::ESHandle<CaloTopology> theCaloTopology;
129  es.get<CaloTopologyRecord>().get(theCaloTopology);
130  myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology);
131  myCalorimetry->getCalorimeter()->initialize(bField000);
132 
134  }
135 
136  m_pRunNumber = run.run();
137 }
138 
140  const TrackerTopology* tTopo,
141  RandomEngineAndDistribution const* random) {
142  // myGenEvent = evt;
143 
144  iEvent++;
146 
147  // Fill the event from the original generated event
148  mySimEvent->fill(*evt, id);
149 
150  // And propagate the particles through the detector
151  myTrajectoryManager->reconstruct(tTopo, random);
152 
153  if (myCalorimetry)
154  myCalorimetry->reconstruct(random);
155 
156  edm::LogInfo("FamosManager") << " saved : Event " << iEvent << " of weight " << mySimEvent->weight() << " with "
157  << mySimEvent->nTracks() << " tracks and " << mySimEvent->nVertices()
158  << " vertices, generated by " << mySimEvent->nGenParts() << " particles " << std::endl;
159 }
FastHFShowerLibrary.h
TrajectoryManager::reconstruct
void reconstruct(const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
Does the real job.
Definition: TrajectoryManager.cc:129
electrons_cff.bool
bool
Definition: electrons_cff.py:366
FSimEvent
Definition: FSimEvent.h:29
MessageLogger.h
TrajectoryManager::initializeTrackerGeometry
void initializeTrackerGeometry(const TrackerGeometry *geomTracker)
Initialize the full Tracker Geometry.
Definition: TrajectoryManager.cc:112
Calorimeter::setupTopology
void setupTopology(const CaloTopology &)
Definition: Calorimeter.cc:127
ESHandle.h
edm::Run
Definition: Run.h:45
TrajectoryManager::initializeRecoGeometry
void initializeRecoGeometry(const GeometricSearchTracker *geomSearchTracker, const TrackerInteractionGeometry *interactionGeometry, const MagneticFieldMap *aFieldMap)
Initialize the Reconstruction Geometry.
Definition: TrajectoryManager.cc:97
FBaseSimEvent::initializePdt
void initializePdt(const HepPDT::ParticleDataTable *aPdt)
Initialize the particle data table.
Definition: FBaseSimEvent.cc:80
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
TrackerInteractionGeometryRecord
Definition: TrackerInteractionGeometryRecord.h:26
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CrossingFrame.h
MagneticFieldMap::inTeslaZ
double inTeslaZ(const GlobalPoint &) const
Definition: MagneticFieldMap.cc:91
TrackerRecoGeometryRecord.h
FamosManager.h
MagneticFieldMapRecord.h
TrackerRecoGeometryRecord
Definition: TrackerRecoGeometryRecord.h:14
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
FSimEvent::nTracks
unsigned int nTracks() const
Number of tracks.
Definition: FSimEvent.cc:24
FamosManager::m_Alignment
bool m_Alignment
Definition: FamosManager.h:63
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
CaloGeometryHelper::initialize
void initialize(double bField)
Definition: CaloGeometryHelper.cc:38
FamosManager::FamosManager
FamosManager(edm::ParameterSet const &p)
Constructor.
Definition: FamosManager.cc:45
FamosManager::m_Tracking
bool m_Tracking
Definition: FamosManager.h:61
FSimEvent.h
TrackerTopology.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
FamosManager::mySimEvent
FSimEvent * mySimEvent
Definition: FamosManager.h:55
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
EventID.h
Run.h
IdealMagneticFieldRecord.h
edm::ESHandle< HepPDT::ParticleDataTable >
Point3DBase< float, GlobalTag >
Calorimeter::setupGeometry
void setupGeometry(const CaloGeometry &pG)
Definition: Calorimeter.cc:117
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
FamosManager::myTrajectoryManager
TrajectoryManager * myTrajectoryManager
Definition: FamosManager.h:56
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FamosManager::m_pRunNumber
int m_pRunNumber
Definition: FamosManager.h:65
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParticleDataTable.h
MagneticFieldMap.h
CalorimetryManager
Definition: CalorimetryManager.h:44
CaloGeometryHelper.h
CaloTopologyRecord.h
CalorimetryManager::getHFShowerLibrary
FastHFShowerLibrary * getHFShowerLibrary() const
Definition: CalorimetryManager.h:63
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
TrajectoryManager.h
CalorimetryManager.h
FamosManager::m_Calorimetry
bool m_Calorimetry
Definition: FamosManager.h:62
FSimEvent::fill
void fill(const HepMC::GenEvent &hev, edm::EventID &Id)
fill the FBaseSimEvent from the current HepMC::GenEvent
Definition: FSimEvent.cc:10
MagneticFieldMapRecord
Definition: MagneticFieldMapRecord.h:27
edm::EventSetup
Definition: EventSetup.h:58
FamosManager::iEvent
int iEvent
Definition: FamosManager.h:53
get
#define get
CalorimetryManager::reconstruct
void reconstruct(RandomEngineAndDistribution const *)
Definition: CalorimetryManager.cc:149
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
FamosManager::myCalorimetry
CalorimetryManager * myCalorimetry
Definition: FamosManager.h:57
FamosManager::setupGeometryAndField
void setupGeometryAndField(edm::Run const &run, const edm::EventSetup &es)
Get information from the Event Setup.
Definition: FamosManager.cc:81
FSimEvent::weight
float weight() const
Method to return the event weight.
Definition: FSimEvent.cc:22
writedatasetfile.run
run
Definition: writedatasetfile.py:27
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
FamosManager::m_pUseMagneticField
bool m_pUseMagneticField
Definition: FamosManager.h:60
HepMC
Definition: GenParticle.h:15
CaloGeometry.h
EventSetup.h
FSimEvent::nVertices
unsigned int nVertices() const
Number of vertices.
Definition: FSimEvent.cc:26
Exception.h
ParameterSet.h
FSimEvent::nGenParts
unsigned int nGenParts() const
Number of MC particles.
Definition: FSimEvent.cc:28
TrajectoryManager
Definition: TrajectoryManager.h:59
FamosManager::~FamosManager
~FamosManager()
Destructor.
Definition: FamosManager.cc:72
edm::EventID
Definition: EventID.h:31
CalorimetryManager::getCalorimeter
CaloGeometryHelper * getCalorimeter() const
Definition: CalorimetryManager.h:60
FamosManager::reconstruct
void reconstruct(const HepMC::GenEvent *evt, const TrackerTopology *tTopo, RandomEngineAndDistribution const *)
The real thing is done here.
Definition: FamosManager.cc:139
g
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
FastHFShowerLibrary::initHFShowerLibrary
const void initHFShowerLibrary(const edm::EventSetup &)
Definition: FastHFShowerLibrary.cc:49
TrackerInteractionGeometryRecord.h
RandomEngineAndDistribution
Definition: RandomEngineAndDistribution.h:18