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 
61 class AlignTransform;
62 class Alignments;
65 class MuonGeometryRecord;
66 struct SurveyErrors;
67 class TrackerTopology;
69 
70 
72 {
73 protected:
75 
76  // 'noexcept(false)' is needed currently for multiple inheritance with Framework modules
77  virtual ~AlignmentProducerBase() noexcept(false);
78 
79  /*** Methods used in implementation of derived classes ***/
81  void startProcessing();
82 
84  void terminateProcessing(const edm::EventSetup* = nullptr);
85 
87  bool processEvent(const edm::Event&, const edm::EventSetup&);
88 
90  void beginRunImpl(const edm::Run&, const edm::EventSetup&);
91 
93  void endRunImpl(const edm::Run&, const edm::EventSetup&);
94 
97 
100 
101  int nEvent() const { return nevent_; }
102 
105  void initAlignmentAlgorithm(const edm::EventSetup&, bool update = false);
106 
109  bool finish();
110 
111  virtual bool getTrajTrackAssociationCollection(const edm::Event&,
113  virtual bool getBeamSpot(const edm::Event&, edm::Handle<reco::BeamSpot>&) = 0;
114  virtual bool getTkFittedLasBeamCollection(const edm::Run&,
116  virtual bool getTsosVectorCollection(const edm::Run&,
118  virtual bool getAliClusterValueMap(const edm::Event&,
120 
121  std::shared_ptr<TrackerGeometry> trackerGeometry_;
122  std::shared_ptr<DTGeometry> muonDTGeometry_;
123  std::shared_ptr<CSCGeometry> muonCSCGeometry_;
125 
128 
131 
134 
137 
138 private:
139 
142 
144  void createMonitors();
145 
147  void createCalibrations();
148 
150  bool setupChanged(const edm::EventSetup&);
151 
153  void initBeamSpot(const edm::Event&);
154 
156  void createGeometries(const edm::EventSetup&, const TrackerTopology*);
157 
161 
164  void createAlignables(const TrackerTopology*, bool update = false);
165 
167  void buildParameterStore();
168 
170  void applyMisalignment();
171 
174  float, float, bool);
175 
179 
182  template<class G, class Rcd, class ErrRcd>
183  void applyDB(G*, const edm::EventSetup&, const AlignTransform&) const;
184 
186  template<class G, class DeformationRcd>
187  void applyDB(G*, const edm::EventSetup&) const;
188 
190  void readInSurveyRcds(const edm::EventSetup&);
191 
193  void addSurveyInfo(Alignable*);
194 
196  void storeAlignmentsToDB();
197 
201 
206  const std::string&, const AlignTransform*, cond::Time_t) const;
207 
211  const std::string&, cond::Time_t) const;
212 
213  template<typename T>
214  bool hasParameter(const edm::ParameterSet&, const std::string& name);
215 
216 
217 
218  //========================== PRIVATE DATA ====================================
219  //============================================================================
220 
221  /*** Alignment data ***/
222 
223  std::unique_ptr<AlignmentAlgorithmBase> alignmentAlgo_;
226 
231 
234  std::unique_ptr<const Alignments> globalPositions_;
235 
237  int nevent_{0};
238  bool runAtPCL_{false};
239 
240 
241  /*** Parameters from config-file ***/
242 
244 
245  const int stNFixAlignables_;
250  const bool useSurvey_;
252 
253 
254  /*** ESWatcher ***/
255 
258 
262 
267 
274 
275 
276  /*** Survey stuff ***/
277 
278  size_t surveyIndex_{0};
279  const Alignments* surveyValues_{nullptr};
280  const SurveyErrors* surveyErrors_{nullptr};
281 
282 
283  /*** Status flags ***/
284  bool isAlgoInitialized_{false};
285  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
286  // both, EDLooper and standard framework
287  // modules
289 
290 };
291 
292 
293 
294 template<class G, class Rcd, class ErrRcd>
295 void
297  const AlignTransform& globalCoordinates) const
298 {
299  // 'G' is the geometry class for that DB should be applied,
300  // 'Rcd' is the record class for its Alignments
301  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
302  // 'globalCoordinates' are global transformation for this geometry
303 
304  const Rcd & record = iSetup.get<Rcd>();
306  const edm::ValidityInterval & validity = record.validityInterval();
307  const edm::IOVSyncValue first = validity.first();
308  const edm::IOVSyncValue last = validity.last();
309  if (first!=edm::IOVSyncValue::beginOfTime() ||
311  throw cms::Exception("DatabaseError")
312  << "@SUB=AlignmentProducerBase::applyDB"
313  << "\nTrying to apply "
314  << record.key().name()
315  << " with multiple IOVs in tag.\n"
316  << "Validity range is "
317  << first.eventID().run() << " - " << last.eventID().run();
318  }
319  }
320 
321  edm::ESHandle<Alignments> alignments;
322  record.get(alignments);
323 
325  iSetup.get<ErrRcd>().get(alignmentErrors);
326 
327  GeometryAligner aligner;
328  aligner.applyAlignments<G>(geometry, &(*alignments), &(*alignmentErrors),
329  globalCoordinates);
330 }
331 
332 
333 template<class G, class DeformationRcd>
334 void
336 {
337  // 'G' is the geometry class for that DB should be applied,
338  // 'DeformationRcd' is the record class for its surface deformations
339 
340  const DeformationRcd & record = iSetup.get<DeformationRcd>();
342  const edm::ValidityInterval & validity = record.validityInterval();
343  const edm::IOVSyncValue first = validity.first();
344  const edm::IOVSyncValue last = validity.last();
345  if (first!=edm::IOVSyncValue::beginOfTime() ||
347  throw cms::Exception("DatabaseError")
348  << "@SUB=AlignmentProducerBase::applyDB"
349  << "\nTrying to apply "
350  << record.key().name()
351  << " with multiple IOVs in tag.\n"
352  << "Validity range is "
353  << first.eventID().run() << " - " << last.eventID().run();
354  }
355  }
357  record.get(surfaceDeformations);
358 
359  GeometryAligner aligner;
360  aligner.attachSurfaceDeformations<G>(geometry, &(*surfaceDeformations));
361 }
362 
363 
364 #endif /* Alignment_CommonAlignmentProducer_AlignmentProducerBase_h */
RunNumber_t run() const
Definition: EventID.h:39
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
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:42
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.
AlignableExtras * alignableExtras_
std::vector< RunRange > RunRanges
Definition: Utilities.h:40
AlignmentProducerBase(const edm::ParameterSet &)
std::vector< std::unique_ptr< AlignmentMonitorBase > > AlignmentMonitors
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
void buildParameterStore()
Creates the , which manages all Alignables.
#define noexcept
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
virtual ~AlignmentProducerBase()(false)
const Alignments * surveyValues_
Interface/Base class for alignment algorithms, each alignment algorithm has to be derived from this c...
AlignmentParameterStore * alignmentParameterStore_
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:16
static const IOVSyncValue & beginOfTime()
std::vector< IntegratedCalibrationBase * > Calibrations
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.
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 hasParameter(const edm::ParameterSet &, const std::string &name)
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_
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
AlignableTracker * alignableTracker_
edm::Handle< reco::BeamSpot > beamSpot_
edm::ESWatcher< CSCSurveyErrorExtendedRcd > watchCSCSurveyErrExtRcd_
void applyMisalignment()
Applies misalignment scenario to .
const T & get() const
Definition: EventSetup.h:58
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:32
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_
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 .
const IOVSyncValue & first() const
Time_t endValue
Definition: Time.h:46
edm::ESWatcher< DTSurveyRcd > watchDTSurveyRcd_
Constructor of the full muon geometry.
Definition: AlignableMuon.h:37
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:43
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void createMonitors()
Creates the monitors.