CMS 3D CMS Logo

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