Skip to content

Commit 628c74d

Browse files
authored
Merge pull request cms-sw#33851 from wpcarvalho/pps_db_reco_geom
Change PPS geometry ES producer to read preprocessed geometry from DB
2 parents 025e9cc + 4f8c283 commit 628c74d

File tree

7 files changed

+222
-42
lines changed

7 files changed

+222
-42
lines changed

Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
1313
#include "Geometry/Records/interface/IdealGeometryRecord.h"
14+
#include "Geometry/Records/interface/VeryForwardIdealGeometryRecord.h"
1415

1516
#include "FWCore/Utilities/interface/mplVector.h"
1617

@@ -24,6 +25,7 @@
2425
class VeryForwardMisalignedGeometryRecord
2526
: public edm::eventsetup::DependentRecordImplementation<
2627
VeryForwardMisalignedGeometryRecord,
27-
edm::mpl::Vector<IdealGeometryRecord, RPMisalignedAlignmentRecord /*, ... */> > {};
28+
edm::mpl::Vector<VeryForwardIdealGeometryRecord, IdealGeometryRecord, RPMisalignedAlignmentRecord /*, ... */> > {
29+
};
2830

2931
#endif

Geometry/Records/interface/VeryForwardRealGeometryRecord.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
1313
#include "Geometry/Records/interface/IdealGeometryRecord.h"
14+
#include "Geometry/Records/interface/VeryForwardIdealGeometryRecord.h"
1415

1516
#include "FWCore/Utilities/interface/mplVector.h"
1617

@@ -20,8 +21,9 @@
2021
* \ingroup TotemRPGeometry
2122
* \brief Event setup record containing the real (actual) geometry information.
2223
**/
23-
class VeryForwardRealGeometryRecord : public edm::eventsetup::DependentRecordImplementation<
24-
VeryForwardRealGeometryRecord,
25-
edm::mpl::Vector<IdealGeometryRecord, RPRealAlignmentRecord /*, ... */> > {};
24+
class VeryForwardRealGeometryRecord
25+
: public edm::eventsetup::DependentRecordImplementation<
26+
VeryForwardRealGeometryRecord,
27+
edm::mpl::Vector<VeryForwardIdealGeometryRecord, IdealGeometryRecord, RPRealAlignmentRecord /*, ... */> > {};
2628

2729
#endif

Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "DetectorDescription/Core/interface/DDFilteredView.h"
1919
#include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
20+
#include "CondFormats/GeometryObjects/interface/PDetGeomDesc.h"
2021

2122
#include "DataFormats/DetId/interface/DetId.h"
2223
#include <Math/Rotation3D.h>
@@ -59,7 +60,10 @@ class DetGeomDesc {
5960
// Constructor from DD4Hep DDFilteredView
6061
/// \param[in] isRun2 Switch between legacy run 2-like geometry and 2021+ scenarii
6162
DetGeomDesc(const cms::DDFilteredView& fv, const bool isRun2);
62-
63+
// Constructor from DB object PDetGeomDesc
64+
DetGeomDesc(const PDetGeomDesc& gd);
65+
// Constructor from DB object PDetGeomDesc::Item
66+
DetGeomDesc(const PDetGeomDesc::Item& item);
6367
virtual ~DetGeomDesc();
6468

6569
enum CopyMode { cmWithChildren, cmWithoutChildren };

Geometry/VeryForwardGeometryBuilder/plugins/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<use name="CondFormats/AlignmentRecord"/>
22
<use name="CondFormats/PPSObjects"/>
3+
<use name="CondFormats/GeometryObjects"/>
34
<use name="DataFormats/CTPPSDetId"/>
45
<use name="DetectorDescription/Core"/>
56
<use name="DetectorDescription/DDCMS"/>

Geometry/VeryForwardGeometryBuilder/plugins/CTPPSGeometryESModule.cc

Lines changed: 106 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Rewritten + Moved out common functionailities to DetGeomDesc(Builder) by Gabrielle Hugo.
77
* Migrated to DD4hep by Wagner Carvalho and Gabrielle Hugo.
88
*
9+
* Add the capability of reading PPS reco geometry from the database
10+
*
911
****************************************************************************/
1012

1113
#include "FWCore/ParameterSet/interface/ParameterSet.h"
@@ -19,9 +21,11 @@
1921
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
2022
#include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
2123

24+
#include "CondFormats/GeometryObjects/interface/PDetGeomDesc.h"
2225
#include "CondFormats/AlignmentRecord/interface/RPRealAlignmentRecord.h"
2326
#include "CondFormats/AlignmentRecord/interface/RPMisalignedAlignmentRecord.h"
2427
#include "Geometry/Records/interface/IdealGeometryRecord.h"
28+
#include "Geometry/Records/interface/VeryForwardIdealGeometryRecord.h"
2529
#include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h"
2630
#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h"
2731

@@ -55,68 +59,96 @@ class CTPPSGeometryESModule : public edm::ESProducer {
5559

5660
private:
5761
std::unique_ptr<DetGeomDesc> produceIdealGD(const IdealGeometryRecord&);
62+
std::unique_ptr<DetGeomDesc> produceIdealGDFromPreprocessedDB(const VeryForwardIdealGeometryRecord&);
5863
std::vector<int> fillCopyNos(TGeoIterator& it);
5964

60-
template <typename ALIGNMENT_REC>
61-
struct GDTokens {
62-
explicit GDTokens(edm::ESConsumesCollector&& iCC)
63-
: idealGDToken_{iCC.consumesFrom<DetGeomDesc, IdealGeometryRecord>(edm::ESInputTag())},
64-
alignmentToken_{iCC.consumesFrom<CTPPSRPAlignmentCorrectionsData, ALIGNMENT_REC>(edm::ESInputTag())} {}
65-
const edm::ESGetToken<DetGeomDesc, IdealGeometryRecord> idealGDToken_;
66-
const edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, ALIGNMENT_REC> alignmentToken_;
67-
};
68-
6965
std::unique_ptr<DetGeomDesc> produceRealGD(const VeryForwardRealGeometryRecord&);
66+
std::unique_ptr<DetGeomDesc> produceRealGDFromPreprocessedDB(const VeryForwardRealGeometryRecord&);
7067
std::unique_ptr<CTPPSGeometry> produceRealTG(const VeryForwardRealGeometryRecord&);
7168

7269
std::unique_ptr<DetGeomDesc> produceMisalignedGD(const VeryForwardMisalignedGeometryRecord&);
70+
std::unique_ptr<DetGeomDesc> produceMisalignedGDFromPreprocessedDB(const VeryForwardMisalignedGeometryRecord&);
7371
std::unique_ptr<CTPPSGeometry> produceMisalignedTG(const VeryForwardMisalignedGeometryRecord&);
7472

75-
template <typename REC>
76-
std::unique_ptr<DetGeomDesc> produceGD(IdealGeometryRecord const&,
73+
template <typename REC, typename GEO>
74+
std::unique_ptr<DetGeomDesc> produceGD(const GEO&,
7775
const std::optional<REC>&,
78-
GDTokens<REC> const&,
76+
edm::ESGetToken<DetGeomDesc, GEO> const&,
77+
edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, REC> const&,
7978
const char* name);
8079

8180
const unsigned int verbosity_;
8281
const bool isRun2_;
8382

8483
edm::ESGetToken<DDCompactView, IdealGeometryRecord> ddToken_;
8584
edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> dd4hepToken_;
86-
const bool fromDD4hep_;
85+
edm::ESGetToken<PDetGeomDesc, VeryForwardIdealGeometryRecord> dbToken_;
86+
const bool fromPreprocessedDB_, fromDD4hep_;
8787

88-
const GDTokens<RPRealAlignmentRecord> gdRealTokens_;
89-
const GDTokens<RPMisalignedAlignmentRecord> gdMisTokens_;
88+
edm::ESGetToken<DetGeomDesc, IdealGeometryRecord> idealGDToken_;
89+
edm::ESGetToken<DetGeomDesc, VeryForwardIdealGeometryRecord> idealDBGDToken_;
90+
edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord> realAlignmentToken_;
91+
edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord> misAlignmentToken_;
9092

91-
const edm::ESGetToken<DetGeomDesc, VeryForwardRealGeometryRecord> dgdRealToken_;
92-
const edm::ESGetToken<DetGeomDesc, VeryForwardMisalignedGeometryRecord> dgdMisToken_;
93+
edm::ESGetToken<DetGeomDesc, VeryForwardRealGeometryRecord> dgdRealToken_;
94+
edm::ESGetToken<DetGeomDesc, VeryForwardMisalignedGeometryRecord> dgdMisToken_;
9395
};
9496

9597
CTPPSGeometryESModule::CTPPSGeometryESModule(const edm::ParameterSet& iConfig)
9698
: verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity")),
9799
isRun2_(iConfig.getParameter<bool>("isRun2")),
98-
fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)),
99-
gdRealTokens_{setWhatProduced(this, &CTPPSGeometryESModule::produceRealGD)},
100-
gdMisTokens_{setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedGD)},
101-
dgdRealToken_{
102-
setWhatProduced(this, &CTPPSGeometryESModule::produceRealTG).consumes<DetGeomDesc>(edm::ESInputTag())},
103-
dgdMisToken_{
104-
setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedTG).consumes<DetGeomDesc>(edm::ESInputTag())} {
105-
auto c = setWhatProduced(this, &CTPPSGeometryESModule::produceIdealGD);
106-
107-
if (!fromDD4hep_) {
100+
fromPreprocessedDB_(iConfig.getUntrackedParameter<bool>("fromPreprocessedDB", false)),
101+
fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)) {
102+
if (fromPreprocessedDB_) {
103+
auto c = setWhatProduced(this, &CTPPSGeometryESModule::produceIdealGDFromPreprocessedDB);
104+
dbToken_ = c.consumes<PDetGeomDesc>(edm::ESInputTag("", iConfig.getParameter<std::string>("dbTag")));
105+
106+
auto c1 = setWhatProduced(this, &CTPPSGeometryESModule::produceRealGDFromPreprocessedDB);
107+
idealDBGDToken_ = c1.consumesFrom<DetGeomDesc, VeryForwardIdealGeometryRecord>(edm::ESInputTag());
108+
realAlignmentToken_ = c1.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(edm::ESInputTag());
109+
110+
auto c2 = setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedGDFromPreprocessedDB);
111+
misAlignmentToken_ =
112+
c2.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord>(edm::ESInputTag());
113+
} else if (!fromDD4hep_) {
114+
auto c = setWhatProduced(this, &CTPPSGeometryESModule::produceIdealGD);
108115
ddToken_ = c.consumes<DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
116+
117+
auto c1 = setWhatProduced(this, &CTPPSGeometryESModule::produceRealGD);
118+
idealGDToken_ = c1.consumesFrom<DetGeomDesc, IdealGeometryRecord>(edm::ESInputTag());
119+
realAlignmentToken_ = c1.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(edm::ESInputTag());
120+
121+
auto c2 = setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedGD);
122+
misAlignmentToken_ =
123+
c2.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord>(edm::ESInputTag());
109124
} else {
125+
auto c = setWhatProduced(this, &CTPPSGeometryESModule::produceIdealGD);
110126
dd4hepToken_ =
111127
c.consumes<cms::DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
128+
129+
auto c1 = setWhatProduced(this, &CTPPSGeometryESModule::produceRealGD);
130+
idealGDToken_ = c1.consumesFrom<DetGeomDesc, IdealGeometryRecord>(edm::ESInputTag());
131+
realAlignmentToken_ = c1.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>(edm::ESInputTag());
132+
133+
auto c2 = setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedGD);
134+
misAlignmentToken_ =
135+
c2.consumesFrom<CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord>(edm::ESInputTag());
112136
}
137+
138+
auto c_RTG = setWhatProduced(this, &CTPPSGeometryESModule::produceRealTG);
139+
dgdRealToken_ = c_RTG.consumes<DetGeomDesc>(edm::ESInputTag());
140+
141+
auto c_MTG = setWhatProduced(this, &CTPPSGeometryESModule::produceMisalignedTG);
142+
dgdMisToken_ = c_MTG.consumes<DetGeomDesc>(edm::ESInputTag());
113143
}
114144

115145
void CTPPSGeometryESModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
116146
edm::ParameterSetDescription desc;
117147
desc.addUntracked<unsigned int>("verbosity", 1);
118148
desc.add<bool>("isRun2", false)->setComment("Switch to legacy (2017-18) definition of diamond geometry");
149+
desc.add<std::string>("dbTag", std::string());
119150
desc.add<std::string>("compactViewTag", std::string());
151+
desc.addUntracked<bool>("fromPreprocessedDB", false);
120152
desc.addUntracked<bool>("fromDD4hep", false);
121153
descriptions.add("CTPPSGeometryESModule", desc);
122154
}
@@ -139,18 +171,32 @@ std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceIdealGD(const IdealGe
139171
}
140172
}
141173

142-
template <typename REC>
143-
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceGD(IdealGeometryRecord const& iIdealRec,
144-
std::optional<REC> const& iAlignRec,
145-
GDTokens<REC> const& iTokens,
146-
const char* name) {
174+
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceIdealGDFromPreprocessedDB(
175+
const VeryForwardIdealGeometryRecord& iRecord) {
176+
// Get the PDetGeomDesc from EventSetup
177+
auto const& myDB = iRecord.get(dbToken_);
178+
179+
edm::LogInfo("CTPPSGeometryESModule") << " myDB size = " << myDB.container_.size();
180+
181+
// Build geo from PDetGeomDesc DB object.
182+
auto pdet = std::make_unique<DetGeomDesc>(myDB);
183+
return pdet;
184+
}
185+
186+
template <typename REC, typename GEO>
187+
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceGD(
188+
GEO const& iIdealRec,
189+
std::optional<REC> const& iAlignRec,
190+
edm::ESGetToken<DetGeomDesc, GEO> const& iGDToken,
191+
edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, REC> const& iAlignToken,
192+
const char* name) {
147193
// get the input GeometricalDet
148-
auto const& idealGD = iIdealRec.get(iTokens.idealGDToken_);
194+
auto const& idealGD = iIdealRec.get(iGDToken);
149195

150196
// load alignments
151197
CTPPSRPAlignmentCorrectionsData const* alignments = nullptr;
152198
if (iAlignRec) {
153-
auto alignmentsHandle = iAlignRec->getHandle(iTokens.alignmentToken_);
199+
auto alignmentsHandle = iAlignRec->getHandle(iAlignToken);
154200
if (alignmentsHandle.isValid()) {
155201
alignments = alignmentsHandle.product();
156202
}
@@ -168,10 +214,33 @@ std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceGD(IdealGeometryRecor
168214
return CTPPSGeometryESCommon::applyAlignments(idealGD, alignments);
169215
}
170216

217+
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceRealGDFromPreprocessedDB(
218+
const VeryForwardRealGeometryRecord& iRecord) {
219+
return produceGD(iRecord.getRecord<VeryForwardIdealGeometryRecord>(),
220+
iRecord.tryToGetRecord<RPRealAlignmentRecord>(),
221+
idealDBGDToken_,
222+
realAlignmentToken_,
223+
"CTPPSGeometryESModule::produceRealGDFromPreprocessedDB");
224+
}
225+
226+
//----------------------------------------------------------------------------------------------------
227+
228+
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceMisalignedGDFromPreprocessedDB(
229+
const VeryForwardMisalignedGeometryRecord& iRecord) {
230+
return produceGD(iRecord.getRecord<VeryForwardIdealGeometryRecord>(),
231+
iRecord.tryToGetRecord<RPMisalignedAlignmentRecord>(),
232+
idealDBGDToken_,
233+
misAlignmentToken_,
234+
"CTPPSGeometryESModule::produceMisalignedGDFromPreprocessedDB");
235+
}
236+
237+
//----------------------------------------------------------------------------------------------------
238+
171239
std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceRealGD(const VeryForwardRealGeometryRecord& iRecord) {
172240
return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
173241
iRecord.tryToGetRecord<RPRealAlignmentRecord>(),
174-
gdRealTokens_,
242+
idealGDToken_,
243+
realAlignmentToken_,
175244
"CTPPSGeometryESModule::produceRealGD");
176245
}
177246

@@ -181,7 +250,8 @@ std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceMisalignedGD(
181250
const VeryForwardMisalignedGeometryRecord& iRecord) {
182251
return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
183252
iRecord.tryToGetRecord<RPMisalignedAlignmentRecord>(),
184-
gdMisTokens_,
253+
idealGDToken_,
254+
misAlignmentToken_,
185255
"CTPPSGeometryESModule::produceMisalignedGD");
186256
}
187257

Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,38 @@ DetGeomDesc::DetGeomDesc(const DetGeomDesc& ref, CopyMode cm) {
7575
m_z = ref.m_z;
7676
}
7777

78+
// Constructor from DB object PDetGeomDesc::Item
79+
DetGeomDesc::DetGeomDesc(const PDetGeomDesc::Item& item)
80+
: m_name(item.name_),
81+
m_copy(item.copy_),
82+
m_isDD4hep(true),
83+
m_params(item.params_), // default unit from DD4hep
84+
m_sensorType(item.sensorType_),
85+
m_geographicalID(item.geographicalID_),
86+
m_z(item.z_) // converted from DD4hep to mm
87+
{
88+
Translation trans(item.dx_, item.dy_, item.dz_);
89+
m_trans = trans;
90+
RotationMatrix rot(item.axx_, item.axy_, item.axz_, item.ayx_, item.ayy_, item.ayz_, item.azx_, item.azy_, item.azz_);
91+
m_rot = rot;
92+
// Set the m_isABox flag for the box shaped sensors, so that m_params are properly set
93+
if ((m_name == DDD_CTPPS_PIXELS_SENSOR_NAME || m_name == DDD_CTPPS_PIXELS_SENSOR_NAME_2x2 ||
94+
m_name == DDD_CTPPS_DIAMONDS_SEGMENT_NAME || m_name == DDD_CTPPS_UFSD_SEGMENT_NAME ||
95+
m_name.substr(0, 7) == DDD_TOTEM_TIMING_SENSOR_TMPL.substr(0, 7)) &&
96+
m_params.size() > 2)
97+
m_isABox = true;
98+
else
99+
m_isABox = false;
100+
m_diamondBoxParams = computeDiamondDimensions(m_isABox, m_isDD4hep, m_params);
101+
}
102+
103+
DetGeomDesc::DetGeomDesc(const PDetGeomDesc& pd) {
104+
for (const auto& i : pd.container_) {
105+
DetGeomDesc* gd = new DetGeomDesc(i);
106+
this->addComponent(gd);
107+
}
108+
}
109+
78110
DetGeomDesc::~DetGeomDesc() { deepDeleteComponents(); }
79111

80112
void DetGeomDesc::addComponent(DetGeomDesc* det) { m_container.emplace_back(det); }
@@ -122,7 +154,7 @@ void DetGeomDesc::deepDeleteComponents() {
122154
}
123155

124156
std::string DetGeomDesc::computeNameWithNoNamespace(std::string_view nameFromView) const {
125-
const auto& semiColonPos = nameFromView.find(":");
157+
const auto& semiColonPos = nameFromView.find(':');
126158
const std::string name{(semiColonPos != std::string::npos ? nameFromView.substr(semiColonPos + 1) : nameFromView)};
127159
return name;
128160
}

0 commit comments

Comments
 (0)