CMS 3D CMS Logo

CSCGeometryESModule.cc
Go to the documentation of this file.
1 
2 #include "CSCGeometryESModule.h"
6 
9 
15 
16 // Alignments
23 
27 
28 #include <memory>
29 
30 using namespace edm;
31 
33  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
34  myLabel_(p.getParameter<std::string>("appendToDataLabel"))
35 {
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 
56  if ( useGangedStripsInME1a ) useOnlyWiresInME1a = false; // override possible inconsistentcy
57 
58  // Use the backed-out offsets that correct the CTI
59  useCentreTIOffsets = p.getParameter<bool>("useCentreTIOffsets");
60 
61  // Debug printout etc. in CSCGeometry etc.
62 
63  debugV = p.getUntrackedParameter<bool>("debugV", false);
64 
65  // Find out if using the DDD or CondDB Geometry source.
66  useDDD_ = p.getParameter<bool>("useDDD");
67 
68  // Feed these value to where I need them
69  applyAlignment_ = p.getParameter<bool>("applyAlignment");
70 
71 
72  edm::LogInfo("Geometry") << "@SUB=CSCGeometryESModule"
73  << "Label '" << myLabel_ << "' "
74  << (applyAlignment_ ? "looking for" : "IGNORING")
75  << " alignment labels '" << alignmentsLabel_ << "'.";
76  setWhatProduced(this);
77 }
78 
79 
81 
82 
83 std::shared_ptr<CSCGeometry> CSCGeometryESModule::produce(const MuonGeometryRecord& record) {
84 
85  auto host = holder_.makeOrGet([this]() {
86  return new HostType(debugV,
91  });
92 
93  initCSCGeometry_(record, host);
94 
95  // Called whenever the alignments or alignment errors change
96 
97  if ( applyAlignment_ ) {
98  // applyAlignment_ is scheduled for removal.
99  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
100  edm::ESHandle<Alignments> globalPosition;
101  record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
102  edm::ESHandle<Alignments> alignments;
103  record.getRecord<CSCAlignmentRcd>().get(alignmentsLabel_, alignments);
105  record.getRecord<CSCAlignmentErrorExtendedRcd>().get(alignmentsLabel_, alignmentErrors);
106  // Only apply alignment if values exist
107  if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
108  edm::LogInfo("Config") << "@SUB=CSCGeometryRecord::produce"
109  << "Alignment(Error)s and global position (label '"
110  << alignmentsLabel_ << "') empty: Geometry producer (label "
111  << "'" << myLabel_ << "') assumes fake and does not apply.";
112  } else {
113  GeometryAligner aligner;
114  aligner.applyAlignments<CSCGeometry>( &(*host), &(*alignments), &(*alignmentErrors),
115  align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)) );
116  }
117  }
118  return host; // automatically converts to std::shared_ptr<CSCGeometry>
119 }
120 
121 
122 void CSCGeometryESModule::initCSCGeometry_( const MuonGeometryRecord& record, std::shared_ptr<HostType>& host)
123 {
124  if ( useDDD_ ) {
125 
126  host->ifRecordChanges<MuonNumberingRecord>(record,
127  [this, &host, &record](auto const& rec) {
128  host->clear();
131  record.getRecord<IdealGeometryRecord>().get(cpv);
132  rec.get(mdc);
134  builder.build(*host, &(*cpv), *mdc);
135  });
136  } else {
137  bool recreateGeometry = false;
138 
139  host->ifRecordChanges<CSCRecoGeometryRcd>(record,
140  [&recreateGeometry](auto const& rec) {
141  recreateGeometry = true;
142  });
143 
144  host->ifRecordChanges<CSCRecoDigiParametersRcd>(record,
145  [&recreateGeometry](auto const& rec) {
146  recreateGeometry = true;
147  });
148 
149  if (recreateGeometry) {
150  host->clear();
153  record.getRecord<CSCRecoGeometryRcd>().get(rig);
154  record.getRecord<CSCRecoDigiParametersRcd>().get(rdp);
155  CSCGeometryBuilder cscgb;
156  cscgb.build(*host, *rig, *rdp);
157  }
158  }
159 }
160 
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:116
T getUntrackedParameter(std::string const &, T const &) const
host
Definition: query.py:115
edm::ESProductHost< CSCGeometry, MuonNumberingRecord, CSCRecoGeometryRcd, CSCRecoDigiParametersRcd > HostType
bool empty() const
Test of empty vector without having to look into internals:
Definition: Alignments.h:15
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_
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
void initCSCGeometry_(const MuonGeometryRecord &, std::shared_ptr< HostType > &host)
~CSCGeometryESModule() override
Destructor.
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
std::shared_ptr< CSCGeometry > produce(const MuonGeometryRecord &record)
Produce CSCGeometry.
Definition: DetId.h:18
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
bool empty() const
Test of empty vector without having to look into internals:
HLT enums.
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
edm::ReusableObjectHolder< HostType > holder_