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  template <typename T>
208  bool hasParameter(const edm::ParameterSet&, const std::string& name);
209 
210  //========================== PRIVATE DATA ====================================
211  //============================================================================
212 
213  /*** Alignment data ***/
214 
215  std::unique_ptr<AlignmentAlgorithmBase> alignmentAlgo_;
218 
223 
226  std::unique_ptr<const Alignments> globalPositions_;
227 
229  int nevent_{0};
230  bool runAtPCL_{false};
231 
232  /*** Parameters from config-file ***/
233 
235 
236  const int stNFixAlignables_;
241  const bool useSurvey_;
243 
244  /*** ESWatcher ***/
245 
248 
252 
257 
264 
265  /*** Survey stuff ***/
266 
267  size_t surveyIndex_{0};
268  const Alignments* surveyValues_{nullptr};
269  const SurveyErrors* surveyErrors_{nullptr};
270 
271  /*** Status flags ***/
272  bool isAlgoInitialized_{false};
273  bool isDuringLoop_{false}; // -> needed to ensure correct behaviour in
274  // both, EDLooper and standard framework
275  // modules
277 };
278 
279 template <class G, class Rcd, class ErrRcd>
281  const edm::EventSetup& iSetup,
282  const AlignTransform& globalCoordinates) const {
283  // 'G' is the geometry class for that DB should be applied,
284  // 'Rcd' is the record class for its Alignments
285  // 'ErrRcd' is the record class for its AlignmentErrorsExtended
286  // 'globalCoordinates' are global transformation for this geometry
287 
288  const Rcd& record = iSetup.get<Rcd>();
290  const edm::ValidityInterval& validity = record.validityInterval();
291  const edm::IOVSyncValue first = validity.first();
292  const edm::IOVSyncValue last = validity.last();
293  if (first != edm::IOVSyncValue::beginOfTime() || last != edm::IOVSyncValue::endOfTime()) {
294  throw cms::Exception("DatabaseError")
295  << "@SUB=AlignmentProducerBase::applyDB"
296  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
297  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
298  }
299  }
300 
301  edm::ESHandle<Alignments> alignments;
302  record.get(alignments);
303 
305  iSetup.get<ErrRcd>().get(alignmentErrors);
306 
307  GeometryAligner aligner;
308  aligner.applyAlignments<G>(geometry, &(*alignments), &(*alignmentErrors), globalCoordinates);
309 }
310 
311 template <class G, class DeformationRcd>
313  // 'G' is the geometry class for that DB should be applied,
314  // 'DeformationRcd' is the record class for its surface deformations
315 
316  const DeformationRcd& record = iSetup.get<DeformationRcd>();
318  const edm::ValidityInterval& validity = record.validityInterval();
319  const edm::IOVSyncValue first = validity.first();
320  const edm::IOVSyncValue last = validity.last();
321  if (first != edm::IOVSyncValue::beginOfTime() || last != edm::IOVSyncValue::endOfTime()) {
322  throw cms::Exception("DatabaseError")
323  << "@SUB=AlignmentProducerBase::applyDB"
324  << "\nTrying to apply " << record.key().name() << " with multiple IOVs in tag.\n"
325  << "Validity range is " << first.eventID().run() << " - " << last.eventID().run();
326  }
327  }
329  record.get(surfaceDeformations);
330 
331  GeometryAligner aligner;
332  aligner.attachSurfaceDeformations<G>(geometry, &(*surfaceDeformations));
333 }
334 
335 #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: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.
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:82
void buildParameterStore()
Creates the , which manages all Alignables.
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()
Definition: IOVSyncValue.cc:88
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
std::vector< IntegratedCalibrationBase * > Calibrations
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_
#define noexcept
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 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_
T get() const
Definition: EventSetup.h:71
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:45
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void createMonitors()
Creates the monitors.