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 <boost/shared_ptr.hpp>
39 #include <memory>
40 
41 
43 {
44 public:
45 
48 
50  virtual ~MisalignedMuonESProducer();
51 
54  boost::shared_ptr<CSCGeometry> > produce( const MuonGeometryRecord& );
55 
57  void saveToDB();
58 
59 private:
60  const bool theSaveToDB;
62 
65 
66  boost::shared_ptr<DTGeometry> theDTGeometry;
67  boost::shared_ptr<CSCGeometry> theCSCGeometry;
68 
73 
74 };
75 
76 //__________________________________________________________________________________________________
77 //__________________________________________________________________________________________________
78 //__________________________________________________________________________________________________
79 
80 
81 //__________________________________________________________________________________________________
83  theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
84  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
85  theDTAlignRecordName( "DTAlignmentRcd" ),
86  theDTErrorRecordName( "DTAlignmentErrorExtendedRcd" ),
87  theCSCAlignRecordName( "CSCAlignmentRcd" ),
88  theCSCErrorRecordName( "CSCAlignmentErrorExtendedRcd" )
89 {
90 
91  setWhatProduced(this);
92 
93 }
94 
95 
96 //__________________________________________________________________________________________________
98 
99 
100 //__________________________________________________________________________________________________
101 edm::ESProducts< boost::shared_ptr<DTGeometry>, boost::shared_ptr<CSCGeometry> >
103 {
104 
105  edm::LogInfo("MisalignedMuon") << "Producer called";
106 
107 
108  // Create the Muon geometry from ideal geometry
110  iRecord.getRecord<IdealGeometryRecord>().get( cpv );
111 
113  iRecord.getRecord<MuonNumberingRecord>().get(mdc);
114 
115  DTGeometryBuilderFromDDD DTGeometryBuilder;
117 
118  theDTGeometry = boost::shared_ptr<DTGeometry>(new DTGeometry );
119  DTGeometryBuilder.build(theDTGeometry, &(*cpv), *mdc );
120  theCSCGeometry = boost::shared_ptr<CSCGeometry>( new CSCGeometry );
121  CSCGeometryBuilder.build( theCSCGeometry, &(*cpv), *mdc );
122 
123 
124  // Create the alignable hierarchy
125  AlignableMuon* theAlignableMuon = new AlignableMuon( &(*theDTGeometry) , &(*theCSCGeometry) );
126 
127  // Create misalignment scenario
128  MuonScenarioBuilder scenarioBuilder( theAlignableMuon );
129  scenarioBuilder.applyScenario( theScenario );
130 
131  // Get alignments and errors
132  dt_Alignments = theAlignableMuon->dtAlignments() ;
134  csc_Alignments = theAlignableMuon->cscAlignments();
136 
137 
138  // Misalign the EventSetup geometry
139  GeometryAligner aligner;
140 
141  aligner.applyAlignments<DTGeometry>( &(*theDTGeometry),
142  dt_Alignments,
144  AlignTransform() );
145  aligner.applyAlignments<CSCGeometry>( &(*theCSCGeometry ),
148  AlignTransform() );
149 
150  // Write alignments to DB
151  if (theSaveToDB) this->saveToDB();
152 
153  edm::LogInfo("MisalignedMuon") << "Producer done";
154 
155  return edm::es::products( theDTGeometry, theCSCGeometry );
156 
157 }
158 
159 
160 //__________________________________________________________________________________________________
162 {
163 
164  // Call service
166  if( !poolDbService.isAvailable() ) // Die if not available
167  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
168 
169  // Store DT alignments and errors
170  poolDbService->writeOne<Alignments>( &(*dt_Alignments), poolDbService->beginOfTime(), theDTAlignRecordName);
171  poolDbService->writeOne<AlignmentErrorsExtended>( &(*dt_AlignmentErrorsExtended), poolDbService->beginOfTime(), theDTErrorRecordName);
172 
173  // Store CSC alignments and errors
174  poolDbService->writeOne<Alignments>( &(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName);
175  poolDbService->writeOne<AlignmentErrorsExtended>( &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName);
176 
177 }
178 //__________________________________________________________________________________________________
179 
Builds a scenario from configuration and applies it to the alignable Muon.
boost::shared_ptr< DTGeometry > theDTGeometry
void saveToDB()
Save alignemnts and error to database.
Class to update a given geometry with a set of alignments.
std::string theDTAlignRecordName
misalignment scenario
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
AlignmentErrorsExtended * dt_AlignmentErrorsExtended
void build(boost::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
edm::ESProducts< boost::shared_ptr< DTGeometry >, boost::shared_ptr< CSCGeometry > > produce(const MuonGeometryRecord &)
Produce the misaligned Muon geometry and store it.
Alignments * dtAlignments()
AlignmentErrorsExtended * csc_AlignmentErrorsExtended
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
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(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
Alignments * cscAlignments()
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
MisalignedMuonESProducer(const edm::ParameterSet &p)
Constructor.
virtual ~MisalignedMuonESProducer()
Destructor.
const edm::ParameterSet theScenario
whether or not writing to DB
boost::shared_ptr< CSCGeometry > theCSCGeometry
Constructor of the full muon geometry.
Definition: AlignableMuon.h:36
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the Muon.