Skip to content

Commit a4037e6

Browse files
author
Sunanda
committed
Allow RPD reconstruction geometry to be instantiation using a Modifier flag
1 parent d0c9676 commit a4037e6

File tree

12 files changed

+157
-62
lines changed

12 files changed

+157
-62
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
zdcAddRPD = cms.Modifier()

DataFormats/HcalDetId/interface/HcalElectronicsId.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,44 @@ class HcalElectronicsId {
7171
}
7272

7373
/// get subtype for this channel (valid for uTCA only)
74-
constexpr int subtype() const { return (isUTCAid()) ? ((hcalElectronicsId_ >> 21) & 0x1F) : (-1); }
74+
constexpr int32_t subtype() const { return (isUTCAid()) ? static_cast<int32_t>((hcalElectronicsId_ >> 21) & 0x1F) : (-1); }
7575
/// get the fiber channel id (which of channels on a fiber)
76-
constexpr int fiberChanId() const { return (isVMEid()) ? (hcalElectronicsId_ & 0x3) : (hcalElectronicsId_ & 0xF); }
76+
constexpr int32_t fiberChanId() const { return (isVMEid()) ? static_cast<int32_t>(hcalElectronicsId_ & 0x3) : (hcalElectronicsId_ & 0xF); }
7777
/// get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zero-based
78-
constexpr int fiberIndex() const {
78+
constexpr int32_t fiberIndex() const {
7979
return (isVMEid()) ? (((hcalElectronicsId_ >> 2) & 0x7) + 1) : ((hcalElectronicsId_ >> 4) & 0x1F);
8080
}
8181
/// get the SLB channel index (valid only for VME trigger-chain ids)
82-
constexpr int slbChannelIndex() const { return hcalElectronicsId_ & 0x3; }
82+
constexpr int32_t slbChannelIndex() const { return hcalElectronicsId_ & 0x3; }
8383
/// get the SLB site number (valid only for VME trigger-chain ids)
84-
constexpr int slbSiteNumber() const { return ((hcalElectronicsId_ >> 2) & 0x7); }
84+
constexpr int32_t slbSiteNumber() const { return ((hcalElectronicsId_ >> 2) & 0x7); }
8585

8686
/// get the HTR channel id (1-24)
87-
constexpr int htrChanId() const { return isVMEid() ? ((fiberChanId() + 1) + ((fiberIndex() - 1) * 3)) : (0); }
87+
constexpr int32_t htrChanId() const { return isVMEid() ? ((fiberChanId() + 1) + ((fiberIndex() - 1) * 3)) : (0); }
8888

8989
/// get the HTR-wide slb channel code (letter plus number)
9090
std::string slbChannelCode() const;
9191

9292
/// get the spigot (input number on DCC, AMC card number for uTCA)
93-
constexpr int spigot() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 5) & 0xF) : slot(); }
93+
constexpr int32_t spigot() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 5) & 0xF) : slot(); }
9494
/// get the (Hcal local) DCC id for VME, crate number for uTCA
95-
constexpr int dccid() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 9) & 0x1F) : crateId(); }
95+
constexpr int32_t dccid() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 9) & 0x1F) : crateId(); }
9696
/// get the htr slot
97-
constexpr int htrSlot() const { return slot(); }
97+
constexpr int32_t htrSlot() const { return slot(); }
9898
/// get the htr or uHTR slot
99-
constexpr int slot() const {
99+
constexpr int32_t slot() const {
100100
return (isVMEid()) ? ((hcalElectronicsId_ >> 14) & 0x1F) : ((hcalElectronicsId_ >> 9) & 0xF);
101101
}
102102
/// get the htr top/bottom (1=top/0=bottom), valid for VME
103-
constexpr int htrTopBottom() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 19) & 0x1) : (-1); }
103+
constexpr int32_t htrTopBottom() const { return (isVMEid()) ? static_cast<int32_t>((hcalElectronicsId_ >> 19) & 0x1) : (-1); }
104104
/// get the readout VME crate number
105-
constexpr int readoutVMECrateId() const { return crateId(); }
105+
constexpr int32_t readoutVMECrateId() const { return crateId(); }
106106
/// get the readout VME crate number
107-
constexpr int crateId() const {
107+
constexpr int32_t crateId() const {
108108
return (isVMEid()) ? ((hcalElectronicsId_ >> 20) & 0x1F) : ((hcalElectronicsId_ >> 13) & 0x3F);
109109
}
110110
/// get a fast, compact, unique index for linear lookups
111-
constexpr int linearIndex() const {
111+
constexpr int32_t linearIndex() const {
112112
return (isVMEid()) ? ((hcalElectronicsId_)&0x3FFF) : ((hcalElectronicsId_)&0x7FFFF);
113113
}
114114

DataFormats/HcalDetId/interface/HcalZDCDetId.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ class HcalZDCDetId : public DetId {
3434

3535
static constexpr int32_t SubdetectorId = 2;
3636

37+
static constexpr int32_t kDepEM = 5;
38+
static constexpr int32_t kDepHAD = 4;
39+
static constexpr int32_t kDepLUM = 2;
40+
static constexpr int32_t kDepRPD = 16;
41+
static constexpr int32_t kDepRun1 = (kDepEM + kDepHAD + kDepLUM);
42+
static constexpr int32_t kDepTot = (kDepRun1 + kDepRPD);
43+
static constexpr int32_t kDepRun3 = kDepTot;
44+
3745
/** Create a null cellid*/
3846
constexpr HcalZDCDetId() : DetId() {}
3947
/** Create cellid from raw id (0=invalid tower id) */
@@ -162,16 +170,6 @@ class HcalZDCDetId : public DetId {
162170
}
163171

164172
private:
165-
enum {
166-
kDepEM = 5,
167-
kDepHAD = 4,
168-
kDepLUM = 2,
169-
kDepRPD = 16,
170-
kDepRun1 = kDepEM + kDepHAD + kDepLUM,
171-
kDepTot = kDepRun1 + kDepRPD,
172-
kDepRun3 = kDepTot
173-
};
174-
175173
constexpr static uint32_t packHcalZDCDetId(const Section& se, const bool& zside, const int32_t& channel) {
176174
uint32_t id = DetId(DetId::Calo, SubdetectorId);
177175
id |= kZDCnewFormat;

Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H
22
#define GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H 1
33

4+
#include <algorithm>
45
#include <memory>
56
#include <vector>
67
#include <set>
@@ -99,6 +100,8 @@ class CaloSubdetectorGeometry {
99100

100101
virtual void initializeParms() { return; }
101102

103+
virtual bool valid(const DetId& id) const { return (std::find(m_validIds.begin(), m_validIds.end(), id) != m_validIds.end()); }
104+
102105
protected:
103106
virtual unsigned int indexFor(const DetId& id) const;
104107
virtual unsigned int sizeForDenseIndex(const DetId& id) const;

Geometry/ForwardGeometry/interface/ZdcGeometry.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class ZdcGeometry : public CaloSubdetectorGeometry {
5757
const CCGFloat* parm,
5858
const DetId& detId) override;
5959

60+
void getSummary(CaloSubdetectorGeometry::TrVec& tVec,
61+
CaloSubdetectorGeometry::IVec& iVec,
62+
CaloSubdetectorGeometry::DimVec& dVec,
63+
CaloSubdetectorGeometry::IVec& dins) const override;
64+
6065
protected:
6166
unsigned int indexFor(const DetId& id) const override { return HcalZDCDetId(id).denseIndex(); }
6267

Geometry/ForwardGeometry/interface/ZdcHardcodeGeometryLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ZdcHardcodeGeometryLoader {
2323

2424
virtual ReturnType load(DetId::Detector det, int subdet);
2525
ReturnType load();
26+
void setAddRPD(bool flag) { m_zdcAddRPD = flag; }
2627

2728
private:
2829
void init();
@@ -31,7 +32,7 @@ class ZdcHardcodeGeometryLoader {
3132

3233
ZdcTopology* theTopology;
3334
const ZdcTopology* extTopology;
34-
35+
bool m_zdcAddRPD;
3536
float theEMSectiondX;
3637
float theEMSectiondY;
3738
float theEMSectiondZ;

Geometry/ForwardGeometry/plugins/ZdcHardcodeGeometryEP.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
2020
#include "FWCore/MessageLogger/interface/MessageLogger.h"
2121

22-
ZdcHardcodeGeometryEP::ZdcHardcodeGeometryEP(const edm::ParameterSet& ps)
23-
: m_loader(nullptr), m_topology(), m_applyAlignment(ps.getUntrackedParameter<bool>("applyAlignment", false)) {
22+
ZdcHardcodeGeometryEP::ZdcHardcodeGeometryEP(const edm::ParameterSet& ps) : m_loader(nullptr), m_topology(), m_applyAlignment(ps.getParameter<bool>("applyAlignment")), m_zdcAddRPD(ps.getParameter<bool>("zdcAddRPD")) {
2423
//the following line is needed to tell the framework what
2524
// data is being produced
2625
setWhatProduced(this, ZdcGeometry::producerTag());
@@ -31,7 +30,7 @@ ZdcHardcodeGeometryEP::ZdcHardcodeGeometryEP(const edm::ParameterSet& ps)
3130
// edm::es::Label( "ZDC" ) );
3231
}
3332

34-
ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() { delete m_loader; }
33+
ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() { }
3534

3635
//
3736
// member functions
@@ -41,7 +40,14 @@ ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() { delete m_loader; }
4140

4241
ZdcHardcodeGeometryEP::ReturnType ZdcHardcodeGeometryEP::produce(const ZDCGeometryRecord& iRecord) {
4342
// ZdcHardcodeGeometryLoader loader ( m_topology ) ;
44-
m_loader = new ZdcHardcodeGeometryLoader(m_topology);
45-
43+
m_loader = std::make_unique<ZdcHardcodeGeometryLoader>(m_topology);
44+
m_loader->setAddRPD(m_zdcAddRPD);
4645
return ReturnType(m_loader->load());
4746
}
47+
48+
void ZdcHardcodeGeometryEP::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
49+
edm::ParameterSetDescription desc;
50+
desc.add<bool>("applyAlignment", false);
51+
desc.add<bool>("zdcAddRPD", false);
52+
descriptions.addWithDefaultLabel(desc);
53+
}

Geometry/ForwardGeometry/plugins/ZdcHardcodeGeometryEP.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ class ZdcHardcodeGeometryEP : public edm::ESProducer {
2121
~ZdcHardcodeGeometryEP() override;
2222

2323
using ReturnType = std::unique_ptr<CaloSubdetectorGeometry>;
24-
24+
2525
ReturnType produce(const ZDCGeometryRecord&);
2626

27+
static void fillDescriptions(edm::ConfigurationDescriptions&);
28+
2729
private:
2830
// ----------member data ---------------------------
2931

30-
ZdcHardcodeGeometryLoader* m_loader;
32+
std::unique_ptr<ZdcHardcodeGeometryLoader> m_loader;
3133

3234
ZdcTopology m_topology;
3335

3436
bool m_applyAlignment;
37+
bool m_zdcAddRPD;
3538
};
3639

3740
#endif
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
import FWCore.ParameterSet.Config as cms
1+
from Geometry.ForwardGeometry.zdcHardcodeGeometryEP_cfi import zdcHardcodeGeometryEP
2+
from Configuration.Eras.Modifier_zdcAddRPD_cff import zdcAddRPD
23

3-
ZdcHardcodeGeometryEP = cms.ESProducer( "ZdcHardcodeGeometryEP" )
4+
zdcAddRPD.toModify(zdcHardcodeGeometryEP, zdcAddRPD = True)

Geometry/ForwardGeometry/src/ZdcGeometry.cc

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@
66
#include "Geometry/ForwardGeometry/interface/ZdcHardcodeGeometryData.h"
77
#include <algorithm>
88

9-
typedef CaloCellGeometry::CCGFloat CCGFloat;
9+
#include <Math/Transform3D.h>
10+
#include <Math/EulerAngles.h>
11+
12+
#include <algorithm>
13+
1014
typedef CaloCellGeometry::Pt3D Pt3D;
1115
typedef CaloCellGeometry::Pt3DVec Pt3DVec;
16+
typedef CaloCellGeometry::Tr3D Tr3D;
17+
18+
typedef CaloSubdetectorGeometry::CCGFloat CCGFloat;
19+
20+
//#define EDM_ML_DEBUG
1221

1322
ZdcGeometry::ZdcGeometry()
1423
: theTopology(new ZdcTopology),
@@ -66,6 +75,9 @@ void ZdcGeometry::newCell(const GlobalPoint& f1,
6675
const CCGFloat* parm,
6776
const DetId& detId) {
6877
const CaloGenericDetId cgid(detId);
78+
#ifdef EDM_ML_DEBUG
79+
edm::LogVerbatim("ZDCGeom") << "ZDCGeometry " << HcalZDCDetId(detId) << " Generic ID " << std::hex << cgid.rawId() << std::dec << " ZDC? " << cgid.isZDC();
80+
#endif
6981
assert(cgid.isZDC());
7082

7183
const unsigned int di(cgid.denseIndex());
@@ -81,3 +93,70 @@ const CaloCellGeometry* ZdcGeometry::getGeometryRawPtr(uint32_t index) const {
8193
const CaloCellGeometry* cell(&m_cellVec[index]);
8294
return (((cell == nullptr) || (nullptr == cell->param())) ? nullptr : cell);
8395
}
96+
97+
void ZdcGeometry::getSummary(CaloSubdetectorGeometry::TrVec& tVec,
98+
CaloSubdetectorGeometry::IVec& iVec,
99+
CaloSubdetectorGeometry::DimVec& dVec,
100+
CaloSubdetectorGeometry::IVec& /*dins*/) const {
101+
tVec.reserve(m_validIds.size() * numberOfTransformParms());
102+
iVec.reserve(numberOfShapes() == 1 ? 1 : m_validIds.size());
103+
dVec.reserve(numberOfShapes() * numberOfParametersPerShape());
104+
105+
for (const auto& pv : parVecVec()) {
106+
for (float iv : pv) {
107+
dVec.emplace_back(iv);
108+
}
109+
}
110+
111+
for (uint32_t i(0); i != m_validIds.size(); ++i) {
112+
Tr3D tr;
113+
std::shared_ptr<const CaloCellGeometry> ptr(cellGeomPtr(i));
114+
#ifdef EDM_ML_DEBUG
115+
edm::LogVerbatim("ZDCGeom") << "ZDCGeometry:Summary " << i << ":" << HcalZDCDetId::kSizeForDenseIndexingRun1 << " Pointer " << ptr << ":" << (nullptr != ptr);
116+
#endif
117+
if (i < static_cast<int32_t>(HcalZDCDetId::kSizeForDenseIndexingRun1))
118+
assert(nullptr != ptr);
119+
if (ptr != nullptr) {
120+
ptr->getTransform(tr, (Pt3DVec*)nullptr);
121+
122+
if (Tr3D() == tr) { // for preshower there is no rotation
123+
const GlobalPoint& gp(ptr->getPosition());
124+
tr = HepGeom::Translate3D(gp.x(), gp.y(), gp.z());
125+
}
126+
127+
const CLHEP::Hep3Vector tt(tr.getTranslation());
128+
tVec.emplace_back(tt.x());
129+
tVec.emplace_back(tt.y());
130+
tVec.emplace_back(tt.z());
131+
if (6 == numberOfTransformParms()) {
132+
const CLHEP::HepRotation rr(tr.getRotation());
133+
const ROOT::Math::Transform3D rtr(rr.xx(), rr.xy(), rr.xz(), tt.x(), rr.yx(), rr.yy(), rr.yz(), tt.y(), rr.zx(), rr.zy(), rr.zz(), tt.z());
134+
ROOT::Math::EulerAngles ea;
135+
rtr.GetRotation(ea);
136+
tVec.emplace_back(ea.Phi());
137+
tVec.emplace_back(ea.Theta());
138+
tVec.emplace_back(ea.Psi());
139+
}
140+
141+
const CCGFloat* par(ptr->param());
142+
143+
unsigned int ishape(9999);
144+
for (unsigned int ivv(0); ivv != parVecVec().size(); ++ivv) {
145+
bool ok(true);
146+
const CCGFloat* pv(&(*parVecVec()[ivv].begin()));
147+
for (unsigned int k(0); k != numberOfParametersPerShape(); ++k) {
148+
ok = ok && (fabs(par[k] - pv[k]) < 1.e-6);
149+
}
150+
if (ok) {
151+
ishape = ivv;
152+
break;
153+
}
154+
}
155+
assert(9999 != ishape);
156+
157+
const unsigned int nn((numberOfShapes() == 1) ? (unsigned int)1 : m_validIds.size());
158+
if (iVec.size() < nn)
159+
iVec.emplace_back(ishape);
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)