65 #include <TMatrixDSymEigen.h>
85 theConfig(cfg), theMode(this->decodeMode(theConfig.getUntrackedParameter<std::
string>(
"mode"))),
86 theDir(theConfig.getUntrackedParameter<std::
string>(
"fileDir")),
87 theAlignmentParameterStore(0), theAlignables(), theAlignableNavigator(0),
88 theMonitor(0), theMille(0), thePedeLabels(0), thePedeSteer(0),
89 theTrajectoryFactory(0),
90 theMinNumHits(cfg.getParameter<unsigned int>(
"minNumHits")),
91 theMaximalCor2D(cfg.getParameter<double>(
"max2Dcorrelation")),
95 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm" <<
"Start in mode '"
97 <<
"' with output directory '" <<
theDir <<
"'.";
128 edm::LogWarning(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::initialize"
129 <<
"Running with AlignabeMuon not yet tested.";
144 RunRangeSelectionVPSet);
147 if (RunRangeSelectionVPSet.size()>0) {
148 labelerPlugin =
"RunRangeDependentPedeLabeler";
149 if (pedeLabelerCfg.
exists(
"plugin")) {
151 if ((labelerPluginCfg!=
"PedeLabeler" && labelerPluginCfg!=
"RunRangeDependentPedeLabeler") ||
154 <<
"MillePedeAlignmentAlgorithm::initialize"
155 <<
"both RunRangeSelection and generic labeler specified in config file. "
156 <<
"Please get rid of either one of them.\n";
160 if (pedeLabelerCfg.
exists(
"plugin")) {
165 if (!pedeLabelerCfg.
exists(
"plugin")) {
169 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::initialize"
170 <<
"Using plugin '" << labelerPlugin <<
"' to generate labels.";
184 const std::vector<edm::ParameterSet> mprespset
186 if (!mprespset.empty()) {
187 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::initialize"
188 <<
"Apply " << mprespset.end() - mprespset.begin()
189 <<
" previous MillePede constants from 'pedeReaderInputs'.";
196 for (std::vector<edm::ParameterSet>::const_iterator iSet = mprespset.begin(), iE = mprespset.end();
197 iSet != iE; ++iSet) {
202 <<
"MillePedeAlignmentAlgorithm::initialize: Problems reading input constants of "
203 <<
"pedeReaderInputs entry " << iSet - mprespset.begin() <<
'.';
220 <<
"'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' must be empty for "
221 <<
"modes running mille.";
261 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::setParametersForRunRange"
262 <<
"Problems reading pede result, but applying!";
279 std::vector<std::string>
files;
283 const std::vector<std::string> plainFiles
285 for (std::vector<std::string>::const_iterator
i = plainFiles.begin(), iEnd = plainFiles.end();
313 for (ConstTrajTrackPairCollection::const_iterator iTrajTrack = tracks.begin();
314 iTrajTrack != tracks.end(); ++iTrajTrack) {
322 unsigned int refTrajCount = 0;
323 for (RefTrajColl::const_iterator iRefTraj = trajectories.begin(), iRefTrajE = trajectories.end();
324 iRefTraj != iRefTrajE; ++iRefTraj, ++refTrajCount) {
329 const std::pair<unsigned int, unsigned int> nHitXy
332 if (
theMonitor && (nHitXy.first || nHitXy.second)) {
336 (trajectories.size() == tracks.size() ? tracks[refTrajCount].second : 0);
345 std::pair<unsigned int, unsigned int>
350 std::pair<unsigned int, unsigned int> hitResultXy(0,0);
351 if (refTrajPtr->isValid()) {
354 std::vector<AlignmentParameters*> parVec(refTrajPtr->recHits().size());
356 std::vector<bool> validHitVecY(refTrajPtr->recHits().size(),
false);
358 for (
unsigned int iHit = 0; iHit < refTrajPtr->recHits().size(); ++iHit) {
359 const int flagXY = this->
addMeasurementData(setup, eventInfo, refTrajPtr, iHit, parVec[iHit]);
362 hitResultXy.first = 0;
365 if (flagXY >= 1) ++hitResultXy.first;
366 validHitVecY[iHit] = (flagXY >= 2);
371 for (
unsigned int iVirtualMeas = 0; iVirtualMeas < refTrajPtr->numberOfVirtualMeas(); ++iVirtualMeas) {
376 if (hitResultXy.first == 0 || hitResultXy.first <
theMinNumHits) {
378 hitResultXy.first = hitResultXy.second = 0;
383 hitResultXy.second = this->
addHitCount(parVec, validHitVecY);
393 const std::vector<bool> &validHitVecY)
const
396 unsigned int nHitY = 0;
397 for (
unsigned int iHit = 0; iHit < validHitVecY.size(); ++iHit) {
398 Alignable *ali = (parVec[iHit] ? parVec[iHit]->alignable() : 0);
409 if (validHitVecY[iHit]) {
411 if (pars == parVec[iHit]) ++nHitY;
446 if (!recHitPtr->isValid())
return 0;
472 std::vector<float> &globalDerivativesX,
473 std::vector<float> &globalDerivativesY,
474 std::vector<int> &globalLabels,
478 if (!ali)
return true;
480 if (
false && theMonitor && alidet != ali) theMonitor->fillFrameToFrame(alidet, ali);
485 if (!lowestParams) lowestParams = params;
487 bool hasSplitParameters = thePedeLabels->hasSplitParameters(ali);
488 const unsigned int alignableLabel = thePedeLabels->alignableLabel(ali);
490 if (0 == alignableLabel) {
491 edm::LogWarning(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
492 <<
"Label not found, skip Alignable.";
496 const std::vector<bool> &selPars = params->
selector();
500 for (
unsigned int iSel = 0; iSel < selPars.size(); ++iSel) {
502 globalDerivativesX.push_back(derivs[iSel][kLocalX]
503 /thePedeSteer->cmsToPedeFactor(iSel));
504 if (hasSplitParameters==
true) {
505 globalLabels.push_back(thePedeLabels->parameterLabel(ali, iSel, eventInfo, tsos));
507 globalLabels.push_back(thePedeLabels->parameterLabel(alignableLabel, iSel));
509 globalDerivativesY.push_back(derivs[iSel][kLocalY]
510 /thePedeSteer->cmsToPedeFactor(iSel));
514 if (thePedeSteer->isNoHiera(ali))
return true;
517 return this->globalDerivativesHierarchy(eventInfo,
518 tsos, ali->
mother(), alidet,
519 globalDerivativesX, globalDerivativesY,
520 globalLabels, lowestParams);
529 std::vector<float> &globalDerivativesX,
530 std::vector<float> &globalDerivativesY,
531 std::vector<int> &globalLabels)
const
533 std::vector<IntegratedCalibrationBase::ValuesIndexPair> derivs;
536 (*iCalib)->derivatives(derivs, *recHit, tsos, setup, eventInfo);
537 for (
auto iValuesInd = derivs.begin(); iValuesInd != derivs.end(); ++iValuesInd) {
540 globalDerivativesX.push_back(iValuesInd->first.first);
541 globalDerivativesY.push_back(iValuesInd->first.second);
585 if (recHit->dimension() < 2) {
587 }
else if (recHit->detUnit()) {
588 return recHit->detUnit()->type().isTrackerPixel();
590 if (dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit->hit())) {
606 std::vector<Alignable*> alis;
607 bool okRead = reader.
read(alis, setUserVars);
608 bool numMatch =
true;
610 std::stringstream
out;
611 out <<
"Read " << alis.size() <<
" alignables";
616 if (!okRead) out <<
", but problems in reading";
617 if (!allEmpty) out <<
", possibly overwriting previous settings";
620 if (okRead && allEmpty) {
622 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
623 }
else if (alis.size()) {
624 edm::LogWarning(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
626 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
632 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
640 for (std::vector<Alignable*>::const_iterator iAli = alignables.begin();
641 iAli != alignables.end(); ++iAli) {
646 for (
int i = 0;
i < parVec.num_row(); ++
i) {
647 if (parVec[
i] != 0.)
return false;
648 for (
int j =
i;
j < parCov.num_col(); ++
j) {
649 if (parCov[
i][
j] != 0.)
return false;
664 if (outFilePlain.empty()) {
665 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO"
666 <<
"treeFile parameter empty => skip writing for 'loop' " <<
loop;
677 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO"
678 <<
"Problem " << ioerr <<
" in writeAlignableOriginalPositions";
681 }
else if (loop == 1) {
683 const std::vector<std::string> inFiles
685 const std::vector<std::string> binFiles
687 if (inFiles.size() != binFiles.size()) {
688 edm::LogWarning(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO"
689 <<
"'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' "
697 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO"
698 <<
"Problem " << ioerr <<
" writing MillePedeVariables";
704 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO" <<
"Problem " << ioerr
705 <<
" in writeOrigRigidBodyAlignmentParameters, " <<
loop;
710 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::doIO" <<
"Problem " << ioerr
711 <<
" in writeAlignableAbsolutePositions, " <<
loop;
721 for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
724 throw cms::Exception(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::buildUserVariables"
725 <<
"No parameters for alignable";
729 for (
unsigned int iPar = 0; iPar < userVars->
size(); ++iPar) {
746 if (mode ==
"full") {
748 }
else if (mode ==
"mille") {
750 }
else if (mode ==
"pede") {
752 }
else if (mode ==
"pedeSteer") {
754 }
else if (mode ==
"pedeRun") {
756 }
else if (mode ==
"pedeRead") {
761 <<
"Unknown mode '" << mode
762 <<
"', use 'full', 'mille', 'pede', 'pedeRun', 'pedeSteer' or 'pedeRead'.";
769 const std::vector<std::string> &inFiles)
const
774 for (std::vector<std::string>::const_iterator iFile = inFiles.begin();
775 iFile != inFiles.end(); ++iFile) {
777 const std::vector<AlignmentUserVariables*> mpVars =
780 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::addHitStatistics"
781 <<
"Error " << ierr <<
" reading from " << inFile
782 <<
", tree " << fromIov <<
", or problems in addHits";
785 for (std::vector<AlignmentUserVariables*>::const_iterator
i = mpVars.begin();
786 i != mpVars.end(); ++
i) {
796 const std::vector<AlignmentUserVariables*> &mpVars)
const
798 bool allOk = (mpVars.size() == alis.size());
799 std::vector<AlignmentUserVariables*>::const_iterator iUser = mpVars.begin();
800 for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
801 iAli != alis.end() && iUser != mpVars.end(); ++iAli, ++iUser) {
805 if (!mpVarNew || !mpVarOld || mpVarOld->
size() != mpVarNew->
size()) {
819 const std::vector<float> &globalDerivativesy,
820 TMatrixF &aGlobalDerivativesM)
823 for (
unsigned int i = 0;
i < globalDerivativesx.size(); ++
i) {
824 aGlobalDerivativesM(0,
i) = globalDerivativesx[
i];
825 aGlobalDerivativesM(1,
i) = globalDerivativesy[
i];
831 (TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM, TMatrixF &aHitResidualsM,
832 TMatrixF &aGlobalDerivativesM)
const
834 TMatrixDSymEigen myDiag(aHitCovarianceM);
835 TMatrixD aTranfoToDiagonalSystem = myDiag.GetEigenVectors();
836 TMatrixD aTranfoToDiagonalSystemInv = myDiag.GetEigenVectors( );
837 TMatrixF aTranfoToDiagonalSystemInvF = myDiag.GetEigenVectors( );
838 TMatrixD aMatrix = aTranfoToDiagonalSystemInv.Invert() * aHitCovarianceM * aTranfoToDiagonalSystem;
844 aHitCovarianceM = TMatrixDSym(2, aMatrix.GetMatrixArray());
845 aTranfoToDiagonalSystemInvF.Invert();
847 aLocalDerivativesM = aTranfoToDiagonalSystemInvF * aLocalDerivativesM;
850 aHitResidualsM = aTranfoToDiagonalSystemInvF * aHitResidualsM;
851 aGlobalDerivativesM = aTranfoToDiagonalSystemInvF * aGlobalDerivativesM;
857 unsigned int iVirtualMeas, TMatrixDSym &aHitCovarianceM,
858 TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
862 const unsigned int xIndex = iVirtualMeas + refTrajPtr->numberOfHitMeas();
866 aHitCovarianceM(0,0)=refTrajPtr->measurementErrors()[xIndex][xIndex];
869 aHitResidualsM(0,0)= refTrajPtr->measurements()[xIndex];
876 for (
int i = 0;
i < locDerivMatrix.num_col(); ++
i) {
877 aLocalDerivativesM(0,
i) = locDerivMatrix[xIndex][
i];
884 unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM,
885 TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
889 const unsigned int xIndex = iTrajHit*2;
890 const unsigned int yIndex = iTrajHit*2+1;
894 aHitCovarianceM(0,0)=refTrajPtr->measurementErrors()[xIndex][xIndex];
895 aHitCovarianceM(0,1)=refTrajPtr->measurementErrors()[xIndex][yIndex];
896 aHitCovarianceM(1,0)=refTrajPtr->measurementErrors()[yIndex][xIndex];
897 aHitCovarianceM(1,1)=refTrajPtr->measurementErrors()[yIndex][yIndex];
900 aHitResidualsM(0,0)= refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
901 aHitResidualsM(1,0)= refTrajPtr->measurements()[yIndex] - refTrajPtr->trajectoryPositions()[yIndex];
908 for (
int i = 0;
i < locDerivMatrix.num_col(); ++
i) {
909 aLocalDerivativesM(0,
i) = locDerivMatrix[xIndex][
i];
910 aLocalDerivativesM(1,
i) = locDerivMatrix[yIndex][
i];
917 unsigned int iTrajHit,
const std::vector<int> &globalLabels,
918 const std::vector<float> &globalDerivativesX,
919 const std::vector<float> &globalDerivativesY)
923 if((aRecHit)->dimension() == 1) {
924 return this->callMille1D(refTrajPtr, iTrajHit, globalLabels, globalDerivativesX);
926 return this->callMille2D(refTrajPtr, iTrajHit, globalLabels,
927 globalDerivativesX, globalDerivativesY);
935 unsigned int iTrajHit,
const std::vector<int> &globalLabels,
936 const std::vector<float> &globalDerivativesX)
939 const unsigned int xIndex = iTrajHit*2;
943 const int nLocal = locDerivMatrix.num_col();
944 std::vector<float> localDerivatives(nLocal);
945 for (
unsigned int i = 0;
i < localDerivatives.size(); ++
i) {
946 localDerivatives[
i] = locDerivMatrix[xIndex][
i];
950 float residX = refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
951 float hitErrX = TMath::Sqrt(refTrajPtr->measurementErrors()[xIndex][xIndex]);
954 const int nGlobal = globalDerivativesX.size();
958 theMille->mille(nLocal, &(localDerivatives[0]), nGlobal, &(globalDerivativesX[0]),
959 &(globalLabels[0]), residX, hitErrX);
962 theMonitor->fillDerivatives(aRecHit, &(localDerivatives[0]), nLocal,
963 &(globalDerivativesX[0]), nGlobal, &(globalLabels[0]));
964 theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
965 iTrajHit, residX, hitErrX,
false);
974 unsigned int iTrajHit,
const std::vector<int> &globalLabels,
975 const std::vector<float> &globalDerivativesx,
976 const std::vector<float> &globalDerivativesy)
980 if((aRecHit)->dimension() != 2) {
981 edm::LogError(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::callMille2D"
982 <<
"You try to call method for 2D hits for a "
984 <<
"D Hit. Hit gets ignored!";
988 TMatrixDSym aHitCovarianceM(2);
989 TMatrixF aHitResidualsM(2,1);
990 TMatrixF aLocalDerivativesM(2, refTrajPtr->derivatives().num_col());
992 this->addRefTrackData2D(refTrajPtr, iTrajHit, aHitCovarianceM,aHitResidualsM,aLocalDerivativesM);
993 TMatrixF aGlobalDerivativesM(2,globalDerivativesx.size());
994 this->makeGlobDerivMatrix(globalDerivativesx, globalDerivativesy, aGlobalDerivativesM);
999 const double corr = aHitCovarianceM(0,1) /
sqrt(aHitCovarianceM(0,0) * aHitCovarianceM(1,1));
1000 if (theMonitor) theMonitor->fillCorrelations2D(corr, aRecHit);
1002 switch(aRecHit->geographicalId().subdetId()) {
1005 if (aRecHit->geographicalId().det() ==
DetId::Tracker && TMath::Abs(corr) > theMaximalCor2D) {
1006 this->diagonalize(aHitCovarianceM, aLocalDerivativesM, aHitResidualsM, aGlobalDerivativesM);
1013 float newResidX = aHitResidualsM(0,0);
1014 float newResidY = aHitResidualsM(1,0);
1015 float newHitErrX = TMath::Sqrt(aHitCovarianceM(0,0));
1016 float newHitErrY = TMath::Sqrt(aHitCovarianceM(1,1));
1017 float *newLocalDerivsX = aLocalDerivativesM[0].GetPtr();
1018 float *newLocalDerivsY = aLocalDerivativesM[1].GetPtr();
1019 float *newGlobDerivsX = aGlobalDerivativesM[0].GetPtr();
1020 float *newGlobDerivsY = aGlobalDerivativesM[1].GetPtr();
1021 const int nLocal = aLocalDerivativesM.GetNcols();
1022 const int nGlobal = aGlobalDerivativesM.GetNcols();
1024 if (diag && (newHitErrX > newHitErrY)) {
1028 std::swap(newLocalDerivsX, newLocalDerivsY);
1029 std::swap(newGlobDerivsX, newGlobDerivsY);
1034 theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX,
1035 &(globalLabels[0]), newResidX, newHitErrX);
1038 theMonitor->fillDerivatives(aRecHit, newLocalDerivsX, nLocal, newGlobDerivsX, nGlobal,
1039 &(globalLabels[0]));
1040 theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
1041 iTrajHit, newResidX, newHitErrX,
false);
1043 const bool isReal2DHit = this->is2D(aRecHit);
1045 theMille->mille(nLocal, newLocalDerivsY, nGlobal, newGlobDerivsY,
1046 &(globalLabels[0]), newResidY, newHitErrY);
1048 theMonitor->fillDerivatives(aRecHit, newLocalDerivsY, nLocal, newGlobDerivsY, nGlobal,
1049 &(globalLabels[0]));
1050 theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
1051 iTrajHit, newResidY, newHitErrY,
true);
1055 return (isReal2DHit ? 2 : 1);
1062 TMatrixDSym aHitCovarianceM(1);
1063 TMatrixF aHitResidualsM(1,1);
1064 TMatrixF aLocalDerivativesM(1, refTrajPtr->derivatives().num_col());
1066 this->addRefTrackVirtualMeas1D(refTrajPtr, iVirtualMeas, aHitCovarianceM, aHitResidualsM, aLocalDerivativesM);
1069 TMatrixF aGlobalDerivativesM(1,1);
1070 aGlobalDerivativesM(0,0) = 0;
1072 float newResidX = aHitResidualsM(0,0);
1073 float newHitErrX = TMath::Sqrt(aHitCovarianceM(0,0));
1074 float *newLocalDerivsX = aLocalDerivativesM[0].GetPtr();
1075 float *newGlobDerivsX = aGlobalDerivativesM[0].GetPtr();
1076 const int nLocal = aLocalDerivativesM.GetNcols();
1077 const int nGlobal = 0;
1079 theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX,
1080 &nGlobal, newResidX, newHitErrX);
1088 TsosVectorCollection::const_iterator iTsoses = lasBeamTsoses.begin();
1089 for(TkFittedLasBeamCollection::const_iterator iBeam = lasBeams.begin(), iEnd = lasBeams.end();
1090 iBeam != iEnd; ++iBeam, ++iTsoses){
1092 edm::LogInfo(
"Alignment") <<
"@SUB=MillePedeAlignmentAlgorithm::addLaserData"
1093 <<
"Beam " << iBeam->getBeamId() <<
" with "
1094 << iBeam->parameters().size() <<
" parameters and "
1095 << iBeam->getData().size() <<
" hits.\n There are "
1096 << iTsoses->size() <<
" TSOSes.";
1098 this->
addLasBeam(eventInfo, *iBeam, *iTsoses);
1105 const std::vector<TrajectoryStateOnSurface> &tsoses)
1108 std::vector<float> lasLocalDerivsX;
1111 for (
unsigned int iHit = 0; iHit < tsoses.size(); ++iHit) {
1112 if (!tsoses[iHit].isValid())
continue;
1117 lasLocalDerivsX.clear();
1122 tsoses[iHit], lasAli, lasAli,
1125 for (
unsigned int nFitParams = 0;
1126 nFitParams < static_cast<unsigned int>(lasBeam.
parameters().size());
1130 lasLocalDerivsX.push_back(derivative);
1138 const float residual = hit.
localPosition().x() - tsoses[iHit].localPosition().x();
1140 const float error = 0.003;
1152 const bool doOutputOnStdout(pxbSurveyCfg.
getParameter<
bool>(
"doOutputOnStdout"));
1153 if (doOutputOnStdout)
std::cout <<
"# Output from addPxbSurvey follows below because doOutputOnStdout is set to True" << std::endl;
1160 std::vector<SurveyPxbImageLocalFit> measurements;
1167 if (doOutputOnStdout)
std::cout <<
"Module " <<
i <<
": ";
1191 fidpointvec.push_back(fidpoint0inSurf1frame);
1192 fidpointvec.push_back(fidpoint1inSurf1frame);
1193 fidpointvec.push_back(fidpoint2);
1194 fidpointvec.push_back(fidpoint3);
1199 dicer.
doDice(fidpointvec,measurements[i].getIdPair(),
outfile);
1205 a = measurements[
i].getLocalParameters();
1209 if (doOutputOnStdout)
1211 std::cout <<
"a: " << a[0] <<
", " << a[1] <<
", " << a[2] <<
", " << a[3]
1212 <<
" S= " <<
sqrt(a[2]*a[2]+a[3]*a[3])
1213 <<
" phi= " << atan(a[3]/a[2])
1214 <<
" chi2= " << chi2 << std::endl;
1226 measurements[i].getLocalDerivsPtr(
j),
1227 (
int)measurements[i].getGlobalDerivsSize(),
1228 measurements[i].getGlobalDerivsPtr(
j),
1229 measurements[i].getGlobalDerivsLabelPtr(
j),
1230 measurements[i].getResiduum(
j),
1231 measurements[i].getSigma(
j));
unsigned int hitsX() const
get number of hits for x-measurement
const TimeTypeSpecs timeTypeSpecs[]
std::vector< int > theIntBuffer
T getParameter(std::string const &) const
unsigned int firstFixedParameter() const
void globalDerivativesCalibration(const TransientTrackingRecHit::ConstRecHitPointer &recHit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo, std::vector< float > &globalDerivativesX, std::vector< float > &globalDerivativesY, std::vector< int > &globalLabels) const
adding derivatives from integrated calibrations
T getUntrackedParameter(std::string const &, T const &) const
std::vector< AlignmentUserVariables * > readMillePedeVariables(const std::vector< Alignable * > &alivec, const char *filename, int iter, int &ierr)
unsigned int size() const
number of parameters
void resetParameters(void)
reset parameters, correlations, user variables
void increaseHitsX(unsigned int add=1)
increase hits for x-measurement
bool read(std::vector< Alignable * > &alignables, bool setUserVars)
std::vector< coord_t > fidpoint_t
void increaseHitsY(unsigned int add=1)
increase hits for y-measurement
std::vector< Alignable * > theAlignables
TrajectoryFactoryBase::ReferenceTrajectoryCollection RefTrajColl
std::vector< ParameterSet > VParameterSet
virtual unsigned int alignableLabel(Alignable *alignable) const =0
bool theDoSurveyPixelBarrel
void writeAlignableOriginalPositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write Alignable original (before misalignment) absolute positions
void fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi)
unsigned int theMinNumHits
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool globalDerivativesHierarchy(const EventInfo &eventInfo, const TrajectoryStateOnSurface &tsos, Alignable *ali, const AlignableDetOrUnitPtr &alidet, std::vector< float > &globalDerivativesX, std::vector< float > &globalDerivativesY, std::vector< int > &globalLabels, AlignmentParameters *&lowestParams) const
recursively adding derivatives and labels, false if problems
void restoreCachedTransformations(void)
restore the previously cached position, rotation and other parameters
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
unsigned int addHitCount(const std::vector< AlignmentParameters * > &parVec, const std::vector< bool > &validHitVecY) const
PedeSteerer * thePedeSteer
virtual LocalPoint localPosition() const
const AlgebraicMatrix & derivatives() const
matrix of local derivatives: columns are parameters, rows are hits
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
int callMille2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy)
std::pair< RunNumber, RunNumber > RunRange
const ConstTrajTrackPairCollection & trajTrackPairs_
const TsosVectorCollection * tkLasBeamTsoses_
might be null!
virtual unsigned int lasBeamLabel(unsigned int lasBeamId) const =0
virtual void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store)
Call at beginning of job.
void addLasBeam(const EventInfo &eventInfo, const TkFittedLasBeam &lasBeam, const std::vector< TrajectoryStateOnSurface > &tsoses)
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
void fillPxbSurveyHistsChi2(const float &chi2)
virtual unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const =0
returns the label for a given alignable parameter number combination
unsigned int doIO(int loop) const
int callMille(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX, const std::vector< float > &globalDerivativesY)
calls callMille1D or callMille2D
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const AlgebraicVector & parameters(void) const
Get alignment parameters.
std::string doDice(const fidpoint_t &fidpointvec, const idPair_t &id, const bool rotate=false)
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
int callMille1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX)
calls Mille for 1D hits
void addLaserData(const EventInfo &eventInfo, const TkFittedLasBeamCollection &tkLasBeams, const TsosVectorCollection &tkLasBeamTsoses)
int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, AlignmentParameters *¶ms)
virtual void terminate(const edm::EventSetup &iSetup)
Call at end of job.
bool isMode(unsigned int testMode) const
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
CLHEP::HepMatrix AlgebraicMatrix
const std::vector< Scalar > & parameters() const
parallel to derivatives()
void fillUsedTrack(const reco::Track *track, unsigned int nHitX, unsigned int nHitY)
virtual bool setParametersForRunRange(const RunRange &runrange)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual void endRun(const EventInfo &eventInfo, const EndRunInfo &runInfo, const edm::EventSetup &setup)
Run on run products, e.g. TkLAS.
PedeLabelerBase * thePedeLabels
int runPede(const std::string &masterSteer) const
run pede, masterSteer should be as returned from buildMasterSteer(...)
unsigned int getBeamId(void) const
return the full beam identifier
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
unsigned int hitsY() const
get number of hits for y-measurement
AlignableNavigator * theAlignableNavigator
bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
true if hit belongs to 2D detector (currently tracker specific)
void diagonalize(TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM, TMatrixF &aHitResidualsM, TMatrixF &theGlobalDerivativesM) const
edm::ParameterSet theConfig
std::string buildMasterSteer(const std::vector< std::string > &binaryFiles)
construct (and return name of) master steering file from config, binaryFiles etc. ...
Container::value_type value_type
void mille(int NLC, const float *derLc, int NGL, const float *derGl, const int *label, float rMeas, float sigma)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
bool addHits(const std::vector< Alignable * > &alis, const std::vector< AlignmentUserVariables * > &mpVars) const
void writeMillePedeVariables(const std::vector< Alignable * > &alivec, const char *filename, int iter, bool validCheck, int &ierr)
bool addHitStatistics(int fromLoop, const std::string &outFile, const std::vector< std::string > &inFiles) const
std::vector< ConstRecHitPointer > ConstRecHitContainer
bool areEmptyParams(const std::vector< Alignable * > &alignables) const
const reco::BeamSpot & beamSpot_
void addVirtualMeas(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas)
adds data for virtual measurements from reference trajectory
bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars, const RunRange &runrange)
read pede input defined by 'psetName', flag to create/not create MillePedeVariables ...
CLHEP::HepVector AlgebraicVector
MillePedeMonitor * theMonitor
std::pair< unsigned int, unsigned int > addReferenceTrajectory(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
fill mille for a trajectory, returning number of x/y hits ([0,0] if 'bad' trajectory) ...
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
const SiStripDetId & getDetId(void) const
void addRefTrackData2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM, TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
adds data from reference trajectory from a specific Hit
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
std::vector< IntegratedCalibrationBase * > theCalibrations
int size(void) const
Get number of parameters.
std::vector< float > theFloatBufferX
void buildSubSteer(AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
construct steering files about hierarchy, fixing etc. an keep track of their names ...
void makeGlobDerivMatrix(const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, TMatrixF &aGlobalDerivativesM)
void addUntrackedParameter(std::string const &name, T const &value)
Class to hold one picture of the BPix survey.
const TkFittedLasBeamCollection * tkLasBeams_
T const * product() const
std::vector< value_t > localpars_t
void fillTrack(const reco::Track *track)
virtual bool addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals)
pass integrated calibrations to Millepede (they are not owned by Millepede!)
virtual void run(const edm::EventSetup &setup, const EventInfo &eventInfo)
Run the algorithm on trajectories and tracks.
define run information passed to algorithms (in endRun)
virtual unsigned int calibrationLabel(const IntegratedCalibrationBase *calib, unsigned int paramNum) const
label for parameter 'paramNum' (counted from 0) of an integrated calibration
void buildUserVariables(const std::vector< Alignable * > &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)
MillePedeAlignmentAlgorithm(const edm::ParameterSet &cfg)
Constructor.
TrajectoryFactoryBase * theTrajectoryFactory
virtual ~MillePedeAlignmentAlgorithm()
Destructor.
virtual void addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals)
tell labeler to treat also integrated calibrations
std::vector< TkFittedLasBeam > TkFittedLasBeamCollection
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
void cacheTransformations(void)
cache the current position, rotation and other parameters
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const =0
void fillRefTrajectory(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
std::vector< float > theFloatBufferY
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void addRefTrackVirtualMeas1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas, TMatrixDSym &aHitCovarianceM, TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
adds data for a specific virtual measurement from reference trajectory
static const count_t nMsrmts
void writeAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write Alignable current absolute positions
void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg)
add measurement data from PXB survey
unsigned int decodeMode(const std::string &mode) const
std::string fullPath() const
const std::vector< SiStripLaserRecHit2D > & getData(void) const
access the collection of hits
void writeOrigRigidBodyAlignmentParameters(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write RigidBodyAlignmentParameters as applied on top of original positions
std::vector< std::vector< TrajectoryStateOnSurface > > TsosVectorCollection
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
Constructor of the full muon geometry.
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
Alignable * mother() const
Return pointer to container alignable (if any)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
T get(const Candidate &c)
const align::Alignables & alignables(void) const
get all alignables
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
bool setAllDefault(unsigned int nParam)
set default values for all data concerning nParam (false if nParam out of range)
define event information passed to algorithms