CMS 3D CMS Logo

AlignmentProducerBase.h
Go to the documentation of this file.
1 #ifndef Alignment_CommonAlignmentProducer_AlignmentProducerBase_h
2 #define Alignment_CommonAlignmentProducer_AlignmentProducerBase_h
3 
25 #include <memory>
26 
30 
49 
54 
64 
66 
67 class AlignTransform;
68 class Alignments;
71 struct SurveyErrors;
72 class TrackerTopology;
74 
76 protected:
78 
79  // 'noexcept(false)' is needed currently for multiple inheritance with Framework modules
80  virtual ~AlignmentProducerBase() noexcept(false);
81 
82  /*** Methods used in implementation of derived classes ***/
84  void startProcessing();
85 
87  void terminateProcessing(const edm::EventSetup* = nullptr);
88 
90  bool processEvent(const edm::Event&, const edm::EventSetup&);
91 
93  void beginRunImpl(const edm::Run&, const edm::EventSetup&);
94 
96  void endRunImpl(const edm::Run&, const edm::EventSetup&);
97 
100 
103 
104  int nEvent() const { return nevent_; }
105 
108  void initAlignmentAlgorithm(const edm::EventSetup&, bool update = false);
109 
112  bool finish();
113 
115  virtual bool getBeamSpot(const edm::Event&, edm::Handle<reco::BeamSpot>&) = 0;
119 
120  std::shared_ptr<TrackerGeometry> trackerGeometry_;
125 
128 
131 
134 
137 
138 private:
141 
144 
147 
149  bool setupChanged(const edm::EventSetup&);
150 
152  void initBeamSpot(const edm::Event&);
153 
155  void createGeometries(const edm::EventSetup&, const TrackerTopology*);
156 
160 
163  void createAlignables(const TrackerTopology*, bool update = false);
164 
166  void buildParameterStore();
167 
169  void applyMisalignment();
170 
172  void simpleMisalignment(const align::Alignables&, const std::string&, float, float, bool);
173 
177 
180  template <class G, class Rcd, class ErrRcd>
181  void applyDB(const G*,
182  const edm::EventSetup&,
185  const AlignTransform&) const;
186 
188  template <class G, class DeformationRcd>
189  void applyDB(const G*,
190  const edm::EventSetup&,
192 
194  void readInSurveyRcds(const edm::EventSetup&);
195 
197  void addSurveyInfo(Alignable*);
198 
200  void storeAlignmentsToDB();
201 
205 
209  void writeDB(Alignments*,
210  const std::string&,
212  const std::string&,
213  const AlignTransform*,
214  cond::Time_t) const;
215 
218  void writeDB(const AlignmentSurfaceDeformations&, const std::string&, cond::Time_t) const;
219 
220  //========================== PRIVATE DATA ====================================
221  //============================================================================
222 
223  /*** Alignment data ***/
224 
225  std::unique_ptr<AlignmentAlgorithmBase> alignmentAlgo_;
228 
229  std::unique_ptr<AlignmentParameterStore> alignmentParameterStore_;
230  std::unique_ptr<AlignableTracker> alignableTracker_;
231  std::unique_ptr<AlignableMuon> alignableMuon_;
232  std::unique_ptr<AlignableExtras> alignableExtras_;
233 
236  std::unique_ptr<const Alignments> globalPositions_;
237 
239  int nevent_{0};
240  bool runAtPCL_{false};
241 
242  /*** Parameters from config-file ***/
243 
245 
246  const int stNFixAlignables_;
251  const bool useSurvey_;
253 
254  /*** ESTokens ***/
262 
272 
280 
281  /*** ESWatcher ***/
282 
285 
289 
294 
301 
302  /*** Survey stuff ***/
303 
304  size_t surveyIndex_{0};
305  const Alignments* surveyValues_{nullptr};
306  const SurveyErrors* surveyErrors_{nullptr};
307 
308  /*** Status flags ***/
309  bool isAlgoInitialized_{false};
310  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
311  // both, EDLooper and standard framework
312  // modules
314 };
315 
316 template <class G, class Rcd, class ErrRcd>
318  const edm::EventSetup& iSetup,
319  const edm::ESGetToken<Alignments, Rcd>& aliToken,
321  const AlignTransform& globalCoordinates) const {
322  // 'G' is the geometry class for that DB should be applied,
323  // 'Rcd' is the record class for its Alignments
324  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
325  // 'globalCoordinates' are global transformation for this geometry
326 
327  const Rcd& record = iSetup.get<Rcd>();
329  const edm::ValidityInterval& validity = record.validityInterval();
330  const edm::IOVSyncValue first = validity.first();
331  const edm::IOVSyncValue last = validity.last();
333  throw cms::Exception("DatabaseError")
334  << "@SUB=AlignmentProducerBase::applyDB"
335  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
336  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
337  }
338  }
339 
340  const Alignments* alignments = &record.get(aliToken);
341  const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(errToken);
342 
343  GeometryAligner aligner;
344  aligner.applyAlignments<G>(geometry, alignments, alignmentErrors, globalCoordinates);
345 }
346 
347 template <class G, class DeformationRcd>
349  const G* geometry,
350  const edm::EventSetup& iSetup,
352  // 'G' is the geometry class for that DB should be applied,
353  // 'DeformationRcd' is the record class for its surface deformations
354 
355  const DeformationRcd& record = iSetup.get<DeformationRcd>();
357  const edm::ValidityInterval& validity = record.validityInterval();
358  const edm::IOVSyncValue first = validity.first();
359  const edm::IOVSyncValue last = validity.last();
361  throw cms::Exception("DatabaseError")
362  << "@SUB=AlignmentProducerBase::applyDB"
363  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
364  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
365  }
366  }
367  const AlignmentSurfaceDeformations* surfaceDeformations = &record.get(surfDefToken);
368 
369  GeometryAligner aligner;
370  aligner.attachSurfaceDeformations<G>(geometry, surfaceDeformations);
371 }
372 
373 #endif /* Alignment_CommonAlignmentProducer_AlignmentProducerBase_h */
void attachSurfaceDeformations(const C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
AlignmentProducerBase(const edm::ParameterSet &, edm::ConsumesCollector)
const IOVSyncValue & last() const
void terminateProcessing(const edm::EventSetup *=nullptr)
Terminate processing of events.
const edm::InputTag tjTkAssociationMapTag_
Map with tracks/trajectories.
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
const IOVSyncValue & first() const
void applyAlignmentsToDB(const edm::EventSetup &)
void createGeometries(const edm::EventSetup &, const TrackerTopology *)
Creates ideal geometry from IdealGeometryRecord.
const edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > cscAliErrToken_
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
edm::ESWatcher< DTAlignmentRcd > watchDTAlRcd_
Class to update a given geometry with a set of alignments.
bool processEvent(const edm::Event &, const edm::EventSetup &)
Process event.
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
std::vector< RunRange > RunRanges
Definition: Utilities.h:39
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
std::vector< std::unique_ptr< AlignmentMonitorBase > > AlignmentMonitors
virtual ~AlignmentProducerBase() noexcept(false)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
void buildParameterStore()
Creates the , which manages all Alignables.
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
std::unique_ptr< AlignableMuon > alignableMuon_
const edm::ESGetToken< Alignments, DTSurveyRcd > dtSurveyToken_
const Alignments * surveyValues_
std::unique_ptr< AlignmentParameterStore > alignmentParameterStore_
Interface/Base class for alignment algorithms, each alignment algorithm has to be derived from this c...
edm::ESWatcher< DTSurveyErrorExtendedRcd > watchDTSurveyErrExtRcd_
virtual bool getTkFittedLasBeamCollection(const edm::Run &, edm::Handle< TkFittedLasBeamCollection > &)=0
const edm::ESGetToken< Alignments, CSCAlignmentRcd > cscAliToken_
std::shared_ptr< TrackerGeometry > trackerGeometry_
const edm::ESGetToken< SurveyErrors, CSCSurveyErrorExtendedRcd > cscSurvErrorToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
void writeForRunRange(cond::Time_t)
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > tkAliToken_
unsigned long long Time_t
Definition: Time.h:14
const edm::ESGetToken< Alignments, TrackerSurveyRcd > tkSurveyToken_
const edm::ESGetToken< Alignments, GEMAlignmentRcd > gemAliToken_
std::unique_ptr< AlignableExtras > alignableExtras_
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void createMonitors(edm::ConsumesCollector &)
Creates the monitors.
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
void createAlignmentAlgorithm(edm::ConsumesCollector &)
Creates the choosen alignment algorithm.
const edm::ESGetToken< SurveyErrors, DTSurveyErrorExtendedRcd > dtSurvErrorToken_
const edm::InputTag beamSpotTag_
BeamSpot.
edm::ESWatcher< TrackerSurveyErrorExtendedRcd > watchTkSurveyErrExtRcd_
void endRunImpl(const edm::Run &, const edm::EventSetup &)
end run
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
T get() const
Definition: EventSetup.h:82
void applyDB(const G *, const edm::EventSetup &, const edm::ESGetToken< Alignments, Rcd > &, const edm::ESGetToken< AlignmentErrorsExtended, ErrRcd > &, const AlignTransform &) const
std::unique_ptr< AlignableTracker > alignableTracker_
void endLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
end lumi block
void createAlignables(const TrackerTopology *, bool update=false)
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const edm::ESGetToken< Alignments, DTAlignmentRcd > dtAliToken_
void startProcessing()
Start processing of events.
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
virtual bool getBeamSpot(const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
edm::ESWatcher< CSCAlignmentErrorExtendedRcd > watchCSCAlErrExtRcd_
std::vector< std::unique_ptr< IntegratedCalibrationBase > > CalibrationsOwner
const edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > gemAliErrToken_
edm::ESHandle< DTGeometry > muonDTGeometry_
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
void createCalibrations(edm::ConsumesCollector &)
Creates the calibrations.
edm::Handle< reco::BeamSpot > beamSpot_
edm::ESWatcher< CSCSurveyErrorExtendedRcd > watchCSCSurveyErrExtRcd_
void applyMisalignment()
Applies misalignment scenario to .
const edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > tkAliErrToken_
const edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_
const align::RunRanges uniqueRunRanges_
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
void beginLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
begin lumi block
edm::ESWatcher< TrackerAlignmentErrorExtendedRcd > watchTrackerAlErrorExtRcd_
bool setupChanged(const edm::EventSetup &)
Checks if one of the EventSetup-Records has changed.
edm::ESWatcher< CSCSurveyRcd > watchCSCSurveyRcd_
#define update(a, b)
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
const edm::ESGetToken< SurveyErrors, TrackerSurveyErrorExtendedRcd > tkSurvErrorToken_
const edm::ESGetToken< AlignmentSurfaceDeformations, TrackerSurfaceDeformationRcd > tkSurfDefToken_
const edm::ESGetToken< Alignments, CSCSurveyRcd > cscSurveyToken_
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
edm::ESHandle< CSCGeometry > muonCSCGeometry_
edm::ESWatcher< CSCAlignmentRcd > watchCSCAlRcd_
const edm::InputTag tkLasBeamTag_
LAS beams in edm::Run (ignore if empty)
const SurveyErrors * surveyErrors_
void initBeamSpot(const edm::Event &)
Initializes Beamspot of Alignables .
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
CalibrationsOwner calibrations_
Time_t endValue
Definition: Time.h:42
edm::ESWatcher< DTSurveyRcd > watchDTSurveyRcd_
const edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > dtAliErrToken_
edm::ESHandle< GEMGeometry > muonGEMGeometry_
void beginRunImpl(const edm::Run &, const edm::EventSetup &)
begin run
const edm::InputTag clusterValueMapTag_
ValueMap containing associtaion cluster-flag.
void simpleMisalignment(const align::Alignables &, const std::string &, float, float, bool)
Applies misalignment scenario to .
Definition: Run.h:45
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_