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 {
20  auto cc = setWhatProduced(this);
21 
22  // Choose wire geometry modelling
23  // We now _require_ some wire geometry specification in the CSCOrcaSpec.xml file
24  // in the DDD Geometry.
25  // Default as of transition to CMSSW is to use real values.
26  // Alternative is to use pseudo-values which match reasonably closely
27  // the calculated geometry values used up to and including ORCA_8_8_1.
28  // (This was the default in ORCA.)
29 
30  useRealWireGeometry = p.getParameter<bool>("useRealWireGeometry");
31 
32  // Suppress strips altogether in ME1a region of ME11?
33 
34  useOnlyWiresInME1a = p.getParameter<bool>("useOnlyWiresInME1a");
35 
36  // Allow strips in ME1a region of ME11 but gang them?
37  // Default is now to treat ME1a with ganged strips (e.g. in clusterizer)
38 
39  useGangedStripsInME1a = p.getParameter<bool>("useGangedStripsInME1a");
40 
41  if ( useGangedStripsInME1a ) 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  }
56  else {
59  }
60 
61  // Feed these value to where I need them
62  applyAlignment_ = p.getParameter<bool>("applyAlignment");
63  if(applyAlignment_) {
67  }
68 
69 
70  edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
71  << "Label '" << myLabel_ << "' "
72  << (applyAlignment_ ? "looking for" : "IGNORING")
73  << " alignment labels '" << alignmentsLabel_ << "'.";
74 }
75 
76 
78 
79 
80 std::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
81 
82  auto host = holder_.makeOrGet([this]() {
83  return new HostType(debugV,
88  });
89 
90  initCSCGeometry_(record, host);
91 
92  // Called whenever the alignments or alignment errors change
93 
94  if ( applyAlignment_ ) {
95  // applyAlignment_ is scheduled for removal.
96  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
97  const auto& globalPosition = record.get(globalPositionToken_);
98  const auto& alignments = record.get(alignmentsToken_);
99  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
100  // Only apply alignment if values exist
101  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
102  edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
103  << "Alignment(Error)s and global position (label '"
104  << alignmentsLabel_ << "') empty: Geometry producer (label "
105  << "'" << myLabel_ << "') assumes fake and does not apply.";
106  } else {
107  GeometryAligner aligner;
108  aligner.applyAlignments<CSCGeometry>( &(*host), &alignments, &alignmentErrors,
109  align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)) );
110  }
111  }
112  return host; // automatically converts to std::shared_ptr<CSCGeometry>
113 }
114 
115 
116 void CSCGeometryESModule::initCSCGeometry_( const MuonGeometryRecord& record, std::shared_ptr<HostType>& host)
117 {
118  if ( useDDD_ ) {
119 
120  host->ifRecordChanges<MuonNumberingRecord>(record,
121  [&host, &record, this](auto const& rec) {
122  host->clear();
124  const auto& mdc = rec.get(mdcToken_);
126  builder.build(*host, cpv.product(), mdc);
127  });
128  } else {
129  bool recreateGeometry = false;
130 
131  host->ifRecordChanges<CSCRecoGeometryRcd>(record,
132  [&recreateGeometry](auto const& rec) {
133  recreateGeometry = true;
134  });
135 
136  host->ifRecordChanges<CSCRecoDigiParametersRcd>(record,
137  [&recreateGeometry](auto const& rec) {
138  recreateGeometry = true;
139  });
140 
141  if (recreateGeometry) {
142  host->clear();
143  const auto& rig = record.get(rigToken_);
144  const auto& rdp = record.get(rdpToken_);
145  CSCGeometryBuilder cscgb;
146  cscgb.build(*host, rig, rdp);
147  }
148  }
149 }
150 
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
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
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
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< CSCGeometry > produce(const MuonGeometryRecord &record)
Produce CSCGeometry.
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > alignmentErrorsToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: DetId.h:18
#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_