CMS 3D CMS Logo

Geometry.cc
Go to the documentation of this file.
1 //Framework Headers
5 
9 
15 
16 #include <iostream>
17 #include <map>
18 
19 using namespace fastsim;
20 
22 
24  : cacheIdentifierTrackerRecoGeometry_(0),
25  cacheIdentifierIdealMagneticField_(0),
26  geometricSearchTracker_(nullptr),
27  magneticField_(nullptr),
28  useFixedMagneticFieldZ_(cfg.exists("magneticFieldZ")),
29  fixedMagneticFieldZ_(cfg.getUntrackedParameter<double>("magneticFieldZ", 0.)),
30  useTrackerRecoGeometryRecord_(cfg.getUntrackedParameter<bool>("useTrackerRecoGeometryRecord", true)),
31  trackerAlignmentLabel_(cfg.getUntrackedParameter<std::string>("trackerAlignmentLabel", "")),
32  barrelLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("BarrelLayers")),
33  forwardLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("EndcapLayers")),
34  maxRadius_(cfg.getUntrackedParameter<double>("maxRadius", 500.)),
35  maxZ_(cfg.getUntrackedParameter<double>("maxZ", 1200.)),
36  barrelBoundary_(cfg.exists("trackerBarrelBoundary")) // Hack to interface "old" calo to "new" tracking
37  ,
38  forwardBoundary_(cfg.exists("trackerForwardBoundary")) // Hack to interface "old" calo to "new" tracking
39  ,
40  trackerBarrelBoundaryCfg_(barrelBoundary_
41  ? cfg.getParameter<edm::ParameterSet>("trackerBarrelBoundary")
42  : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
43  ,
44  trackerForwardBoundaryCfg_(forwardBoundary_
45  ? cfg.getParameter<edm::ParameterSet>("trackerForwardBoundary")
46  : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
47  {};
48 
49 void Geometry::update(const edm::EventSetup& iSetup,
50  const std::map<std::string, fastsim::InteractionModel*>& interactionModelMap) {
52  iSetup.get<IdealMagneticFieldRecord>().cacheIdentifier() == cacheIdentifierIdealMagneticField_) {
53  return;
54  }
55 
56  //----------------
57  // find tracker reconstruction geometry
58  //----------------
61  edm::ESHandle<GeometricSearchTracker> geometricSearchTrackerHandle;
62  iSetup.get<TrackerRecoGeometryRecord>().get(trackerAlignmentLabel_, geometricSearchTrackerHandle);
63  geometricSearchTracker_ = &(*geometricSearchTrackerHandle);
64  }
65  }
66 
67  //----------------
68  // update magnetic field
69  //----------------
71  if (useFixedMagneticFieldZ_) // use constant magnetic field
72  {
75  } else // get magnetic field from EventSetup
76  {
79  magneticField_ = &(*magneticField);
80  }
81  }
82 
83  //---------------
84  // layer factory
85  //---------------
86  SimplifiedGeometryFactory simplifiedGeometryFactory(
87  geometricSearchTracker_, *magneticField_, interactionModelMap, maxRadius_, maxZ_);
88 
89  //---------------
90  // update barrel layers
91  //---------------
92  barrelLayers_.clear();
93  for (const edm::ParameterSet& layerCfg : barrelLayerCfg_) {
94  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(layerCfg));
95  }
96 
97  // Hack to interface "old" calo to "new" tracking
98  if (barrelBoundary_) {
99  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(trackerBarrelBoundaryCfg_));
101  }
102 
103  for (unsigned index = 0; index < barrelLayers_.size(); index++) {
104  // set index
105  barrelLayers_[index]->setIndex(index);
106  // check order
107  if (index > 0) {
108  if (barrelLayers_[index]->getRadius() <= barrelLayers_[index - 1]->getRadius()) {
109  throw cms::Exception("fastsim::Geometry")
110  << "barrel layers must be ordered according to increading radius"
111  << "\nbarrel layer " << index << " has radius smaller than or equal to radius of barrel layer " << index - 1
112  << " (" << barrelLayers_[index]->getRadius() << "/" << barrelLayers_[index - 1]->getRadius() << ")";
113  }
114  }
115  }
116 
117  //--------------
118  // update forward layers
119  //--------------
120  forwardLayers_.clear();
121  for (const edm::ParameterSet& layerCfg : forwardLayerCfg_) {
122  forwardLayers_.push_back(simplifiedGeometryFactory.createForwardSimplifiedGeometry(
124  forwardLayers_.insert(forwardLayers_.begin(),
125  simplifiedGeometryFactory.createForwardSimplifiedGeometry(
127  }
128 
129  // Hack to interface "old" calo to "new" tracking
130  if (forwardBoundary_) {
131  forwardLayers_.push_back(simplifiedGeometryFactory.createForwardSimplifiedGeometry(
134  forwardLayers_.insert(forwardLayers_.begin(),
135  simplifiedGeometryFactory.createForwardSimplifiedGeometry(
138  }
139 
140  for (unsigned index = 0; index < forwardLayers_.size(); index++) {
141  // set index
142  forwardLayers_[index]->setIndex(index);
143  // check order
144  if (index > 0) {
145  if (forwardLayers_[index]->getZ() <= forwardLayers_[index - 1]->getZ()) {
146  throw cms::Exception("fastsim::Geometry")
147  << "forward layers must be ordered according to increasing z"
148  << "forward layer " << index << " has z smaller than or equal to z of forward layer " << index - 1;
149  }
150  }
151  }
152 }
153 
155  return magneticField_->inTesla(GlobalPoint(position.X(), position.Y(), position.Z())).z();
156 }
157 
158 std::ostream& fastsim::operator<<(std::ostream& os, const fastsim::Geometry& geometry) {
159  os << "-----------"
160  << "\n# fastsim::Geometry"
161  << "\n## BarrelLayers:";
162  for (const auto& layer : geometry.barrelLayers_) {
163  os << "\n " << *layer << layer->getInteractionModels().size() << " interaction models";
164  }
165  os << "\n## ForwardLayers:";
166  for (const auto& layer : geometry.forwardLayers_) {
167  os << "\n " << *layer << layer->getInteractionModels().size() << " interaction models";
168  }
169  os << "\n-----------";
170  return os;
171 }
fastsim::SimplifiedGeometryFactory::createForwardSimplifiedGeometry
std::unique_ptr< ForwardSimplifiedGeometry > createForwardSimplifiedGeometry(LayerType type, const edm::ParameterSet &cfg) const
Helper method for createSimplifiedGeometry(..) to create a forward layer (ForwardSimplifiedGeometry).
Definition: SimplifiedGeometryFactory.cc:45
fastsim::Geometry::trackerBarrelBoundaryCfg_
const edm::ParameterSet trackerBarrelBoundaryCfg_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:169
fastsim::Geometry
Definition the tracker geometry (vectors of forward/barrel layers).
Definition: Geometry.h:32
electrons_cff.bool
bool
Definition: electrons_cff.py:372
fastsim::Geometry::magneticField_
const MagneticField * magneticField_
The tracker geometry.
Definition: Geometry.h:154
fastsim::Geometry::trackerForwardBoundaryCfg_
const edm::ParameterSet trackerForwardBoundaryCfg_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:170
fastsim::Geometry::forwardBoundary_
const bool forwardBoundary_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:168
fastsim::Geometry::cacheIdentifierIdealMagneticField_
unsigned long long cacheIdentifierIdealMagneticField_
Check interval of validity of the magnetic field.
Definition: Geometry.h:151
fastsim::Geometry::trackerAlignmentLabel_
const std::string trackerAlignmentLabel_
The tracker alignment label.
Definition: Geometry.h:159
fastsim::Geometry::cacheIdentifierTrackerRecoGeometry_
unsigned long long cacheIdentifierTrackerRecoGeometry_
Check interval of validity of the tracker geometry.
Definition: Geometry.h:150
ESHandle.h
fastsim::Geometry::maxRadius_
const double maxRadius_
Definition: Geometry.h:164
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
fastsim::Geometry::ownedMagneticField_
std::unique_ptr< MagneticField > ownedMagneticField_
Needed to create a uniform magnetic field if speciefied in config.
Definition: Geometry.h:148
fastsim::Geometry::barrelLayers_
std::vector< std::unique_ptr< BarrelSimplifiedGeometry > > barrelLayers_
The vector of barrel layers (increasing radius)
Definition: Geometry.h:144
edm
HLT enums.
Definition: AlignableModifier.h:19
geometry
Definition: geometry.py:1
TrackerRecoGeometryRecord.h
Geometry.h
fastsim::Geometry::fixedMagneticFieldZ_
const double fixedMagneticFieldZ_
Use a uniform magnetic field or non-uniform from MagneticFieldRecord.
Definition: Geometry.h:156
TrackerRecoGeometryRecord
Definition: TrackerRecoGeometryRecord.h:11
fastsim::SimplifiedGeometryFactory
Constructs a tracker layer according to entry in python config (incl interaction models).
Definition: SimplifiedGeometryFactory.h:40
fastsim::Geometry::Geometry
Geometry(const edm::ParameterSet &cfg)
Constructor.
Definition: Geometry.cc:23
fastsim::Geometry::barrelLayerCfg_
const std::vector< edm::ParameterSet > barrelLayerCfg_
The config in which all parameters of the barrel layers are defined.
Definition: Geometry.h:161
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
fastsim::SimplifiedGeometryFactory::POSFWD
Definition: SimplifiedGeometryFactory.h:57
fastsim::SimplifiedGeometryFactory::NEGFWD
Definition: SimplifiedGeometryFactory.h:57
fastsim::SimplifiedGeometryFactory::createBarrelSimplifiedGeometry
std::unique_ptr< BarrelSimplifiedGeometry > createBarrelSimplifiedGeometry(const edm::ParameterSet &cfg) const
Helper method for createSimplifiedGeometry(..) to create a barrel layer (BarrelSimplifiedGeometry).
Definition: SimplifiedGeometryFactory.cc:38
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
fastsim::Geometry::~Geometry
~Geometry()
Default destructor.
Definition: Geometry.cc:21
fastsim::Geometry::getMagneticFieldZ
double getMagneticFieldZ(const math::XYZTLorentzVector &position) const
Initializes the tracker geometry.
Definition: Geometry.cc:154
fastsim::Geometry::maxZ_
const double maxZ_
Upper bound of the radius of the whole tracker geometry.
Definition: Geometry.h:165
IdealMagneticFieldRecord.h
edm::ESHandle< GeometricSearchTracker >
fastsim::Geometry::barrelBoundary_
const bool barrelBoundary_
Upper bound of the length/2 (0 to +Z) of the whole tracker geometry.
Definition: Geometry.h:167
BarrelSimplifiedGeometry.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
fastsim::SimplifiedGeometry::TRACKERBOUNDARY
Definition: SimplifiedGeometry.h:59
SimplifiedGeometryFactory.h
fastsim::Geometry::useTrackerRecoGeometryRecord_
const bool useTrackerRecoGeometryRecord_
Use GeometricSearchTracker (active layers/reco geometry). Can be used to get position/radius of track...
Definition: Geometry.h:158
fastsim::operator<<
std::ostream & operator<<(std::ostream &os, const fastsim::Geometry &geometry)
Definition: Geometry.cc:158
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
ParameterSet
Definition: Functions.h:16
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
ForwardSimplifiedGeometry.h
fastsim::Geometry::geometricSearchTracker_
const GeometricSearchTracker * geometricSearchTracker_
Definition: Geometry.h:153
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
UniformMagneticField.h
get
#define get
looper.cfg
cfg
Definition: looper.py:297
fastsim::Geometry::forwardLayers_
std::vector< std::unique_ptr< ForwardSimplifiedGeometry > > forwardLayers_
The vector of forward layers (increasing Z-position)
Definition: Geometry.h:146
std
Definition: JetResolutionObject.h:76
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
Exception
Definition: hltDiff.cc:246
Exception.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:185
fastsim
Definition: BarrelSimplifiedGeometry.h:15
ParameterSet.h
fastsim::Geometry::forwardLayerCfg_
const std::vector< edm::ParameterSet > forwardLayerCfg_
The config in which all parameters of the forward layers are defined.
Definition: Geometry.h:163
fastsim::Geometry::useFixedMagneticFieldZ_
const bool useFixedMagneticFieldZ_
Needed to create a uniform magnetic field if speciefied in config.
Definition: Geometry.h:155
fastsim::Geometry::update
void update(const edm::EventSetup &iSetup, const std::map< std::string, InteractionModel * > &interactionModelMap)
Initializes the tracker geometry.
Definition: Geometry.cc:49
UniformMagneticField
Definition: UniformMagneticField.h:13