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_;
254 
255  /*** ESTokens ***/
263 
273 
281 
282  /*** ESWatcher ***/
283 
286 
290 
295 
302 
303  /*** Survey stuff ***/
304 
305  size_t surveyIndex_{0};
306  const Alignments* surveyValues_{nullptr};
307  const SurveyErrors* surveyErrors_{nullptr};
308 
309  /*** Status flags ***/
310  bool isAlgoInitialized_{false};
311  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
312  // both, EDLooper and standard framework
313  // modules
315 };
316 
317 template <class G, class Rcd, class ErrRcd>
319  const edm::EventSetup& iSetup,
320  const edm::ESGetToken<Alignments, Rcd>& aliToken,
322  const AlignTransform& globalCoordinates) const {
323  // 'G' is the geometry class for that DB should be applied,
324  // 'Rcd' is the record class for its Alignments
325  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
326  // 'globalCoordinates' are global transformation for this geometry
327 
328  const Rcd& record = iSetup.get<Rcd>();
330  const edm::ValidityInterval& validity = record.validityInterval();
331  const edm::IOVSyncValue first = validity.first();
332  const edm::IOVSyncValue last = validity.last();
334  throw cms::Exception("DatabaseError")
335  << "@SUB=AlignmentProducerBase::applyDB"
336  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
337  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
338  }
339  }
340 
341  const Alignments* alignments = &record.get(aliToken);
342  const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(errToken);
343 
344  GeometryAligner aligner;
345  aligner.applyAlignments<G>(geometry, alignments, alignmentErrors, globalCoordinates);
346 }
347 
348 template <class G, class DeformationRcd>
350  const G* geometry,
351  const edm::EventSetup& iSetup,
353  // 'G' is the geometry class for that DB should be applied,
354  // 'DeformationRcd' is the record class for its surface deformations
355 
356  const DeformationRcd& record = iSetup.get<DeformationRcd>();
358  const edm::ValidityInterval& validity = record.validityInterval();
359  const edm::IOVSyncValue first = validity.first();
360  const edm::IOVSyncValue last = validity.last();
362  throw cms::Exception("DatabaseError")
363  << "@SUB=AlignmentProducerBase::applyDB"
364  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
365  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
366  }
367  }
368  const AlignmentSurfaceDeformations* surfaceDeformations = &record.get(surfDefToken);
369 
370  GeometryAligner aligner;
371  aligner.attachSurfaceDeformations<G>(geometry, surfaceDeformations);
372 }
373 
374 #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 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_