CMS 3D CMS Logo

Geometry.cc
Go to the documentation of this file.
1 //Framework Headers
5 
6 
10 
11 
17 
18 #include <iostream>
19 #include <map>
20 
21 using namespace fastsim;
22 
24 
30  , useFixedMagneticFieldZ_(cfg.exists("magneticFieldZ"))
31  , fixedMagneticFieldZ_(cfg.getUntrackedParameter<double>("magneticFieldZ",0.))
32  , useTrackerRecoGeometryRecord_(cfg.getUntrackedParameter<bool>("useTrackerRecoGeometryRecord",true))
33  , trackerAlignmentLabel_(cfg.getUntrackedParameter<std::string>("trackerAlignmentLabel",""))
34  , barrelLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("BarrelLayers"))
35  , forwardLayerCfg_(cfg.getParameter<std::vector<edm::ParameterSet>>("EndcapLayers"))
36  , maxRadius_(cfg.getUntrackedParameter<double>("maxRadius",500.))
37  , maxZ_(cfg.getUntrackedParameter<double>("maxZ",1200.))
38  , barrelBoundary_(cfg.exists("trackerBarrelBoundary")) // Hack to interface "old" calo to "new" tracking
39  , forwardBoundary_(cfg.exists("trackerForwardBoundary")) // Hack to interface "old" calo to "new" tracking
40  , trackerBarrelBoundaryCfg_(barrelBoundary_ ? cfg.getParameter<edm::ParameterSet>("trackerBarrelBoundary") : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
41  , trackerForwardBoundaryCfg_(forwardBoundary_ ? cfg.getParameter<edm::ParameterSet>("trackerForwardBoundary") : edm::ParameterSet()) // Hack to interface "old" calo to "new" tracking
42 {};
43 
44 void Geometry::update(const edm::EventSetup & iSetup,const std::map<std::string,fastsim::InteractionModel*> & interactionModelMap)
45 {
47  && iSetup.get<IdealMagneticFieldRecord>().cacheIdentifier() == cacheIdentifierIdealMagneticField_)
48  {
49  return;
50  }
51 
52  //----------------
53  // find tracker reconstruction geometry
54  //----------------
57  {
58  edm::ESHandle<GeometricSearchTracker> geometricSearchTrackerHandle;
59  iSetup.get<TrackerRecoGeometryRecord>().get(trackerAlignmentLabel_,geometricSearchTrackerHandle);
60  geometricSearchTracker_ = &(*geometricSearchTrackerHandle);
61  }
62  }
63 
64 
65  //----------------
66  // update magnetic field
67  //----------------
69  if(useFixedMagneticFieldZ_) // use constant magnetic field
70  {
73  }
74  else // get magnetic field from EventSetup
75  {
77  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
78  magneticField_ = &(*magneticField);
79  }
80  }
81 
82 
83  //---------------
84  // layer factory
85  //---------------
86  SimplifiedGeometryFactory simplifiedGeometryFactory(geometricSearchTracker_
88  ,interactionModelMap
89  ,maxRadius_
90  ,maxZ_);
91 
92  //---------------
93  // update barrel layers
94  //---------------
95  barrelLayers_.clear();
96  for(const edm::ParameterSet & layerCfg : barrelLayerCfg_)
97  {
98  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(layerCfg));
99  }
100 
101  // Hack to interface "old" calo to "new" tracking
102  if(barrelBoundary_){
103  barrelLayers_.push_back(simplifiedGeometryFactory.createBarrelSimplifiedGeometry(trackerBarrelBoundaryCfg_));
105  }
106 
107  for(unsigned index = 0; index < barrelLayers_.size(); index++)
108  {
109  // set index
110  barrelLayers_[index]->setIndex(index);
111  // check order
112  if(index > 0)
113  {
114  if(barrelLayers_[index]->getRadius() <= barrelLayers_[index-1]->getRadius())
115  {
116  throw cms::Exception("fastsim::Geometry")
117  << "barrel layers must be ordered according to increading radius"
118  << "\nbarrel layer " << index
119  << " has radius smaller than or equal to radius of barrel layer " << index -1
120  << " (" << barrelLayers_[index]->getRadius() << "/" << barrelLayers_[index-1]->getRadius() << ")";
121  }
122  }
123  }
124 
125  //--------------
126  // update forward layers
127  //--------------
128  forwardLayers_.clear();
129  for(const edm::ParameterSet & layerCfg : forwardLayerCfg_)
130  {
133  }
134 
135  // Hack to interface "old" calo to "new" tracking
136  if(forwardBoundary_){
141  }
142 
143  for(unsigned index = 0; index < forwardLayers_.size(); index++)
144  {
145  // set index
146  forwardLayers_[index]->setIndex(index);
147  // check order
148  if(index > 0)
149  {
150  if(forwardLayers_[index]->getZ() <= forwardLayers_[index-1]->getZ())
151  {
152  throw cms::Exception("fastsim::Geometry")
153  << "forward layers must be ordered according to increasing z"
154  << "forward layer " << index
155  << " has z smaller than or equal to z of forward layer " << index -1;
156  }
157  }
158  }
159 }
160 
162 {
163  return magneticField_->inTesla(GlobalPoint(position.X(),position.Y(),position.Z())).z();
164 }
165 
166 std::ostream& fastsim::operator << (std::ostream& os , const fastsim::Geometry & geometry)
167 {
168  os << "-----------"
169  << "\n# fastsim::Geometry"
170  << "\n## BarrelLayers:";
171  for(const auto & layer : geometry.barrelLayers_)
172  {
173  os << "\n " << *layer
174  << layer->getInteractionModels().size() << " interaction models";
175  }
176  os << "\n## ForwardLayers:";
177  for(const auto & layer : geometry.forwardLayers_)
178  {
179  os << "\n " << *layer
180  << layer->getInteractionModels().size() << " interaction models";
181  }
182  os << "\n-----------";
183  return os;
184 }
185 
const bool useTrackerRecoGeometryRecord_
Use GeometricSearchTracker (active layers/reco geometry). Can be used to get position/radius of track...
Definition: Geometry.h:167
unsigned long long cacheIdentifier() const
unsigned long long cacheIdentifierTrackerRecoGeometry_
Check interval of validity of the tracker geometry.
Definition: Geometry.h:160
void update(const edm::EventSetup &iSetup, const std::map< std::string, InteractionModel * > &interactionModelMap)
Initializes the tracker geometry.
Definition: Geometry.cc:44
std::vector< std::unique_ptr< BarrelSimplifiedGeometry > > barrelLayers_
The vector of barrel layers (increasing radius)
Definition: Geometry.h:156
const GeometricSearchTracker * geometricSearchTracker_
Definition: Geometry.h:163
const MagneticField * magneticField_
The tracker geometry.
Definition: Geometry.h:164
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:170
const std::vector< edm::ParameterSet > barrelLayerCfg_
The config in which all parameters of the barrel layers are defined.
Definition: Geometry.h:169
#define nullptr
const double fixedMagneticFieldZ_
Use a uniform magnetic field or non-uniform from MagneticFieldRecord.
Definition: Geometry.h:166
const double maxZ_
Upper bound of the radius of the whole tracker geometry.
Definition: Geometry.h:172
const edm::ParameterSet trackerForwardBoundaryCfg_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:177
const std::string trackerAlignmentLabel_
The tracker alignment label.
Definition: Geometry.h:168
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:158
T z() const
Definition: PV3DBase.h:64
std::ostream & operator<<(std::ostream &os, const fastsim::Geometry &geometry)
Definition: Geometry.cc:166
const bool forwardBoundary_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:175
double getMagneticFieldZ(const math::XYZTLorentzVector &position) const
Initializes the tracker geometry.
Definition: Geometry.cc:161
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Geometry(const edm::ParameterSet &cfg)
Constructor.
Definition: Geometry.cc:25
Constructs a tracker layer according to entry in python config (incl interaction models).
const edm::ParameterSet trackerBarrelBoundaryCfg_
Hack to interface "old" calo to "new" tracking.
Definition: Geometry.h:176
Definition the tracker geometry (vectors of forward/barrel layers).
Definition: Geometry.h:34
HLT enums.
const double maxRadius_
Definition: Geometry.h:171
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get() const
Definition: EventSetup.h:63
std::vector< std::unique_ptr< ForwardSimplifiedGeometry > > forwardLayers_
The vector of forward layers (increasing Z-position)
Definition: Geometry.h:157
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:165
~Geometry()
Default destructor.
Definition: Geometry.cc:23
const bool barrelBoundary_
Upper bound of the length/2 (0 to +Z) of the whole tracker geometry.
Definition: Geometry.h:174
unsigned long long cacheIdentifierIdealMagneticField_
Check interval of validity of the magnetic field.
Definition: Geometry.h:161