Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:20

0001 #ifndef FASTSIM_GEOMETRY_H
0002 #define FASTSIM_GEOMETRY_H
0003 
0004 #include "DataFormats/Math/interface/LorentzVector.h"
0005 #include "FastSimulation/SimplifiedGeometryPropagator/interface/ForwardSimplifiedGeometry.h"
0006 #include "FastSimulation/SimplifiedGeometryPropagator/interface/BarrelSimplifiedGeometry.h"
0007 #include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/ESGetToken.h"
0010 #include "MagneticField/Engine/interface/MagneticField.h"
0011 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0012 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
0013 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0014 
0015 ///////////////////////////////////////////////
0016 // Author: L. Vanelderen, S. Kurz
0017 // Date: 29 May 2017
0018 //////////////////////////////////////////////////////////
0019 
0020 #include <vector>
0021 
0022 namespace fastsim {
0023   class InteractionModel;
0024 
0025   //! Definition the tracker geometry (vectors of forward/barrel layers).
0026   /*!
0027         This class models the material budget of the tracker. Those are reflected by 2 vectors of forward (disks, ordered by increasing Z-position) and barrel layers respectively (cylinders, ordered by increasing radius).
0028         Furthermore, initiatilizes the magnetic field used for propagation of particles inside the tracker.
0029     */
0030   class Geometry {
0031   public:
0032     //! Constructor.
0033     Geometry(const edm::ParameterSet&, edm::ConsumesCollector&&);
0034 
0035     //! Default destructor.
0036     ~Geometry();
0037 
0038     //! Initializes the tracker geometry.
0039     /*!
0040             Calls SimplifiedGeometryFactory to initialize the vectors of barrel/forward layers and provides magnetic field and interaction models for those.
0041             \param iSetup The Event Setup.
0042             \param interactionModelMap Map of all interaction models considered (for any layer)
0043             \sa SimplifiedGeometryFactory
0044         */
0045     void update(const edm::EventSetup& iSetup, const std::map<std::string, InteractionModel*>& interactionModelMap);
0046 
0047     //! Initializes the tracker geometry.
0048     /*!
0049             Get the field from the MagneticFieldRecord (or set constant if defined in python config)
0050             \param position The position where you want to get the magnetic field (field only in Z direction).
0051             \return The magnetic field (Z-direction) for a given position.
0052         */
0053     double getMagneticFieldZ(const math::XYZTLorentzVector& position) const;
0054 
0055     //! Return the vector of barrel layers.
0056     /*!
0057             Ordered by increasing radius (0 to +inf).
0058             \return The barrel layers according to defined geometry.
0059         */
0060     const std::vector<std::unique_ptr<BarrelSimplifiedGeometry>>& barrelLayers() const { return barrelLayers_; }
0061 
0062     //! Return the vector of forward layers (disks).
0063     /*!
0064             Ordered by increasing Z-position (-inf to +inf).
0065             \return The forward layers according to defined geometry.
0066         */
0067     const std::vector<std::unique_ptr<ForwardSimplifiedGeometry>>& forwardLayers() const { return forwardLayers_; }
0068 
0069     //! Upper bound of the radius of the whole tracker geometry.
0070     /*!
0071             Necessary to initialize the magnetic field within this volume.
0072             \return Upper bound of radius of the whole tracker geometry
0073         */
0074     double getMaxRadius() { return maxRadius_; }
0075 
0076     //! Upper bound of the length/2 (0 to +Z) of the whole tracker geometry.
0077     /*!
0078             Necessary to initialize the magnetic field within this volume.
0079             \return Upper bound of length/2 of the whole tracker geometry
0080         */
0081     double getMaxZ() { return maxZ_; }
0082 
0083     //! Provides some basic output for e.g. debugging.
0084     friend std::ostream& operator<<(std::ostream& o, const fastsim::Geometry& geometry);
0085 
0086     //! Helps to navigate through the vector of barrel layers.
0087     /*!
0088             For a given layer, returns the next layer (as ordered in std::vector<...> barrelLayers_).
0089             \param layer A barrel layer
0090             \return The next layer (increasing radius). Returns 0 if last layer reached.
0091         */
0092     const BarrelSimplifiedGeometry* nextLayer(const BarrelSimplifiedGeometry* layer) const {
0093       if (layer == nullptr) {
0094         return nullptr;
0095       }
0096       unsigned nextLayerIndex = layer->index() + 1;
0097       return nextLayerIndex < barrelLayers_.size() ? barrelLayers_[nextLayerIndex].get() : nullptr;
0098     }
0099 
0100     //! Helps to navigate through the vector of forward layers.
0101     /*!
0102             For a given layer, returns the next layer (as ordered in std::vector<...> forwardLayers_).
0103             \param layer A forward layer
0104             \return The next layer (increasing Z-position). Returns 0 if last layer reached.
0105         */
0106     const ForwardSimplifiedGeometry* nextLayer(const ForwardSimplifiedGeometry* layer) const {
0107       if (layer == nullptr) {
0108         return nullptr;
0109       }
0110       unsigned nextLayerIndex = layer->index() + 1;
0111       return nextLayerIndex < forwardLayers_.size() ? forwardLayers_[nextLayerIndex].get() : nullptr;
0112     }
0113 
0114     //! Helps to navigate through the vector of barrel layers.
0115     /*!
0116             For a given layer, returns the previous layer (as ordered in std::vector<...> barrelLayers_).
0117             \param layer A barrel layer
0118             \return The previous layer (decreasing radius). Returns 0 if first layer reached.
0119         */
0120     const BarrelSimplifiedGeometry* previousLayer(const BarrelSimplifiedGeometry* layer) const {
0121       if (layer == nullptr) {
0122         return barrelLayers_.back().get();
0123       }
0124       return layer->index() > 0 ? barrelLayers_[layer->index() - 1].get() : nullptr;
0125     }
0126 
0127     //! Helps to navigate through the vector of forward layers.
0128     /*!
0129             For a given layer, returns the previous layer (as ordered in std::vector<...> forwardLayers_).
0130             \param layer A forward layer
0131             \return The previous layer (decreasing Z-position). Returns 0 if first layer reached.
0132         */
0133     const ForwardSimplifiedGeometry* previousLayer(const ForwardSimplifiedGeometry* layer) const {
0134       if (layer == nullptr) {
0135         return forwardLayers_.back().get();
0136       }
0137       return layer->index() > 0 ? forwardLayers_[layer->index() - 1].get() : nullptr;
0138     }
0139 
0140   private:
0141     std::vector<std::unique_ptr<BarrelSimplifiedGeometry>>
0142         barrelLayers_;  //!< The vector of barrel layers (increasing radius)
0143     std::vector<std::unique_ptr<ForwardSimplifiedGeometry>>
0144         forwardLayers_;  //!< The vector of forward layers (increasing Z-position)
0145     std::unique_ptr<MagneticField>
0146         ownedMagneticField_;  //!< Needed to create a uniform magnetic field if speciefied in config
0147 
0148     unsigned long long cacheIdentifierTrackerRecoGeometry_;  //!< Check interval of validity of the tracker geometry
0149     unsigned long long cacheIdentifierIdealMagneticField_;   //!< Check interval of validity of the magnetic field
0150 
0151     const GeometricSearchTracker* geometricSearchTracker_;  //! The tracker geometry
0152     const MagneticField* magneticField_;                    //!< The magnetic field
0153     const bool useFixedMagneticFieldZ_;  //!< Needed to create a uniform magnetic field if speciefied in config
0154     const double fixedMagneticFieldZ_;   //!< Use a uniform magnetic field or non-uniform from MagneticFieldRecord
0155     const bool
0156         useTrackerRecoGeometryRecord_;  //!< Use GeometricSearchTracker (active layers/reco geometry). Can be used to get position/radius of tracker material that reflects active layers
0157     const std::string trackerAlignmentLabel_;  //!< The tracker alignment label
0158     const std::vector<edm::ParameterSet>
0159         barrelLayerCfg_;  //!< The config in which all parameters of the barrel layers are defined
0160     const std::vector<edm::ParameterSet>
0161         forwardLayerCfg_;     //!< The config in which all parameters of the forward layers are defined
0162     const double maxRadius_;  //! Upper bound of the radius of the whole tracker geometry
0163     const double maxZ_;       //! Upper bound of the length/2 (0 to +Z) of the whole tracker geometry
0164 
0165     const bool barrelBoundary_;                          //!< Hack to interface "old" calo to "new" tracking
0166     const bool forwardBoundary_;                         //!< Hack to interface "old" calo to "new" tracking
0167     const edm::ParameterSet trackerBarrelBoundaryCfg_;   //!< Hack to interface "old" calo to "new" tracking
0168     const edm::ParameterSet trackerForwardBoundaryCfg_;  //!< Hack to interface "old" calo to "new" tracking
0169 
0170     edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> geometricSearchTrackerESToken_;
0171     edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldESToken_;
0172   };
0173   std::ostream& operator<<(std::ostream& os, const fastsim::Geometry& geometry);
0174 }  // namespace fastsim
0175 
0176 #endif