|
|
Go to the documentation of this file.
31 : doTracker_{
config.getUntrackedParameter<
bool>(
"doTracker")},
32 doMuon_{
config.getUntrackedParameter<
bool>(
"doMuon")},
33 useExtras_{
config.getUntrackedParameter<
bool>(
"useExtras")},
41 stNFixAlignables_{
config.getParameter<
int>(
"nFixAlignables")},
42 stRandomShift_{
config.getParameter<
double>(
"randomShift")},
43 stRandomRotation_{
config.getParameter<
double>(
"randomRotation")},
44 applyDbAlignment_{
config.getUntrackedParameter<
bool>(
"applyDbAlignment")},
45 checkDbAlignmentValidity_{
config.getUntrackedParameter<
bool>(
"checkDbAlignmentValidity")},
46 doMisalignmentScenario_{
config.getParameter<
bool>(
"doMisalignmentScenario")},
47 saveToDB_{
config.getParameter<
bool>(
"saveToDB")},
48 saveApeToDB_{
config.getParameter<
bool>(
"saveApeToDB")},
49 saveDeformationsToDB_{
config.getParameter<
bool>(
"saveDeformationsToDB")},
50 useSurvey_{
config.getParameter<
bool>(
"useSurvey")},
51 enableAlignableUpdates_{
config.getParameter<
bool>(
"enableAlignableUpdates")},
52 idealGeometryLabel(
"idealForAlignmentProducerBase") {
53 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::AlignmentProducerBase";
55 const auto&
algoConfig = config_.getParameterSet(
"algoConfig");
56 if (config_.existsAs<
bool>(
"runAtPCL")) {
58 runAtPCL_ = config_.getParameter<
bool>(
"runAtPCL");
60 if (
algoConfig.existsAs<
bool>(
"runAtPCL") && (runAtPCL_ !=
algoConfig.getParameter<
bool>(
"runAtPCL"))) {
61 throw cms::Exception(
"BadConfig") <<
"Inconsistent settings for 'runAtPCL' in configuration of the "
62 <<
"alignment producer and the alignment algorithm.";
65 }
else if (
algoConfig.existsAs<
bool>(
"runAtPCL")) {
67 runAtPCL_ =
algoConfig.getParameter<
bool>(
"runAtPCL");
74 createAlignmentAlgorithm();
87 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::startProcessing"
91 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::startProcessing\n"
92 <<
"Trying to start event processing before initializing the alignment "
102 iCal->startNewLoop();
115 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::terminateProcessing"
116 <<
"Terminating algorithm.";
135 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
136 <<
"EventSetup-Record changed.";
153 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
154 <<
"Skipping event. The current configuration of the alignment algorithm "
155 <<
"does not need to process any events.";
163 for (
int i = 10;
i < 10000000;
i *= 10) {
165 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
166 <<
"Events processed: " <<
nevent_;
177 for (
auto iter = handleTrajTracksCollection->
begin(); iter != handleTrajTracksCollection->
end(); ++iter) {
186 clusterValueMapPtr = &(*clusterValueMap);
196 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent"
197 <<
"No track collection found: skipping event";
207 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::beginRunImpl"
208 <<
"EventSetup-Record changed.";
225 if (
firstRun_ > static_cast<cond::Time_t>(
run.id().run())) {
240 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::endRunImpl"
241 <<
"No Tk LAS beams to forward to algorithm.";
273 for (
const auto& miter :
monitors) {
342 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
362 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
363 <<
"Initializing alignment algorithm.";
373 throw cms::Exception(
"BadConfig") <<
"@SUB=AlignmentProducerBase::createCalibrations\n"
374 <<
"Configured " <<
calibrations_.size() <<
" calibration(s) "
375 <<
"for algorithm not supporting it.";
394 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm"
403 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initBeamSpot"
404 <<
"Initializing AlignableBeamSpot";
422 trackerGeometry_ = std::shared_ptr<TrackerGeometry>(trackerBuilder.
build(&(*geometricDet), *ptp, tTopo));
444 applyDB<TrackerGeometry, TrackerAlignmentRcd, TrackerAlignmentErrorExtendedRcd>(
451 applyDB<DTGeometry, DTAlignmentRcd, DTAlignmentErrorExtendedRcd>(
454 applyDB<CSCGeometry, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd>(
457 applyDB<GEMGeometry, GEMAlignmentRcd, GEMAlignmentErrorExtendedRcd>(
493 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
494 <<
"Creating AlignmentParameterBuilder";
508 const auto& alignables = alignmentParameterBuilder.alignables();
509 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
510 <<
"got " << alignables.size() <<
" alignables";
514 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore"
515 <<
"AlignmentParameterStore created!";
524 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment"
525 <<
"Applying misalignment scenario to " << (
doTracker_ ?
"tracker" :
"")
540 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment"
541 <<
"NOT applying misalignment scenario!";
552 std::ostringstream
output;
555 output <<
"Adding random flat shift of max size " <<
shift <<
" and adding random flat rotation of max size " <<
rot
558 std::vector<bool> commSel(0);
564 <<
"[AlignmentProducerBase::simpleMisalignment_]\n"
565 <<
"Expect selection string '" <<
selection <<
"' to be at least of length "
567 <<
"(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
569 for (
const auto& cIter : cSel) {
570 commSel.push_back(cIter ==
'0' ?
false :
true);
572 output <<
"parameters defined by (" <<
selection <<
"), representing (x,y,z,alpha,beta,gamma),";
574 output <<
"the active parameters of each alignable,";
576 output <<
" in " << (
local ?
"local" :
"global") <<
" frame.";
578 for (
const auto& ali : alivec) {
579 std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
582 double s0 = 0., s1 = 0.,
s2 = 0.;
584 s0 =
shift * double(random() % 1000 - 500) / 500.;
586 s1 =
shift * double(random() % 1000 - 500) / 500.;
588 s2 =
shift * double(random() % 1000 - 500) / 500.;
602 r(1) =
rot * double(random() % 1000 - 500) / 500.;
604 r(2) =
rot * double(random() % 1000 - 500) / 500.;
606 r(3) =
rot * double(random() % 1000 - 500) / 500.;
610 ali->rotateInLocalFrame(mrot);
612 ali->rotateInGlobalFrame(mrot);
618 output <<
"No simple misalignment added!";
620 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::simpleMisalignment" <<
output.str();
625 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry"
626 <<
"Now physically apply alignments to geometry...";
633 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
634 <<
"Trying to apply tracker alignment before creating it.";
638 std::unique_ptr<AlignmentErrorsExtended> alignmentErrExt{
alignableTracker_->alignmentErrors()};
639 std::unique_ptr<AlignmentSurfaceDeformations> aliDeforms{
alignableTracker_->surfaceDeformations()};
647 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n"
648 <<
"Trying to apply muon alignment before creating it.";
651 std::unique_ptr<Alignments> dtAlignments{
alignableMuon_->dtAlignments()};
652 std::unique_ptr<Alignments> cscAlignments{
alignableMuon_->cscAlignments()};
653 std::unique_ptr<Alignments> gemAlignments{
alignableMuon_->gemAlignments()};
655 std::unique_ptr<AlignmentErrorsExtended> dtAlignmentErrExt{
alignableMuon_->dtAlignmentErrorsExtended()};
656 std::unique_ptr<AlignmentErrorsExtended> cscAlignmentErrExt{
alignableMuon_->cscAlignmentErrorsExtended()};
657 std::unique_ptr<AlignmentErrorsExtended> gemAlignmentErrExt{
alignableMuon_->gemAlignmentErrorsExtended()};
671 edm::LogInfo(
"Alignment") <<
"watcher tksurveyrcd: " << tkSurveyBool;
672 edm::LogInfo(
"Alignment") <<
"watcher tksurveyerrrcd: " << tkSurveyErrBool;
673 if (tkSurveyBool || tkSurveyErrBool) {
674 edm::LogInfo(
"Alignment") <<
"ADDING THE SURVEY INFORMATION";
694 if (DTSurveyBool || DTSurveyErrBool || CSCSurveyBool || CSCSurveyErrBool) {
709 for (
const auto&
barrel : barrels)
716 for (
const auto&
endcap : endcaps)
726 for (
const auto&
comp : comps)
732 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
763 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::finish"
764 <<
"No payload to be stored!";
780 const auto& uniqueRunRanges =
783 std::vector<AlgebraicVector> beamSpotParameters;
785 for (
const auto& iRunRange : uniqueRunRanges) {
797 auto beamSpotAliPars = dynamic_cast<BeamSpotAlignmentParameters*>(alis[0]->alignmentParameters());
798 if (!beamSpotAliPars) {
799 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::storeAlignmentsToDB\n"
800 <<
"First alignable of alignableExtras_ does not have "
801 <<
"'BeamSpotAlignmentParameters', while it should have.";
804 beamSpotParameters.push_back(beamSpotAliPars->parameters());
810 std::ostringstream bsOutput;
812 auto itPar = beamSpotParameters.cbegin();
813 for (
auto iRunRange = uniqueRunRanges.cbegin(); iRunRange != uniqueRunRanges.cend(); ++iRunRange, ++itPar) {
814 bsOutput <<
"Run range: " << (*iRunRange).first <<
" - " << (*iRunRange).second <<
"\n";
815 bsOutput <<
" Displacement: x=" << (*itPar)[0] <<
", y=" << (*itPar)[1] <<
"\n";
816 bsOutput <<
" Slope: dx/dz=" << (*itPar)[2] <<
", dy/dz=" << (*itPar)[3] <<
"\n";
819 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::storeAlignmentsToDB"
820 <<
"Parameters for alignable beamspot:\n"
836 alignments,
"TrackerAlignmentRcd", alignmentErrors,
"TrackerAlignmentErrorExtendedRcd", trackerGlobal,
time);
841 this->
writeDB(alignmentSurfaceDeformations,
"TrackerSurfaceDeformationRcd",
time);
852 auto alignmentErrors =
alignableMuon_->dtAlignmentErrorsExtended();
853 this->
writeDB(alignments,
"DTAlignmentRcd", alignmentErrors,
"DTAlignmentErrorExtendedRcd", muonGlobal,
time);
858 this->
writeDB(alignments,
"CSCAlignmentRcd", alignmentErrors,
"CSCAlignmentErrorExtendedRcd", muonGlobal,
time);
875 delete tempAlignments;
876 delete tempAlignmentErrorsExtended;
877 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
880 if (globalCoordinates
881 && globalCoordinates->
transform() != AlignTransform::Transform::Identity) {
887 alignments, alignmentErrors, *globalCoordinates, tempAlignments, tempAlignmentErrorsExtended);
890 delete alignmentErrors;
892 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::writeDB"
893 <<
"globalCoordinates removed from alignments (" << alignRcd <<
") and errors ("
898 edm::LogInfo(
"Alignment") <<
"Writing Alignments for run " <<
time <<
" to " << alignRcd <<
".";
901 delete tempAlignments;
905 edm::LogInfo(
"Alignment") <<
"Writing AlignmentErrorsExtended for run " <<
time <<
" to " << errRcd <<
".";
908 delete tempAlignmentErrorsExtended;
919 delete alignmentSurfaceDeformations;
920 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
924 edm::LogInfo(
"Alignment") <<
"Writing AlignmentSurfaceDeformations for run " <<
time <<
" to "
925 << surfaceDeformationRcd <<
".";
928 delete alignmentSurfaceDeformations;
bool check(const edm::EventSetup &iSetup)
T const * product() const
void initAlignmentAlgorithm(const edm::EventSetup &, bool update=false)
edm::ESHandle< DTGeometry > muonDTGeometry_
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_
std::string idealGeometryLabel
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)
const Alignments * surveyValues_
Log< level::Info, false > LogInfo
def create(alignables, pedeDump, additionalData, outputFile, config)
const bool doMisalignmentScenario_
double dxdz() const
dxdz slope
align::Scalar length() const
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
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.
edm::ESHandle< CSCGeometry > muonCSCGeometry_
CalibrationsOwner calibrations_
virtual bool getTrajTrackAssociationCollection(const edm::Event &, edm::Handle< TrajTrackAssociationCollection > &)=0
const bool applyDbAlignment_
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
edm::ESHandle< GEMGeometry > muonGEMGeometry_
void buildParameterStore()
Creates the @alignmentParameterStore_, which manages all Alignables.
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.
Log< level::Error, false > LogError
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)
eventInfo
add run, event number and lumi section
double x0() const
x coordinate
edm::ESWatcher< CSCAlignmentErrorExtendedRcd > watchCSCAlErrExtRcd_
void attachSurfaceDeformations(const C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
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)
T getParameter(std::string const &) const
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.
void beginRunImpl(const edm::Run &, const edm::EventSetup &)
begin run
edm::ParameterSet config_
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