Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:17

0001 #ifndef FastSimulation_CaloGeometryTools_CaloPoint_h
0002 #define FastSimulation_CaloGeometryTools_CaloPoint_h
0003 /*
0004  *
0005  * A point belonging to a given detector
0006  * 
0007  */
0008 
0009 #include "Geometry/CaloTopology/interface/CaloDirection.h"
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "DataFormats/Math/interface/Vector3D.h"
0012 
0013 #include <string>
0014 
0015 //ideally this class should inherit from XYZPoint & CellID
0016 
0017 class CaloPoint : public math::XYZVector {
0018 public:
0019   typedef math::XYZVector XYZVector;
0020   typedef math::XYZVector XYZPoint;
0021 
0022   /// Empty constructor
0023   CaloPoint() : XYZPoint(), side_{NONE} {}
0024   //  /// Constructor from DetId, side and position.
0025   //  CaloPoint(DetId cell, CaloDirection side, const XYZPoint& position);
0026   //
0027   //  /// Constructor side and position
0028   //  CaloPoint( CaloDirection side, const XYZPoint& position):XYZPoint(position),side_(side){;};
0029 
0030   /// constructor for ECAL
0031   CaloPoint(const DetId& cell, CaloDirection side, const XYZPoint& position);
0032 
0033   /// constructor for HCAL
0034   CaloPoint(DetId::Detector detector, const XYZPoint& position);
0035 
0036   /// constructor for preshower
0037   CaloPoint(DetId::Detector detector, int subdetn, int layer, const XYZPoint& position);
0038 
0039   ~CaloPoint() { ; }
0040   /// returns the cellID
0041   inline DetId getDetId() const { return cellid_; };
0042   /// returns the Side (see numbering)
0043   inline CaloDirection getSide() const { return side_; };
0044 
0045   inline bool operator<(const CaloPoint& p) const { return this->mag2() < p.mag2(); };
0046 
0047   inline void setDetId(DetId::Detector det) { detector_ = det; }
0048   inline DetId::Detector whichDetector() const { return detector_; };
0049 
0050   inline void setSubDetector(int i) { subdetector_ = i; }
0051 
0052   ///  watch out, only valid in ECAL and preshower
0053   inline int whichSubDetector() const { return subdetector_; };
0054 
0055   inline void setLayer(int i) { layer_ = i; }
0056 
0057   inline int whichLayer() const { return layer_; }
0058 
0059   //  const CaloGeometryHelper * getCalorimeter() const { return myCalorimeter_;}
0060 
0061 private:
0062   //  const CaloGeometryHelper * myCalorimeter_;
0063   DetId cellid_;
0064   CaloDirection side_;
0065   DetId::Detector detector_;
0066   int subdetector_;
0067   int layer_;
0068 
0069 public:
0070   class DistanceToVertex {
0071   public:
0072     DistanceToVertex(const XYZPoint& vert) : vertex(vert) {}
0073     ~DistanceToVertex() {}
0074     bool operator()(const CaloPoint& point1, const CaloPoint& point2) {
0075       return ((point1 - vertex).mag2() < (point2 - vertex).mag2());
0076     }
0077 
0078   private:
0079     XYZPoint vertex;
0080   };
0081 };
0082 #include <iosfwd>
0083 std::ostream& operator<<(std::ostream& o, const CaloPoint& cid);
0084 
0085 #endif