CMS 3D CMS Logo

CSCGeometryESModule.cc
Go to the documentation of this file.
1 /*
2 // \class CSCGeometryESModule
3 //
4 // Description: CSC ESModule for DD4hep
5 //
6 //
7 // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osborne made for DTs (DD4HEP migration)
8 // Created: Thu, 05 March 2020
9 // Modified: Thu, 04 June 2020, following what made in PR #30047
10 //
11 // Original author: Tim Cox
12 */
13 
38 
39 // Alignments
45 
46 #include <memory>
47 #include <string>
48 
50 public:
53 
56 
58  std::shared_ptr<CSCGeometry> produce(const MuonGeometryRecord& record);
59 
60 private:
62 
63  void initCSCGeometry_(const MuonGeometryRecord&, std::shared_ptr<HostType>& host);
64 
66  // DDD
69  //dd4hep
71 
74 
78 
79  // Flags for controlling geometry modelling during build of CSCGeometry
84  bool debugV_;
85  bool applyAlignment_; // Switch to apply alignment corrections
86  bool fromDDD_; // whether to build from DDD or DB
90 };
91 
92 using namespace edm;
93 
95  : fromDDD_(p.getParameter<bool>("fromDDD")),
96  fromDD4hep_(p.getParameter<bool>("fromDD4hep")),
97  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
98  myLabel_(p.getParameter<std::string>("appendToDataLabel")) {
99  auto cc = setWhatProduced(this);
100 
101  // Choose wire geometry modelling
102  // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
103  // in the DDD Geometry.
104  // Default as of transition to CMSSW is to use real values.
105  // Alternative is to use pseudo-values which match reasonably closely
106  // the calculated geometry values used up to and including ORCA_8_8_1.
107  // (This was the default in ORCA.)
108 
109  useRealWireGeometry_ = p.getParameter<bool>("useRealWireGeometry");
110 
111  // Suppress strips altogether in ME1a region of ME11?
112 
113  useOnlyWiresInME1a_ = p.getParameter<bool>("useOnlyWiresInME1a");
114 
115  // Allow strips in ME1a region of ME11 but gang them?
116  // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
117 
118  useGangedStripsInME1a_ = p.getParameter<bool>("useGangedStripsInME1a");
119 
121  useOnlyWiresInME1a_ = false; // override possible inconsistentcy
122 
123  // Use the backed-out offsets that correct the CTI
124  useCentreTIOffsets_ = p.getParameter<bool>("useCentreTIOffsets");
125 
126  // Debug printout etc. in CSCGeometry etc.
127 
128  debugV_ = p.getUntrackedParameter<bool>("debugV", false);
129 
130  if (fromDDD_) {
131  cpvToken_ = cc.consumes();
132  mdcToken_ = cc.consumes();
133  } else if (fromDD4hep_) {
134  cpvTokendd4hep_ = cc.consumes();
135  mdcToken_ = cc.consumes();
136  } else {
139  }
140 
141  // Feed these value to where I need them
142  applyAlignment_ = p.getParameter<bool>("applyAlignment");
143  if (applyAlignment_) {
148  }
149 
150  edm::LogVerbatim("Geometry") << "@SUB=CSCGeometryESModule Label '" << myLabel_ << "' "
151  << (applyAlignment_ ? "looking for" : "IGNORING") << " alignment labels '"
152  << alignmentsLabel_ << "'.";
153 }
154 
156  //
157  // This cfi should be included to build the CSC geometry model.
158  //
159  // modelling flags (for completeness - internal defaults are already sane)
160  // GF would like to have a shorter name (e.g. CSCGeometry), but since originally
161  // there was no name, replace statements in other configs would not work anymore...
163  desc.add<bool>("fromDDD", true);
164  desc.add<bool>("fromDD4hep", false);
165  desc.add<std::string>("alignmentsLabel", "");
166  desc.add<std::string>("appendToDataLabel", "");
167  desc.add<bool>("useRealWireGeometry", true);
168  desc.add<bool>("useOnlyWiresInME1a", false);
169  desc.add<bool>("useGangedStripsInME1a", true);
170  desc.add<bool>("useCentreTIOffsets", false);
171  desc.add<bool>("applyAlignment", true); //GF: to be abandoned
172  desc.addUntracked<bool>("debugV", false);
173  descriptions.add("CSCGeometryESModule", desc);
174 }
175 
176 std::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
177  auto host = holder_.makeOrGet([this]() {
178  return new HostType(
179  debugV_, useGangedStripsInME1a_, useOnlyWiresInME1a_, useRealWireGeometry_, useCentreTIOffsets_);
180  });
181 
182  initCSCGeometry_(record, host);
183 
184  // Called whenever the alignments or alignment errors change
185 
186  if (applyAlignment_) {
187  // applyAlignment_ is scheduled for removal.
188  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
189  const auto& globalPosition = record.get(globalPositionToken_);
190  const auto& alignments = record.get(alignmentsToken_);
191  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
192  // Only apply alignment if values exist
193  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
194  edm::LogVerbatim("Config") << "@SUB=CSCGeometryRecord::produce Alignment(Error)s and global position (label '"
195  << alignmentsLabel_ << "') empty: Geometry producer (label "
196  << "'" << myLabel_ << "') assumes fake and does not apply.";
197  } else {
198  GeometryAligner aligner;
199  aligner.applyAlignments<CSCGeometry>(
200  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
201  }
202  }
203  return host; // automatically converts to std::shared_ptr<CSCGeometry>
204 }
205 
206 void CSCGeometryESModule::initCSCGeometry_(const MuonGeometryRecord& record, std::shared_ptr<HostType>& host) {
207  if (fromDDD_) {
208  edm::LogVerbatim("CSCGeoemtryESModule") << "(0) CSCGeometryESModule - DDD ";
209  host->ifRecordChanges<IdealGeometryRecord>(record, [&host, &record, this](auto const& rec) {
210  host->clear();
211  edm::ESTransientHandle<DDCompactView> cpv = record.getTransientHandle(cpvToken_);
212  const auto& mdc = rec.get(mdcToken_);
214  builder.build(*host, cpv.product(), mdc);
215  });
216  } else if (fromDD4hep_) {
217  edm::LogVerbatim("CSCGeoemtryESModule") << "(0) CSCGeometryESModule - DD4HEP ";
218  host->ifRecordChanges<IdealGeometryRecord>(record, [&host, &record, this](auto const& rec) {
219  host->clear();
220  edm::ESTransientHandle<cms::DDCompactView> cpv = record.getTransientHandle(cpvTokendd4hep_);
221  const auto& mdc = rec.get(mdcToken_);
223  builder.build(*host, cpv.product(), mdc);
224  });
225  } else {
226  bool recreateGeometry = false;
227 
228  host->ifRecordChanges<CSCRecoGeometryRcd>(record,
229  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
230 
231  host->ifRecordChanges<CSCRecoDigiParametersRcd>(record,
232  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
233  edm::LogVerbatim("CSCGeoemtryESModule") << "(0) CSCGeometryESModule - DB recreateGeometry=false ";
234  if (recreateGeometry) {
235  edm::LogVerbatim("CSCGeoemtryESModule") << "(0) CSCGeometryESModule - DB recreateGeometry=true ";
236  host->clear();
237  const auto& rig = record.get(rigToken_);
238  const auto& rdp = record.get(rdpToken_);
239  CSCGeometryBuilder cscgb;
240  cscgb.build(*host, rig, rdp);
241  }
242  }
243 }
244 
ConfigurationDescriptions.h
AlignmentErrorsExtended.h
CSCGeometryESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Creation of configuration file.
Definition: CSCGeometryESModule.cc:155
GlobalPositionRcd.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
cscGeometryOrcaCompare_cfi.CSCGeometryESModule
CSCGeometryESModule
Definition: cscGeometryOrcaCompare_cfi.py:18
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
CSCRecoDigiParameters
Definition: CSCRecoDigiParameters.h:18
CSCGeometryBuilder.h
CSCGeometryESModule::useRealWireGeometry_
bool useRealWireGeometry_
Definition: CSCGeometryESModule.cc:80
edm
HLT enums.
Definition: AlignableModifier.h:19
MuonGeometryConstants.h
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
CSCGeometryESModule::fromDDD_
bool fromDDD_
Definition: CSCGeometryESModule.cc:86
CSCGeometryESModule::globalPositionToken_
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
Definition: CSCGeometryESModule.cc:75
CSCGeometryESModule::useOnlyWiresInME1a_
bool useOnlyWiresInME1a_
Definition: CSCGeometryESModule.cc:81
DetectorGlobalPosition.h
CSCGeometryESModule::CSCGeometryESModule
CSCGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: CSCGeometryESModule.cc:94
MuonNumberingRecord.h
query.host
string host
Definition: query.py:115
ESGetToken.h
DDCompactView.h
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
CSCGeometryESModule::debugV_
bool debugV_
Definition: CSCGeometryESModule.cc:84
cc
edm::ReusableObjectHolder< HostType >
CSCGeometry
Definition: CSCGeometry.h:24
DetId
Definition: DetId.h:17
CSCGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: CSCGeometryESModule.cc:77
CSCGeometryBuilder
Definition: CSCGeometryBuilder.h:20
ReusableObjectHolder.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CSCAlignmentErrorExtendedRcd.h
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
CSCRecoGeometryRcd.h
CSCGeometryBuilder::build
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
Definition: CSCGeometryBuilder.cc:17
DDCompactView.h
CSCGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: CSCGeometryESModule.cc:68
RecoIdealGeometry.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CSCRecoDigiParameters.h
CSCAlignmentErrorExtendedRcd
Definition: CSCAlignmentErrorExtendedRcd.h:6
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
CSCRecoDigiParametersRcd
Definition: CSCRecoDigiParametersRcd.h:5
CSCGeometryBuilderFromDDD::build
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonGeometryConstants &muonConstants)
Definition: CSCGeometryBuilderFromDDD.cc:28
CSCGeometryESModule::useGangedStripsInME1a_
bool useGangedStripsInME1a_
Definition: CSCGeometryESModule.cc:82
IdealGeometryRecord.h
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
CSCGeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: CSCGeometryESModule.cc:67
CSCGeometryBuilderFromDDD.h
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< DDCompactView, IdealGeometryRecord >
CSCGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, CSCAlignmentRcd > alignmentsToken_
Definition: CSCGeometryESModule.cc:76
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
CSCGeometryESModule::fromDD4hep_
bool fromDD4hep_
Definition: CSCGeometryESModule.cc:87
GeometryAligner.h
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
CSCGeometryBuilderFromDDD
Definition: CSCGeometryBuilderFromDDD.h:26
CSCGeometryESModule::cpvTokendd4hep_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokendd4hep_
Definition: CSCGeometryESModule.cc:70
CSCGeometryESModule::produce
std::shared_ptr< CSCGeometry > produce(const MuonGeometryRecord &record)
Produce CSCGeometry.
Definition: CSCGeometryESModule.cc:176
CSCGeometryESModule::useCentreTIOffsets_
bool useCentreTIOffsets_
Definition: CSCGeometryESModule.cc:83
CSCGeometryESModule::rigToken_
edm::ESGetToken< RecoIdealGeometry, CSCRecoGeometryRcd > rigToken_
Definition: CSCGeometryESModule.cc:72
CSCGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: CSCGeometryESModule.cc:85
CSCGeometryESModule::rdpToken_
edm::ESGetToken< CSCRecoDigiParameters, CSCRecoDigiParametersRcd > rdpToken_
Definition: CSCGeometryESModule.cc:73
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
CSCRecoDigiParametersRcd.h
DetId::Muon
Definition: DetId.h:26
CSCChamberSpecs.h
ParameterSet.h
MuonGeometryRecord.h
CSCGeometryESModule::myLabel_
const std::string myLabel_
Definition: CSCGeometryESModule.cc:89
Alignments
Definition: Alignments.h:10
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
CSCGeometryESModule::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: CSCGeometryESModule.cc:65
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28
CSCAlignmentRcd
Definition: CSCAlignmentRcd.h:6
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
CSCGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: CSCGeometryESModule.cc:88
CSCRecoGeometryRcd
Definition: CSCRecoGeometryRcd.h:5
CSCAlignmentRcd.h
CSCGeometry.h
CSCGeometryESModule::initCSCGeometry_
void initCSCGeometry_(const MuonGeometryRecord &, std::shared_ptr< HostType > &host)
Definition: CSCGeometryESModule.cc:206