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 ****************************************************************************/
10 
17 
21 
27 
32 
34 
35 #include <regex>
36 
46 using RotationMatrix = ROOT::Math::Rotation3D;
47 using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
48 
50 public:
52  ~CTPPSGeometryESModule() override {}
53 
54  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
55 
56 private:
57  std::unique_ptr<DetGeomDesc> produceIdealGD(const IdealGeometryRecord&);
58  std::vector<int> fillCopyNos(TGeoIterator& it);
59 
60  template <typename ALIGNMENT_REC>
61  struct GDTokens {
62  explicit GDTokens(edm::ESConsumesCollector&& iCC)
64  alignmentToken_{iCC.consumesFrom<CTPPSRPAlignmentCorrectionsData, ALIGNMENT_REC>(edm::ESInputTag())} {}
67  };
68 
69  std::unique_ptr<DetGeomDesc> produceRealGD(const VeryForwardRealGeometryRecord&);
70  std::unique_ptr<CTPPSGeometry> produceRealTG(const VeryForwardRealGeometryRecord&);
71 
72  std::unique_ptr<DetGeomDesc> produceMisalignedGD(const VeryForwardMisalignedGeometryRecord&);
73  std::unique_ptr<CTPPSGeometry> produceMisalignedTG(const VeryForwardMisalignedGeometryRecord&);
74 
75  template <typename REC>
76  std::unique_ptr<DetGeomDesc> produceGD(IdealGeometryRecord const&,
77  const std::optional<REC>&,
78  GDTokens<REC> const&,
79  const char* name);
80 
81  const unsigned int verbosity_;
82  const bool isRun2_;
83 
86  const bool fromDD4hep_;
87 
90 
93 };
94 
96  : verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity")),
97  isRun2_(iConfig.getParameter<bool>("isRun2")),
98  fromDD4hep_(iConfig.getUntrackedParameter<bool>("fromDD4hep", false)),
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_) {
108  ddToken_ = c.consumes<DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
109  } else {
110  dd4hepToken_ =
111  c.consumes<cms::DDCompactView>(edm::ESInputTag("", iConfig.getParameter<std::string>("compactViewTag")));
112  }
113 }
114 
117  desc.addUntracked<unsigned int>("verbosity", 1);
118  desc.add<bool>("isRun2", false)->setComment("Switch to legacy (2017-18) definition of diamond geometry");
119  desc.add<std::string>("compactViewTag", std::string());
120  desc.addUntracked<bool>("fromDD4hep", false);
121  descriptions.add("CTPPSGeometryESModule", desc);
122 }
123 
124 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceIdealGD(const IdealGeometryRecord& iRecord) {
125  if (!fromDD4hep_) {
126  // Get the DDCompactView from EventSetup
127  auto const& myCompactView = iRecord.get(ddToken_);
128 
129  // Build geo from compact view.
131  }
132 
133  else {
134  // Get the DDCompactView from EventSetup
135  auto const& myCompactView = iRecord.get(dd4hepToken_);
136 
137  // Build geo from compact view.
139  }
140 }
141 
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) {
147  // get the input GeometricalDet
148  auto const& idealGD = iIdealRec.get(iTokens.idealGDToken_);
149 
150  // load alignments
151  CTPPSRPAlignmentCorrectionsData const* alignments = nullptr;
152  if (iAlignRec) {
153  auto alignmentsHandle = iAlignRec->getHandle(iTokens.alignmentToken_);
154  if (alignmentsHandle.isValid()) {
155  alignments = alignmentsHandle.product();
156  }
157  }
158 
159  if (verbosity_) {
160  if (alignments) {
161  edm::LogVerbatim(name) << ">> " << name << " > Real geometry: " << alignments->getRPMap().size() << " RP and "
162  << alignments->getSensorMap().size() << " sensor alignments applied.";
163  } else {
164  edm::LogVerbatim(name) << ">> " << name << " > Real geometry: No alignment applied.";
165  }
166  }
167 
168  return CTPPSGeometryESCommon::applyAlignments(idealGD, alignments);
169 }
170 
171 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceRealGD(const VeryForwardRealGeometryRecord& iRecord) {
172  return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
175  "CTPPSGeometryESModule::produceRealGD");
176 }
177 
178 //----------------------------------------------------------------------------------------------------
179 
180 std::unique_ptr<DetGeomDesc> CTPPSGeometryESModule::produceMisalignedGD(
181  const VeryForwardMisalignedGeometryRecord& iRecord) {
182  return produceGD(iRecord.getRecord<IdealGeometryRecord>(),
184  gdMisTokens_,
185  "CTPPSGeometryESModule::produceMisalignedGD");
186 }
187 
188 //----------------------------------------------------------------------------------------------------
189 
190 std::unique_ptr<CTPPSGeometry> CTPPSGeometryESModule::produceRealTG(const VeryForwardRealGeometryRecord& iRecord) {
191  auto const& gD = iRecord.get(dgdRealToken_);
192 
193  return std::make_unique<CTPPSGeometry>(&gD, verbosity_);
194 }
195 
196 //----------------------------------------------------------------------------------------------------
197 
198 std::unique_ptr<CTPPSGeometry> CTPPSGeometryESModule::produceMisalignedTG(
199  const VeryForwardMisalignedGeometryRecord& iRecord) {
200  auto const& gD = iRecord.get(dgdMisToken_);
201 
202  return std::make_unique<CTPPSGeometry>(&gD, verbosity_);
203 }
204 
edm::eventsetup::DependentRecordImplementation::getRecord
const DepRecordT getRecord() const
Definition: DependentRecordImplementation.h:50
CTPPSGeometryESModule::GDTokens::idealGDToken_
const edm::ESGetToken< DetGeomDesc, IdealGeometryRecord > idealGDToken_
Definition: CTPPSGeometryESModule.cc:64
CTPPSGeometryESModule::CTPPSGeometryESModule
CTPPSGeometryESModule(const edm::ParameterSet &)
Definition: CTPPSGeometryESModule.cc:94
VeryForwardRealGeometryRecord
Event setup record containing the real (actual) geometry information.
Definition: VeryForwardRealGeometryRecord.h:22
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
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
CTPPSGeometryESModule::GDTokens::GDTokens
GDTokens(edm::ESConsumesCollector &&iCC)
Definition: CTPPSGeometryESModule.cc:61
edm::ESConsumesCollector
Definition: ESConsumesCollector.h:61
ESHandle.h
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:81
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
CTPPSGeometryESModule::produceGD
std::unique_ptr< DetGeomDesc > produceGD(IdealGeometryRecord const &, const std::optional< REC > &, GDTokens< REC > const &, const char *name)
Definition: CTPPSGeometryESModule.cc:142
CTPPSGeometryESModule::gdMisTokens_
const GDTokens< RPMisalignedAlignmentRecord > gdMisTokens_
Definition: CTPPSGeometryESModule.cc:88
RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: PGeometricDetBuilder.cc:21
RPMisalignedAlignmentRecord
Definition: RPMisalignedAlignmentRecord.h:6
DDCompactView.h
VeryForwardMisalignedGeometryRecord.h
CTPPSGeometryESCommon.h
CTPPSGeometryESModule::produceRealGD
std::unique_ptr< DetGeomDesc > produceRealGD(const VeryForwardRealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:170
RPMisalignedAlignmentRecord.h
CTPPSGeometryESModule
Definition: CTPPSGeometryESModule.cc:48
CTPPSGeometry.h
CTPPSGeometryESModule::ddToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
Definition: CTPPSGeometryESModule.cc:83
RPRealAlignmentRecord
Definition: RPRealAlignmentRecord.h:6
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CTPPSGeometryESModule::dgdMisToken_
const edm::ESGetToken< DetGeomDesc, VeryForwardMisalignedGeometryRecord > dgdMisToken_
Definition: CTPPSGeometryESModule.cc:91
CTPPSGeometryESModule::GDTokens::alignmentToken_
const edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, ALIGNMENT_REC > alignmentToken_
Definition: CTPPSGeometryESModule.cc:65
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
CTPPSGeometryESModule::produceRealTG
std::unique_ptr< CTPPSGeometry > produceRealTG(const VeryForwardRealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:189
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::gdRealTokens_
const GDTokens< RPRealAlignmentRecord > gdRealTokens_
Definition: CTPPSGeometryESModule.cc:87
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSGeometryESModule::~CTPPSGeometryESModule
~CTPPSGeometryESModule() override
Definition: CTPPSGeometryESModule.cc:51
CTPPSGeometryESModule::produceIdealGD
std::unique_ptr< DetGeomDesc > produceIdealGD(const IdealGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:123
CTPPSGeometryESModule::verbosity_
const unsigned int verbosity_
Definition: CTPPSGeometryESModule.cc:80
edm::ParameterSet
Definition: ParameterSet.h:47
DetGeomDesc.h
CTPPSGeometryESModule::GDTokens
Definition: CTPPSGeometryESModule.cc:60
CTPPSGeometryESModule::produceMisalignedGD
std::unique_ptr< DetGeomDesc > produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:179
DetGeomDescBuilder.h
createfilelist.int
int
Definition: createfilelist.py:10
DetGeomDesc
Definition: DetGeomDesc.h:49
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:20
IdealGeometryRecord.h
CTPPSDDDNames.h
VeryForwardRealGeometryRecord.h
edm::ESGetToken< DetGeomDesc, IdealGeometryRecord >
CTPPSGeometryESModule::fromDD4hep_
const bool fromDD4hep_
Definition: CTPPSGeometryESModule.cc:85
VeryForwardMisalignedGeometryRecord
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
Definition: VeryForwardMisalignedGeometryRecord.h:23
ModuleFactory.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
CTPPSGeometryESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSGeometryESModule.cc:114
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
CTPPSGeometryESModule::dgdRealToken_
const edm::ESGetToken< DetGeomDesc, VeryForwardRealGeometryRecord > dgdRealToken_
Definition: CTPPSGeometryESModule.cc:90
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
CTPPSRPAlignmentCorrectionsData.h
edm::ESProducer
Definition: ESProducer.h:104
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
detgeomdescbuilder::buildDetGeomDescFromCompactView
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
Definition: DetGeomDescBuilder.cc:10
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CTPPSGeometryESModule::produceMisalignedTG
std::unique_ptr< CTPPSGeometry > produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &)
Definition: CTPPSGeometryESModule.cc:197
CTPPSGeometryESModule::dd4hepToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
Definition: CTPPSGeometryESModule.cc:84