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 69 of file AlignmentProducerBase.h.

Constructor & Destructor Documentation

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

Definition at line 34 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  : doTracker_{config.getUntrackedParameter<bool>("doTracker")},
36  doMuon_{config.getUntrackedParameter<bool>("doMuon")},
37  useExtras_{config.getUntrackedParameter<bool>("useExtras")},
38  tjTkAssociationMapTag_{config.getParameter<edm::InputTag>("tjTkAssociationMapTag")},
39  beamSpotTag_{config.getParameter<edm::InputTag>("beamSpotTag")},
40  tkLasBeamTag_{config.getParameter<edm::InputTag>("tkLasBeamTag")},
41  clusterValueMapTag_{config.getParameter<edm::InputTag>("hitPrescaleMapTag")},
44  config_{config},
45  stNFixAlignables_{config.getParameter<int>("nFixAlignables")},
46  stRandomShift_{config.getParameter<double>("randomShift")},
47  stRandomRotation_{config.getParameter<double>("randomRotation")},
48  applyDbAlignment_{config.getUntrackedParameter<bool>("applyDbAlignment")},
49  checkDbAlignmentValidity_{config.getUntrackedParameter<bool>("checkDbAlignmentValidity")},
50  doMisalignmentScenario_{config.getParameter<bool>("doMisalignmentScenario")},
51  saveToDB_{config.getParameter<bool>("saveToDB")},
52  saveApeToDB_{config.getParameter<bool>("saveApeToDB")},
53  saveDeformationsToDB_{config.getParameter<bool>("saveDeformationsToDB")},
54  useSurvey_{config.getParameter<bool>("useSurvey")},
55  enableAlignableUpdates_{config.getParameter<bool>("enableAlignableUpdates")} {
56  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::AlignmentProducerBase";
57 
58  const auto& algoConfig = config_.getParameterSet("algoConfig");
59  if (hasParameter<bool>(config_, "runAtPCL")) {
60  // configured in main config?
61  runAtPCL_ = config_.getParameter<bool>("runAtPCL");
62 
63  if (hasParameter<bool>(algoConfig, "runAtPCL") && (runAtPCL_ != algoConfig.getParameter<bool>("runAtPCL"))) {
64  throw cms::Exception("BadConfig") << "Inconsistent settings for 'runAtPCL' in configuration of the "
65  << "alignment producer and the alignment algorithm.";
66  }
67 
68  } else if (hasParameter<bool>(algoConfig, "runAtPCL")) {
69  // configured in algo config?
70  runAtPCL_ = algoConfig.getParameter<bool>("runAtPCL");
71 
72  } else {
73  // assume 'false' if it was not configured
74  runAtPCL_ = false;
75  }
76 
80 }
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 83 of file AlignmentProducerBase.cc.

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

83  {
84  for (auto& iCal : calibrations_)
85  delete iCal;
86 
88  delete alignableExtras_;
89  delete alignableTracker_;
90  delete alignableMuon_;
91 }
AlignableExtras * alignableExtras_
AlignmentParameterStore * alignmentParameterStore_
AlignableTracker * alignableTracker_

Member Function Documentation

void AlignmentProducerBase::addSurveyInfo ( Alignable ali)
private

Adds survey info to an Alignable.

Definition at line 744 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().

744  {
745  const auto& comps = ali->components();
746 
747  for (const auto& comp : comps)
749 
751 
752  if (ali->id() != error.rawId() || ali->alignableObjectId() != error.structureType()) {
753  throw cms::Exception("DatabaseError") << "Error reading survey info from DB. Mismatched id!";
754  }
755 
756  const auto& pos = surveyValues_->m_align[surveyIndex_].translation();
757  const auto& rot = surveyValues_->m_align[surveyIndex_].rotation();
758 
759  AlignableSurface surf(
760  align::PositionType(pos.x(), pos.y(), pos.z()),
761  align::RotationType(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
762 
763  surf.setWidth(ali->surface().width());
764  surf.setLength(ali->surface().length());
765 
766  ali->setSurvey(new SurveyDet(surf, error.matrix()));
767 
768  ++surveyIndex_;
769 }
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_
virtual const Alignables & components() const =0
Return vector of all direct components.
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.
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:340
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 460 of file AlignmentProducerBase.cc.

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

Referenced by initAlignmentAlgorithm().

460  {
461  // Retrieve and apply alignments, if requested (requires z setup)
462  if (applyDbAlignment_) {
463  // we need GlobalPositionRcd - and have to keep track for later removal
464  // before writing again to DB...
465 
466  edm::ESHandle<Alignments> globalAlignments;
467  setup.get<GlobalPositionRcd>().get(globalAlignments);
468  globalPositions_ = std::make_unique<Alignments>(*globalAlignments);
469 
470  if (doTracker_) {
471  applyDB<TrackerGeometry, TrackerAlignmentRcd, TrackerAlignmentErrorExtendedRcd>(
473 
474  applyDB<TrackerGeometry, TrackerSurfaceDeformationRcd>(trackerGeometry_.get(), setup);
475  }
476 
477  if (doMuon_) {
478  applyDB<DTGeometry, DTAlignmentRcd, DTAlignmentErrorExtendedRcd>(
480 
481  applyDB<CSCGeometry, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd>(
483  }
484  }
485 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::shared_ptr< TrackerGeometry > trackerGeometry_
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
Definition: DetId.h:18
std::shared_ptr< DTGeometry > muonDTGeometry_
T get() const
Definition: EventSetup.h:71
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
void AlignmentProducerBase::applyAlignmentsToGeometry ( )
private

Applies Alignments, AlignmentErrors and SurfaceDeformations to

Definition at line 648 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().

648  {
649  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry"
650  << "Now physically apply alignments to geometry...";
651 
652  // Propagate changes to reconstruction geometry (from initialisation or iteration)
653  GeometryAligner aligner;
654 
655  if (doTracker_) {
656  if (!alignableTracker_) {
657  throw cms::Exception("LogicError") << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
658  << "Trying to apply tracker alignment before creating it.";
659  }
660 
661  std::unique_ptr<Alignments> alignments{alignableTracker_->alignments()};
662  std::unique_ptr<AlignmentErrorsExtended> alignmentErrExt{alignableTracker_->alignmentErrors()};
663  std::unique_ptr<AlignmentSurfaceDeformations> aliDeforms{alignableTracker_->surfaceDeformations()};
664 
665  aligner.applyAlignments(trackerGeometry_.get(), alignments.get(), alignmentErrExt.get(), AlignTransform());
666  aligner.attachSurfaceDeformations(trackerGeometry_.get(), aliDeforms.get());
667  }
668 
669  if (doMuon_) {
670  if (!alignableMuon_) {
671  throw cms::Exception("LogicError") << "@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
672  << "Trying to apply muon alignment before creating it.";
673  }
674 
675  std::unique_ptr<Alignments> dtAlignments{alignableMuon_->dtAlignments()};
676  std::unique_ptr<Alignments> cscAlignments{alignableMuon_->cscAlignments()};
677 
678  std::unique_ptr<AlignmentErrorsExtended> dtAlignmentErrExt{alignableMuon_->dtAlignmentErrorsExtended()};
679  std::unique_ptr<AlignmentErrorsExtended> cscAlignmentErrExt{alignableMuon_->cscAlignmentErrorsExtended()};
680 
681  aligner.applyAlignments(muonDTGeometry_.get(), dtAlignments.get(), dtAlignmentErrExt.get(), AlignTransform());
682  aligner.applyAlignments(muonCSCGeometry_.get(), cscAlignments.get(), cscAlignmentErrExt.get(), AlignTransform());
683  }
684 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
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:262
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 override
Return alignments, sorted by DetId.
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, 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 280 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().

282  {
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 }
RunNumber_t run() const
Definition: EventID.h:39
const EventID & eventID() const
Definition: IOVSyncValue.h:40
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:82
const IOVSyncValue & last() const
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
ESHandle< TrackerGeometry > geometry
T get() const
Definition: EventSetup.h:71
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 312 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().

312  {
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 }
RunNumber_t run() const
Definition: EventID.h:39
const EventID & eventID() const
Definition: IOVSyncValue.h:40
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:82
const IOVSyncValue & last() const
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
ESHandle< TrackerGeometry > geometry
T get() const
Definition: EventSetup.h:71
const IOVSyncValue & first() const
void AlignmentProducerBase::applyMisalignment ( )
private

Applies misalignment scenario to .

Definition at line 543 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().

543  {
544  // Apply misalignment scenario to alignable tracker and muon if requested
545  // WARNING: this assumes scenarioConfig can be passed to both muon and tracker
546 
548  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::applyMisalignment"
549  << "Applying misalignment scenario to " << (doTracker_ ? "tracker" : "")
550  << (doMuon_ ? (doTracker_ ? " and muon" : "muon") : ".");
551 
552  const auto& scenarioConfig = config_.getParameterSet("MisalignmentScenario");
553 
554  if (doTracker_) {
555  TrackerScenarioBuilder scenarioBuilder(alignableTracker_);
556  scenarioBuilder.applyScenario(scenarioConfig);
557  }
558  if (doMuon_) {
559  MuonScenarioBuilder muonScenarioBuilder(alignableMuon_);
560  muonScenarioBuilder.applyScenario(scenarioConfig);
561  }
562 
563  } else {
564  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::applyMisalignment"
565  << "NOT applying misalignment scenario!";
566  }
567 
568  // Apply simple misalignment
569  const auto& sParSel = config_.getParameter<std::string>("parameterSelectorSimple");
571 }
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 258 of file AlignmentProducerBase.cc.

References alignmentAlgo_.

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

258  {
259  // Do not forward edm::LuminosityBlock
260  alignmentAlgo_->beginLuminosityBlock(setup);
261 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::beginRunImpl ( const edm::Run run,
const edm::EventSetup setup 
)
protected

begin run

Definition at line 215 of file AlignmentProducerBase.cc.

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

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

215  {
216  const bool changed{setupChanged(setup)};
217  if (changed) {
218  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::beginRunImpl"
219  << "EventSetup-Record changed.";
220 
221  // updatable alignables are currently not used at PCL, but event setup
222  // changes require a complete re-initialization
223  if (runAtPCL_) {
224  initAlignmentAlgorithm(setup, /* update = */ false);
225  } else if (enableAlignableUpdates_) {
226  initAlignmentAlgorithm(setup, /* update = */ true);
227  }
228  }
229 
230  alignmentAlgo_->beginRun(run, setup, changed && (runAtPCL_ || enableAlignableUpdates_));
231 
232  for (const auto& iCal : calibrations_)
233  iCal->beginRun(run, setup);
234 
235  //store the first run analyzed to be used for setting the IOV (for PCL)
236  if (firstRun_ > static_cast<cond::Time_t>(run.id().run())) {
237  firstRun_ = static_cast<cond::Time_t>(run.id().run());
238  }
239 }
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 515 of file AlignmentProducerBase.cc.

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

Referenced by initAlignmentAlgorithm().

515  {
516  // Create alignment parameter builder
517  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::buildParameterStore"
518  << "Creating AlignmentParameterBuilder";
519 
520  const auto& alParamBuildCfg = config_.getParameter<edm::ParameterSet>("ParameterBuilder");
521  const auto& alParamStoreCfg = config_.getParameter<edm::ParameterSet>("ParameterStore");
522 
523  AlignmentParameterBuilder alignmentParameterBuilder{
525 
526  // Fix alignables if requested
527  if (stNFixAlignables_ > 0) {
528  alignmentParameterBuilder.fixAlignables(stNFixAlignables_);
529  }
530 
531  // Get list of alignables
532  const auto& alignables = alignmentParameterBuilder.alignables();
533  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::buildParameterStore"
534  << "got " << alignables.size() << " alignables";
535 
536  // Create AlignmentParameterStore
537  alignmentParameterStore_ = new AlignmentParameterStore(alignables, alParamStoreCfg);
538  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::buildParameterStore"
539  << "AlignmentParameterStore created!";
540 }
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 488 of file AlignmentProducerBase.cc.

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

Referenced by initAlignmentAlgorithm().

488  {
489  if (doTracker_) {
490  if (update) {
492  } else {
494  }
495  }
496 
497  if (doMuon_) {
498  if (update) {
500  } else {
502  }
503  }
504 
505  if (useExtras_) {
506  if (update) {
507  // FIXME: Requires further code changes to track beam spot condition changes
508  } else {
510  }
511  }
512 }
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 270 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().

270  {
271  auto algoConfig = config_.getParameter<edm::ParameterSet>("algoConfig");
272  algoConfig.addUntrackedParameter("RunRangeSelection", config_.getParameter<edm::VParameterSet>("RunRangeSelection"));
273  algoConfig.addUntrackedParameter<align::RunNumber>("firstIOV", runAtPCL_ ? 1 : uniqueRunRanges_.front().first);
274  algoConfig.addUntrackedParameter("enableAlignableUpdates", enableAlignableUpdates_);
275 
276  const auto& algoName = algoConfig.getParameter<std::string>("algoName");
278  std::unique_ptr<AlignmentAlgorithmBase>{AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig)};
279 
280  if (!alignmentAlgo_) {
281  throw cms::Exception("BadConfig") << "Couldn't find the called alignment algorithm: " << algoName;
282  }
283 }
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:38
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::createCalibrations ( )
private

Creates the calibrations.

Definition at line 301 of file AlignmentProducerBase.cc.

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

Referenced by AlignmentProducerBase().

301  {
302  const auto& calibrations = config_.getParameter<edm::VParameterSet>("calibrations");
303  for (const auto& iCalib : calibrations) {
304  calibrations_.push_back(
305  IntegratedCalibrationPluginFactory::get()->create(iCalib.getParameter<std::string>("calibrationName"), iCalib));
306  }
307 }
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
void AlignmentProducerBase::createGeometries ( const edm::EventSetup iSetup,
const TrackerTopology tTopo 
)
private

Creates ideal geometry from IdealGeometryRecord.

Definition at line 432 of file AlignmentProducerBase.cc.

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

Referenced by initAlignmentAlgorithm().

432  {
433  if (doTracker_) {
434  edm::ESHandle<GeometricDet> geometricDet;
435  iSetup.get<IdealGeometryRecord>().get(geometricDet);
436 
438  iSetup.get<PTrackerParametersRcd>().get(ptp);
439 
440  TrackerGeomBuilderFromGeometricDet trackerBuilder;
441 
442  trackerGeometry_ = std::shared_ptr<TrackerGeometry>(trackerBuilder.build(&(*geometricDet), *ptp, tTopo));
443  }
444 
445  if (doMuon_) {
447  iSetup.get<IdealGeometryRecord>().get(cpv);
449  iSetup.get<MuonNumberingRecord>().get(mdc);
452  muonDTGeometry_ = std::make_shared<DTGeometry>();
453  DTGeometryBuilder.build(*muonDTGeometry_, &(*cpv), *mdc);
454  muonCSCGeometry_ = std::make_shared<CSCGeometry>();
455  CSCGeometryBuilder.build(*muonCSCGeometry_, &(*cpv), *mdc);
456  }
457 }
std::shared_ptr< CSCGeometry > muonCSCGeometry_
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
std::shared_ptr< TrackerGeometry > trackerGeometry_
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
std::shared_ptr< DTGeometry > muonDTGeometry_
T get() const
Definition: EventSetup.h:71
void AlignmentProducerBase::createMonitors ( )
private

Creates the monitors.

Definition at line 286 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().

286  {
287  const auto& monitorConfig = config_.getParameter<edm::ParameterSet>("monitorConfig");
288  auto monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >("monitors");
289  for (const auto& miter : monitors) {
290  std::unique_ptr<AlignmentMonitorBase> newMonitor{
291  AlignmentMonitorPluginFactory::get()->create(miter, monitorConfig.getUntrackedParameterSet(miter))};
292 
293  if (!newMonitor) {
294  throw cms::Exception("BadConfig") << "Couldn't find monitor named " << miter;
295  }
296  monitors_.emplace_back(std::move(newMonitor));
297  }
298 }
T getParameter(std::string const &) const
def move(src, dest)
Definition: eostools.py:511
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 264 of file AlignmentProducerBase.cc.

References alignmentAlgo_.

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

264  {
265  // Do not forward edm::LuminosityBlock
266  alignmentAlgo_->endLuminosityBlock(setup);
267 }
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
void AlignmentProducerBase::endRunImpl ( const edm::Run run,
const edm::EventSetup setup 
)
protected

end run

Definition at line 242 of file AlignmentProducerBase.cc.

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

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

242  {
243  if (!tkLasBeamTag_.encode().empty()) {
246  getTkFittedLasBeamCollection(run, lasBeams);
247  getTsosVectorCollection(run, tsoses);
248 
249  alignmentAlgo_->endRun(EndRunInfo(run.id(), &(*lasBeams), &(*tsoses)), setup);
250  } else {
251  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::endRunImpl"
252  << "No Tk LAS beams to forward to algorithm.";
253  alignmentAlgo_->endRun(EndRunInfo(run.id(), nullptr, nullptr), setup);
254  }
255 }
RunID const & id() const
Definition: RunBase.h:39
std::string encode() const
Definition: InputTag.cc:159
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 772 of file AlignmentProducerBase.cc.

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

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

772  {
773  for (const auto& monitor : monitors_)
774  monitor->endOfJob();
775 
776  if (alignmentAlgo_->processesEvents() && nevent_ == 0) {
777  return false;
778  }
779 
781  if (alignmentAlgo_->storeAlignments())
783  } else {
784  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::finish"
785  << "No payload to be stored!";
786  }
787 
788  // takes care of storing output of calibrations, but needs to be called only
789  // after 'storeAlignmentsToDB()'
790  for (const auto& iCal : calibrations_)
791  iCal->endOfJob();
792 
793  return true;
794 }
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 955 of file AlignmentProducerBase.cc.

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

955  {
956  try {
957  config.getParameter<T>(name);
958  } catch (const edm::Exception& e) {
960  if (e.message().find("MissingParameter") != std::string::npos) {
961  return false;
962  } else {
963  throw;
964  }
965  } else {
966  throw;
967  }
968  }
969 
970  return true;
971 }
Code categoryCode() const
Definition: EDMException.h:97
T getParameter(std::string const &) const
std::string message() const
Definition: Exception.cc:145
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 362 of file AlignmentProducerBase.cc.

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

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

362  {
363  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
364  << "Begin";
365 
366  auto isTrueUpdate = update && isAlgoInitialized_;
367 
368  // Retrieve tracker topology from geometry
369  edm::ESHandle<TrackerTopology> tTopoHandle;
370  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
371  const TrackerTopology* const tTopo = tTopoHandle.product();
372 
373  // Create the geometries from the ideal geometries
374  createGeometries(setup, tTopo);
375 
376  applyAlignmentsToDB(setup);
377  createAlignables(tTopo, isTrueUpdate);
380 
381  // Initialize alignment algorithm and integrated calibration and pass the
382  // latter to algorithm
383  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
384  << "Initializing alignment algorithm.";
386 
387  // Not all algorithms support calibrations - so do not pass empty vector
388  // and throw if non-empty and not supported:
389  if (!calibrations_.empty()) {
390  if (alignmentAlgo_->supportsCalibrations()) {
391  alignmentAlgo_->addCalibrations(calibrations_);
392  } else {
393  throw cms::Exception("BadConfig") << "@SUB=AlignmentProducerBase::createCalibrations\n"
394  << "Configured " << calibrations_.size() << " calibration(s) "
395  << "for algorithm not supporting it.";
396  }
397  }
398 
399  isAlgoInitialized_ = true;
400 
402 
403  if (!isTrueUpdate) { // only needed the first time
404  for (const auto& iCal : calibrations_) {
406  }
407  for (const auto& monitor : monitors_) {
409  }
410  }
411  startProcessing(); // needed if derived class is non-EDLooper-based
412  // has no effect, if called during loop
413 
414  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
415  << "End";
416 }
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 .
#define update(a, b)
T get() const
Definition: EventSetup.h:71
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 419 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().

419  {
420  getBeamSpot(event, beamSpot_);
421 
422  if (nevent_ == 0 && alignableExtras_) {
423  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::initBeamSpot"
424  << "Initializing AlignableBeamSpot";
425 
428  }
429 }
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 144 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().

144  {
145  if (setupChanged(setup)) {
146  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::processEvent"
147  << "EventSetup-Record changed.";
148 
149  // updatable alignables are currently not used at PCL, but event setup
150  // changes require a complete re-initialization
151  if (runAtPCL_) {
152  initAlignmentAlgorithm(setup, /* update = */ false);
153  } else if (enableAlignableUpdates_) {
154  initAlignmentAlgorithm(setup, /* update = */ true);
155  }
156  }
157 
158  initBeamSpot(event); // must happen every event and before incrementing 'nevent_'
159 
160  ++nevent_; // must happen before the check below;
161  // otherwise subsequent checks fail for "EmptySource"
162 
163  if (!alignmentAlgo_->processesEvents()) {
164  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::processEvent"
165  << "Skipping event. The current configuration of the alignment algorithm "
166  << "does not need to process any events.";
167  return false;
168  }
169 
170  // reading in survey records
171  readInSurveyRcds(setup);
172 
173  // Printout event number
174  for (int i = 10; i < 10000000; i *= 10) {
175  if (nevent_ < 10 * i && (nevent_ % i) == 0) {
176  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::processEvent"
177  << "Events processed: " << nevent_;
178  }
179  }
180 
181  // Retrieve trajectories and tracks from the event
182  // -> merely skip if collection is empty
183  edm::Handle<TrajTrackAssociationCollection> handleTrajTracksCollection;
184 
185  if (getTrajTrackAssociationCollection(event, handleTrajTracksCollection)) {
186  // Form pairs of trajectories and tracks
187  ConstTrajTrackPairs trajTracks;
188  for (auto iter = handleTrajTracksCollection->begin(); iter != handleTrajTracksCollection->end(); ++iter) {
189  trajTracks.push_back(ConstTrajTrackPair(&(*(*iter).key), &(*(*iter).val)));
190  }
191 
192  // Run the alignment algorithm with its input
193  const AliClusterValueMap* clusterValueMapPtr{nullptr};
194  if (!clusterValueMapTag_.encode().empty()) {
195  edm::Handle<AliClusterValueMap> clusterValueMap;
196  getAliClusterValueMap(event, clusterValueMap);
197  clusterValueMapPtr = &(*clusterValueMap);
198  }
199 
200  const AlignmentAlgorithmBase::EventInfo eventInfo{event.id(), trajTracks, *beamSpot_, clusterValueMapPtr};
201  alignmentAlgo_->run(setup, eventInfo);
202 
203  for (const auto& monitor : monitors_) {
204  monitor->duringLoop(event, setup, trajTracks); // forward eventInfo?
205  }
206  } else {
207  edm::LogError("Alignment") << "@SUB=AlignmentProducerBase::processEvent"
208  << "No track collection found: skipping event";
209  }
210 
211  return true;
212 }
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
std::vector< ConstTrajTrackPair > ConstTrajTrackPairs
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:159
define event information passed to algorithms
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 .
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
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 687 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().

687  {
688  // Get Survey Rcds and add Survey Info
689  if (doTracker_ && useSurvey_) {
690  bool tkSurveyBool = watchTkSurveyRcd_.check(iSetup);
691  bool tkSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
692  edm::LogInfo("Alignment") << "watcher tksurveyrcd: " << tkSurveyBool;
693  edm::LogInfo("Alignment") << "watcher tksurveyerrrcd: " << tkSurveyErrBool;
694  if (tkSurveyBool || tkSurveyErrBool) {
695  edm::LogInfo("Alignment") << "ADDING THE SURVEY INFORMATION";
697  edm::ESHandle<SurveyErrors> surveyErrors;
698 
699  iSetup.get<TrackerSurveyRcd>().get(surveys);
700  iSetup.get<TrackerSurveyErrorExtendedRcd>().get(surveyErrors);
701 
702  surveyIndex_ = 0;
703  surveyValues_ = &*surveys;
704  surveyErrors_ = &*surveyErrors;
706  }
707  }
708 
709  if (doMuon_ && useSurvey_) {
710  bool DTSurveyBool = watchTkSurveyRcd_.check(iSetup);
711  bool DTSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
712  bool CSCSurveyBool = watchTkSurveyRcd_.check(iSetup);
713  bool CSCSurveyErrBool = watchTkSurveyErrExtRcd_.check(iSetup);
714 
715  if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool) {
716  edm::ESHandle<Alignments> dtSurveys;
717  edm::ESHandle<SurveyErrors> dtSurveyErrors;
718  edm::ESHandle<Alignments> cscSurveys;
719  edm::ESHandle<SurveyErrors> cscSurveyErrors;
720 
721  iSetup.get<DTSurveyRcd>().get(dtSurveys);
722  iSetup.get<DTSurveyErrorExtendedRcd>().get(dtSurveyErrors);
723  iSetup.get<CSCSurveyRcd>().get(cscSurveys);
724  iSetup.get<CSCSurveyErrorExtendedRcd>().get(cscSurveyErrors);
725 
726  surveyIndex_ = 0;
727  surveyValues_ = &*dtSurveys;
728  surveyErrors_ = &*dtSurveyErrors;
729  const auto& barrels = alignableMuon_->DTBarrel();
730  for (const auto& barrel : barrels)
732 
733  surveyIndex_ = 0;
734  surveyValues_ = &*cscSurveys;
735  surveyErrors_ = &*cscSurveyErrors;
736  const auto& endcaps = alignableMuon_->CSCEndcaps();
737  for (const auto& endcap : endcaps)
739  }
740  }
741 }
align::Alignables DTBarrel()
const Alignments * surveyValues_
align::Alignables CSCEndcaps()
edm::ESWatcher< TrackerSurveyErrorExtendedRcd > watchTkSurveyErrExtRcd_
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
AlignableTracker * alignableTracker_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
T get() const
Definition: EventSetup.h:71
const SurveyErrors * surveyErrors_
bool AlignmentProducerBase::setupChanged ( const edm::EventSetup setup)
private

Checks if one of the EventSetup-Records has changed.

Definition at line 310 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().

310  {
311  bool changed{false};
312 
313  if (watchIdealGeometryRcd_.check(setup)) {
314  changed = true;
315  }
316 
317  if (watchGlobalPositionRcd_.check(setup)) {
318  changed = true;
319  }
320 
321  if (doTracker_) {
322  if (watchTrackerAlRcd_.check(setup)) {
323  changed = true;
324  }
325 
326  if (watchTrackerAlErrorExtRcd_.check(setup)) {
327  changed = true;
328  }
329 
330  if (watchTrackerSurDeRcd_.check(setup)) {
331  changed = true;
332  }
333  }
334 
335  if (doMuon_) {
336  if (watchDTAlRcd_.check(setup)) {
337  changed = true;
338  }
339 
340  if (watchDTAlErrExtRcd_.check(setup)) {
341  changed = true;
342  }
343 
344  if (watchCSCAlRcd_.check(setup)) {
345  changed = true;
346  }
347 
348  if (watchCSCAlErrExtRcd_.check(setup)) {
349  changed = true;
350  }
351  }
352 
353  /* TODO: ExtraAlignables: Which record(s) to check?
354  *
355  if (useExtras_) {}
356  */
357 
358  return changed;
359 }
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:52
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 574 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().

575  {
576  std::ostringstream output; // collecting output
577 
578  if (shift > 0. || rot > 0.) {
579  output << "Adding random flat shift of max size " << shift << " and adding random flat rotation of max size " << rot
580  << " to ";
581 
582  std::vector<bool> commSel(0);
583  if (selection != "-1") {
584  AlignmentParameterSelector aSelector(nullptr, nullptr); // no alignable needed here...
585  const std::vector<char> cSel(aSelector.convertParamSel(selection));
586  if (cSel.size() < RigidBodyAlignmentParameters::N_PARAM) {
587  throw cms::Exception("BadConfig")
588  << "[AlignmentProducerBase::simpleMisalignment_]\n"
589  << "Expect selection string '" << selection << "' to be at least of length "
590  << RigidBodyAlignmentParameters::N_PARAM << " or to be '-1'.\n"
591  << "(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
592  }
593  for (const auto& cIter : cSel) {
594  commSel.push_back(cIter == '0' ? false : true);
595  }
596  output << "parameters defined by (" << selection << "), representing (x,y,z,alpha,beta,gamma),";
597  } else {
598  output << "the active parameters of each alignable,";
599  }
600  output << " in " << (local ? "local" : "global") << " frame.";
601 
602  for (const auto& ali : alivec) {
603  std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
604 
605  if (std::abs(shift) > 0.00001) {
606  double s0 = 0., s1 = 0., s2 = 0.;
608  s0 = shift * double(random() % 1000 - 500) / 500.;
610  s1 = shift * double(random() % 1000 - 500) / 500.;
612  s2 = shift * double(random() % 1000 - 500) / 500.;
613 
614  if (local)
615  ali->move(ali->surface().toGlobal(align::LocalVector(s0, s1, s2)));
616  else
617  ali->move(align::GlobalVector(s0, s1, s2));
618 
619  //AlignmentPositionError ape(dx,dy,dz);
620  //ali->addAlignmentPositionError(ape);
621  }
622 
623  if (std::abs(rot) > 0.00001) {
626  r(1) = rot * double(random() % 1000 - 500) / 500.;
628  r(2) = rot * double(random() % 1000 - 500) / 500.;
630  r(3) = rot * double(random() % 1000 - 500) / 500.;
631 
632  const align::RotationType mrot = align::toMatrix(r);
633  if (local)
634  ali->rotateInLocalFrame(mrot);
635  else
636  ali->rotateInGlobalFrame(mrot);
637 
638  //ali->addAlignmentPositionErrorFromRotation(mrot);
639  }
640  } // end loop on alignables
641  } else {
642  output << "No simple misalignment added!";
643  }
644  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::simpleMisalignment" << output.str();
645 }
selection
main part
Definition: corrVsCorr.py:100
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 94 of file AlignmentProducerBase.cc.

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

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

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

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

Definition at line 797 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().

797  {
798  const auto runRangeSelectionVPSet = config_.getParameterSetVector("RunRangeSelection");
799 
800  // handle PCL use case
801  const auto& uniqueRunRanges =
802  (runAtPCL_ ? align::makeUniqueRunRanges(runRangeSelectionVPSet, firstRun_) : uniqueRunRanges_);
803 
804  std::vector<AlgebraicVector> beamSpotParameters;
805 
806  for (const auto& iRunRange : uniqueRunRanges) {
807  alignmentAlgo_->setParametersForRunRange(iRunRange);
808 
809  // Save alignments to database
811  writeForRunRange(iRunRange.first);
812  }
813 
814  // Deal with extra alignables, e.g. beam spot
815  if (alignableExtras_) {
816  auto& alis = alignableExtras_->beamSpot();
817  if (!alis.empty()) {
818  auto beamSpotAliPars = dynamic_cast<BeamSpotAlignmentParameters*>(alis[0]->alignmentParameters());
819  if (!beamSpotAliPars) {
820  throw cms::Exception("LogicError") << "@SUB=AlignmentProducerBase::storeAlignmentsToDB\n"
821  << "First alignable of alignableExtras_ does not have "
822  << "'BeamSpotAlignmentParameters', while it should have.";
823  }
824 
825  beamSpotParameters.push_back(beamSpotAliPars->parameters());
826  }
827  }
828  }
829 
830  if (alignableExtras_) {
831  std::ostringstream bsOutput;
832 
833  auto itPar = beamSpotParameters.cbegin();
834  for (auto iRunRange = uniqueRunRanges.cbegin(); iRunRange != uniqueRunRanges.cend(); ++iRunRange, ++itPar) {
835  bsOutput << "Run range: " << (*iRunRange).first << " - " << (*iRunRange).second << "\n";
836  bsOutput << " Displacement: x=" << (*itPar)[0] << ", y=" << (*itPar)[1] << "\n";
837  bsOutput << " Slope: dx/dz=" << (*itPar)[2] << ", dy/dz=" << (*itPar)[3] << "\n";
838  }
839 
840  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::storeAlignmentsToDB"
841  << "Parameters for alignable beamspot:\n"
842  << bsOutput.str();
843  }
844 }
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 122 of file AlignmentProducerBase.cc.

References alignmentAlgo_, calibrations_, isDuringLoop_, and monitors_.

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

122  {
123  if (!isDuringLoop_)
124  return;
125 
126  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::terminateProcessing"
127  << "Terminating algorithm.";
128  if (setup) {
129  alignmentAlgo_->terminate(*setup);
130  } else {
131  alignmentAlgo_->terminate();
132  }
133 
134  // FIXME: Should this be done in algorithm::terminate()??
135  for (const auto& iCal : calibrations_)
136  iCal->endOfLoop();
137  for (const auto& monitor : monitors_)
138  monitor->endOfLoop();
139 
140  isDuringLoop_ = false;
141 }
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 884 of file AlignmentProducerBase.cc.

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

Referenced by writeForRunRange().

889  {
890  Alignments* tempAlignments = alignments;
891  AlignmentErrorsExtended* tempAlignmentErrorsExtended = alignmentErrors;
892 
893  // Call service
895  if (!poolDb.isAvailable()) { // Die if not available
896  delete tempAlignments; // promised to take over ownership...
897  delete tempAlignmentErrorsExtended; // dito
898  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
899  }
900 
901  if (globalCoordinates // happens only if (applyDbAlignment_ == true)
902  && globalCoordinates->transform() != AlignTransform::Transform::Identity) {
903  tempAlignments = new Alignments(); // temporary storage for
904  tempAlignmentErrorsExtended = new AlignmentErrorsExtended(); // final alignments and errors
905 
906  GeometryAligner aligner;
907  aligner.removeGlobalTransform(
908  alignments, alignmentErrors, *globalCoordinates, tempAlignments, tempAlignmentErrorsExtended);
909 
910  delete alignments; // have to delete original alignments
911  delete alignmentErrors; // same thing for the errors
912 
913  edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::writeDB"
914  << "globalCoordinates removed from alignments (" << alignRcd << ") and errors ("
915  << alignRcd << ").";
916  }
917 
918  if (saveToDB_) {
919  edm::LogInfo("Alignment") << "Writing Alignments for run " << time << " to " << alignRcd << ".";
920  poolDb->writeOne<Alignments>(tempAlignments, time, alignRcd);
921  } else { // poolDb->writeOne(..) takes over 'alignments' ownership,...
922  delete tempAlignments; // ...otherwise we have to delete, as promised!
923  }
924 
925  if (saveApeToDB_) {
926  edm::LogInfo("Alignment") << "Writing AlignmentErrorsExtended for run " << time << " to " << errRcd << ".";
927  poolDb->writeOne<AlignmentErrorsExtended>(tempAlignmentErrorsExtended, time, errRcd);
928  } else { // poolDb->writeOne(..) takes over 'alignmentErrors' ownership,...
929  delete tempAlignmentErrorsExtended; // ...otherwise we have to delete, as promised!
930  }
931 }
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:40
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 934 of file AlignmentProducerBase.cc.

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

936  {
937  // Call service
939  if (!poolDb.isAvailable()) { // Die if not available
940  delete alignmentSurfaceDeformations; // promised to take over ownership...
941  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
942  }
943 
944  if (saveDeformationsToDB_) {
945  edm::LogInfo("Alignment") << "Writing AlignmentSurfaceDeformations for run " << time << " to "
946  << surfaceDeformationRcd << ".";
947  poolDb->writeOne<AlignmentSurfaceDeformations>(alignmentSurfaceDeformations, time, surfaceDeformationRcd);
948  } else { // poolDb->writeOne(..) takes over 'surfaceDeformation' ownership,...
949  delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised!
950  }
951 }
bool isAvailable() const
Definition: Service.h:40
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 847 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().

847  {
848  if (doTracker_) { // first tracker
849  const AlignTransform* trackerGlobal{nullptr}; // will be 'removed' from constants
850  if (globalPositions_) { // i.e. applied before in applyDB
852  }
853 
854  auto alignments = alignableTracker_->alignments();
855  auto alignmentErrors = alignableTracker_->alignmentErrors();
856  this->writeDB(
857  alignments, "TrackerAlignmentRcd", alignmentErrors, "TrackerAlignmentErrorExtendedRcd", trackerGlobal, time);
858 
859  // Save surface deformations to database
860  if (saveDeformationsToDB_) {
861  auto alignmentSurfaceDeformations = alignableTracker_->surfaceDeformations();
862  this->writeDB(alignmentSurfaceDeformations, "TrackerSurfaceDeformationRcd", time);
863  }
864  }
865 
866  if (doMuon_) { // now muon
867  const AlignTransform* muonGlobal{nullptr}; // will be 'removed' from constants
868  if (globalPositions_) { // i.e. applied before in applyDB
870  }
871  // Get alignments+errors, first DT - ownership taken over by writeDB(..), so no delete
872  auto alignments = alignableMuon_->dtAlignments();
873  auto alignmentErrors = alignableMuon_->dtAlignmentErrorsExtended();
874  this->writeDB(alignments, "DTAlignmentRcd", alignmentErrors, "DTAlignmentErrorExtendedRcd", muonGlobal, time);
875 
876  // Get alignments+errors, now CSC - ownership taken over by writeDB(..), so no delete
877  alignments = alignableMuon_->cscAlignments();
878  alignmentErrors = alignableMuon_->cscAlignmentErrorsExtended();
879  this->writeDB(alignments, "CSCAlignmentRcd", alignmentErrors, "CSCAlignmentErrorExtendedRcd", muonGlobal, time);
880  }
881 }
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:262
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.
Alignments * alignments() const override
Return alignments, sorted by DetId.
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)

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 238 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyAlignmentsToDB().

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

Definition at line 224 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 238 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 239 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 276 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 226 of file AlignmentProducerBase.h.

Referenced by applyAlignmentsToDB(), and writeForRunRange().

bool AlignmentProducerBase::isAlgoInitialized_ {false}
private

Definition at line 272 of file AlignmentProducerBase.h.

Referenced by initAlignmentAlgorithm(), and startProcessing().

bool AlignmentProducerBase::isDuringLoop_ {false}
private

Definition at line 273 of file AlignmentProducerBase.h.

Referenced by 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 229 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 236 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and buildParameterStore().

const double AlignmentProducerBase::stRandomRotation_
private

Definition at line 237 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyMisalignment().

const double AlignmentProducerBase::stRandomShift_
private

Definition at line 237 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and applyMisalignment().

const SurveyErrors* AlignmentProducerBase::surveyErrors_ { 0 }
private

Definition at line 269 of file AlignmentProducerBase.h.

Referenced by addSurveyInfo(), and readInSurveyRcds().

size_t AlignmentProducerBase::surveyIndex_ {0}
private

Definition at line 267 of file AlignmentProducerBase.h.

Referenced by addSurveyInfo(), and readInSurveyRcds().

const Alignments* AlignmentProducerBase::surveyValues_ { 0 }
private

Definition at line 268 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 117 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and createAlignables().

const bool AlignmentProducerBase::useSurvey_
private

Definition at line 241 of file AlignmentProducerBase.h.

Referenced by AlignmentProducerBase(), and readInSurveyRcds().

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

Definition at line 256 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 255 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 263 of file AlignmentProducerBase.h.

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

Definition at line 262 of file AlignmentProducerBase.h.

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

Definition at line 254 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 253 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 261 of file AlignmentProducerBase.h.

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

Definition at line 260 of file AlignmentProducerBase.h.

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

Definition at line 247 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 246 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 259 of file AlignmentProducerBase.h.

Referenced by readInSurveyRcds().

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

Definition at line 258 of file AlignmentProducerBase.h.

Referenced by readInSurveyRcds().

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

Definition at line 250 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 249 of file AlignmentProducerBase.h.

Referenced by setupChanged().

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

Definition at line 251 of file AlignmentProducerBase.h.

Referenced by setupChanged().