56 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::AlignmentProducerBase";
59 if (hasParameter<bool>(
config_,
"runAtPCL")) {
64 throw cms::Exception(
"BadConfig") <<
"Inconsistent settings for 'runAtPCL' in configuration of the " 65 <<
"alignment producer and the alignment algorithm.";
68 }
else if (hasParameter<bool>(
algoConfig,
"runAtPCL")) {
98 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::startProcessing" 102 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::startProcessing\n" 103 <<
"Trying to start event processing before initializing the alignment " 113 iCal->startNewLoop();
115 monitor->startingNewLoop();
126 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::terminateProcessing" 127 <<
"Terminating algorithm.";
138 monitor->endOfLoop();
146 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 147 <<
"EventSetup-Record changed.";
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.";
174 for (
int i = 10;
i < 10000000;
i *= 10) {
176 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 177 <<
"Events processed: " <<
nevent_;
188 for (
auto iter = handleTrajTracksCollection->
begin(); iter != handleTrajTracksCollection->
end(); ++iter) {
197 clusterValueMapPtr = &(*clusterValueMap);
204 monitor->duringLoop(event, setup, trajTracks);
207 edm::LogError(
"Alignment") <<
"@SUB=AlignmentProducerBase::processEvent" 208 <<
"No track collection found: skipping event";
218 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::beginRunImpl" 219 <<
"EventSetup-Record changed.";
233 iCal->beginRun(run, setup);
251 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::endRunImpl" 252 <<
"No Tk LAS beams to forward to algorithm.";
280 if (!alignmentAlgo_) {
289 for (
const auto& miter : monitors) {
290 std::unique_ptr<AlignmentMonitorBase> newMonitor{
294 throw cms::Exception(
"BadConfig") <<
"Couldn't find monitor named " << miter;
363 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 383 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 384 <<
"Initializing alignment algorithm.";
393 throw cms::Exception(
"BadConfig") <<
"@SUB=AlignmentProducerBase::createCalibrations\n" 394 <<
"Configured " <<
calibrations_.size() <<
" calibration(s) " 395 <<
"for algorithm not supporting it.";
399 isAlgoInitialized_ =
true;
414 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initAlignmentAlgorithm" 423 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::initBeamSpot" 424 <<
"Initializing AlignableBeamSpot";
442 trackerGeometry_ = std::shared_ptr<TrackerGeometry>(trackerBuilder.
build(&(*geometricDet), *ptp, tTopo));
471 applyDB<TrackerGeometry, TrackerAlignmentRcd, TrackerAlignmentErrorExtendedRcd>(
478 applyDB<DTGeometry, DTAlignmentRcd, DTAlignmentErrorExtendedRcd>(
481 applyDB<CSCGeometry, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd>(
517 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 518 <<
"Creating AlignmentParameterBuilder";
532 const auto& alignables = alignmentParameterBuilder.alignables();
533 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 534 <<
"got " << alignables.size() <<
" alignables";
538 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::buildParameterStore" 539 <<
"AlignmentParameterStore created!";
548 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment" 549 <<
"Applying misalignment scenario to " << (
doTracker_ ?
"tracker" :
"")
564 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyMisalignment" 565 <<
"NOT applying misalignment scenario!";
576 std::ostringstream
output;
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
582 std::vector<bool> commSel(0);
583 if (selection !=
"-1") {
588 <<
"[AlignmentProducerBase::simpleMisalignment_]\n" 589 <<
"Expect selection string '" << selection <<
"' to be at least of length " 591 <<
"(Most probably you have to adjust the parameter 'parameterSelectorSimple'.)";
593 for (
const auto& cIter : cSel) {
594 commSel.push_back(cIter ==
'0' ?
false :
true);
596 output <<
"parameters defined by (" << selection <<
"), representing (x,y,z,alpha,beta,gamma),";
598 output <<
"the active parameters of each alignable,";
600 output <<
" in " << (local ?
"local" :
"global") <<
" frame.";
602 for (
const auto& ali : alivec) {
603 std::vector<bool> mysel(commSel.empty() ? ali->alignmentParameters()->selector() : commSel);
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.;
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.;
634 ali->rotateInLocalFrame(mrot);
636 ali->rotateInGlobalFrame(mrot);
642 output <<
"No simple misalignment added!";
644 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::simpleMisalignment" << output.str();
649 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry" 650 <<
"Now physically apply alignments to geometry...";
657 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n" 658 <<
"Trying to apply tracker alignment before creating it.";
671 throw cms::Exception(
"LogicError") <<
"@SUB=AlignmentProducerBase::applyAlignmentsToGeometry\n" 672 <<
"Trying to apply muon alignment before creating it.";
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";
715 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" 857 alignments,
"TrackerAlignmentRcd", alignmentErrors,
"TrackerAlignmentErrorExtendedRcd", trackerGlobal, time);
862 this->
writeDB(alignmentSurfaceDeformations,
"TrackerSurfaceDeformationRcd", time);
874 this->
writeDB(alignments,
"DTAlignmentRcd", alignmentErrors,
"DTAlignmentErrorExtendedRcd", muonGlobal, time);
879 this->
writeDB(alignments,
"CSCAlignmentRcd", alignmentErrors,
"CSCAlignmentErrorExtendedRcd", muonGlobal, time);
896 delete tempAlignments;
897 delete tempAlignmentErrorsExtended;
898 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
901 if (globalCoordinates
902 && globalCoordinates->
transform() != AlignTransform::Transform::Identity) {
908 alignments, alignmentErrors, *globalCoordinates, tempAlignments, tempAlignmentErrorsExtended);
911 delete alignmentErrors;
913 edm::LogInfo(
"Alignment") <<
"@SUB=AlignmentProducerBase::writeDB" 914 <<
"globalCoordinates removed from alignments (" << alignRcd <<
") and errors (" 919 edm::LogInfo(
"Alignment") <<
"Writing Alignments for run " << time <<
" to " << alignRcd <<
".";
922 delete tempAlignments;
926 edm::LogInfo(
"Alignment") <<
"Writing AlignmentErrorsExtended for run " << time <<
" to " << errRcd <<
".";
929 delete tempAlignmentErrorsExtended;
940 delete alignmentSurfaceDeformations;
941 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
945 edm::LogInfo(
"Alignment") <<
"Writing AlignmentSurfaceDeformations for run " << time <<
" to " 946 << surfaceDeformationRcd <<
".";
949 delete alignmentSurfaceDeformations;
954 template <
typename T>
960 if (e.
message().find(
"MissingParameter") != std::string::npos) {
Code categoryCode() const
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
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_
void update(const DTGeometry *, const CSCGeometry *)
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
AlignableExtras * alignableExtras_
AlignmentProducerBase(const edm::ParameterSet &)
const bool enableAlignableUpdates_
void update(const TrackerGeometry *, const TrackerTopology *)
align::Alignables DTBarrel()
void buildParameterStore()
Creates the , which manages all Alignables.
virtual bool getAliClusterValueMap(const edm::Event &, edm::Handle< AliClusterValueMap > &)=0
def setup(process, global_tag, zero_tesla=False)
std::string message() const
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.
uint8_t structureType() const
const double stRandomShift_
AlignmentParameterStore * alignmentParameterStore_
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)
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
unsigned long long Time_t
align::Alignables CSCEndcaps()
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
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)
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)
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
std::unique_ptr< const Alignments > globalPositions_
GlobalPositions that might be read from DB, nullptr otherwise.
AlignmentAlgorithmBase::EndRunInfo EndRunInfo
const bool doMisalignmentScenario_
bool hasParameter(const edm::ParameterSet &, const std::string &name)
void startProcessing()
Start processing of events.
edm::ESWatcher< IdealGeometryRecord > watchIdealGeometryRcd_
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
double dxdz() const
dxdz slope
virtual bool getBeamSpot(const edm::Event &, edm::Handle< reco::BeamSpot > &)=0
AlignableMuon * alignableMuon_
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
AlignableTracker * alignableTracker_
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_
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
void storeAlignmentsToDB()
Writes Alignments (i.e. Records) to database-file.
Calibrations calibrations_
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
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.
Alignments * alignments() const override
Return alignments, sorted by DetId.
edm::ESWatcher< TrackerSurveyRcd > watchTkSurveyRcd_
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
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)
eventInfo
add run, event number and lumi section
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_
T get(const Candidate &c)
const align::Alignables & alignables(void) const
get all alignables
cond::RealTimeType< cond::runnumber >::type RunNumber
std::unique_ptr< AlignmentAlgorithmBase > alignmentAlgo_
double x0() const
x coordinate
void createMonitors()
Creates the monitors.