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 #include <memory>
19 
20 using namespace fastsim;
21 
23 
25  : cacheIdentifierTrackerRecoGeometry_(0),
26  cacheIdentifierIdealMagneticField_(0),
27  geometricSearchTracker_(nullptr),
28  magneticField_(nullptr),
29  useFixedMagneticFieldZ_(cfg.exists("magneticFieldZ")),
30  fixedMagneticFieldZ_(cfg.getUntrackedParameter<double>("magneticFieldZ", 0.)),
31  useTrackerRecoGeometryRecord_(cfg.getUntrackedParameter<bool>("useTrackerRecoGeometryRecord", true)),
32  trackerAlignmentLabel_(cfg.getUntrackedParameter<std::string>("trackerAlignmentLabel", "")),
33  barrelLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("BarrelLayers")),
34  forwardLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("EndcapLayers")),
35  maxRadius_(cfg.getUntrackedParameter<double>("maxRadius", 500.)),
36  maxZ_(cfg.getUntrackedParameter<double>("maxZ", 1200.)),
37  barrelBoundary_(cfg.exists("trackerBarrelBoundary")) // Hack to interface "old" calo to "new" tracking
38  ,
39  forwardBoundary_(cfg.exists("trackerForwardBoundary")) // Hack to interface "old" calo to "new" tracking
40  ,
41  trackerBarrelBoundaryCfg_(barrelBoundary_
42  ? cfg.getParameter<edm::ParameterSet>("trackerBarrelBoundary")
43  : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
44  ,
45  trackerForwardBoundaryCfg_(forwardBoundary_
46  ? cfg.getParameter<edm::ParameterSet>("trackerForwardBoundary")
47  : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
48  {};
49 
50 void Geometry::update(const edm::EventSetup& iSetup,
51  const std::map<std::string, fastsim::InteractionModel*>& interactionModelMap) {
53  iSetup.get<IdealMagneticFieldRecord>().cacheIdentifier() == cacheIdentifierIdealMagneticField_) {
54  return;
55  }
56 
57  //----------------
58  // find tracker reconstruction geometry
59  //----------------
62  edm::ESHandle<GeometricSearchTracker> geometricSearchTrackerHandle;
63  iSetup.get<TrackerRecoGeometryRecord>().get(trackerAlignmentLabel_, geometricSearchTrackerHandle);
64  geometricSearchTracker_ = &(*geometricSearchTrackerHandle);
65  }
66  }
67 
68  //----------------
69  // update magnetic field
70  //----------------
72  if (useFixedMagneticFieldZ_) // use constant magnetic field
73  {
74  ownedMagneticField_ = std::make_unique<UniformMagneticField>(fixedMagneticFieldZ_);
76  } else // get magnetic field from EventSetup
77  {
80  magneticField_ = &(*magneticField);
81  }
82  }
83 
84  //---------------
85  // layer factory
86  //---------------
87  SimplifiedGeometryFactory simplifiedGeometryFactory(
88  geometricSearchTracker_, *magneticField_, interactionModelMap, maxRadius_, maxZ_);
89 
90  //---------------
91  // update barrel layers
92  //---------------
93  barrelLayers_.clear();
94  for (const edm::ParameterSet& layerCfg : barrelLayerCfg_) {
95  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(layerCfg));
96  }
97 
98  // Hack to interface "old" calo to "new" tracking
99  if (barrelBoundary_) {
100  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(trackerBarrelBoundaryCfg_));
102  }
103 
104  for (unsigned index = 0; index < barrelLayers_.size(); index++) {
105  // set index
106  barrelLayers_[index]->setIndex(index);
107  // check order
108  if (index > 0) {
109  if (barrelLayers_[index]->getRadius() <= barrelLayers_[index - 1]->getRadius()) {
110  throw cms::Exception("fastsim::Geometry")
111  << "barrel layers must be ordered according to increading radius"
112  << "\nbarrel layer " << index << " has radius smaller than or equal to radius of barrel layer " << index - 1
113  << " (" << barrelLayers_[index]->getRadius() << "/" << barrelLayers_[index - 1]->getRadius() << ")";
114  }
115  }
116  }
117 
118  //--------------
119  // update forward layers
120  //--------------
121  forwardLayers_.clear();
122  for (const edm::ParameterSet& layerCfg : forwardLayerCfg_) {
123  forwardLayers_.push_back(simplifiedGeometryFactory.createForwardSimplifiedGeometry(
125  forwardLayers_.insert(forwardLayers_.begin(),
126  simplifiedGeometryFactory.createForwardSimplifiedGeometry(
128  }
129 
130  // Hack to interface "old" calo to "new" tracking
131  if (forwardBoundary_) {
132  forwardLayers_.push_back(simplifiedGeometryFactory.createForwardSimplifiedGeometry(
135  forwardLayers_.insert(forwardLayers_.begin(),
136  simplifiedGeometryFactory.createForwardSimplifiedGeometry(
139  }
140 
141  for (unsigned index = 0; index < forwardLayers_.size(); index++) {
142  // set index
143  forwardLayers_[index]->setIndex(index);
144  // check order
145  if (index > 0) {
146  if (forwardLayers_[index]->getZ() <= forwardLayers_[index - 1]->getZ()) {
147  throw cms::Exception("fastsim::Geometry")
148  << "forward layers must be ordered according to increasing z"
149  << "forward layer " << index << " has z smaller than or equal to z of forward layer " << index - 1;
150  }
151  }
152  }
153 }
154 
156  return magneticField_->inTesla(GlobalPoint(position.X(), position.Y(), position.Z())).z();
157 }
158 
159 std::ostream& fastsim::operator<<(std::ostream& os, const fastsim::Geometry& geometry) {
160  os << "-----------"
161  << "\n# fastsim::Geometry"
162  << "\n## BarrelLayers:";
163  for (const auto& layer : geometry.barrelLayers_) {
164  os << "\n " << *layer << layer->getInteractionModels().size() << " interaction models";
165  }
166  os << "\n## ForwardLayers:";
167  for (const auto& layer : geometry.forwardLayers_) {
168  os << "\n " << *layer << layer->getInteractionModels().size() << " interaction models";
169  }
170  os << "\n-----------";
171  return os;
172 }
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:46
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:393
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
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
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
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:24
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:39
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
fastsim::Geometry::~Geometry
~Geometry()
Default destructor.
Definition: Geometry.cc:22
fastsim::Geometry::getMagneticFieldZ
double getMagneticFieldZ(const math::XYZTLorentzVector &position) const
Initializes the tracker geometry.
Definition: Geometry.cc:155
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:159
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
ForwardSimplifiedGeometry.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
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:184
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:50