CMS 3D CMS Logo

CaloDetIdAssociator.h
Go to the documentation of this file.
1 #ifndef HTrackAssociator_HCaloDetIdAssociator_h
2 #define HTrackAssociator_HCaloDetIdAssociator_h 1
3 // -*- C++ -*-
4 //
5 // Package: HTrackAssociator
6 // Class: HCaloDetIdAssociator
7 //
8 /*
9 
10  Description: <one line class summary>
11 
12  Implementation:
13  <Notes on implementation>
14 */
15 //
16 // Original Author: Dmytro Kovalskyi
17 // Modified for ECAL+HCAL by Michal Szleper
18 //
19 
25 
27  public:
29  HCaloDetIdAssociator(const int nPhi, const int nEta, const double etaBinSize)
30  :HDetIdAssociator(nPhi, nEta, etaBinSize),geometry_(nullptr){};
31 
32  virtual void setGeometry(const CaloGeometry* ptr){ geometry_ = ptr; };
33 
34  protected:
35  void check_setup() override
36  {
38  if (geometry_==nullptr) throw cms::Exception("CaloGeometry is not set");
39  };
40 
41  GlobalPoint getPosition(const DetId& id) override{
42  GlobalPoint point = (id.det() == DetId::Hcal) ?
43  (static_cast<const HcalGeometry*>(geometry_->getSubdetectorGeometry(id)))->getPosition(id) : geometry_->getPosition(id);
44  return point;
45  };
46 
47  std::set<DetId> getASetOfValidDetIds() override{
48  std::set<DetId> setOfValidIds;
49  const std::vector<DetId>& vectOfValidIds = geometry_->getValidDetIds(DetId::Calo, 1);
50  for(std::vector<DetId>::const_iterator it = vectOfValidIds.begin(); it != vectOfValidIds.end(); ++it)
51  setOfValidIds.insert(*it);
52 
53  return setOfValidIds;
54  };
55 
56  std::vector<GlobalPoint> getDetIdPoints(const DetId& id) override{
57  std::vector<GlobalPoint> points;
59  LogDebug("CaloDetIdAssociator") << "Cannot find sub-detector geometry for " << id.rawId() <<"\n";
60  } else {
62  LogDebug("CaloDetIdAssociator") << "Cannot find CaloCell geometry for " << id.rawId() <<"\n";
63  } else {
64  const CaloCellGeometry::CornersVec& cor ( geometry_->getSubdetectorGeometry(id)->getGeometry(id)->getCorners() );
65  points.assign( cor.begin(), cor.end() ) ;
66  points.push_back(getPosition(id));
67  }
68  }
69 
70  return points;
71  };
72 
73  bool insideElement(const GlobalPoint& point, const DetId& id) override{
74  return geometry_->getSubdetectorGeometry(id)->getGeometry(id)->inside(point);
75  };
76 
77  const CaloGeometry* geometry_;
78 };
79 #endif
#define LogDebug(id)
virtual void check_setup()
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
const CaloGeometry * geometry_
bool insideElement(const GlobalPoint &point, const DetId &id) override
std::vector< GlobalPoint > getDetIdPoints(const DetId &id) override
#define nullptr
GlobalPoint getPosition(const DetId &id) override
CaloGeometry const * getGeometry()
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
Definition: DetId.h:18
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::set< DetId > getASetOfValidDetIds() override
void assign(const T &t=T())
Definition: EZArrayFL.h:57
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
virtual void setGeometry(const CaloGeometry *ptr)
void check_setup() override
HCaloDetIdAssociator(const int nPhi, const int nEta, const double etaBinSize)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5