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();
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->writeOne<Alignments>(&(*dt_Alignments), poolDbService->beginOfTime(), theDTAlignRecordName);
136  poolDbService->writeOne<AlignmentErrorsExtended>(
137  &(*dt_AlignmentErrorsExtended), poolDbService->beginOfTime(), theDTErrorRecordName);
138 
139  // Store CSC alignments and errors
140  poolDbService->writeOne<Alignments>(&(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName);
141  poolDbService->writeOne<AlignmentErrorsExtended>(
142  &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName);
143  poolDbService->writeOne<Alignments>(&(*gem_Alignments), poolDbService->beginOfTime(), theGEMAlignRecordName);
144  poolDbService->writeOne<AlignmentErrorsExtended>(
145  &(*gem_AlignmentErrorsExtended), poolDbService->beginOfTime(), theGEMErrorRecordName);
146 }
147 //____________________________________________________________________________________________
MuonMisalignedProducer::theGEMAlignRecordName
std::string theGEMAlignRecordName
Definition: MuonMisalignedProducer.cc:58
AlignableMuon::dtAlignmentErrorsExtended
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
Definition: AlignableMuon.cc:561
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
MessageLogger.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
ESHandle.h
MuonMisalignedProducer::esTokenGEM_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > esTokenGEM_
Definition: MuonMisalignedProducer.cc:62
ESInputTag
edm
HLT enums.
Definition: AlignableModifier.h:19
MuonMisalignedProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Produce the misaligned Muon geometry and store iti.
Definition: MuonMisalignedProducer.cc:90
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonMisalignedProducer::MuonMisalignedProducer
MuonMisalignedProducer(const edm::ParameterSet &)
Constructor.
Definition: MuonMisalignedProducer.cc:73
AlignableMuon::cscAlignments
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
Definition: AlignableMuon.cc:568
MuonMisalignedProducer::theGEMErrorRecordName
std::string theGEMErrorRecordName
Definition: MuonMisalignedProducer.cc:58
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
MuonMisalignedProducer::gem_AlignmentErrorsExtended
AlignmentErrorsExtended * gem_AlignmentErrorsExtended
Definition: MuonMisalignedProducer.cc:69
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MuonMisalignedProducer::saveToDB
void saveToDB()
Save alignemnts and error to database.
Definition: MuonMisalignedProducer.cc:128
AlignableMuon::dtAlignments
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
Definition: AlignableMuon.cc:554
MuonScenarioBuilder.h
align::AlignableMuon
Definition: StructureType.h:90
MakerMacros.h
PoolDBOutputService.h
MuonScenarioBuilder::applyScenario
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
Definition: MuonScenarioBuilder.cc:37
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
MuonMisalignedProducer::theDTAlignRecordName
std::string theDTAlignRecordName
misalignment scenario
Definition: MuonMisalignedProducer.cc:56
MuonMisalignedProducer
Definition: MuonMisalignedProducer.cc:39
edm::ESHandle< DTGeometry >
AlignableMuon::gemAlignments
Alignments * gemAlignments()
Definition: AlignableMuon.cc:597
MuonMisalignedProducer::csc_Alignments
Alignments * csc_Alignments
Definition: MuonMisalignedProducer.cc:66
MuonMisalignedProducer::csc_AlignmentErrorsExtended
AlignmentErrorsExtended * csc_AlignmentErrorsExtended
Definition: MuonMisalignedProducer.cc:67
MuonMisalignedProducer::theSaveToDB
const bool theSaveToDB
Definition: MuonMisalignedProducer.cc:53
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
MuonMisalignedProducer::esTokenDT_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > esTokenDT_
Definition: MuonMisalignedProducer.cc:60
AlignableMuon.h
AlignableMuon
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38
edm::Service< cond::service::PoolDBOutputService >
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
MuonMisalignedProducer::theDTErrorRecordName
std::string theDTErrorRecordName
Definition: MuonMisalignedProducer.cc:56
AlignableMuon::gemAlignmentErrorsExtended
AlignmentErrorsExtended * gemAlignmentErrorsExtended()
Definition: AlignableMuon.cc:608
edm::EventSetup
Definition: EventSetup.h:58
MuonMisalignedProducer::dt_Alignments
Alignments * dt_Alignments
Definition: MuonMisalignedProducer.cc:64
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
edm::ESGetToken< DTGeometry, MuonGeometryRecord >
MuonMisalignedProducer::theCSCAlignRecordName
std::string theCSCAlignRecordName
Definition: MuonMisalignedProducer.cc:57
GEMGeometry.h
GeometryAligner.h
MuonMisalignedProducer::esTokenCSC_
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > esTokenCSC_
Definition: MuonMisalignedProducer.cc:61
MuonMisalignedProducer::gem_Alignments
Alignments * gem_Alignments
Definition: MuonMisalignedProducer.cc:68
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
Alignable.h
MuonMisalignedProducer::~MuonMisalignedProducer
~MuonMisalignedProducer() override
Destructor.
Definition: MuonMisalignedProducer.cc:87
Exception.h
MuonMisalignedProducer::theCSCErrorRecordName
std::string theCSCErrorRecordName
Definition: MuonMisalignedProducer.cc:57
cms::Exception
Definition: Exception.h:70
ParameterSet.h
AlignableMuon::cscAlignmentErrorsExtended
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
Definition: AlignableMuon.cc:580
MuonGeometryRecord.h
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MuonMisalignedProducer::dt_AlignmentErrorsExtended
AlignmentErrorsExtended * dt_AlignmentErrorsExtended
Definition: MuonMisalignedProducer.cc:65
edm::Event
Definition: Event.h:73
Alignments
Definition: Alignments.h:10
MuonMisalignedProducer::theScenario
const edm::ParameterSet theScenario
whether or not writing to DB
Definition: MuonMisalignedProducer.cc:54
MuonScenarioBuilder
Builds a scenario from configuration and applies it to the alignable Muon.
Definition: MuonScenarioBuilder.h:19
CSCGeometry.h