22 std::cout <<
" [LASBarrelAlgorithm::CalculateParameters] -- Starting." << std::endl;
40 minuit->mnexcm(
"SET PRI", arglist, 1, _ierflg);
44 minuit->mnexcm(
"SET ERR", arglist, 1, _ierflg);
51 static float _vstart[52] = {
52 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
53 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
54 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
55 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
56 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
57 0.00, 0.00, 0.0, 0.0, 0.0, 0.0,
58 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
59 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
67 static float _vstep[52] = {
68 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
69 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
70 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
71 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
72 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
73 0.001, 0.001, 0.1, 0.1, 0.1, 0.1,
74 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001,
75 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001
81 minuit->mnparm(0,
"subRot1TIB+", _vstart[0], _vstep[0], 0, 0, _ierflg);
83 minuit->mnparm(1,
"subRot2TIB+", _vstart[1], _vstep[1], 0, 0, _ierflg);
85 minuit->mnparm(2,
"subTransX1TIB+", _vstart[2], _vstep[2], 0, 0, _ierflg);
87 minuit->mnparm(3,
"subTransX2TIB+", _vstart[3], _vstep[3], 0, 0, _ierflg);
89 minuit->mnparm(4,
"subTransY1TIB+", _vstart[4], _vstep[4], 0, 0, _ierflg);
91 minuit->mnparm(5,
"subTransY2TIB+", _vstart[5], _vstep[5], 0, 0, _ierflg);
96 minuit->mnparm(6,
"subRot1TIB-", _vstart[6], _vstep[6], 0, 0, _ierflg);
98 minuit->mnparm(7,
"subRot2TIB-", _vstart[7], _vstep[7], 0, 0, _ierflg);
100 minuit->mnparm(8,
"subTransX1TIB-", _vstart[8], _vstep[8], 0, 0, _ierflg);
102 minuit->mnparm(9,
"subTransX2TIB-", _vstart[9], _vstep[9], 0, 0, _ierflg);
104 minuit->mnparm(10,
"subTransY1TIB-", _vstart[10], _vstep[10], 0, 0, _ierflg);
106 minuit->mnparm(11,
"subTransY2TIB-", _vstart[11], _vstep[11], 0, 0, _ierflg);
111 minuit->mnparm(12,
"subRot1TOB+", _vstart[12], _vstep[12], 0, 0, _ierflg);
113 minuit->mnparm(13,
"subRot2TOB+", _vstart[13], _vstep[13], 0, 0, _ierflg);
115 minuit->mnparm(14,
"subTransX1TOB+", _vstart[14], _vstep[14], 0, 0, _ierflg);
117 minuit->mnparm(15,
"subTransX2TOB+", _vstart[15], _vstep[15], 0, 0, _ierflg);
119 minuit->mnparm(16,
"subTransY1TOB+", _vstart[16], _vstep[16], 0, 0, _ierflg);
121 minuit->mnparm(17,
"subTransY2TOB+", _vstart[17], _vstep[17], 0, 0, _ierflg);
126 minuit->mnparm(18,
"subRot1TOB-", _vstart[18], _vstep[18], 0, 0, _ierflg);
128 minuit->mnparm(19,
"subRot2TOB-", _vstart[19], _vstep[19], 0, 0, _ierflg);
130 minuit->mnparm(20,
"subTransX1TOB-", _vstart[20], _vstep[20], 0, 0, _ierflg);
132 minuit->mnparm(21,
"subTransX2TOB-", _vstart[21], _vstep[21], 0, 0, _ierflg);
134 minuit->mnparm(22,
"subTransY1TOB-", _vstart[22], _vstep[22], 0, 0, _ierflg);
136 minuit->mnparm(23,
"subTransY2TOB-", _vstart[23], _vstep[23], 0, 0, _ierflg);
141 minuit->mnparm(24,
"subRot1TEC+", _vstart[24], _vstep[24], 0, 0, _ierflg);
143 minuit->mnparm(25,
"subRot2TEC+", _vstart[25], _vstep[25], 0, 0, _ierflg);
145 minuit->mnparm(26,
"subTransX1TEC+", _vstart[26], _vstep[26], 0, 0, _ierflg);
147 minuit->mnparm(27,
"subTransX2TEC+", _vstart[27], _vstep[27], 0, 0, _ierflg);
149 minuit->mnparm(28,
"subTransY1TEC+", _vstart[28], _vstep[28], 0, 0, _ierflg);
151 minuit->mnparm(29,
"subTransY2TEC+", _vstart[29], _vstep[29], 0, 0, _ierflg);
156 minuit->mnparm(30,
"subRot1TEC-", _vstart[30], _vstep[30], 0, 0, _ierflg);
158 minuit->mnparm(31,
"subRot2TEC-", _vstart[31], _vstep[31], 0, 0, _ierflg);
160 minuit->mnparm(32,
"subTransX1TEC-", _vstart[32], _vstep[32], 0, 0, _ierflg);
162 minuit->mnparm(33,
"subTransX2TEC-", _vstart[33], _vstep[33], 0, 0, _ierflg);
164 minuit->mnparm(34,
"subTransY1TEC-", _vstart[34], _vstep[34], 0, 0, _ierflg);
166 minuit->mnparm(35,
"subTransY2TEC-", _vstart[35], _vstep[35], 0, 0, _ierflg);
171 minuit->mnparm(36,
"beamRot1Beam0", _vstart[36], _vstep[36], 0, 0, _ierflg);
173 minuit->mnparm(37,
"beamRot2Beam0", _vstart[37], _vstep[37], 0, 0, _ierflg);
176 minuit->mnparm(38,
"beamRot1Beam1", _vstart[38], _vstep[38], 0, 0, _ierflg);
178 minuit->mnparm(39,
"beamRot2Beam1", _vstart[39], _vstep[39], 0, 0, _ierflg);
181 minuit->mnparm(40,
"beamRot1Beam2", _vstart[40], _vstep[40], 0, 0, _ierflg);
183 minuit->mnparm(41,
"beamRot2Beam2", _vstart[41], _vstep[41], 0, 0, _ierflg);
186 minuit->mnparm(42,
"beamRot1Beam3", _vstart[42], _vstep[42], 0, 0, _ierflg);
188 minuit->mnparm(43,
"beamRot2Beam3", _vstart[43], _vstep[43], 0, 0, _ierflg);
191 minuit->mnparm(44,
"beamRot1Beam4", _vstart[44], _vstep[44], 0, 0, _ierflg);
193 minuit->mnparm(45,
"beamRot2Beam4", _vstart[45], _vstep[45], 0, 0, _ierflg);
196 minuit->mnparm(46,
"beamRot1Beam5", _vstart[46], _vstep[46], 0, 0, _ierflg);
198 minuit->mnparm(47,
"beamRot2Beam5", _vstart[47], _vstep[47], 0, 0, _ierflg);
201 minuit->mnparm(48,
"beamRot1Beam6", _vstart[48], _vstep[48], 0, 0, _ierflg);
203 minuit->mnparm(49,
"beamRot2Beam6", _vstart[49], _vstep[49], 0, 0, _ierflg);
206 minuit->mnparm(50,
"beamRot1Beam7", _vstart[50], _vstep[50], 0, 0, _ierflg);
208 minuit->mnparm(51,
"beamRot2Beam7", _vstart[51], _vstep[51], 0, 0, _ierflg);
225 for (
int par = 37; par <= 52; ++par)
226 parlist[par - 37] = par;
227 minuit->mnexcm(
"FIX", parlist, 16, _ierflg);
240 minuit->mnexcm(
"MIGRAD", arglist, 2, _ierflg);
246 double par = 0., parError = 0.;
249 minuit->GetParameter(24, par, parError);
252 minuit->GetParameter(25, par, parError);
256 minuit->GetParameter(26, par, parError);
259 minuit->GetParameter(27, par, parError);
263 minuit->GetParameter(28, par, parError);
266 minuit->GetParameter(29, par, parError);
271 minuit->GetParameter(30, par, parError);
274 minuit->GetParameter(31, par, parError);
278 minuit->GetParameter(32, par, parError);
281 minuit->GetParameter(33, par, parError);
285 minuit->GetParameter(34, par, parError);
288 minuit->GetParameter(35, par, parError);
293 minuit->GetParameter(0, par, parError);
296 minuit->GetParameter(1, par, parError);
300 minuit->GetParameter(2, par, parError);
303 minuit->GetParameter(3, par, parError);
307 minuit->GetParameter(4, par, parError);
310 minuit->GetParameter(5, par, parError);
315 minuit->GetParameter(6, par, parError);
318 minuit->GetParameter(7, par, parError);
322 minuit->GetParameter(8, par, parError);
325 minuit->GetParameter(9, par, parError);
329 minuit->GetParameter(10, par, parError);
332 minuit->GetParameter(11, par, parError);
337 minuit->GetParameter(12, par, parError);
340 minuit->GetParameter(13, par, parError);
344 minuit->GetParameter(14, par, parError);
347 minuit->GetParameter(15, par, parError);
351 minuit->GetParameter(16, par, parError);
354 minuit->GetParameter(17, par, parError);
359 minuit->GetParameter(18, par, parError);
362 minuit->GetParameter(19, par, parError);
366 minuit->GetParameter(20, par, parError);
369 minuit->GetParameter(21, par, parError);
373 minuit->GetParameter(22, par, parError);
376 minuit->GetParameter(23, par, parError);
380 std::cout <<
" [LASBarrelAlgorithm::CalculateParameters] -- Done." << std::endl;
388 void fcn(
int& npar,
double* gin,
double&
f,
double* par,
int iflag) {
389 double chisquare = 0.;
401 std::vector<std::vector<std::vector<double> > > endFaceZPositions(
402 4,
std::vector<std::vector<double> >(2, std::vector<double>(2, 0.)));
403 endFaceZPositions.at(0).at(0).at(0) = 1322.5;
404 endFaceZPositions.at(0).at(0).at(1) = 2667.5;
405 endFaceZPositions.at(1).at(0).at(0) = -2667;
406 endFaceZPositions.at(1).at(0).at(1) = -1322.5;
407 endFaceZPositions.at(2).at(1).at(0) = -700.;
408 endFaceZPositions.at(2).at(1).at(1) = -300.;
409 endFaceZPositions.at(2).at(0).at(0) = 300.;
410 endFaceZPositions.at(2).at(0).at(1) = 700.;
411 endFaceZPositions.at(3).at(1).at(0) = -1090.;
412 endFaceZPositions.at(3).at(1).at(1) = -300.;
413 endFaceZPositions.at(3).at(0).at(0) = 300.;
414 endFaceZPositions.at(3).at(0).at(1) = 1090.;
417 std::vector<double> disk9EndFaceZPositions(2, 0.);
418 disk9EndFaceZPositions.at(0) = -2667.5;
419 disk9EndFaceZPositions.at(1) = 2667.5;
422 double detReducedZ[2] = {0., 0.};
424 double beamReducedZ[2] = {0., 0.};
432 const int theSide =
pos < 3 ? 0 : 1;
436 const double radialOffset = det == 2 ? 50. : 36.;
441 detReducedZ[0] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
444 detReducedZ[1] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
449 beamReducedZ[0] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
452 beamReducedZ[1] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
464 double calculatedResidual = 0.;
486 calculatedResidual += detReducedZ[1] * par[indexBase + 0];
489 calculatedResidual += detReducedZ[0] * par[indexBase + 1];
492 calculatedResidual += detReducedZ[1] *
sin(currentPhi) / currentR * par[indexBase + 2];
495 calculatedResidual += detReducedZ[0] *
sin(currentPhi) / currentR * par[indexBase + 3];
498 calculatedResidual += -1. * detReducedZ[1] *
cos(currentPhi) / currentR * par[indexBase + 4];
501 calculatedResidual += -1. * detReducedZ[0] *
cos(currentPhi) / currentR * par[indexBase + 5];
504 indexBase = 36 +
beam * 2;
509 calculatedResidual += beamReducedZ[1] * par[indexBase];
512 calculatedResidual += beamReducedZ[0] * par[indexBase + 1];
515 chisquare +=
pow(measuredResidual - calculatedResidual, 2) /
526 const int theSide = 0;
531 detReducedZ[0] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
534 detReducedZ[1] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
538 beamReducedZ[0] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
540 beamReducedZ[1] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
552 double calculatedResidual = 0.;
560 calculatedResidual += detReducedZ[1] * (det == 0 ? par[24] : par[30]);
563 calculatedResidual += detReducedZ[0] * (det == 0 ? par[25] : par[31]);
566 calculatedResidual += detReducedZ[1] *
sin(currentPhi) * (det == 0 ? par[26] : par[32]) / currentR;
569 calculatedResidual += detReducedZ[0] *
sin(currentPhi) * (det == 0 ? par[27] : par[33]) / currentR;
572 calculatedResidual += -1. * detReducedZ[1] *
cos(currentPhi) * (det == 0 ? par[28] : par[34]) / currentR;
575 calculatedResidual += -1. * detReducedZ[0] *
cos(currentPhi) * (det == 0 ? par[29] : par[35]) / currentR;
578 const unsigned int indexBase = 36 +
beam * 2;
583 calculatedResidual += beamReducedZ[1] * par[indexBase];
586 calculatedResidual += beamReducedZ[0] * par[indexBase + 1];
590 chisquare +=
pow(measuredResidual - calculatedResidual, 2) /
605 std::cerr <<
" [LASBarrelAlgorithm::Dump] ** WARNING: minimizer object uninitialized." << std::endl;
609 std::cout << std::endl <<
" [LASBarrelAlgorithm::Dump] -- Parameter dump: " << std::endl;
611 const int subdetParMap[6] = {24, 30, 0, 6, 12, 18};
615 std::cout <<
" Detector parameters: " << std::endl;
616 std::cout <<
" -------------------" << std::endl;
617 std::cout <<
" Values: PHI1 X1 Y1 PHI2 X2 Y2 " << std::endl;
618 for (
int subdet = 0; subdet < 6; ++subdet) {
620 for (
int par = subdetParMap[subdet]; par <= subdetParMap[subdet] + 4; par += 2) {
624 for (
int par = subdetParMap[subdet] + 1; par <= subdetParMap[subdet] + 5; par += 2) {
631 std::cout <<
" Errors: PHI1 X1 Y1 PHI2 X2 Y2 " << std::endl;
632 for (
int subdet = 0; subdet < 6; ++subdet) {
634 for (
int par = subdetParMap[subdet]; par <= subdetParMap[subdet] + 4; par += 2) {
638 for (
int par = subdetParMap[subdet] + 1; par <= subdetParMap[subdet] + 5; par += 2) {
646 std::cout <<
" Beam parameters: " << std::endl;
647 std::cout <<
" ---------------" << std::endl;
648 std::cout <<
" Values: PHI1 PHI2" << std::endl;
651 for (
int z = 0;
z < 2; ++
z) {
658 std::cout <<
" Errors: PHI1 PHI2" << std::endl;
661 for (
int z = 0;
z < 2; ++
z) {
669 std::ofstream
file(
"/afs/cern.ch/user/o/olzem/public/parameters_det.txt");
670 for (
int subdet = 0; subdet < 6; ++subdet) {
671 for (
int par = subdetParMap[subdet]; par <= subdetParMap[subdet] + 4; par += 2) {
675 for (
int par = subdetParMap[subdet] + 1; par <= subdetParMap[subdet] + 5; par += 2) {
684 file.open(
"/afs/cern.ch/user/o/olzem/public/parameters_beam.txt");
686 for (
int z = 0;
z < 2; ++
z) {
694 std::cout <<
" [LASBarrelAlgorithm::Dump] -- End parameter dump." << std::endl;
712 std::cerr <<
" [LASBarrelAlgorithm::ReadMisalignmentFromFile] ** ERROR: cannot open file \"" <<
filename <<
"\"." 718 <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 721 <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 724 <<
" [LASBarrelAlgorithm::ReadMisalignmentFromFile] ** WARNING: you are reading a fake measurement from a file!" 727 <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 730 <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 735 measuredCoordinates = nominalCoordinates;
769 while (!
file.eof()) {
808 std::cerr <<
" [LASBarrelAlgorithm::ReadStartParametersFromFile] ** ERROR: cannot open file \"" <<
filename <<
"\"." 813 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 816 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 819 std::cerr <<
" [LASBarrelAlgorithm::ReadStartParametersFrom File] ** WARNING: you are reading parameter start values " 822 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 825 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" 830 const int subdetParMap[6] = {24, 30, 0, 6, 12, 18};
832 for (
int det = 0; det < 6; ++det) {
std::pair< double, double > & GetParameter(int aSubdetector, int aDisk, int aParameter)
void SetPhiError(double aPhiError)
void fcn(int &npar, double *gin, double &f, double *par, int iflag)
Sin< T >::type sin(const T &t)
bool TEC2TECLoop(int &, int &, int &) const
double GetPhiError(void) const
LASGlobalData< LASCoordinateSet > * aMeasuredCoordinates
void ReadMisalignmentFromFile(const char *, LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
LASGlobalData< LASCoordinateSet > * aNominalCoordinates
bool TECLoop(int &, int &, int &, int &) const
LASBarrelAlignmentParameterSet CalculateParameters(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
Cos< T >::type cos(const T &t)
void ReadStartParametersFromFile(const char *, float[52])
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
bool TIBTOBLoop(int &, int &, int &) const
double GetPhi(void) const
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
static const char * subdetNames[]