9#include <alignment/GlobalParam.h>
11#include <alignment/Hierarchy.h>
12#include <framework/geometry/B2Vector3.h>
13#include <framework/logging/Logger.h>
14#include <vxd/geometry/GeoCache.h>
36 this->ensureConstructed();
37 if (element != 0 or param > 3) {
38 B2ERROR(
"Invalid global BeamSpot parameter id");
42 if (
auto bp =
dynamic_cast<BeamSpot*
>(this->getDBObj()))
43 return bp->getIPPosition()[param - 1];
45 B2ERROR(
"Could not get value for BeamSpot");
52 this->ensureConstructed();
53 if (element != 0 or param > 3) {
54 B2ERROR(
"Invalid global BeamSpot id");
57 if (
auto bp =
dynamic_cast<BeamSpot*
>(this->getDBObj())) {
59 vertex[param - 1] = value;
60 bp->setIP(vertex, bp->getIPPositionCovMatrix());
62 B2ERROR(
"Could not set value for BeamSpot");
70 return {{0, 1}, {0, 2}, {0, 3}};
77 short unsigned int param)
84 short unsigned int param)
86 auto dbObj =
m_vector.find(uniqueID);
88 dbObj->second->setGlobalParam(value, element, param);
90 B2WARNING(
"Did not found DB object with unique id " << uniqueID <<
" in global vector. Cannot set value for element " << element <<
91 " and parameter " << param);
96 auto dbObj =
m_vector.find(uniqueID);
98 return dbObj->second->getGlobalParam(element, param);
100 B2WARNING(
"Did not found DB object with unique id " << uniqueID <<
" in global vector. Cannot get value for element " << element <<
101 " and parameter " << param <<
". Returning 0.");
107 std::vector<std::tuple<unsigned short, unsigned short, unsigned short>> params;
109 for (
auto element_param : uID_DBObj.second->listGlobalParams()) {
110 params.push_back({uID_DBObj.first, element_param.first, element_param.second});
117 std::vector<TObject*> result;
119 if (onlyConstructed and not uID_DBObj.second->isConstructed())
122 result.push_back({uID_DBObj.second->releaseObject()});
129 uID_DBObj.second->loadFromDBObjPtr();
135 uID_DBObj.second->loadFromDB(event);
141 interface->setupAlignmentHierarchy(hierarchy);
148 if (not uID_DBObj.second->isConstructed()) uID_DBObj.second->construct();
152 std::vector< std::tuple< short unsigned int, short unsigned int, short unsigned int, double > >& results)
155 interface->readFromResult(results, *
this);
160 VXDGlobalParamInterface::E_VXDHierarchyType::c_Full;
176 for (
auto& sensor : geo.getListOfSensors()) {
186 geo.getSensorInfo(sensor).getTransformation(
true));
198 for (
auto& halfShellPlacement : geo.getHalfShellPlacements()) {
200 if (halfShellPlacement.first.getLayerNumber() <= 2 and !
s_enablePXD)
203 if (halfShellPlacement.first.getLayerNumber() > 2 and !
s_enableSVD)
206 TGeoHMatrix trafoHalfShell = halfShellPlacement.second;
207 trafoHalfShell *= geo.getTGeoFromRigidBodyParams(
217 for (
auto& ladderPlacement : geo.getLadderPlacements(halfShellPlacement.first)) {
219 TGeoHMatrix trafoLadder = ladderPlacement.second;
220 trafoLadder *= geo.getTGeoFromRigidBodyParams(
231 for (
auto& sensorPlacement : geo.getSensorPlacements(ladderPlacement.first)) {
233 TGeoHMatrix trafoSensor = sensorPlacement.second;
234 trafoSensor *= geo.getTGeoFromRigidBodyParams(
243 trafoLadder * trafoSensor);
261 for (
auto& halfShellPlacement : geo.getHalfShellPlacements()) {
263 if (halfShellPlacement.first.getLayerNumber() <= 2 and !
s_enablePXD)
266 if (halfShellPlacement.first.getLayerNumber() > 2 and !
s_enableSVD)
269 TGeoHMatrix trafoHalfShell = halfShellPlacement.second;
270 trafoHalfShell *= geo.getTGeoFromRigidBodyParams(
280 for (
auto& ladderPlacement : geo.getLadderPlacements(halfShellPlacement.first)) {
282 TGeoHMatrix trafoLadder = ladderPlacement.second;
283 trafoLadder *= geo.getTGeoFromRigidBodyParams(
291 rigidBodyHierarchy.insertTGeoTransform<
VXDAlignment,
VXDAlignment>(ladderPlacement.first, halfShellPlacement.first, trafoLadder);
293 for (
auto& sensorPlacement : geo.getSensorPlacements(ladderPlacement.first)) {
295 TGeoHMatrix trafoSensor = sensorPlacement.second;
296 trafoSensor *= geo.getTGeoFromRigidBodyParams(
304 rigidBodyHierarchy.insertTGeoTransform<
VXDAlignment,
VXDAlignment>(sensorPlacement.first, ladderPlacement.first, trafoSensor);
311 }
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.