132using namespace Eigen;
138#if (defined (JNA_DEBUG) || defined (JNA_MEMORY_MONITOR))
139#define JNA_DO_MONITOR 1
141#define JNA_DO_MONITOR 0
147long int num_gbl_point = 0;
148long int num_gbl_traj = 0;
149long int num_mille_bin = 0;
150long int num_gbl_det_layer = 0;
151long int num_gbl_simple_helix = 0;
152long int num_gbl_helix_prediction = 0;
167__attribute__((destructor))
170 <<
" GBL Structures Left\n"
171 <<
"GBL Points: " << num_gbl_point <<
"\n"
172 <<
"GBL Trajectories: " << num_gbl_traj <<
"\n"
173 <<
"Mille Binaries: " << num_mille_bin <<
"\n"
174 <<
"GBL Det Layers: " << num_gbl_det_layer <<
"\n"
175 <<
"GBL Simple Helix: " << num_gbl_simple_helix <<
"\n"
176 <<
"GBL Helix Pred: " << num_gbl_helix_prediction <<
"\n"
195 std::vector<GblPoint> points_vec;
201 points_vec.reserve(npoints);
203 for (
int i{0}; i < npoints; ++i) {
208 points_vec.emplace_back(*(gblpoint));
213 std::cout <<
"COPY GblPoint " << gblpoint <<
" -> " << &(points_vec.back()) << std::endl;
237 std::cout <<
"MilleBinaryCtor(" << fileName <<
", " << filenamesize <<
", "
238 << doublePrecision <<
", " << keepZeros <<
", " << aSize <<
")" << std::endl;
240 std::string binName(fileName,filenamesize);
243 std::cout <<
"MilleBinary created at " << mb << std::endl;
266 std::cout <<
"MilleBinary_close(" << self <<
")" << std::endl;
271 if (self)
delete self;
281 Map<Matrix5d> jacobian(matrixArray,5,5);
287 std::cout <<
"GblPointCtor at " << self <<
" " << num_gbl_point << std::endl;
305 std::cout <<
"GblPoint_delete(" << self <<
") " << num_gbl_point << std::endl;
307 if (self)
delete self;
316 std::cout <<
"GblPoint_printPoint(" << self <<
", " << level <<
")" << std::endl;
333 std::cout <<
"GblPoint_getNumMeasurements(" << self <<
")" << std::endl;
356 double minPrecision) {
358 std::cout <<
"GblPoint_addMeasurement2D("
359 << self <<
", " << projArray <<
", " << resArray <<
", " << precArray <<
", " << minPrecision
363 Map<Matrix2d> aProjection(projArray,2,2);
364 Map<Vector2d> aResiduals(resArray, 2);
365 Map<Vector2d> aPrecision(precArray,2);
367 self->
addMeasurement(aProjection, aResiduals, aPrecision, minPrecision);
380 std::cout <<
"GblPoint_addScatterer(" << self <<
", "
381 << resArray <<
", " << precArray <<
")" << std::endl;
385 Eigen::Vector2d aResiduals(resArray);
386 Eigen::Vector2d aPrecision(precArray);
401 std::cout <<
"GblPoint_addGlobals(" << self
402 <<
", " << labels <<
", " << nlabels <<
", " << derArray <<
")" << std::endl;
404 std::vector<int> aLabels;
405 for (
int i=0; i<nlabels; i++) {
406 aLabels.push_back(labels[i]);
408 Map<Eigen::MatrixXd> derivatives(derArray,1,nlabels);
422 std::cout <<
"GblPoint_getGlobalLabelsAndDerivatives("
423 << self <<
", " << labels <<
", " << ders
426 std::vector<int> glabels;
427 std::vector<double> gders;
430 std::cout <<
" GblPoint has " << std::flush
432 <<
" measurements." << std::endl;
441 std::cout <<
" Aquired " << glabels.size() <<
" labels and " << gders.size() <<
" derivatives." <<std::endl;
444 *nlabels = glabels.size();
445 *labels =
new int[*nlabels];
446 *ders =
new double[*nlabels];
449 std::cout <<
" Allocated return arrays." << std::endl;
453 for (std::size_t il{0}; il < glabels.size(); ++il) {
454 (*labels)[il] = glabels.at(il);
460 for (std::size_t
id{0};
id < glabels.size(); ++id) {
461 (*ders)[id] = gders.at(
id);
468 std::cout <<
" Done with assignment and leaving." << std::endl;
487 int flagCurv,
int flagU1dir,
int flagU2dir) {
489 std::cout <<
"GblTracjectoryCtorPtrArray("
490 << points <<
", " << npoints <<
", "
491 << flagCurv <<
", " << flagU1dir <<
", " << flagU2dir
499 flagCurv!=0, flagU1dir!=0, flagU2dir!=0);
515 int aLabel,
double seedArray[],
516 int flagCurv,
int flagU1dir,
int flagU2dir) {
518 std::cout <<
"GblTrajectoryCtorPtrArraySeed("
519 << points <<
", " << npoints <<
", "
520 << aLabel <<
", " << seedArray <<
", "
521 << flagCurv <<
", " << flagU1dir <<
", " << flagU2dir
528 Map<Matrix5d> seed(seedArray,5,5);
531 flagCurv!=0, flagU1dir!=0, flagU2dir!=0);
546 GblPoint* points_2[],
int npoints_2,
double trafo_2[]) {
548 std::cout <<
"GblTrajectoryCtorPtrComposed("
549 << points_1 <<
", " << npoints_1 <<
", " << trafo_1 <<
", "
550 << points_2 <<
", " << npoints_2 <<
", " << trafo_2 <<
")"
558 MatrixXd inner_1(2,3);
559 inner_1(0,0)=trafo_1[0];
560 inner_1(0,1)=trafo_1[1];
561 inner_1(0,2)=trafo_1[2];
563 inner_1(1,0)=trafo_1[3];
564 inner_1(1,1)=trafo_1[4];
565 inner_1(1,2)=trafo_1[5];
567 std::pair<std::vector<GblPoint>, MatrixXd> track_trafo_1 = std::make_pair(
ptr_array_to_vector(points_1, npoints_1), inner_1);
571 MatrixXd inner_2(2,3);
572 inner_2(0,0)=trafo_2[0];
573 inner_2(0,1)=trafo_2[1];
574 inner_2(0,2)=trafo_2[2];
576 inner_2(1,0)=trafo_2[3];
577 inner_2(1,1)=trafo_2[4];
578 inner_2(1,2)=trafo_2[5];
580 std::pair<std::vector<GblPoint>, MatrixXd> track_trafo_2 = std::make_pair(
ptr_array_to_vector(points_2, npoints_2), inner_2);
597 std::cout <<
"GblTrajectory_fit("
598 << self <<
", " << Chi2 <<
", " << Ndf <<
", " << lostWeight <<
", " << c_optionList <<
", " << aLabel <<
")"
602 std::string optionList(c_optionList);
603 self->
fit(*Chi2, *Ndf, *lostWeight, optionList,aLabel);
613 std::cout <<
"GblTrajectory_delete(" << self <<
")" << std::endl;
621 if (self)
delete self;
631 std::cout <<
"GblTrajectory_isValid(" << self <<
")" << std::endl;
633 return self->
isValid() ? 0 : 1;
643 std::cout <<
"GblTrajectory_getNumPoints(" << self <<
")" << std::endl;
655 std::cout <<
"GblTrajectory_printTrajectory(" << self <<
", " << level <<
")" << std::endl;
666 std::cout <<
"GblTrajectory_printData(" << self <<
")" << std::endl;
678 std::cout <<
"GblTrajectory_printPoints(" << self <<
", " << level <<
")" << std::endl;
694 double * localCov,
int* sizeLocalCov) {
696 std::cout <<
"GblTrajectory_getResults(" << self
697 <<
", " << aSignedLabel <<
", " << localPar <<
", " << nLocalPar
698 <<
", " << localCov <<
", " << sizeLocalCov <<
")" << std::endl;
701 Eigen::VectorXd e_localPar(5);
702 Eigen::MatrixXd e_localCov(5,5);
704 self->
getResults(aSignedLabel, e_localPar, e_localCov);
710 Map<Vector5d>(localPar, 5) = e_localPar;
711 Map<Matrix5d>(localCov, 5, 5) = e_localCov;
728 double* aResiduals,
double* aMeasErrors,
double* aResErrors,
729 double* aDownWeights) {
731 std::cout <<
"GblTrajectory_getMeasResults(" << self
732 <<
", " << aLabel <<
", " << numData <<
", " << aResiduals
733 <<
", " << aMeasErrors <<
", " << aResErrors <<
", " << aDownWeights <<
")" << std::endl;
736 Eigen::VectorXd e_aResiduals(2);
737 Eigen::VectorXd e_aMeasErrors(2);
738 Eigen::VectorXd e_aResErrors(2);
739 Eigen::VectorXd e_aDownWeights(2);
740 unsigned int num_data = 0;
742 unsigned int out = self->
getMeasResults(aLabel, num_data, e_aResiduals, e_aMeasErrors,
743 e_aResErrors, e_aDownWeights);
745 std::cout <<
" getMeasResults returned the status code " << out << std::endl;
750 for (
unsigned int i = 0; i < num_data; i++) {
751 aResiduals[i] = e_aResiduals(i);
752 aMeasErrors[i] = e_aMeasErrors(i);
753 aResErrors[i] = e_aResErrors(i);
754 aDownWeights[i] = e_aDownWeights(i);
768 std::cout <<
"GblTrajectory_milleOut(" << self
769 <<
", " << millebinary <<
")" << std::endl;
789 double aCenter[],
double aResolution[],
double aPrecision[],
790 double measTrafo[],
double alignTrafo[]) {
792 std::cout <<
"GblDetectorLayerCtor(" << aName <<
", " << aLayer
793 <<
", " << aDim <<
", " << thickness <<
", " << aCenter <<
", " << aResolution
794 <<
", " << aPrecision <<
", " << measTrafo <<
", " << alignTrafo <<
")" << std::endl;
803 Vector3d e_aCenter(Map<Vector3d>(aCenter,3));
804 Vector2d e_aResolution(Map<Vector2d>(aResolution,2));
805 Vector2d e_aPrecision(Map<Vector2d>(aPrecision,2));
806 Matrix3d e_measTrafo(Map<Matrix3d>(measTrafo,3,3));
807 Matrix3d e_alignTrafo(Map<Matrix3d>(alignTrafo,3,3));
818 std::cout <<
"GblDetectorLayer_delete(" << self <<
")" << std::endl;
823 if (self)
delete self;
832 std::cout <<
"GblDetectorLayer_print(" << self <<
")" << std::endl;
843 std::cout <<
"GblDetectorLayer_getRadiationLength(" << self <<
")" << std::endl;
866 std::cout <<
"GblDetectorLayer_intersectWithHelix(" << self <<
", " << hlx <<
")" << std::endl;
869 ++num_gbl_helix_prediction;
889 ++num_gbl_simple_helix;
899 --num_gbl_simple_helix;
901 if (self)
delete self;
911 return self->
getPhi(aRadius);
945 double* newPhi0,
double* newDca,
double* newZ0) {
947 *newPhi0, *newDca, *newZ0);
961 Map<Vector3d> e_refPos(refPos,3);
962 Map<Vector3d> e_uDir(uDir,3);
963 Map<Vector3d> e_vDir(vDir,3);
973 ++num_gbl_helix_prediction;
990 double nDir[],
double aPos[]) {
991 Map<Vector2d> e_aPred(aPred,2);
992 Map<Vector3d> e_tDir(tDir,3);
993 Map<Vector3d> e_uDir(uDir,3);
994 Map<Vector3d> e_vDir(vDir,3);
995 Map<Vector3d> e_nDir(nDir,3);
996 Map<Vector3d> e_aPos(aPos,3);
1000 ++num_gbl_helix_prediction;
1012 --num_gbl_helix_prediction;
1014 if (self)
delete self;
1036 prediction[0] = e_pred(0);
1037 prediction[1] = e_pred(1);
1049 position[0] = e_pos(0);
1050 position[1] = e_pos(1);
1051 position[2] = e_pos(2);
1063 direction[0] = e_dir(0);
1064 direction[1] = e_dir(1);
1065 direction[2] = e_dir(2);
1087 curvilinear[0] = curDirs(0,0);
1088 curvilinear[1] = curDirs(0,1);
1089 curvilinear[2] = curDirs(0,2);
1090 curvilinear[3] = curDirs(1,0);
1091 curvilinear[4] = curDirs(1,1);
1092 curvilinear[5] = curDirs(1,2);
GblTrajectory definition.
Definitions for GBL utilities.
void GblTrajectory_printTrajectory(GblTrajectory *self, int level)
call gbl::GblTrajectory::printTrajectory
void GblHelixPrediction_getPosition(GblHelixPrediction *self, double *position)
get the position
void GblHelixPrediction_getCurvilinearDirs(GblHelixPrediction *self, double curvilinear[])
get the curvilinear directions
GblHelixPrediction * GblDetectorLayer_intersectWithHelix(GblDetectorLayer *self, GblSimpleHelix *hlx)
construct a helix prediction from a layer
void GblHelixPrediction_delete(GblHelixPrediction *self)
delete a gbl::GblHelixPrediction
double GblSimpleHelix_getPhi(GblSimpleHelix *self, double aRadius)
call gbl::GblSimpleHelix::getPhi
GblTrajectory * GblTrajectoryCtorPtrComposed(GblPoint *points_1[], int npoints_1, double trafo_1[], GblPoint *points_2[], int npoints_2, double trafo_2[])
compose trajectory for a 2-body decay
void GblTrajectory_getResults(GblTrajectory *self, int aSignedLabel, double *localPar, int *nLocalPar, double *localCov, int *sizeLocalCov)
get trajectory results
void MilleBinary_close(MilleBinary *self)
Closing a gbl::MilleBinary file is the same as destructing it.
double GblSimpleHelix_getArcLengthXY(GblSimpleHelix *self, double xPos, double yPos)
call gbl::GblSimpleHelix::getArcLengthXY
void GblTrajectory_delete(GblTrajectory *self)
delete self
int GblPoint_getNumMeasurements(GblPoint *self)
calculate number of measurements in a gbl::GblPoint
void GblHelixPrediction_getDirection(GblHelixPrediction *self, double direction[])
get the direction
MilleBinary * MilleBinaryCtor(const char *fileName, int filenamesize, int doublePrecision, int keepZeros, int aSize)
Dynamically create new MilleBinary file.
int GblTrajectory_getNumPoints(GblTrajectory *self)
call gbl::GblTrajectory::getNumPoints
GblTrajectory * GblTrajectoryCtorPtrArraySeed(GblPoint *points[], int npoints, int aLabel, double seedArray[], int flagCurv, int flagU1dir, int flagU2dir)
construct new gbl::GblTrajectory with a seed matrix
std::vector< GblPoint > ptr_array_to_vector(GblPoint *points[], int npoints)
convert the pointer array of gbl::GblPoint into a vector holding the objects
GblTrajectory * GblTrajectoryCtorPtrArray(GblPoint *points[], int npoints, int flagCurv, int flagU1dir, int flagU2dir)
simple construction of a new gbl::GblTrajectory
double GblHelixPrediction_getArcLength(GblHelixPrediction *self)
get the arc length of a helix prediction
int GblTrajectory_isValid(GblTrajectory *self)
call gbl::GblTrajectory::isValid
void GblSimpleHelix_moveToXY(GblSimpleHelix *self, double xPos, double yPos, double *newPhi0, double *newDca, double *newZ0)
call gbl::GblSimpleHelix::moveToXY
GblHelixPrediction * GblHelixPredictionCtor(double sArc, double aPred[], double tDir[], double uDir[], double vDir[], double nDir[], double aPos[])
create a new helix prediction manually
void GblDetectorLayer_print(GblDetectorLayer *self)
call gbl::GblDetectorLayer::print
GblHelixPrediction * GblSimpleHelix_getPrediction(GblSimpleHelix *self, double refPos[], double uDir[], double vDir[])
get a helical prediction from a reference coordinate system
void GblPoint_addGlobals(GblPoint *self, int *labels, int nlabels, double *derArray)
add global derivatives to the point
void GblPoint_delete(GblPoint *self)
delete gbl::GblPoint
void GblTrajectory_milleOut(GblTrajectory *self, MilleBinary *millebinary)
write a trajectory to a gbl::MilleBinary file
void GblPoint_addScatterer(GblPoint *self, double *resArray, double *precArray)
add a vector-precision scatterer
double GblSimpleHelix_getArcLengthR(GblSimpleHelix *self, double aRadius)
call gbl::GblSimpleHelix::getArcLengthR
GblSimpleHelix * GblSimpleHelixCtor(double aRinv, double aPhi0, double aDca, double aDzds, double aZ0)
construct a new simple helix
GblPoint * GblPointCtor(double matrixArray[NROW *NCOL])
create new gbl::GblPoint from a jacobian
void GblHelixPrediction_getMeasPred(GblHelixPrediction *self, double *prediction)
get the predicted measurement
double GblHelixPrediction_getCosIncidence(GblHelixPrediction *self)
get the cosine incidence
GblDetectorLayer * GblDetectorLayerCtor(const char *aName, int aLayer, int aDim, double thickness, double aCenter[], double aResolution[], double aPrecision[], double measTrafo[], double alignTrafo[])
construct a detector layer
void GblTrajectory_fit(GblTrajectory *self, double *Chi2, int *Ndf, double *lostWeight, char *c_optionList, unsigned int aLabel)
call gbl::GblTrajectory::fit on self
void GblSimpleHelix_delete(GblSimpleHelix *self)
delete gbl::GblSimpleHelix
void GblDetectorLayer_delete(GblDetectorLayer *self)
delete gbl::GblDetectorLayer
void GblPoint_getGlobalLabelsAndDerivatives(GblPoint *self, int *nlabels, int **labels, double **ders)
get global derivatives and their labels from the point
void GblTrajectory_printPoints(GblTrajectory *self, int level)
call gbl::GblTrajectory::printPoints
void GblPoint_printPoint(const GblPoint *self, unsigned int level)
call gbl::GblPoint::printPoint on self
void GblPoint_addMeasurement2D(GblPoint *self, double *projArray, double *resArray, double *precArray, double minPrecision)
add a 2D measurement
double GblDetectorLayer_getRadiationLength(GblDetectorLayer *self)
call gbl::GblDetectorLayer::getRadiationLength
void GblTrajectory_printData(GblTrajectory *self)
call gbl::GblTrajectory::printData
int GblTrajectory_getMeasResults(GblTrajectory *self, int aLabel, int *numData, double *aResiduals, double *aMeasErrors, double *aResErrors, double *aDownWeights)
get measurement results from trajectory
Eigen::Vector3d getCenter() const
Get center.
double getRadiationLength() const
Get radiation length.
void print() const
Print GblDetectorLayer.
Eigen::Matrix3d getMeasSystemDirs() const
Get directions of measurement system.
Eigen::Matrix< double, 2, 3 > getCurvilinearDirs() const
Get curvilinear directions (U,V)
double getArcLength() const
Get arc-length.
const Eigen::Vector2d & getMeasPred() const
Get (measurement) prediction.
double getCosIncidence() const
Get cosine of incidence.
const Eigen::Vector3d & getPosition() const
Get position.
const Eigen::Vector3d & getDirection() const
Get position.
void addMeasurement(const Eigen::MatrixBase< Projection > &aProjection, const Eigen::MatrixBase< Residuals > &aResiduals, const Eigen::MatrixBase< Precision > &aPrecision, double minPrecision=0.)
Add a measurement to a point.
void getGlobalLabelsAndDerivatives(unsigned int aMeas, unsigned int aRow, std::vector< int > &aLabels, std::vector< double > &aDerivatives) const
Retrieve global derivatives from a measurement at a point for a single row.
void printPoint(unsigned int level=0) const
Print GblPoint.
std::vector< GblMeasurement >::iterator getMeasBegin()
Get GblMeasurement iterator for begin.
void addGlobals(const std::vector< int > &aLabels, const Eigen::MatrixBase< Derivative > &aDerivatives)
Add global derivatives to a point.
std::vector< GblMeasurement >::iterator getMeasEnd()
Get GblMeasurement iterator for end.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::Matrix2d &aPrecision)
Add a thin scatterer to a point.
double getArcLengthR(double aRadius) const
Get (2D) arc length for given radius (to ref. point)
void moveToXY(double xPos, double yPos, double &newPhi0, double &newDca, double &newZ0) const
Move to new reference point (X,Y)
GblHelixPrediction getPrediction(const Eigen::Vector3d &refPos, const Eigen::Vector3d &uDir, const Eigen::Vector3d &vDir) const
Get prediction.
double getPhi(double aRadius) const
Get phi (of point on circle) for given radius (to ref. point)
double getArcLengthXY(double xPos, double yPos) const
Get (2D) arc length for given point.
void printPoints(unsigned int level=0) const
Print GblPoints on trajectory.
unsigned int getMeasResults(unsigned int aLabel, unsigned int &numData, Eigen::VectorXd &aResiduals, Eigen::VectorXd &aMeasErrors, Eigen::VectorXd &aResErrors, Eigen::VectorXd &aDownWeights)
Get residuals from fit at point for measurement "long list".
void printTrajectory(unsigned int level=0) const
Print GblTrajectory.
void milleOut(MilleBinary &aMille)
Write valid trajectory to Millepede-II binary file.
bool isValid() const
Retrieve validity of trajectory.
unsigned int getResults(int aSignedLabel, Eigen::VectorXd &localPar, Eigen::MatrixXd &localCov) const
Get fit results at point.
unsigned int fit(double &Chi2, int &Ndf, double &lostWeight, const std::string &optionList="", unsigned int aLabel=0)
Perform fit of (valid) trajectory.
void printData() const
Print GblData blocks for trajectory.
unsigned int getNumPoints() const
Retrieve number of point from trajectory.
Millepede-II (binary) record.
Namespace for the general broken lines package.