CMS 3D CMS Logo

MisalignedMuonESProducer.cc
Go to the documentation of this file.
1 
13 
14 // Framework
23 
24 // Conditions database
27 
28 // Alignment
37 
38 #include <memory>
39 
40 
42 {
43 public:
44 
47 
49  ~MisalignedMuonESProducer() override;
50 
53  std::unique_ptr<CSCGeometry> > produce( const MuonGeometryRecord& );
54 
56  void saveToDB();
57 
58 private:
59  const bool theSaveToDB;
61 
64 
69 
70 };
71 
72 //__________________________________________________________________________________________________
73 //__________________________________________________________________________________________________
74 //__________________________________________________________________________________________________
75 
76 
77 //__________________________________________________________________________________________________
79  theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
80  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
81  theDTAlignRecordName( "DTAlignmentRcd" ),
82  theDTErrorRecordName( "DTAlignmentErrorExtendedRcd" ),
83  theCSCAlignRecordName( "CSCAlignmentRcd" ),
84  theCSCErrorRecordName( "CSCAlignmentErrorExtendedRcd" )
85 {
86 
87  setWhatProduced(this);
88 
89 }
90 
91 
92 //__________________________________________________________________________________________________
94 
95 
96 //__________________________________________________________________________________________________
97 edm::ESProducts< std::unique_ptr<DTGeometry>, std::unique_ptr<CSCGeometry> >
99 {
100 
101  edm::LogInfo("MisalignedMuon") << "Producer called";
102 
103 
104  // Create the Muon geometry from ideal geometry
106  iRecord.getRecord<IdealGeometryRecord>().get( cpv );
107 
109  iRecord.getRecord<MuonNumberingRecord>().get(mdc);
110 
113 
114  auto theDTGeometry = std::make_unique<DTGeometry>();
115  DTGeometryBuilder.build(*theDTGeometry, &(*cpv), *mdc);
116  auto theCSCGeometry = std::make_unique<CSCGeometry>();
117  CSCGeometryBuilder.build(*theCSCGeometry, &(*cpv), *mdc);
118 
119  // Create the alignable hierarchy
120  AlignableMuon* theAlignableMuon = new AlignableMuon( &(*theDTGeometry) , &(*theCSCGeometry) );
121 
122  // Create misalignment scenario
123  MuonScenarioBuilder scenarioBuilder( theAlignableMuon );
124  scenarioBuilder.applyScenario( theScenario );
125 
126  // Get alignments and errors
127  dt_Alignments = theAlignableMuon->dtAlignments() ;
129  csc_Alignments = theAlignableMuon->cscAlignments();
131 
132 
133  // Misalign the EventSetup geometry
134  GeometryAligner aligner;
135 
136  aligner.applyAlignments<DTGeometry>( &(*theDTGeometry),
137  dt_Alignments,
139  AlignTransform() );
140  aligner.applyAlignments<CSCGeometry>( &(*theCSCGeometry ),
143  AlignTransform() );
144 
145  // Write alignments to DB
146  if (theSaveToDB) this->saveToDB();
147 
148  edm::LogInfo("MisalignedMuon") << "Producer done";
149 
150  return edm::es::products( std::move(theDTGeometry), std::move(theCSCGeometry) );
151 }
152 
153 
154 //__________________________________________________________________________________________________
156 {
157 
158  // Call service
160  if( !poolDbService.isAvailable() ) // Die if not available
161  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
162 
163  // Store DT alignments and errors
164  poolDbService->writeOne<Alignments>( &(*dt_Alignments), poolDbService->beginOfTime(), theDTAlignRecordName);
165  poolDbService->writeOne<AlignmentErrorsExtended>( &(*dt_AlignmentErrorsExtended), poolDbService->beginOfTime(), theDTErrorRecordName);
166 
167  // Store CSC alignments and errors
168  poolDbService->writeOne<Alignments>( &(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName);
169  poolDbService->writeOne<AlignmentErrorsExtended>( &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName);
170 
171 }
172 //__________________________________________________________________________________________________
173 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
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:37
def move(src, dest)
Definition: eostools.py:511
~MisalignedMuonESProducer() override
Destructor.