9#include <alignment/GlobalParam.h>
11#include <alignment/Hierarchy.h>
12#include <framework/logging/Logger.h>
13#include <vxd/geometry/GeoCache.h>
15#include <Math/Vector3D.h>
37 this->ensureConstructed();
38 if (element != 0 or param > 3) {
39 B2ERROR(
"Invalid global BeamSpot parameter id");
43 if (
auto bp =
dynamic_cast<BeamSpot*
>(this->getDBObj())) {
45 return bp->getIPPosition().X();
46 }
else if (param == 2) {
47 return bp->getIPPosition().Y();
48 }
else if (param == 3) {
49 return bp->getIPPosition().Z();
53 B2ERROR(
"Could not get value for BeamSpot");
60 this->ensureConstructed();
61 if (element != 0 or param > 3) {
62 B2ERROR(
"Invalid global BeamSpot id");
65 if (
auto bp =
dynamic_cast<BeamSpot*
>(this->getDBObj())) {
66 ROOT::Math::XYZVector vertex = bp->getIPPosition();
67 if (param == 1) vertex.SetX(value);
68 else if (param == 2) vertex.SetY(value);
69 else if (param == 3) vertex.SetZ(value);
70 bp->setIP(vertex, bp->getIPPositionCovMatrix());
72 B2ERROR(
"Could not set value for BeamSpot");
80 return {{0, 1}, {0, 2}, {0, 3}};
87 short unsigned int param)
94 short unsigned int param)
96 auto dbObj =
m_vector.find(uniqueID);
98 dbObj->second->setGlobalParam(value, element, param);
100 B2WARNING(
"Did not found DB object with unique id " << uniqueID <<
" in global vector. Cannot set value for element " << element <<
101 " and parameter " << param);
106 auto dbObj =
m_vector.find(uniqueID);
108 return dbObj->second->getGlobalParam(element, param);
110 B2WARNING(
"Did not found DB object with unique id " << uniqueID <<
" in global vector. Cannot get value for element " << element <<
111 " and parameter " << param <<
". Returning 0.");
117 std::vector<std::tuple<unsigned short, unsigned short, unsigned short>> params;
119 for (
auto element_param : uID_DBObj.second->listGlobalParams()) {
120 params.push_back({uID_DBObj.first, element_param.first, element_param.second});
127 std::vector<TObject*> result;
129 if (onlyConstructed and not uID_DBObj.second->isConstructed())
132 result.push_back({uID_DBObj.second->releaseObject()});
139 uID_DBObj.second->loadFromDBObjPtr();
145 uID_DBObj.second->loadFromDB(event);
151 interface->setupAlignmentHierarchy(hierarchy);
158 if (not uID_DBObj.second->isConstructed()) uID_DBObj.second->construct();
162 std::vector< std::tuple< short unsigned int, short unsigned int, short unsigned int, double > >& results)
165 interface->readFromResult(results, *
this);
170 VXDGlobalParamInterface::E_VXDHierarchyType::c_Full;
186 for (
auto& sensor : geo.getListOfSensors()) {
196 geo.getSensorInfo(sensor).getTransformation(
true));
208 for (
auto& halfShellPlacement : geo.getHalfShellPlacements()) {
210 if (halfShellPlacement.first.getLayerNumber() <= 2 and !
s_enablePXD)
213 if (halfShellPlacement.first.getLayerNumber() > 2 and !
s_enableSVD)
216 TGeoHMatrix trafoHalfShell = halfShellPlacement.second;
217 trafoHalfShell *= geo.getTGeoFromRigidBodyParams(
227 for (
auto& ladderPlacement : geo.getLadderPlacements(halfShellPlacement.first)) {
229 TGeoHMatrix trafoLadder = ladderPlacement.second;
230 trafoLadder *= geo.getTGeoFromRigidBodyParams(
241 for (
auto& sensorPlacement : geo.getSensorPlacements(ladderPlacement.first)) {
243 TGeoHMatrix trafoSensor = sensorPlacement.second;
244 trafoSensor *= geo.getTGeoFromRigidBodyParams(
253 trafoLadder * trafoSensor);
271 for (
auto& halfShellPlacement : geo.getHalfShellPlacements()) {
273 if (halfShellPlacement.first.getLayerNumber() <= 2 and !
s_enablePXD)
276 if (halfShellPlacement.first.getLayerNumber() > 2 and !
s_enableSVD)
279 TGeoHMatrix trafoHalfShell = halfShellPlacement.second;
280 trafoHalfShell *= geo.getTGeoFromRigidBodyParams(
290 for (
auto& ladderPlacement : geo.getLadderPlacements(halfShellPlacement.first)) {
292 TGeoHMatrix trafoLadder = ladderPlacement.second;
293 trafoLadder *= geo.getTGeoFromRigidBodyParams(
301 rigidBodyHierarchy.insertTGeoTransform<
VXDAlignment,
VXDAlignment>(ladderPlacement.first, halfShellPlacement.first, trafoLadder);
303 for (
auto& sensorPlacement : geo.getSensorPlacements(ladderPlacement.first)) {
305 TGeoHMatrix trafoSensor = sensorPlacement.second;
306 trafoSensor *= geo.getTGeoFromRigidBodyParams(
314 rigidBodyHierarchy.insertTGeoTransform<
VXDAlignment,
VXDAlignment>(sensorPlacement.first, ladderPlacement.first, trafoSensor);
321 }
catch (
const std::bad_cast& e) {
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Class for accessing objects in the database.
VXD alignment (and maybe some calibration) parameters.
static const baseType dAlpha
Sensor/layer/ladder alignment in local alpha.
static const baseType dGamma
Sensor/layer/ladder alignment in local gamma.
static const baseType dW
Sensor/layer/ladder alignment in local w.
static const baseType dBeta
Sensor/layer/ladder alignment in local beta.
static const baseType dU
Sensor/layer/ladder alignment in local u.
static const baseType dV
Sensor/layer/ladder alignment in local v.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Class to uniquely identify a any structure of the PXD and SVD.
Object representing no parameters.
Class for alignment/calibration parameter hierarchy & constraints.
virtual void setGlobalParam(double value, unsigned short element, unsigned short param) override final
Set global parameter of the DB object by its element and parameter number.
virtual double getGlobalParam(unsigned short element, unsigned short param) override final
Get global parameter of the DB object by its element and parameter number Note this is not const,...
virtual std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams() override final
List global parameters in this DB object.
virtual unsigned short getGlobalUniqueID() const override final
The DB object unique id in global calibration.
std::vector< std::tuple< unsigned short, unsigned short, unsigned short > > listGlobalParams()
Create vector of all global parameters maintained by GlobalParamVector.
std::vector< TObject * > releaseObjects(bool onlyConstructed=true)
Get the vector of raw pointers to DB objects Caller takes the ownership of the objects and has to del...
GlobalParamVector(const std::vector< std::string > &components={})
Constructor.
std::map< unsigned short, std::unique_ptr< GlobalParamSetAccess > > m_vector
The vector (well, actually a map) of DB objects.
std::vector< std::shared_ptr< IGlobalParamInterface > > m_subDetectorInterfacesVector
Vector of interfaces to run at specific points in the workflow.
void setGlobalParam(double value, unsigned short uniqueID, unsigned short element, unsigned short param)
Set param value.
double getGlobalParam(unsigned short uniqueID, unsigned short element, unsigned short param)
Get parameter value.
void construct()
Construct all DB objects using default constructors (should be filled with zeros)
void postReadFromResult(std::vector< std::tuple< unsigned short, unsigned short, unsigned short, double > > &result)
Function calling interfaces to do post processing after reading millepede result into GlobalParamVect...
void postHierarchyChanged(GlobalDerivativesHierarchy &hierarchy)
Function calling interfaces to build alignment hierarchy after constants changed in DB.
void loadFromDB()
Load content of all objects in vector with values valid at current EventMetaData Uses DBObjPtr<DBObjT...
void updateGlobalParam(double difference, unsigned short uniqueID, unsigned short element, unsigned short param)
Add 'difference' to param value.
6D Hierarchy of rigid bodies
static bool s_enablePXD
Enable PXD in hierarchy?
static bool s_enableSVD
Enable SVD in hierarchy?
virtual void setupAlignmentHierarchy(GlobalDerivativesHierarchy &hierarchy) override final
Very tentative function: not yet used.
E_VXDHierarchyType
Type of VXD hierarchy.
static E_VXDHierarchyType s_hierarchyType
What type of hierarchy to use for VXD?
Abstract base class for different kinds of events.