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 Osburne made for DTs (DD4HEP migration)
8 // Created: Thu, 05 March 2020
9 //
10 // Original author: Tim Cox
11 */
12 #include "CSCGeometryESModule.h"
16 
18 
21 
22 #include <memory>
23 
27 
28 using namespace edm;
29 
31  : useDDD_(p.getParameter<bool>("useDDD")),
32  useDD4hep_{p.getUntrackedParameter<bool>("useDD4hep", false)},
33  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
34  myLabel_(p.getParameter<std::string>("appendToDataLabel")) {
35  auto cc = setWhatProduced(this);
36 
37  // Choose wire geometry modelling
38  // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
39  // in the DDD Geometry.
40  // Default as of transition to CMSSW is to use real values.
41  // Alternative is to use pseudo-values which match reasonably closely
42  // the calculated geometry values used up to and including ORCA_8_8_1.
43  // (This was the default in ORCA.)
44 
45  useRealWireGeometry = p.getParameter<bool>("useRealWireGeometry");
46 
47  // Suppress strips altogether in ME1a region of ME11?
48 
49  useOnlyWiresInME1a = p.getParameter<bool>("useOnlyWiresInME1a");
50 
51  // Allow strips in ME1a region of ME11 but gang them?
52  // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
53 
54  useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
55 
57  useOnlyWiresInME1a = false; // override possible inconsistentcy
58 
59  // Use the backed-out offsets that correct the CTI
60  useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets");
61 
62  // Debug printout etc. in CSCGeometry etc.
63 
64  debugV = p.getUntrackedParameter<bool>("debugV", false);
65 
66  // Find out if using the DDD or CondDB Geometry source.
67  useDDD_ = p.getParameter<bool>("useDDD");
68  if (useDDD_) {
69  cpvToken_ = cc.consumesFrom<DDCompactView, IdealGeometryRecord>(edm::ESInputTag{});
70  mdcToken_ = cc.consumesFrom<MuonGeometryConstants, IdealGeometryRecord>(edm::ESInputTag{});
71  } else if (useDD4hep_) {
72  cpvTokendd4hep_ = cc.consumesFrom<cms::DDCompactView, IdealGeometryRecord>(edm::ESInputTag{});
73  mdcTokendd4hep_ = cc.consumesFrom<cms::MuonNumbering, MuonNumberingRecord>(edm::ESInputTag{});
74  } else {
75  rigToken_ = cc.consumesFrom<RecoIdealGeometry, CSCRecoGeometryRcd>(edm::ESInputTag{});
77  }
78 
79  // Feed these value to where I need them
80  applyAlignment_ = p.getParameter<bool>("applyAlignment");
81  if (applyAlignment_) {
82  globalPositionToken_ = cc.consumesFrom<Alignments, GlobalPositionRcd>(edm::ESInputTag{"", alignmentsLabel_});
83  alignmentsToken_ = cc.consumesFrom<Alignments, CSCAlignmentRcd>(edm::ESInputTag{"", alignmentsLabel_});
84  alignmentErrorsToken_ =
85  cc.consumesFrom<AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd>(edm::ESInputTag{"", alignmentsLabel_});
86  }
87 
88  edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
89  << "Label '" << myLabel_ << "' " << (applyAlignment_ ? "looking for" : "IGNORING")
90  << " alignment labels '" << alignmentsLabel_ << "'.";
91 }
92 
94 
95 std::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
96  auto host = holder_.makeOrGet([this]() {
98  });
99 
101 
102  // Called whenever the alignments or alignment errors change
103 
104  if (applyAlignment_) {
105  // applyAlignment_ is scheduled for removal.
106  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
107  const auto& globalPosition = record.get(globalPositionToken_);
108  const auto& alignments = record.get(alignmentsToken_);
109  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
110  // Only apply alignment if values exist
111  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
112  edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
113  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
114  << "') empty: Geometry producer (label "
115  << "'" << myLabel_ << "') assumes fake and does not apply.";
116  } else {
117  GeometryAligner aligner;
118  aligner.applyAlignments<CSCGeometry>(
119  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
120  }
121  }
122  return host; // automatically converts to std::shared_ptr<CSCGeometry>
123 }
124 
125 void CSCGeometryESModule::initCSCGeometry_(const MuonGeometryRecord& record, std::shared_ptr<HostType>& host) {
126  if (useDDD_) {
127  host->ifRecordChanges<MuonNumberingRecord>(record, [&host, &record, this](auto const& rec) {
128  host->clear();
129  edm::ESTransientHandle<DDCompactView> cpv = record.getTransientHandle(cpvToken_);
130  const auto& mdc = rec.get(mdcToken_);
132  builder.build(*host, cpv.product(), mdc);
133  });
134  } else if (useDD4hep_) {
135  host->ifRecordChanges<MuonNumberingRecord>(record, [&host, &record, this](auto const& rec) {
136  host->clear();
138  const auto& mdc = rec.get(mdcTokendd4hep_);
140  builder.build(*host, cpv.product(), mdc);
141  });
142  } else {
143  bool recreateGeometry = false;
144 
145  host->ifRecordChanges<CSCRecoGeometryRcd>(record,
146  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
147 
148  host->ifRecordChanges<CSCRecoDigiParametersRcd>(record,
149  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
150 
151  if (recreateGeometry) {
152  host->clear();
153  const auto& rig = record.get(rigToken_);
154  const auto& rdp = record.get(rdpToken_);
155  CSCGeometryBuilder cscgb;
156  cscgb.build(*host, rig, rdp);
157  }
158  }
159 }
160 
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
CSCRecoDigiParameters
Definition: CSCRecoDigiParameters.h:18
CSCGeometryBuilder.h
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
CSCGeometryESModule::useGangedStripsInME1a
bool useGangedStripsInME1a
Definition: CSCGeometryESModule.h:79
CSCGeometryESModule::globalPositionToken_
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
Definition: CSCGeometryESModule.h:72
CSCGeometryESModule::CSCGeometryESModule
CSCGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: CSCGeometryESModule.cc:30
CSCGeometryESModule::useRealWireGeometry
bool useRealWireGeometry
Definition: CSCGeometryESModule.h:77
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
cscGeometry_cfi.debugV
debugV
Definition: cscGeometry_cfi.py:11
cc
query.host
host
Definition: query.py:115
CSCGeometryESModule.h
edm::ReusableObjectHolder::makeOrGet
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
Definition: ReusableObjectHolder.h:126
CSCGeometry
Definition: CSCGeometry.h:24
DetId
Definition: DetId.h:17
CSCGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: CSCGeometryESModule.h:74
CSCGeometryBuilder
Definition: CSCGeometryBuilder.h:20
cscGeometryOrcaCompare_cfi.useOnlyWiresInME1a
useOnlyWiresInME1a
Definition: cscGeometryOrcaCompare_cfi.py:19
cscGeometryOrcaCompare_cfi.useRealWireGeometry
useRealWireGeometry
Definition: cscGeometryOrcaCompare_cfi.py:20
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
CSCGeometryESModule::mdcTokendd4hep_
edm::ESGetToken< cms::MuonNumbering, MuonNumberingRecord > mdcTokendd4hep_
Definition: CSCGeometryESModule.h:67
CSCGeometryBuilder::build
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
Definition: CSCGeometryBuilder.cc:17
CSCGeometryESModule::useOnlyWiresInME1a
bool useOnlyWiresInME1a
Definition: CSCGeometryESModule.h:78
CSCGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: CSCGeometryESModule.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCGeometryESModule::useDD4hep_
bool useDD4hep_
Definition: CSCGeometryESModule.h:84
CSCAlignmentErrorExtendedRcd
Definition: CSCAlignmentErrorExtendedRcd.h:6
edm::ParameterSet
Definition: ParameterSet.h:36
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:32
MuonBaseNumber.h
CSCGeometryESModule::~CSCGeometryESModule
~CSCGeometryESModule() override
Destructor.
Definition: CSCGeometryESModule.cc:93
cms::MuonNumbering
Definition: DD4hep_MuonNumbering.h:37
CSCGeometryESModule::debugV
bool debugV
Definition: CSCGeometryESModule.h:81
cscGeometryInMTCC_cfi.useCentreTIOffsets
useCentreTIOffsets
Definition: cscGeometryInMTCC_cfi.py:8
CSCGeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: CSCGeometryESModule.h:63
CSCGeometryBuilderFromDDD.h
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
CSCGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, CSCAlignmentRcd > alignmentsToken_
Definition: CSCGeometryESModule.h:73
DD4hep_MuonNumbering.h
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
ModuleFactory.h
GeometryAligner.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
CSCGeometryBuilderFromDDD
Definition: CSCGeometryBuilderFromDDD.h:30
CSCGeometryESModule::cpvTokendd4hep_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokendd4hep_
Definition: CSCGeometryESModule.h:66
csc_dqm_sourceclient-live_cfg.useGangedStripsInME1a
useGangedStripsInME1a
Definition: csc_dqm_sourceclient-live_cfg.py:95
CSCGeometryESModule::useCentreTIOffsets
bool useCentreTIOffsets
Definition: CSCGeometryESModule.h:80
CSCGeometryESModule::produce
std::shared_ptr< CSCGeometry > produce(const MuonGeometryRecord &record)
Produce CSCGeometry.
Definition: CSCGeometryESModule.cc:95
cms::DDCompactView
Definition: DDCompactView.h:29
CSCGeometryESModule::rigToken_
edm::ESGetToken< RecoIdealGeometry, CSCRecoGeometryRcd > rigToken_
Definition: CSCGeometryESModule.h:69
CSCGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: CSCGeometryESModule.h:82
CSCGeometryESModule::rdpToken_
edm::ESGetToken< CSCRecoDigiParameters, CSCRecoDigiParametersRcd > rdpToken_
Definition: CSCGeometryESModule.h:70
DetId::Muon
Definition: DetId.h:26
CSCChamberSpecs.h
MuonNumberingRecord
Definition: MuonNumberingRecord.h:30
CSCGeometryESModule::myLabel_
const std::string myLabel_
Definition: CSCGeometryESModule.h:86
CSCGeometryESModule
Definition: CSCGeometryESModule.h:45
MuonDDDNumbering.h
Alignments
Definition: Alignments.h:10
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
CSCGeometryESModule::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: CSCGeometryESModule.h:61
GeometryAligner::applyAlignments
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28
CSCAlignmentRcd
Definition: CSCAlignmentRcd.h:6
CSCGeometryESModule::useDDD_
bool useDDD_
Definition: CSCGeometryESModule.h:83
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
CSCGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: CSCGeometryESModule.h:85
CSCRecoGeometryRcd
Definition: CSCRecoGeometryRcd.h:5
CSCGeometryESModule::HostType
edm::ESProductHost< CSCGeometry, MuonNumberingRecord, CSCRecoGeometryRcd, CSCRecoDigiParametersRcd > HostType
Definition: CSCGeometryESModule.h:57
CSCGeometryESModule::initCSCGeometry_
void initCSCGeometry_(const MuonGeometryRecord &, std::shared_ptr< HostType > &host)
Definition: CSCGeometryESModule.cc:125