56 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::AlignmentProducerBase";
64 throw cms::Exception(
"BadConfig") <<
"Inconsistent settings for 'runAtPCL' in configuration of the " 65 <<
"alignment producer and the alignment algorithm.";
68 }
else if (
algoConfig.existsAs<
bool>(
"runAtPCL")) {
90 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::startProcessing" 94 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::startProcessing\n" 95 <<
"Trying to start event processing before initializing the alignment " 105 iCal->startNewLoop();
118 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::terminateProcessing" 119 <<
"Terminating algorithm.";
138 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 139 <<
"EventSetup-Record changed.";
156 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 157 <<
"Skipping event. The current configuration of the alignment algorithm " 158 <<
"does not need to process any events.";
166 for (
int i = 10;
i < 10000000;
i *= 10) {
168 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 169 <<
"Events processed: " <<
nevent_;
180 for (
auto iter = handleTrajTracksCollection->
begin(); iter != handleTrajTracksCollection->
end(); ++iter) {
189 clusterValueMapPtr = &(*clusterValueMap);
196 monitor->duringLoop(event, setup, trajTracks);
199 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 200 <<
"No track collection found: skipping event";
210 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::beginRunImpl" 211 <<
"EventSetup-Record changed.";
225 iCal->beginRun(run, setup);
243 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::endRunImpl" 244 <<
"No Tk LAS beams to forward to algorithm.";
276 for (
const auto& miter : monitors) {
345 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 365 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 366 <<
"Initializing alignment algorithm.";
376 throw cms::Exception(
"BadConfig") <<
"@SUB=AlignmentProducerBase::createCalibrations\n" 377 <<
"Configured " <<
calibrations_.size() <<
" calibration(s) " 378 <<
"for algorithm not supporting it.";
382 isAlgoInitialized_ =
true;
397 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 406 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initBeamSpot" 407 <<
"Initializing AlignableBeamSpot";
425 trackerGeometry_ = std::shared_ptr<TrackerGeometry>(trackerBuilder.
build(&(*geometricDet), *ptp, tTopo));
454 applyDB<TrackerGeometry, TrackerAlignmentRcd, TrackerAlignmentErrorExtendedRcd>(
461 applyDB<DTGeometry, DTAlignmentRcd, DTAlignmentErrorExtendedRcd>(
464 applyDB<CSCGeometry, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd>(
500 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 501 <<
"Creating AlignmentParameterBuilder";
515 const auto& alignables = alignmentParameterBuilder.alignables();
516 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 517 <<
"got " << alignables.size() <<
" alignables";
521 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 522 <<
"AlignmentParameterStore created!";
531 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment" 532 <<
"Applying misalignment scenario to " << (
doTracker_ ?
"tracker" :
"")
547 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment" 548 <<
"NOT applying misalignment scenario!";
559 std::ostringstream
output;
561 if (shift > 0. || rot > 0.) {
562 output <<
"Adding random flat shift of max size " << shift <<
" and adding random flat rotation of max size " << rot
565 std::vector<bool> commSel(0);
566 if (selection !=
"-1") {
571 <<
"[AlignmentProducerBase::simpleMisalignment_]\n" 572 <<
"Expect selection string '" << selection <<
"' to be at least of length " 574 <<
"(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
576 for (
const auto& cIter : cSel) {
577 commSel.push_back(cIter ==
'0' ?
false :
true);
579 output <<
"parameters defined by (" << selection <<
"), representing (x,y,z,alpha,beta,gamma),";
581 output <<
"the active parameters of each alignable,";
583 output <<
" in " << (local ?
"local" :
"global") <<
" frame.";
585 for (
const auto& ali : alivec) {
586 std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
589 double s0 = 0., s1 = 0.,
s2 = 0.;
591 s0 = shift * double(random() % 1000 - 500) / 500.;
593 s1 = shift * double(random() % 1000 - 500) / 500.;
595 s2 = shift * double(random() % 1000 - 500) / 500.;
609 r(1) = rot * double(random() % 1000 - 500) / 500.;
611 r(2) = rot * double(random() % 1000 - 500) / 500.;
613 r(3) = rot * double(random() % 1000 - 500) / 500.;
617 ali->rotateInLocalFrame(mrot);
619 ali->rotateInGlobalFrame(mrot);
625 output <<
"No simple misalignment added!";
627 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::simpleMisalignment" << output.str();
632 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry" 633 <<
"Now physically apply alignments to geometry...";
640 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n" 641 <<
"Trying to apply tracker alignment before creating it.";
645 std::unique_ptr<AlignmentErrorsExtended> alignmentErrExt{
alignableTracker_->alignmentErrors()};
646 std::unique_ptr<AlignmentSurfaceDeformations> aliDeforms{
alignableTracker_->surfaceDeformations()};
654 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n" 655 <<
"Trying to apply muon alignment before creating it.";
658 std::unique_ptr<Alignments> dtAlignments{
alignableMuon_->dtAlignments()};
659 std::unique_ptr<Alignments> cscAlignments{
alignableMuon_->cscAlignments()};
661 std::unique_ptr<AlignmentErrorsExtended> dtAlignmentErrExt{
alignableMuon_->dtAlignmentErrorsExtended()};
662 std::unique_ptr<AlignmentErrorsExtended> cscAlignmentErrExt{
alignableMuon_->cscAlignmentErrorsExtended()};
675 edm::LogInfo(
"Alignment") <<
"watcher tksurveyrcd: " << tkSurveyBool;
676 edm::LogInfo(
"Alignment") <<
"watcher tksurveyerrrcd: " << tkSurveyErrBool;
677 if (tkSurveyBool || tkSurveyErrBool) {
678 edm::LogInfo(
"Alignment") <<
"ADDING THE SURVEY INFORMATION";
698 if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool) {
713 for (
const auto&
barrel : barrels)
720 for (
const auto&
endcap : endcaps)
730 for (
const auto&
comp : comps)
736 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
767 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::finish" 768 <<
"No payload to be stored!";
784 const auto& uniqueRunRanges =
787 std::vector<AlgebraicVector> beamSpotParameters;
789 for (
const auto& iRunRange : uniqueRunRanges) {
802 if (!beamSpotAliPars) {
803 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::storeAlignmentsToDB\n" 804 <<
"First alignable of alignableExtras_ does not have " 805 <<
"'BeamSpotAlignmentParameters', while it should have.";
808 beamSpotParameters.push_back(beamSpotAliPars->parameters());
814 std::ostringstream bsOutput;
816 auto itPar = beamSpotParameters.cbegin();
817 for (
auto iRunRange = uniqueRunRanges.cbegin(); iRunRange != uniqueRunRanges.cend(); ++iRunRange, ++itPar) {
818 bsOutput <<
"Run range: " << (*iRunRange).first <<
" - " << (*iRunRange).second <<
"\n";
819 bsOutput <<
" Displacement: x=" << (*itPar)[0] <<
", y=" << (*itPar)[1] <<
"\n";
820 bsOutput <<
" Slope: dx/dz=" << (*itPar)[2] <<
", dy/dz=" << (*itPar)[3] <<
"\n";
823 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::storeAlignmentsToDB" 824 <<
"Parameters for alignable beamspot:\n" 840 alignments,
"TrackerAlignmentRcd", alignmentErrors,
"TrackerAlignmentErrorExtendedRcd", trackerGlobal, time);
845 this->
writeDB(alignmentSurfaceDeformations,
"TrackerSurfaceDeformationRcd", time);
856 auto alignmentErrors =
alignableMuon_->dtAlignmentErrorsExtended();
857 this->
writeDB(alignments,
"DTAlignmentRcd", alignmentErrors,
"DTAlignmentErrorExtendedRcd", muonGlobal, time);
862 this->
writeDB(alignments,
"CSCAlignmentRcd", alignmentErrors,
"CSCAlignmentErrorExtendedRcd", muonGlobal, time);
879 delete tempAlignments;
880 delete tempAlignmentErrorsExtended;
881 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
884 if (globalCoordinates
885 && globalCoordinates->
transform() != AlignTransform::Transform::Identity) {
891 alignments, alignmentErrors, *globalCoordinates, tempAlignments, tempAlignmentErrorsExtended);
894 delete alignmentErrors;
896 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::writeDB" 897 <<
"globalCoordinates removed from alignments (" << alignRcd <<
") and errors (" 902 edm::LogInfo(
"Alignment") <<
"Writing Alignments for run " << time <<
" to " << alignRcd <<
".";
905 delete tempAlignments;
909 edm::LogInfo(
"Alignment") <<
"Writing AlignmentErrorsExtended for run " << time <<
" to " << errRcd <<
".";
912 delete tempAlignmentErrorsExtended;
923 delete alignmentSurfaceDeformations;
924 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
928 edm::LogInfo(
"Alignment") <<
"Writing AlignmentSurfaceDeformations for run " << time <<
" to " 929 << surfaceDeformationRcd <<
".";
932 delete alignmentSurfaceDeformations;
const TimeTypeSpecs timeTypeSpecs[]
align::Scalar width() const
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
double z0() const
z coordinate
T getUntrackedParameter(std::string const &, T const &) const
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
std::shared_ptr< CSCGeometry > muonCSCGeometry_
Builds a scenario from configuration and applies it to the alignable Muon.
AlignmentMonitors monitors_
Alignment producer base class.
def create(alignables, pedeDump, additionalData, outputFile, config)
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
const_iterator end() const
last iterator over the map (read only)
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)
void terminateProcessing(const edm::EventSetup *=0)
Terminate processing of events.
std::vector< ParameterSet > VParameterSet
ErrorMatrix matrix() const
AlignmentProducerBase(const edm::ParameterSet &)
const bool enableAlignableUpdates_
void buildParameterStore()
Creates the , which manages all Alignables.
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
std::unique_ptr< AlignableMuon > alignableMuon_
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
virtual ~AlignmentProducerBase()(false)
const Alignments * surveyValues_
void setWidth(align::Scalar width)
virtual const Alignables & components() const =0
Return vector of all direct components.
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
define event information passed to algorithms
std::shared_ptr< TrackerGeometry > trackerGeometry_
void setLength(align::Scalar length)
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
double dydz() const
dydz slope
void writeForRunRange(cond::Time_t)
unsigned long long Time_t
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
std::unique_ptr< AlignableExtras > alignableExtras_
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
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.
Abs< T >::type abs(const T &t)
std::unique_ptr< AlignableTracker > alignableTracker_
void endLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
end lumi block
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
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 bool doMisalignmentScenario_
void startProcessing()
Start processing of events.
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
double dxdz() const
dxdz slope
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_
const int stNFixAlignables_
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
AlgebraicVector EulerAngles
align::Scalar length() const
edm::Handle< reco::BeamSpot > beamSpot_
ParameterSet const & getParameterSet(std::string const &) const
void applyMisalignment()
Applies misalignment scenario to .
void setSurvey(const SurveyDet *)
Set survey info.
const align::RunRanges uniqueRunRanges_
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
const bool checkDbAlignmentValidity_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
bool check(const edm::EventSetup &iSetup)
std::vector< Alignable * > Alignables
std::shared_ptr< DTGeometry > muonDTGeometry_
const double stRandomRotation_
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
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_
void applyAlignmentsToGeometry()
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
void createCalibrations()
Creates the calibrations.
std::vector< char > convertParamSel(const std::string &selString) const
Converting std::string into std::vector<char>
double y0() const
y coordinate
static unsigned int const shift
void createAlignmentAlgorithm()
Creates the choosen alignment algorithm.
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_iterator begin() const
first iterator over the map (read only)
CalibrationsOwner calibrations_
std::vector< SurveyError > m_surveyErrors
const bool saveDeformationsToDB_
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.
T const * product() const
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_
double x0() const
x coordinate
void createMonitors()
Creates the monitors.