CMS 3D CMS Logo

List of all members | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
AlignmentProducerBase Class Referenceabstract

#include <AlignmentProducerBase.h>

Inheritance diagram for AlignmentProducerBase:
AlignmentProducer AlignmentProducerAsAnalyzer

Protected Member Functions

 AlignmentProducerBase (const edm::ParameterSet &)
 
void beginLuminosityBlockImpl (const edm::LuminosityBlock &, const edm::EventSetup &)
 begin lumi block More...
 
void beginRunImpl (const edm::Run &, const edm::EventSetup &)
 begin run More...
 
void endLuminosityBlockImpl (const edm::LuminosityBlock &, const edm::EventSetup &)
 end lumi block More...
 
void endRunImpl (const edm::Run &, const edm::EventSetup &)
 end run More...
 
bool finish ()
 
virtual bool getAliClusterValueMap (const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
 
virtual bool getBeamSpot (const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
 
virtual bool getTkFittedLasBeamCollection (const edm::Run &, edm::Handle< TkFittedLasBeamCollection > &)=0
 
virtual bool getTrajTrackAssociationCollection (const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
 
virtual bool getTsosVectorCollection (const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
 
void initAlignmentAlgorithm (const edm::EventSetup &, bool update=false)
 
int nEvent () const
 
bool processEvent (const edm::Event &, const edm::EventSetup &)
 Process event. More...
 
void startProcessing ()
 Start processing of events. More...
 
void terminateProcessing (const edm::EventSetup *=0)
 Terminate processing of events. More...
 
virtual ~AlignmentProducerBase ()(false)
 

Protected Attributes

const edm::InputTag beamSpotTag_
 BeamSpot. More...
 
const edm::InputTag clusterValueMapTag_
 ValueMap containing associtaion cluster-flag. More...
 
const bool doMuon_
 
const bool doTracker_
 
std::shared_ptr< CSCGeometrymuonCSCGeometry_
 
std::shared_ptr< DTGeometrymuonDTGeometry_
 
const edm::InputTag tjTkAssociationMapTag_
 Map with tracks/trajectories. More...
 
const edm::InputTag tkLasBeamTag_
 LAS beams in edm::Run (ignore if empty) More...
 
std::shared_ptr< TrackerGeometrytrackerGeometry_
 
const bool useExtras_
 

Private Member Functions

void addSurveyInfo (Alignable *)
 Adds survey info to an Alignable. More...
 
void applyAlignmentsToDB (const edm::EventSetup &)
 
void applyAlignmentsToGeometry ()
 
template<class G , class Rcd , class ErrRcd >
void applyDB (G *, const edm::EventSetup &, const AlignTransform &) const
 
template<class G , class DeformationRcd >
void applyDB (G *, const edm::EventSetup &) const
 Applies DB constants for SurfaceDeformations. More...
 
void applyMisalignment ()
 Applies misalignment scenario to . More...
 
void buildParameterStore ()
 Creates the , which manages all Alignables. More...
 
void createAlignables (const TrackerTopology *, bool update=false)
 
void createAlignmentAlgorithm ()
 Creates the choosen alignment algorithm. More...
 
void createCalibrations ()
 Creates the calibrations. More...
 
void createGeometries (const edm::EventSetup &, const TrackerTopology *)
 Creates ideal geometry from IdealGeometryRecord. More...
 
void createMonitors ()
 Creates the monitors. More...
 
template<typename T >
bool hasParameter (const edm::ParameterSet &, const std::string &name)
 
void initBeamSpot (const edm::Event &)
 Initializes Beamspot of Alignables . More...
 
void readInSurveyRcds (const edm::EventSetup &)
 Reads in survey records. More...
 
bool setupChanged (const edm::EventSetup &)
 Checks if one of the EventSetup-Records has changed. More...
 
void simpleMisalignment (const align::Alignables &, const std::string &, float, float, bool)
 Applies misalignment scenario to . More...
 
void storeAlignmentsToDB ()
 Writes Alignments (i.e. Records) to database-file. More...
 
void writeDB (Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
 
void writeDB (AlignmentSurfaceDeformations *, const std::string &, cond::Time_t) const
 
void writeForRunRange (cond::Time_t)
 

Private Attributes

AlignableExtrasalignableExtras_ { 0 }
 
AlignableMuonalignableMuon_ { 0 }
 
AlignableTrackeralignableTracker_ { 0 }
 
std::unique_ptr< AlignmentAlgorithmBasealignmentAlgo_
 
AlignmentParameterStorealignmentParameterStore_ { 0 }
 
const bool applyDbAlignment_
 
edm::Handle< reco::BeamSpotbeamSpot_
 
Calibrations calibrations_
 
const bool checkDbAlignmentValidity_
 
edm::ParameterSet config_
 
const bool doMisalignmentScenario_
 
const bool enableAlignableUpdates_
 
cond::Time_t firstRun_ {cond::timeTypeSpecs[cond::runnumber].endValue}
 
std::unique_ptr< const AlignmentsglobalPositions_
 GlobalPositions that might be read from DB, nullptr otherwise. More...
 
bool isAlgoInitialized_ {false}
 
bool isDuringLoop_ {false}
 
AlignmentMonitors monitors_
 
int nevent_ {0}
 
bool runAtPCL_ {false}
 
const bool saveApeToDB_
 
const bool saveDeformationsToDB_
 
const bool saveToDB_
 
const int stNFixAlignables_
 
const double stRandomRotation_
 
const double stRandomShift_
 
const SurveyErrorssurveyErrors_ { 0 }
 
size_t surveyIndex_ {0}
 
const AlignmentssurveyValues_ { 0 }
 
const align::RunRanges uniqueRunRanges_
 
const bool useSurvey_
 
edm::ESWatcher< CSCAlignmentErrorExtendedRcdwatchCSCAlErrExtRcd_
 
edm::ESWatcher< CSCAlignmentRcdwatchCSCAlRcd_
 
edm::ESWatcher< CSCSurveyErrorExtendedRcdwatchCSCSurveyErrExtRcd_
 
edm::ESWatcher< CSCSurveyRcdwatchCSCSurveyRcd_
 
edm::ESWatcher< DTAlignmentErrorExtendedRcdwatchDTAlErrExtRcd_
 
edm::ESWatcher< DTAlignmentRcdwatchDTAlRcd_
 
edm::ESWatcher< DTSurveyErrorExtendedRcdwatchDTSurveyErrExtRcd_
 
edm::ESWatcher< DTSurveyRcdwatchDTSurveyRcd_
 
edm::ESWatcher< GlobalPositionRcdwatchGlobalPositionRcd_
 
edm::ESWatcher< IdealGeometryRecordwatchIdealGeometryRcd_
 
edm::ESWatcher< TrackerSurveyErrorExtendedRcdwatchTkSurveyErrExtRcd_
 
edm::ESWatcher< TrackerSurveyRcdwatchTkSurveyRcd_
 
edm::ESWatcher< TrackerAlignmentErrorExtendedRcdwatchTrackerAlErrorExtRcd_
 
edm::ESWatcher< TrackerAlignmentRcdwatchTrackerAlRcd_
 
edm::ESWatcher< TrackerSurfaceDeformationRcdwatchTrackerSurDeRcd_
 

Detailed Description

Definition at line 71 of file AlignmentProducerBase.h.

Constructor & Destructor Documentation

AlignmentProducerBase::AlignmentProducerBase ( const edm::ParameterSet config)
protected

Definition at line 35 of file AlignmentProducerBase.cc.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::algoConfig, applyDbAlignment_, beamSpotTag_, cond::TimeTypeSpecs::beginValue, checkDbAlignmentValidity_, clusterValueMapTag_, config_, createAlignmentAlgorithm(), createCalibrations(), createMonitors(), doMisalignmentScenario_, doMuon_, enableAlignableUpdates_, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getUntrackedParameter(), align::makeUniqueRunRanges(), runAtPCL_, cond::runnumber, saveApeToDB_, saveDeformationsToDB_, saveToDB_, stNFixAlignables_, stRandomRotation_, stRandomShift_, cond::timeTypeSpecs, tjTkAssociationMapTag_, tkLasBeamTag_, uniqueRunRanges_, useExtras_, and useSurvey_.

35  :
36  doTracker_{config.getUntrackedParameter<bool>("doTracker")},
37  doMuon_{config.getUntrackedParameter<bool>("doMuon")},
38  useExtras_{config.getUntrackedParameter<bool>("useExtras")},
39  tjTkAssociationMapTag_{config.getParameter<edm::InputTag>("tjTkAssociationMapTag")},
40  beamSpotTag_{config.getParameter<edm::InputTag>("beamSpotTag")},
41  tkLasBeamTag_{config.getParameter<edm::InputTag>("tkLasBeamTag")},
42  clusterValueMapTag_{config.getParameter<edm::InputTag>("hitPrescaleMapTag")},
44  {align::makeUniqueRunRanges(config.getParameter<edm::VParameterSet>("RunRangeSelection"),
46  config_{config},
47  stNFixAlignables_{config.getParameter<int>("nFixAlignables")},
48  stRandomShift_{config.getParameter<double>("randomShift")},
49  stRandomRotation_{config.getParameter<double>("randomRotation")},
50  applyDbAlignment_{config.getUntrackedParameter<bool>("applyDbAlignment")},
51  checkDbAlignmentValidity_{config.getUntrackedParameter<bool>("checkDbAlignmentValidity")},
52  doMisalignmentScenario_{config.getParameter<bool>("doMisalignmentScenario")},
53  saveToDB_{config.getParameter<bool>("saveToDB")},
54  saveApeToDB_{config.getParameter<bool>("saveApeToDB")},
55  saveDeformationsToDB_{config.getParameter<bool>("saveDeformationsToDB")},
56  useSurvey_{config.getParameter<bool>("useSurvey")},
57  enableAlignableUpdates_{config.getParameter<bool>("enableAlignableUpdates")}
58 {
59  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::AlignmentProducerBase";
60 
61  const auto& algoConfig = config_.getParameterSet("algoConfig");
62  if (hasParameter<bool>(config_, "runAtPCL")) {
63  // configured in main config?
64  runAtPCL_ = config_.getParameter<bool>("runAtPCL");
65 
66  if (hasParameter<bool>(algoConfig, "runAtPCL") &&
67  (runAtPCL_ != algoConfig.getParameter<bool>("runAtPCL"))) {
68  throw cms::Exception("BadConfig")
69  << "Inconsistent settings for 'runAtPCL' in configuration of the "
70  << "alignment producer and the alignment algorithm.";
71  }
72 
73  } else if (hasParameter<bool>(algoConfig, "runAtPCL")) {
74  // configured in algo config?
75  runAtPCL_ = algoConfig.getParameter<bool>("runAtPCL");
76 
77  } else {
78  // assume 'false' if it was not configured
79  runAtPCL_ = false;
80  }
81 
85 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const edm::InputTag tjTkAssociationMapTag_
Map with tracks/trajectories.
Time_t beginValue
Definition: Time.h:45
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:263
const edm::InputTag beamSpotTag_
BeamSpot.
ParameterSet const & getParameterSet(std::string const &) const
const align::RunRanges uniqueRunRanges_
void createCalibrations()
Creates the calibrations.
void createAlignmentAlgorithm()
Creates the choosen alignment algorithm.
const edm::InputTag tkLasBeamTag_
LAS beams in edm::Run (ignore if empty)
const edm::InputTag clusterValueMapTag_
ValueMap containing associtaion cluster-flag.
void createMonitors()
Creates the monitors.
AlignmentProducerBase::~AlignmentProducerBase ( )
protectedvirtual

Definition at line 90 of file AlignmentProducerBase.cc.

References alignableExtras_, alignableMuon_, alignableTracker_, alignmentParameterStore_, and calibrations_.

91 {
92  for (auto& iCal: calibrations_) delete iCal;
93 
95  delete alignableExtras_;
96  delete alignableTracker_;
97  delete alignableMuon_;
98 }
AlignableExtras * alignableExtras_
AlignmentParameterStore * alignmentParameterStore_
AlignableTracker * alignableTracker_

Member Function Documentation

void AlignmentProducerBase::addSurveyInfo ( Alignable ali)
private

Adds survey info to an Alignable.

Definition at line 871 of file AlignmentProducerBase.cc.

References Alignable::alignableObjectId(), AlCaHLTBitMon_QueryRunRegistry::comp, Alignable::components(), relativeConstraints::error, Exception, Alignable::id(), AlignableSurface::length(), Alignments::m_align, SurveyErrors::m_surveyErrors, SurveyError::matrix(), SurveyError::rawId(), makeMuonMisalignmentScenario::rot, AlignableSurface::setLength(), Alignable::setSurvey(), AlignableSurface::setWidth(), SurveyError::structureType(), Alignable::surface(), surveyErrors_, surveyIndex_, surveyValues_, and AlignableSurface::width().

Referenced by readInSurveyRcds().

872 {
873  const auto& comps = ali->components();
874 
875  for (const auto& comp: comps) addSurveyInfo(comp);
876 
878 
879  if ( ali->id() != error.rawId() ||
880  ali->alignableObjectId() != error.structureType() )
881  {
882  throw cms::Exception("DatabaseError")
883  << "Error reading survey info from DB. Mismatched id!";
884  }
885 
886  const auto& pos = surveyValues_->m_align[surveyIndex_].translation();
887  const auto& rot = surveyValues_->m_align[surveyIndex_].rotation();
888 
889  AlignableSurface surf(align::PositionType(pos.x(), pos.y(), pos.z()),
890  align::RotationType(rot.xx(), rot.xy(), rot.xz(),
891  rot.yx(), rot.yy(), rot.yz(),
892  rot.zx(), rot.zy(), rot.zz()));
893 
894  surf.setWidth(ali->surface().width());
895  surf.setLength(ali->surface().length());
896 
897  ali->setSurvey(new SurveyDet(surf, error.matrix()));
898 
899  ++surveyIndex_;
900 }
align::Scalar width() const
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
ErrorMatrix matrix() const
Definition: SurveyError.h:76
const Alignments * surveyValues_
uint8_t structureType() const
Definition: SurveyError.h:66
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual Alignables components() const =0
Return vector of all direct components.
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
align::ID rawId() const
Definition: SurveyError.h:71
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
align::Scalar length() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:356
const SurveyErrors * surveyErrors_
std::vector< SurveyError > m_surveyErrors
Definition: SurveyErrors.h:23
void AlignmentProducerBase::applyAlignmentsToDB ( const edm::EventSetup setup)
private

Applies Alignments from Database (GlobalPositionRcd) to Geometry

Definition at line 534 of file AlignmentProducerBase.cc.

References applyDB(), applyDbAlignment_, align::DetectorGlobalPosition(), doMuon_, doTracker_, edm::EventSetup::get(), globalPositions_, DetId::Muon, muonCSCGeometry_, muonDTGeometry_, GeneralSetup::setup(), DetId::Tracker, and trackerGeometry_.

Referenced by initAlignmentAlgorithm().

535 {
536  // Retrieve and apply alignments, if requested (requires z setup)
537  if (applyDbAlignment_) {
538  // we need GlobalPositionRcd - and have to keep track for later removal
539  // before writing again to DB...
540 
541  edm::ESHandle<Alignments> globalAlignments;
542  setup.get<GlobalPositionRcd>().get(globalAlignments);
543  globalPositions_ = std::make_unique<Alignments>(*globalAlignments);
544 
545  if (doTracker_) {
549  (trackerGeometry_.get(), setup,
551  );
552 
553  applyDB<TrackerGeometry,
555  }
556 
557  if (doMuon_) {
561  (muonDTGeometry_.get(), setup,
563  );
564 
568  (muonCSCGeometry_.get(), setup,
570  );
571  }
572  }
573 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::shared_ptr< TrackerGeometry > trackerGeometry_
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
std::shared_ptr< DTGeometry > muonDTGeometry_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
void applyDB(G *, const edm::EventSetup &, const AlignTransform &) const
void AlignmentProducerBase::applyAlignmentsToGeometry ( )
private

Applies Alignments, AlignmentErrors and SurfaceDeformations to

Definition at line 757 of file AlignmentProducerBase.cc.

References alignableMuon_, alignableTracker_, AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), GeometryAligner::applyAlignments(), GeometryAligner::attachSurfaceDeformations(), AlignableMuon::cscAlignmentErrorsExtended(), AlignableMuon::cscAlignments(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrorsExtended(), AlignableMuon::dtAlignments(), Exception, muonCSCGeometry_, muonDTGeometry_, Alignable::surfaceDeformations(), and trackerGeometry_.

Referenced by initAlignmentAlgorithm(), and startProcessing().

758 {
759  edm::LogInfo("Alignment")
760  << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry"
761  << "Now physically apply alignments to geometry...";
762 
763  // Propagate changes to reconstruction geometry (from initialisation or iteration)
764  GeometryAligner aligner;
765 
766  if (doTracker_) {
767  if (!alignableTracker_) {
768  throw cms::Exception("LogicError")
769  << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
770  << "Trying to apply tracker alignment before creating it.";
771  }
772 
773  std::unique_ptr<Alignments> alignments{alignableTracker_->alignments()};
774  std::unique_ptr<AlignmentErrorsExtended>
775  alignmentErrExt{alignableTracker_->alignmentErrors()};
776  std::unique_ptr<AlignmentSurfaceDeformations>
777  aliDeforms{alignableTracker_->surfaceDeformations()};
778 
779  aligner.applyAlignments(trackerGeometry_.get(), alignments.get(),
780  alignmentErrExt.get(), AlignTransform());
781  aligner.attachSurfaceDeformations(trackerGeometry_.get(), aliDeforms.get());
782  }
783 
784  if (doMuon_) {
785  if (!alignableMuon_) {
786  throw cms::Exception("LogicError")
787  << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
788  << "Trying to apply muon alignment before creating it.";
789  }
790 
791  std::unique_ptr<Alignments> dtAlignments{alignableMuon_->dtAlignments()};
792  std::unique_ptr<Alignments> cscAlignments{alignableMuon_->cscAlignments()};
793 
794  std::unique_ptr<AlignmentErrorsExtended>
795  dtAlignmentErrExt{alignableMuon_->dtAlignmentErrorsExtended()};
796  std::unique_ptr<AlignmentErrorsExtended>
797  cscAlignmentErrExt{alignableMuon_->cscAlignmentErrorsExtended()};
798 
799  aligner.applyAlignments(muonDTGeometry_.get(), dtAlignments.get(),
800  dtAlignmentErrExt.get(), AlignTransform());
801  aligner.applyAlignments(muonCSCGeometry_.get(), cscAlignments.get(),
802  cscAlignmentErrExt.get(), AlignTransform());
803  }
804 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
AlignmentErrorsExtended * alignmentErrors() const
Return alignment errors, sorted by DetId.
Class to update a given geometry with a set of alignments.
std::shared_ptr< TrackerGeometry > trackerGeometry_
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:264
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
AlignableTracker * alignableTracker_
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
std::shared_ptr< DTGeometry > muonDTGeometry_
Alignments * alignments() const
Return alignments, sorted by DetId.
template<class G , class Rcd , class ErrRcd >
void AlignmentProducerBase::applyDB ( G *  geometry,
const edm::EventSetup iSetup,
const AlignTransform globalCoordinates 
) const
private

Applies DB constants belonging to (Err)Rcd to Geometry, taking into account 'globalPosition' correction.

Definition at line 296 of file AlignmentProducerBase.h.

References GeometryAligner::applyAlignments(), edm::IOVSyncValue::beginOfTime(), checkDbAlignmentValidity_, edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), Exception, edm::ValidityInterval::first(), plotBeamSpotDB::first, callgraph::G, geometry, edm::EventSetup::get(), edm::ValidityInterval::last(), plotBeamSpotDB::last, record, and edm::EventID::run().

Referenced by applyAlignmentsToDB().

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 }
RunNumber_t run() const
Definition: EventID.h:39
const EventID & eventID() const
Definition: IOVSyncValue.h:42
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
const IOVSyncValue & last() const
static const IOVSyncValue & beginOfTime()
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
const T & get() const
Definition: EventSetup.h:56
ESHandle< TrackerGeometry > geometry
const IOVSyncValue & first() const
template<class G , class DeformationRcd >
void AlignmentProducerBase::applyDB ( G *  geometry,
const edm::EventSetup iSetup 
) const
private

Applies DB constants for SurfaceDeformations.

Definition at line 335 of file AlignmentProducerBase.h.

References GeometryAligner::attachSurfaceDeformations(), edm::IOVSyncValue::beginOfTime(), checkDbAlignmentValidity_, edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), Exception, edm::ValidityInterval::first(), plotBeamSpotDB::first, callgraph::G, geometry, edm::EventSetup::get(), edm::ValidityInterval::last(), plotBeamSpotDB::last, record, and edm::EventID::run().

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 }
RunNumber_t run() const
Definition: EventID.h:39
const EventID & eventID() const
Definition: IOVSyncValue.h:42
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
const IOVSyncValue & last() const
static const IOVSyncValue & beginOfTime()
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const T & get() const
Definition: EventSetup.h:56
ESHandle< TrackerGeometry > geometry
const IOVSyncValue & first() const
void AlignmentProducerBase::applyMisalignment ( )
private

Applies misalignment scenario to .

Definition at line 647 of file AlignmentProducerBase.cc.

References alignableMuon_, AlignmentParameterStore::alignables(), alignableTracker_, alignmentParameterStore_, MuonScenarioBuilder::applyScenario(), TrackerScenarioBuilder::applyScenario(), config_, doMisalignmentScenario_, doMuon_, doTracker_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), simpleMisalignment(), stRandomRotation_, stRandomShift_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by initAlignmentAlgorithm().

648 {
649  // Apply misalignment scenario to alignable tracker and muon if requested
650  // WARNING: this assumes scenarioConfig can be passed to both muon and tracker
651 
653  edm::LogInfo("Alignment")
654  << "@SUB=AlignmentProducerBase::applyMisalignment"
655  << "Applying misalignment scenario to "
656  << (doTracker_ ? "tracker" : "")
657  << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : ".");
658 
659  const auto& scenarioConfig = config_.getParameterSet("MisalignmentScenario");
660 
661  if (doTracker_) {
662  TrackerScenarioBuilder scenarioBuilder(alignableTracker_);
663  scenarioBuilder.applyScenario(scenarioConfig);
664  }
665  if (doMuon_) {
666  MuonScenarioBuilder muonScenarioBuilder(alignableMuon_);
667  muonScenarioBuilder.applyScenario(scenarioConfig);
668  }
669 
670  } else {
671  edm::LogInfo("Alignment")
672  << "@SUB=AlignmentProducerBase::applyMisalignment"
673  << "NOT applying misalignment scenario!";
674  }
675 
676  // Apply simple misalignment
677  const auto& sParSel =
678  config_.getParameter<std::string>("parameterSelectorSimple");
681 }
T getParameter(std::string const &) const
Builds a scenario from configuration and applies it to the alignable Muon.
AlignmentParameterStore * alignmentParameterStore_
AlignableTracker * alignableTracker_
ParameterSet const & getParameterSet(std::string const &) const
Builds a scenario from configuration and applies it to the alignable tracker.
void simpleMisalignment(const align::Alignables &, const std::string &, float, float, bool)
Applies misalignment scenario to .
const align::Alignables & alignables(void) const
get all alignables
void AlignmentProducerBase::beginLuminosityBlockImpl ( const edm::LuminosityBlock ,
const edm::EventSetup setup 
)
protected

begin lumi block

Definition at line 287 of file AlignmentProducerBase.cc.

References alignmentAlgo_.

Referenced by AlignmentProducerAsAnalyzer::beginLuminosityBlock(), and AlignmentProducer::beginLuminosityBlock().

289 {
290  // Do not forward edm::LuminosityBlock
291  alignmentAlgo_->beginLuminosityBlock(setup);
292 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::beginRunImpl ( const edm::Run run,
const edm::EventSetup setup 
)
protected

begin run

Definition at line 237 of file AlignmentProducerBase.cc.

References alignmentAlgo_, enableAlignableUpdates_, firstRun_, edm::RunBase::id(), initAlignmentAlgorithm(), edm::RunID::run(), runAtPCL_, and setupChanged().

Referenced by AlignmentProducerAsAnalyzer::beginRun(), and AlignmentProducer::beginRun().

238 {
239  const bool changed{setupChanged(setup)};
240  if (changed) {
241  edm::LogInfo("Alignment")
242  << "@SUB=AlignmentProducerBase::beginRunImpl"
243  << "EventSetup-Record changed.";
244 
245  // updatable alignables are currently not used at PCL, but event setup
246  // changes require a complete re-initialization
247  if (runAtPCL_) {
248  initAlignmentAlgorithm(setup, /* update = */ false);
249  } else if (enableAlignableUpdates_) {
250  initAlignmentAlgorithm(setup, /* update = */ true);
251  }
252  }
253 
254  alignmentAlgo_->beginRun(run, setup,
255  changed && (runAtPCL_ || enableAlignableUpdates_));
256 
257  //store the first run analyzed to be used for setting the IOV (for PCL)
258  if (firstRun_ > static_cast<cond::Time_t>(run.id().run())) {
259  firstRun_ = static_cast<cond::Time_t>(run.id().run());
260  }
261 }
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:39
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
unsigned long long Time_t
Definition: Time.h:16
bool setupChanged(const edm::EventSetup &)
Checks if one of the EventSetup-Records has changed.
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::buildParameterStore ( )
private

Creates the , which manages all Alignables.

Definition at line 608 of file AlignmentProducerBase.cc.

References alignableExtras_, alignableMuon_, alignableTracker_, AlignmentParameterStore_cfi::AlignmentParameterStore, alignmentParameterStore_, config_, edm::ParameterSet::getParameter(), and stNFixAlignables_.

Referenced by initAlignmentAlgorithm().

609 {
610  // Create alignment parameter builder
611  edm::LogInfo("Alignment")
612  << "@SUB=AlignmentProducerBase::buildParameterStore"
613  << "Creating AlignmentParameterBuilder";
614 
615  const auto& alParamBuildCfg =
616  config_.getParameter<edm::ParameterSet>("ParameterBuilder");
617  const auto& alParamStoreCfg =
618  config_.getParameter<edm::ParameterSet>("ParameterStore");
619 
620  AlignmentParameterBuilder alignmentParameterBuilder{alignableTracker_,
623  alParamBuildCfg};
624 
625  // Fix alignables if requested
626  if (stNFixAlignables_ > 0) {
627  alignmentParameterBuilder.fixAlignables(stNFixAlignables_);
628  }
629 
630  // Get list of alignables
631  const auto& alignables = alignmentParameterBuilder.alignables();
632  edm::LogInfo("Alignment")
633  << "@SUB=AlignmentProducerBase::buildParameterStore"
634  << "got " << alignables.size() << " alignables";
635 
636  // Create AlignmentParameterStore
638  new AlignmentParameterStore(alignables, alParamStoreCfg);
639  edm::LogInfo("Alignment")
640  << "@SUB=AlignmentProducerBase::buildParameterStore"
641  << "AlignmentParameterStore created!";
642 }
T getParameter(std::string const &) const
AlignableExtras * alignableExtras_
AlignmentParameterStore * alignmentParameterStore_
AlignableTracker * alignableTracker_
void AlignmentProducerBase::createAlignables ( const TrackerTopology tTopo,
bool  update = false 
)
private

Creates Alignables from the previously loaded Geometry

Definition at line 578 of file AlignmentProducerBase.cc.

References alignableExtras_, align::AlignableMuon, alignableMuon_, alignableTracker_, doMuon_, doTracker_, muonCSCGeometry_, muonDTGeometry_, trackerGeometry_, AlignableTracker::update(), AlignableMuon::update(), and useExtras_.

Referenced by initAlignmentAlgorithm().

579 {
580  if (doTracker_) {
581  if (update) {
583  } else {
585  }
586  }
587 
588  if (doMuon_) {
589  if (update) {
591  } else {
593  }
594  }
595 
596  if (useExtras_) {
597  if (update) {
598  // FIXME: Requires further code changes to track beam spot condition changes
599  } else {
601  }
602  }
603 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
void update(const DTGeometry *, const CSCGeometry *)
AlignableExtras * alignableExtras_
void update(const TrackerGeometry *, const TrackerTopology *)
std::shared_ptr< TrackerGeometry > trackerGeometry_
AlignableTracker * alignableTracker_
std::shared_ptr< DTGeometry > muonDTGeometry_
#define update(a, b)
void AlignmentProducerBase::createAlignmentAlgorithm ( )
private

Creates the choosen alignment algorithm.

Definition at line 308 of file AlignmentProducerBase.cc.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::algoConfig, HIPAlignmentAlgorithm_cfi::algoName, alignmentAlgo_, config_, enableAlignableUpdates_, Exception, reco::get(), edm::ParameterSet::getParameter(), runAtPCL_, AlCaHLTBitMon_QueryRunRegistry::string, and uniqueRunRanges_.

Referenced by AlignmentProducerBase().

309 {
310  auto algoConfig = config_.getParameter<edm::ParameterSet>("algoConfig");
311  algoConfig.addUntrackedParameter("RunRangeSelection",
312  config_.getParameter<edm::VParameterSet>("RunRangeSelection"));
313  algoConfig.addUntrackedParameter<align::RunNumber>("firstIOV",
314  runAtPCL_ ?
315  1 :
316  uniqueRunRanges_.front().first);
317  algoConfig.addUntrackedParameter("enableAlignableUpdates",
319 
320  const auto& algoName = algoConfig.getParameter<std::string>("algoName");
321  alignmentAlgo_ = std::unique_ptr<AlignmentAlgorithmBase>
323 
324  if (!alignmentAlgo_) {
325  throw cms::Exception("BadConfig")
326  << "Couldn't find the called alignment algorithm: " << algoName;
327  }
328 }
T getParameter(std::string const &) const
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
const align::RunRanges uniqueRunRanges_
T get(const Candidate &c)
Definition: component.h:55
cond::RealTimeType< cond::runnumber >::type RunNumber
Definition: Utilities.h:37
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::createCalibrations ( )
private

Creates the calibrations.

Definition at line 352 of file AlignmentProducerBase.cc.

References alignmentAlgo_, AlignmentProducer_cff::calibrations, calibrations_, config_, beamerCreator::create(), Exception, reco::get(), edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by AlignmentProducerBase().

353 {
354  const auto& calibrations = config_.getParameter<edm::VParameterSet>("calibrations");
355  for (const auto& iCalib: calibrations) {
357  ->create(iCalib.getParameter<std::string>("calibrationName"),
358  iCalib));
359  }
360 
361  // Not all algorithms support calibrations - so do not pass empty vector
362  // and throw if non-empty and not supported:
363  if (!calibrations_.empty()) {
364  if (alignmentAlgo_->supportsCalibrations()) {
365  alignmentAlgo_->addCalibrations(calibrations_);
366 
367  } else {
368  throw cms::Exception("BadConfig")
369  << "@SUB=AlignmentProducerBase::createCalibrations\n"
370  << "Configured " << calibrations_.size() << " calibration(s) "
371  << "for algorithm not supporting it.";
372  }
373  }
374 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::createGeometries ( const edm::EventSetup iSetup,
const TrackerTopology tTopo 
)
private

Creates ideal geometry from IdealGeometryRecord.

Definition at line 501 of file AlignmentProducerBase.cc.

References TrackerGeomBuilderFromGeometricDet::build(), CSCGeometryBuilderFromDDD::build(), DTGeometryBuilderFromDDD::build(), doMuon_, doTracker_, edm::EventSetup::get(), muonCSCGeometry_, muonDTGeometry_, and trackerGeometry_.

Referenced by initAlignmentAlgorithm().

503 {
504  if (doTracker_) {
505  edm::ESHandle<GeometricDet> geometricDet;
506  iSetup.get<IdealGeometryRecord>().get(geometricDet);
507 
509  iSetup.get<PTrackerParametersRcd>().get(ptp);
510 
511  TrackerGeomBuilderFromGeometricDet trackerBuilder;
512 
513  trackerGeometry_ = std::shared_ptr<TrackerGeometry>
514  (trackerBuilder.build(&(*geometricDet), *ptp, tTopo));
515  }
516 
517  if (doMuon_) {
519  iSetup.get<IdealGeometryRecord>().get(cpv);
521  iSetup.get<MuonNumberingRecord>().get(mdc);
522  DTGeometryBuilderFromDDD DTGeometryBuilder;
524  muonDTGeometry_ = std::make_shared<DTGeometry>();
525  DTGeometryBuilder.build(muonDTGeometry_, &(*cpv), *mdc);
526  muonCSCGeometry_ = std::make_shared<CSCGeometry>();
527  CSCGeometryBuilder.build(muonCSCGeometry_, &(*cpv), *mdc );
528  }
529 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
std::shared_ptr< TrackerGeometry > trackerGeometry_
const T & get() const
Definition: EventSetup.h:56
void build(std::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
std::shared_ptr< DTGeometry > muonDTGeometry_
void build(std::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
void AlignmentProducerBase::createMonitors ( )
private

Creates the monitors.

Definition at line 333 of file AlignmentProducerBase.cc.

References config_, Exception, reco::get(), edm::ParameterSet::getParameter(), AlignmentProducer_cff::monitorConfig, gather_cfg::monitors, monitors_, and eostools::move().

Referenced by AlignmentProducerBase().

334 {
335  const auto& monitorConfig = config_.getParameter<edm::ParameterSet>("monitorConfig");
336  auto monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >("monitors");
337  for (const auto& miter: monitors) {
338  std::unique_ptr<AlignmentMonitorBase> newMonitor
340  ->create(miter, monitorConfig.getUntrackedParameterSet(miter))};
341 
342  if (!newMonitor) {
343  throw cms::Exception("BadConfig") << "Couldn't find monitor named " << miter;
344  }
345  monitors_.emplace_back(std::move(newMonitor));
346  }
347 }
T getParameter(std::string const &) const
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55
void AlignmentProducerBase::endLuminosityBlockImpl ( const edm::LuminosityBlock ,
const edm::EventSetup setup 
)
protected

end lumi block

Definition at line 297 of file AlignmentProducerBase.cc.

References alignmentAlgo_.

Referenced by AlignmentProducerAsAnalyzer::endLuminosityBlock(), and AlignmentProducer::endLuminosityBlock().

299 {
300  // Do not forward edm::LuminosityBlock
301  alignmentAlgo_->endLuminosityBlock(setup);
302 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::endRunImpl ( const edm::Run run,
const edm::EventSetup setup 
)
protected

end run

Definition at line 266 of file AlignmentProducerBase.cc.

References alignmentAlgo_, edm::InputTag::encode(), getTkFittedLasBeamCollection(), getTsosVectorCollection(), edm::RunBase::id(), and tkLasBeamTag_.

Referenced by AlignmentProducerAsAnalyzer::endRun(), and AlignmentProducer::endRun().

267 {
268  if (tkLasBeamTag_.encode().size()) {
271  getTkFittedLasBeamCollection(run, lasBeams);
272  getTsosVectorCollection(run, tsoses);
273 
274  alignmentAlgo_->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup);
275  } else {
276  edm::LogInfo("Alignment")
277  << "@SUB=AlignmentProducerBase::endRunImpl"
278  << "No Tk LAS beams to forward to algorithm.";
279  alignmentAlgo_->endRun(EndRunInfo(run.id(), 0, 0), setup);
280  }
281 
282 }
RunID const & id() const
Definition: RunBase.h:39
std::string encode() const
Definition: InputTag.cc:165
virtual bool getTkFittedLasBeamCollection(const edm::Run &, edm::Handle< TkFittedLasBeamCollection > &)=0
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
AlignmentAlgorithmBase::EndRunInfo EndRunInfo
const edm::InputTag tkLasBeamTag_
LAS beams in edm::Run (ignore if empty)
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
bool AlignmentProducerBase::finish ( )
protected

Steers activities after end of job, terminates the AlignmentAlgorithm

Definition at line 905 of file AlignmentProducerBase.cc.

References alignmentAlgo_, calibrations_, Exception, isDuringLoop_, monitors_, nevent_, saveApeToDB_, saveDeformationsToDB_, saveToDB_, and storeAlignmentsToDB().

Referenced by progressbar.ProgressBar::__next__(), AlignmentProducerAsAnalyzer::endJob(), AlignmentProducer::endOfJob(), and nEvent().

906 {
907  if (isDuringLoop_) {
908  throw cms::Exception("LogicError")
909  << "@SUB=AlignmentProducerBase::finish\n"
910  << "Trying to finish before terminating event processing.";
911  }
912 
913  for (const auto& monitor: monitors_) monitor->endOfJob();
914 
915  if (alignmentAlgo_->processesEvents() && nevent_ == 0) {
916  return false;
917  }
918 
919  for (const auto& iCal:calibrations_) iCal->endOfJob();
920 
922  if (alignmentAlgo_->storeAlignments()) storeAlignmentsToDB();
923  } else {
924  edm::LogInfo("Alignment")
925  << "@SUB=AlignmentProducerBase::finish"
926  << "No payload to be stored!";
927  }
928 
929  return true;
930 }
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
virtual bool AlignmentProducerBase::getAliClusterValueMap ( const edm::Event ,
edm::Handle< AliClusterValueMap > &   
)
protectedpure virtual

Implemented in AlignmentProducer, and AlignmentProducerAsAnalyzer.

Referenced by nEvent(), and processEvent().

virtual bool AlignmentProducerBase::getBeamSpot ( const edm::Event ,
edm::Handle< reco::BeamSpot > &   
)
protectedpure virtual

Implemented in AlignmentProducer, and AlignmentProducerAsAnalyzer.

Referenced by initBeamSpot(), and nEvent().

virtual bool AlignmentProducerBase::getTkFittedLasBeamCollection ( const edm::Run ,
edm::Handle< TkFittedLasBeamCollection > &   
)
protectedpure virtual

Implemented in AlignmentProducer, and AlignmentProducerAsAnalyzer.

Referenced by endRunImpl(), and nEvent().

virtual bool AlignmentProducerBase::getTrajTrackAssociationCollection ( const edm::Event ,
edm::Handle< TrajTrackAssociationCollection > &   
)
protectedpure virtual

Implemented in AlignmentProducer, and AlignmentProducerAsAnalyzer.

Referenced by nEvent(), and processEvent().

virtual bool AlignmentProducerBase::getTsosVectorCollection ( const edm::Run ,
edm::Handle< TsosVectorCollection > &   
)
protectedpure virtual

Implemented in AlignmentProducer, and AlignmentProducerAsAnalyzer.

Referenced by endRunImpl(), and nEvent().

template<typename T >
bool AlignmentProducerBase::hasParameter ( const edm::ParameterSet config,
const std::string &  name 
)
private

Definition at line 1124 of file AlignmentProducerBase.cc.

References edm::Exception::categoryCode(), edm::errors::Configuration, MillePedeFileConverter_cfg::e, edm::ParameterSet::getParameter(), cms::Exception::message(), and dataset::name.

1126 {
1127  try {
1128  config.getParameter<T>(name);
1129  } catch (const edm::Exception& e) {
1131  if (e.message().find("MissingParameter") != std::string::npos) {
1132  return false;
1133  } else {
1134  throw;
1135  }
1136  } else {
1137  throw;
1138  }
1139  }
1140 
1141  return true;
1142 }
Code categoryCode() const
Definition: EDMException.h:93
T getParameter(std::string const &) const
std::string message() const
Definition: Exception.cc:187
long double T
void AlignmentProducerBase::initAlignmentAlgorithm ( const edm::EventSetup setup,
bool  update = false 
)
protected

Creates Geometry and Alignables of the Tracker and initializes the AlignmentAlgorithm

Definition at line 434 of file AlignmentProducerBase.cc.

References alignableExtras_, alignableMuon_, alignableTracker_, alignmentAlgo_, alignmentParameterStore_, applyAlignmentsToDB(), applyAlignmentsToGeometry(), applyMisalignment(), buildParameterStore(), calibrations_, createAlignables(), createGeometries(), edm::EventSetup::get(), isAlgoInitialized_, monitors_, edm::ESHandle< T >::product(), and startProcessing().

Referenced by AlignmentProducer::beginOfJob(), beginRunImpl(), nEvent(), and processEvent().

436 {
437  auto isTrueUpdate = update && isAlgoInitialized_;
438 
439  // Retrieve tracker topology from geometry
440  edm::ESHandle<TrackerTopology> tTopoHandle;
441  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
442  const TrackerTopology* const tTopo = tTopoHandle.product();
443 
444  // Create the geometries from the ideal geometries
445  createGeometries(setup, tTopo);
446 
447  applyAlignmentsToDB(setup);
448  createAlignables(tTopo, isTrueUpdate);
451 
452  // Initialize alignment algorithm and integrated calibration and pass the
453  // latter to algorithm
454  edm::LogInfo("Alignment")
455  << "@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
456  << "Initializing alignment algorithm.";
457  alignmentAlgo_->initialize(setup,
462  isAlgoInitialized_ = true;
463 
465 
466  if (!isTrueUpdate) { // only needed the first time
467  for (const auto& iCal: calibrations_) {
469  }
470  for (const auto& monitor: monitors_) {
472  }
473  }
474  startProcessing(); // needed if derived class is non-EDLooper-based
475  // has no effect, if called during loop
476 }
void applyAlignmentsToDB(const edm::EventSetup &)
void createGeometries(const edm::EventSetup &, const TrackerTopology *)
Creates ideal geometry from IdealGeometryRecord.
AlignableExtras * alignableExtras_
void buildParameterStore()
Creates the , which manages all Alignables.
AlignmentParameterStore * alignmentParameterStore_
void createAlignables(const TrackerTopology *, bool update=false)
void startProcessing()
Start processing of events.
AlignableTracker * alignableTracker_
void applyMisalignment()
Applies misalignment scenario to .
const T & get() const
Definition: EventSetup.h:56
#define update(a, b)
T const * product() const
Definition: ESHandle.h:86
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::initBeamSpot ( const edm::Event event)
private

Initializes Beamspot of Alignables .

Definition at line 481 of file AlignmentProducerBase.cc.

References alignableExtras_, beamSpot_, reco::BeamSpot::dxdz(), reco::BeamSpot::dydz(), getBeamSpot(), AlignableExtras::initializeBeamSpot(), nevent_, reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

Referenced by processEvent().

482 {
483  getBeamSpot(event, beamSpot_);
484 
485  if (nevent_== 0 && alignableExtras_) {
486  edm::LogInfo("Alignment")
487  << "@SUB=AlignmentProducerBase::initBeamSpot"
488  << "Initializing AlignableBeamSpot";
489 
491  beamSpot_->y0(),
492  beamSpot_->z0(),
493  beamSpot_->dxdz(),
494  beamSpot_->dydz());
495  }
496 }
double z0() const
z coordinate
Definition: BeamSpot.h:68
AlignableExtras * alignableExtras_
double dydz() const
dydz slope
Definition: BeamSpot.h:84
void initializeBeamSpot(double x, double y, double z, double dxdz, double dydz)
Initialize the alignable beam spot with the given parameters.
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
virtual bool getBeamSpot(const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
edm::Handle< reco::BeamSpot > beamSpot_
double y0() const
y coordinate
Definition: BeamSpot.h:66
double x0() const
x coordinate
Definition: BeamSpot.h:64
int AlignmentProducerBase::nEvent ( ) const
inlineprotected
bool AlignmentProducerBase::processEvent ( const edm::Event event,
const edm::EventSetup setup 
)
protected

Process event.

Definition at line 151 of file AlignmentProducerBase.cc.

References alignmentAlgo_, beamSpot_, edm::AssociationMap< Tag >::begin(), clusterValueMapTag_, enableAlignableUpdates_, edm::InputTag::encode(), edm::AssociationMap< Tag >::end(), dumpTauVariables_cfi::eventInfo, getAliClusterValueMap(), getTrajTrackAssociationCollection(), mps_fire::i, initAlignmentAlgorithm(), initBeamSpot(), monitors_, nevent_, readInSurveyRcds(), runAtPCL_, and setupChanged().

Referenced by AlignmentProducerAsAnalyzer::analyze(), and AlignmentProducer::duringLoop().

153 {
154  if (setupChanged(setup)) {
155  edm::LogInfo("Alignment")
156  << "@SUB=AlignmentProducerBase::processEvent"
157  << "EventSetup-Record changed.";
158 
159  // updatable alignables are currently not used at PCL, but event setup
160  // changes require a complete re-initialization
161  if (runAtPCL_) {
162  initAlignmentAlgorithm(setup, /* update = */ false);
163  } else if (enableAlignableUpdates_) {
164  initAlignmentAlgorithm(setup, /* update = */ true);
165  }
166  }
167 
168  initBeamSpot(event); // must happen every event and before incrementing 'nevent_'
169 
170  if (!alignmentAlgo_->processesEvents()) {
171  edm::LogWarning("BadConfig")
172  << "@SUB=AlignmentProducerBase::processEvent"
173  << "Skipping event. The current configuration of the alignment algorithm "
174  << "does not need to process any events.";
175  return false;
176  }
177 
178  ++nevent_;
179 
180  // reading in survey records
181  readInSurveyRcds(setup);
182 
183  // Printout event number
184  for ( int i=10; i<10000000; i*=10 ) {
185  if ( nevent_<10*i && (nevent_%i)==0 ) {
186  edm::LogInfo("Alignment")
187  << "@SUB=AlignmentProducerBase::processEvent"
188  << "Events processed: " << nevent_;
189  }
190  }
191 
192  // Retrieve trajectories and tracks from the event
193  // -> merely skip if collection is empty
194  edm::Handle<TrajTrackAssociationCollection> handleTrajTracksCollection;
195 
196  if (getTrajTrackAssociationCollection(event, handleTrajTracksCollection)) {
197 
198  // Form pairs of trajectories and tracks
199  ConstTrajTrackPairs trajTracks;
200  for (auto iter = handleTrajTracksCollection->begin();
201  iter != handleTrajTracksCollection->end();
202  ++iter) {
203  trajTracks.push_back(ConstTrajTrackPair(&(*(*iter).key), &(*(*iter).val)));
204  }
205 
206  // Run the alignment algorithm with its input
207  const AliClusterValueMap* clusterValueMapPtr{nullptr};
208  if (clusterValueMapTag_.encode().size()) {
209  edm::Handle<AliClusterValueMap> clusterValueMap;
210  getAliClusterValueMap(event, clusterValueMap);
211  clusterValueMapPtr = &(*clusterValueMap);
212  }
213 
214 
216  trajTracks,
217  *beamSpot_,
218  clusterValueMapPtr};
219  alignmentAlgo_->run(setup, eventInfo);
220 
221 
222  for (const auto& monitor: monitors_) {
223  monitor->duringLoop(event, setup, trajTracks); // forward eventInfo?
224  }
225  } else {
226  edm::LogError("Alignment")
227  << "@SUB=AlignmentProducerBase::processEvent"
228  << "No track collection found: skipping event";
229  }
230 
231  return true;
232 }
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
const_iterator end() const
last iterator over the map (read only)
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
std::string encode() const
Definition: InputTag.cc:165
define event information passed to algorithms
std::vector< ConstTrajTrackPair > ConstTrajTrackPairs
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
edm::Handle< reco::BeamSpot > beamSpot_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
bool setupChanged(const edm::EventSetup &)
Checks if one of the EventSetup-Records has changed.
void initBeamSpot(const edm::Event &)
Initializes Beamspot of Alignables .
const_iterator begin() const
first iterator over the map (read only)
eventInfo
add run, event number and lumi section
const edm::InputTag clusterValueMapTag_
ValueMap containing associtaion cluster-flag.
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::readInSurveyRcds ( const edm::EventSetup iSetup)
private

Reads in survey records.

Definition at line 809 of file AlignmentProducerBase.cc.

References addSurveyInfo(), alignableMuon_, alignableTracker_, Reference_intrackfit_cff::barrel, edm::ESWatcher< T >::check(), AlignableMuon::CSCEndcaps(), doMuon_, doTracker_, AlignableMuon::DTBarrel(), makeMuonMisalignmentScenario::endcap, edm::EventSetup::get(), surveyErrors_, surveyIndex_, surveyValues_, useSurvey_, watchTkSurveyErrExtRcd_, and watchTkSurveyRcd_.

Referenced by processEvent().

810 {
811 
812  // Get Survey Rcds and add Survey Info
813  if ( doTracker_ && useSurvey_ ){
814  bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup);
815  bool tkSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
816  edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool;
817  edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool;
818  if ( tkSurveyBool || tkSurveyErrBool){
819 
820  edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION";
822  edm::ESHandle<SurveyErrors> surveyErrors;
823 
824  iSetup.get<TrackerSurveyRcd>().get(surveys);
825  iSetup.get<TrackerSurveyErrorExtendedRcd>().get(surveyErrors);
826 
827  surveyIndex_ = 0;
828  surveyValues_ = &*surveys;
829  surveyErrors_ = &*surveyErrors;
831  }
832  }
833 
834  if ( doMuon_ && useSurvey_) {
835  bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup);
836  bool DTSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
837  bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup);
838  bool CSCSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
839 
840  if ( DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool ){
841  edm::ESHandle<Alignments> dtSurveys;
842  edm::ESHandle<SurveyErrors> dtSurveyErrors;
843  edm::ESHandle<Alignments> cscSurveys;
844  edm::ESHandle<SurveyErrors> cscSurveyErrors;
845 
846  iSetup.get<DTSurveyRcd>().get(dtSurveys);
847  iSetup.get<DTSurveyErrorExtendedRcd>().get(dtSurveyErrors);
848  iSetup.get<CSCSurveyRcd>().get(cscSurveys);
849  iSetup.get<CSCSurveyErrorExtendedRcd>().get(cscSurveyErrors);
850 
851  surveyIndex_ = 0;
852  surveyValues_ = &*dtSurveys;
853  surveyErrors_ = &*dtSurveyErrors;
854  const auto& barrels = alignableMuon_->DTBarrel();
855  for (const auto& barrel: barrels) addSurveyInfo(barrel);
856 
857  surveyIndex_ = 0;
858  surveyValues_ = &*cscSurveys;
859  surveyErrors_ = &*cscSurveyErrors;
860  const auto& endcaps = alignableMuon_->CSCEndcaps();
861  for (const auto& endcap: endcaps) addSurveyInfo(endcap);
862 
863  }
864  }
865 
866 }
align::Alignables DTBarrel()
const Alignments * surveyValues_
align::Alignables CSCEndcaps()
edm::ESWatcher< TrackerSurveyErrorExtendedRcd > watchTkSurveyErrExtRcd_
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
AlignableTracker * alignableTracker_
const T & get() const
Definition: EventSetup.h:56
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
const SurveyErrors * surveyErrors_
bool AlignmentProducerBase::setupChanged ( const edm::EventSetup setup)
private

Checks if one of the EventSetup-Records has changed.

Definition at line 379 of file AlignmentProducerBase.cc.

References edm::ESWatcher< T >::check(), doMuon_, doTracker_, watchCSCAlErrExtRcd_, watchCSCAlRcd_, watchDTAlErrExtRcd_, watchDTAlRcd_, watchGlobalPositionRcd_, watchIdealGeometryRcd_, watchTrackerAlErrorExtRcd_, watchTrackerAlRcd_, and watchTrackerSurDeRcd_.

Referenced by beginRunImpl(), and processEvent().

380 {
381  bool changed{false};
382 
383  if (watchIdealGeometryRcd_.check(setup)) {
384  changed = true;
385  }
386 
387  if (watchGlobalPositionRcd_.check(setup)) {
388  changed = true;
389  }
390 
391  if (doTracker_) {
392  if (watchTrackerAlRcd_.check(setup)) {
393  changed = true;
394  }
395 
396  if (watchTrackerAlErrorExtRcd_.check(setup)) {
397  changed = true;
398  }
399 
400  if (watchTrackerSurDeRcd_.check(setup)) {
401  changed = true;
402  }
403  }
404 
405  if (doMuon_) {
406  if (watchDTAlRcd_.check(setup)) {
407  changed = true;
408  }
409 
410  if (watchDTAlErrExtRcd_.check(setup)) {
411  changed = true;
412  }
413 
414  if (watchCSCAlRcd_.check(setup)) {
415  changed = true;
416  }
417 
418  if (watchCSCAlErrExtRcd_.check(setup)) {
419  changed = true;
420  }
421  }
422 
423  /* TODO: ExtraAlignables: Which record(s) to check?
424  *
425  if (useExtras_) {}
426  */
427 
428  return changed;
429 }
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
edm::ESWatcher< DTAlignmentRcd > watchDTAlRcd_
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
edm::ESWatcher< CSCAlignmentErrorExtendedRcd > watchCSCAlErrExtRcd_
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
edm::ESWatcher< TrackerAlignmentErrorExtendedRcd > watchTrackerAlErrorExtRcd_
edm::ESWatcher< CSCAlignmentRcd > watchCSCAlRcd_
void AlignmentProducerBase::simpleMisalignment ( const align::Alignables alivec,
const std::string &  selection,
float  shift,
float  rot,
bool  local 
)
private

Applies misalignment scenario to .

Definition at line 686 of file AlignmentProducerBase.cc.

References funct::abs(), AlignmentParameterSelector::convertParamSel(), RigidBodyAlignmentParameters::dalpha, RigidBodyAlignmentParameters::dbeta, RigidBodyAlignmentParameters::dgamma, RigidBodyAlignmentParameters::dx, RigidBodyAlignmentParameters::dy, RigidBodyAlignmentParameters::dz, Exception, RigidBodyAlignmentParameters::N_PARAM, convertSQLitetoXML_cfg::output, alignCSCRings::r, random, indexGen::s2, and align::toMatrix().

Referenced by applyMisalignment().

689 {
690 
691  std::ostringstream output; // collecting output
692 
693  if (shift > 0. || rot > 0.) {
694  output << "Adding random flat shift of max size " << shift
695  << " and adding random flat rotation of max size " << rot <<" to ";
696 
697  std::vector<bool> commSel(0);
698  if (selection != "-1") {
699  AlignmentParameterSelector aSelector(0,0); // no alignable needed here...
700  const std::vector<char> cSel(aSelector.convertParamSel(selection));
701  if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) {
702  throw cms::Exception("BadConfig")
703  << "[AlignmentProducerBase::simpleMisalignment_]\n"
704  << "Expect selection string '" << selection << "' to be at least of length "
705  << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n"
706  << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
707  }
708  for (const auto& cIter: cSel) {
709  commSel.push_back(cIter == '0' ? false : true);
710  }
711  output << "parameters defined by (" << selection
712  << "), representing (x,y,z,alpha,beta,gamma),";
713  } else {
714  output << "the active parameters of each alignable,";
715  }
716  output << " in " << (local ? "local" : "global") << " frame.";
717 
718  for (const auto& ali: alivec) {
719  std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
720 
721  if (std::abs(shift)>0.00001) {
722  double s0 = 0., s1 = 0., s2 = 0.;
723  if (mysel[RigidBodyAlignmentParameters::dx]) s0 = shift * double(random()%1000-500)/500.;
724  if (mysel[RigidBodyAlignmentParameters::dy]) s1 = shift * double(random()%1000-500)/500.;
725  if (mysel[RigidBodyAlignmentParameters::dz]) s2 = shift * double(random()%1000-500)/500.;
726 
727  if (local) ali->move(ali->surface().toGlobal(align::LocalVector(s0,s1,s2)));
728  else ali->move(align::GlobalVector(s0,s1,s2));
729 
730  //AlignmentPositionError ape(dx,dy,dz);
731  //ali->addAlignmentPositionError(ape);
732  }
733 
734  if (std::abs(rot)>0.00001) {
736  if (mysel[RigidBodyAlignmentParameters::dalpha]) r(1)=rot*double(random()%1000-500)/500.;
737  if (mysel[RigidBodyAlignmentParameters::dbeta]) r(2)=rot*double(random()%1000-500)/500.;
738  if (mysel[RigidBodyAlignmentParameters::dgamma]) r(3)=rot*double(random()%1000-500)/500.;
739 
740  const align::RotationType mrot = align::toMatrix(r);
741  if (local) ali->rotateInLocalFrame(mrot);
742  else ali->rotateInGlobalFrame(mrot);
743 
744  //ali->addAlignmentPositionErrorFromRotation(mrot);
745  }
746  } // end loop on alignables
747  } else {
748  output << "No simple misalignment added!";
749  }
750  edm::LogInfo("Alignment")
751  << "@SUB=AlignmentProducerBase::simpleMisalignment" << output.str();
752 }
selection
main part
Definition: corrVsCorr.py:98
TRandom random
Definition: MVATrainer.cc:138
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
AlgebraicVector EulerAngles
Definition: Definitions.h:36
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:42
static unsigned int const shift
void AlignmentProducerBase::startProcessing ( )
protected

Start processing of events.

Definition at line 103 of file AlignmentProducerBase.cc.

References alignmentAlgo_, applyAlignmentsToGeometry(), calibrations_, Exception, isAlgoInitialized_, isDuringLoop_, monitors_, and nevent_.

Referenced by initAlignmentAlgorithm(), and AlignmentProducer::startingNewLoop().

104 {
105  if (isDuringLoop_) return;
106  if (!isAlgoInitialized_) {
107  throw cms::Exception("LogicError")
108  << "@SUB=AlignmentProducerBase::startProcessing\n"
109  << "Trying to start event processing before initializing the alignment "
110  << "algorithm.";
111  }
112 
113  nevent_ = 0;
114 
115  alignmentAlgo_->startNewLoop();
116 
117  // FIXME: Should this be done in algorithm::startNewLoop()??
118  for (const auto& iCal: calibrations_) iCal->startNewLoop();
119  for (const auto& monitor: monitors_) monitor->startingNewLoop();
120 
122  isDuringLoop_ = true;
123 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::storeAlignmentsToDB ( )
private

Writes Alignments (i.e. Records) to database-file.

Definition at line 935 of file AlignmentProducerBase.cc.

References alignableExtras_, alignmentAlgo_, AlignableExtras::beamSpot(), config_, Exception, firstRun_, edm::ParameterSet::getParameterSetVector(), align::makeUniqueRunRanges(), runAtPCL_, saveApeToDB_, saveDeformationsToDB_, saveToDB_, uniqueRunRanges_, and writeForRunRange().

Referenced by finish().

936 {
937  const auto runRangeSelectionVPSet =
938  config_.getParameterSetVector("RunRangeSelection");
939 
940  // handle PCL use case
941  const auto& uniqueRunRanges =
942  (runAtPCL_ ?
943  align::makeUniqueRunRanges(runRangeSelectionVPSet, firstRun_) :
945 
946  std::vector<AlgebraicVector> beamSpotParameters;
947 
948  for (const auto& iRunRange: uniqueRunRanges) {
949 
950  alignmentAlgo_->setParametersForRunRange(iRunRange);
951 
952  // Save alignments to database
954  writeForRunRange(iRunRange.first);
955  }
956 
957  // Deal with extra alignables, e.g. beam spot
958  if (alignableExtras_) {
959  auto& alis = alignableExtras_->beamSpot();
960  if (!alis.empty()) {
961  auto beamSpotAliPars =
962  dynamic_cast<BeamSpotAlignmentParameters*>(alis[0]->alignmentParameters());
963  if (!beamSpotAliPars) {
964  throw cms::Exception("LogicError")
965  << "@SUB=AlignmentProducerBase::storeAlignmentsToDB\n"
966  << "First alignable of alignableExtras_ does not have "
967  << "'BeamSpotAlignmentParameters', while it should have.";
968  }
969 
970  beamSpotParameters.push_back(beamSpotAliPars->parameters());
971  }
972  }
973  }
974 
975  if (alignableExtras_) {
976  std::ostringstream bsOutput;
977 
978  auto itPar = beamSpotParameters.cbegin();
979  for (auto iRunRange = uniqueRunRanges.cbegin();
980  iRunRange != uniqueRunRanges.cend();
981  ++iRunRange, ++itPar) {
982  bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n";
983  bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n";
984  bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n";
985  }
986 
987  edm::LogInfo("Alignment")
988  << "@SUB=AlignmentProducerBase::storeAlignmentsToDB"
989  << "Parameters for alignable beamspot:\n" << bsOutput.str();
990  }
991 }
VParameterSet const & getParameterSetVector(std::string const &name) const
AlignableExtras * alignableExtras_
void writeForRunRange(cond::Time_t)
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:263
const align::RunRanges uniqueRunRanges_
Alignables & beamSpot()
Return beam spot alignable as a vector with one element.
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::terminateProcessing ( const edm::EventSetup setup = 0)
protected

Terminate processing of events.

Definition at line 128 of file AlignmentProducerBase.cc.

References alignmentAlgo_, calibrations_, isDuringLoop_, and monitors_.

Referenced by AlignmentProducerAsAnalyzer::endJob(), and AlignmentProducer::endOfLoop().

129 {
130  if (!isDuringLoop_) return;
131 
132  edm::LogInfo("Alignment")
133  << "@SUB=AlignmentProducerBase::terminateProcessing"
134  << "Terminating algorithm.";
135  if (setup) {
136  alignmentAlgo_->terminate(*setup);
137  } else {
138  alignmentAlgo_->terminate();
139  }
140 
141  // FIXME: Should this be done in algorithm::terminate()??
142  for (const auto& iCal:calibrations_) iCal->endOfLoop();
143  for (const auto& monitor: monitors_) monitor->endOfLoop();
144 
145  isDuringLoop_ = false;
146 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::writeDB ( Alignments alignments,
const std::string &  alignRcd,
AlignmentErrorsExtended alignmentErrors,
const std::string &  errRcd,
const AlignTransform globalCoordinates,
cond::Time_t  time 
) const
private

Writes Alignments and/or AlignmentErrors to DB for record names (removes *globalCoordinates before writing if non-null...). Takes over ownership of Alignments and AlignmentErrors.

Definition at line 1042 of file AlignmentProducerBase.cc.

References Exception, edm::Service< T >::isAvailable(), GeometryAligner::removeGlobalTransform(), saveApeToDB_, saveToDB_, ntuplemaker::time, AlignTransform::transform(), and cond::service::PoolDBOutputService::writeOne().

Referenced by writeForRunRange().

1048 {
1049  Alignments* tempAlignments = alignments;
1050  AlignmentErrorsExtended* tempAlignmentErrorsExtended = alignmentErrors;
1051 
1052  // Call service
1054  if (!poolDb.isAvailable()) { // Die if not available
1055  delete tempAlignments; // promised to take over ownership...
1056  delete tempAlignmentErrorsExtended; // dito
1057  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
1058  }
1059 
1060  if (globalCoordinates // happens only if (applyDbAlignment_ == true)
1061  && globalCoordinates->transform() != AlignTransform::Transform::Identity) {
1062 
1063  tempAlignments = new Alignments(); // temporary storage for
1064  tempAlignmentErrorsExtended = new AlignmentErrorsExtended(); // final alignments and errors
1065 
1066  GeometryAligner aligner;
1067  aligner.removeGlobalTransform(alignments, alignmentErrors,
1068  *globalCoordinates,
1069  tempAlignments, tempAlignmentErrorsExtended);
1070 
1071  delete alignments; // have to delete original alignments
1072  delete alignmentErrors; // same thing for the errors
1073 
1074  edm::LogInfo("Alignment")
1075  << "@SUB=AlignmentProducerBase::writeDB"
1076  << "globalCoordinates removed from alignments (" << alignRcd
1077  << ") and errors (" << alignRcd << ").";
1078  }
1079 
1080  if (saveToDB_) {
1081  edm::LogInfo("Alignment") << "Writing Alignments for run " << time
1082  << " to " << alignRcd << ".";
1083  poolDb->writeOne<Alignments>(tempAlignments, time, alignRcd);
1084  } else { // poolDb->writeOne(..) takes over 'alignments' ownership,...
1085  delete tempAlignments; // ...otherwise we have to delete, as promised!
1086  }
1087 
1088  if (saveApeToDB_) {
1089  edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " << time
1090  << " to " << errRcd << ".";
1091  poolDb->writeOne<AlignmentErrorsExtended>(tempAlignmentErrorsExtended, time, errRcd);
1092  } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,...
1093  delete tempAlignmentErrorsExtended; // ...otherwise we have to delete, as promised!
1094  }
1095 }
Class to update a given geometry with a set of alignments.
void removeGlobalTransform(const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates, Alignments *newAlignments, AlignmentErrorsExtended *newAlignmentErrorsExtended)
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
Transform transform() const
void AlignmentProducerBase::writeDB ( AlignmentSurfaceDeformations alignmentSurfaceDeformations,
const std::string &  surfaceDeformationRcd,
cond::Time_t  time 
) const
private

Writes SurfaceDeformations (bows & kinks) to DB for given record name Takes over ownership of AlignmentSurfaceDeformations.

Definition at line 1099 of file AlignmentProducerBase.cc.

References Exception, edm::Service< T >::isAvailable(), saveDeformationsToDB_, ntuplemaker::time, and cond::service::PoolDBOutputService::writeOne().

1102 {
1103  // Call service
1105  if (!poolDb.isAvailable()) { // Die if not available
1106  delete alignmentSurfaceDeformations; // promised to take over ownership...
1107  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
1108  }
1109 
1110  if (saveDeformationsToDB_) {
1111  edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time
1112  << " to " << surfaceDeformationRcd << ".";
1113  poolDb->writeOne<AlignmentSurfaceDeformations>(alignmentSurfaceDeformations, time,
1114  surfaceDeformationRcd);
1115  } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,...
1116  delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised!
1117  }
1118 }
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void AlignmentProducerBase::writeForRunRange ( cond::Time_t  time)
private

Writes Alignments and AlignmentErrors for all sub detectors and the given run number

Definition at line 996 of file AlignmentProducerBase.cc.

References alignableMuon_, alignableTracker_, AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), AlignableMuon::cscAlignmentErrorsExtended(), AlignableMuon::cscAlignments(), align::DetectorGlobalPosition(), doMuon_, doTracker_, AlignableMuon::dtAlignmentErrorsExtended(), AlignableMuon::dtAlignments(), globalPositions_, DetId::Muon, saveDeformationsToDB_, Alignable::surfaceDeformations(), DetId::Tracker, and writeDB().

Referenced by storeAlignmentsToDB().

997 {
998  if (doTracker_) { // first tracker
999  const AlignTransform* trackerGlobal{nullptr}; // will be 'removed' from constants
1000  if (globalPositions_) { // i.e. applied before in applyDB
1003  }
1004 
1005  auto alignments = alignableTracker_->alignments();
1006  auto alignmentErrors = alignableTracker_->alignmentErrors();
1007  this->writeDB(alignments, "TrackerAlignmentRcd",
1008  alignmentErrors, "TrackerAlignmentErrorExtendedRcd", trackerGlobal,
1009  time);
1010 
1011  // Save surface deformations to database
1012  if (saveDeformationsToDB_) {
1013  auto alignmentSurfaceDeformations = alignableTracker_->surfaceDeformations();
1014  this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time);
1015  }
1016  }
1017 
1018  if (doMuon_) { // now muon
1019  const AlignTransform* muonGlobal{nullptr}; // will be 'removed' from constants
1020  if (globalPositions_) { // i.e. applied before in applyDB
1022  DetId(DetId::Muon));
1023  }
1024  // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete
1025  auto alignments = alignableMuon_->dtAlignments();
1026  auto alignmentErrors = alignableMuon_->dtAlignmentErrorsExtended();
1027  this->writeDB(alignments, "DTAlignmentRcd",
1028  alignmentErrors, "DTAlignmentErrorExtendedRcd", muonGlobal,
1029  time);
1030 
1031  // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete
1032  alignments = alignableMuon_->cscAlignments();
1033  alignmentErrors = alignableMuon_->cscAlignmentErrorsExtended();
1034  this->writeDB(alignments, "CSCAlignmentRcd",
1035  alignmentErrors, "CSCAlignmentErrorExtendedRcd", muonGlobal,
1036  time);
1037  }
1038 }
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
AlignmentErrorsExtended * alignmentErrors() const
Return alignment errors, sorted by DetId.
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:264
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
Definition: DetId.h:18
AlignableTracker * alignableTracker_
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Alignments * alignments() const
Return alignments, sorted by DetId.

Member Data Documentation

AlignableExtras* AlignmentProducerBase::alignableExtras_ { 0 }
private
AlignableMuon* AlignmentProducerBase::alignableMuon_ { 0 }
private
AlignableTracker* AlignmentProducerBase::alignableTracker_ { 0 }
private
std::unique_ptr<AlignmentAlgorithmBase> AlignmentProducerBase::alignmentAlgo_
private
AlignmentParameterStore* AlignmentProducerBase::alignmentParameterStore_ { 0 }
private
const bool AlignmentProducerBase::applyDbAlignment_
private

Definition at line 247 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyAlignmentsToDB().

edm::Handle<reco::BeamSpot> AlignmentProducerBase::beamSpot_
private

Definition at line 232 of file AlignmentProducerBase.h.

Referenced by initBeamSpot(), and processEvent().

const edm::InputTag AlignmentProducerBase::beamSpotTag_
protected
Calibrations AlignmentProducerBase::calibrations_
private
const bool AlignmentProducerBase::checkDbAlignmentValidity_
private

Definition at line 247 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyDB().

const edm::InputTag AlignmentProducerBase::clusterValueMapTag_
protected
edm::ParameterSet AlignmentProducerBase::config_
private
const bool AlignmentProducerBase::doMisalignmentScenario_
private

Definition at line 248 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyMisalignment().

const bool AlignmentProducerBase::doMuon_
protected
const bool AlignmentProducerBase::doTracker_
protected
const bool AlignmentProducerBase::enableAlignableUpdates_
private
cond::Time_t AlignmentProducerBase::firstRun_ {cond::timeTypeSpecs[cond::runnumber].endValue}
private

Definition at line 288 of file AlignmentProducerBase.h.

Referenced by beginRunImpl(), and storeAlignmentsToDB().

std::unique_ptr<const Alignments> AlignmentProducerBase::globalPositions_
private

GlobalPositions that might be read from DB, nullptr otherwise.

Definition at line 234 of file AlignmentProducerBase.h.

Referenced by applyAlignmentsToDB(), and writeForRunRange().

bool AlignmentProducerBase::isAlgoInitialized_ {false}
private

Definition at line 284 of file AlignmentProducerBase.h.

Referenced by initAlignmentAlgorithm(), and startProcessing().

bool AlignmentProducerBase::isDuringLoop_ {false}
private

Definition at line 285 of file AlignmentProducerBase.h.

Referenced by finish(), startProcessing(), and terminateProcessing().

AlignmentMonitors AlignmentProducerBase::monitors_
private
std::shared_ptr<CSCGeometry> AlignmentProducerBase::muonCSCGeometry_
protected
std::shared_ptr<DTGeometry> AlignmentProducerBase::muonDTGeometry_
protected
int AlignmentProducerBase::nevent_ {0}
private

Definition at line 237 of file AlignmentProducerBase.h.

Referenced by finish(), initBeamSpot(), nEvent(), processEvent(), and startProcessing().

bool AlignmentProducerBase::runAtPCL_ {false}
private
const bool AlignmentProducerBase::saveApeToDB_
private
const bool AlignmentProducerBase::saveDeformationsToDB_
private
const bool AlignmentProducerBase::saveToDB_
private
const int AlignmentProducerBase::stNFixAlignables_
private

Definition at line 245 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and buildParameterStore().

const double AlignmentProducerBase::stRandomRotation_
private

Definition at line 246 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyMisalignment().

const double AlignmentProducerBase::stRandomShift_
private

Definition at line 246 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyMisalignment().

const SurveyErrors* AlignmentProducerBase::surveyErrors_ { 0 }
private

Definition at line 280 of file AlignmentProducerBase.h.

Referenced by addSurveyInfo(), and readInSurveyRcds().

size_t AlignmentProducerBase::surveyIndex_ {0}
private

Definition at line 278 of file AlignmentProducerBase.h.

Referenced by addSurveyInfo(), and readInSurveyRcds().

const Alignments* AlignmentProducerBase::surveyValues_ { 0 }
private

Definition at line 279 of file AlignmentProducerBase.h.

Referenced by addSurveyInfo(), and readInSurveyRcds().

const edm::InputTag AlignmentProducerBase::tjTkAssociationMapTag_
protected
const edm::InputTag AlignmentProducerBase::tkLasBeamTag_
protected
std::shared_ptr<TrackerGeometry> AlignmentProducerBase::trackerGeometry_
protected
const align::RunRanges AlignmentProducerBase::uniqueRunRanges_
private
const bool AlignmentProducerBase::useExtras_
protected

Definition at line 124 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and createAlignables().

const bool AlignmentProducerBase::useSurvey_
private

Definition at line 250 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and readInSurveyRcds().

edm::ESWatcher<CSCAlignmentErrorExtendedRcd> AlignmentProducerBase::watchCSCAlErrExtRcd_
private

Definition at line 266 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<CSCAlignmentRcd> AlignmentProducerBase::watchCSCAlRcd_
private

Definition at line 265 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<CSCSurveyErrorExtendedRcd> AlignmentProducerBase::watchCSCSurveyErrExtRcd_
private

Definition at line 273 of file AlignmentProducerBase.h.

edm::ESWatcher<CSCSurveyRcd> AlignmentProducerBase::watchCSCSurveyRcd_
private

Definition at line 272 of file AlignmentProducerBase.h.

edm::ESWatcher<DTAlignmentErrorExtendedRcd> AlignmentProducerBase::watchDTAlErrExtRcd_
private

Definition at line 264 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<DTAlignmentRcd> AlignmentProducerBase::watchDTAlRcd_
private

Definition at line 263 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<DTSurveyErrorExtendedRcd> AlignmentProducerBase::watchDTSurveyErrExtRcd_
private

Definition at line 271 of file AlignmentProducerBase.h.

edm::ESWatcher<DTSurveyRcd> AlignmentProducerBase::watchDTSurveyRcd_
private

Definition at line 270 of file AlignmentProducerBase.h.

edm::ESWatcher<GlobalPositionRcd> AlignmentProducerBase::watchGlobalPositionRcd_
private

Definition at line 257 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<IdealGeometryRecord> AlignmentProducerBase::watchIdealGeometryRcd_
private

Definition at line 256 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<TrackerSurveyErrorExtendedRcd> AlignmentProducerBase::watchTkSurveyErrExtRcd_
private

Definition at line 269 of file AlignmentProducerBase.h.

Referenced by readInSurveyRcds().

edm::ESWatcher<TrackerSurveyRcd> AlignmentProducerBase::watchTkSurveyRcd_
private

Definition at line 268 of file AlignmentProducerBase.h.

Referenced by readInSurveyRcds().

edm::ESWatcher<TrackerAlignmentErrorExtendedRcd> AlignmentProducerBase::watchTrackerAlErrorExtRcd_
private

Definition at line 260 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<TrackerAlignmentRcd> AlignmentProducerBase::watchTrackerAlRcd_
private

Definition at line 259 of file AlignmentProducerBase.h.

Referenced by setupChanged().

edm::ESWatcher<TrackerSurfaceDeformationRcd> AlignmentProducerBase::watchTrackerSurDeRcd_
private

Definition at line 261 of file AlignmentProducerBase.h.

Referenced by setupChanged().