1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#ifndef HTrackAssociator_HCaloDetIdAssociator_h
#define HTrackAssociator_HCaloDetIdAssociator_h 1
// -*- C++ -*-
//
// Package: HTrackAssociator
// Class: HCaloDetIdAssociator
//
/*
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Dmytro Kovalskyi
// Modified for ECAL+HCAL by Michal Szleper
//
#include "Calibration/Tools/interface/DetIdAssociator.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
class HCaloDetIdAssociator : public HDetIdAssociator {
public:
HCaloDetIdAssociator() : HDetIdAssociator(72, 70, 0.087), geometry_(nullptr){};
HCaloDetIdAssociator(const int nPhi, const int nEta, const double etaBinSize)
: HDetIdAssociator(nPhi, nEta, etaBinSize), geometry_(nullptr){};
virtual void setGeometry(const CaloGeometry* ptr) { geometry_ = ptr; };
protected:
void check_setup() override {
HDetIdAssociator::check_setup();
if (geometry_ == nullptr)
throw cms::Exception("CaloGeometry is not set");
};
GlobalPoint getPosition(const DetId& id) override {
GlobalPoint point = (id.det() == DetId::Hcal)
? (static_cast<const HcalGeometry*>(geometry_->getSubdetectorGeometry(id)))->getPosition(id)
: geometry_->getPosition(id);
return point;
};
std::set<DetId> getASetOfValidDetIds() override {
std::set<DetId> setOfValidIds;
const std::vector<DetId>& vectOfValidIds = geometry_->getValidDetIds(DetId::Calo, 1);
for (std::vector<DetId>::const_iterator it = vectOfValidIds.begin(); it != vectOfValidIds.end(); ++it)
setOfValidIds.insert(*it);
return setOfValidIds;
};
std::vector<GlobalPoint> getDetIdPoints(const DetId& id) override {
std::vector<GlobalPoint> points;
if (!geometry_->getSubdetectorGeometry(id)) {
LogDebug("CaloDetIdAssociator") << "Cannot find sub-detector geometry for " << id.rawId() << "\n";
} else {
if (!(geometry_->getSubdetectorGeometry(id))->getGeometry(id)) {
LogDebug("CaloDetIdAssociator") << "Cannot find CaloCell geometry for " << id.rawId() << "\n";
} else {
const CaloCellGeometry::CornersVec& cor(geometry_->getSubdetectorGeometry(id)->getGeometry(id)->getCorners());
points.assign(cor.begin(), cor.end());
points.push_back(getPosition(id));
}
}
return points;
};
bool insideElement(const GlobalPoint& point, const DetId& id) override {
return geometry_->getSubdetectorGeometry(id)->getGeometry(id)->inside(point);
};
const CaloGeometry* geometry_;
};
#endif
|