CMS 3D CMS Logo

CSCGeometryESModule.cc
Go to the documentation of this file.
1 
2 #include "CSCGeometryESModule.h"
6 
8 
11 
12 #include <memory>
13 
14 using namespace edm;
15 
17  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
18  myLabel_(p.getParameter<std::string>("appendToDataLabel")) {
19  auto cc = setWhatProduced(this);
20 
21  // Choose wire geometry modelling
22  // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
23  // in the DDD Geometry.
24  // Default as of transition to CMSSW is to use real values.
25  // Alternative is to use pseudo-values which match reasonably closely
26  // the calculated geometry values used up to and including ORCA_8_8_1.
27  // (This was the default in ORCA.)
28 
29  useRealWireGeometry = p.getParameter<bool>("useRealWireGeometry");
30 
31  // Suppress strips altogether in ME1a region of ME11?
32 
33  useOnlyWiresInME1a = p.getParameter<bool>("useOnlyWiresInME1a");
34 
35  // Allow strips in ME1a region of ME11 but gang them?
36  // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
37 
38  useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
39 
40  if (useGangedStripsInME1a)
41  useOnlyWiresInME1a = false; // override possible inconsistentcy
42 
43  // Use the backed-out offsets that correct the CTI
44  useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets");
45 
46  // Debug printout etc. in CSCGeometry etc.
47 
48  debugV = p.getUntrackedParameter<bool>("debugV", false);
49 
50  // Find out if using the DDD or CondDB Geometry source.
51  useDDD_ = p.getParameter<bool>("useDDD");
52  if (useDDD_) {
55  } else {
58  }
59 
60  // Feed these value to where I need them
61  applyAlignment_ = p.getParameter<bool>("applyAlignment");
62  if (applyAlignment_) {
67  }
68 
69  edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
70  << "Label '" << myLabel_ << "' " << (applyAlignment_ ? "looking for" : "IGNORING")
71  << " alignment labels '" << alignmentsLabel_ << "'.";
72 }
73 
75 
76 std::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
77  auto host = holder_.makeOrGet([this]() {
79  });
80 
81  initCSCGeometry_(record, host);
82 
83  // Called whenever the alignments or alignment errors change
84 
85  if (applyAlignment_) {
86  // applyAlignment_ is scheduled for removal.
87  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
88  const auto& globalPosition = record.get(globalPositionToken_);
89  const auto& alignments = record.get(alignmentsToken_);
90  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
91  // Only apply alignment if values exist
92  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
93  edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
94  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
95  << "') empty: Geometry producer (label "
96  << "'" << myLabel_ << "') assumes fake and does not apply.";
97  } else {
98  GeometryAligner aligner;
100  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
101  }
102  }
103  return host; // automatically converts to std::shared_ptr<CSCGeometry>
104 }
105 
106 void CSCGeometryESModule::initCSCGeometry_(const MuonGeometryRecord& record, std::shared_ptr<HostType>& host) {
107  if (useDDD_) {
108  host->ifRecordChanges<MuonNumberingRecord>(record, [&host, &record, this](auto const& rec) {
109  host->clear();
111  const auto& mdc = rec.get(mdcToken_);
113  builder.build(*host, cpv.product(), mdc);
114  });
115  } else {
116  bool recreateGeometry = false;
117 
118  host->ifRecordChanges<CSCRecoGeometryRcd>(record,
119  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
120 
121  host->ifRecordChanges<CSCRecoDigiParametersRcd>(record,
122  [&recreateGeometry](auto const& rec) { recreateGeometry = true; });
123 
124  if (recreateGeometry) {
125  host->clear();
126  const auto& rig = record.get(rigToken_);
127  const auto& rdp = record.get(rdpToken_);
128  CSCGeometryBuilder cscgb;
129  cscgb.build(*host, rig, rdp);
130  }
131  }
132 }
133 
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
T getUntrackedParameter(std::string const &, T const &) const
host
Definition: query.py:115
edm::ESGetToken< Alignments, CSCAlignmentRcd > alignmentsToken_
edm::ESProductHost< CSCGeometry, MuonNumberingRecord, CSCRecoGeometryRcd, CSCRecoDigiParametersRcd > HostType
CSCGeometryESModule(const edm::ParameterSet &p)
Constructor.
const std::string alignmentsLabel_
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
const std::string myLabel_
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
edm::ESGetToken< CSCRecoDigiParameters, CSCRecoDigiParametersRcd > rdpToken_
void initCSCGeometry_(const MuonGeometryRecord &, std::shared_ptr< HostType > &host)
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
~CSCGeometryESModule() override
Destructor.
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
std::shared_ptr< CSCGeometry > produce(const MuonGeometryRecord &record)
Produce CSCGeometry.
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > alignmentErrorsToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: DetId.h:17
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
T const * product() const
HLT enums.
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
edm::ESGetToken< MuonDDDConstants, MuonNumberingRecord > mdcToken_
edm::ReusableObjectHolder< HostType > holder_
edm::ESGetToken< RecoIdealGeometry, CSCRecoGeometryRcd > rigToken_