CMS 3D CMS Logo

MisalignedMuonESProducer.cc
Go to the documentation of this file.
1 
13 // Framework
22 
23 // Conditions database
26 
27 // Alignment
36 
37 #include <memory>
38 
40 public:
43 
45  ~MisalignedMuonESProducer() override;
46 
48  edm::ESProducts<std::unique_ptr<DTGeometry>, std::unique_ptr<CSCGeometry> > produce(const MuonGeometryRecord&);
49 
51  void saveToDB();
52 
53 private:
54  const bool theSaveToDB;
56 
59 
64 };
65 
66 //__________________________________________________________________________________________________
67 //__________________________________________________________________________________________________
68 //__________________________________________________________________________________________________
69 
70 //__________________________________________________________________________________________________
72  : theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
73  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
74  theDTAlignRecordName("DTAlignmentRcd"),
75  theDTErrorRecordName("DTAlignmentErrorExtendedRcd"),
76  theCSCAlignRecordName("CSCAlignmentRcd"),
77  theCSCErrorRecordName("CSCAlignmentErrorExtendedRcd") {
78  setWhatProduced(this);
79 }
80 
81 //__________________________________________________________________________________________________
83 
84 //__________________________________________________________________________________________________
86  const MuonGeometryRecord& iRecord) {
87  edm::LogInfo("MisalignedMuon") << "Producer called";
88 
89  // Create the Muon geometry from ideal geometry
91  iRecord.getRecord<IdealGeometryRecord>().get(cpv);
92 
94  iRecord.getRecord<MuonNumberingRecord>().get(mdc);
95 
98 
99  auto theDTGeometry = std::make_unique<DTGeometry>();
100  DTGeometryBuilder.build(*theDTGeometry, &(*cpv), *mdc);
101  auto theCSCGeometry = std::make_unique<CSCGeometry>();
102  CSCGeometryBuilder.build(*theCSCGeometry, &(*cpv), *mdc);
103 
104  // Create the alignable hierarchy
105  AlignableMuon* theAlignableMuon = new AlignableMuon(&(*theDTGeometry), &(*theCSCGeometry));
106 
107  // Create misalignment scenario
108  MuonScenarioBuilder scenarioBuilder(theAlignableMuon);
109  scenarioBuilder.applyScenario(theScenario);
110 
111  // Get alignments and errors
112  dt_Alignments = theAlignableMuon->dtAlignments();
114  csc_Alignments = theAlignableMuon->cscAlignments();
116 
117  // Misalign the EventSetup geometry
118  GeometryAligner aligner;
119 
121  aligner.applyAlignments<CSCGeometry>(
123 
124  // Write alignments to DB
125  if (theSaveToDB)
126  this->saveToDB();
127 
128  edm::LogInfo("MisalignedMuon") << "Producer done";
129 
130  return edm::es::products(std::move(theDTGeometry), std::move(theCSCGeometry));
131 }
132 
133 //__________________________________________________________________________________________________
135  // Call service
137  if (!poolDbService.isAvailable()) // Die if not available
138  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
139 
140  // Store DT alignments and errors
141  poolDbService->writeOne<Alignments>(&(*dt_Alignments), poolDbService->beginOfTime(), theDTAlignRecordName);
142  poolDbService->writeOne<AlignmentErrorsExtended>(
143  &(*dt_AlignmentErrorsExtended), poolDbService->beginOfTime(), theDTErrorRecordName);
144 
145  // Store CSC alignments and errors
146  poolDbService->writeOne<Alignments>(&(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName);
147  poolDbService->writeOne<AlignmentErrorsExtended>(
148  &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName);
149 }
150 //__________________________________________________________________________________________________
151 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
Builds a scenario from configuration and applies it to the alignable Muon.
void saveToDB()
Save alignemnts and error to database.
Class to update a given geometry with a set of alignments.
std::string theDTAlignRecordName
misalignment scenario
AlignmentErrorsExtended * dt_AlignmentErrorsExtended
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&...args)
Definition: ESProducts.h:128
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
AlignmentErrorsExtended * csc_AlignmentErrorsExtended
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
bool isAvailable() const
Definition: Service.h:40
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
HLT enums.
MisalignedMuonESProducer(const edm::ParameterSet &p)
Constructor.
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
edm::ESProducts< std::unique_ptr< DTGeometry >, std::unique_ptr< CSCGeometry > > produce(const MuonGeometryRecord &)
Produce the misaligned Muon geometry and store it.
const edm::ParameterSet theScenario
whether or not writing to DB
Constructor of the full muon geometry.
Definition: AlignableMuon.h:33
def move(src, dest)
Definition: eostools.py:511
~MisalignedMuonESProducer() override
Destructor.