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->writeOneIOV<Alignments>(alignments, poolDbService->currentTime(), theAlignRecordName);
121  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
122  alignmentErrors, poolDbService->currentTime(), theErrorRecordName);
123  }
124 
125  edm::LogInfo("MisalignedTracker") << "Producer done";
126  return theTracker;
127 }
128 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
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 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.