Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:32

0001 #ifndef FastSimulation_GeometryTool_BaseCrystal_h
0002 #define FastSimulation_GeometryTool_BaseCrystal_h
0003 
0004 //Data Formats
0005 #include "DataFormats/Math/interface/Vector3D.h"
0006 #include "Math/GenVector/Plane3D.h"
0007 
0008 // Unfortunately, GlobalPoints are also needed
0009 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0010 #include "Geometry/CaloTopology/interface/CaloDirection.h"
0011 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0012 #include "FastSimulation/CaloGeometryTools/interface/CaloDirectionOperations.h"
0013 #include "DataFormats/DetId/interface/DetId.h"
0014 
0015 #include <vector>
0016 
0017 class DetId;
0018 
0019 class BaseCrystal {
0020 public:
0021   typedef math::XYZVector XYZVector;
0022   typedef math::XYZVector XYZPoint;
0023   typedef ROOT::Math::Plane3D Plane3D;
0024 
0025   // side numbering
0026   //  enum CrystalSide{EAST=0,NORTH=1,WEST=2,SOUTH=3,FRONT=4,BACK=5};
0027   /// Empty constructor
0028   BaseCrystal() { ; };
0029   /// constructor from DetId
0030   BaseCrystal(const DetId& cell);
0031 
0032   /// Copy constructor
0033   //    BaseCrystal (const BaseCrystal& bc):corners_(bc.getCorners()),cellid_(bc.getDetId())
0034   //    {
0035   //      std::cout << " Copy constructor " ;
0036   //      computeBasicProperties();
0037   //      std::cout << " done " << std::endl;
0038   //    }
0039   ~BaseCrystal() { ; }
0040   ///
0041   void setCorners(const CaloCellGeometry::CornersVec& vec, const GlobalPoint& pos);
0042 
0043   // inline const std::vector<XYZPoint>& getCorners() const {return corners_;}
0044 
0045   /// get the i-th corner
0046   inline const XYZPoint& getCorner(unsigned i) const { return corners_[i]; };
0047   /// get 1/8*(Sum of corners)
0048   inline const XYZPoint& getCenter() const { return center_; };
0049   /// get front center
0050   inline const XYZPoint& getFrontCenter() const { return frontcenter_; };
0051   /// get front center
0052   inline const XYZPoint& getBackCenter() const { return backcenter_; }
0053   /// Direction of the first edge
0054   inline const XYZVector& getFirstEdge() const { return firstedgedirection_; }
0055   /// Direction of the fifth edge
0056   inline const XYZVector& getFifthEdge() const { return fifthedgedirection_; }
0057   /// get the DetId
0058   inline const DetId& getDetId() const { return cellid_; };
0059   /// get the subdector
0060   inline const int getSubdetNumber() const { return subdetn_; }
0061 
0062   /// get the lateral edges
0063   void getLateralEdges(unsigned i, XYZPoint&, XYZPoint&) const;
0064   /// coordinates of the front side
0065   void getFrontSide(XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const;
0066   void getFrontSide(std::vector<XYZPoint>& corners) const;
0067   /// Coordinates of the back side
0068   void getBackSide(XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const;
0069   void getBackSide(std::vector<XYZPoint>& corners) const;
0070   /// Coordinates of the i=th lateral side
0071   void getLateralSide(unsigned i, XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const;
0072   void getLateralSide(unsigned i, std::vector<XYZPoint>& corners) const;
0073   /// generic access
0074   void getSide(const CaloDirection& side, XYZPoint& a, XYZPoint& b, XYZPoint& c, XYZPoint& d) const;
0075   void getSide(const CaloDirection& side, std::vector<XYZPoint>& corners) const;
0076 
0077   /// front plane
0078   inline const Plane3D& getFrontPlane() const { return lateralPlane_[4]; }
0079   /// back plane
0080   inline const Plane3D& getBackPlane() const { return lateralPlane_[5]; }
0081   /// lateral planes
0082   inline const Plane3D& getLateralPlane(unsigned i) const { return lateralPlane_[i]; };
0083   /// generic access
0084   const Plane3D& getPlane(const CaloDirection& side) const {
0085     return lateralPlane_[CaloDirectionOperations::Side(side)];
0086   }
0087 
0088   /// lateral directions
0089   inline const XYZVector& getLateralEdge(unsigned i) const { return lateraldirection_[i]; };
0090 
0091   /// normal exiting vector for the surface
0092   inline const XYZVector& exitingNormal(const CaloDirection& side) const {
0093     return exitingNormal_[CaloDirectionOperations::Side(side)];
0094   };
0095 
0096   static unsigned oppositeDirection(unsigned iside);
0097 
0098   /// for debugging.
0099   void getDrawingCoordinates(std::vector<float>& x, std::vector<float>& y, std::vector<float>& z) const;
0100 
0101   /// get crystal axis
0102   inline const XYZVector& getAxis() const { return crystalaxis_; }
0103 
0104   void print() const;
0105 
0106 private:
0107   void computeBasicProperties();
0108 
0109 private:
0110   XYZPoint corners_[8];
0111   DetId cellid_;
0112   int subdetn_;
0113   XYZPoint center_;
0114   XYZPoint frontcenter_;
0115   XYZPoint backcenter_;
0116   XYZVector firstedgedirection_;
0117   XYZVector fifthedgedirection_;
0118   XYZVector crystalaxis_;
0119   XYZVector lateraldirection_[4];
0120   Plane3D lateralPlane_[6];
0121   XYZVector exitingNormal_[6];
0122 };
0123 #endif