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 
48 
53 
62 
64 
65 class AlignTransform;
66 class Alignments;
69 struct SurveyErrors;
70 class TrackerTopology;
72 
74 protected:
76 
77  // 'noexcept(false)' is needed currently for multiple inheritance with Framework modules
78  virtual ~AlignmentProducerBase() noexcept(false);
79 
80  /*** Methods used in implementation of derived classes ***/
82  void startProcessing();
83 
85  void terminateProcessing(const edm::EventSetup* = nullptr);
86 
88  bool processEvent(const edm::Event&, const edm::EventSetup&);
89 
91  void beginRunImpl(const edm::Run&, const edm::EventSetup&);
92 
94  void endRunImpl(const edm::Run&, const edm::EventSetup&);
95 
98 
101 
102  int nEvent() const { return nevent_; }
103 
106  void initAlignmentAlgorithm(const edm::EventSetup&, bool update = false);
107 
110  bool finish();
111 
113  virtual bool getBeamSpot(const edm::Event&, edm::Handle<reco::BeamSpot>&) = 0;
117 
118  std::shared_ptr<TrackerGeometry> trackerGeometry_;
123 
126 
129 
132 
135 
136 private:
139 
142 
145 
147  bool setupChanged(const edm::EventSetup&);
148 
150  void initBeamSpot(const edm::Event&);
151 
153  void createGeometries(const edm::EventSetup&, const TrackerTopology*);
154 
158 
161  void createAlignables(const TrackerTopology*, bool update = false);
162 
164  void buildParameterStore();
165 
167  void applyMisalignment();
168 
170  void simpleMisalignment(const align::Alignables&, const std::string&, float, float, bool);
171 
175 
178  template <class G, class Rcd, class ErrRcd>
179  void applyDB(const G*,
180  const edm::EventSetup&,
183  const AlignTransform&) const;
184 
186  template <class G, class DeformationRcd>
187  void applyDB(const G*,
188  const edm::EventSetup&,
190 
192  void readInSurveyRcds(const edm::EventSetup&);
193 
195  void addSurveyInfo(Alignable*);
196 
198  void storeAlignmentsToDB();
199 
203 
207  void writeDB(Alignments*,
208  const std::string&,
210  const std::string&,
211  const AlignTransform*,
212  cond::Time_t) const;
213 
216  void writeDB(const AlignmentSurfaceDeformations&, const std::string&, cond::Time_t) const;
217 
218  //========================== PRIVATE DATA ====================================
219  //============================================================================
220 
221  /*** Alignment data ***/
222 
223  std::unique_ptr<AlignmentAlgorithmBase> alignmentAlgo_;
226 
227  std::unique_ptr<AlignmentParameterStore> alignmentParameterStore_;
228  std::unique_ptr<AlignableTracker> alignableTracker_;
229  std::unique_ptr<AlignableMuon> alignableMuon_;
230  std::unique_ptr<AlignableExtras> alignableExtras_;
231 
234  std::unique_ptr<const Alignments> globalPositions_;
235 
237  int nevent_{0};
238  bool runAtPCL_{false};
239 
240  /*** Parameters from config-file ***/
241 
243 
244  const int stNFixAlignables_;
249  const bool useSurvey_;
252 
253  /*** ESTokens ***/
260 
270 
278 
279  /*** ESWatcher ***/
280 
283 
287 
292 
299 
300  /*** Survey stuff ***/
301 
302  size_t surveyIndex_{0};
303  const Alignments* surveyValues_{nullptr};
304  const SurveyErrors* surveyErrors_{nullptr};
305 
306  /*** Status flags ***/
307  bool isAlgoInitialized_{false};
308  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
309  // both, EDLooper and standard framework
310  // modules
312 };
313 
314 template <class G, class Rcd, class ErrRcd>
316  const edm::EventSetup& iSetup,
317  const edm::ESGetToken<Alignments, Rcd>& aliToken,
319  const AlignTransform& globalCoordinates) const {
320  // 'G' is the geometry class for that DB should be applied,
321  // 'Rcd' is the record class for its Alignments
322  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
323  // 'globalCoordinates' are global transformation for this geometry
324 
325  const Rcd& record = iSetup.get<Rcd>();
327  const edm::ValidityInterval& validity = record.validityInterval();
328  const edm::IOVSyncValue first = validity.first();
329  const edm::IOVSyncValue last = validity.last();
331  throw cms::Exception("DatabaseError")
332  << "@SUB=AlignmentProducerBase::applyDB"
333  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
334  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
335  }
336  }
337 
338  const Alignments* alignments = &record.get(aliToken);
339  const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(errToken);
340 
341  GeometryAligner aligner;
342  aligner.applyAlignments<G>(geometry, alignments, alignmentErrors, globalCoordinates);
343 }
344 
345 template <class G, class DeformationRcd>
347  const G* geometry,
348  const edm::EventSetup& iSetup,
350  // 'G' is the geometry class for that DB should be applied,
351  // 'DeformationRcd' is the record class for its surface deformations
352 
353  const DeformationRcd& record = iSetup.get<DeformationRcd>();
355  const edm::ValidityInterval& validity = record.validityInterval();
356  const edm::IOVSyncValue first = validity.first();
357  const edm::IOVSyncValue last = validity.last();
359  throw cms::Exception("DatabaseError")
360  << "@SUB=AlignmentProducerBase::applyDB"
361  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
362  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
363  }
364  }
365  const AlignmentSurfaceDeformations* surfaceDeformations = &record.get(surfDefToken);
366 
367  GeometryAligner aligner;
368  aligner.attachSurfaceDeformations<G>(geometry, surfaceDeformations);
369 }
370 
371 #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.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
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_
const std::string tkAliRcdName_
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:79
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.
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 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_