CMS 3D CMS Logo

MuonMisalignedProducer.cc
Go to the documentation of this file.
1 
13 // Framework
20 
21 // Conditions database
24 
25 // Alignment
34 
35 #include <memory>
36 
37 #include <iostream>
38 
40 public:
43 
45  ~MuonMisalignedProducer() override;
46 
48  void analyze(const edm::Event&, const edm::EventSetup&) override;
50  void saveToDB();
51 
52 private:
53  const bool theSaveToDB;
55 
59 
63 
70 };
71 
72 //__________________________________________________________________________________________________
74  : theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
75  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
76  theDTAlignRecordName("DTAlignmentRcd"),
77  theDTErrorRecordName("DTAlignmentErrorExtendedRcd"),
78  theCSCAlignRecordName("CSCAlignmentRcd"),
79  theCSCErrorRecordName("CSCAlignmentErrorExtendedRcd"),
80  theGEMAlignRecordName("GEMAlignmentRcd"),
81  theGEMErrorRecordName("GEMAlignmentErrorExtendedRcd"),
82  esTokenDT_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))),
83  esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))),
84  esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))) {}
85 
86 //__________________________________________________________________________________________________
88 
89 //__________________________________________________________________________________________________
91  edm::LogInfo("MisalignedMuon") << "Producer called";
92  // Create the Muon geometry from ideal geometry
93  edm::ESHandle<DTGeometry> theDTGeometry = eventSetup.getHandle(esTokenDT_);
94  edm::ESHandle<CSCGeometry> theCSCGeometry = eventSetup.getHandle(esTokenCSC_);
95  edm::ESHandle<GEMGeometry> theGEMGeometry = eventSetup.getHandle(esTokenGEM_);
96 
97  // Create the alignable hierarchy
98  AlignableMuon* theAlignableMuon = new AlignableMuon(&(*theDTGeometry), &(*theCSCGeometry), &(*theGEMGeometry));
99 
100  // Create misalignment scenario
101  MuonScenarioBuilder scenarioBuilder(theAlignableMuon);
102  scenarioBuilder.applyScenario(theScenario);
103 
104  // Get alignments and errors
105  dt_Alignments = *(theAlignableMuon->dtAlignments());
106  dt_AlignmentErrorsExtended = *(theAlignableMuon->dtAlignmentErrorsExtended());
107  csc_Alignments = *(theAlignableMuon->cscAlignments());
109  gem_Alignments = *(theAlignableMuon->gemAlignments());
111 
112  // Misalign the EventSetup geometry
113  /* GeometryAligner aligner;
114  aligner.applyAlignments<DTGeometry>(&(*theDTGeometry), dt_Alignments, dt_AlignmentErrorsExtended, AlignTransform());
115  aligner.applyAlignments<CSCGeometry>(
116  &(*theCSCGeometry), csc_Alignments, csc_AlignmentErrorsExtended, AlignTransform());
117  aligner.applyAlignments<GEMGeometry>(
118  &(*theGEMGeometry), gem_Alignments, gem_AlignmentErrorsExtended, AlignTransform());
119  */
120  // Write alignments to DB
121  if (theSaveToDB)
122  this->saveToDB();
123 
124  edm::LogInfo("MisalignedMuon") << "Producer done";
125 }
126 
127 //__________________________________________________________________________________________________
129  // Call service
131  if (!poolDbService.isAvailable()) // Die if not available
132  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
133 
134  // Store DT alignments and errors
135  poolDbService->writeOneIOV<Alignments>(dt_Alignments, poolDbService->beginOfTime(), theDTAlignRecordName);
136  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
138 
139  // Store CSC alignments and errors
140  poolDbService->writeOneIOV<Alignments>(csc_Alignments, poolDbService->beginOfTime(), theCSCAlignRecordName);
141  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
143  poolDbService->writeOneIOV<Alignments>(gem_Alignments, poolDbService->beginOfTime(), theGEMAlignRecordName);
144  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
146 }
147 //____________________________________________________________________________________________
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Builds a scenario from configuration and applies it to the alignable Muon.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > esTokenDT_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~MuonMisalignedProducer() override
Destructor.
const edm::ParameterSet theScenario
whether or not writing to DB
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > esTokenCSC_
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
AlignmentErrorsExtended dt_AlignmentErrorsExtended
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
Log< level::Info, false > LogInfo
void analyze(const edm::Event &, const edm::EventSetup &) override
Produce the misaligned Muon geometry and store iti.
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
Alignments * gemAlignments()
AlignmentErrorsExtended csc_AlignmentErrorsExtended
MuonMisalignedProducer(const edm::ParameterSet &)
Constructor.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
AlignmentErrorsExtended * gemAlignmentErrorsExtended()
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > esTokenGEM_
HLT enums.
void saveToDB()
Save alignemnts and error to database.
bool isAvailable() const
Definition: Service.h:40
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
std::string theDTAlignRecordName
misalignment scenario
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38
AlignmentErrorsExtended gem_AlignmentErrorsExtended
Definition: event.py:1