73 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::AlignmentProducerBase";
80 if (algoConfig.existsAs<
bool>(
"runAtPCL") && (
runAtPCL_ != algoConfig.getParameter<
bool>(
"runAtPCL"))) {
81 throw cms::Exception(
"BadConfig") <<
"Inconsistent settings for 'runAtPCL' in configuration of the "
82 <<
"alignment producer and the alignment algorithm.";
85 }
else if (algoConfig.existsAs<
bool>(
"runAtPCL")) {
87 runAtPCL_ = algoConfig.getParameter<
bool>(
"runAtPCL");
107 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::startProcessing"
111 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::startProcessing\n"
112 <<
"Trying to start event processing before initializing the alignment "
122 iCal->startNewLoop();
124 monitor->startingNewLoop();
135 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::terminateProcessing"
136 <<
"Terminating algorithm.";
147 monitor->endOfLoop();
155 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
156 <<
"EventSetup-Record changed.";
173 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
174 <<
"Skipping event. The current configuration of the alignment algorithm "
175 <<
"does not need to process any events.";
183 for (
int i = 10;
i < 10000000;
i *= 10) {
185 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
186 <<
"Events processed: " <<
nevent_;
197 for (
auto iter = handleTrajTracksCollection->begin(); iter != handleTrajTracksCollection->end(); ++iter) {
206 clusterValueMapPtr = &(*clusterValueMap);
213 monitor->duringLoop(event, setup, trajTracks);
216 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
217 <<
"No track collection found: skipping event";
227 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::beginRunImpl"
228 <<
"EventSetup-Record changed.";
242 iCal->beginRun(run, setup);
260 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::endRunImpl"
261 <<
"No Tk LAS beams to forward to algorithm.";
285 const auto& algoName = algoConfig.getParameter<
std::string>(
"algoName");
293 for (
const auto& miter : monitors) {
302 for (
const auto& iCalib : calibrations) {
304 iCalib.getParameter<
std::string>(
"calibrationName"), iCalib, iC));
362 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
380 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
381 <<
"Initializing alignment algorithm.";
391 throw cms::Exception(
"BadConfig") <<
"@SUB=AlignmentProducerBase::createCalibrations\n"
392 <<
"Configured " <<
calibrations_.size() <<
" calibration(s) "
393 <<
"for algorithm not supporting it.";
397 isAlgoInitialized_ =
true;
412 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
421 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initBeamSpot"
422 <<
"Initializing AlignableBeamSpot";
436 trackerGeometry_ = std::shared_ptr<TrackerGeometry>(trackerBuilder.
build(geometricDet, ptitp, *ptp, tTopo));
457 applyDB<TrackerGeometry, TrackerAlignmentRcd, TrackerAlignmentErrorExtendedRcd>(
468 applyDB<DTGeometry, DTAlignmentRcd, DTAlignmentErrorExtendedRcd>(
475 applyDB<CSCGeometry, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd>(
482 applyDB<GEMGeometry, GEMAlignmentRcd, GEMAlignmentErrorExtendedRcd>(
522 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
523 <<
"Creating AlignmentParameterBuilder";
537 const auto& alignables = alignmentParameterBuilder.alignables();
538 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
539 <<
"got " << alignables.size() <<
" alignables";
543 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
544 <<
"AlignmentParameterStore created!";
553 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment"
554 <<
"Applying misalignment scenario to " << (
doTracker_ ?
"tracker" :
"")
569 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment"
570 <<
"NOT applying misalignment scenario!";
581 std::ostringstream
output;
583 if (shift > 0. || rot > 0.) {
584 output <<
"Adding random flat shift of max size " << shift <<
" and adding random flat rotation of max size " << rot
587 std::vector<bool> commSel(0);
588 if (selection !=
"-1") {
593 <<
"[AlignmentProducerBase::simpleMisalignment_]\n"
594 <<
"Expect selection string '" << selection <<
"' to be at least of length "
596 <<
"(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
598 for (
const auto& cIter : cSel) {
599 commSel.push_back(cIter ==
'0' ?
false :
true);
601 output <<
"parameters defined by (" << selection <<
"), representing (x,y,z,alpha,beta,gamma),";
603 output <<
"the active parameters of each alignable,";
605 output <<
" in " << (local ?
"local" :
"global") <<
" frame.";
607 for (
const auto& ali : alivec) {
608 std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
611 double s0 = 0., s1 = 0., s2 = 0.;
613 s0 = shift * double(random() % 1000 - 500) / 500.;
615 s1 = shift * double(random() % 1000 - 500) / 500.;
617 s2 = shift * double(random() % 1000 - 500) / 500.;
631 r(1) = rot * double(random() % 1000 - 500) / 500.;
633 r(2) = rot * double(random() % 1000 - 500) / 500.;
635 r(3) = rot * double(random() % 1000 - 500) / 500.;
639 ali->rotateInLocalFrame(mrot);
641 ali->rotateInGlobalFrame(mrot);
647 output <<
"No simple misalignment added!";
649 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::simpleMisalignment" << output.str();
654 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry"
655 <<
"Now physically apply alignments to geometry...";
662 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
663 <<
"Trying to apply tracker alignment before creating it.";
667 std::unique_ptr<AlignmentErrorsExtended> alignmentErrExt{
alignableTracker_->alignmentErrors()};
668 std::unique_ptr<AlignmentSurfaceDeformations> aliDeforms{
alignableTracker_->surfaceDeformations()};
676 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
677 <<
"Trying to apply muon alignment before creating it.";
680 std::unique_ptr<Alignments> dtAlignments{
alignableMuon_->dtAlignments()};
681 std::unique_ptr<Alignments> cscAlignments{
alignableMuon_->cscAlignments()};
682 std::unique_ptr<Alignments> gemAlignments{
alignableMuon_->gemAlignments()};
684 std::unique_ptr<AlignmentErrorsExtended> dtAlignmentErrExt{
alignableMuon_->dtAlignmentErrorsExtended()};
685 std::unique_ptr<AlignmentErrorsExtended> cscAlignmentErrExt{
alignableMuon_->cscAlignmentErrorsExtended()};
686 std::unique_ptr<AlignmentErrorsExtended> gemAlignmentErrExt{
alignableMuon_->gemAlignmentErrorsExtended()};
700 edm::LogInfo(
"Alignment") <<
"watcher tksurveyrcd: " << tkSurveyBool;
701 edm::LogInfo(
"Alignment") <<
"watcher tksurveyerrrcd: " << tkSurveyErrBool;
702 if (tkSurveyBool || tkSurveyErrBool) {
703 edm::LogInfo(
"Alignment") <<
"ADDING THE SURVEY INFORMATION";
720 if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool) {
730 for (
const auto&
barrel : barrels)
737 for (
const auto&
endcap : endcaps)
747 for (
const auto&
comp : comps)
753 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
784 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::finish"
785 <<
"No payload to be stored!";
801 const auto& uniqueRunRanges =
804 std::vector<AlgebraicVector> beamSpotParameters;
806 for (
const auto& iRunRange : uniqueRunRanges) {
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.";
825 beamSpotParameters.push_back(beamSpotAliPars->parameters());
831 std::ostringstream bsOutput;
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";
840 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::storeAlignmentsToDB"
841 <<
"Parameters for alignable beamspot:\n"
854 auto alignments = alignableTracker_->alignments();
855 auto alignmentErrors = alignableTracker_->alignmentErrors();
857 alignments,
"TrackerAlignmentRcd", alignmentErrors,
"TrackerAlignmentErrorExtendedRcd", trackerGlobal, time);
861 const auto alignmentSurfaceDeformations = *(alignableTracker_->surfaceDeformations());
862 this->
writeDB(alignmentSurfaceDeformations,
"TrackerSurfaceDeformationRcd", time);
872 auto alignments = alignableMuon_->dtAlignments();
873 auto alignmentErrors = alignableMuon_->dtAlignmentErrorsExtended();
874 this->
writeDB(alignments,
"DTAlignmentRcd", alignmentErrors,
"DTAlignmentErrorExtendedRcd", muonGlobal, time);
877 alignments = alignableMuon_->cscAlignments();
878 alignmentErrors = alignableMuon_->cscAlignmentErrorsExtended();
879 this->
writeDB(alignments,
"CSCAlignmentRcd", alignmentErrors,
"CSCAlignmentErrorExtendedRcd", muonGlobal, time);
896 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
899 if (globalCoordinates
900 && globalCoordinates->
transform() != AlignTransform::Transform::Identity) {
906 alignments, alignmentErrors, *globalCoordinates, &tempAlignments, &tempAlignmentErrorsExtended);
909 delete alignmentErrors;
911 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::writeDB"
912 <<
"globalCoordinates removed from alignments (" << alignRcd <<
") and errors ("
917 edm::LogInfo(
"Alignment") <<
"Writing Alignments for run " << time <<
" to " << alignRcd <<
".";
922 edm::LogInfo(
"Alignment") <<
"Writing AlignmentErrorsExtended for run " << time <<
" to " << errRcd <<
".";
934 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
938 edm::LogInfo(
"Alignment") <<
"Writing AlignmentSurfaceDeformations for run " << time <<
" to "
939 << surfaceDeformationRcd <<
".";
void attachSurfaceDeformations(const C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const TimeTypeSpecs timeTypeSpecs[]
align::Scalar width() const
AlignmentProducerBase(const edm::ParameterSet &, edm::ConsumesCollector)
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
T getUntrackedParameter(std::string const &, T const &) const
void terminateProcessing(const edm::EventSetup *=nullptr)
Terminate processing of events.
VParameterSet const & getParameterSetVector(std::string const &name) const
const edm::InputTag tjTkAssociationMapTag_
Map with tracks/trajectories.
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
const bool applyDbAlignment_
void applyAlignmentsToDB(const edm::EventSetup &)
void createGeometries(const edm::EventSetup &, const TrackerTopology *)
Creates ideal geometry from IdealGeometryRecord.
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
std::vector< ConstTrajTrackPair > ConstTrajTrackPairs
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
Builds a scenario from configuration and applies it to the alignable Muon.
AlignmentMonitors monitors_
Alignment producer base class.
const edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > cscAliErrToken_
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
edm::ESWatcher< DTAlignmentRcd > watchDTAlRcd_
Class to update a given geometry with a set of alignments.
bool processEvent(const edm::Event &, const edm::EventSetup &)
Process event.
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
std::vector< ParameterSet > VParameterSet
ErrorMatrix matrix() const
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const bool enableAlignableUpdates_
virtual ~AlignmentProducerBase() noexcept(false)
void buildParameterStore()
Creates the , which manages all Alignables.
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
std::unique_ptr< AlignableMuon > alignableMuon_
const edm::ESGetToken< Alignments, DTSurveyRcd > dtSurveyToken_
const Alignments * surveyValues_
void setWidth(align::Scalar width)
Log< level::Error, false > LogError
std::unique_ptr< AlignmentParameterStore > alignmentParameterStore_
uint8_t structureType() const
const double stRandomShift_
std::vector< AlignTransform > m_align
virtual bool getTkFittedLasBeamCollection(const edm::Run &, edm::Handle< TkFittedLasBeamCollection > &)=0
const edm::ESGetToken< Alignments, CSCAlignmentRcd > cscAliToken_
define event information passed to algorithms
std::shared_ptr< TrackerGeometry > trackerGeometry_
const edm::ESGetToken< SurveyErrors, CSCSurveyErrorExtendedRcd > cscSurvErrorToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void setLength(align::Scalar length)
bool getData(T &iHolder) const
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
void writeForRunRange(cond::Time_t)
const edm::ESGetToken< Alignments, TrackerAlignmentRcd > tkAliToken_
unsigned long long Time_t
const edm::ESGetToken< Alignments, TrackerSurveyRcd > tkSurveyToken_
const edm::ESGetToken< Alignments, GEMAlignmentRcd > gemAliToken_
std::unique_ptr< AlignableExtras > alignableExtras_
void createMonitors(edm::ConsumesCollector &)
Creates the monitors.
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
void createAlignmentAlgorithm(edm::ConsumesCollector &)
Creates the choosen alignment algorithm.
const edm::ESGetToken< SurveyErrors, DTSurveyErrorExtendedRcd > dtSurvErrorToken_
const edm::InputTag beamSpotTag_
BeamSpot.
void removeGlobalTransform(const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates, Alignments *newAlignments, AlignmentErrorsExtended *newAlignmentErrorsExtended)
edm::ESWatcher< TrackerSurveyErrorExtendedRcd > watchTkSurveyErrExtRcd_
void endRunImpl(const edm::Run &, const edm::EventSetup &)
end run
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Abs< T >::type abs(const T &t)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
std::unique_ptr< AlignableTracker > alignableTracker_
void endLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
end lumi block
void createAlignables(const TrackerTopology *, bool update=false)
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
AlignmentAlgorithmBase::EndRunInfo EndRunInfo
const edm::ESGetToken< Alignments, DTAlignmentRcd > dtAliToken_
const bool doMisalignmentScenario_
virtual const Alignables & components() const =0
Return vector of all direct components.
void startProcessing()
Start processing of events.
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
virtual bool getBeamSpot(const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
edm::ESWatcher< CSCAlignmentErrorExtendedRcd > watchCSCAlErrExtRcd_
Log< level::Info, false > LogInfo
const int stNFixAlignables_
const edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > gemAliErrToken_
edm::ESHandle< DTGeometry > muonDTGeometry_
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
AlgebraicVector EulerAngles
align::Scalar length() const
void createCalibrations(edm::ConsumesCollector &)
Creates the calibrations.
edm::Handle< reco::BeamSpot > beamSpot_
ParameterSet const & getParameterSet(std::string const &) const
void addUntrackedParameter(std::string const &name, T const &value)
void applyMisalignment()
Applies misalignment scenario to .
const edm::ESGetToken< AlignmentErrorsExtended, TrackerAlignmentErrorExtendedRcd > tkAliErrToken_
const edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_
void setSurvey(const SurveyDet *)
Set survey info.
T getParameter(std::string const &) const
const align::RunRanges uniqueRunRanges_
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
const bool checkDbAlignmentValidity_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
bool check(const edm::EventSetup &iSetup)
std::vector< Alignable * > Alignables
const double stRandomRotation_
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
tuple config
parse the configuration file
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
void beginLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
begin lumi block
edm::ESWatcher< TrackerAlignmentErrorExtendedRcd > watchTrackerAlErrorExtRcd_
bool setupChanged(const edm::EventSetup &)
Checks if one of the EventSetup-Records has changed.
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
const edm::ESGetToken< SurveyErrors, TrackerSurveyErrorExtendedRcd > tkSurvErrorToken_
const edm::ESGetToken< AlignmentSurfaceDeformations, TrackerSurfaceDeformationRcd > tkSurfDefToken_
void applyAlignmentsToGeometry()
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
const edm::ESGetToken< Alignments, CSCSurveyRcd > cscSurveyToken_
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
std::vector< char > convertParamSel(const std::string &selString) const
Converting std::string into std::vector<char>
static unsigned int const shift
edm::ESHandle< CSCGeometry > muonCSCGeometry_
edm::ESWatcher< CSCAlignmentRcd > watchCSCAlRcd_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
const edm::InputTag tkLasBeamTag_
LAS beams in edm::Run (ignore if empty)
const SurveyErrors * surveyErrors_
void initBeamSpot(const edm::Event &)
Initializes Beamspot of Alignables .
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_
CalibrationsOwner calibrations_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::vector< SurveyError > m_surveyErrors
const edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > dtAliErrToken_
const bool saveDeformationsToDB_
edm::ESHandle< GEMGeometry > muonGEMGeometry_
Builds a scenario from configuration and applies it to the alignable tracker.
void beginRunImpl(const edm::Run &, const edm::EventSetup &)
begin run
const edm::InputTag clusterValueMapTag_
ValueMap containing associtaion cluster-flag.
void simpleMisalignment(const align::Alignables &, const std::string &, float, float, bool)
Applies misalignment scenario to .
edm::ParameterSet config_
cond::RealTimeType< cond::runnumber >::type RunNumber
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_