CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MillePedeAlignmentAlgorithm Class Reference

#include <MillePedeAlignmentAlgorithm.h>

Inheritance diagram for MillePedeAlignmentAlgorithm:
AlignmentAlgorithmBase

Public Member Functions

virtual bool addCalibrations (const std::vector< IntegratedCalibrationBase * > &iCals) override
 Pass integrated calibrations to Millepede (they are not owned by Millepede!) More...
 
virtual void beginLuminosityBlock (const edm::EventSetup &) override
 called at begin of luminosity block (resets Mille binary in mille mode) More...
 
virtual void endLuminosityBlock (const edm::EventSetup &) override
 called at end of luminosity block More...
 
virtual void endRun (const EventInfo &, const EndRunInfo &, const edm::EventSetup &)
 Run on run products, e.g. TkLAS. More...
 
virtual void endRun (const EndRunInfo &runInfo, const edm::EventSetup &setup) override
 called at end of run - order of arguments like in EDProducer etc. More...
 
virtual void initialize (const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
 Called at beginning of job. More...
 
 MillePedeAlignmentAlgorithm (const edm::ParameterSet &cfg)
 Constructor. More...
 
virtual bool processesEvents () override
 Returns whether MP should process events in the current configuration. More...
 
virtual void run (const edm::EventSetup &setup, const EventInfo &eventInfo) override
 Run the algorithm on trajectories and tracks. More...
 
virtual bool setParametersForRunRange (const RunRange &runrange) override
 
virtual bool storeAlignments () override
 Returns whether MP produced results to be stored. More...
 
virtual bool supportsCalibrations () override
 Returns whether MP supports calibrations. More...
 
virtual void terminate (const edm::EventSetup &iSetup) override
 Called at end of job. More...
 
virtual void terminate () override
 Called at end of job. More...
 
virtual ~MillePedeAlignmentAlgorithm ()
 Destructor. More...
 
- Public Member Functions inherited from AlignmentAlgorithmBase
virtual bool addCalibrations (const Calibrations &)
 
 AlignmentAlgorithmBase (const edm::ParameterSet &)
 Constructor. More...
 
virtual void beginRun (const edm::EventSetup &setup)
 called at begin of run More...
 
virtual void startNewLoop ()
 
virtual ~AlignmentAlgorithmBase ()
 Destructor. More...
 

Private Types

enum  EModeBit { myMilleBit = 1 << 0, myPedeRunBit = 1 << 1, myPedeSteerBit = 1 << 2, myPedeReadBit = 1 << 3 }
 
enum  MeasurementDirection { kLocalX = 0, kLocalY }
 

Private Member Functions

int addGlobalData (const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, gbl::GblPoint &gblPoint)
 
unsigned int addHitCount (const std::vector< AlignmentParameters * > &parVec, const std::vector< bool > &validHitVecY) const
 
bool addHits (const std::vector< Alignable * > &alis, const std::vector< AlignmentUserVariables * > &mpVars) const
 
bool addHitStatistics (int fromLoop, const std::string &outFile, const std::vector< std::string > &inFiles) const
 
void addLasBeam (const EventInfo &eventInfo, const TkFittedLasBeam &lasBeam, const std::vector< TrajectoryStateOnSurface > &tsoses)
 
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 *&params)
 
void addPxbSurvey (const edm::ParameterSet &pxbSurveyCfg)
 add measurement data from PXB survey More...
 
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) More...
 
void addRefTrackData2D (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, TMatrixDSym &aHitCovarianceM, TMatrixF &aHitResidualsM, TMatrixF &aLocalDerivativesM)
 adds data from reference trajectory from a specific Hit More...
 
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 More...
 
void addVirtualMeas (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas)
 adds data for virtual measurements from reference trajectory More...
 
bool areEmptyParams (const std::vector< Alignable * > &alignables) const
 
void buildUserVariables (const std::vector< Alignable * > &alignables) const
 add MillePedeVariables for each AlignmentParameters (exception if no parameters...) More...
 
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 More...
 
int callMille1D (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX)
 calls Mille for 1D hits More...
 
int callMille2D (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy)
 
unsigned int decodeMode (const std::string &mode) const
 
void diagonalize (TMatrixDSym &aHitCovarianceM, TMatrixF &aLocalDerivativesM, TMatrixF &aHitResidualsM, TMatrixF &theGlobalDerivativesM) const
 
unsigned int doIO (int loop) const
 
std::vector< std::string > getExistingFormattedFiles (const std::vector< std::string > &plainFiles, const std::string &theDir)
 
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 More...
 
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 More...
 
bool globalDerivativesHierarchy (const EventInfo &eventInfo, const TrajectoryStateOnSurface &tsos, Alignable *ali, const AlignableDetOrUnitPtr &alidet, std::vector< double > &globalDerivativesX, std::vector< double > &globalDerivativesY, std::vector< int > &globalLabels, AlignmentParameters *&lowestParams) const
 recursively adding derivatives (double) and labels, false if problems More...
 
bool is2D (const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
 true if hit belongs to 2D detector (currently tracker specific) More...
 
bool isMode (unsigned int testMode) const
 
void makeGlobDerivMatrix (const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, TMatrixF &aGlobalDerivativesM)
 
bool readFromPede (const edm::ParameterSet &mprespset, bool setUserVars, const RunRange &runrange)
 read pede input defined by 'psetName', flag to create/not create MillePedeVariables More...
 

Private Attributes

const bool ignoreHitsWithoutGlobalDerivatives_
 
const bool runAtPCL_
 
std::unique_ptr
< AlignableNavigator
theAlignableNavigator
 
std::vector< Alignable * > theAlignables
 
AlignmentParameterStoretheAlignmentParameterStore
 directory for all kind of files More...
 
std::unique_ptr< gbl::MilleBinarytheBinary
 
std::vector
< IntegratedCalibrationBase * > 
theCalibrations
 
edm::ParameterSet theConfig
 
std::string theDir
 
bool theDoSurveyPixelBarrel
 
std::vector< float > theFloatBufferX
 
std::vector< float > theFloatBufferY
 
bool theGblDoubleBinary
 
std::vector< int > theIntBuffer
 
int theLastWrittenIov
 
double theMaximalCor2D
 
std::unique_ptr< MilletheMille
 
unsigned int theMinNumHits
 
unsigned int theMode
 
std::unique_ptr< MillePedeMonitortheMonitor
 
std::shared_ptr< PedeLabelerBasethePedeLabels
 
std::unique_ptr< PedeSteererthePedeSteer
 
std::unique_ptr
< TrajectoryFactoryBase
theTrajectoryFactory
 

Additional Inherited Members

- Public Types inherited from AlignmentAlgorithmBase
typedef std::pair< const
Trajectory *, const
reco::Track * > 
ConstTrajTrackPair
 
typedef std::vector
< ConstTrajTrackPair
ConstTrajTrackPairCollection
 
typedef cond::RealTimeType
< cond::runnumber >::type 
RunNumber
 
typedef std::pair< RunNumber,
RunNumber
RunRange
 

Detailed Description

CMSSW interface to pede: produces pede's binary input and steering file(s)

Author
: Gero Flucke date : October 2006
Revision:
1.36
Date:
2012/08/10 09:01:11

(last update by

Author:
flucke

)

Definition at line 56 of file MillePedeAlignmentAlgorithm.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm ( const edm::ParameterSet cfg)

Constructor.

Definition at line 89 of file MillePedeAlignmentAlgorithm.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isMode(), myMilleBit, AlCaHLTBitMon_QueryRunRegistry::string, theBinary, theConfig, theDir, theGblDoubleBinary, and theMille.

89  :
91  theConfig(cfg),
95  theAlignables(),
96  theMinNumHits(cfg.getParameter<unsigned int>("minNumHits")),
97  theMaximalCor2D(cfg.getParameter<double>("max2Dcorrelation")),
99  theGblDoubleBinary(cfg.getParameter<bool>("doubleBinary")),
100  runAtPCL_(cfg.getParameter<bool>("runAtPCL")),
101  ignoreHitsWithoutGlobalDerivatives_(cfg.getParameter<bool>("ignoreHitsWithoutGlobalDerivatives"))
102 {
103  if (!theDir.empty() && theDir.find_last_of('/') != theDir.size()-1) theDir += '/';// may need '/'
104  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm" << "Start in mode '"
106  << "' with output directory '" << theDir << "'.";
107  if (this->isMode(myMilleBit)) {
108  theMille = std::make_unique<Mille>((theDir + theConfig.getParameter<std::string>("binaryFile")).c_str());// add ', false);' for text output);
109  // use same file for GBL
110  theBinary = std::make_unique<MilleBinary>((theDir + theConfig.getParameter<std::string>("binaryFile")).c_str(), theGblDoubleBinary);
111  }
112 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< Alignable * > theAlignables
std::unique_ptr< gbl::MilleBinary > theBinary
bool isMode(unsigned int testMode) const
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
AlignmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
unsigned int decodeMode(const std::string &mode) const
MillePedeAlignmentAlgorithm::~MillePedeAlignmentAlgorithm ( )
virtual

Destructor.

Definition at line 116 of file MillePedeAlignmentAlgorithm.cc.

117 {
118 }

Member Function Documentation

bool MillePedeAlignmentAlgorithm::addCalibrations ( const std::vector< IntegratedCalibrationBase * > &  iCals)
overridevirtual

Pass integrated calibrations to Millepede (they are not owned by Millepede!)

Definition at line 292 of file MillePedeAlignmentAlgorithm.cc.

References theCalibrations, and thePedeLabels.

293 {
294  theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end());
295  thePedeLabels->addCalibrations(iCals);
296  return true;
297 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::vector< IntegratedCalibrationBase * > theCalibrations
int MillePedeAlignmentAlgorithm::addGlobalData ( const edm::EventSetup setup,
const EventInfo eventInfo,
const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iHit,
gbl::GblPoint gblPoint 
)
private

Add global data (labels, derivatives) to GBL trajectory Returns -1 if any problem (for params cf. globalDerivativesHierarchy)

Definition at line 656 of file MillePedeAlignmentAlgorithm.cc.

References gbl::GblPoint::addGlobals(), globalDerivativesHierarchy(), i, theAlignableNavigator, theCalibrations, theIntBuffer, and thePedeLabels.

Referenced by addReferenceTrajectory().

659 {
660  AlignmentParameters* params = 0;
661  std::vector<double> theDoubleBufferX, theDoubleBufferY;
662  theDoubleBufferX.clear();
663  theDoubleBufferY.clear();
664  theIntBuffer.clear();
665  int iret = 0;
666 
667  const TrajectoryStateOnSurface &tsos = refTrajPtr->trajectoryStates()[iHit];
668  const ConstRecHitPointer &recHitPtr = refTrajPtr->recHits()[iHit];
669  // ignore invalid hits
670  if (!recHitPtr->isValid()) return 0;
671 
672  // get AlignableDet/Unit for this hit
673  AlignableDetOrUnitPtr alidet(theAlignableNavigator->alignableFromDetId(recHitPtr->geographicalId()));
674 
675  if (!this->globalDerivativesHierarchy(eventInfo,
676  tsos, alidet, alidet, theDoubleBufferX, // 2x alidet, sic!
677  theDoubleBufferY, theIntBuffer, params)) {
678  return -1; // problem
679  }
680  //calibration parameters
681  int globalLabel;
682  std::vector<IntegratedCalibrationBase::ValuesIndexPair> derivs;
683  for (auto iCalib = theCalibrations.begin(); iCalib != theCalibrations.end(); ++iCalib) {
684  // get all derivatives of this calibration // const unsigned int num =
685  (*iCalib)->derivatives(derivs, *recHitPtr, tsos, setup, eventInfo);
686  for (auto iValuesInd = derivs.begin(); iValuesInd != derivs.end(); ++iValuesInd) {
687  // transfer label and x/y derivatives
688  globalLabel = thePedeLabels->calibrationLabel(*iCalib, iValuesInd->second);
689  if (globalLabel > 0 && globalLabel <= 2147483647) {
690  theIntBuffer.push_back(globalLabel);
691  theDoubleBufferX.push_back(iValuesInd->first.first);
692  theDoubleBufferY.push_back(iValuesInd->first.second);
693  } else {
694  edm::LogError("Alignment")
695  << "@SUB=MillePedeAlignmentAlgorithm::addGlobalData"
696  << "Invalid label " << globalLabel << " <= 0 or > 2147483647";
697  }
698  }
699  }
700  unsigned int numGlobals = theIntBuffer.size();
701  if (numGlobals > 0)
702  {
703  TMatrixD globalDer(2,numGlobals);
704  for (unsigned int i = 0; i < numGlobals; ++i) {
705  globalDer(0,i) = theDoubleBufferX[i];
706  globalDer(1,i) = theDoubleBufferY[i];
707  }
708  gblPoint.addGlobals( theIntBuffer, globalDer );
709  iret = 1;
710  }
711  return iret;
712 }
int i
Definition: DBlmapReader.cc:9
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
std::shared_ptr< PedeLabelerBase > thePedeLabels
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
void addGlobals(const std::vector< int > &aLabels, const TMatrixD &aDerivatives)
Add global derivatives to a point.
Definition: GblPoint.cc:298
std::vector< IntegratedCalibrationBase * > theCalibrations
std::unique_ptr< AlignableNavigator > theAlignableNavigator
unsigned int MillePedeAlignmentAlgorithm::addHitCount ( const std::vector< AlignmentParameters * > &  parVec,
const std::vector< bool > &  validHitVecY 
) const
private

Increase hit counting of MillePedeVariables behind each parVec[i] (and also for parameters higher in hierarchy), assuming 'parVec' and 'validHitVecY' to be parallel. Returns number of valid y-hits.

Definition at line 556 of file MillePedeAlignmentAlgorithm.cc.

References Alignable::alignmentParameters(), MillePedeVariables::increaseHitsX(), MillePedeVariables::increaseHitsY(), Alignable::mother(), and AlignmentParameters::userVariables().

Referenced by addReferenceTrajectory().

558 {
559  // Loop on all hit information in the input arrays and count valid y-hits:
560  unsigned int nHitY = 0;
561  for (unsigned int iHit = 0; iHit < validHitVecY.size(); ++iHit) {
562  Alignable *ali = (parVec[iHit] ? parVec[iHit]->alignable() : 0);
563  // Loop upwards on hierarchy of alignables to add hits to all levels
564  // that are currently aligned. If only a non-selected alignable was hit,
565  // (i.e. flagXY == 0 in addReferenceTrajectory(..)), there is no loop at all...
566  while (ali) {
568  if (pars) { // otherwise hierarchy level not selected
569  // cast ensured by previous checks:
570  MillePedeVariables *mpVar = static_cast<MillePedeVariables*>(pars->userVariables());
571  // every hit has an x-measurement, cf. addReferenceTrajectory(..):
572  mpVar->increaseHitsX();
573  if (validHitVecY[iHit]) {
574  mpVar->increaseHitsY();
575  if (pars == parVec[iHit]) ++nHitY; // do not count hits twice
576  }
577  }
578  ali = ali->mother();
579  }
580  }
581 
582  return nHitY;
583 }
void increaseHitsX(unsigned int add=1)
increase hits for x-measurement
void increaseHitsY(unsigned int add=1)
increase hits for y-measurement
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:90
bool MillePedeAlignmentAlgorithm::addHits ( const std::vector< Alignable * > &  alis,
const std::vector< AlignmentUserVariables * > &  mpVars 
) const
private

Definition at line 1103 of file MillePedeAlignmentAlgorithm.cc.

References MillePedeVariables::hitsX(), MillePedeVariables::hitsY(), MillePedeVariables::increaseHitsX(), MillePedeVariables::increaseHitsY(), MillePedeVariables::size(), and AlignmentParameters::userVariables().

Referenced by addHitStatistics().

1105 {
1106  bool allOk = (mpVars.size() == alis.size());
1107  std::vector<AlignmentUserVariables*>::const_iterator iUser = mpVars.begin();
1108  for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
1109  iAli != alis.end() && iUser != mpVars.end(); ++iAli, ++iUser) {
1110  MillePedeVariables *mpVarNew = dynamic_cast<MillePedeVariables*>(*iUser);
1111  AlignmentParameters *ps = (*iAli)->alignmentParameters();
1112  MillePedeVariables *mpVarOld = (ps ? dynamic_cast<MillePedeVariables*>(ps->userVariables()) : 0);
1113  if (!mpVarNew || !mpVarOld || mpVarOld->size() != mpVarNew->size()) {
1114  allOk = false;
1115  continue; // FIXME error etc.?
1116  }
1117 
1118  mpVarOld->increaseHitsX(mpVarNew->hitsX());
1119  mpVarOld->increaseHitsY(mpVarNew->hitsY());
1120  }
1121 
1122  return allOk;
1123 }
unsigned int hitsX() const
get number of hits for x-measurement
unsigned int size() const
number of parameters
void increaseHitsX(unsigned int add=1)
increase hits for x-measurement
void increaseHitsY(unsigned int add=1)
increase hits for y-measurement
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
unsigned int hitsY() const
get number of hits for y-measurement
bool MillePedeAlignmentAlgorithm::addHitStatistics ( int  fromLoop,
const std::string &  outFile,
const std::vector< std::string > &  inFiles 
) const
private

Definition at line 1076 of file MillePedeAlignmentAlgorithm.cc.

References addHits(), i, MillePedeVariablesIORoot::readMillePedeVariables(), AlCaHLTBitMon_QueryRunRegistry::string, theAlignables, and theDir.

Referenced by doIO().

1078 {
1079  bool allOk = true;
1080  int ierr = 0;
1081  MillePedeVariablesIORoot millePedeIO;
1082  for (std::vector<std::string>::const_iterator iFile = inFiles.begin();
1083  iFile != inFiles.end(); ++iFile) {
1084  const std::string inFile(theDir + *iFile);
1085  const std::vector<AlignmentUserVariables*> mpVars =
1086  millePedeIO.readMillePedeVariables(theAlignables, inFile.c_str(), fromIov, ierr);
1087  if (ierr || !this->addHits(theAlignables, mpVars)) {
1088  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addHitStatistics"
1089  << "Error " << ierr << " reading from " << inFile
1090  << ", tree " << fromIov << ", or problems in addHits";
1091  allOk = false;
1092  }
1093  for (std::vector<AlignmentUserVariables*>::const_iterator i = mpVars.begin();
1094  i != mpVars.end(); ++i) {
1095  delete *i; // clean created objects
1096  }
1097  }
1098 
1099  return allOk;
1100 }
std::vector< AlignmentUserVariables * > readMillePedeVariables(const std::vector< Alignable * > &alivec, const char *filename, int iter, int &ierr)
int i
Definition: DBlmapReader.cc:9
std::vector< Alignable * > theAlignables
bool addHits(const std::vector< Alignable * > &alis, const std::vector< AlignmentUserVariables * > &mpVars) const
void MillePedeAlignmentAlgorithm::addLasBeam ( const EventInfo eventInfo,
const TkFittedLasBeam lasBeam,
const std::vector< TrajectoryStateOnSurface > &  tsoses 
)
private

Definition at line 1414 of file MillePedeAlignmentAlgorithm.cc.

References funct::derivative(), TkFittedLasBeam::derivatives(), relativeConstraints::error, TkFittedLasBeam::firstFixedParameter(), TkLasBeam::getBeamId(), TkLasBeam::getData(), SiStripLaserRecHit2D::getDetId(), globalDerivativesHierarchy(), SiStripLaserRecHit2D::localPosition(), TkFittedLasBeam::parameters(), theAlignableNavigator, theFloatBufferX, theFloatBufferY, theIntBuffer, theMille, and thePedeLabels.

Referenced by addLaserData().

1417 {
1418  AlignmentParameters *dummyPtr = 0; // for globalDerivativesHierarchy()
1419  std::vector<float> lasLocalDerivsX; // buffer for local derivatives
1420  const unsigned int beamLabel = thePedeLabels->lasBeamLabel(lasBeam.getBeamId());// for global par
1421 
1422  for (unsigned int iHit = 0; iHit < tsoses.size(); ++iHit) {
1423  if (!tsoses[iHit].isValid()) continue;
1424  // clear buffer
1425  theFloatBufferX.clear();
1426  theFloatBufferY.clear();
1427  theIntBuffer.clear();
1428  lasLocalDerivsX.clear();
1429  // get alignables and global parameters
1430  const SiStripLaserRecHit2D &hit = lasBeam.getData()[iHit];
1431  AlignableDetOrUnitPtr lasAli(theAlignableNavigator->alignableFromDetId(hit.getDetId()));
1432  this->globalDerivativesHierarchy(eventInfo,
1433  tsoses[iHit], lasAli, lasAli,
1435  // fill derivatives vector from derivatives matrix
1436  for (unsigned int nFitParams = 0;
1437  nFitParams < static_cast<unsigned int>(lasBeam.parameters().size());
1438  ++nFitParams) {
1439  const float derivative = lasBeam.derivatives()[iHit][nFitParams];
1440  if (nFitParams < lasBeam.firstFixedParameter()) { // first local beam parameters
1441  lasLocalDerivsX.push_back(derivative);
1442  } else { // now global ones
1443  const unsigned int numPar = nFitParams - lasBeam.firstFixedParameter();
1444  theIntBuffer.push_back(thePedeLabels->parameterLabel(beamLabel, numPar));
1445  theFloatBufferX.push_back(derivative);
1446  }
1447  } // end loop over parameters
1448 
1449  const float residual = hit.localPosition().x() - tsoses[iHit].localPosition().x();
1450  // error from file or assume 0.003
1451  const float error = 0.003; // hit.localPositionError().xx(); sqrt???
1452 
1453  theMille->mille(lasLocalDerivsX.size(), &(lasLocalDerivsX[0]), theFloatBufferX.size(),
1454  &(theFloatBufferX[0]), &(theIntBuffer[0]), residual, error);
1455  } // end of loop over hits
1456 
1457  theMille->end();
1458 }
unsigned int firstFixedParameter() const
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
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
std::shared_ptr< PedeLabelerBase > thePedeLabels
virtual LocalPoint localPosition() const
const AlgebraicMatrix & derivatives() const
matrix of local derivatives: columns are parameters, rows are hits
const std::vector< Scalar > & parameters() const
parallel to derivatives()
unsigned int getBeamId(void) const
return the full beam identifier
Definition: TkLasBeam.h:25
const SiStripDetId & getDetId(void) const
std::unique_ptr< AlignableNavigator > theAlignableNavigator
const std::vector< SiStripLaserRecHit2D > & getData(void) const
access the collection of hits
Definition: TkLasBeam.h:28
void MillePedeAlignmentAlgorithm::addLaserData ( const EventInfo eventInfo,
const TkFittedLasBeamCollection tkLasBeams,
const TsosVectorCollection tkLasBeamTsoses 
)
private

Definition at line 1395 of file MillePedeAlignmentAlgorithm.cc.

References addLasBeam().

Referenced by endRun().

1398 {
1399  TsosVectorCollection::const_iterator iTsoses = lasBeamTsoses.begin();
1400  for(TkFittedLasBeamCollection::const_iterator iBeam = lasBeams.begin(), iEnd = lasBeams.end();
1401  iBeam != iEnd; ++iBeam, ++iTsoses){ // beam/tsoses parallel!
1402 
1403  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addLaserData"
1404  << "Beam " << iBeam->getBeamId() << " with "
1405  << iBeam->parameters().size() << " parameters and "
1406  << iBeam->getData().size() << " hits.\n There are "
1407  << iTsoses->size() << " TSOSes.";
1408 
1409  this->addLasBeam(eventInfo, *iBeam, *iTsoses);
1410  }
1411 }
void addLasBeam(const EventInfo &eventInfo, const TkFittedLasBeam &lasBeam, const std::vector< TrajectoryStateOnSurface > &tsoses)
int MillePedeAlignmentAlgorithm::addMeasurementData ( const edm::EventSetup setup,
const EventInfo eventInfo,
const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iHit,
AlignmentParameters *&  params 
)
private

If hit is usable: callMille for x and (probably) y direction. If globalDerivatives fine: returns 2 if 2D-hit, 1 if 1D-hit, 0 if no Alignable for hit. Returns -1 if any problem (for params cf. globalDerivativesHierarchy)

Definition at line 617 of file MillePedeAlignmentAlgorithm.cc.

References callMille(), globalDerivativesCalibration(), globalDerivativesHierarchy(), ignoreHitsWithoutGlobalDerivatives_, theAlignableNavigator, theFloatBufferX, theFloatBufferY, and theIntBuffer.

Referenced by addReferenceTrajectory().

622 {
623  params = 0;
624  theFloatBufferX.clear();
625  theFloatBufferY.clear();
626  theIntBuffer.clear();
627 
628  const TrajectoryStateOnSurface &tsos = refTrajPtr->trajectoryStates()[iHit];
629  const ConstRecHitPointer &recHitPtr = refTrajPtr->recHits()[iHit];
630  // ignore invalid hits
631  if (!recHitPtr->isValid()) return 0;
632 
633  // First add the derivatives from IntegratedCalibration's,
634  // should even be OK if problems for "usual" derivatives from Alignables
635  this->globalDerivativesCalibration(recHitPtr, tsos, setup, eventInfo, // input
637 
638  // get AlignableDet/Unit for this hit
639  AlignableDetOrUnitPtr alidet(theAlignableNavigator->alignableFromDetId(recHitPtr->geographicalId()));
640 
641  if (!this->globalDerivativesHierarchy(eventInfo,
642  tsos, alidet, alidet, theFloatBufferX, // 2x alidet, sic!
643  theFloatBufferY, theIntBuffer, params)) {
644  return -1; // problem
646  return 0; // empty for X: no alignable for hit, nor calibrations
647  } else {
648  // store measurement even if no alignable or calibrations
649  // -> measurement used for pede-internal track-fit
650  return this->callMille(refTrajPtr, iHit, theIntBuffer, theFloatBufferX, theFloatBufferY);
651  }
652 }
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
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
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
std::unique_ptr< AlignableNavigator > theAlignableNavigator
void MillePedeAlignmentAlgorithm::addPxbSurvey ( const edm::ParameterSet pxbSurveyCfg)
private

add measurement data from PXB survey

Definition at line 1460 of file MillePedeAlignmentAlgorithm.cc.

References a, beam_dqm_sourceclient-live_cfg::chi2, SurveyPxbDicer::doDice(), lut2db_cfg::filename, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, j, SurveyPxbImageLocalFit::nMsrmts, timingPdfMaker::outfile, matplotRender::reader, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), theAlignableNavigator, theMille, theMonitor, thePedeLabels, AlignableSurface::toGlobal(), and AlignableSurface::toLocal().

Referenced by initialize().

1461 {
1462  // do some printing, if requested
1463  const bool doOutputOnStdout(pxbSurveyCfg.getParameter<bool>("doOutputOnStdout"));
1464  if (doOutputOnStdout) {
1465  edm::LogInfo("Alignment")
1466  << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1467  << "# Output from addPxbSurvey follows below because "
1468  << "doOutputOnStdout is set to True";
1469  }
1470 
1471  // instantiate a dicer object
1472  SurveyPxbDicer dicer(pxbSurveyCfg.getParameter<std::vector<edm::ParameterSet> >("toySurveyParameters"), pxbSurveyCfg.getParameter<unsigned int>("toySurveySeed"));
1473  std::ofstream outfile(pxbSurveyCfg.getUntrackedParameter<std::string>("toySurveyFile").c_str());
1474 
1475  // read data from file
1476  std::vector<SurveyPxbImageLocalFit> measurements;
1477  std::string filename(pxbSurveyCfg.getParameter<edm::FileInPath>("infile").fullPath());
1479 
1480  // loop over photographs (=measurements) and perform the fit
1481  for(std::vector<SurveyPxbImageLocalFit>::size_type i=0; i!=measurements.size(); i++)
1482  {
1483  if (doOutputOnStdout) {
1484  edm::LogInfo("Alignment")
1485  << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1486  << "Module " << i << ": ";
1487  }
1488 
1489  // get the Alignables and their surfaces
1490  AlignableDetOrUnitPtr mod1(theAlignableNavigator->alignableFromDetId(measurements[i].getIdFirst()));
1491  AlignableDetOrUnitPtr mod2(theAlignableNavigator->alignableFromDetId(measurements[i].getIdSecond()));
1492  const AlignableSurface& surf1 = mod1->surface();
1493  const AlignableSurface& surf2 = mod2->surface();
1494 
1495  // the position of the fiducial points in local frame of a PXB module
1496  const LocalPoint fidpoint0(-0.91,+3.30);
1497  const LocalPoint fidpoint1(+0.91,+3.30);
1498  const LocalPoint fidpoint2(+0.91,-3.30);
1499  const LocalPoint fidpoint3(-0.91,-3.30);
1500 
1501  // We choose the local frame of the first module as reference,
1502  // so take the fidpoints of the second module and calculate their
1503  // positions in the reference frame
1504  const GlobalPoint surf2point0(surf2.toGlobal(fidpoint0));
1505  const GlobalPoint surf2point1(surf2.toGlobal(fidpoint1));
1506  const LocalPoint fidpoint0inSurf1frame(surf1.toLocal(surf2point0));
1507  const LocalPoint fidpoint1inSurf1frame(surf1.toLocal(surf2point1));
1508 
1509  // Create the vector for the fit
1511  fidpointvec.push_back(fidpoint0inSurf1frame);
1512  fidpointvec.push_back(fidpoint1inSurf1frame);
1513  fidpointvec.push_back(fidpoint2);
1514  fidpointvec.push_back(fidpoint3);
1515 
1516  // if toy survey is requested, dice the values now
1517  if (pxbSurveyCfg.getParameter<bool>("doToySurvey"))
1518  {
1519  dicer.doDice(fidpointvec,measurements[i].getIdPair(), outfile);
1520  }
1521 
1522  // do the fit
1523  measurements[i].doFit(fidpointvec, thePedeLabels->alignableLabel(mod1), thePedeLabels->alignableLabel(mod2));
1524  SurveyPxbImageLocalFit::localpars_t a; // local pars from fit
1525  a = measurements[i].getLocalParameters();
1526  const SurveyPxbImageLocalFit::value_t chi2 = measurements[i].getChi2();
1527 
1528  // do some reporting, if requested
1529  if (doOutputOnStdout)
1530  {
1531  edm::LogInfo("Alignment")
1532  << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1533  << "a: " << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3]
1534  << " S= " << sqrt(a[2]*a[2]+a[3]*a[3])
1535  << " phi= " << atan(a[3]/a[2])
1536  << " chi2= " << chi2 << std::endl;
1537  }
1538  if (theMonitor)
1539  {
1540  theMonitor->fillPxbSurveyHistsChi2(chi2);
1541  theMonitor->fillPxbSurveyHistsLocalPars(a[0],a[1],sqrt(a[2]*a[2]+a[3]*a[3]),atan(a[3]/a[2]));
1542  }
1543 
1544  // pass the results from the local fit to mille
1546  {
1547  theMille->mille((int)measurements[i].getLocalDerivsSize(),
1548  measurements[i].getLocalDerivsPtr(j),
1549  (int)measurements[i].getGlobalDerivsSize(),
1550  measurements[i].getGlobalDerivsPtr(j),
1551  measurements[i].getGlobalDerivsLabelPtr(j),
1552  measurements[i].getResiduum(j),
1553  measurements[i].getSigma(j));
1554  }
1555  theMille->end();
1556  }
1557  outfile.close();
1558 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::unique_ptr< MillePedeMonitor > theMonitor
std::vector< coord_t > fidpoint_t
std::shared_ptr< PedeLabelerBase > thePedeLabels
uint16_t size_type
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
T sqrt(T t)
Definition: SSEVec.h:18
int j
Definition: DBlmapReader.cc:9
Class to hold one picture of the BPix survey.
std::vector< value_t > localpars_t
double a
Definition: hdecay.h:121
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
tuple filename
Definition: lut2db_cfg.py:20
static const count_t nMsrmts
std::string fullPath() const
Definition: FileInPath.cc:184
std::unique_ptr< AlignableNavigator > theAlignableNavigator
std::pair< unsigned int, unsigned int > MillePedeAlignmentAlgorithm::addReferenceTrajectory ( const edm::EventSetup setup,
const EventInfo eventInfo,
const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr 
)
private

fill mille for a trajectory, returning number of x/y hits ([0,0] if 'bad' trajectory)

Definition at line 470 of file MillePedeAlignmentAlgorithm.cc.

References addGlobalData(), addHitCount(), addMeasurementData(), addVirtualMeas(), gbl::GblTrajectory::milleOut(), theBinary, theMille, and theMinNumHits.

Referenced by run().

473 {
474  std::pair<unsigned int, unsigned int> hitResultXy(0,0);
475  if (refTrajPtr->isValid()) {
476 
477 
478  // GblTrajectory?
479  if (refTrajPtr->gblInput().size() > 0) {
480  // by construction: number of GblPoints == number of recHits or == zero !!!
481  unsigned int iHit = 0;
482  unsigned int numPointsWithMeas = 0;
483  std::vector<GblPoint>::iterator itPoint;
484  std::vector<std::pair<std::vector<GblPoint>, TMatrixD> > theGblInput = refTrajPtr->gblInput();
485  for (unsigned int iTraj = 0; iTraj < refTrajPtr->gblInput().size(); ++iTraj) {
486  for (itPoint = refTrajPtr->gblInput()[iTraj].first.begin(); itPoint < refTrajPtr->gblInput()[iTraj].first.end(); ++itPoint) {
487  if (this->addGlobalData(setup, eventInfo, refTrajPtr, iHit++, *itPoint) < 0) return hitResultXy;
488  if (itPoint->hasMeasurement() >= 1) ++numPointsWithMeas;
489  }
490  }
491  hitResultXy.first = numPointsWithMeas;
492  // check #hits criterion
493  if (hitResultXy.first == 0 || hitResultXy.first < theMinNumHits) return hitResultXy;
494  // construct GBL trajectory
495  if (refTrajPtr->gblInput().size() == 1) {
496  // from single track
497  GblTrajectory aGblTrajectory( refTrajPtr->gblInput()[0].first, refTrajPtr->nominalField() != 0 );
498  // GBL fit trajectory
499  /*double Chi2;
500  int Ndf;
501  double lostWeight;
502  aGblTrajectory.fit(Chi2, Ndf, lostWeight);
503  std::cout << " GblFit: " << Chi2 << ", " << Ndf << ", " << lostWeight << std::endl; */
504  // write to MP binary file
505  if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits) aGblTrajectory.milleOut(*theBinary);
506  }
507  if (refTrajPtr->gblInput().size() == 2) {
508  // from TwoBodyDecay
509  GblTrajectory aGblTrajectory( refTrajPtr->gblInput(), refTrajPtr->gblExtDerivatives(), refTrajPtr->gblExtMeasurements(), refTrajPtr->gblExtPrecisions() );
510  // write to MP binary file
511  if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits) aGblTrajectory.milleOut(*theBinary);
512  }
513  } else {
514  // to add hits if all fine:
515  std::vector<AlignmentParameters*> parVec(refTrajPtr->recHits().size());
516  // collect hit statistics, assuming that there are no y-only hits
517  std::vector<bool> validHitVecY(refTrajPtr->recHits().size(), false);
518  // Use recHits from ReferenceTrajectory (since they have the right order!):
519  for (unsigned int iHit = 0; iHit < refTrajPtr->recHits().size(); ++iHit) {
520  const int flagXY = this->addMeasurementData(setup, eventInfo, refTrajPtr, iHit, parVec[iHit]);
521 
522  if (flagXY < 0) { // problem
523  hitResultXy.first = 0;
524  break;
525  } else { // hit is fine, increase x/y statistics
526  if (flagXY >= 1) ++hitResultXy.first;
527  validHitVecY[iHit] = (flagXY >= 2);
528  }
529  } // end loop on hits
530 
531  // add virtual measurements
532  for (unsigned int iVirtualMeas = 0; iVirtualMeas < refTrajPtr->numberOfVirtualMeas(); ++iVirtualMeas) {
533  this->addVirtualMeas(refTrajPtr, iVirtualMeas);
534  }
535 
536  // kill or end 'track' for mille, depends on #hits criterion
537  if (hitResultXy.first == 0 || hitResultXy.first < theMinNumHits) {
538  theMille->kill();
539  hitResultXy.first = hitResultXy.second = 0; //reset
540  } else {
541  theMille->end();
542  // add x/y hit count to MillePedeVariables of parVec,
543  // returning number of y-hits of the reference trajectory
544  hitResultXy.second = this->addHitCount(parVec, validHitVecY);
545  //
546  }
547  }
548 
549  } // end if valid trajectory
550 
551  return hitResultXy;
552 }
GBL trajectory.
Definition: GblTrajectory.h:26
std::unique_ptr< gbl::MilleBinary > theBinary
int addGlobalData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, gbl::GblPoint &gblPoint)
unsigned int addHitCount(const std::vector< AlignmentParameters * > &parVec, const std::vector< bool > &validHitVecY) const
int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, AlignmentParameters *&params)
void addVirtualMeas(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas)
adds data for virtual measurements from reference trajectory
void milleOut(MilleBinary &aMille)
Write valid trajectory to Millepede-II binary file.
void MillePedeAlignmentAlgorithm::addRefTrackData2D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iTrajHit,
TMatrixDSym &  aHitCovarianceM,
TMatrixF &  aHitResidualsM,
TMatrixF &  aLocalDerivativesM 
)
private

adds data from reference trajectory from a specific Hit

Definition at line 1194 of file MillePedeAlignmentAlgorithm.cc.

References i.

1197 {
1198  // This Method is valid for 2D measurements only
1199 
1200  const unsigned int xIndex = iTrajHit*2;
1201  const unsigned int yIndex = iTrajHit*2+1;
1202  // Covariance into a TMatrixDSym
1203 
1204  //aHitCovarianceM = new TMatrixDSym(2);
1205  aHitCovarianceM(0,0)=refTrajPtr->measurementErrors()[xIndex][xIndex];
1206  aHitCovarianceM(0,1)=refTrajPtr->measurementErrors()[xIndex][yIndex];
1207  aHitCovarianceM(1,0)=refTrajPtr->measurementErrors()[yIndex][xIndex];
1208  aHitCovarianceM(1,1)=refTrajPtr->measurementErrors()[yIndex][yIndex];
1209 
1210  //theHitResidualsM= new TMatrixF(2,1);
1211  aHitResidualsM(0,0)= refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
1212  aHitResidualsM(1,0)= refTrajPtr->measurements()[yIndex] - refTrajPtr->trajectoryPositions()[yIndex];
1213 
1214  // Local Derivatives into a TMatrixDSym (to use matrix operations)
1215  const AlgebraicMatrix &locDerivMatrix = refTrajPtr->derivatives();
1216  // theLocalDerivativeNumber = locDerivMatrix.num_col();
1217 
1218  //theLocalDerivativesM = new TMatrixF(2,locDerivMatrix.num_col());
1219  for (int i = 0; i < locDerivMatrix.num_col(); ++i) {
1220  aLocalDerivativesM(0,i) = locDerivMatrix[xIndex][i];
1221  aLocalDerivativesM(1,i) = locDerivMatrix[yIndex][i];
1222  }
1223 }
int i
Definition: DBlmapReader.cc:9
CLHEP::HepMatrix AlgebraicMatrix
void MillePedeAlignmentAlgorithm::addRefTrackVirtualMeas1D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iVirtualMeas,
TMatrixDSym &  aHitCovarianceM,
TMatrixF &  aHitResidualsM,
TMatrixF &  aLocalDerivativesM 
)
private

adds data for a specific virtual measurement from reference trajectory

Definition at line 1167 of file MillePedeAlignmentAlgorithm.cc.

References i.

1170 {
1171  // This Method is valid for 1D measurements only
1172 
1173  const unsigned int xIndex = iVirtualMeas + refTrajPtr->numberOfHitMeas();
1174  // Covariance into a TMatrixDSym
1175 
1176  //aHitCovarianceM = new TMatrixDSym(1);
1177  aHitCovarianceM(0,0)=refTrajPtr->measurementErrors()[xIndex][xIndex];
1178 
1179  //theHitResidualsM= new TMatrixF(1,1);
1180  aHitResidualsM(0,0)= refTrajPtr->measurements()[xIndex];
1181 
1182  // Local Derivatives into a TMatrixDSym (to use matrix operations)
1183  const AlgebraicMatrix &locDerivMatrix = refTrajPtr->derivatives();
1184  // theLocalDerivativeNumber = locDerivMatrix.num_col();
1185 
1186  //theLocalDerivativesM = new TMatrixF(1,locDerivMatrix.num_col());
1187  for (int i = 0; i < locDerivMatrix.num_col(); ++i) {
1188  aLocalDerivativesM(0,i) = locDerivMatrix[xIndex][i];
1189  }
1190 }
int i
Definition: DBlmapReader.cc:9
CLHEP::HepMatrix AlgebraicMatrix
void MillePedeAlignmentAlgorithm::addVirtualMeas ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iVirtualMeas 
)
private

adds data for virtual measurements from reference trajectory

Definition at line 1371 of file MillePedeAlignmentAlgorithm.cc.

Referenced by addReferenceTrajectory().

1372 {
1373  TMatrixDSym aHitCovarianceM(1);
1374  TMatrixF aHitResidualsM(1,1);
1375  TMatrixF aLocalDerivativesM(1, refTrajPtr->derivatives().num_col());
1376  // below method fills above 3 'matrices'
1377  this->addRefTrackVirtualMeas1D(refTrajPtr, iVirtualMeas, aHitCovarianceM, aHitResidualsM, aLocalDerivativesM);
1378 
1379  // no global parameters (use dummy 0)
1380  TMatrixF aGlobalDerivativesM(1,1);
1381  aGlobalDerivativesM(0,0) = 0;
1382 
1383  float newResidX = aHitResidualsM(0,0);
1384  float newHitErrX = TMath::Sqrt(aHitCovarianceM(0,0));
1385  float *newLocalDerivsX = aLocalDerivativesM[0].GetPtr();
1386  float *newGlobDerivsX = aGlobalDerivativesM[0].GetPtr();
1387  const int nLocal = aLocalDerivativesM.GetNcols();
1388  const int nGlobal = 0;
1389 
1390  theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX,
1391  &nGlobal, newResidX, newHitErrX);
1392 }
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
bool MillePedeAlignmentAlgorithm::areEmptyParams ( const std::vector< Alignable * > &  alignables) const
private

Definition at line 945 of file MillePedeAlignmentAlgorithm.cc.

References AlignmentParameters::covariance(), i, j, and AlignmentParameters::parameters().

Referenced by readFromPede().

946 {
947 
948  for (std::vector<Alignable*>::const_iterator iAli = alignables.begin();
949  iAli != alignables.end(); ++iAli) {
950  const AlignmentParameters *params = (*iAli)->alignmentParameters();
951  if (params) {
952  const auto& parVec(params->parameters());
953  const auto& parCov(params->covariance());
954  for (int i = 0; i < parVec.num_row(); ++i) {
955  if (parVec[i] != 0.) return false;
956  for (int j = i; j < parCov.num_col(); ++j) {
957  if (parCov[i][j] != 0.) return false;
958  }
959  }
960  }
961  }
962 
963  return true;
964 }
int i
Definition: DBlmapReader.cc:9
const AlgebraicVector & parameters(void) const
Get alignment parameters.
int j
Definition: DBlmapReader.cc:9
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
void MillePedeAlignmentAlgorithm::beginLuminosityBlock ( const edm::EventSetup )
overridevirtual

called at begin of luminosity block (resets Mille binary in mille mode)

Reimplemented from AlignmentAlgorithmBase.

Definition at line 602 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), myMilleBit, runAtPCL_, and theMille.

603 {
604  if (!runAtPCL_) return;
605  if(this->isMode(myMilleBit)) theMille->resetOutputFile();
606 }
bool isMode(unsigned int testMode) const
void MillePedeAlignmentAlgorithm::buildUserVariables ( const std::vector< Alignable * > &  alignables) const
private

add MillePedeVariables for each AlignmentParameters (exception if no parameters...)

Definition at line 1027 of file MillePedeAlignmentAlgorithm.cc.

References Exception, MillePedeVariables::setAllDefault(), AlignmentParameters::setUserVariables(), MillePedeVariables::size(), AlignmentParameters::size(), thePedeLabels, and AlignmentParameters::userVariables().

Referenced by initialize(), and setParametersForRunRange().

1028 {
1029  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
1030  AlignmentParameters *params = (*iAli)->alignmentParameters();
1031  if (!params) {
1032  throw cms::Exception("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::buildUserVariables"
1033  << "No parameters for alignable";
1034  }
1035  MillePedeVariables *userVars = dynamic_cast<MillePedeVariables*>(params->userVariables());
1036  if (userVars) { // Just re-use existing, keeping label and numHits:
1037  for (unsigned int iPar = 0; iPar < userVars->size(); ++iPar) {
1038  // if (params->hierarchyLevel() > 0) {
1039  //std::cout << params->hierarchyLevel() << "\nBefore: " << userVars->parameter()[iPar];
1040  // }
1041  userVars->setAllDefault(iPar);
1042  //std::cout << "\nAfter: " << userVars->parameter()[iPar] << std::endl;
1043  }
1044  } else { // Nothing yet or erase wrong type:
1045  userVars = new MillePedeVariables(params->size(), thePedeLabels->alignableLabel(*iAli));
1046  params->setUserVariables(userVars);
1047  }
1048  }
1049 }
unsigned int size() const
number of parameters
std::shared_ptr< PedeLabelerBase > thePedeLabels
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
int size(void) const
Get number of parameters.
bool setAllDefault(unsigned int nParam)
set default values for all data concerning nParam (false if nParam out of range)
int MillePedeAlignmentAlgorithm::callMille ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iTrajHit,
const std::vector< int > &  globalLabels,
const std::vector< float > &  globalDerivativesX,
const std::vector< float > &  globalDerivativesY 
)
private

calls callMille1D or callMille2D

Definition at line 1227 of file MillePedeAlignmentAlgorithm.cc.

Referenced by addMeasurementData().

1231 {
1232  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1233 
1234  if((aRecHit)->dimension() == 1) {
1235  return this->callMille1D(refTrajPtr, iTrajHit, globalLabels, globalDerivativesX);
1236  } else {
1237  return this->callMille2D(refTrajPtr, iTrajHit, globalLabels,
1238  globalDerivativesX, globalDerivativesY);
1239  }
1240 }
int callMille2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy)
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
int callMille1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, const std::vector< int > &globalLabels, const std::vector< float > &globalDerivativesX)
calls Mille for 1D hits
int MillePedeAlignmentAlgorithm::callMille1D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iTrajHit,
const std::vector< int > &  globalLabels,
const std::vector< float > &  globalDerivativesX 
)
private

calls Mille for 1D hits

Definition at line 1245 of file MillePedeAlignmentAlgorithm.cc.

References i.

1248 {
1249  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1250  const unsigned int xIndex = iTrajHit*2; // the even ones are local x
1251 
1252  // local derivatives
1253  const AlgebraicMatrix &locDerivMatrix = refTrajPtr->derivatives();
1254  const int nLocal = locDerivMatrix.num_col();
1255  std::vector<float> localDerivatives(nLocal);
1256  for (unsigned int i = 0; i < localDerivatives.size(); ++i) {
1257  localDerivatives[i] = locDerivMatrix[xIndex][i];
1258  }
1259 
1260  // residuum and error
1261  float residX = refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
1262  float hitErrX = TMath::Sqrt(refTrajPtr->measurementErrors()[xIndex][xIndex]);
1263 
1264  // number of global derivatives
1265  const int nGlobal = globalDerivativesX.size();
1266 
1267  // &(localDerivatives[0]) etc. are valid - as long as vector is not empty
1268  // cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
1269  theMille->mille(nLocal, &(localDerivatives[0]), nGlobal, &(globalDerivativesX[0]),
1270  &(globalLabels[0]), residX, hitErrX);
1271 
1272  if (theMonitor) {
1273  theMonitor->fillDerivatives(aRecHit, &(localDerivatives[0]), nLocal,
1274  &(globalDerivativesX[0]), nGlobal, &(globalLabels[0]));
1275  theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
1276  iTrajHit, residX, hitErrX, false);
1277  }
1278 
1279  return 1;
1280 }
int i
Definition: DBlmapReader.cc:9
std::unique_ptr< MillePedeMonitor > theMonitor
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
CLHEP::HepMatrix AlgebraicMatrix
int MillePedeAlignmentAlgorithm::callMille2D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iTrajHit,
const std::vector< int > &  globalLabels,
const std::vector< float > &  globalDerivativesx,
const std::vector< float > &  globalDerivativesy 
)
private

calls Mille for x and possibly y component of hit, y is skipped for non-real 2D (e.g. SiStripRecHit2D), for TID/TEC first diagonalises if correlation is larger than configurable

Definition at line 1284 of file MillePedeAlignmentAlgorithm.cc.

References Abs(), corr, pat::helper::ParametrizationHelper::dimension(), fastTrackerRecHitType::is2D(), mathSSE::sqrt(), std::swap(), SiStripDetId::TEC, SiStripDetId::TID, and DetId::Tracker.

1288 {
1289  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1290 
1291  if((aRecHit)->dimension() != 2) {
1292  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::callMille2D"
1293  << "You try to call method for 2D hits for a "
1294  << (aRecHit)->dimension()
1295  << "D Hit. Hit gets ignored!";
1296  return -1;
1297  }
1298 
1299  TMatrixDSym aHitCovarianceM(2);
1300  TMatrixF aHitResidualsM(2,1);
1301  TMatrixF aLocalDerivativesM(2, refTrajPtr->derivatives().num_col());
1302  // below method fills above 3 matrices
1303  this->addRefTrackData2D(refTrajPtr, iTrajHit, aHitCovarianceM,aHitResidualsM,aLocalDerivativesM);
1304  TMatrixF aGlobalDerivativesM(2,globalDerivativesx.size());
1305  this->makeGlobDerivMatrix(globalDerivativesx, globalDerivativesy, aGlobalDerivativesM);
1306 
1307  // calculates correlation between Hit measurements
1308  // FIXME: Should take correlation (and resulting transformation) from original hit,
1309  // not 2x2 matrix from ReferenceTrajectory: That can come from error propagation etc.!
1310  const double corr = aHitCovarianceM(0,1) / sqrt(aHitCovarianceM(0,0) * aHitCovarianceM(1,1));
1311  if (theMonitor) theMonitor->fillCorrelations2D(corr, aRecHit);
1312  bool diag = false; // diagonalise only tracker TID, TEC
1313  switch(aRecHit->geographicalId().subdetId()) {
1314  case SiStripDetId::TID:
1315  case SiStripDetId::TEC:
1316  if (aRecHit->geographicalId().det() == DetId::Tracker && TMath::Abs(corr) > theMaximalCor2D) {
1317  this->diagonalize(aHitCovarianceM, aLocalDerivativesM, aHitResidualsM, aGlobalDerivativesM);
1318  diag = true;
1319  }
1320  break;
1321  default:;
1322  }
1323 
1324  float newResidX = aHitResidualsM(0,0);
1325  float newResidY = aHitResidualsM(1,0);
1326  float newHitErrX = TMath::Sqrt(aHitCovarianceM(0,0));
1327  float newHitErrY = TMath::Sqrt(aHitCovarianceM(1,1));
1328  float *newLocalDerivsX = aLocalDerivativesM[0].GetPtr();
1329  float *newLocalDerivsY = aLocalDerivativesM[1].GetPtr();
1330  float *newGlobDerivsX = aGlobalDerivativesM[0].GetPtr();
1331  float *newGlobDerivsY = aGlobalDerivativesM[1].GetPtr();
1332  const int nLocal = aLocalDerivativesM.GetNcols();
1333  const int nGlobal = aGlobalDerivativesM.GetNcols();
1334 
1335  if (diag && (newHitErrX > newHitErrY)) { // also for 2D hits?
1336  // measurement with smaller error is x-measurement (for !is2D do not fill y-measurement):
1337  std::swap(newResidX, newResidY);
1338  std::swap(newHitErrX, newHitErrY);
1339  std::swap(newLocalDerivsX, newLocalDerivsY);
1340  std::swap(newGlobDerivsX, newGlobDerivsY);
1341  }
1342 
1343  // &(globalLabels[0]) is valid - as long as vector is not empty
1344  // cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
1345  theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX,
1346  &(globalLabels[0]), newResidX, newHitErrX);
1347 
1348  if (theMonitor) {
1349  theMonitor->fillDerivatives(aRecHit, newLocalDerivsX, nLocal, newGlobDerivsX, nGlobal,
1350  &(globalLabels[0]));
1351  theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
1352  iTrajHit, newResidX, newHitErrX, false);
1353  }
1354  const bool isReal2DHit = this->is2D(aRecHit); // strip is 1D (except matched hits)
1355  if (isReal2DHit) {
1356  theMille->mille(nLocal, newLocalDerivsY, nGlobal, newGlobDerivsY,
1357  &(globalLabels[0]), newResidY, newHitErrY);
1358  if (theMonitor) {
1359  theMonitor->fillDerivatives(aRecHit, newLocalDerivsY, nLocal, newGlobDerivsY, nGlobal,
1360  &(globalLabels[0]));
1361  theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit],
1362  iTrajHit, newResidY, newHitErrY, true);// true: y
1363  }
1364  }
1365 
1366  return (isReal2DHit ? 2 : 1);
1367 }
std::unique_ptr< MillePedeMonitor > theMonitor
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:18
T Abs(T a)
Definition: MathUtil.h:49
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
JetCorrectorParameters corr
Definition: classes.h:5
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 makeGlobDerivMatrix(const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, TMatrixF &aGlobalDerivativesM)
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
unsigned int MillePedeAlignmentAlgorithm::decodeMode ( const std::string &  mode) const
private

Definition at line 1052 of file MillePedeAlignmentAlgorithm.cc.

References Exception, myMilleBit, myPedeReadBit, myPedeRunBit, and myPedeSteerBit.

1053 {
1054  if (mode == "full") {
1056  } else if (mode == "mille") {
1057  return myMilleBit; // + myPedeSteerBit; // sic! Including production of steerig file. NO!
1058  } else if (mode == "pede") {
1060  } else if (mode == "pedeSteer") {
1061  return myPedeSteerBit;
1062  } else if (mode == "pedeRun") {
1063  return myPedeSteerBit + myPedeRunBit + myPedeReadBit; // sic! Including steering and reading of result.
1064  } else if (mode == "pedeRead") {
1065  return myPedeReadBit;
1066  }
1067 
1068  throw cms::Exception("BadConfig")
1069  << "Unknown mode '" << mode
1070  << "', use 'full', 'mille', 'pede', 'pedeRun', 'pedeSteer' or 'pedeRead'.";
1071 
1072  return 0;
1073 }
void MillePedeAlignmentAlgorithm::diagonalize ( TMatrixDSym &  aHitCovarianceM,
TMatrixF &  aLocalDerivativesM,
TMatrixF &  aHitResidualsM,
TMatrixF &  theGlobalDerivativesM 
) const
private

Definition at line 1139 of file MillePedeAlignmentAlgorithm.cc.

1141 {
1142  TMatrixDSymEigen myDiag(aHitCovarianceM);
1143  TMatrixD aTranfoToDiagonalSystem = myDiag.GetEigenVectors();
1144  TMatrixD aTranfoToDiagonalSystemInv = myDiag.GetEigenVectors( );
1145  TMatrixF aTranfoToDiagonalSystemInvF = myDiag.GetEigenVectors( );
1146  TMatrixD aMatrix = aTranfoToDiagonalSystemInv.Invert() * aHitCovarianceM * aTranfoToDiagonalSystem;
1147  // Tranformation of matrix M is done by A^T*M*A, not A^{-1}*M*A.
1148  // But here A^T == A^{-1}, so we would only save CPU by Transpose()...
1149  // FIXME this - I guess simply use T(), not Transpose()...
1150  // TMatrixD aMatrix = aTranfoToDiagonalSystemInv.Transpose() * aHitCovarianceM
1151  // * aTranfoToDiagonalSystem;
1152  aHitCovarianceM = TMatrixDSym(2, aMatrix.GetMatrixArray());
1153  aTranfoToDiagonalSystemInvF.Invert();
1154  //edm::LogInfo("Alignment") << "NEW HIT loca in matrix"<<aLocalDerivativesM(0,0);
1155  aLocalDerivativesM = aTranfoToDiagonalSystemInvF * aLocalDerivativesM;
1156 
1157  //edm::LogInfo("Alignment") << "NEW HIT loca in matrix after diag:"<<aLocalDerivativesM(0,0);
1158  aHitResidualsM = aTranfoToDiagonalSystemInvF * aHitResidualsM;
1159  if (aGlobalDerivativesM.GetNoElements() > 0) {
1160  // diagnoalize only if measurement depends on alignables or calibrations
1161  aGlobalDerivativesM = aTranfoToDiagonalSystemInvF * aGlobalDerivativesM;
1162  }
1163 }
unsigned int MillePedeAlignmentAlgorithm::doIO ( int  loop) const
private

Definition at line 967 of file MillePedeAlignmentAlgorithm.cc.

References addHitStatistics(), edm::ParameterSet::getParameter(), cmsHarvester::loop, produceTPGParameters_beamv6_transparency_spikekill_2016_script::outFile, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, theAlignables, theConfig, theDir, AlignmentIORoot::writeAlignableAbsolutePositions(), AlignmentIORoot::writeAlignableOriginalPositions(), MillePedeVariablesIORoot::writeMillePedeVariables(), and AlignmentIORoot::writeOrigRigidBodyAlignmentParameters().

Referenced by setParametersForRunRange(), and terminate().

968 {
969  unsigned int result = 0;
970 
971  const std::string outFilePlain(theConfig.getParameter<std::string>("treeFile"));
972  if (outFilePlain.empty()) {
973  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
974  << "treeFile parameter empty => skip writing for 'loop' " << loop;
975  return result;
976  }
977 
978  const std::string outFile(theDir + outFilePlain);
979 
980  AlignmentIORoot aliIO;
981  int ioerr = 0;
982  if (loop == 0) {
983  aliIO.writeAlignableOriginalPositions(theAlignables, outFile.c_str(), loop, false, ioerr);
984  if (ioerr) {
985  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
986  << "Problem " << ioerr << " in writeAlignableOriginalPositions";
987  ++result;
988  }
989  } else if (loop == 1) {
990  // only for first iov add hit counts, else 2x, 3x,... number of hits in IOV 2, 3,...
991  const std::vector<std::string> inFiles
992  (theConfig.getParameter<std::vector<std::string> >("mergeTreeFiles"));
993  const std::vector<std::string> binFiles
994  (theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles"));
995  if (inFiles.size() != binFiles.size()) {
996  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
997  << "'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' "
998  << "differ in size";
999  }
1000  this->addHitStatistics(0, outFile, inFiles); // add hit info from tree 0 in 'infiles'
1001  }
1002  MillePedeVariablesIORoot millePedeIO;
1003  millePedeIO.writeMillePedeVariables(theAlignables, outFile.c_str(), loop, false, ioerr);
1004  if (ioerr) {
1005  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1006  << "Problem " << ioerr << " writing MillePedeVariables";
1007  ++result;
1008  }
1009 
1010  aliIO.writeOrigRigidBodyAlignmentParameters(theAlignables, outFile.c_str(), loop, false, ioerr);
1011  if (ioerr) {
1012  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO" << "Problem " << ioerr
1013  << " in writeOrigRigidBodyAlignmentParameters, " << loop;
1014  ++result;
1015  }
1016  aliIO.writeAlignableAbsolutePositions(theAlignables, outFile.c_str(), loop, false, ioerr);
1017  if (ioerr) {
1018  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO" << "Problem " << ioerr
1019  << " in writeAlignableAbsolutePositions, " << loop;
1020  ++result;
1021  }
1022 
1023  return result;
1024 }
T getParameter(std::string const &) const
std::vector< Alignable * > theAlignables
void writeAlignableOriginalPositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write Alignable original (before misalignment) absolute positions
int loop
CMSSW
tuple result
Definition: mps_fire.py:84
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
void writeAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write Alignable current absolute positions
void writeOrigRigidBodyAlignmentParameters(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
write RigidBodyAlignmentParameters as applied on top of original positions
void MillePedeAlignmentAlgorithm::endLuminosityBlock ( const edm::EventSetup )
overridevirtual

called at end of luminosity block

Reimplemented from AlignmentAlgorithmBase.

Definition at line 609 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), myMilleBit, runAtPCL_, and theMille.

610 {
611  if (!runAtPCL_) return;
612  if(this->isMode(myMilleBit)) theMille->flushOutputFile();
613 }
bool isMode(unsigned int testMode) const
void MillePedeAlignmentAlgorithm::endRun ( const EventInfo eventInfo,
const EndRunInfo runInfo,
const edm::EventSetup setup 
)
virtual

Run on run products, e.g. TkLAS.

Definition at line 586 of file MillePedeAlignmentAlgorithm.cc.

References addLaserData(), isMode(), myMilleBit, theMille, AlignmentAlgorithmBase::EndRunInfo::tkLasBeams(), and AlignmentAlgorithmBase::EndRunInfo::tkLasBeamTsoses().

588 {
589  if(runInfo.tkLasBeams() && runInfo.tkLasBeamTsoses()){
590  // LAS beam treatment
591  this->addLaserData(eventInfo, *(runInfo.tkLasBeams()), *(runInfo.tkLasBeamTsoses()));
592  }
593  if(this->isMode(myMilleBit)) theMille->flushOutputFile();
594 }
void addLaserData(const EventInfo &eventInfo, const TkFittedLasBeamCollection &tkLasBeams, const TsosVectorCollection &tkLasBeamTsoses)
bool isMode(unsigned int testMode) const
const TkFittedLasBeamCollection * tkLasBeams() const
const TsosVectorCollection * tkLasBeamTsoses() const
might be null!
void MillePedeAlignmentAlgorithm::endRun ( const EndRunInfo runInfo,
const edm::EventSetup setup 
)
overridevirtual

called at end of run - order of arguments like in EDProducer etc.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 597 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), myMilleBit, and theMille.

597  {
598  if(this->isMode(myMilleBit)) theMille->flushOutputFile();
599 }
bool isMode(unsigned int testMode) const
std::vector< std::string > MillePedeAlignmentAlgorithm::getExistingFormattedFiles ( const std::vector< std::string > &  plainFiles,
const std::string &  theDir 
)
private

Generates list of files to read, given the list and dir from the configuration. This will automatically expand formatting directives, if they appear.

Definition at line 391 of file MillePedeAlignmentAlgorithm.cc.

References MainPageGenerator::files, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by terminate().

391  {
392  std::vector<std::string> files;
393  for (const auto& plainFile: plainFiles) {
394  std::string theInputFileName = plainFile;
395  int theNumber = 0;
396  while (true) {
397  // Create a formatted version of the filename, with growing numbers
398  // If the parameter doesn't contain a formatting directive, it just stays unchanged
399  char theNumberedInputFileName[200];
400  sprintf(theNumberedInputFileName, theInputFileName.c_str(), theNumber);
401  std::string theCompleteInputFileName = theDir + theNumberedInputFileName;
402  const auto endOfStrippedFileName = theCompleteInputFileName.rfind(" --");
403  const auto strippedInputFileName = theCompleteInputFileName.substr(0, endOfStrippedFileName);
404  // Check if the file exists
405  struct stat buffer;
406  if (stat (strippedInputFileName.c_str(), &buffer) == 0) {
407  // If the file exists, add it to the list
408  files.push_back(theCompleteInputFileName);
409  if (theNumberedInputFileName == theInputFileName) {
410  // If the filename didn't contain a formatting directive, no reason to look any further, break out of the loop
411  break;
412  } else {
413  // Otherwise look for the next number
414  theNumber++;
415  }
416  } else {
417  // The file doesn't exist, break out of the loop
418  break;
419  }
420  }
421  // warning if unformatted (-> theNumber stays at 0) does not exist
422  if (theNumber == 0 && (files.size() == 0 || files.back() != plainFile)) {
423  edm::LogWarning("Alignment")
424  << "The input file '" << plainFile << "' does not exist.";
425  }
426  }
427  return files;
428 }
void MillePedeAlignmentAlgorithm::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
private

adding derivatives from integrated calibrations

Definition at line 834 of file MillePedeAlignmentAlgorithm.cc.

References theCalibrations, and thePedeLabels.

Referenced by addMeasurementData().

840 {
841  std::vector<IntegratedCalibrationBase::ValuesIndexPair> derivs;
842  for (auto iCalib = theCalibrations.begin(); iCalib != theCalibrations.end(); ++iCalib) {
843  // get all derivatives of this calibration // const unsigned int num =
844  (*iCalib)->derivatives(derivs, *recHit, tsos, setup, eventInfo);
845  for (auto iValuesInd = derivs.begin(); iValuesInd != derivs.end(); ++iValuesInd) {
846  // transfer label and x/y derivatives
847  globalLabels.push_back(thePedeLabels->calibrationLabel(*iCalib, iValuesInd->second));
848  globalDerivativesX.push_back(iValuesInd->first.first);
849  globalDerivativesY.push_back(iValuesInd->first.second);
850  }
851  }
852 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::vector< IntegratedCalibrationBase * > theCalibrations
bool MillePedeAlignmentAlgorithm::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
private

recursively adding derivatives and labels, false if problems

Definition at line 716 of file MillePedeAlignmentAlgorithm.cc.

References Alignable::alignmentParameters(), AlignmentParameters::derivatives(), Alignable::mother(), and AlignmentParameters::selector().

Referenced by addGlobalData(), addLasBeam(), and addMeasurementData().

723 {
724  // derivatives and labels are recursively attached
725  if (!ali) return true; // no mother might be OK
726 
727  if (false && theMonitor && alidet != ali) theMonitor->fillFrameToFrame(alidet, ali);
728 
729  AlignmentParameters *params = ali->alignmentParameters();
730 
731  if (params) {
732  if (!lowestParams) lowestParams = params; // set parameters of lowest level
733 
734  bool hasSplitParameters = thePedeLabels->hasSplitParameters(ali);
735  const unsigned int alignableLabel = thePedeLabels->alignableLabel(ali);
736 
737  if (0 == alignableLabel) { // FIXME: what about regardAllHits in Markus' code?
738  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
739  << "Label not found, skip Alignable.";
740  return false;
741  }
742 
743  const std::vector<bool> &selPars = params->selector();
744  const AlgebraicMatrix derivs(params->derivatives(tsos, alidet));
745 
746  // cols: 2, i.e. x&y, rows: parameters, usually RigidBodyAlignmentParameters::N_PARAM
747  for (unsigned int iSel = 0; iSel < selPars.size(); ++iSel) {
748  if (selPars[iSel]) {
749  globalDerivativesX.push_back(derivs[iSel][kLocalX]
750  /thePedeSteer->cmsToPedeFactor(iSel));
751  if (hasSplitParameters==true) {
752  globalLabels.push_back(thePedeLabels->parameterLabel(ali, iSel, eventInfo, tsos));
753  } else {
754  globalLabels.push_back(thePedeLabels->parameterLabel(alignableLabel, iSel));
755  }
756  globalDerivativesY.push_back(derivs[iSel][kLocalY]
757  /thePedeSteer->cmsToPedeFactor(iSel));
758  }
759  }
760  // Exclude mothers if Alignable selected to be no part of a hierarchy:
761  if (thePedeSteer->isNoHiera(ali)) return true;
762  }
763  // Call recursively for mother, will stop if mother == 0:
764  return this->globalDerivativesHierarchy(eventInfo,
765  tsos, ali->mother(), alidet,
766  globalDerivativesX, globalDerivativesY,
767  globalLabels, lowestParams);
768 }
std::unique_ptr< MillePedeMonitor > theMonitor
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
std::shared_ptr< PedeLabelerBase > thePedeLabels
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
CLHEP::HepMatrix AlgebraicMatrix
std::unique_ptr< PedeSteerer > thePedeSteer
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:90
bool MillePedeAlignmentAlgorithm::globalDerivativesHierarchy ( const EventInfo eventInfo,
const TrajectoryStateOnSurface tsos,
Alignable ali,
const AlignableDetOrUnitPtr alidet,
std::vector< double > &  globalDerivativesX,
std::vector< double > &  globalDerivativesY,
std::vector< int > &  globalLabels,
AlignmentParameters *&  lowestParams 
) const
private

recursively adding derivatives (double) and labels, false if problems

Definition at line 772 of file MillePedeAlignmentAlgorithm.cc.

References Alignable::alignmentParameters(), AlignmentParameters::derivatives(), Alignable::mother(), and AlignmentParameters::selector().

779 {
780  // derivatives and labels are recursively attached
781  if (!ali) return true; // no mother might be OK
782 
783  if (false && theMonitor && alidet != ali) theMonitor->fillFrameToFrame(alidet, ali);
784 
785  AlignmentParameters *params = ali->alignmentParameters();
786 
787  if (params) {
788  if (!lowestParams) lowestParams = params; // set parameters of lowest level
789 
790  bool hasSplitParameters = thePedeLabels->hasSplitParameters(ali);
791  const unsigned int alignableLabel = thePedeLabels->alignableLabel(ali);
792 
793  if (0 == alignableLabel) { // FIXME: what about regardAllHits in Markus' code?
794  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
795  << "Label not found, skip Alignable.";
796  return false;
797  }
798 
799  const std::vector<bool> &selPars = params->selector();
800  const AlgebraicMatrix derivs(params->derivatives(tsos, alidet));
801  int globalLabel;
802 
803  // cols: 2, i.e. x&y, rows: parameters, usually RigidBodyAlignmentParameters::N_PARAM
804  for (unsigned int iSel = 0; iSel < selPars.size(); ++iSel) {
805  if (selPars[iSel]) {
806  if (hasSplitParameters==true) {
807  globalLabel = thePedeLabels->parameterLabel(ali, iSel, eventInfo, tsos);
808  } else {
809  globalLabel = thePedeLabels->parameterLabel(alignableLabel, iSel);
810  }
811  if (globalLabel > 0 && globalLabel <= 2147483647) {
812  globalLabels.push_back(globalLabel);
813  globalDerivativesX.push_back(derivs[iSel][kLocalX] / thePedeSteer->cmsToPedeFactor(iSel));
814  globalDerivativesY.push_back(derivs[iSel][kLocalY] / thePedeSteer->cmsToPedeFactor(iSel));
815  } else {
816  edm::LogError("Alignment")
817  << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
818  << "Invalid label " << globalLabel << " <= 0 or > 2147483647";
819  }
820  }
821  }
822  // Exclude mothers if Alignable selected to be no part of a hierarchy:
823  if (thePedeSteer->isNoHiera(ali)) return true;
824  }
825  // Call recursively for mother, will stop if mother == 0:
826  return this->globalDerivativesHierarchy(eventInfo,
827  tsos, ali->mother(), alidet,
828  globalDerivativesX, globalDerivativesY,
829  globalLabels, lowestParams);
830 }
std::unique_ptr< MillePedeMonitor > theMonitor
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
std::shared_ptr< PedeLabelerBase > thePedeLabels
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
CLHEP::HepMatrix AlgebraicMatrix
std::unique_ptr< PedeSteerer > thePedeSteer
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:90
void MillePedeAlignmentAlgorithm::initialize ( const edm::EventSetup setup,
AlignableTracker tracker,
AlignableMuon muon,
AlignableExtras extras,
AlignmentParameterStore store 
)
overridevirtual

Called at beginning of job.

Implements AlignmentAlgorithmBase.

Definition at line 122 of file MillePedeAlignmentAlgorithm.cc.

References addPxbSurvey(), edm::ParameterSet::addUntrackedParameter(), cond::TimeTypeSpecs::beginValue, buildUserVariables(), relativeConstraints::empty, cond::TimeTypeSpecs::endValue, Exception, edm::ParameterSet::exists(), reco::get(), edm::EventSetup::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isMode(), relval_steps::key, cond::time::MAX_VAL(), cond::time::MIN_VAL(), metsig::muon, myMilleBit, myPedeSteerBit, edm::ESHandle< class >::product(), readFromPede(), runAtPCL_, cond::runnumber, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, theAlignableNavigator, theAlignables, theAlignmentParameterStore, theConfig, theDir, theDoSurveyPixelBarrel, theMonitor, thePedeLabels, thePedeSteer, theTrajectoryFactory, cond::timeTypeSpecs, and patCandidatesForDimuonsSequences_cff::tracker.

125 {
126  if (muon) {
127  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
128  << "Running with AlignabeMuon not yet tested.";
129  }
130 
131  // temporary fix to avoid corrupted database output
132  if (!runAtPCL_) {
135  const auto& iov_alignments =
136  setup.get<TrackerAlignmentRcd>().validityInterval();
137  const auto& iov_surfaces =
138  setup.get<TrackerSurfaceDeformationRcd>().validityInterval();
139  const auto& iov_errors =
140  setup.get<TrackerAlignmentErrorExtendedRcd>().validityInterval();
141  if (iov_alignments.first().eventID().run() != MIN_VAL ||
142  iov_alignments.last().eventID().run() != MAX_VAL) {
143  throw cms::Exception("DatabaseError")
144  << "@SUB=MillePedeAlignmentAlgorithm::initialize"
145  << "\nTrying to apply " << setup.get<TrackerAlignmentRcd>().key().name()
146  << " with multiple IOVs in tag.\n"
147  << "Validity range is "
148  << iov_alignments.first().eventID().run() << " - "
149  << iov_alignments.last().eventID().run();
150  }
151  if (iov_surfaces.first().eventID().run() != MIN_VAL ||
152  iov_surfaces.last().eventID().run() != MAX_VAL) {
153  throw cms::Exception("DatabaseError")
154  << "@SUB=MillePedeAlignmentAlgorithm::initialize"
155  << "\nTrying to apply "
156  << setup.get<TrackerSurfaceDeformationRcd>().key().name()
157  << " with multiple IOVs in tag.\n"
158  << "Validity range is "
159  << iov_surfaces.first().eventID().run() << " - "
160  << iov_surfaces.last().eventID().run();
161  }
162  if (iov_errors.first().eventID().run() != MIN_VAL ||
163  iov_errors.last().eventID().run() != MAX_VAL) {
164  throw cms::Exception("DatabaseError")
165  << "@SUB=MillePedeAlignmentAlgorithm::initialize"
166  << "\nTrying to apply "
167  << setup.get<TrackerAlignmentErrorExtendedRcd>().key().name()
168  << " with multiple IOVs in tag.\n"
169  << "Validity range is "
170  << iov_errors.first().eventID().run() << " - "
171  << iov_errors.last().eventID().run();
172  }
173  }
174 
175 
176  //Retrieve tracker topology from geometry
177  edm::ESHandle<TrackerTopology> tTopoHandle;
178  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
179  const TrackerTopology* const tTopo = tTopoHandle.product();
180 
181  theAlignableNavigator = std::make_unique<AlignableNavigator>(extras, tracker, muon);
183  theAlignables = theAlignmentParameterStore->alignables();
184 
185  edm::ParameterSet pedeLabelerCfg(theConfig.getParameter<edm::ParameterSet>("pedeLabeler"));
186  edm::VParameterSet RunRangeSelectionVPSet(theConfig.getUntrackedParameter<edm::VParameterSet>("RunRangeSelection"));
187  pedeLabelerCfg.addUntrackedParameter<edm::VParameterSet>("RunRangeSelection",
188  RunRangeSelectionVPSet);
189 
190  std::string labelerPlugin = "PedeLabeler";
191  if (RunRangeSelectionVPSet.size()>0) {
192  labelerPlugin = "RunRangeDependentPedeLabeler";
193  if (pedeLabelerCfg.exists("plugin")) {
194  std::string labelerPluginCfg = pedeLabelerCfg.getParameter<std::string>("plugin");
195  if ((labelerPluginCfg!="PedeLabeler" && labelerPluginCfg!="RunRangeDependentPedeLabeler") ||
196  pedeLabelerCfg.getUntrackedParameter<edm::VParameterSet>("parameterInstances").size()>0) {
197  throw cms::Exception("BadConfig")
198  << "MillePedeAlignmentAlgorithm::initialize"
199  << "both RunRangeSelection and generic labeler specified in config file. "
200  << "Please get rid of either one of them.\n";
201  }
202  }
203  } else {
204  if (pedeLabelerCfg.exists("plugin")) {
205  labelerPlugin = pedeLabelerCfg.getParameter<std::string>("plugin");
206  }
207  }
208 
209  if (!pedeLabelerCfg.exists("plugin")) {
210  pedeLabelerCfg.addUntrackedParameter<std::string>("plugin", labelerPlugin);
211  }
212 
213  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
214  << "Using plugin '" << labelerPlugin << "' to generate labels.";
215 
216  thePedeLabels = std::shared_ptr<PedeLabelerBase>(PedeLabelerPluginFactory::get()
217  ->create(labelerPlugin,
218  PedeLabelerBase::TopLevelAlignables(tracker, muon, extras),
219  pedeLabelerCfg));
220 
221  // 1) Create PedeSteerer: correct alignable positions for coordinate system selection
222  edm::ParameterSet pedeSteerCfg(theConfig.getParameter<edm::ParameterSet>("pedeSteerer"));
223  thePedeSteer = std::make_unique<PedeSteerer>(tracker, muon, extras,
225  pedeSteerCfg, theDir, !this->isMode(myPedeSteerBit));
226 
227  // 2) If requested, directly read in and apply result of previous pede run,
228  // assuming that correction from 1) was also applied to create the result:
229  const std::vector<edm::ParameterSet> mprespset
230  (theConfig.getParameter<std::vector<edm::ParameterSet> >("pedeReaderInputs"));
231  if (!mprespset.empty()) {
232  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
233  << "Apply " << mprespset.end() - mprespset.begin()
234  << " previous MillePede constants from 'pedeReaderInputs'.";
235  }
236 
237  // FIXME: add selection of run range via 'pedeReaderInputs'
238  // Note: Results for parameters of IntegratedCalibration's cannot be treated...
239  RunRange runrange(cond::timeTypeSpecs[cond::runnumber].beginValue,
241  for (std::vector<edm::ParameterSet>::const_iterator iSet = mprespset.begin(), iE = mprespset.end();
242  iSet != iE; ++iSet) {
243  // This read will ignore calibrations as long as they are not yet passed to Millepede
244  // during/before initialize(..) - currently addCalibrations(..) is called later in AlignmentProducer
245  if (!this->readFromPede((*iSet), false, runrange)) { // false: do not erase SelectionUserVariables
246  throw cms::Exception("BadConfig")
247  << "MillePedeAlignmentAlgorithm::initialize: Problems reading input constants of "
248  << "pedeReaderInputs entry " << iSet - mprespset.begin() << '.';
249  }
250  theAlignmentParameterStore->applyParameters();
251  // Needed to shut up later warning from checkAliParams:
252  theAlignmentParameterStore->resetParameters();
253  }
254 
255  // 3) Now create steerings with 'final' start position:
256  thePedeSteer->buildSubSteer(tracker, muon, extras);
257 
258  // After (!) 1-3 of PedeSteerer which uses the SelectionUserVariables attached to the parameters:
259  this->buildUserVariables(theAlignables); // for hit statistics and/or pede result
260 
261  if (this->isMode(myMilleBit)) {
262  if (!theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles").empty() ||
263  !theConfig.getParameter<std::vector<std::string> >("mergeTreeFiles").empty()) {
264  throw cms::Exception("BadConfig")
265  << "'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' must be empty for "
266  << "modes running mille.";
267  }
268  const std::string moniFile(theConfig.getUntrackedParameter<std::string>("monitorFile"));
269  if (moniFile.size()) theMonitor = std::make_unique<MillePedeMonitor>(tTopo, (theDir + moniFile).c_str());
270 
271  // Get trajectory factory. In case nothing found, FrameWork will throw...
272  const edm::ParameterSet fctCfg(theConfig.getParameter<edm::ParameterSet>("TrajectoryFactory"));
273  const std::string fctName(fctCfg.getParameter<std::string>("TrajectoryFactoryName"));
274  theTrajectoryFactory = std::unique_ptr<TrajectoryFactoryBase>(TrajectoryFactoryPlugin::get()
275  ->create(fctName, fctCfg));
276  }
277 
278  if (this->isMode(myPedeSteerBit)) {
279  // Get config for survey and set flag accordingly
280  const edm::ParameterSet pxbSurveyCfg(theConfig.getParameter<edm::ParameterSet>("surveyPixelBarrel"));
281  theDoSurveyPixelBarrel = pxbSurveyCfg.getParameter<bool>("doSurvey");
282  if (theDoSurveyPixelBarrel) this->addPxbSurvey(pxbSurveyCfg);
283  }
284 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< MillePedeMonitor > theMonitor
Time_t beginValue
Definition: Time.h:45
std::vector< Alignable * > theAlignables
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
std::unique_ptr< TrajectoryFactoryBase > theTrajectoryFactory
const Time_t MIN_VAL(0)
std::shared_ptr< PedeLabelerBase > thePedeLabels
bool isMode(unsigned int testMode) const
std::pair< RunNumber, RunNumber > RunRange
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
std::unique_ptr< PedeSteerer > thePedeSteer
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars, const RunRange &runrange)
read pede input defined by &#39;psetName&#39;, flag to create/not create MillePedeVariables ...
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void buildUserVariables(const std::vector< Alignable * > &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)
void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg)
add measurement data from PXB survey
std::unique_ptr< AlignableNavigator > theAlignableNavigator
Time_t endValue
Definition: Time.h:46
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
tuple size
Write out results.
T get(const Candidate &c)
Definition: component.h:55
bool MillePedeAlignmentAlgorithm::is2D ( const TransientTrackingRecHit::ConstRecHitPointer recHit) const
private

true if hit belongs to 2D detector (currently tracker specific)

Definition at line 889 of file MillePedeAlignmentAlgorithm.cc.

890 {
891  // FIXME: Check whether this is a reliable and recommended way to find out...
892 
893  if (recHit->dimension() < 2) {
894  return false; // some muon and TIB/TOB stuff really has RecHit1D
895  } else if (recHit->detUnit()) { // detunit in strip is 1D, in pixel 2D
896  return recHit->detUnit()->type().isTrackerPixel();
897  } else { // stereo strips (FIXME: endcap trouble due to non-parallel strips (wedge sensors)?)
898  if (dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit->hit())) { // check persistent hit
899  // projected: 1D measurement on 'glued' module
900  return false;
901  } else {
902  return true;
903  }
904  }
905 }
bool MillePedeAlignmentAlgorithm::isMode ( unsigned int  testMode) const
inlineprivate
void MillePedeAlignmentAlgorithm::makeGlobDerivMatrix ( const std::vector< float > &  globalDerivativesx,
const std::vector< float > &  globalDerivativesy,
TMatrixF &  aGlobalDerivativesM 
)
private

Definition at line 1126 of file MillePedeAlignmentAlgorithm.cc.

References i.

1129 {
1130 
1131  for (unsigned int i = 0; i < globalDerivativesx.size(); ++i) {
1132  aGlobalDerivativesM(0,i) = globalDerivativesx[i];
1133  aGlobalDerivativesM(1,i) = globalDerivativesy[i];
1134  }
1135 }
int i
Definition: DBlmapReader.cc:9
bool MillePedeAlignmentAlgorithm::processesEvents ( )
overridevirtual

Returns whether MP should process events in the current configuration.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 300 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), and myMilleBit.

301 {
302  if (isMode(myMilleBit)) {
303  return true;
304  } else {
305  return false;
306  }
307 }
bool isMode(unsigned int testMode) const
bool MillePedeAlignmentAlgorithm::readFromPede ( const edm::ParameterSet mprespset,
bool  setUserVars,
const RunRange runrange 
)
private

read pede input defined by 'psetName', flag to create/not create MillePedeVariables

Definition at line 908 of file MillePedeAlignmentAlgorithm.cc.

References areEmptyParams(), fileinputsource_cfi::out, PedeReader::read(), matplotRender::reader, theAlignables, thePedeLabels, and thePedeSteer.

Referenced by initialize(), and setParametersForRunRange().

910 {
911  bool allEmpty = this->areEmptyParams(theAlignables);
912 
913  PedeReader reader(mprespset, *thePedeSteer, *thePedeLabels, runrange);
914  std::vector<Alignable*> alis;
915  bool okRead = reader.read(alis, setUserVars); // also may set params of IntegratedCalibration's
916  bool numMatch = true;
917 
918  std::stringstream out;
919  out << "Read " << alis.size() << " alignables";
920  if (alis.size() != theAlignables.size()) {
921  out << " while " << theAlignables.size() << " in store";
922  numMatch = false; // FIXME: Should we check one by one? Or transfer 'alis' to the store?
923  }
924  if (!okRead) out << ", but problems in reading";
925  if (!allEmpty) out << ", possibly overwriting previous settings";
926  out << ".";
927 
928  if (okRead && allEmpty) {
929  if (numMatch) { // as many alignables with result as trying to align
930  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
931  } else if (alis.size()) { // dead module do not get hits and no pede result
932  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
933  } else { // serious problem: no result read - and not all modules can be dead...
934  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
935  return false;
936  }
937  return true;
938  }
939  // the rest is not OK:
940  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
941  return false;
942 }
std::vector< Alignable * > theAlignables
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::unique_ptr< PedeSteerer > thePedeSteer
bool areEmptyParams(const std::vector< Alignable * > &alignables) const
void MillePedeAlignmentAlgorithm::run ( const edm::EventSetup setup,
const EventInfo eventInfo 
)
overridevirtual

Run the algorithm on trajectories and tracks.

Implements AlignmentAlgorithmBase.

Definition at line 432 of file MillePedeAlignmentAlgorithm.cc.

References addReferenceTrajectory(), AlignmentAlgorithmBase::EventInfo::beamSpot(), isMode(), myMilleBit, hltrates_dqm_sourceclient-live_cfg::offset, edm::second(), theMonitor, theTrajectoryFactory, testEve_cfg::tracks, HLT_FULL_cff::trajectories, and AlignmentAlgorithmBase::EventInfo::trajTrackPairs().

Referenced by Types.EventID::cppID(), and Types.LuminosityBlockID::cppID().

433 {
434  if (!this->isMode(myMilleBit)) return; // no theMille created...
435  const auto& tracks = eventInfo.trajTrackPairs();
436 
437  if (theMonitor) { // monitor input tracks
438  for (const auto& iTrajTrack: tracks) {
439  theMonitor->fillTrack(iTrajTrack.second);
440  }
441  }
442 
443  const RefTrajColl trajectories(theTrajectoryFactory->trajectories(setup, tracks, eventInfo.beamSpot()));
444 
445  // Now loop over ReferenceTrajectoryCollection
446  unsigned int refTrajCount = 0; // counter for track monitoring
447  const auto tracksPerTraj = theTrajectoryFactory->tracksPerTrajectory();
448  for (auto iRefTraj = trajectories.cbegin(), iRefTrajE = trajectories.cend();
449  iRefTraj != iRefTrajE; ++iRefTraj, ++refTrajCount) {
450 
451  RefTrajColl::value_type refTrajPtr = *iRefTraj;
452  if (theMonitor) theMonitor->fillRefTrajectory(refTrajPtr);
453 
454  const auto nHitXy = this->addReferenceTrajectory(setup, eventInfo, refTrajPtr);
455 
456  if (theMonitor && (nHitXy.first || nHitXy.second)) {
457  // if trajectory used (i.e. some hits), fill monitoring
458  const auto offset = tracksPerTraj*refTrajCount;
459  for (unsigned int iTrack = 0; iTrack < tracksPerTraj; ++iTrack) {
460  theMonitor->fillUsedTrack(tracks[offset+iTrack].second,
461  nHitXy.first, nHitXy.second);
462  }
463  }
464 
465  } // end of reference trajectory and track loop
466 }
std::unique_ptr< MillePedeMonitor > theMonitor
TrajectoryFactoryBase::ReferenceTrajectoryCollection RefTrajColl
std::unique_ptr< TrajectoryFactoryBase > theTrajectoryFactory
const ConstTrajTrackPairCollection & trajTrackPairs() const
U second(std::pair< T, U > const &p)
bool isMode(unsigned int testMode) const
tuple trajectories
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 &#39;bad&#39; trajectory) ...
tuple tracks
Definition: testEve_cfg.py:39
const reco::BeamSpot & beamSpot() const
bool MillePedeAlignmentAlgorithm::setParametersForRunRange ( const RunRange runrange)
overridevirtual

Called in order to pass parameters to alignables for a specific run range in case the algorithm supports run range dependent alignment.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 327 of file MillePedeAlignmentAlgorithm.cc.

References AlignmentParameterStore::applyParameters(), buildUserVariables(), doIO(), edm::ParameterSet::getParameter(), isMode(), myPedeReadBit, readFromPede(), AlignmentParameterStore::resetParameters(), AlignmentParameterStore::restoreCachedTransformations(), theAlignables, theAlignmentParameterStore, theConfig, and theLastWrittenIov.

328 {
329  if (this->isMode(myPedeReadBit)) {
330  // restore initial positions, rotations and deformations
332 
333  // Needed to shut up later warning from checkAliParams:
335  // To avoid that they keep values from previous IOV if no new one in pede result
337 
338  if (!this->readFromPede(theConfig.getParameter<edm::ParameterSet>("pedeReader"), true, runrange)) {
339  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::setParametersForRunRange"
340  << "Problems reading pede result, but applying!";
341  }
343 
344  this->doIO(++theLastWrittenIov); // pre-increment!
345  }
346 
347  return true;
348 }
T getParameter(std::string const &) const
void resetParameters(void)
reset parameters, correlations, user variables
std::vector< Alignable * > theAlignables
void restoreCachedTransformations(void)
restore the previously cached position, rotation and other parameters
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
unsigned int doIO(int loop) const
bool isMode(unsigned int testMode) const
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
bool readFromPede(const edm::ParameterSet &mprespset, bool setUserVars, const RunRange &runrange)
read pede input defined by &#39;psetName&#39;, flag to create/not create MillePedeVariables ...
void buildUserVariables(const std::vector< Alignable * > &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)
bool MillePedeAlignmentAlgorithm::storeAlignments ( )
overridevirtual

Returns whether MP produced results to be stored.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 310 of file MillePedeAlignmentAlgorithm.cc.

References edm::ParameterSet::getParameter(), isMode(), myPedeRunBit, MillePedeFileReader::read(), runAtPCL_, MillePedeFileReader::storeAlignments(), theConfig, and thePedeLabels.

311 {
312  if (isMode(myPedeRunBit)) {
313  if (runAtPCL_) {
314  MillePedeFileReader mpReader(theConfig.getParameter<edm::ParameterSet>("MillePedeFileReader"),
315  thePedeLabels);
316  mpReader.read();
317  return mpReader.storeAlignments();
318  } else {
319  return true;
320  }
321  } else {
322  return false;
323  }
324 }
T getParameter(std::string const &) const
std::shared_ptr< PedeLabelerBase > thePedeLabels
bool isMode(unsigned int testMode) const
bool MillePedeAlignmentAlgorithm::supportsCalibrations ( )
overridevirtual

Returns whether MP supports calibrations.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 287 of file MillePedeAlignmentAlgorithm.cc.

287  {
288  return true;
289 }
void MillePedeAlignmentAlgorithm::terminate ( const edm::EventSetup iSetup)
overridevirtual

Called at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 352 of file MillePedeAlignmentAlgorithm.cc.

References terminate().

353 {
354  terminate();
355 }
virtual void terminate() override
Called at end of job.
void MillePedeAlignmentAlgorithm::terminate ( void  )
overridevirtual

Called at end of job.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 356 of file MillePedeAlignmentAlgorithm.cc.

References AlignmentParameterStore::cacheTransformations(), doIO(), mergeVDriftHistosByStation::file, MainPageGenerator::files, getExistingFormattedFiles(), edm::ParameterSet::getParameter(), isMode(), myMilleBit, myPedeRunBit, AlCaHLTBitMon_QueryRunRegistry::string, theAlignmentParameterStore, theBinary, theConfig, theDir, theLastWrittenIov, theMille, and thePedeSteer.

Referenced by terminate().

357 {
358  theMille.reset(); // delete to close binary before running pede below (flush would be enough...)
359  theBinary.reset();
360 
361  std::vector<std::string> files;
362  if (this->isMode(myMilleBit) || !theConfig.getParameter<std::string>("binaryFile").empty()) {
363  files.push_back(theDir + theConfig.getParameter<std::string>("binaryFile"));
364  } else {
365  const std::vector<std::string> plainFiles(theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles"));
366  files = getExistingFormattedFiles(plainFiles, theDir);
367  // Do some logging:
368  std::string filesForLogOutput;
369  for (const auto& file: files) filesForLogOutput += " " + file + ",";
370  if (filesForLogOutput.length() != 0) filesForLogOutput.pop_back();
371  edm::LogInfo("Alignment")
372  << "Based on the config parameter mergeBinaryFiles, using the following "
373  << "files as input (assigned weights are indicated by ' -- <weight>'):"
374  << filesForLogOutput;
375  }
376 
377  // cache all positions, rotations and deformations
379 
380  const std::string masterSteer(thePedeSteer->buildMasterSteer(files));// do only if myPedeSteerBit?
381  if (this->isMode(myPedeRunBit)) {
382  thePedeSteer->runPede(masterSteer);
383  }
384 
385  // parameters from pede are not yet applied,
386  // so we can still write start positions (but with hit statistics in case of mille):
387  this->doIO(0);
388  theLastWrittenIov = 0;
389 }
T getParameter(std::string const &) const
std::unique_ptr< gbl::MilleBinary > theBinary
std::vector< std::string > getExistingFormattedFiles(const std::vector< std::string > &plainFiles, const std::string &theDir)
unsigned int doIO(int loop) const
bool isMode(unsigned int testMode) const
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
std::unique_ptr< PedeSteerer > thePedeSteer
void cacheTransformations(void)
cache the current position, rotation and other parameters

Member Data Documentation

const bool MillePedeAlignmentAlgorithm::ignoreHitsWithoutGlobalDerivatives_
private

Definition at line 270 of file MillePedeAlignmentAlgorithm.h.

Referenced by addMeasurementData().

const bool MillePedeAlignmentAlgorithm::runAtPCL_
private
std::unique_ptr<AlignableNavigator> MillePedeAlignmentAlgorithm::theAlignableNavigator
private
std::vector<Alignable*> MillePedeAlignmentAlgorithm::theAlignables
private
AlignmentParameterStore* MillePedeAlignmentAlgorithm::theAlignmentParameterStore
private

directory for all kind of files

Definition at line 248 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize(), setParametersForRunRange(), and terminate().

std::unique_ptr<gbl::MilleBinary> MillePedeAlignmentAlgorithm::theBinary
private
std::vector<IntegratedCalibrationBase*> MillePedeAlignmentAlgorithm::theCalibrations
private
edm::ParameterSet MillePedeAlignmentAlgorithm::theConfig
private
std::string MillePedeAlignmentAlgorithm::theDir
private
bool MillePedeAlignmentAlgorithm::theDoSurveyPixelBarrel
private

Definition at line 264 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

std::vector<float> MillePedeAlignmentAlgorithm::theFloatBufferX
private

Definition at line 261 of file MillePedeAlignmentAlgorithm.h.

Referenced by addLasBeam(), and addMeasurementData().

std::vector<float> MillePedeAlignmentAlgorithm::theFloatBufferY
private

Definition at line 262 of file MillePedeAlignmentAlgorithm.h.

Referenced by addLasBeam(), and addMeasurementData().

bool MillePedeAlignmentAlgorithm::theGblDoubleBinary
private

Definition at line 267 of file MillePedeAlignmentAlgorithm.h.

Referenced by MillePedeAlignmentAlgorithm().

std::vector<int> MillePedeAlignmentAlgorithm::theIntBuffer
private

Definition at line 263 of file MillePedeAlignmentAlgorithm.h.

Referenced by addGlobalData(), addLasBeam(), and addMeasurementData().

int MillePedeAlignmentAlgorithm::theLastWrittenIov
private

maximal correlation allowed for 2D hit in TID/TEC. If larger, the 2D measurement gets diagonalized!!!

Definition at line 260 of file MillePedeAlignmentAlgorithm.h.

Referenced by setParametersForRunRange(), and terminate().

double MillePedeAlignmentAlgorithm::theMaximalCor2D
private

Definition at line 258 of file MillePedeAlignmentAlgorithm.h.

std::unique_ptr<Mille> MillePedeAlignmentAlgorithm::theMille
private
unsigned int MillePedeAlignmentAlgorithm::theMinNumHits
private

Definition at line 257 of file MillePedeAlignmentAlgorithm.h.

Referenced by addReferenceTrajectory().

unsigned int MillePedeAlignmentAlgorithm::theMode
private

Definition at line 246 of file MillePedeAlignmentAlgorithm.h.

Referenced by isMode().

std::unique_ptr<MillePedeMonitor> MillePedeAlignmentAlgorithm::theMonitor
private

Definition at line 251 of file MillePedeAlignmentAlgorithm.h.

Referenced by addPxbSurvey(), initialize(), and run().

std::shared_ptr<PedeLabelerBase> MillePedeAlignmentAlgorithm::thePedeLabels
private
std::unique_ptr<PedeSteerer> MillePedeAlignmentAlgorithm::thePedeSteer
private

Definition at line 254 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize(), readFromPede(), and terminate().

std::unique_ptr<TrajectoryFactoryBase> MillePedeAlignmentAlgorithm::theTrajectoryFactory
private

Definition at line 255 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize(), and run().