CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual ~MisalignedMuonESProducer();
50 
53  std::shared_ptr<CSCGeometry> > produce( const MuonGeometryRecord& );
54 
56  void saveToDB();
57 
58 private:
59  const bool theSaveToDB;
61 
64 
65  std::shared_ptr<DTGeometry> theDTGeometry;
66  std::shared_ptr<CSCGeometry> theCSCGeometry;
67 
72 
73 };
74 
75 //__________________________________________________________________________________________________
76 //__________________________________________________________________________________________________
77 //__________________________________________________________________________________________________
78 
79 
80 //__________________________________________________________________________________________________
82  theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
83  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
84  theDTAlignRecordName( "DTAlignmentRcd" ),
85  theDTErrorRecordName( "DTAlignmentErrorExtendedRcd" ),
86  theCSCAlignRecordName( "CSCAlignmentRcd" ),
87  theCSCErrorRecordName( "CSCAlignmentErrorExtendedRcd" )
88 {
89 
90  setWhatProduced(this);
91 
92 }
93 
94 
95 //__________________________________________________________________________________________________
97 
98 
99 //__________________________________________________________________________________________________
100 edm::ESProducts< std::shared_ptr<DTGeometry>, std::shared_ptr<CSCGeometry> >
102 {
103 
104  edm::LogInfo("MisalignedMuon") << "Producer called";
105 
106 
107  // Create the Muon geometry from ideal geometry
109  iRecord.getRecord<IdealGeometryRecord>().get( cpv );
110 
112  iRecord.getRecord<MuonNumberingRecord>().get(mdc);
113 
114  DTGeometryBuilderFromDDD DTGeometryBuilder;
116 
117  theDTGeometry = std::make_shared<DTGeometry>();
118  DTGeometryBuilder.build(theDTGeometry, &(*cpv), *mdc );
119  theCSCGeometry = std::make_shared<CSCGeometry>();
120  CSCGeometryBuilder.build( theCSCGeometry, &(*cpv), *mdc );
121 
122 
123  // Create the alignable hierarchy
124  AlignableMuon* theAlignableMuon = new AlignableMuon( &(*theDTGeometry) , &(*theCSCGeometry) );
125 
126  // Create misalignment scenario
127  MuonScenarioBuilder scenarioBuilder( theAlignableMuon );
128  scenarioBuilder.applyScenario( theScenario );
129 
130  // Get alignments and errors
131  dt_Alignments = theAlignableMuon->dtAlignments() ;
133  csc_Alignments = theAlignableMuon->cscAlignments();
135 
136 
137  // Misalign the EventSetup geometry
138  GeometryAligner aligner;
139 
140  aligner.applyAlignments<DTGeometry>( &(*theDTGeometry),
141  dt_Alignments,
143  AlignTransform() );
144  aligner.applyAlignments<CSCGeometry>( &(*theCSCGeometry ),
147  AlignTransform() );
148 
149  // Write alignments to DB
150  if (theSaveToDB) this->saveToDB();
151 
152  edm::LogInfo("MisalignedMuon") << "Producer done";
153 
154  return edm::es::products( theDTGeometry, theCSCGeometry );
155 
156 }
157 
158 
159 //__________________________________________________________________________________________________
161 {
162 
163  // Call service
165  if( !poolDbService.isAvailable() ) // Die if not available
166  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
167 
168  // Store DT alignments and errors
169  poolDbService->writeOne<Alignments>( &(*dt_Alignments), poolDbService->beginOfTime(), theDTAlignRecordName);
170  poolDbService->writeOne<AlignmentErrorsExtended>( &(*dt_AlignmentErrorsExtended), poolDbService->beginOfTime(), theDTErrorRecordName);
171 
172  // Store CSC alignments and errors
173  poolDbService->writeOne<Alignments>( &(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName);
174  poolDbService->writeOne<AlignmentErrorsExtended>( &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName);
175 
176 }
177 //__________________________________________________________________________________________________
178 
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
std::shared_ptr< CSCGeometry > theCSCGeometry
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
AlignmentErrorsExtended * dt_AlignmentErrorsExtended
Alignments * dtAlignments()
AlignmentErrorsExtended * csc_AlignmentErrorsExtended
edm::ESProducts< std::shared_ptr< DTGeometry >, std::shared_ptr< CSCGeometry > > produce(const MuonGeometryRecord &)
Produce the misaligned Muon geometry and store it.
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
std::shared_ptr< DTGeometry > theDTGeometry
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void build(std::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
Alignments * cscAlignments()
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
MisalignedMuonESProducer(const edm::ParameterSet &p)
Constructor.
void build(std::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
virtual ~MisalignedMuonESProducer()
Destructor.
const edm::ParameterSet theScenario
whether or not writing to DB
Constructor of the full muon geometry.
Definition: AlignableMuon.h:37
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the Muon.