Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FastSimulation_GeometryTool_Crystal_h
0002 #define FastSimulation_GeometryTool_Crystal_h
0003 
0004 // Data Formats
0005 #include "Math/GenVector/Plane3D.h"
0006 #include "DataFormats/Math/interface/Vector3D.h"
0007 
0008 // Unfortunately, GlobalPoints are also needed
0009 #include "Geometry/CaloTopology/interface/CaloDirection.h"
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 
0012 //FAMOS
0013 #include "FastSimulation/CaloGeometryTools/interface/CrystalNeighbour.h"
0014 #include "FastSimulation/CaloGeometryTools/interface/BaseCrystal.h"
0015 
0016 #include <vector>
0017 
0018 class DetId;
0019 
0020 class Crystal {
0021 public:
0022   typedef math::XYZVector XYZVector;
0023   typedef math::XYZVector XYZPoint;
0024   typedef ROOT::Math::Plane3D Plane3D;
0025 
0026   // side numbering
0027   //  enum CrystalSide{EAST=0,NORTH=1,WEST=2,SOUTH=3,FRONT=4,BACK=5};
0028   /// Empty constructor
0029   Crystal() = default;
0030   /// constructor from DetId
0031   Crystal(const DetId& cell, const BaseCrystal* bc = nullptr);
0032 
0033   /// get the i-th corner
0034   inline const XYZPoint& getCorner(unsigned i) const { return myCrystal_->getCorner(i); };
0035   /// get 1/8*(Sum of corners)
0036   inline const XYZPoint& getCenter() const { return myCrystal_->getCenter(); };
0037   /// get front center
0038   inline const XYZPoint& getFrontCenter() const { return myCrystal_->getFrontCenter(); };
0039   /// get front center
0040   inline const XYZPoint& getBackCenter() const { return myCrystal_->getBackCenter(); }
0041   /// Direction of the first edge
0042   inline const XYZVector& getFirstEdge() const { return myCrystal_->getFirstEdge(); }
0043   /// Direction of the fifth edge
0044   inline const XYZVector& getFifthEdge() const { return myCrystal_->getFifthEdge(); }
0045   /// get the DetId
0046   inline const DetId& getDetId() const { return cellid_; };
0047   /// get the subdector
0048   inline const int getSubdetNumber() const { return myCrystal_->getSubdetNumber(); }
0049   void print() const { return myCrystal_->print(); }
0050   /// get the lateral edges
0051   void getLateralEdges(unsigned i, XYZPoint& a, XYZPoint& b) const { myCrystal_->getLateralEdges(i, a, b); };
0052   /// coordinates of the front side
0053   void getFrontSide(XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const { myCrystal_->getFrontSide(a, b, c, d); }
0054   void getFrontSide(std::vector<XYZPoint>& corners) const { myCrystal_->getFrontSide(corners); }
0055   /// Coordinates of the back side
0056   void getBackSide(XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const { myCrystal_->getBackSide(a, b, c, d); }
0057   void getBackSide(std::vector<XYZPoint>& corners) const { myCrystal_->getBackSide(corners); }
0058   /// Coordinates of the i=th lateral side
0059   void getLateralSide(unsigned i, XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const {
0060     myCrystal_->getLateralSide(i, a, b, c, d);
0061   }
0062   void getLateralSide(unsigned i, std::vector<XYZPoint>& corners) const { myCrystal_->getLateralSide(i, corners); }
0063   /// generic access
0064   void getSide(const CaloDirection& side, XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const {
0065     myCrystal_->getSide(side, a, b, c, d);
0066   }
0067   void getSide(const CaloDirection& side, std::vector<XYZPoint>& corners) const { myCrystal_->getSide(side, corners); }
0068 
0069   /// front plane
0070   const Plane3D& getFrontPlane() const { return myCrystal_->getFrontPlane(); }
0071   /// back plane
0072   const Plane3D& getBackPlane() const { return myCrystal_->getBackPlane(); }
0073   /// lateral planes
0074   const Plane3D& getLateralPlane(unsigned i) const { return myCrystal_->getLateralPlane(i); }
0075   /// generic access
0076   const Plane3D& getPlane(const CaloDirection& side) const { return myCrystal_->getPlane(side); }
0077 
0078   /// lateral directions
0079   inline const XYZVector& getLateralEdge(unsigned i) const { return myCrystal_->getLateralEdge(i); }
0080 
0081   /// normal exiting vector for the surface
0082   inline const XYZVector& exitingNormal(const CaloDirection& side) const { return myCrystal_->exitingNormal(side); }
0083 
0084   static unsigned oppositeDirection(unsigned iside);
0085 
0086   /// for debugging.
0087   void getDrawingCoordinates(std::vector<float>& x, std::vector<float>& y, std::vector<float>& z) const {
0088     myCrystal_->getDrawingCoordinates(x, y, z);
0089   }
0090 
0091   /// it might be useful to have a number assigned to the crystal
0092   inline void setNumber(unsigned n) { number_ = n; };
0093 
0094   /// get the number of the crystal
0095   inline unsigned number() const { return number_; };
0096 
0097   /// Direct acces to the iq-th neighbour
0098   inline CrystalNeighbour& crystalNeighbour(unsigned iq) { return neighbours_[iq]; }
0099 
0100   /// get crystal axis
0101   inline const XYZVector& getAxis() const { return myCrystal_->getAxis(); }
0102 
0103   /// set X0back (it depends on the choosen origin, it isn't purely geometrical)
0104   inline void setX0Back(double val) { X0back_ = val; }
0105 
0106   /// get the X0back
0107   inline double getX0Back() const { return X0back_; }
0108 
0109   ~Crystal() { ; };
0110 
0111 private:
0112   unsigned number_ = 0;
0113   DetId cellid_;
0114   std::vector<CrystalNeighbour> neighbours_;
0115   double X0back_ = 0.;
0116   const BaseCrystal* myCrystal_ = nullptr;
0117 
0118 public:
0119   class crystalEqual {
0120   public:
0121     crystalEqual(const DetId& cell) : ref_(cell) { ; };
0122     ~crystalEqual() { ; };
0123     inline bool operator()(const Crystal& xtal) const { return (ref_ == xtal.getDetId()); }
0124 
0125   private:
0126     const DetId& ref_;
0127   };
0128 };
0129 #endif