CMS 3D CMS Logo

CTPPSGeometryESModule.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Based on CTPPSGeometryESModule.cc by:
3 * Jan Kaspar (jan.kaspar@gmail.com)
4 * Dominik Mierzejewski <dmierzej@cern.ch>
5 *
6 * Rewritten + Moved out common functionailities to DetGeomDesc(Builder) by Gabrielle Hugo.
7 * Migrated to DD4hep by Wagner Carvalho and Gabrielle Hugo.
8 *
9 * Add the capability of reading PPS reco geometry from the database
10 *
11 ****************************************************************************/
12 
18 
22 
30 
35 
37 
38 #include <regex>
39 
49 using RotationMatrix = ROOT::Math::Rotation3D;
50 using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
51 
53 public:
55  ~CTPPSGeometryESModule() override {}
56 
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59 private:
60  std::unique_ptr<DetGeomDesc> produceIdealGD(const IdealGeometryRecord&);
61  std::unique_ptr<DetGeomDesc> produceIdealGDFromPreprocessedDB(const VeryForwardIdealGeometryRecord&);
62  std::vector<int> fillCopyNos(TGeoIterator& it);
63 
64  std::unique_ptr<DetGeomDesc> produceRealGD(const VeryForwardRealGeometryRecord&);
65  std::unique_ptr<DetGeomDesc> produceRealGDFromPreprocessedDB(const VeryForwardRealGeometryRecord&);
66  std::unique_ptr<CTPPSGeometry> produceRealTG(const VeryForwardRealGeometryRecord&);
67 
68  std::unique_ptr<DetGeomDesc> produceMisalignedGD(const VeryForwardMisalignedGeometryRecord&);
70  std::unique_ptr<CTPPSGeometry> produceMisalignedTG(const VeryForwardMisalignedGeometryRecord&);
71 
72  template <typename REC, typename GEO>
73  std::unique_ptr<DetGeomDesc> produceGD(const GEO&,
74  const std::optional<REC>&,
77  const char* name);
78 
79  const unsigned int verbosity_;
80  const bool isRun2_;
81 
85  const bool fromPreprocessedDB_, fromDD4hep_;
86 
91 
94 };
95 
97  : verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity")),
98  isRun2_(iConfig.getParameter<bool>("isRun2")),
99  fromPreprocessedDB_(iConfig.getUntrackedParameter<bool>("fromPreprocessedDB", false)),
100  fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)) {
101  if (fromPreprocessedDB_) {
103  dbToken_ = c.consumes<PDetGeomDesc>(edm::ESInputTag("", iConfig.getParameter<std::string>("dbTag")));
104 
108 
112  } else if (!fromDD4hep_) {
114  ddToken_ = c.consumes<DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
115 
119 
123  } else {
125  dd4hepToken_ =
126  c.consumes<cms::DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
127 
131 
135  }
136 
138  dgdRealToken_ = c_RTG.consumes<DetGeomDesc>(edm::ESInputTag());
139 
141  dgdMisToken_ = c_MTG.consumes<DetGeomDesc>(edm::ESInputTag());
142 }
143 
146  desc.addUntracked<unsigned int>("verbosity", 1);
147  desc.add<bool>("isRun2", false)->setComment("Switch to legacy (2017-18) definition of diamond geometry");
148  desc.add<std::string>("dbTag", std::string());
149  desc.add<std::string>("compactViewTag", std::string());
150  desc.addUntracked<bool>("fromPreprocessedDB", false);
151  desc.addUntracked<bool>("fromDD4hep", false);
152  descriptions.add("CTPPSGeometryESModule", desc);
153 }
154 
155 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceIdealGD(const IdealGeometryRecord& iRecord) {
156  if (!fromDD4hep_) {
157  // Get the DDCompactView from EventSetup
158  auto const& myCompactView = iRecord.get(ddToken_);
159 
160  // Build geo from compact view.
162  }
163 
164  else {
165  // Get the DDCompactView from EventSetup
166  auto const& myCompactView = iRecord.get(dd4hepToken_);
167 
168  // Build geo from compact view.
170  }
171 }
172 
174  const VeryForwardIdealGeometryRecord& iRecord) {
175  // Get the PDetGeomDesc from EventSetup
176  auto const& myDB = iRecord.get(dbToken_);
177 
178  edm::LogInfo("CTPPSGeometryESModule") << " myDB size = " << myDB.container_.size();
179 
180  // Build geo from PDetGeomDesc DB object.
181  auto pdet = std::make_unique<DetGeomDesc>(myDB);
182  return pdet;
183 }
184 
185 template <typename REC, typename GEO>
186 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceGD(
187  GEO const& iIdealRec,
188  std::optional<REC> const& iAlignRec,
189  edm::ESGetToken<DetGeomDesc, GEO> const& iGDToken,
191  const char* name) {
192  // get the input GeometricalDet
193  auto const& idealGD = iIdealRec.get(iGDToken);
194 
195  // load alignments
196  CTPPSRPAlignmentCorrectionsData const* alignments = nullptr;
197  if (iAlignRec) {
198  auto alignmentsHandle = iAlignRec->getHandle(iAlignToken);
199  if (alignmentsHandle.isValid()) {
200  alignments = alignmentsHandle.product();
201  }
202  }
203 
204  if (verbosity_) {
205  if (alignments) {
206  edm::LogVerbatim(name) << ">> " << name << " > Real geometry: " << alignments->getRPMap().size() << " RP and "
207  << alignments->getSensorMap().size() << " sensor alignments applied.";
208  } else {
209  edm::LogVerbatim(name) << ">> " << name << " > Real geometry: No alignment applied.";
210  }
211  }
212 
213  return CTPPSGeometryESCommon::applyAlignments(idealGD, alignments);
214 }
215 
216 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceRealGDFromPreprocessedDB(
217  const VeryForwardRealGeometryRecord& iRecord) {
222  "CTPPSGeometryESModule::produceRealGDFromPreprocessedDB");
223 }
224 
225 //----------------------------------------------------------------------------------------------------
226 
228  const VeryForwardMisalignedGeometryRecord& iRecord) {
233  "CTPPSGeometryESModule::produceMisalignedGDFromPreprocessedDB");
234 }
235 
236 //----------------------------------------------------------------------------------------------------
237 
238 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceRealGD(const VeryForwardRealGeometryRecord& iRecord) {
239  return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
243  "CTPPSGeometryESModule::produceRealGD");
244 }
245 
246 //----------------------------------------------------------------------------------------------------
247 
248 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceMisalignedGD(
249  const VeryForwardMisalignedGeometryRecord& iRecord) {
250  return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
254  "CTPPSGeometryESModule::produceMisalignedGD");
255 }
256 
257 //----------------------------------------------------------------------------------------------------
258 
259 std::unique_ptr<CTPPSGeometry> CTPPSGeometryESModule::produceRealTG(const VeryForwardRealGeometryRecord& iRecord) {
260  auto const& gD = iRecord.get(dgdRealToken_);
261 
262  return std::make_unique<CTPPSGeometry>(&gD, verbosity_);
263 }
264 
265 //----------------------------------------------------------------------------------------------------
266 
267 std::unique_ptr<CTPPSGeometry> CTPPSGeometryESModule::produceMisalignedTG(
268  const VeryForwardMisalignedGeometryRecord& iRecord) {
269  auto const& gD = iRecord.get(dgdMisToken_);
270 
271  return std::make_unique<CTPPSGeometry>(&gD, verbosity_);
272 }
273 
edm::eventsetup::DependentRecordImplementation::getRecord
const DepRecordT getRecord() const
Definition: DependentRecordImplementation.h:50
CTPPSGeometryESModule::CTPPSGeometryESModule
CTPPSGeometryESModule(const edm::ParameterSet &)
Definition: CTPPSGeometryESModule.cc:95
VeryForwardRealGeometryRecord
Event setup record containing the real (actual) geometry information.
Definition: VeryForwardRealGeometryRecord.h:23
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
CTPPSGeometryESModule::dbToken_
edm::ESGetToken< PDetGeomDesc, VeryForwardIdealGeometryRecord > dbToken_
Definition: CTPPSGeometryESModule.cc:83
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
CTPPSRPAlignmentCorrectionsData::getRPMap
const mapType & getRPMap() const
returns the map of RP alignment corrections
Definition: CTPPSRPAlignmentCorrectionsData.h:46
VeryForwardIdealGeometryRecord
Event setup record containing the ideal PPS geometry information.
Definition: VeryForwardIdealGeometryRecord.h:9
CTPPSRPAlignmentCorrectionsData::getSensorMap
const mapType & getSensorMap() const
returns the map of sensor alignment corrections
Definition: CTPPSRPAlignmentCorrectionsData.h:49
CTPPSGeometryESModule::isRun2_
const bool isRun2_
Definition: CTPPSGeometryESModule.cc:79
CTPPSGeometryESModule::produceIdealGDFromPreprocessedDB
std::unique_ptr< DetGeomDesc > produceIdealGDFromPreprocessedDB(const VeryForwardIdealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:172
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:22
RPMisalignedAlignmentRecord
Definition: RPMisalignedAlignmentRecord.h:6
CTPPSGeometryESModule::dgdMisToken_
edm::ESGetToken< DetGeomDesc, VeryForwardMisalignedGeometryRecord > dgdMisToken_
Definition: CTPPSGeometryESModule.cc:92
DDCompactView.h
VeryForwardMisalignedGeometryRecord.h
CTPPSGeometryESCommon.h
CTPPSGeometryESModule::produceRealGD
std::unique_ptr< DetGeomDesc > produceRealGD(const VeryForwardRealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:237
RPMisalignedAlignmentRecord.h
CTPPSGeometryESModule
Definition: CTPPSGeometryESModule.cc:51
CTPPSGeometry.h
CTPPSGeometryESModule::ddToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
Definition: CTPPSGeometryESModule.cc:81
RPRealAlignmentRecord
Definition: RPRealAlignmentRecord.h:6
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PDetGeomDesc.h
CTPPSGeometryESModule::produceGD
std::unique_ptr< DetGeomDesc > produceGD(const GEO &, const std::optional< REC > &, edm::ESGetToken< DetGeomDesc, GEO > const &, edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, REC > const &, const char *name)
Definition: CTPPSGeometryESModule.cc:185
CTPPSGeometryESModule::idealGDToken_
edm::ESGetToken< DetGeomDesc, IdealGeometryRecord > idealGDToken_
Definition: CTPPSGeometryESModule.cc:86
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
CTPPSGeometryESModule::produceRealTG
std::unique_ptr< CTPPSGeometry > produceRealTG(const VeryForwardRealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:258
RPRealAlignmentRecord.h
CTPPSGeometryESModule::fillCopyNos
std::vector< int > fillCopyNos(TGeoIterator &it)
DDCompactView.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
CTPPSGeometryESModule::idealDBGDToken_
edm::ESGetToken< DetGeomDesc, VeryForwardIdealGeometryRecord > idealDBGDToken_
Definition: CTPPSGeometryESModule.cc:87
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CTPPSGeometryESModule::~CTPPSGeometryESModule
~CTPPSGeometryESModule() override
Definition: CTPPSGeometryESModule.cc:54
CTPPSGeometryESModule::produceIdealGD
std::unique_ptr< DetGeomDesc > produceIdealGD(const IdealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:154
CTPPSGeometryESModule::verbosity_
const unsigned int verbosity_
Definition: CTPPSGeometryESModule.cc:78
edm::ParameterSet
Definition: ParameterSet.h:47
CTPPSGeometryESModule::realAlignmentToken_
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord > realAlignmentToken_
Definition: CTPPSGeometryESModule.cc:88
DetGeomDesc.h
CTPPSGeometryESModule::fromPreprocessedDB_
const bool fromPreprocessedDB_
Definition: CTPPSGeometryESModule.cc:84
CTPPSGeometryESModule::produceMisalignedGD
std::unique_ptr< DetGeomDesc > produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:247
DetGeomDescBuilder.h
createfilelist.int
int
Definition: createfilelist.py:10
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
DetGeomDesc
Definition: DetGeomDesc.h:50
CTPPSGeometryESModule::misAlignmentToken_
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord > misAlignmentToken_
Definition: CTPPSGeometryESModule.cc:89
CTPPSGeometryESCommon::applyAlignments
std::unique_ptr< DetGeomDesc > applyAlignments(const DetGeomDesc &, const CTPPSRPAlignmentCorrectionsData *)
Definition: CTPPSGeometryESCommon.cc:6
Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: PGeometricDetBuilder.cc:21
IdealGeometryRecord.h
CTPPSDDDNames.h
PDetGeomDesc
Definition: PDetGeomDesc.h:9
VeryForwardRealGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken
Definition: EventSetup.h:48
CTPPSGeometryESModule::fromDD4hep_
const bool fromDD4hep_
Definition: CTPPSGeometryESModule.cc:84
VeryForwardMisalignedGeometryRecord
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
Definition: VeryForwardMisalignedGeometryRecord.h:24
VeryForwardIdealGeometryRecord.h
ModuleFactory.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
CTPPSGeometryESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSGeometryESModule.cc:143
edm::eventsetup::DependentRecordImplementation::tryToGetRecord
std::optional< DepRecordT > tryToGetRecord() const
Definition: DependentRecordImplementation.h:71
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
cms::DDCompactView
Definition: DDCompactView.h:31
CTPPSRPAlignmentCorrectionsData
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
Definition: CTPPSRPAlignmentCorrectionsData.h:24
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
CTPPSGeometryESModule::dgdRealToken_
edm::ESGetToken< DetGeomDesc, VeryForwardRealGeometryRecord > dgdRealToken_
Definition: CTPPSGeometryESModule.cc:91
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CTPPSRPAlignmentCorrectionsData.h
edm::ESProducer
Definition: ESProducer.h:104
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
detgeomdescbuilder::buildDetGeomDescFromCompactView
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
Definition: DetGeomDescBuilder.cc:10
CTPPSGeometryESModule::produceMisalignedGDFromPreprocessedDB
std::unique_ptr< DetGeomDesc > produceMisalignedGDFromPreprocessedDB(const VeryForwardMisalignedGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:226
CTPPSGeometryESModule::produceRealGDFromPreprocessedDB
std::unique_ptr< DetGeomDesc > produceRealGDFromPreprocessedDB(const VeryForwardRealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:215
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CTPPSGeometryESModule::produceMisalignedTG
std::unique_ptr< CTPPSGeometry > produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:266
CTPPSGeometryESModule::dd4hepToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
Definition: CTPPSGeometryESModule.cc:82