78 const unsigned int nSuper = 9;
79 double nLayer[nSuper] = { 8, 6, 6, 6, 6, 6, 6, 6, 6 };
80 double rInner[nSuper] = { 16.80, 25.70, 36.52, 47.69, 58.41, 69.53, 80.25,
82 double rOuter[nSuper] = { 23.80, 34.80, 45.57, 56.69, 67.41, 78.53, 89.25,
84 double stereo[nSuper] = { 0., 0.068, 0., -0.060, 0., 0.064, 0., -0.072, 0. };
85 double zStart[nSuper] = { -35.9, -51.4, -57.5, -59.6, -61.8, -63.9, -66.0,
87 double zEnd[nSuper] = { 67.9, 98.6, 132.9, 144.7, 146.8, 148.9, 151.0,
90 unsigned int nTry = 1000;
91 std::cout <<
" GblComposedGeo $Id$ " << nTry <<
", " << nSuper << std::endl;
93 clock_t startTime = clock();
95 const double bfac = 0.0045;
97 double beamPos[] = { 0., 0., 0. };
98 double beamSize[] = { 0.005, 0.005, 0.3 };
99 const bool useBeamSpot =
true;
107 unsigned int iEvent = 0;
110 for (
unsigned int iTry = 0; iTry < nTry; ++iTry) {
112 std::vector<std::array<double, 6>> allGenPar;
116 std::array<double, 3> vtx = { beamPos[0] + beamSize[0] *
unrm(),
117 beamPos[1] + beamSize[1] *
unrm(), beamPos[2]
118 + beamSize[2] *
unrm() };
119 std::cout <<
" gen(vertex) " << iEvent <<
": " << vtx[0] <<
" "
120 << vtx[1] <<
" " << vtx[2] <<
" " << std::endl;
123 for (
unsigned int iTrack = 0; iTrack < nTrack; ++iTrack) {
126 const double qbyp = 0.2;
127 const double genPhi0 = M_PI * (2. *
unif() - 1.);
128 const double genDzds = (2. *
unif() - 1.);
129 const double genCurv = bfac * qbyp * sqrt(1. + genDzds * genDzds);
131 const double genDca = sin(genPhi0) * vtx[0] - cos(genPhi0) * vtx[1];
132 const double genZ0 = vtx[2];
134 std::cout <<
" gen(inline) " << iEvent <<
": " << genCurv <<
" "
135 << genPhi0 <<
" " << genDca <<
" " << genDzds <<
" "
136 << genZ0 << std::endl;
137 std::array<double, 6> par = { genCurv, genPhi0, genDca, genDzds,
139 allGenPar.push_back(par);
142 std::vector<std::vector<GblPoint>> listsOfPoints;
143 std::vector<Matrix<double, 2, 3>> listOfTrafos;
144 for (
unsigned int iTrack = 0; iTrack < nTrack; ++iTrack) {
148 std::array<double, 6> genPar = allGenPar[iTrack];
149 double curv(genPar[0]), phi0(genPar[1]), dca(genPar[2]), dzds(
150 genPar[3]), z0(genPar[4]);
154 std::vector<GblDetectorLayer> layers;
161 beamPos[2], phi0 + sArc * curv, dzds, beamSize[0],
162 beamSize[1], beamSize[2]));
164 unsigned int cLayer = 0;
165 for (
unsigned int iSuper = 0; iSuper < nSuper; ++iSuper) {
166 double radius = rInner[iSuper];
167 double step = (rOuter[iSuper] - radius) / (nLayer[iSuper] - 1);
169 for (
unsigned int iLayer = 0; iLayer < nLayer[iSuper];
172 if (fabs(dca) < radius) {
178 double phiPos = hlx.
getPhi(radius);
180 double xPos(cos(phiPos) * radius), yPos(
181 sin(phiPos) * radius), zPos(z0 + sArc * dzds);
183 if (zPos > zStart[iSuper] and zPos < zEnd[iSuper])
186 zPos, phi0 + sArc * curv, dzds,
187 stereo[iSuper], 0.015));
199 std::array<double, 6> seedPar = allGenPar[iTrack];
204 double seedCurv(seedPar[0]), seedPhi0(seedPar[1]), seedDca(
205 seedPar[2]), seedDzds(seedPar[3]), seedZ0(seedPar[4]);
210 const double cosLambdaSeed = 1. / sqrt(1. + (seedDzds * seedDzds));
212 const double qbyp = seedCurv / bfac * cosLambdaSeed;
215 Matrix<double, 2, 3> innerTrafo = Matrix<double, 2, 3>::Zero();
217 innerTrafo(0, 0) = -sin(seedPhi0);
218 innerTrafo(0, 1) = cos(seedPhi0);
219 innerTrafo(1, 0) = -cos(seedPhi0) * cosLambdaSeed * seedDzds;
220 innerTrafo(1, 1) = -sin(seedPhi0) * cosLambdaSeed * seedDzds;
221 innerTrafo(1, 2) = cosLambdaSeed;
223 listOfTrafos.push_back(innerTrafo);
226 std::vector<GblPoint> listOfPoints;
227 for (
unsigned int iLayer = 0; iLayer < layers.size(); ++iLayer) {
237 Vector2d res = measPrediction;
241 res[0] += sigma[0] *
unrm();
243 std::cout <<
" impact par " << res[0] <<
" " << res[1]
244 <<
" " << seedCurv <<
" " << seedPhi0 <<
" "
245 << seedDca <<
" " << seedDzds <<
" " << seedZ0
246 <<
" " << sArc <<
" " << layers.size() << std::endl;
252 Matrix2d proM2l = transG2l * transM2g.block<3, 2>(0, 0);
254 Matrix2d proL2m = proM2l.inverse();
257 (sArc - sOld) / cosLambdaSeed, cosLambdaSeed, bfac);
261 if (lid > 0 or (iTrack == 0 and useBeamSpot))
266 std::vector<int> labGlobal(6);
277 for (
int p = 0; p < 6; p++)
278 labGlobal[p] = layerID * 1000 + p + 1;
279 Matrix<double, 2, 6> derGlobal =
288 Vector2d scat(0., 0.);
289 Vector2d scatPrec(1. / (errMs * errMs),
290 1. / (errMs * errMs));
295 listOfPoints.push_back(point);
297 listsOfPoints.push_back(listOfPoints);
301 unsigned int nAccepted = 0;
302 for (
unsigned int iTrack = 0; iTrack < nTrack; ++iTrack)
304 if (listsOfPoints[iTrack].size() >= 10)
310 std::vector<std::pair<std::vector<GblPoint>, MatrixXd> > aPointsAndTransList;
311 for (
unsigned int iTrack = 0; iTrack < nTrack; ++iTrack) {
312 aPointsAndTransList.push_back(
313 make_pair(listsOfPoints[iTrack], listOfTrafos[iTrack]));
326 unsigned int ierr = traj.
fit(Chi2, Ndf, lostWeight);
327 std::cout <<
" Fit " << iTry <<
": " << Chi2 <<
", " << Ndf <<
", "
328 << lostWeight << std::endl;
338 LostSum += lostWeight;
351 clock_t endTime = clock();
352 double diff = endTime - startTime;
353 double cps = CLOCKS_PER_SEC;
354 std::cout <<
" Time elapsed " << diff / cps <<
" s" << std::endl;
355 std::cout <<
" Chi2/Ndf = " << Chi2Sum / NdfSum << std::endl;
356 std::cout <<
" Tracks fitted " << numFit << std::endl;
358 std::cout <<
" Weight lost " << LostSum << std::endl;
GblTrajectory definition.
GblHelixPrediction intersectWithHelix(GblSimpleHelix hlx) const
Intersect with helix.
double getRadiationLength() const
Get radiation length.
unsigned int getLayerID() const
Get layer ID.
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 getResolution() const
Get resolution.
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.
double getArcLengthR(double aRadius) const
Get (2D) arc length for given radius (to ref. point)
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 printTrajectory(unsigned int level=0) const
Print GblTrajectory.
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 exampleComposedGeo()
Drift chamber example.
Definitions for exampleUtil(ities) for a Cylindrical Drift Chamber.
Namespace for the general broken lines package.
GblDetectorLayer CreateWireCdc(const std::string aName, unsigned int layer, double xPos, double yPos, double zPos, double phi, double tanLambda, double stereoAngle, double uRes)
Create a drift chamber wire with 1D measurement.
double unrm()
unit normal distribution, Box-Muller method, polar form
double gblMultipleScatteringError(double qbyp, double xbyx0)
Multiple scattering error.
GblDetectorLayer CreateImpactPar(const std::string aName, unsigned int layer, double xPos, double yPos, double zPos, double phi, double tanLambda, double xRes, double yRes, double zRes)
Create detector plane for impact parameters as 2D measurement.
double unif()
uniform distribution [0..1]
Matrix5d gblSimpleJacobian(double ds, double cosl, double bfac)
Simple jacobian.
Eigen::Matrix< double, 5, 5 > Matrix5d