CMS 3D CMS Logo

Functions | Variables
LASBarrelAlgorithm.cc File Reference
#include "Alignment/LaserAlignment/interface/LASBarrelAlgorithm.h"

Go to the source code of this file.

Functions

void fcn (int &npar, double *gin, double &f, double *par, int iflag)
 

Variables

LASGlobalData< LASCoordinateSet > * aMeasuredCoordinates
 
LASGlobalData< LASCoordinateSet > * aNominalCoordinates
 

Function Documentation

◆ fcn()

void fcn ( int &  npar,
double *  gin,
double &  f,
double *  par,
int  iflag 
)

minuit chisquare func

Definition at line 388 of file LASBarrelAlgorithm.cc.

388  {
389  double chisquare = 0.;
390 
391  // the loop object and its variables
392  LASGlobalLoop moduleLoop;
393  int det, beam, pos, disk;
394 
396  // ADJUST THIS ALSO IN LASGeometryUpdater
398 
399  // the z positions of the halfbarrel_end_faces / outer_TEC_disks (in mm);
400  // parameters are: det, side(0=+/1=-), z(lower/upper). TECs have no side (use side = 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; // TEC+, *, disk1 ///
404  endFaceZPositions.at(0).at(0).at(1) = 2667.5; // TEC+, *, disk9 /// SIDE INFORMATION
405  endFaceZPositions.at(1).at(0).at(0) = -2667; // TEC-, *, disk1 /// MEANINGLESS FOR TEC -> USE .at(0)!
406  endFaceZPositions.at(1).at(0).at(1) = -1322.5; // TEC-, *, disk9 ///
407  endFaceZPositions.at(2).at(1).at(0) = -700.; // TIB, -, small z
408  endFaceZPositions.at(2).at(1).at(1) = -300.; // TIB, -, large z
409  endFaceZPositions.at(2).at(0).at(0) = 300.; // TIB, +, small z
410  endFaceZPositions.at(2).at(0).at(1) = 700.; // TIB, +, large z
411  endFaceZPositions.at(3).at(1).at(0) = -1090.; // TOB, -, small z
412  endFaceZPositions.at(3).at(1).at(1) = -300.; // TOB, -, large z
413  endFaceZPositions.at(3).at(0).at(0) = 300.; // TOB, +, small z
414  endFaceZPositions.at(3).at(0).at(1) = 1090.; // TOB, +, large z
415 
416  // the z positions of the virtual planes at which the beam parameters are measured
417  std::vector<double> disk9EndFaceZPositions(2, 0.);
418  disk9EndFaceZPositions.at(0) = -2667.5; // TEC- disk9
419  disk9EndFaceZPositions.at(1) = 2667.5; // TEC+ disk9
420 
421  // reduced z positions of the beam spots ( z'_{k,j}, z"_{k,j} )
422  double detReducedZ[2] = {0., 0.};
423  // reduced beam splitter positions ( zt'_{k,j}, zt"_{k,j} )
424  double beamReducedZ[2] = {0., 0.};
425 
426  // calculate residual for TIBTOB
427  det = 2;
428  beam = 0;
429  pos = 0;
430  do {
431  // define the side: 0 for TIB+/TOB+ and 1 for TIB-/TOB-
432  const int theSide = pos < 3 ? 0 : 1;
433 
434  // this is the path the beam has to travel radially after being reflected
435  // by the AT mirrors (TIB:50mm, TOB:36mm) -> used for beam parameters
436  const double radialOffset = det == 2 ? 50. : 36.;
437 
438  // reduced module's z position with respect to the subdetector endfaces
439  detReducedZ[0] =
440  aMeasuredCoordinates->GetTIBTOBEntry(det, beam, pos).GetZ() - endFaceZPositions.at(det).at(theSide).at(0);
441  detReducedZ[0] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
442  detReducedZ[1] =
443  endFaceZPositions.at(det).at(theSide).at(1) - aMeasuredCoordinates->GetTIBTOBEntry(det, beam, pos).GetZ();
444  detReducedZ[1] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
445 
446  // reduced module's z position with respect to the tec disks +-9 (for the beam parameters)
447  beamReducedZ[0] =
448  (aMeasuredCoordinates->GetTIBTOBEntry(det, beam, pos).GetZ() - radialOffset) - disk9EndFaceZPositions.at(0);
449  beamReducedZ[0] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
450  beamReducedZ[1] =
451  disk9EndFaceZPositions.at(1) - (aMeasuredCoordinates->GetTIBTOBEntry(det, beam, pos).GetZ() - radialOffset);
452  beamReducedZ[1] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
453 
454  // phi residual for this module as measured
455  const double measuredResidual = aMeasuredCoordinates->GetTIBTOBEntry(det, beam, pos).GetPhi() - //&
457 
458  // shortcuts for speed
459  const double currentPhi = aNominalCoordinates->GetTIBTOBEntry(det, beam, pos).GetPhi();
460  const double currentR = aNominalCoordinates->GetTIBTOBEntry(det, beam, pos).GetR();
461 
462  // phi residual for this module calculated from the parameters and nominal coordinates:
463  // this is the sum over the contributions from all parameters
464  double calculatedResidual = 0.;
465 
466  // note that the contributions ym_{i,j,k} given in the tables in TkLasATModel TWiki
467  // are defined as R*phi, so here they are divided by the R_j factors (we minimize delta phi)
468 
469  // unfortunately, minuit keeps parameters in a 1-dim array,
470  // so we need to address the correct par[] for the 4 cases TIB+/TIB-/TOB+/TOB-
471  int indexBase = 0;
472  if (det == 2) { // TIB
473  if (theSide == 0)
474  indexBase = 0; // TIB+
475  if (theSide == 1)
476  indexBase = 6; // TIB-
477  }
478  if (det == 3) { // TOB
479  if (theSide == 0)
480  indexBase = 12; // TOB+
481  if (theSide == 1)
482  indexBase = 18; // TOB-
483  }
484 
485  // par[0] ("subRot1"): rotation around z of first end face
486  calculatedResidual += detReducedZ[1] * par[indexBase + 0];
487 
488  // par[1] ("subRot2"): rotation around z of second end face
489  calculatedResidual += detReducedZ[0] * par[indexBase + 1];
490 
491  // par[2] ("subTransX1"): translation along x of first end face
492  calculatedResidual += detReducedZ[1] * sin(currentPhi) / currentR * par[indexBase + 2];
493 
494  // par[3] ("subTransX2"): translation along x of second end face
495  calculatedResidual += detReducedZ[0] * sin(currentPhi) / currentR * par[indexBase + 3];
496 
497  // par[4] ("subTransY1"): translation along y of first end face
498  calculatedResidual += -1. * detReducedZ[1] * cos(currentPhi) / currentR * par[indexBase + 4];
499 
500  // par[5] ("subTransY2"): translation along y of second end face
501  calculatedResidual += -1. * detReducedZ[0] * cos(currentPhi) / currentR * par[indexBase + 5];
502 
503  // now come the 8*2 beam parameters, calculate the respective parameter index base first (-> which beam)
504  indexBase = 36 + beam * 2;
505 
506  // (there's no TIB/TOB/+/- distinction here for the beams)
507 
508  // ("beamRot1"): rotation around z at zt1
509  calculatedResidual += beamReducedZ[1] * par[indexBase];
510 
511  // ("beamRot2"): rotation around z at zt2
512  calculatedResidual += beamReducedZ[0] * par[indexBase + 1];
513 
514  // now calculate the chisquare
515  chisquare += pow(measuredResidual - calculatedResidual, 2) /
517 
518  } while (moduleLoop.TIBTOBLoop(det, beam, pos));
519 
520  // calculate residual for TEC AT
521  det = 0;
522  beam = 0;
523  disk = 0;
524  do {
525  // define the side: TECs sides already disentangled by the "det" index, so fix this to zero
526  const int theSide = 0;
527 
528  // reduced module's z position with respect to the subdetector endfaces
529  detReducedZ[0] =
530  aMeasuredCoordinates->GetTEC2TECEntry(det, beam, disk).GetZ() - endFaceZPositions.at(det).at(theSide).at(0);
531  detReducedZ[0] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
532  detReducedZ[1] =
533  endFaceZPositions.at(det).at(theSide).at(1) - aMeasuredCoordinates->GetTEC2TECEntry(det, beam, disk).GetZ();
534  detReducedZ[1] /= (endFaceZPositions.at(det).at(theSide).at(1) - endFaceZPositions.at(det).at(theSide).at(0));
535 
536  // reduced module's z position with respect to the tec disks +-9 (for the beam parameters)
537  beamReducedZ[0] = aMeasuredCoordinates->GetTEC2TECEntry(det, beam, disk).GetZ() - disk9EndFaceZPositions.at(0);
538  beamReducedZ[0] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
539  beamReducedZ[1] = disk9EndFaceZPositions.at(1) - aMeasuredCoordinates->GetTEC2TECEntry(det, beam, disk).GetZ();
540  beamReducedZ[1] /= (disk9EndFaceZPositions.at(1) - disk9EndFaceZPositions.at(0));
541 
542  // phi residual for this module as measured
543  const double measuredResidual = aMeasuredCoordinates->GetTEC2TECEntry(det, beam, disk).GetPhi() - //&
545 
546  // shortcuts for speed
547  const double currentPhi = aNominalCoordinates->GetTEC2TECEntry(det, beam, disk).GetPhi();
548  const double currentR = aNominalCoordinates->GetTEC2TECEntry(det, beam, disk).GetR();
549 
550  // phi residual for this module calculated from the parameters and nominal coordinates:
551  // this is the sum over the contributions from all parameters
552  double calculatedResidual = 0.;
553 
554  // note that the contributions ym_{i,j,k} given in the tables in TkLasATModel TWiki
555  // are defined as R*phi, so here they are divided by the R_j factors (we minimize delta phi)
556 
557  // there's also a distinction between TEC+/- parameters in situ (det==0 ? <TEC+> : <TEC->)
558 
559  // par[0] ("subRot1"): rotation around z of first end face
560  calculatedResidual += detReducedZ[1] * (det == 0 ? par[24] : par[30]);
561 
562  // par[1] ("subRot2"): rotation around z of second end face
563  calculatedResidual += detReducedZ[0] * (det == 0 ? par[25] : par[31]);
564 
565  // par[2] ("subTransX1"): translation along x of first end face
566  calculatedResidual += detReducedZ[1] * sin(currentPhi) * (det == 0 ? par[26] : par[32]) / currentR;
567 
568  // par[3] ("subTransX2"): translation along x of second end face
569  calculatedResidual += detReducedZ[0] * sin(currentPhi) * (det == 0 ? par[27] : par[33]) / currentR;
570 
571  // par[4] ("subTransY1"): translation along y of first end face
572  calculatedResidual += -1. * detReducedZ[1] * cos(currentPhi) * (det == 0 ? par[28] : par[34]) / currentR;
573 
574  // par[5] ("subTransY2"): translation along y of second end face
575  calculatedResidual += -1. * detReducedZ[0] * cos(currentPhi) * (det == 0 ? par[29] : par[35]) / currentR;
576 
577  // now come the 8*2 beam parameters; calculate the respective parameter index base first (-> which beam)
578  const unsigned int indexBase = 36 + beam * 2;
579 
580  // there's no TEC+/- distinction here
581 
582  // par[6] ("beamRot1"): rotation around z at zt1
583  calculatedResidual += beamReducedZ[1] * par[indexBase];
584 
585  // par[7] ("beamRot2"): rotation around z at zt2
586  calculatedResidual += beamReducedZ[0] * par[indexBase + 1];
587 
588  // now calculate the chisquare
589  // TODO: check for phi != 0 !!!
590  chisquare += pow(measuredResidual - calculatedResidual, 2) /
592 
593  } while (moduleLoop.TEC2TECLoop(det, beam, disk));
594 
595  // return the chisquare by ref
596  f = chisquare;
597 }

References aMeasuredCoordinates, aNominalCoordinates, EcalCondDBWriter_cfi::beam, funct::cos(), f, LASCoordinateSet::GetPhi(), LASCoordinateSet::GetPhiError(), LASCoordinateSet::GetR(), LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), LASCoordinateSet::GetZ(), funct::pow(), funct::sin(), LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TIBTOBLoop(), and trackerHitRTTI::vector.

Referenced by CTPPSCompositeESSource::buildOptics(), LASBarrelAlgorithm::CalculateParameters(), MuonResidualsFitter::dofit(), fftjetcms::fftjet_JetFunctor_parser(), fftjetcms::fftjet_PeakFunctor_parser(), npstat::ArrayND< Num1, Len1, Dim1 >::jointSliceLoop(), npstat::MultivariateFunctorScanner< IndexMapper >::MultivariateFunctorScanner(), CTPPSOpticalFunctionsESSource::produce(), npstat::ArrayND< Num1, Len1, Dim1 >::projectLoop(), npstat::ArrayND< Num1, Len1, Dim1 >::projectLoop2(), PVFitter::runBXFitter(), and PVFitter::runFitter().

Variable Documentation

◆ aMeasuredCoordinates

LASGlobalData<LASCoordinateSet>* aMeasuredCoordinates

Definition at line 7 of file LASBarrelAlgorithm.cc.

Referenced by LASBarrelAlgorithm::CalculateParameters(), and fcn().

◆ aNominalCoordinates

LASGlobalData<LASCoordinateSet>* aNominalCoordinates
LASGlobalLoop::TIBTOBLoop
bool TIBTOBLoop(int &, int &, int &) const
Definition: LASGlobalLoop.cc:46
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
pos
Definition: PixelAliasList.h:18
LASCoordinateSet::GetZ
double GetZ(void) const
Definition: LASCoordinateSet.h:22
LASGlobalLoop
Definition: LASGlobalLoop.h:24
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
aNominalCoordinates
LASGlobalData< LASCoordinateSet > * aNominalCoordinates
Definition: LASBarrelAlgorithm.cc:8
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
EcalCondDBWriter_cfi.beam
beam
Definition: EcalCondDBWriter_cfi.py:45
aMeasuredCoordinates
LASGlobalData< LASCoordinateSet > * aMeasuredCoordinates
Definition: LASBarrelAlgorithm.cc:7
LASCoordinateSet::GetPhiError
double GetPhiError(void) const
Definition: LASCoordinateSet.h:19
LASGlobalData::GetTIBTOBEntry
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
Definition: LASGlobalData.h:107
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
LASGlobalLoop::TEC2TECLoop
bool TEC2TECLoop(int &, int &, int &) const
Definition: LASGlobalLoop.cc:74
LASGlobalData::GetTEC2TECEntry
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
Definition: LASGlobalData.h:129
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
LASCoordinateSet::GetPhi
double GetPhi(void) const
Definition: LASCoordinateSet.h:18
LASCoordinateSet::GetR
double GetR(void) const
Definition: LASCoordinateSet.h:20