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 {
39 public:
40 
43 
45  ~MisalignedTrackerESProducer() override;
46 
48  std::unique_ptr<TrackerGeometry> produce(const TrackerDigiGeometryRecord& iRecord);
49 
50 private:
51  const bool theSaveToDB;
52  const bool theSaveFakeScenario;
55 
56 };
57 
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 {
72  setWhatProduced(this);
73 
74 }
75 
76 
77 //__________________________________________________________________________________________________
79 
80 
81 //__________________________________________________________________________________________________
82 std::unique_ptr<TrackerGeometry>
84 {
85  //Retrieve tracker topology from geometry
87  iRecord.getRecord<TrackerTopologyRcd>().get(tTopoHandle);
88  const TrackerTopology* const tTopo = tTopoHandle.product();
89 
90  edm::LogInfo("MisalignedTracker") << "Producer called";
91 
92  // Create the tracker geometry from ideal geometry
94  iRecord.getRecord<IdealGeometryRecord>().get( gD );
96  iRecord.getRecord<PTrackerParametersRcd>().get( ptp );
98  std::unique_ptr<TrackerGeometry> theTracker( trackerBuilder.build(&(*gD), *ptp, tTopo));
99 
100  // Create the alignable hierarchy
101  auto theAlignableTracker = std::make_unique<AlignableTracker>( &(*theTracker), tTopo );
102 
103  // Create misalignment scenario, apply to geometry
104  TrackerScenarioBuilder scenarioBuilder( &(*theAlignableTracker) );
105  scenarioBuilder.applyScenario( theScenario );
106  Alignments* alignments = theAlignableTracker->alignments();
107  AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors();
108 
109  // Store result to EventSetup
110  GeometryAligner aligner;
111  aligner.applyAlignments<TrackerGeometry>( &(*theTracker), alignments, alignmentErrors,
112  AlignTransform()); // dummy global position
113 
114  // Write alignments to DB: have to sort beforhand!
115  if (theSaveToDB) {
116 
117  // Call service
119  if( !poolDbService.isAvailable() ) // Die if not available
120  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
121  if (theSaveFakeScenario) { // make empty!
122  alignments->clear();
123  alignmentErrors->clear();
124  }
125  poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(),
127  poolDbService->writeOne<AlignmentErrorsExtended>(alignmentErrors, poolDbService->currentTime(),
129  } else {
130  // poolDbService::writeOne takes over ownership
131  // we have to delete in the case that containers are not written
132  delete alignments;
133  delete alignmentErrors;
134  }
135 
136 
137  edm::LogInfo("MisalignedTracker") << "Producer done";
138  return theTracker;
139 
140 }
141 
142 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
const bool theSaveFakeScenario
whether or not writing to DB
Class to update a given geometry with a set of alignments.
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
~MisalignedTrackerESProducer() override
Destructor.
MisalignedTrackerESProducer(const edm::ParameterSet &p)
Constructor.
const std::string theAlignRecordName
misalignment scenario
bool isAvailable() const
Definition: Service.h:40
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
const edm::ParameterSet theScenario
if theSaveToDB is true, save a fake scenario (empty alignments), irrespective of the misalignment sce...
HLT enums.
std::unique_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &iRecord)
Produce the misaligned tracker geometry and store it.
Builds a scenario from configuration and applies it to the alignable tracker.
T const * product() const
Definition: ESHandle.h:86