Skip to content
Snippets Groups Projects
Commit a3e4f1b4 authored by Markus Tobias Prim's avatar Markus Tobias Prim
Browse files

Update code to make full use of the Gaudi property, change data format to...

Update code to make full use of the Gaudi property, change data format to store aligment constants. Update python scripts to make use of the changes.
parent b7b92754
No related branches found
No related tags found
1 merge request!203Modify the tracker database generation tool so it can read an external input....
......@@ -5,7 +5,7 @@ import sys
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaConfiguration.ComponentFactory import CompFactory
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", alignmentConstants={}, **kwargs):
# Initialize GeoModel
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
......@@ -32,7 +32,12 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
PoolContainerPrefix="ConditionsContainer",
TopLevelContainerName = "<type>",
SubLevelBranchName= "<key>" )
kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE))
trackerAlignDBTool = CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool,
OutputLevel=VERBOSE,
AlignmentConstants = {})
kwargs.setdefault("AlignDbTool", trackerAlignDBTool)
trackerAlignDBTool.AlignmentConstants = alignmentConstants
a.addEventAlgo(WriteAlignmentAlg(name, **kwargs))
return a
......@@ -53,12 +58,23 @@ if __name__ == "__main__":
ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200"
ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch
ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root")
# Parse flags from command line and lock
ConfigFlags.addFlag("AlignDbTool.AlignmentConstants", {})
ConfigFlags.fillFromArgs(sys.argv[1:])
ConfigFlags.lock()
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
acc = MainServicesCfg(ConfigFlags)
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(WriteAlignmentCfg(ConfigFlags, alignmentConstants=ConfigFlags.AlignDbTool.AlignmentConstants, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"), ))
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
acc = MainServicesCfg(ConfigFlags)
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN")))
......
......@@ -5,7 +5,7 @@ import sys
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaConfiguration.ComponentFactory import CompFactory
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", alignmentConstants={}, **kwargs):
# Initialize GeoModel
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
......@@ -32,7 +32,12 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
PoolContainerPrefix="ConditionsContainer",
TopLevelContainerName = "<type>",
SubLevelBranchName= "<key>" )
kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE))
trackerAlignDBTool = CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool,
OutputLevel=VERBOSE,
AlignmentConstants = {})
kwargs.setdefault("AlignDbTool", trackerAlignDBTool)
trackerAlignDBTool.AlignmentConstants = alignmentConstants
a.addEventAlgo(WriteAlignmentAlg(name, **kwargs))
return a
......@@ -53,12 +58,23 @@ if __name__ == "__main__":
ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200"
ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch
ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root")
# Parse flags from command line and lock
ConfigFlags.addFlag("AlignDbTool.AlignmentConstants", {})
ConfigFlags.fillFromArgs(sys.argv[1:])
ConfigFlags.lock()
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
acc = MainServicesCfg(ConfigFlags)
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(WriteAlignmentCfg(ConfigFlags, alignmentConstants=ConfigFlags.AlignDbTool.AlignmentConstants, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"), ))
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
acc = MainServicesCfg(ConfigFlags)
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN")))
......
......@@ -5,7 +5,7 @@ import sys
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaConfiguration.ComponentFactory import CompFactory
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", alignmentConstants={}, **kwargs):
# Initialize GeoModel
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
......@@ -32,7 +32,12 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs):
PoolContainerPrefix="ConditionsContainer",
TopLevelContainerName = "<type>",
SubLevelBranchName= "<key>" )
kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE))
trackerAlignDBTool = CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool,
OutputLevel=VERBOSE,
AlignmentConstants = {})
kwargs.setdefault("AlignDbTool", trackerAlignDBTool)
trackerAlignDBTool.AlignmentConstants = alignmentConstants
a.addEventAlgo(WriteAlignmentAlg(name, **kwargs))
return a
......@@ -53,6 +58,10 @@ if __name__ == "__main__":
ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200"
ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch
ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root")
# Parse flags from command line and lock
ConfigFlags.addFlag("AlignDbTool.AlignmentConstants", {})
ConfigFlags.fillFromArgs(sys.argv[1:])
ConfigFlags.lock()
# Configure components
......@@ -60,7 +69,7 @@ if __name__ == "__main__":
acc = MainServicesCfg(ConfigFlags)
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN")))
acc.merge(WriteAlignmentCfg(ConfigFlags, alignmentConstants=ConfigFlags.AlignDbTool.AlignmentConstants, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"), ))
# Configure verbosity
# ConfigFlags.dump()
......
......@@ -214,25 +214,27 @@ StatusCode TrackerAlignDBTool::createDB() const
int iModule = iModulePhi;
if (iModuleEta < 0) iModule +=4;
const auto key = [](auto iStation, auto iLayer, auto iModule, auto parameter) {
const auto buildKey = [](auto iStation, auto iLayer, auto iModule) {
std::stringstream ss;
ss << iStation << "." << iLayer << "." << iModule << "-" << parameter;
ss << iStation << iLayer << iModule;
return ss.str();
};
const double x = m_alignment.value().find(key(iStation, iLayer, iModule, "x"))->second;
const double y = m_alignment.value().find(key(iStation, iLayer, iModule, "y"))->second;
const double z = m_alignment.value().find(key(iStation, iLayer, iModule, "z"))->second;
const double alpha = m_alignment.value().find(key(iStation, iLayer, iModule, "alpha"))->second;
const double beta = m_alignment.value().find(key(iStation, iLayer, iModule, "beta"))->second;
const double gamma = m_alignment.value().find(key(iStation, iLayer, iModule, "gamma"))->second;
Amg::Translation3D newtranslation(x, y, z);
Amg::Transform3D alignment = newtranslation * Amg::RotationMatrix3D::Identity();
alignment *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
alignment *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
alignment *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
pat->add(ident, Amg::EigenTransformToCLHEP(alignment));
const auto key = buildKey(iStation, iLayer, iModule);
if (not (m_alignment.find(key) == m_alignment.end())) {
const std::vector<double> c = m_alignment.value().find(key)->second;
ATH_MSG_VERBOSE("Applying correction for " << key);
ATH_MSG_VERBOSE(c[0] << " " << c[1] << " " << c[2] << " " << c[3] << " " << c[4] << " " << c[5]);
Amg::Translation3D newtranslation(c[0], c[1], c[2]);
Amg::Transform3D alignment = newtranslation * Amg::RotationMatrix3D::Identity();
alignment *= Amg::AngleAxis3D(c[5], Amg::Vector3D(0.,0.,1.));
alignment *= Amg::AngleAxis3D(c[4], Amg::Vector3D(0.,1.,0.));
alignment *= Amg::AngleAxis3D(c[3], Amg::Vector3D(1.,0.,0.));
pat->add(ident, Amg::EigenTransformToCLHEP(alignment));
} else {
ATH_MSG_VERBOSE("No correction given for " << key);
}
}
else
{
......@@ -256,25 +258,27 @@ StatusCode TrackerAlignDBTool::createDB() const
auto iStation = m_sctid->station(ident);
auto iLayer = m_sctid->layer(ident);
const auto key = [](auto iStation, auto iLayer, auto parameter) {
const auto buildKey = [](auto iStation, auto iLayer) {
std::stringstream ss;
ss << iStation << "." << iLayer << "-" << parameter;
ss << iStation << iLayer;
return ss.str();
};
const double x = m_alignment.value().find(key(iStation, iLayer, "x"))->second;
const double y = m_alignment.value().find(key(iStation, iLayer, "y"))->second;
const double z = m_alignment.value().find(key(iStation, iLayer, "z"))->second;
const double alpha = m_alignment.value().find(key(iStation, iLayer, "alpha"))->second;
const double beta = m_alignment.value().find(key(iStation, iLayer, "beta"))->second;
const double gamma = m_alignment.value().find(key(iStation, iLayer, "gamma"))->second;
Amg::Translation3D newtranslation(x, y, z);
Amg::Transform3D alignment = newtranslation * Amg::RotationMatrix3D::Identity();
alignment *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
alignment *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
alignment *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
pat->add(ident2, Amg::EigenTransformToCLHEP(alignment));
const auto key = buildKey(iStation, iLayer);
if (not (m_alignment.find(key) == m_alignment.end())) {
const std::vector<double> c = m_alignment.value().find(key)->second;
ATH_MSG_VERBOSE("Applying correction for " << key);
ATH_MSG_VERBOSE(c[0] << " " << c[1] << " " << c[2] << " " << c[3] << " " << c[4] << " " << c[5]);
Amg::Translation3D newtranslation(c[0], c[1], c[2]);
Amg::Transform3D alignment = newtranslation * Amg::RotationMatrix3D::Identity();
alignment *= Amg::AngleAxis3D(c[5], Amg::Vector3D(0.,0.,1.));
alignment *= Amg::AngleAxis3D(c[4], Amg::Vector3D(0.,1.,0.));
alignment *= Amg::AngleAxis3D(c[3], Amg::Vector3D(1.,0.,0.));
pat->add(ident2, Amg::EigenTransformToCLHEP(alignment));
} else {
ATH_MSG_VERBOSE("No correction given for " << key);
}
}
else
{
......
......@@ -186,7 +186,7 @@ class TrackerAlignDBTool: virtual public ITrackerAlignDBTool, public AthAlgTool
bool m_dynamicDB;
bool m_forceUserDBConfig;
std::set<int> m_stations;
Gaudi::Property<std::map<std::string, double>> m_alignment{ this, "AlignmentConstants", {}, "Alignment constants."};
Gaudi::Property<std::map<std::string, std::vector<double>>> m_alignment{ this, "AlignmentConstants", {}, "Alignment constants."};
mutable ToolHandle<IAthenaOutputStreamTool> m_outputTool { this, "OutputTool", "AthenaOutputStreamTool/CondStream1"} ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment