|
|
Go to the documentation of this file.
35 : doTracker_{
config.getUntrackedParameter<
bool>(
"doTracker")},
36 doMuon_{
config.getUntrackedParameter<
bool>(
"doMuon")},
37 useExtras_{
config.getUntrackedParameter<
bool>(
"useExtras")},
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";
58 const auto&
algoConfig = config_.getParameterSet(
"algoConfig");
59 if (config_.existsAs<
bool>(
"runAtPCL")) {
61 runAtPCL_ = config_.getParameter<
bool>(
"runAtPCL");
63 if (
algoConfig.existsAs<
bool>(
"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.";
68 }
else if (
algoConfig.existsAs<
bool>(
"runAtPCL")) {
70 runAtPCL_ =
algoConfig.getParameter<
bool>(
"runAtPCL");
77 createAlignmentAlgorithm();
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);
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.";
228 if (
firstRun_ > static_cast<cond::Time_t>(
run.id().run())) {
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.";
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;
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);
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) {
801 auto beamSpotAliPars = dynamic_cast<BeamSpotAlignmentParameters*>(alis[0]->alignmentParameters());
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;
bool check(const edm::EventSetup &iSetup)
T const * product() const
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
void beginLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
begin lumi block
void createGeometries(const edm::EventSetup &, const TrackerTopology *)
Creates ideal geometry @trackerGeometry_ from IdealGeometryRecord.
std::unique_ptr< AlignableMuon > alignableMuon_
void endRunImpl(const edm::Run &, const edm::EventSetup &)
end run
edm::ESWatcher< DTAlignmentErrorExtendedRcd > watchDTAlErrExtRcd_
void applyMisalignment()
Applies misalignment scenario to @alignableTracker_.
void endLuminosityBlockImpl(const edm::LuminosityBlock &, const edm::EventSetup &)
end lumi block
void createMonitors()
Creates the monitors.
std::unique_ptr< AlignableExtras > alignableExtras_
Builds a scenario from configuration and applies it to the alignable tracker.
double z0() const
z coordinate
edm::ESWatcher< DTAlignmentRcd > watchDTAlRcd_
cond::RealTimeType< cond::runnumber >::type RunNumber
AlignmentProducerBase(const edm::ParameterSet &)
void removeGlobalTransform(const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates, Alignments *newAlignments, AlignmentErrorsExtended *newAlignmentErrorsExtended)
void simpleMisalignment(const align::Alignables &, const std::string &, float, float, bool)
Applies misalignment scenario to @alignableTracker_.
edm::ESWatcher< TrackerAlignmentErrorExtendedRcd > watchTrackerAlErrorExtRcd_
std::vector< ParameterSet > VParameterSet
Alignment producer base class.
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
const Alignments * surveyValues_
def create(alignables, pedeDump, additionalData, outputFile, config)
const bool doMisalignmentScenario_
double dxdz() const
dxdz slope
align::Scalar length() const
virtual bool getBeamSpot(const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
const align::RunRanges uniqueRunRanges_
std::shared_ptr< TrackerGeometry > trackerGeometry_
const_iterator end() const
last iterator over the map (read only)
void setSurvey(const SurveyDet *)
Set survey info.
std::vector< ConstTrajTrackPair > ConstTrajTrackPairs
std::vector< char > convertParamSel(const std::string &selString) const
Converting std::string into std::vector<char>
const TimeTypeSpecs timeTypeSpecs[]
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
edm::Handle< reco::BeamSpot > beamSpot_
void writeForRunRange(cond::Time_t)
edm::ESWatcher< TrackerSurveyErrorExtendedRcd > watchTkSurveyErrExtRcd_
void addSurveyInfo(Alignable *)
Adds survey info to an Alignable.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentAlgorithmBase::EndRunInfo EndRunInfo
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
CalibrationsOwner calibrations_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
const bool applyDbAlignment_
void build(CSCGeometry &theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
Build the geometry.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
edm::ESWatcher< TrackerAlignmentRcd > watchTrackerAlRcd_
const int stNFixAlignables_
void createAlignables(const TrackerTopology *, bool update=false)
edm::ESWatcher< CSCAlignmentRcd > watchCSCAlRcd_
bool processEvent(const edm::Event &, const edm::EventSetup &)
Process event.
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
std::unique_ptr< AlignableTracker > alignableTracker_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
void createCalibrations()
Creates the calibrations.
virtual bool getTkFittedLasBeamCollection(const edm::Run &, edm::Handle< TkFittedLasBeamCollection > &)=0
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
void terminateProcessing(const edm::EventSetup *=nullptr)
Terminate processing of events.
unsigned long long Time_t
void buildParameterStore()
Creates the @alignmentParameterStore_, which manages all Alignables.
std::shared_ptr< CSCGeometry > muonCSCGeometry_
void readInSurveyRcds(const edm::EventSetup &)
Reads in survey records.
const bool enableAlignableUpdates_
void applyAlignmentsToGeometry()
edm::ESWatcher< TrackerSurfaceDeformationRcd > watchTrackerSurDeRcd_
bool setupChanged(const edm::EventSetup &)
Checks if one of the EventSetup-Records has changed.
AlignmentMonitors monitors_
const edm::InputTag tkLasBeamTag_
LAS beams in edm::Run (ignore if empty)
AlgebraicVector EulerAngles
virtual bool getTsosVectorCollection(const edm::Run &, edm::Handle< TsosVectorCollection > &)=0
double dydz() const
dydz slope
void setWidth(align::Scalar width)
T getParameter(std::string const &) const
double x0() const
x coordinate
edm::ESWatcher< CSCAlignmentErrorExtendedRcd > watchCSCAlErrExtRcd_
const SurveyErrors * surveyErrors_
std::vector< Alignable * > Alignables
void initBeamSpot(const edm::Event &)
Initializes Beamspot @beamSpot_ of Alignables @alignableExtras_.
static unsigned const int shift
align::Scalar width() const
virtual ~AlignmentProducerBase() noexcept(false)
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
const_iterator begin() const
first iterator over the map (read only)
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
void applyAlignmentsToDB(const edm::EventSetup &)
const edm::InputTag clusterValueMapTag_
ValueMap containing associtaion cluster-flag.
void setLength(align::Scalar length)
edm::ESWatcher< GlobalPositionRcd > watchGlobalPositionRcd_
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
std::unique_ptr< AlignmentParameterStore > alignmentParameterStore_
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
void createAlignmentAlgorithm()
Creates the choosen alignment algorithm.
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
VParameterSet const & getParameterSetVector(std::string const &name) const
std::vector< AlignTransform > m_align
Abs< T >::type abs(const T &t)
const double stRandomRotation_
const double stRandomShift_
void startProcessing()
Start processing of events.
double y0() const
y coordinate
std::vector< SurveyError > m_surveyErrors
const bool saveDeformationsToDB_
virtual const Alignables & components() const =0
Return vector of all direct components.
std::shared_ptr< DTGeometry > muonDTGeometry_
void beginRunImpl(const edm::Run &, const edm::EventSetup &)
begin run
edm::ParameterSet config_
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Builds a scenario from configuration and applies it to the alignable Muon.
ParameterSet const & getParameterSet(std::string const &) const
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
void writeDB(Alignments *, const std::string &, AlignmentErrorsExtended *, const std::string &, const AlignTransform *, cond::Time_t) const
Class to update a given geometry with a set of alignments.
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
define event information passed to algorithms