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 
47 
51 
57 
59 
60 class AlignTransform;
61 class Alignments;
64 class MuonGeometryRecord;
65 struct SurveyErrors;
66 class TrackerTopology;
68 
70 protected:
72 
73  // 'noexcept(false)' is needed currently for multiple inheritance with Framework modules
74  virtual ~AlignmentProducerBase() noexcept(false);
75 
76  /*** Methods used in implementation of derived classes ***/
78  void startProcessing();
79 
81  void terminateProcessing(const edm::EventSetup* = nullptr);
82 
84  bool processEvent(const edm::Event&, const edm::EventSetup&);
85 
87  void beginRunImpl(const edm::Run&, const edm::EventSetup&);
88 
90  void endRunImpl(const edm::Run&, const edm::EventSetup&);
91 
94 
97 
98  int nEvent() const { return nevent_; }
99 
102  void initAlignmentAlgorithm(const edm::EventSetup&, bool update = false);
103 
106  bool finish();
107 
109  virtual bool getBeamSpot(const edm::Event&, edm::Handle<reco::BeamSpot>&) = 0;
113 
114  std::shared_ptr<TrackerGeometry> trackerGeometry_;
115  std::shared_ptr<DTGeometry> muonDTGeometry_;
116  std::shared_ptr<CSCGeometry> muonCSCGeometry_;
118 
121 
124 
127 
130 
131 private:
134 
136  void createMonitors();
137 
139  void createCalibrations();
140 
142  bool setupChanged(const edm::EventSetup&);
143 
145  void initBeamSpot(const edm::Event&);
146 
148  void createGeometries(const edm::EventSetup&, const TrackerTopology*);
149 
153 
156  void createAlignables(const TrackerTopology*, bool update = false);
157 
159  void buildParameterStore();
160 
162  void applyMisalignment();
163 
165  void simpleMisalignment(const align::Alignables&, const std::string&, float, float, bool);
166 
170 
173  template <class G, class Rcd, class ErrRcd>
174  void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const;
175 
177  template <class G, class DeformationRcd>
178  void applyDB(G*, const edm::EventSetup&) const;
179 
181  void readInSurveyRcds(const edm::EventSetup&);
182 
184  void addSurveyInfo(Alignable*);
185 
187  void storeAlignmentsToDB();
188 
192 
196  void writeDB(Alignments*,
197  const std::string&,
199  const std::string&,
200  const AlignTransform*,
201  cond::Time_t) const;
202 
206 
207  //========================== PRIVATE DATA ====================================
208  //============================================================================
209 
210  /*** Alignment data ***/
211 
212  std::unique_ptr<AlignmentAlgorithmBase> alignmentAlgo_;
215 
216  std::unique_ptr<AlignmentParameterStore> alignmentParameterStore_;
217  std::unique_ptr<AlignableTracker> alignableTracker_;
218  std::unique_ptr<AlignableMuon> alignableMuon_;
219  std::unique_ptr<AlignableExtras> alignableExtras_;
220 
223  std::unique_ptr<const Alignments> globalPositions_;
224 
226  int nevent_{0};
227  bool runAtPCL_{false};
228 
229  /*** Parameters from config-file ***/
230 
232 
233  const int stNFixAlignables_;
238  const bool useSurvey_;
240 
241  /*** ESWatcher ***/
242 
245 
249 
254 
261 
262  /*** Survey stuff ***/
263 
264  size_t surveyIndex_{0};
265  const Alignments* surveyValues_{nullptr};
266  const SurveyErrors* surveyErrors_{nullptr};
267 
268  /*** Status flags ***/
269  bool isAlgoInitialized_{false};
270  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
271  // both, EDLooper and standard framework
272  // modules
274 };
275 
276 template <class G, class Rcd, class ErrRcd>
278  const edm::EventSetup& iSetup,
279  const AlignTransform& globalCoordinates) const {
280  // 'G' is the geometry class for that DB should be applied,
281  // 'Rcd' is the record class for its Alignments
282  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
283  // 'globalCoordinates' are global transformation for this geometry
284 
285  const Rcd& record = iSetup.get<Rcd>();
287  const edm::ValidityInterval& validity = record.validityInterval();
288  const edm::IOVSyncValue first = validity.first();
289  const edm::IOVSyncValue last = validity.last();
290  if (first != edm::IOVSyncValue::beginOfTime() || last != edm::IOVSyncValue::endOfTime()) {
291  throw cms::Exception("DatabaseError")
292  << "@SUB=AlignmentProducerBase::applyDB"
293  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
294  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
295  }
296  }
297 
298  edm::ESHandle<Alignments> alignments;
299  record.get(alignments);
300 
302  iSetup.get<ErrRcd>().get(alignmentErrors);
303 
304  GeometryAligner aligner;
305  aligner.applyAlignments<G>(geometry, &(*alignments), &(*alignmentErrors), globalCoordinates);
306 }
307 
308 template <class G, class DeformationRcd>
310  // 'G' is the geometry class for that DB should be applied,
311  // 'DeformationRcd' is the record class for its surface deformations
312 
313  const DeformationRcd& record = iSetup.get<DeformationRcd>();
315  const edm::ValidityInterval& validity = record.validityInterval();
316  const edm::IOVSyncValue first = validity.first();
317  const edm::IOVSyncValue last = validity.last();
318  if (first != edm::IOVSyncValue::beginOfTime() || last != edm::IOVSyncValue::endOfTime()) {
319  throw cms::Exception("DatabaseError")
320  << "@SUB=AlignmentProducerBase::applyDB"
321  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
322  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
323  }
324  }
326  record.get(surfaceDeformations);
327 
328  GeometryAligner aligner;
329  aligner.attachSurfaceDeformations<G>(geometry, &(*surfaceDeformations));
330 }
331 
332 #endif /* Alignment_CommonAlignmentProducer_AlignmentProducerBase_h */
RunNumber_t run() const
Definition: EventID.h:38
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
const edm::InputTag tjTkAssociationMapTag_
Map with tracks/trajectories.
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
void applyAlignmentsToDB(const edm::EventSetup &)
void createGeometries(const edm::EventSetup &, const TrackerTopology *)
Creates ideal geometry from IdealGeometryRecord.
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
std::shared_ptr< CSCGeometry > muonCSCGeometry_
const EventID & eventID() const
Definition: IOVSyncValue.h:40
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
edm::ESWatcher< DTAlignmentRcd > watchDTAlRcd_
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
bool processEvent(const edm::Event &, const edm::EventSetup &)
Process event.
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
void terminateProcessing(const edm::EventSetup *=0)
Terminate processing of events.
std::vector< RunRange > RunRanges
Definition: Utilities.h:39
AlignmentProducerBase(const edm::ParameterSet &)
std::vector< std::unique_ptr< AlignmentMonitorBase > > AlignmentMonitors
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_
virtual ~AlignmentProducerBase()(false)
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
std::shared_ptr< TrackerGeometry > trackerGeometry_
const IOVSyncValue & last() const
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
void writeForRunRange(cond::Time_t)
unsigned long long Time_t
Definition: Time.h:14
std::unique_ptr< AlignableExtras > alignableExtras_
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
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.
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.
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_
#define noexcept
std::vector< std::unique_ptr< IntegratedCalibrationBase > > CalibrationsOwner
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
edm::Handle< reco::BeamSpot > beamSpot_
edm::ESWatcher< CSCSurveyErrorExtendedRcd > watchCSCSurveyErrExtRcd_
void applyMisalignment()
Applies misalignment scenario to .
const align::RunRanges uniqueRunRanges_
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
std::shared_ptr< DTGeometry > muonDTGeometry_
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
ESHandle< TrackerGeometry > geometry
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_
T get() const
Definition: EventSetup.h:73
void createCalibrations()
Creates the calibrations.
void createAlignmentAlgorithm()
Creates the choosen alignment algorithm.
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 .
CalibrationsOwner calibrations_
const IOVSyncValue & first() const
Time_t endValue
Definition: Time.h:42
edm::ESWatcher< DTSurveyRcd > watchDTSurveyRcd_
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 .
void applyDB(G *, const edm::EventSetup &, const AlignTransform &) const
Definition: Run.h:45
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void createMonitors()
Creates the monitors.