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:
53 
54  const bool theSaveToDB;
55  const bool
59 };
60 
61 //__________________________________________________________________________________________________
62 //__________________________________________________________________________________________________
63 //__________________________________________________________________________________________________
64 
65 //__________________________________________________________________________________________________
67  : theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
68  theSaveFakeScenario(p.getUntrackedParameter<bool>("saveFakeScenario")),
69  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
70  theAlignRecordName("TrackerAlignmentRcd"),
71  theErrorRecordName("TrackerAlignmentErrorExtendedRcd") {
72  auto cc = setWhatProduced(this);
73  geomDetToken_ = cc.consumes();
74  ptpToken_ = cc.consumes();
75  ptitpToken_ = cc.consumes();
76  topoToken_ = cc.consumes();
77 }
78 
79 //__________________________________________________________________________________________________
81 
82 //__________________________________________________________________________________________________
83 std::unique_ptr<TrackerGeometry> MisalignedTrackerESProducer::produce(const TrackerDigiGeometryRecord& iRecord) {
84  //Retrieve tracker topology from geometry
85  const TrackerTopology* tTopo = &iRecord.get(topoToken_);
86 
87  edm::LogInfo("MisalignedTracker") << "Producer called";
88 
89  // Create the tracker geometry from ideal geometry
90  const GeometricDet* gD = &iRecord.get(geomDetToken_);
91  const PTrackerParameters& ptp = iRecord.get(ptpToken_);
92  const PTrackerAdditionalParametersPerDet* ptitp = &iRecord.get(ptitpToken_);
93 
95  std::unique_ptr<TrackerGeometry> theTracker(trackerBuilder.build(gD, ptitp, ptp, tTopo));
96 
97  // Create the alignable hierarchy
98  auto theAlignableTracker = std::make_unique<AlignableTracker>(&(*theTracker), tTopo);
99 
100  // Create misalignment scenario, apply to geometry
101  TrackerScenarioBuilder scenarioBuilder(&(*theAlignableTracker));
102  scenarioBuilder.applyScenario(theScenario);
103  Alignments alignments = *(theAlignableTracker->alignments());
104  AlignmentErrorsExtended alignmentErrors = *(theAlignableTracker->alignmentErrors());
105 
106  // Store result to EventSetup
107  GeometryAligner aligner;
108  aligner.applyAlignments<TrackerGeometry>(&(*theTracker),
109  &alignments,
110  &alignmentErrors,
111  AlignTransform()); // dummy global position
112 
113  // Write alignments to DB: have to sort beforhand!
114  if (theSaveToDB) {
115  // Call service
117  if (!poolDbService.isAvailable()) // Die if not available
118  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
119  if (theSaveFakeScenario) { // make empty!
120  alignments.clear();
121  alignmentErrors.clear();
122  }
123  poolDbService->writeOneIOV<Alignments>(alignments, poolDbService->currentTime(), theAlignRecordName);
124  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
125  alignmentErrors, poolDbService->currentTime(), theErrorRecordName);
126  }
127 
128  edm::LogInfo("MisalignedTracker") << "Producer done";
129  return theTracker;
130 }
131 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
const bool theSaveFakeScenario
whether or not writing to DB
Class to update a given geometry with a set of alignments.
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
~MisalignedTrackerESProducer() override
Destructor.
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
MisalignedTrackerESProducer(const edm::ParameterSet &p)
Constructor.
const std::string theAlignRecordName
misalignment scenario
edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
Log< level::Info, false > LogInfo
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
const edm::ParameterSet theScenario
if theSaveToDB is true, save a fake scenario (empty alignments), irrespective of the misalignment sce...
HLT enums.
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
std::unique_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &iRecord)
Produce the misaligned tracker geometry and store it.
bool isAvailable() const
Definition: Service.h:40
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Builds a scenario from configuration and applies it to the alignable tracker.
edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_