Skip to content

Commit 4ecd7fc

Browse files
authored
Merge pull request cms-sw#43266 from bsunanda/Run3-hcx357
Run3-hcx357 Allow RPD reconstruction geometry to be instantiation using a Modifier flag
2 parents 18bde74 + efd54e8 commit 4ecd7fc

File tree

12 files changed

+174
-61
lines changed

12 files changed

+174
-61
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: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class HcalElectronicsId {
4242
/** VME Constructor from slb channel,slb site,spigot,dccid */
4343
constexpr HcalElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb)
4444
: hcalElectronicsId_(
45-
(uint32_t)((slbChan & 0x3) | (((slbSite)&0x7) << 2) | ((spigot & 0xF) << 5) | ((dccid & 0x1F) << 9))) {
45+
(uint32_t)((slbChan & 0x3) | (((slbSite) & 0x7) << 2) | ((spigot & 0xF) << 5) | ((dccid & 0x1F) << 9))) {
4646
hcalElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
4747
hcalElectronicsId_ |= 0x02000000;
4848
}
4949
/** uTCA constructor */
5050
constexpr HcalElectronicsId(int crate, int slot, int fiber, int fc, bool isTrigger)
51-
: hcalElectronicsId_((int)((fc & 0xF) | (((fiber)&0x1F) << 4) | ((slot & 0xF) << 9) | ((crate & 0x3F) << 13))) {
51+
: hcalElectronicsId_((int)((fc & 0xF) | (((fiber) & 0x1F) << 4) | ((slot & 0xF) << 9) | ((crate & 0x3F) << 13))) {
5252
if (isTrigger)
5353
hcalElectronicsId_ |= 0x02000000;
5454
hcalElectronicsId_ |= 0x04000000;
@@ -71,45 +71,51 @@ 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 {
75+
return (isUTCAid()) ? static_cast<int32_t>((hcalElectronicsId_ >> 21) & 0x1F) : (-1);
76+
}
7577
/// get the fiber channel id (which of channels on a fiber)
76-
constexpr int fiberChanId() const { return (isVMEid()) ? (hcalElectronicsId_ & 0x3) : (hcalElectronicsId_ & 0xF); }
78+
constexpr int32_t fiberChanId() const {
79+
return (isVMEid()) ? static_cast<int32_t>(hcalElectronicsId_ & 0x3) : (hcalElectronicsId_ & 0xF);
80+
}
7781
/// 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 {
82+
constexpr int32_t fiberIndex() const {
7983
return (isVMEid()) ? (((hcalElectronicsId_ >> 2) & 0x7) + 1) : ((hcalElectronicsId_ >> 4) & 0x1F);
8084
}
8185
/// get the SLB channel index (valid only for VME trigger-chain ids)
82-
constexpr int slbChannelIndex() const { return hcalElectronicsId_ & 0x3; }
86+
constexpr int32_t slbChannelIndex() const { return hcalElectronicsId_ & 0x3; }
8387
/// get the SLB site number (valid only for VME trigger-chain ids)
84-
constexpr int slbSiteNumber() const { return ((hcalElectronicsId_ >> 2) & 0x7); }
88+
constexpr int32_t slbSiteNumber() const { return ((hcalElectronicsId_ >> 2) & 0x7); }
8589

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

8993
/// get the HTR-wide slb channel code (letter plus number)
9094
std::string slbChannelCode() const;
9195

9296
/// get the spigot (input number on DCC, AMC card number for uTCA)
93-
constexpr int spigot() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 5) & 0xF) : slot(); }
97+
constexpr int32_t spigot() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 5) & 0xF) : slot(); }
9498
/// get the (Hcal local) DCC id for VME, crate number for uTCA
95-
constexpr int dccid() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 9) & 0x1F) : crateId(); }
99+
constexpr int32_t dccid() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 9) & 0x1F) : crateId(); }
96100
/// get the htr slot
97-
constexpr int htrSlot() const { return slot(); }
101+
constexpr int32_t htrSlot() const { return slot(); }
98102
/// get the htr or uHTR slot
99-
constexpr int slot() const {
103+
constexpr int32_t slot() const {
100104
return (isVMEid()) ? ((hcalElectronicsId_ >> 14) & 0x1F) : ((hcalElectronicsId_ >> 9) & 0xF);
101105
}
102106
/// get the htr top/bottom (1=top/0=bottom), valid for VME
103-
constexpr int htrTopBottom() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 19) & 0x1) : (-1); }
107+
constexpr int32_t htrTopBottom() const {
108+
return (isVMEid()) ? static_cast<int32_t>((hcalElectronicsId_ >> 19) & 0x1) : (-1);
109+
}
104110
/// get the readout VME crate number
105-
constexpr int readoutVMECrateId() const { return crateId(); }
111+
constexpr int32_t readoutVMECrateId() const { return crateId(); }
106112
/// get the readout VME crate number
107-
constexpr int crateId() const {
113+
constexpr int32_t crateId() const {
108114
return (isVMEid()) ? ((hcalElectronicsId_ >> 20) & 0x1F) : ((hcalElectronicsId_ >> 13) & 0x3F);
109115
}
110116
/// get a fast, compact, unique index for linear lookups
111-
constexpr int linearIndex() const {
112-
return (isVMEid()) ? ((hcalElectronicsId_)&0x3FFF) : ((hcalElectronicsId_)&0x7FFFF);
117+
constexpr int32_t linearIndex() const {
118+
return (isVMEid()) ? ((hcalElectronicsId_) & 0x3FFF) : ((hcalElectronicsId_) & 0x7FFFF);
113119
}
114120

115121
static const int maxLinearIndex = 0x7FFFF; //

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: 5 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,10 @@ class CaloSubdetectorGeometry {
99100

100101
virtual void initializeParms() { return; }
101102

103+
virtual bool valid(const DetId& id) const {
104+
return (std::find(m_validIds.begin(), m_validIds.end(), id) != m_validIds.end());
105+
}
106+
102107
protected:
103108
virtual unsigned int indexFor(const DetId& id) const;
104109
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: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
#include "FWCore/MessageLogger/interface/MessageLogger.h"
2121

2222
ZdcHardcodeGeometryEP::ZdcHardcodeGeometryEP(const edm::ParameterSet& ps)
23-
: m_loader(nullptr), m_topology(), m_applyAlignment(ps.getUntrackedParameter<bool>("applyAlignment", false)) {
23+
: m_loader(nullptr),
24+
m_topology(),
25+
m_applyAlignment(ps.getParameter<bool>("applyAlignment")),
26+
m_zdcAddRPD(ps.getParameter<bool>("zdcAddRPD")) {
2427
//the following line is needed to tell the framework what
2528
// data is being produced
2629
setWhatProduced(this, ZdcGeometry::producerTag());
@@ -31,7 +34,7 @@ ZdcHardcodeGeometryEP::ZdcHardcodeGeometryEP(const edm::ParameterSet& ps)
3134
// edm::es::Label( "ZDC" ) );
3235
}
3336

34-
ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() { delete m_loader; }
37+
ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() {}
3538

3639
//
3740
// member functions
@@ -41,7 +44,14 @@ ZdcHardcodeGeometryEP::~ZdcHardcodeGeometryEP() { delete m_loader; }
4144

4245
ZdcHardcodeGeometryEP::ReturnType ZdcHardcodeGeometryEP::produce(const ZDCGeometryRecord& iRecord) {
4346
// ZdcHardcodeGeometryLoader loader ( m_topology ) ;
44-
m_loader = new ZdcHardcodeGeometryLoader(m_topology);
45-
47+
m_loader = std::make_unique<ZdcHardcodeGeometryLoader>(m_topology);
48+
m_loader->setAddRPD(m_zdcAddRPD);
4649
return ReturnType(m_loader->load());
4750
}
51+
52+
void ZdcHardcodeGeometryEP::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
53+
edm::ParameterSetDescription desc;
54+
desc.add<bool>("applyAlignment", false);
55+
desc.add<bool>("zdcAddRPD", false);
56+
descriptions.addWithDefaultLabel(desc);
57+
}

Geometry/ForwardGeometry/plugins/ZdcHardcodeGeometryEP.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ class ZdcHardcodeGeometryEP : public edm::ESProducer {
2424

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: 83 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,10 @@ 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()
80+
<< std::dec << " ZDC? " << cgid.isZDC();
81+
#endif
6982
assert(cgid.isZDC());
7083

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

0 commit comments

Comments
 (0)