CMS 3D CMS Logo

MisalignedTrackerESProducer.cc
Go to the documentation of this file.
1 // Framework
8 
9 // Conditions database
12 
13 // Geometry
19 
20 // Alignment
25 
26 // C++
27 #include <memory>
28 #include <algorithm>
29 
36 
38 public:
41 
44 
46  std::unique_ptr<TrackerGeometry> produce(const TrackerDigiGeometryRecord& iRecord);
47 
48 private:
52 
53  const bool theSaveToDB;
54  const bool
58 };
59 
60 //__________________________________________________________________________________________________
61 //__________________________________________________________________________________________________
62 //__________________________________________________________________________________________________
63 
64 //__________________________________________________________________________________________________
66  : theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
67  theSaveFakeScenario(p.getUntrackedParameter<bool>("saveFakeScenario")),
68  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
69  theAlignRecordName("TrackerAlignmentRcd"),
70  theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
71  auto cc = setWhatProduced(this);
72  geomDetToken_ = cc.consumes();
73  ptpToken_ = cc.consumes();
74  topoToken_ = cc.consumes();
75 }
76 
77 //__________________________________________________________________________________________________
79 
80 //__________________________________________________________________________________________________
81 std::unique_ptr<TrackerGeometry> MisalignedTrackerESProducer::produce(const TrackerDigiGeometryRecord& iRecord) {
82  //Retrieve tracker topology from geometry
83  const TrackerTopology* tTopo = &iRecord.get(topoToken_);
84 
85  edm::LogInfo("MisalignedTracker") << "Producer called";
86 
87  // Create the tracker geometry from ideal geometry
88  const GeometricDet* gD = &iRecord.get(geomDetToken_);
89  const PTrackerParameters& ptp = iRecord.get(ptpToken_);
90 
92  std::unique_ptr<TrackerGeometry> theTracker(trackerBuilder.build(gD, ptp, tTopo));
93 
94  // Create the alignable hierarchy
95  auto theAlignableTracker = std::make_unique<AlignableTracker>(&(*theTracker), tTopo);
96 
97  // Create misalignment scenario, apply to geometry
98  TrackerScenarioBuilder scenarioBuilder(&(*theAlignableTracker));
99  scenarioBuilder.applyScenario(theScenario);
100  Alignments* alignments = theAlignableTracker->alignments();
101  AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors();
102 
103  // Store result to EventSetup
104  GeometryAligner aligner;
105  aligner.applyAlignments<TrackerGeometry>(&(*theTracker),
106  alignments,
107  alignmentErrors,
108  AlignTransform()); // dummy global position
109 
110  // Write alignments to DB: have to sort beforhand!
111  if (theSaveToDB) {
112  // Call service
114  if (!poolDbService.isAvailable()) // Die if not available
115  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
116  if (theSaveFakeScenario) { // make empty!
117  alignments->clear();
118  alignmentErrors->clear();
119  }
120  poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(), theAlignRecordName);
121  poolDbService->writeOne<AlignmentErrorsExtended>(alignmentErrors, poolDbService->currentTime(), theErrorRecordName);
122  } else {
123  // poolDbService::writeOne takes over ownership
124  // we have to delete in the case that containers are not written
125  delete alignments;
126  delete alignmentErrors;
127  }
128 
129  edm::LogInfo("MisalignedTracker") << "Producer done";
130  return theTracker;
131 }
132 
AlignmentErrorsExtended.h
MisalignedTrackerESProducer::theSaveToDB
const bool theSaveToDB
Definition: MisalignedTrackerESProducer.cc:53
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MessageLogger.h
TrackerGeometry.h
PTrackerParameters
Definition: PTrackerParameters.h:6
ESHandle.h
TrackerScenarioBuilder
Builds a scenario from configuration and applies it to the alignable tracker.
Definition: TrackerScenarioBuilder.h:24
MisalignedTrackerESProducer::theAlignRecordName
const std::string theAlignRecordName
misalignment scenario
Definition: MisalignedTrackerESProducer.cc:57
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ESProducer.h
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
MisalignedTrackerESProducer::theErrorRecordName
const std::string theErrorRecordName
Definition: MisalignedTrackerESProducer.cc:57
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MisalignedTrackerESProducer
Definition: MisalignedTrackerESProducer.cc:37
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
PoolDBOutputService.h
TrackerScenarioBuilder.h
TrackerTopologyRcd.h
Service.h
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
MisalignedTrackerESProducer::produce
std::unique_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &iRecord)
Produce the misaligned tracker geometry and store it.
Definition: MisalignedTrackerESProducer.cc:81
TrackerScenarioBuilder::applyScenario
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
Definition: TrackerScenarioBuilder.cc:39
GeometricDet
Definition: GeometricDet.h:31
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
AlignTransform
Definition: AlignTransform.h:15
MisalignedTrackerESProducer::theSaveFakeScenario
const bool theSaveFakeScenario
whether or not writing to DB
Definition: MisalignedTrackerESProducer.cc:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
MisalignedTrackerESProducer::topoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: MisalignedTrackerESProducer.cc:51
edm::Service< cond::service::PoolDBOutputService >
MisalignedTrackerESProducer::geomDetToken_
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
Definition: MisalignedTrackerESProducer.cc:49
MisalignedTrackerESProducer::~MisalignedTrackerESProducer
~MisalignedTrackerESProducer() override
Destructor.
Definition: MisalignedTrackerESProducer.cc:78
MisalignedTrackerESProducer::ptpToken_
edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Definition: MisalignedTrackerESProducer.cc:50
cc
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
edm::ESGetToken< GeometricDet, IdealGeometryRecord >
ModuleFactory.h
GeometryAligner.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
MisalignedTrackerESProducer::theScenario
const edm::ParameterSet theScenario
if theSaveToDB is true, save a fake scenario (empty alignments), irrespective of the misalignment sce...
Definition: MisalignedTrackerESProducer.cc:56
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
Alignable.h
Exception.h
edm::ESProducer
Definition: ESProducer.h:104
TrackerGeomBuilderFromGeometricDet.h
TrackerGeomBuilderFromGeometricDet
Definition: TrackerGeomBuilderFromGeometricDet.h:17
AlignableTracker.h
cms::Exception
Definition: Exception.h:70
ParameterSet.h
MisalignedTrackerESProducer::MisalignedTrackerESProducer
MisalignedTrackerESProducer(const edm::ParameterSet &p)
Constructor.
Definition: MisalignedTrackerESProducer.cc:65
Alignments
Definition: Alignments.h:10
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
TrackerGeometry
Definition: TrackerGeometry.h:14