95 thickness[0] = 0.0025;
96 for (
unsigned int iLayer = 1; iLayer < 11; ++iLayer)
97 thickness[iLayer] = 0.0005;
98 thickness[11] = 0.0025;
100 std::vector<GblDetectorLayer> layers;
101 const double theta(25.), cosTheta(cos(theta / 180. * M_PI)), sinTheta(
102 sin(theta / 180. * M_PI));
105 for (
unsigned int iLayer = 0; iLayer < 6; ++iLayer) {
107 CreateLayerDc(
"CH1+", 100, dist * sinTheta, 0.0, dist * cosTheta,
108 thickness[iLayer], theta, 6., 0.030));
111 for (
unsigned int iLayer = 6; iLayer < 12; ++iLayer) {
113 CreateLayerDc(
"CH1-", 100, dist * sinTheta, 0.0, dist * cosTheta,
114 thickness[iLayer], theta, -6., 0.030));
119 for (
unsigned int iLayer = 0; iLayer < 6; ++iLayer) {
121 CreateLayerDc(
"CH2+", 200, dist * sinTheta, 0.0, dist * cosTheta,
122 thickness[iLayer], theta, 6., 0.030));
125 for (
unsigned int iLayer = 6; iLayer < 12; ++iLayer) {
127 CreateLayerDc(
"CH2-", 200, dist * sinTheta, 0.0, dist * cosTheta,
128 thickness[iLayer], theta, -6., 0.030));
133 for (
unsigned int iLayer = 0; iLayer < 6; ++iLayer) {
135 CreateLayerDc(
"CH3+", 300, dist * sinTheta, 0.0, dist * cosTheta,
136 thickness[iLayer], theta, 6., 0.030));
139 for (
unsigned int iLayer = 6; iLayer < 12; ++iLayer) {
141 CreateLayerDc(
"CH3-", 300, dist * sinTheta, 0.0, dist * cosTheta,
142 thickness[iLayer], theta, -6., 0.030));
154 <<
"! MillePede-II: constraints for alignables with SINGLE 1D measurements"
156 for (
unsigned int iLayer = 0; iLayer < layers.size(); ++iLayer) {
158 unsigned int numMeas = 0;
159 for (
unsigned int jLayer = 0; jLayer < layers.size(); ++jLayer) {
160 if (layers[iLayer].getLayerID() == layers[jLayer].getLayerID())
165 layers[iLayer].printMP2Constraint();
167 std::cout <<
"! End of lines to be added to MillePede-II steering file"
169 std::cout << std::endl;
171 unsigned int nTry = 10000;
172 std::cout <<
" GblDc $Id$ " << nTry <<
", " << layers.size() << std::endl;
174 clock_t startTime = clock();
178 const double bfac = 0.;
187 for (
unsigned int iTry = 0; iTry < nTry; ++iTry) {
190 const double genDca = 0.1 *
unrm();
191 const double genZ0 = 0.1 *
unrm();
192 const double genPhi0 = 0.52 * (2. *
unif() - 1.);
193 const double genDzds = 10. *
unif() + 1.2;
194 const double genCurv = bfac * qbyp * sqrt(1. + genDzds * genDzds);
199 std::vector<Vector2d> hits;
200 double curv(genCurv), phi0(genPhi0), dca(genDca), dzds(genDzds), z0(
202 const double cosLambda = 1. / sqrt(1. + dzds * dzds);
203 for (
unsigned int iLayer = 0; iLayer < layers.size(); ++iLayer) {
211 Vector2d sigma = layers[iLayer].getResolution();
212 meas[0] += sigma[0] *
unrm();
213 meas[1] += sigma[1] *
unrm();
215 hits.push_back(meas);
218 double radlen = layers[iLayer].getRadiationLength()
222 hlx.
moveToXY(measPos[0], measPos[1], phi0, dca, z0);
223 phi0 +=
unrm() * errMs / cosLambda;
224 dzds +=
unrm() * errMs / (cosLambda * cosLambda);
227 newhlx.
moveToXY(-measPos[0], -measPos[1], phi0, dca, z0);
234 double seedCurv(genCurv), seedPhi0(genPhi0), seedDca(genDca), seedDzds(
235 genDzds), seedZ0(genZ0);
240 const double cosLambdaSeed = 1. / sqrt(1. + (seedDzds * seedDzds));
242 std::vector<GblPoint> listOfPoints;
243 for (
unsigned int iLayer = 0; iLayer < layers.size(); ++iLayer) {
252 Vector2d res(hits[iLayer][0] - measPrediction[0],
253 hits[iLayer][1] - measPrediction[1]);
259 Matrix2d proM2l = transG2l * transM2g.block<3, 2>(0, 0);
261 Matrix2d proL2m = proM2l.inverse();
264 (sArc - sOld) / cosLambdaSeed, cosLambdaSeed, bfac);
270 std::vector<int> labGlobal(6);
274 for (
int p = 0; p < 6; p++)
277 dir).block<2, 6>(0, 0);
284 Vector2d scat(0., 0.);
285 Vector2d scatPrec(1. / (errMs * errMs), 1. / (errMs * errMs));
289 listOfPoints.push_back(point);
297 unsigned int ierr = traj.
fit(Chi2, Ndf, lostWeight);
306 LostSum += lostWeight;
310 clock_t endTime = clock();
311 double diff = endTime - startTime;
312 double cps = CLOCKS_PER_SEC;
313 std::cout <<
" Time elapsed " << diff / cps <<
" s" << std::endl;
314 std::cout <<
" Chi2/Ndf = " << Chi2Sum / NdfSum << std::endl;
315 std::cout <<
" Tracks fitted " << numFit << std::endl;
317 std::cout <<
" Weight lost " << LostSum << std::endl;
336 double xPos,
double yPos,
double zPos,
double thickness,
double xzAngle,
337 double stereoAngle,
double uRes) {
338 Vector3d aCenter(xPos, yPos, zPos);
339 Vector2d aResolution(uRes, 0.);
340 Vector2d aPrecision(1. / (uRes * uRes), 0.);
342 const double cosXz = cos(xzAngle / 180. * M_PI);
343 const double sinXz = sin(xzAngle / 180. * M_PI);
344 const double cosSt = cos(stereoAngle / 180. * M_PI);
345 const double sinSt = sin(stereoAngle / 180. * M_PI);
346 measTrafo << cosSt * cosXz, sinSt, -cosSt * sinXz, -sinSt * cosXz, cosSt, sinSt
347 * sinXz, sinXz, 0., cosXz;
349 alignTrafo << cosXz, 0., -sinXz, 0., 1., 0., sinXz, 0., cosXz;
351 aPrecision, measTrafo, alignTrafo);
GblTrajectory definition.
unsigned int getRigidBodyGlobalLabel(const unsigned int aPar) const
Get global label.
GblHelixPrediction intersectWithHelix(GblSimpleHelix hlx) const
Intersect with helix.
double getRadiationLength() const
Get radiation length.
Eigen::Matrix3d getMeasSystemDirs() const
Get directions of measurement system.
Eigen::Matrix< double, 3, 6 > getRigidBodyDerGlobal(Eigen::Vector3d &position, Eigen::Vector3d &direction) const
Get rigid body derivatives in global frame.
Eigen::Vector2d getPrecision() const
Get precision.
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 addGlobals(const std::vector< int > &aLabels, const Eigen::MatrixBase< Derivative > &aDerivatives)
Add global derivatives to a point.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::Matrix2d &aPrecision)
Add a thin scatterer to a point.
void moveToXY(double xPos, double yPos, double &newPhi0, double &newDca, double &newZ0) const
Move to new reference point (X,Y)
void milleOut(MilleBinary &aMille)
Write valid trajectory to Millepede-II binary file.
unsigned int fit(double &Chi2, int &Ndf, double &lostWeight, const std::string &optionList="", unsigned int aLabel=0)
Perform fit of (valid) trajectory.
Millepede-II (binary) record.
void exampleDc()
Drift chamber example.
Definitions for exampleDc.
Namespace for the general broken lines package.
double unrm()
unit normal distribution, Box-Muller method, polar form
double gblMultipleScatteringError(double qbyp, double xbyx0)
Multiple scattering error.
GblDetectorLayer CreateLayerDc(const std::string aName, unsigned int layer, double xPos, double yPos, double zPos, double thickness, double xzAngle, double stereoAngle, double uRes)
Create a drift chamber layer with 1D measurement.
double unif()
uniform distribution [0..1]
Matrix5d gblSimpleJacobian(double ds, double cosl, double bfac)
Simple jacobian.
Eigen::Matrix< double, 5, 5 > Matrix5d