CMS 3D CMS Logo

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

bool addCalibrations (const std::vector< IntegratedCalibrationBase *> &iCals) override
 Pass integrated calibrations to Millepede (they are not owned by Millepede!) More...
 
void beginLuminosityBlock (const edm::EventSetup &) override
 called at begin of luminosity block (resets Mille binary in mille mode) More...
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup, bool changed) override
 called at begin of run More...
 
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...
 
void endRun (const EndRunInfo &runInfo, const edm::EventSetup &setup) override
 called at end of run - order of arguments like in EDProducer etc. More...
 
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, edm::ConsumesCollector &iC)
 Constructor. More...
 
bool processesEvents () override
 Returns whether MP should process events in the current configuration. More...
 
void run (const edm::EventSetup &setup, const EventInfo &eventInfo) override
 Run the algorithm on trajectories and tracks. More...
 
bool setParametersForRunRange (const RunRange &runrange) override
 
bool storeAlignments () override
 Returns whether MP produced results to be stored. More...
 
virtual bool storeThresholds (const int &nRecords, const AlignPCLThresholdsHG::threshold_map &thresholdMap, const AlignPCLThresholdsHG::param_map &floatMap)
 
bool supportsCalibrations () override
 Returns whether MP supports calibrations. More...
 
void terminate (const edm::EventSetup &iSetup) override
 Called at end of job. More...
 
void terminate () override
 Called at end of job. More...
 
 ~MillePedeAlignmentAlgorithm () override
 Destructor. More...
 
- Public Member Functions inherited from AlignmentAlgorithmBase
virtual bool addCalibrations (const Calibrations &)
 
bool addCalibrations (const CalibrationsOwner &cals)
 
 AlignmentAlgorithmBase (const edm::ParameterSet &, const edm::ConsumesCollector &)
 Constructor. 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 align::Alignables &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...
 
template<typename CovarianceMatrix , typename ResidualMatrix , typename LocalDerivativeMatrix >
void addRefTrackData2D (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< LocalDerivativeMatrix > &aLocalDerivativesM)
 adds data from reference trajectory from a specific Hit More...
 
template<typename CovarianceMatrix , typename ResidualMatrix , typename LocalDerivativeMatrix >
void addRefTrackVirtualMeas1D (const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas, Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< LocalDerivativeMatrix > &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 align::Alignables &alignables) const
 
bool areIOVsSpecified () const
 
void buildUserVariables (const align::Alignables &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
 
template<typename CovarianceMatrix , typename LocalDerivativeMatrix , typename ResidualMatrix , typename GlobalDerivativeMatrix >
void diagonalize (Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< LocalDerivativeMatrix > &aLocalDerivativesM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< GlobalDerivativeMatrix > &aGlobalDerivativesM) 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
 
template<typename GlobalDerivativeMatrix >
void makeGlobDerivMatrix (const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, Eigen::MatrixBase< GlobalDerivativeMatrix > &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 edm::ESGetToken< AlignPCLThresholdsHG, AlignPCLThresholdsHGRcdaliThrToken_
 
std::vector< align::RunNumbercachedRuns_
 
const bool enableAlignableUpdates_
 
const bool enforceSingleIOVInput_
 
const align::RunNumber firstIOV_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomToken_
 
const bool ignoreFirstIOVCheck_
 
const bool ignoreHitsWithoutGlobalDerivatives_
 
align::RunNumber lastProcessedRun_
 
std::shared_ptr< PixelTopologyMappixelTopologyMap
 
const bool runAtPCL_
 
const bool skipGlobalPositionRcdCheck_
 
std::unique_ptr< AlignableNavigatortheAlignableNavigator
 
align::Alignables theAlignables
 
AlignmentParameterStoretheAlignmentParameterStore
 directory for all kind of files More...
 
std::unique_ptr< gbl::MilleBinary > theBinary
 
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::shared_ptr< AlignPCLThresholdsHGtheThresholds
 
std::unique_ptr< TrajectoryFactoryBasetheTrajectoryFactory
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtopoToken_
 
const align::RunRanges uniqueRunRanges_
 

Additional Inherited Members

- Public Types inherited from AlignmentAlgorithmBase
typedef std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
 
typedef std::vector< ConstTrajTrackPairConstTrajTrackPairCollection
 
using RunNumber = align::RunNumber
 
using RunRange = align::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 63 of file MillePedeAlignmentAlgorithm.h.

Member Enumeration Documentation

◆ EModeBit

◆ MeasurementDirection

Constructor & Destructor Documentation

◆ MillePedeAlignmentAlgorithm()

MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Constructor.

Definition at line 87 of file MillePedeAlignmentAlgorithm.cc.

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

92  theConfig(cfg),
96  theAlignables(),
99  .getParameter<std::string>("TrajectoryFactoryName"),
100  theConfig.getParameter<edm::ParameterSet>("TrajectoryFactory"),
101  iC)),
102  theMinNumHits(cfg.getParameter<unsigned int>("minNumHits")),
103  theMaximalCor2D(cfg.getParameter<double>("max2Dcorrelation")),
104  firstIOV_(cfg.getUntrackedParameter<AlignmentAlgorithmBase::RunNumber>("firstIOV")),
105  ignoreFirstIOVCheck_(cfg.getUntrackedParameter<bool>("ignoreFirstIOVCheck")),
106  enableAlignableUpdates_(cfg.getUntrackedParameter<bool>("enableAlignableUpdates")),
108  theGblDoubleBinary(cfg.getParameter<bool>("doubleBinary")),
109  runAtPCL_(cfg.getParameter<bool>("runAtPCL")),
110  ignoreHitsWithoutGlobalDerivatives_(cfg.getParameter<bool>("ignoreHitsWithoutGlobalDerivatives")),
111  skipGlobalPositionRcdCheck_(cfg.getParameter<bool>("skipGlobalPositionRcdCheck")),
112  uniqueRunRanges_(align::makeUniqueRunRanges(cfg.getUntrackedParameter<edm::VParameterSet>("RunRangeSelection"),
116  if (!theDir.empty() && theDir.find_last_of('/') != theDir.size() - 1)
117  theDir += '/'; // may need '/'
118  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm"
119  << "Start in mode '" << theConfig.getUntrackedParameter<std::string>("mode")
120  << "' with output directory '" << theDir << "'.";
121  if (this->isMode(myMilleBit)) {
122  theMille = std::make_unique<Mille>(
123  (theDir + theConfig.getParameter<std::string>("binaryFile")).c_str()); // add ', false);' for text output);
124  // use same file for GBL
125  theBinary = std::make_unique<MilleBinary>((theDir + theConfig.getParameter<std::string>("binaryFile")).c_str(),
127  }
128 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
def create(alignables, pedeDump, additionalData, outputFile, config)
Time_t beginValue
Definition: Time.h:41
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
std::unique_ptr< TrajectoryFactoryBase > theTrajectoryFactory
std::unique_ptr< gbl::MilleBinary > theBinary
bool isMode(unsigned int testMode) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
RunRanges makeUniqueRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:241
const edm::ESGetToken< AlignPCLThresholdsHG, AlignPCLThresholdsHGRcd > aliThrToken_
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
unsigned int decodeMode(const std::string &mode) const
AlignmentAlgorithmBase(const edm::ParameterSet &, const edm::ConsumesCollector &)
Constructor.
Log< level::Info, false > LogInfo
#define get

◆ ~MillePedeAlignmentAlgorithm()

MillePedeAlignmentAlgorithm::~MillePedeAlignmentAlgorithm ( )
override

Destructor.

Definition at line 132 of file MillePedeAlignmentAlgorithm.cc.

132 {}

Member Function Documentation

◆ addCalibrations()

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

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

Definition at line 302 of file MillePedeAlignmentAlgorithm.cc.

References theCalibrations, and thePedeLabels.

302  {
303  theCalibrations.insert(theCalibrations.end(), iCals.begin(), iCals.end());
304  thePedeLabels->addCalibrations(iCals);
305  return true;
306 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::vector< IntegratedCalibrationBase * > theCalibrations

◆ addGlobalData()

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 787 of file MillePedeAlignmentAlgorithm.cc.

References dumpTauVariables_cfi::eventInfo, globalDerivativesHierarchy(), mps_fire::i, submitPVValidationJobs::params, singleTopDQM_cfi::setup, theAlignableNavigator, theCalibrations, theIntBuffer, and thePedeLabels.

Referenced by addReferenceTrajectory().

791  {
792  AlignmentParameters *params = nullptr;
793  std::vector<double> theDoubleBufferX, theDoubleBufferY;
794  theDoubleBufferX.clear();
795  theDoubleBufferY.clear();
796  theIntBuffer.clear();
797  int iret = 0;
798 
799  const TrajectoryStateOnSurface &tsos = refTrajPtr->trajectoryStates()[iHit];
800  const ConstRecHitPointer &recHitPtr = refTrajPtr->recHits()[iHit];
801  // ignore invalid hits
802  if (!recHitPtr->isValid())
803  return 0;
804 
805  // get AlignableDet/Unit for this hit
806  AlignableDetOrUnitPtr alidet(theAlignableNavigator->alignableFromDetId(recHitPtr->geographicalId()));
807 
808  if (!this->globalDerivativesHierarchy(eventInfo,
809  tsos,
810  alidet,
811  alidet,
812  theDoubleBufferX, // 2x alidet, sic!
813  theDoubleBufferY,
814  theIntBuffer,
815  params)) {
816  return -1; // problem
817  }
818  //calibration parameters
819  int globalLabel;
820  std::vector<IntegratedCalibrationBase::ValuesIndexPair> derivs;
821  for (auto iCalib = theCalibrations.begin(); iCalib != theCalibrations.end(); ++iCalib) {
822  // get all derivatives of this calibration // const unsigned int num =
823  (*iCalib)->derivatives(derivs, *recHitPtr, tsos, setup, eventInfo);
824  for (auto iValuesInd = derivs.begin(); iValuesInd != derivs.end(); ++iValuesInd) {
825  // transfer label and x/y derivatives
826  globalLabel = thePedeLabels->calibrationLabel(*iCalib, iValuesInd->second);
827  if (globalLabel > 0 && globalLabel <= 2147483647) {
828  theIntBuffer.push_back(globalLabel);
829  theDoubleBufferX.push_back(iValuesInd->first.first);
830  theDoubleBufferY.push_back(iValuesInd->first.second);
831  } else {
832  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addGlobalData"
833  << "Invalid label " << globalLabel << " <= 0 or > 2147483647";
834  }
835  }
836  }
837  unsigned int numGlobals = theIntBuffer.size();
838  if (numGlobals > 0) {
839  Eigen::Matrix<double, 2, Eigen::Dynamic> globalDer{2, numGlobals};
840  for (unsigned int i = 0; i < numGlobals; ++i) {
841  globalDer(0, i) = theDoubleBufferX[i];
842  globalDer(1, i) = theDoubleBufferY[i];
843  }
844  gblPoint.addGlobals(theIntBuffer, globalDer);
845  iret = 1;
846  }
847  return iret;
848 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
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
Log< level::Error, false > LogError
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
std::vector< IntegratedCalibrationBase * > theCalibrations
eventInfo
add run, event number and lumi section
std::unique_ptr< AlignableNavigator > theAlignableNavigator

◆ addHitCount()

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 602 of file MillePedeAlignmentAlgorithm.cc.

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

Referenced by addReferenceTrajectory().

603  {
604  // Loop on all hit information in the input arrays and count valid y-hits:
605  unsigned int nHitY = 0;
606  for (unsigned int iHit = 0; iHit < validHitVecY.size(); ++iHit) {
607  Alignable *ali = (parVec[iHit] ? parVec[iHit]->alignable() : nullptr);
608  // Loop upwards on hierarchy of alignables to add hits to all levels
609  // that are currently aligned. If only a non-selected alignable was hit,
610  // (i.e. flagXY == 0 in addReferenceTrajectory(..)), there is no loop at all...
611  while (ali) {
613  if (pars) { // otherwise hierarchy level not selected
614  // cast ensured by previous checks:
615  MillePedeVariables *mpVar = static_cast<MillePedeVariables *>(pars->userVariables());
616  // every hit has an x-measurement, cf. addReferenceTrajectory(..):
617  mpVar->increaseHitsX();
618  if (validHitVecY[iHit]) {
619  mpVar->increaseHitsY();
620  if (pars == parVec[iHit])
621  ++nHitY; // do not count hits twice
622  }
623  }
624  ali = ali->mother();
625  }
626  }
627 
628  return nHitY;
629 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91
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.

◆ addHits()

bool MillePedeAlignmentAlgorithm::addHits ( const align::Alignables alis,
const std::vector< AlignmentUserVariables *> &  mpVars 
) const
private

Definition at line 1232 of file MillePedeAlignmentAlgorithm.cc.

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

Referenced by addHitStatistics().

1233  {
1234  bool allOk = (mpVars.size() == alis.size());
1235  std::vector<AlignmentUserVariables *>::const_iterator iUser = mpVars.begin();
1236  for (auto iAli = alis.cbegin(); iAli != alis.cend() && iUser != mpVars.end(); ++iAli, ++iUser) {
1237  MillePedeVariables *mpVarNew = dynamic_cast<MillePedeVariables *>(*iUser);
1238  AlignmentParameters *ps = (*iAli)->alignmentParameters();
1239  MillePedeVariables *mpVarOld = (ps ? dynamic_cast<MillePedeVariables *>(ps->userVariables()) : nullptr);
1240  if (!mpVarNew || !mpVarOld || mpVarOld->size() != mpVarNew->size()) {
1241  allOk = false;
1242  continue; // FIXME error etc.?
1243  }
1244 
1245  mpVarOld->increaseHitsX(mpVarNew->hitsX());
1246  mpVarOld->increaseHitsY(mpVarNew->hitsY());
1247  }
1248 
1249  return allOk;
1250 }
void increaseHitsX(unsigned int add=1)
increase hits for x-measurement
void increaseHitsY(unsigned int add=1)
increase hits for y-measurement
unsigned int hitsX() const
get number of hits for x-measurement
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
unsigned int size() const
number of parameters
unsigned int hitsY() const
get number of hits for y-measurement

◆ addHitStatistics()

bool MillePedeAlignmentAlgorithm::addHitStatistics ( int  fromLoop,
const std::string &  outFile,
const std::vector< std::string > &  inFiles 
) const
private

Definition at line 1207 of file MillePedeAlignmentAlgorithm.cc.

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

Referenced by doIO().

1209  {
1210  bool allOk = true;
1211  int ierr = 0;
1212  MillePedeVariablesIORoot millePedeIO;
1213  for (std::vector<std::string>::const_iterator iFile = inFiles.begin(); iFile != inFiles.end(); ++iFile) {
1214  const std::string inFile(theDir + *iFile);
1215  const std::vector<AlignmentUserVariables *> mpVars =
1216  millePedeIO.readMillePedeVariables(theAlignables, inFile.c_str(), fromIov, ierr);
1217  if (ierr || !this->addHits(theAlignables, mpVars)) {
1218  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addHitStatistics"
1219  << "Error " << ierr << " reading from " << inFile << ", tree " << fromIov
1220  << ", or problems in addHits";
1221  allOk = false;
1222  }
1223  for (std::vector<AlignmentUserVariables *>::const_iterator i = mpVars.begin(); i != mpVars.end(); ++i) {
1224  delete *i; // clean created objects
1225  }
1226  }
1227 
1228  return allOk;
1229 }
Log< level::Error, false > LogError
std::vector< AlignmentUserVariables * > readMillePedeVariables(const align::Alignables &alivec, const char *filename, int iter, int &ierr)
bool addHits(const align::Alignables &alis, const std::vector< AlignmentUserVariables *> &mpVars) const

◆ addLasBeam()

void MillePedeAlignmentAlgorithm::addLasBeam ( const EventInfo eventInfo,
const TkFittedLasBeam lasBeam,
const std::vector< TrajectoryStateOnSurface > &  tsoses 
)
private

Definition at line 1536 of file MillePedeAlignmentAlgorithm.cc.

References funct::derivative(), TkFittedLasBeam::derivatives(), relativeConstraints::error, TkFittedLasBeam::firstFixedParameter(), TkLasBeam::getBeamId(), TkLasBeam::getData(), globalDerivativesHierarchy(), sistrip::SpyUtilities::isValid(), TkFittedLasBeam::parameters(), theAlignableNavigator, theFloatBufferX, theFloatBufferY, theIntBuffer, theMille, thePedeLabels, and hit::x.

Referenced by addLaserData().

1538  {
1539  AlignmentParameters *dummyPtr = nullptr; // for globalDerivativesHierarchy()
1540  std::vector<float> lasLocalDerivsX; // buffer for local derivatives
1541  const unsigned int beamLabel = thePedeLabels->lasBeamLabel(lasBeam.getBeamId()); // for global par
1542 
1543  for (unsigned int iHit = 0; iHit < tsoses.size(); ++iHit) {
1544  if (!tsoses[iHit].isValid())
1545  continue;
1546  // clear buffer
1547  theFloatBufferX.clear();
1548  theFloatBufferY.clear();
1549  theIntBuffer.clear();
1550  lasLocalDerivsX.clear();
1551  // get alignables and global parameters
1552  const SiStripLaserRecHit2D &hit = lasBeam.getData()[iHit];
1553  AlignableDetOrUnitPtr lasAli(theAlignableNavigator->alignableFromDetId(hit.getDetId()));
1555  eventInfo, tsoses[iHit], lasAli, lasAli, theFloatBufferX, theFloatBufferY, theIntBuffer, dummyPtr);
1556  // fill derivatives vector from derivatives matrix
1557  for (unsigned int nFitParams = 0; nFitParams < static_cast<unsigned int>(lasBeam.parameters().size());
1558  ++nFitParams) {
1559  const float derivative = lasBeam.derivatives()[iHit][nFitParams];
1560  if (nFitParams < lasBeam.firstFixedParameter()) { // first local beam parameters
1561  lasLocalDerivsX.push_back(derivative);
1562  } else { // now global ones
1563  const unsigned int numPar = nFitParams - lasBeam.firstFixedParameter();
1564  theIntBuffer.push_back(thePedeLabels->parameterLabel(beamLabel, numPar));
1565  theFloatBufferX.push_back(derivative);
1566  }
1567  } // end loop over parameters
1568 
1569  const float residual = hit.localPosition().x() - tsoses[iHit].localPosition().x();
1570  // error from file or assume 0.003
1571  const float error = 0.003; // hit.localPositionError().xx(); sqrt???
1572 
1573  theMille->mille(lasLocalDerivsX.size(),
1574  &(lasLocalDerivsX[0]),
1575  theFloatBufferX.size(),
1576  &(theFloatBufferX[0]),
1577  &(theIntBuffer[0]),
1578  residual,
1579  error);
1580  } // end of loop over hits
1581 
1582  theMille->end();
1583 }
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
std::shared_ptr< PedeLabelerBase > thePedeLabels
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
const std::vector< SiStripLaserRecHit2D > & getData(void) const
access the collection of hits
Definition: TkLasBeam.h:26
const AlgebraicMatrix & derivatives() const
matrix of local derivatives: columns are parameters, rows are hits
unsigned int getBeamId(void) const
return the full beam identifier
Definition: TkLasBeam.h:23
unsigned int firstFixedParameter() const
std::unique_ptr< AlignableNavigator > theAlignableNavigator
const std::vector< Scalar > & parameters() const
parallel to derivatives()

◆ addLaserData()

void MillePedeAlignmentAlgorithm::addLaserData ( const EventInfo eventInfo,
const TkFittedLasBeamCollection tkLasBeams,
const TsosVectorCollection tkLasBeamTsoses 
)
private

Definition at line 1519 of file MillePedeAlignmentAlgorithm.cc.

References addLasBeam().

Referenced by endRun().

1521  {
1522  TsosVectorCollection::const_iterator iTsoses = lasBeamTsoses.begin();
1523  for (TkFittedLasBeamCollection::const_iterator iBeam = lasBeams.begin(), iEnd = lasBeams.end(); iBeam != iEnd;
1524  ++iBeam, ++iTsoses) { // beam/tsoses parallel!
1525 
1526  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addLaserData"
1527  << "Beam " << iBeam->getBeamId() << " with " << iBeam->parameters().size()
1528  << " parameters and " << iBeam->getData().size() << " hits.\n There are "
1529  << iTsoses->size() << " TSOSes.";
1530 
1531  this->addLasBeam(eventInfo, *iBeam, *iTsoses);
1532  }
1533 }
void addLasBeam(const EventInfo &eventInfo, const TkFittedLasBeam &lasBeam, const std::vector< TrajectoryStateOnSurface > &tsoses)
Log< level::Info, false > LogInfo

◆ addMeasurementData()

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 738 of file MillePedeAlignmentAlgorithm.cc.

References callMille(), dumpTauVariables_cfi::eventInfo, globalDerivativesCalibration(), globalDerivativesHierarchy(), ignoreHitsWithoutGlobalDerivatives_, submitPVValidationJobs::params, singleTopDQM_cfi::setup, theAlignableNavigator, theFloatBufferX, theFloatBufferY, and theIntBuffer.

Referenced by addReferenceTrajectory().

742  {
743  params = nullptr;
744  theFloatBufferX.clear();
745  theFloatBufferY.clear();
746  theIntBuffer.clear();
747 
748  const TrajectoryStateOnSurface &tsos = refTrajPtr->trajectoryStates()[iHit];
749  const ConstRecHitPointer &recHitPtr = refTrajPtr->recHits()[iHit];
750  // ignore invalid hits
751  if (!recHitPtr->isValid())
752  return 0;
753 
754  // First add the derivatives from IntegratedCalibration's,
755  // should even be OK if problems for "usual" derivatives from Alignables
756  this->globalDerivativesCalibration(recHitPtr,
757  tsos,
758  setup,
759  eventInfo, // input
762  theIntBuffer); // output
763 
764  // get AlignableDet/Unit for this hit
765  AlignableDetOrUnitPtr alidet(theAlignableNavigator->alignableFromDetId(recHitPtr->geographicalId()));
766 
767  if (!this->globalDerivativesHierarchy(eventInfo,
768  tsos,
769  alidet,
770  alidet,
771  theFloatBufferX, // 2x alidet, sic!
773  theIntBuffer,
774  params)) {
775  return -1; // problem
777  return 0; // empty for X: no alignable for hit, nor calibrations
778  } else {
779  // store measurement even if no alignable or calibrations
780  // -> measurement used for pede-internal track-fit
781  return this->callMille(refTrajPtr, iHit, theIntBuffer, theFloatBufferX, theFloatBufferY);
782  }
783 }
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
eventInfo
add run, event number and lumi section
std::unique_ptr< AlignableNavigator > theAlignableNavigator

◆ addPxbSurvey()

void MillePedeAlignmentAlgorithm::addPxbSurvey ( const edm::ParameterSet pxbSurveyCfg)
private

add measurement data from PXB survey

Definition at line 1585 of file MillePedeAlignmentAlgorithm.cc.

References a, hltPixelTracks_cff::chi2, SurveyPxbDicer::doDice(), corrVsCorr::filename, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, dqmiolumiharvest::j, SurveyPxbImageLocalFit::nMsrmts, timingPdfMaker::outfile, DQM::reader, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), theAlignableNavigator, theMille, theMonitor, thePedeLabels, AlignableSurface::toGlobal(), and AlignableSurface::toLocal().

Referenced by initialize().

1585  {
1586  // do some printing, if requested
1587  const bool doOutputOnStdout(pxbSurveyCfg.getParameter<bool>("doOutputOnStdout"));
1588  if (doOutputOnStdout) {
1589  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1590  << "# Output from addPxbSurvey follows below because "
1591  << "doOutputOnStdout is set to True";
1592  }
1593 
1594  // instantiate a dicer object
1595  SurveyPxbDicer dicer(pxbSurveyCfg.getParameter<std::vector<edm::ParameterSet> >("toySurveyParameters"),
1596  pxbSurveyCfg.getParameter<unsigned int>("toySurveySeed"));
1597  std::ofstream outfile(pxbSurveyCfg.getUntrackedParameter<std::string>("toySurveyFile").c_str());
1598 
1599  // read data from file
1600  std::vector<SurveyPxbImageLocalFit> measurements;
1601  std::string filename(pxbSurveyCfg.getParameter<edm::FileInPath>("infile").fullPath());
1603 
1604  // loop over photographs (=measurements) and perform the fit
1605  for (std::vector<SurveyPxbImageLocalFit>::size_type i = 0; i != measurements.size(); i++) {
1606  if (doOutputOnStdout) {
1607  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1608  << "Module " << i << ": ";
1609  }
1610 
1611  // get the Alignables and their surfaces
1612  AlignableDetOrUnitPtr mod1(theAlignableNavigator->alignableFromDetId(measurements[i].getIdFirst()));
1613  AlignableDetOrUnitPtr mod2(theAlignableNavigator->alignableFromDetId(measurements[i].getIdSecond()));
1614  const AlignableSurface &surf1 = mod1->surface();
1615  const AlignableSurface &surf2 = mod2->surface();
1616 
1617  // the position of the fiducial points in local frame of a PXB module
1618  const LocalPoint fidpoint0(-0.91, +3.30);
1619  const LocalPoint fidpoint1(+0.91, +3.30);
1620  const LocalPoint fidpoint2(+0.91, -3.30);
1621  const LocalPoint fidpoint3(-0.91, -3.30);
1622 
1623  // We choose the local frame of the first module as reference,
1624  // so take the fidpoints of the second module and calculate their
1625  // positions in the reference frame
1626  const GlobalPoint surf2point0(surf2.toGlobal(fidpoint0));
1627  const GlobalPoint surf2point1(surf2.toGlobal(fidpoint1));
1628  const LocalPoint fidpoint0inSurf1frame(surf1.toLocal(surf2point0));
1629  const LocalPoint fidpoint1inSurf1frame(surf1.toLocal(surf2point1));
1630 
1631  // Create the vector for the fit
1633  fidpointvec.push_back(fidpoint0inSurf1frame);
1634  fidpointvec.push_back(fidpoint1inSurf1frame);
1635  fidpointvec.push_back(fidpoint2);
1636  fidpointvec.push_back(fidpoint3);
1637 
1638  // if toy survey is requested, dice the values now
1639  if (pxbSurveyCfg.getParameter<bool>("doToySurvey")) {
1640  dicer.doDice(fidpointvec, measurements[i].getIdPair(), outfile);
1641  }
1642 
1643  // do the fit
1644  measurements[i].doFit(fidpointvec, thePedeLabels->alignableLabel(mod1), thePedeLabels->alignableLabel(mod2));
1645  SurveyPxbImageLocalFit::localpars_t a; // local pars from fit
1646  a = measurements[i].getLocalParameters();
1647  const SurveyPxbImageLocalFit::value_t chi2 = measurements[i].getChi2();
1648 
1649  // do some reporting, if requested
1650  if (doOutputOnStdout) {
1651  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::addPxbSurvey"
1652  << "a: " << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3]
1653  << " S= " << sqrt(a[2] * a[2] + a[3] * a[3]) << " phi= " << atan(a[3] / a[2])
1654  << " chi2= " << chi2 << std::endl;
1655  }
1656  if (theMonitor) {
1657  theMonitor->fillPxbSurveyHistsChi2(chi2);
1658  theMonitor->fillPxbSurveyHistsLocalPars(a[0], a[1], sqrt(a[2] * a[2] + a[3] * a[3]), atan(a[3] / a[2]));
1659  }
1660 
1661  // pass the results from the local fit to mille
1663  theMille->mille((int)measurements[i].getLocalDerivsSize(),
1664  measurements[i].getLocalDerivsPtr(j),
1665  (int)measurements[i].getGlobalDerivsSize(),
1666  measurements[i].getGlobalDerivsPtr(j),
1667  measurements[i].getGlobalDerivsLabelPtr(j),
1668  measurements[i].getResiduum(j),
1669  measurements[i].getSigma(j));
1670  }
1671  theMille->end();
1672  }
1673  outfile.close();
1674 }
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< MillePedeMonitor > theMonitor
std::vector< coord_t > fidpoint_t
std::string fullPath() const
Definition: FileInPath.cc:161
std::shared_ptr< PedeLabelerBase > thePedeLabels
reader
Definition: DQM.py:105
uint16_t size_type
T getUntrackedParameter(std::string const &, T const &) const
T sqrt(T t)
Definition: SSEVec.h:19
Log< level::Info, false > LogInfo
Class to hold one picture of the BPix survey.
std::vector< value_t > localpars_t
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
double a
Definition: hdecay.h:119
static const count_t nMsrmts
std::unique_ptr< AlignableNavigator > theAlignableNavigator

◆ addReferenceTrajectory()

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 511 of file MillePedeAlignmentAlgorithm.cc.

References addGlobalData(), addHitCount(), addMeasurementData(), addVirtualMeas(), dumpTauVariables_cfi::eventInfo, theBinary, theMille, and theMinNumHits.

Referenced by run().

512  {
513  std::pair<unsigned int, unsigned int> hitResultXy(0, 0);
514  if (refTrajPtr->isValid()) {
515  // GblTrajectory?
516  if (!refTrajPtr->gblInput().empty()) {
517  // by construction: number of GblPoints == number of recHits or == zero !!!
518  unsigned int iHit = 0;
519  unsigned int numPointsWithMeas = 0;
520  std::vector<GblPoint>::iterator itPoint;
521  auto theGblInput = refTrajPtr->gblInput();
522  for (unsigned int iTraj = 0; iTraj < refTrajPtr->gblInput().size(); ++iTraj) {
523  for (itPoint = refTrajPtr->gblInput()[iTraj].first.begin(); itPoint < refTrajPtr->gblInput()[iTraj].first.end();
524  ++itPoint) {
525  if (this->addGlobalData(setup, eventInfo, refTrajPtr, iHit++, *itPoint) < 0)
526  return hitResultXy;
527  if (itPoint->numMeasurements() >= 1)
528  ++numPointsWithMeas;
529  }
530  }
531  hitResultXy.first = numPointsWithMeas;
532  // check #hits criterion
533  if (hitResultXy.first == 0 || hitResultXy.first < theMinNumHits)
534  return hitResultXy;
535  // construct GBL trajectory
536  if (refTrajPtr->gblInput().size() == 1) {
537  // from single track
538  GblTrajectory aGblTrajectory(refTrajPtr->gblInput()[0].first, refTrajPtr->nominalField() != 0);
539  // GBL fit trajectory
540  /*double Chi2;
541  int Ndf;
542  double lostWeight;
543  aGblTrajectory.fit(Chi2, Ndf, lostWeight);
544  std::cout << " GblFit: " << Chi2 << ", " << Ndf << ", " << lostWeight << std::endl; */
545  // write to MP binary file
546  if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits)
547  aGblTrajectory.milleOut(*theBinary);
548  }
549  if (refTrajPtr->gblInput().size() == 2) {
550  // from TwoBodyDecay
551  GblTrajectory aGblTrajectory(refTrajPtr->gblInput(),
552  refTrajPtr->gblExtDerivatives(),
553  refTrajPtr->gblExtMeasurements(),
554  refTrajPtr->gblExtPrecisions());
555  // write to MP binary file
556  if (aGblTrajectory.isValid() && aGblTrajectory.getNumPoints() >= theMinNumHits)
557  aGblTrajectory.milleOut(*theBinary);
558  }
559  } else {
560  // to add hits if all fine:
561  std::vector<AlignmentParameters *> parVec(refTrajPtr->recHits().size());
562  // collect hit statistics, assuming that there are no y-only hits
563  std::vector<bool> validHitVecY(refTrajPtr->recHits().size(), false);
564  // Use recHits from ReferenceTrajectory (since they have the right order!):
565  for (unsigned int iHit = 0; iHit < refTrajPtr->recHits().size(); ++iHit) {
566  const int flagXY = this->addMeasurementData(setup, eventInfo, refTrajPtr, iHit, parVec[iHit]);
567 
568  if (flagXY < 0) { // problem
569  hitResultXy.first = 0;
570  break;
571  } else { // hit is fine, increase x/y statistics
572  if (flagXY >= 1)
573  ++hitResultXy.first;
574  validHitVecY[iHit] = (flagXY >= 2);
575  }
576  } // end loop on hits
577 
578  // add virtual measurements
579  for (unsigned int iVirtualMeas = 0; iVirtualMeas < refTrajPtr->numberOfVirtualMeas(); ++iVirtualMeas) {
580  this->addVirtualMeas(refTrajPtr, iVirtualMeas);
581  }
582 
583  // kill or end 'track' for mille, depends on #hits criterion
584  if (hitResultXy.first == 0 || hitResultXy.first < theMinNumHits) {
585  theMille->kill();
586  hitResultXy.first = hitResultXy.second = 0; //reset
587  } else {
588  theMille->end();
589  // add x/y hit count to MillePedeVariables of parVec,
590  // returning number of y-hits of the reference trajectory
591  hitResultXy.second = this->addHitCount(parVec, validHitVecY);
592  //
593  }
594  }
595 
596  } // end if valid trajectory
597 
598  return hitResultXy;
599 }
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)
int addMeasurementData(const edm::EventSetup &setup, const EventInfo &eventInfo, const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iHit, AlignmentParameters *&params)
unsigned int addHitCount(const std::vector< AlignmentParameters *> &parVec, const std::vector< bool > &validHitVecY) const
void addVirtualMeas(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas)
adds data for virtual measurements from reference trajectory
eventInfo
add run, event number and lumi section

◆ addRefTrackData2D()

template<typename CovarianceMatrix , typename ResidualMatrix , typename LocalDerivativeMatrix >
void MillePedeAlignmentAlgorithm::addRefTrackData2D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iTrajHit,
Eigen::MatrixBase< CovarianceMatrix > &  aHitCovarianceM,
Eigen::MatrixBase< ResidualMatrix > &  aHitResidualsM,
Eigen::MatrixBase< LocalDerivativeMatrix > &  aLocalDerivativesM 
)
private

adds data from reference trajectory from a specific Hit

Definition at line 1318 of file MillePedeAlignmentAlgorithm.cc.

References mps_fire::i.

Referenced by callMille2D().

1322  {
1323  // This Method is valid for 2D measurements only
1324 
1325  const unsigned int xIndex = iTrajHit * 2;
1326  const unsigned int yIndex = iTrajHit * 2 + 1;
1327 
1328  aHitCovarianceM(0, 0) = refTrajPtr->measurementErrors()[xIndex][xIndex];
1329  aHitCovarianceM(0, 1) = refTrajPtr->measurementErrors()[xIndex][yIndex];
1330  aHitCovarianceM(1, 0) = refTrajPtr->measurementErrors()[yIndex][xIndex];
1331  aHitCovarianceM(1, 1) = refTrajPtr->measurementErrors()[yIndex][yIndex];
1332 
1333  aHitResidualsM(0, 0) = refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
1334  aHitResidualsM(1, 0) = refTrajPtr->measurements()[yIndex] - refTrajPtr->trajectoryPositions()[yIndex];
1335 
1336  const auto &locDerivMatrix = refTrajPtr->derivatives();
1337  for (int i = 0; i < locDerivMatrix.num_col(); ++i) {
1338  aLocalDerivativesM(0, i) = locDerivMatrix[xIndex][i];
1339  aLocalDerivativesM(1, i) = locDerivMatrix[yIndex][i];
1340  }
1341 }

◆ addRefTrackVirtualMeas1D()

template<typename CovarianceMatrix , typename ResidualMatrix , typename LocalDerivativeMatrix >
void MillePedeAlignmentAlgorithm::addRefTrackVirtualMeas1D ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iVirtualMeas,
Eigen::MatrixBase< CovarianceMatrix > &  aHitCovarianceM,
Eigen::MatrixBase< ResidualMatrix > &  aHitResidualsM,
Eigen::MatrixBase< LocalDerivativeMatrix > &  aLocalDerivativesM 
)
private

adds data for a specific virtual measurement from reference trajectory

Definition at line 1297 of file MillePedeAlignmentAlgorithm.cc.

References mps_fire::i.

Referenced by addVirtualMeas().

1302  {
1303  // This Method is valid for 1D measurements only
1304 
1305  const unsigned int xIndex = iVirtualMeas + refTrajPtr->numberOfHitMeas();
1306 
1307  aHitCovarianceM(0, 0) = refTrajPtr->measurementErrors()[xIndex][xIndex];
1308  aHitResidualsM(0, 0) = refTrajPtr->measurements()[xIndex];
1309 
1310  const auto &locDerivMatrix = refTrajPtr->derivatives();
1311  for (int i = 0; i < locDerivMatrix.num_col(); ++i) {
1312  aLocalDerivativesM(0, i) = locDerivMatrix[xIndex][i];
1313  }
1314 }

◆ addVirtualMeas()

void MillePedeAlignmentAlgorithm::addVirtualMeas ( const ReferenceTrajectoryBase::ReferenceTrajectoryPtr refTrajPtr,
unsigned int  iVirtualMeas 
)
private

adds data for virtual measurements from reference trajectory

Definition at line 1491 of file MillePedeAlignmentAlgorithm.cc.

References addRefTrackVirtualMeas1D(), and theMille.

Referenced by addReferenceTrajectory().

1492  {
1493  Eigen::Matrix<double, 1, 1> aHitCovarianceM;
1494  Eigen::Matrix<float, 1, 1> aHitResidualsM;
1495  Eigen::Matrix<float, 1, Eigen::Dynamic> aLocalDerivativesM{1, refTrajPtr->derivatives().num_col()};
1496  // below method fills above 3 'matrices'
1497  this->addRefTrackVirtualMeas1D(refTrajPtr, iVirtualMeas, aHitCovarianceM, aHitResidualsM, aLocalDerivativesM);
1498 
1499  // no global parameters (use dummy 0)
1500  auto aGlobalDerivativesM = Eigen::Matrix<float, 1, 1>::Zero();
1501 
1502  float newResidX = aHitResidualsM(0, 0);
1503  float newHitErrX = TMath::Sqrt(aHitCovarianceM(0, 0));
1504  std::vector<float> newLocalDerivsX(aLocalDerivativesM.size());
1505  Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(
1506  newLocalDerivsX.data(), aLocalDerivativesM.rows(), aLocalDerivativesM.cols()) = aLocalDerivativesM;
1507 
1508  std::vector<float> newGlobDerivsX(aGlobalDerivativesM.size());
1509  Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(
1510  newGlobDerivsX.data(), aGlobalDerivativesM.rows(), aGlobalDerivativesM.cols()) = aGlobalDerivativesM;
1511 
1512  const int nLocal = aLocalDerivativesM.cols();
1513  const int nGlobal = 0;
1514 
1515  theMille->mille(nLocal, newLocalDerivsX.data(), nGlobal, newGlobDerivsX.data(), &nGlobal, newResidX, newHitErrX);
1516 }
void addRefTrackVirtualMeas1D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iVirtualMeas, Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< LocalDerivativeMatrix > &aLocalDerivativesM)
adds data for a specific virtual measurement from reference trajectory

◆ areEmptyParams()

bool MillePedeAlignmentAlgorithm::areEmptyParams ( const align::Alignables alignables) const
private

Definition at line 1080 of file MillePedeAlignmentAlgorithm.cc.

References mps_fire::i, dqmiolumiharvest::j, and submitPVValidationJobs::params.

Referenced by readFromPede().

1080  {
1081  for (const auto &iAli : alignables) {
1082  const AlignmentParameters *params = iAli->alignmentParameters();
1083  if (params) {
1084  const auto &parVec(params->parameters());
1085  const auto &parCov(params->covariance());
1086  for (int i = 0; i < parVec.num_row(); ++i) {
1087  if (parVec[i] != 0.)
1088  return false;
1089  for (int j = i; j < parCov.num_col(); ++j) {
1090  if (parCov[i][j] != 0.)
1091  return false;
1092  }
1093  }
1094  }
1095  }
1096 
1097  return true;
1098 }

◆ areIOVsSpecified()

bool MillePedeAlignmentAlgorithm::areIOVsSpecified ( ) const
private

Definition at line 1676 of file MillePedeAlignmentAlgorithm.cc.

References edm::ParameterSet::getUntrackedParameter(), align::makeNonOverlappingRunRanges(), cond::runnumber, theConfig, and cond::timeTypeSpecs.

1676  {
1677  const auto runRangeSelection = theConfig.getUntrackedParameter<edm::VParameterSet>("RunRangeSelection");
1678 
1679  if (runRangeSelection.empty())
1680  return false;
1681 
1682  const auto runRanges =
1684 
1685  return !(runRanges.empty());
1686 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
T getUntrackedParameter(std::string const &, T const &) const
RunRanges makeNonOverlappingRunRanges(const edm::VParameterSet &runRanges, const RunNumber &defaultRun)
Definition: Utilities.cc:202

◆ beginLuminosityBlock()

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 722 of file MillePedeAlignmentAlgorithm.cc.

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

722  {
723  if (!runAtPCL_)
724  return;
725  if (this->isMode(myMilleBit))
726  theMille->resetOutputFile();
727 }
bool isMode(unsigned int testMode) const

◆ beginRun()

void MillePedeAlignmentAlgorithm::beginRun ( const edm::Run run,
const edm::EventSetup setup,
bool  changed 
)
overridevirtual

called at begin of run

Reimplemented from AlignmentAlgorithmBase.

Definition at line 631 of file MillePedeAlignmentAlgorithm.cc.

References cond::TimeTypeSpecs::beginValue, cachedRuns_, AlignmentParameterStore::cacheTransformations(), enableAlignableUpdates_, edm::IOVSyncValue::eventID(), Exception, spr::find(), edm::ValidityInterval::first(), firstIOV_, dataset::firstRun, ignoreFirstIOVCheck_, edm::eventsetup::EventSetupRecordImplementation< T >::key(), lastProcessedRun_, edm::eventsetup::EventSetupRecordKey::name(), edm::EventID::run(), run(), cond::runnumber, convertSQLiteXML::runNumber, crab_NZS2018C_1::runRange, singleTopDQM_cfi::setup, skipGlobalPositionRcdCheck_, theAlignmentParameterStore, cond::persistency::throwException(), cond::timeTypeSpecs, uniqueRunRanges_, and edm::eventsetup::EventSetupRecord::validityInterval().

631  {
632  if (run.run() < firstIOV_ && !ignoreFirstIOVCheck_) {
633  throw cms::Exception("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::beginRun\n"
634  << "Using data (run = " << run.run() << ") prior to the first defined IOV ("
635  << firstIOV_ << ").";
636  }
637 
638  lastProcessedRun_ = run.run();
639 
640  if (changed && enableAlignableUpdates_) {
641  const auto runNumber = run.run();
643  for (auto runRange = uniqueRunRanges_.crbegin(); runRange != uniqueRunRanges_.crend(); ++runRange) {
644  if (runNumber >= runRange->first) {
645  firstRun = runRange->first;
646  break;
647  }
648  }
649  if (std::find(cachedRuns_.begin(), cachedRuns_.end(), firstRun) != cachedRuns_.end()) {
650  const auto &geometryRcd = setup.get<IdealGeometryRecord>();
651  const auto &globalPosRcd = setup.get<GlobalPositionRcd>();
652  const auto &alignmentRcd = setup.get<TrackerAlignmentRcd>();
653  const auto &surfaceRcd = setup.get<TrackerSurfaceDeformationRcd>();
654  const auto &errorRcd = setup.get<TrackerAlignmentErrorExtendedRcd>();
655 
656  std::ostringstream message;
657  bool throwException{false};
658  message << "Trying to cache tracker alignment payloads for a run (" << runNumber << ") in an IOV (" << firstRun
659  << ") that was already cached.\n"
660  << "The following records in your input database tag have an IOV "
661  << "boundary that does not match your IOV definition:\n";
662  if (geometryRcd.validityInterval().first().eventID().run() > firstRun) {
663  message << " - IdealGeometryRecord '" << geometryRcd.key().name() << "' (since "
664  << geometryRcd.validityInterval().first().eventID().run() << ")\n";
665  throwException = true;
666  }
667  if (globalPosRcd.validityInterval().first().eventID().run() > firstRun) {
668  message << " - GlobalPositionRecord '" << globalPosRcd.key().name() << "' (since "
669  << globalPosRcd.validityInterval().first().eventID().run() << ")";
671  message << " --> ignored\n";
672  } else {
673  message << "\n";
674  throwException = true;
675  }
676  }
677  if (alignmentRcd.validityInterval().first().eventID().run() > firstRun) {
678  message << " - TrackerAlignmentRcd '" << alignmentRcd.key().name() << "' (since "
679  << alignmentRcd.validityInterval().first().eventID().run() << ")\n";
680  throwException = true;
681  }
682  if (surfaceRcd.validityInterval().first().eventID().run() > firstRun) {
683  message << " - TrackerSurfaceDeformationRcd '" << surfaceRcd.key().name() << "' (since "
684  << surfaceRcd.validityInterval().first().eventID().run() << ")\n";
685  throwException = true;
686  }
687  if (errorRcd.validityInterval().first().eventID().run() > firstRun) {
688  message << " - TrackerAlignmentErrorExtendedRcd '" << errorRcd.key().name() << "' (since "
689  << errorRcd.validityInterval().first().eventID().run() << ")\n";
690  throwException = true;
691  }
692 
693  if (throwException) {
694  throw cms::Exception("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::beginRun\n" << message.str();
695  }
696  } else {
697  cachedRuns_.push_back(firstRun);
699  }
700  }
701 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
const IOVSyncValue & first() const
Time_t beginValue
Definition: Time.h:41
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< align::RunNumber > cachedRuns_
RunNumber_t run() const
Definition: RunBase.h:40
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
RunNumber_t run() const
Definition: EventID.h:38
const EventID & eventID() const
Definition: IOVSyncValue.h:40
void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override
Run the algorithm on trajectories and tracks.
void cacheTransformations(void)
cache the current position, rotation and other parameters
firstRun
Definition: dataset.py:940
ValidityInterval validityInterval() const
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ buildUserVariables()

void MillePedeAlignmentAlgorithm::buildUserVariables ( const align::Alignables alignables) const
private

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

Definition at line 1158 of file MillePedeAlignmentAlgorithm.cc.

References Exception, submitPVValidationJobs::params, MillePedeVariables::setAllDefault(), MillePedeVariables::size(), and thePedeLabels.

Referenced by initialize(), and setParametersForRunRange().

1158  {
1159  for (const auto &iAli : alis) {
1160  AlignmentParameters *params = iAli->alignmentParameters();
1161  if (!params) {
1162  throw cms::Exception("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::buildUserVariables"
1163  << "No parameters for alignable";
1164  }
1165  MillePedeVariables *userVars = dynamic_cast<MillePedeVariables *>(params->userVariables());
1166  if (userVars) { // Just re-use existing, keeping label and numHits:
1167  for (unsigned int iPar = 0; iPar < userVars->size(); ++iPar) {
1168  // if (params->hierarchyLevel() > 0) {
1169  //std::cout << params->hierarchyLevel() << "\nBefore: " << userVars->parameter()[iPar];
1170  // }
1171  userVars->setAllDefault(iPar);
1172  //std::cout << "\nAfter: " << userVars->parameter()[iPar] << std::endl;
1173  }
1174  } else { // Nothing yet or erase wrong type:
1175  userVars = new MillePedeVariables(
1176  params->size(),
1177  thePedeLabels->alignableLabel(iAli),
1178  thePedeLabels->alignableTracker()->objectIdProvider().typeToName(iAli->alignableObjectId()));
1179  params->setUserVariables(userVars);
1180  }
1181  }
1182 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
unsigned int size() const
number of parameters
bool setAllDefault(unsigned int nParam)
set default values for all data concerning nParam (false if nParam out of range)

◆ callMille()

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 1344 of file MillePedeAlignmentAlgorithm.cc.

References callMille1D(), and callMille2D().

Referenced by addMeasurementData().

1348  {
1349  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1350 
1351  if ((aRecHit)->dimension() == 1) {
1352  return this->callMille1D(refTrajPtr, iTrajHit, globalLabels, globalDerivativesX);
1353  } else {
1354  return this->callMille2D(refTrajPtr, iTrajHit, globalLabels, globalDerivativesX, globalDerivativesY);
1355  }
1356 }
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

◆ callMille1D()

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 1359 of file MillePedeAlignmentAlgorithm.cc.

References mps_fire::i, theMille, and theMonitor.

Referenced by callMille().

1362  {
1363  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1364  const unsigned int xIndex = iTrajHit * 2; // the even ones are local x
1365 
1366  // local derivatives
1367  const AlgebraicMatrix &locDerivMatrix = refTrajPtr->derivatives();
1368  const int nLocal = locDerivMatrix.num_col();
1369  std::vector<float> localDerivatives(nLocal);
1370  for (unsigned int i = 0; i < localDerivatives.size(); ++i) {
1371  localDerivatives[i] = locDerivMatrix[xIndex][i];
1372  }
1373 
1374  // residuum and error
1375  float residX = refTrajPtr->measurements()[xIndex] - refTrajPtr->trajectoryPositions()[xIndex];
1376  float hitErrX = TMath::Sqrt(refTrajPtr->measurementErrors()[xIndex][xIndex]);
1377 
1378  // number of global derivatives
1379  const int nGlobal = globalDerivativesX.size();
1380 
1381  // &(localDerivatives[0]) etc. are valid - as long as vector is not empty
1382  // cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
1383  theMille->mille(
1384  nLocal, &(localDerivatives[0]), nGlobal, &(globalDerivativesX[0]), &(globalLabels[0]), residX, hitErrX);
1385 
1386  if (theMonitor) {
1387  theMonitor->fillDerivatives(
1388  aRecHit, &(localDerivatives[0]), nLocal, &(globalDerivativesX[0]), nGlobal, &(globalLabels[0]));
1389  theMonitor->fillResiduals(aRecHit, refTrajPtr->trajectoryStates()[iTrajHit], iTrajHit, residX, hitErrX, false);
1390  }
1391 
1392  return 1;
1393 }
std::unique_ptr< MillePedeMonitor > theMonitor
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
CLHEP::HepMatrix AlgebraicMatrix

◆ callMille2D()

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 1396 of file MillePedeAlignmentAlgorithm.cc.

References addRefTrackData2D(), alignCSCRings::corr, diagonalize(), pat::helper::ParametrizationHelper::dimension(), is2D(), makeGlobDerivMatrix(), mathSSE::sqrt(), std::swap(), SiStripDetId::TEC, theMaximalCor2D, theMille, theMonitor, SiStripDetId::TID, and DetId::Tracker.

Referenced by callMille().

1400  {
1401  const ConstRecHitPointer aRecHit(refTrajPtr->recHits()[iTrajHit]);
1402 
1403  if ((aRecHit)->dimension() != 2) {
1404  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::callMille2D"
1405  << "You try to call method for 2D hits for a " << (aRecHit)->dimension()
1406  << "D Hit. Hit gets ignored!";
1407  return -1;
1408  }
1409 
1410  Eigen::Matrix<double, 2, 2> aHitCovarianceM;
1411  Eigen::Matrix<float, 2, 1> aHitResidualsM;
1412  Eigen::Matrix<float, 2, Eigen::Dynamic> aLocalDerivativesM{2, refTrajPtr->derivatives().num_col()};
1413  // below method fills above 3 matrices
1414  this->addRefTrackData2D(refTrajPtr, iTrajHit, aHitCovarianceM, aHitResidualsM, aLocalDerivativesM);
1415  Eigen::Matrix<float, 2, Eigen::Dynamic> aGlobalDerivativesM{2, globalDerivativesx.size()};
1416  this->makeGlobDerivMatrix(globalDerivativesx, globalDerivativesy, aGlobalDerivativesM);
1417 
1418  // calculates correlation between Hit measurements
1419  // FIXME: Should take correlation (and resulting transformation) from original hit,
1420  // not 2x2 matrix from ReferenceTrajectory: That can come from error propagation etc.!
1421  const double corr = aHitCovarianceM(0, 1) / sqrt(aHitCovarianceM(0, 0) * aHitCovarianceM(1, 1));
1422  if (theMonitor)
1423  theMonitor->fillCorrelations2D(corr, aRecHit);
1424  bool diag = false; // diagonalise only tracker TID, TEC
1425  switch (aRecHit->geographicalId().subdetId()) {
1426  case SiStripDetId::TID:
1427  case SiStripDetId::TEC:
1428  if (aRecHit->geographicalId().det() == DetId::Tracker && TMath::Abs(corr) > theMaximalCor2D) {
1429  this->diagonalize(aHitCovarianceM, aLocalDerivativesM, aHitResidualsM, aGlobalDerivativesM);
1430  diag = true;
1431  }
1432  break;
1433  default:;
1434  }
1435 
1436  float newResidX = aHitResidualsM(0, 0);
1437  float newResidY = aHitResidualsM(1, 0);
1438  float newHitErrX = TMath::Sqrt(aHitCovarianceM(0, 0));
1439  float newHitErrY = TMath::Sqrt(aHitCovarianceM(1, 1));
1440 
1441  // change from column major (Eigen default) to row major to have row entries
1442  // in continuous memory
1443  std::vector<float> newLocalDerivs(aLocalDerivativesM.size());
1444  Eigen::Map<Eigen::Matrix<float, 2, Eigen::Dynamic, Eigen::RowMajor> >(
1445  newLocalDerivs.data(), aLocalDerivativesM.rows(), aLocalDerivativesM.cols()) = aLocalDerivativesM;
1446  float *newLocalDerivsX = &(newLocalDerivs[0]);
1447  float *newLocalDerivsY = &(newLocalDerivs[aLocalDerivativesM.cols()]);
1448 
1449  // change from column major (Eigen default) to row major to have row entries
1450  // in continuous memory
1451  std::vector<float> newGlobDerivs(aGlobalDerivativesM.size());
1452  Eigen::Map<Eigen::Matrix<float, 2, Eigen::Dynamic, Eigen::RowMajor> >(
1453  newGlobDerivs.data(), aGlobalDerivativesM.rows(), aGlobalDerivativesM.cols()) = aGlobalDerivativesM;
1454  float *newGlobDerivsX = &(newGlobDerivs[0]);
1455  float *newGlobDerivsY = &(newGlobDerivs[aGlobalDerivativesM.cols()]);
1456 
1457  const int nLocal = aLocalDerivativesM.cols();
1458  const int nGlobal = aGlobalDerivativesM.cols();
1459 
1460  if (diag && (newHitErrX > newHitErrY)) { // also for 2D hits?
1461  // measurement with smaller error is x-measurement (for !is2D do not fill y-measurement):
1462  std::swap(newResidX, newResidY);
1463  std::swap(newHitErrX, newHitErrY);
1464  std::swap(newLocalDerivsX, newLocalDerivsY);
1465  std::swap(newGlobDerivsX, newGlobDerivsY);
1466  }
1467 
1468  // &(globalLabels[0]) is valid - as long as vector is not empty
1469  // cf. http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3
1470  theMille->mille(nLocal, newLocalDerivsX, nGlobal, newGlobDerivsX, &(globalLabels[0]), newResidX, newHitErrX);
1471 
1472  if (theMonitor) {
1473  theMonitor->fillDerivatives(aRecHit, newLocalDerivsX, nLocal, newGlobDerivsX, nGlobal, &(globalLabels[0]));
1474  theMonitor->fillResiduals(
1475  aRecHit, refTrajPtr->trajectoryStates()[iTrajHit], iTrajHit, newResidX, newHitErrX, false);
1476  }
1477  const bool isReal2DHit = this->is2D(aRecHit); // strip is 1D (except matched hits)
1478  if (isReal2DHit) {
1479  theMille->mille(nLocal, newLocalDerivsY, nGlobal, newGlobDerivsY, &(globalLabels[0]), newResidY, newHitErrY);
1480  if (theMonitor) {
1481  theMonitor->fillDerivatives(aRecHit, newLocalDerivsY, nLocal, newGlobDerivsY, nGlobal, &(globalLabels[0]));
1482  theMonitor->fillResiduals(
1483  aRecHit, refTrajPtr->trajectoryStates()[iTrajHit], iTrajHit, newResidY, newHitErrY, true); // true: y
1484  }
1485  }
1486 
1487  return (isReal2DHit ? 2 : 1);
1488 }
std::unique_ptr< MillePedeMonitor > theMonitor
static constexpr auto TID
Definition: SiStripDetId.h:38
Log< level::Error, false > LogError
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
dictionary corr
bool is2D(const TransientTrackingRecHit::ConstRecHitPointer &recHit) const
true if hit belongs to 2D detector (currently tracker specific)
void makeGlobDerivMatrix(const std::vector< float > &globalDerivativesx, const std::vector< float > &globalDerivativesy, Eigen::MatrixBase< GlobalDerivativeMatrix > &aGlobalDerivativesM)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
void diagonalize(Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< LocalDerivativeMatrix > &aLocalDerivativesM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< GlobalDerivativeMatrix > &aGlobalDerivativesM) const
void addRefTrackData2D(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr, unsigned int iTrajHit, Eigen::MatrixBase< CovarianceMatrix > &aHitCovarianceM, Eigen::MatrixBase< ResidualMatrix > &aHitResidualsM, Eigen::MatrixBase< LocalDerivativeMatrix > &aLocalDerivativesM)
adds data from reference trajectory from a specific Hit
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
static constexpr auto TEC
Definition: SiStripDetId.h:40

◆ decodeMode()

unsigned int MillePedeAlignmentAlgorithm::decodeMode ( const std::string &  mode) const
private

Definition at line 1185 of file MillePedeAlignmentAlgorithm.cc.

References Exception, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, myMilleBit, myPedeReadBit, myPedeRunBit, and myPedeSteerBit.

1185  {
1186  if (mode == "full") {
1188  } else if (mode == "mille") {
1189  return myMilleBit; // + myPedeSteerBit; // sic! Including production of steerig file. NO!
1190  } else if (mode == "pede") {
1192  } else if (mode == "pedeSteer") {
1193  return myPedeSteerBit;
1194  } else if (mode == "pedeRun") {
1195  return myPedeSteerBit + myPedeRunBit + myPedeReadBit; // sic! Including steering and reading of result.
1196  } else if (mode == "pedeRead") {
1197  return myPedeReadBit;
1198  }
1199 
1200  throw cms::Exception("BadConfig") << "Unknown mode '" << mode
1201  << "', use 'full', 'mille', 'pede', 'pedeRun', 'pedeSteer' or 'pedeRead'.";
1202 
1203  return 0;
1204 }

◆ diagonalize()

template<typename CovarianceMatrix , typename LocalDerivativeMatrix , typename ResidualMatrix , typename GlobalDerivativeMatrix >
void MillePedeAlignmentAlgorithm::diagonalize ( Eigen::MatrixBase< CovarianceMatrix > &  aHitCovarianceM,
Eigen::MatrixBase< LocalDerivativeMatrix > &  aLocalDerivativesM,
Eigen::MatrixBase< ResidualMatrix > &  aHitResidualsM,
Eigen::MatrixBase< GlobalDerivativeMatrix > &  aGlobalDerivativesM 
) const
private

Definition at line 1270 of file MillePedeAlignmentAlgorithm.cc.

References relativeConstraints::value.

Referenced by callMille2D().

1273  {
1275  "'aLocalDerivativesM' and 'aHitResidualsM' must have the "
1276  "same underlying scalar type");
1278  "'aLocalDerivativesM' and 'aGlobalDerivativesM' must have the "
1279  "same underlying scalar type");
1280 
1281  Eigen::SelfAdjointEigenSolver<typename CovarianceMatrix::PlainObject> myDiag{aHitCovarianceM};
1282  // eigenvectors of real symmetric matrices are orthogonal, i.e. invert == transpose
1283  auto aTranfoToDiagonalSystemInv =
1284  myDiag.eigenvectors().transpose().template cast<typename LocalDerivativeMatrix::Scalar>();
1285 
1286  aHitCovarianceM = myDiag.eigenvalues().asDiagonal();
1287  aLocalDerivativesM = aTranfoToDiagonalSystemInv * aLocalDerivativesM;
1288  aHitResidualsM = aTranfoToDiagonalSystemInv * aHitResidualsM;
1289  if (aGlobalDerivativesM.size() > 0) {
1290  // diagonalize only if measurement depends on alignables or calibrations
1291  aGlobalDerivativesM = aTranfoToDiagonalSystemInv * aGlobalDerivativesM;
1292  }
1293 }

◆ doIO()

unsigned int MillePedeAlignmentAlgorithm::doIO ( int  loop) const
private

Definition at line 1101 of file MillePedeAlignmentAlgorithm.cc.

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

Referenced by setParametersForRunRange(), and terminate().

1101  {
1102  unsigned int result = 0;
1103 
1104  const std::string outFilePlain(theConfig.getParameter<std::string>("treeFile"));
1105  if (outFilePlain.empty()) {
1106  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1107  << "treeFile parameter empty => skip writing for 'loop' " << loop;
1108  return result;
1109  }
1110 
1111  const std::string outFile(theDir + outFilePlain);
1112 
1113  AlignmentIORoot aliIO;
1114  int ioerr = 0;
1115  if (loop == 0) {
1116  aliIO.writeAlignableOriginalPositions(theAlignables, outFile.c_str(), loop, false, ioerr);
1117  if (ioerr) {
1118  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1119  << "Problem " << ioerr << " in writeAlignableOriginalPositions";
1120  ++result;
1121  }
1122  } else if (loop == 1) {
1123  // only for first iov add hit counts, else 2x, 3x,... number of hits in IOV 2, 3,...
1124  const std::vector<std::string> inFiles(theConfig.getParameter<std::vector<std::string> >("mergeTreeFiles"));
1125  const std::vector<std::string> binFiles(theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles"));
1126  if (inFiles.size() != binFiles.size()) {
1127  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1128  << "'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' "
1129  << "differ in size";
1130  }
1131  this->addHitStatistics(0, outFile, inFiles); // add hit info from tree 0 in 'infiles'
1132  }
1133  MillePedeVariablesIORoot millePedeIO;
1134  millePedeIO.writeMillePedeVariables(theAlignables, outFile.c_str(), loop, false, ioerr);
1135  if (ioerr) {
1136  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1137  << "Problem " << ioerr << " writing MillePedeVariables";
1138  ++result;
1139  }
1140 
1141  aliIO.writeOrigRigidBodyAlignmentParameters(theAlignables, outFile.c_str(), loop, false, ioerr);
1142  if (ioerr) {
1143  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1144  << "Problem " << ioerr << " in writeOrigRigidBodyAlignmentParameters, " << loop;
1145  ++result;
1146  }
1147  aliIO.writeAlignableAbsolutePositions(theAlignables, outFile.c_str(), loop, false, ioerr);
1148  if (ioerr) {
1149  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::doIO"
1150  << "Problem " << ioerr << " in writeAlignableAbsolutePositions, " << loop;
1151  ++result;
1152  }
1153 
1154  return result;
1155 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Error, false > LogError
void writeMillePedeVariables(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)
void writeAlignableOriginalPositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr) override
write Alignable original (before misalignment) absolute positions
void writeOrigRigidBodyAlignmentParameters(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr) override
write RigidBodyAlignmentParameters as applied on top of original positions
bool addHitStatistics(int fromLoop, const std::string &outFile, const std::vector< std::string > &inFiles) const
Log< level::Info, false > LogInfo
void writeAlignableAbsolutePositions(const align::Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr) override
write Alignable current absolute positions
Log< level::Warning, false > LogWarning

◆ endLuminosityBlock()

void MillePedeAlignmentAlgorithm::endLuminosityBlock ( const edm::EventSetup )
overridevirtual

called at end of luminosity block

Reimplemented from AlignmentAlgorithmBase.

Definition at line 730 of file MillePedeAlignmentAlgorithm.cc.

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

730  {
731  if (!runAtPCL_)
732  return;
733  if (this->isMode(myMilleBit))
734  theMille->flushOutputFile();
735 }
bool isMode(unsigned int testMode) const

◆ endRun() [1/2]

void MillePedeAlignmentAlgorithm::endRun ( const EventInfo eventInfo,
const EndRunInfo runInfo,
const edm::EventSetup setup 
)
virtual

Run on run products, e.g. TkLAS.

Definition at line 704 of file MillePedeAlignmentAlgorithm.cc.

References addLaserData(), isMode(), myMilleBit, submitPVValidationJobs::runInfo, and theMille.

706  {
707  if (runInfo.tkLasBeams() && runInfo.tkLasBeamTsoses()) {
708  // LAS beam treatment
709  this->addLaserData(eventInfo, *(runInfo.tkLasBeams()), *(runInfo.tkLasBeamTsoses()));
710  }
711  if (this->isMode(myMilleBit))
712  theMille->flushOutputFile();
713 }
bool isMode(unsigned int testMode) const
void addLaserData(const EventInfo &eventInfo, const TkFittedLasBeamCollection &tkLasBeams, const TsosVectorCollection &tkLasBeamTsoses)
const TkFittedLasBeamCollection * tkLasBeams() const

◆ endRun() [2/2]

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 716 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), myMilleBit, and theMille.

716  {
717  if (this->isMode(myMilleBit))
718  theMille->flushOutputFile();
719 }
bool isMode(unsigned int testMode) const

◆ getExistingFormattedFiles()

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 434 of file MillePedeAlignmentAlgorithm.cc.

References edmScanValgrind::buffer, submitPVResolutionJobs::files, edm_modernize_messagelogger::stat, AlCaHLTBitMon_QueryRunRegistry::string, and theDir.

Referenced by terminate().

435  {
436  std::vector<std::string> files;
437  for (const auto &plainFile : plainFiles) {
438  const std::string &theInputFileName = plainFile;
439  int theNumber = 0;
440  while (true) {
441  // Create a formatted version of the filename, with growing numbers
442  // If the parameter doesn't contain a formatting directive, it just stays unchanged
443  char theNumberedInputFileName[200];
444  sprintf(theNumberedInputFileName, theInputFileName.c_str(), theNumber);
445  std::string theCompleteInputFileName = theDir + theNumberedInputFileName;
446  const auto endOfStrippedFileName = theCompleteInputFileName.rfind(" --");
447  const auto strippedInputFileName = theCompleteInputFileName.substr(0, endOfStrippedFileName);
448  // Check if the file exists
449  struct stat buffer;
450  if (stat(strippedInputFileName.c_str(), &buffer) == 0) {
451  // If the file exists, add it to the list
452  files.push_back(theCompleteInputFileName);
453  if (theNumberedInputFileName == theInputFileName) {
454  // If the filename didn't contain a formatting directive, no reason to look any further, break out of the loop
455  break;
456  } else {
457  // Otherwise look for the next number
458  theNumber++;
459  }
460  } else {
461  // The file doesn't exist, break out of the loop
462  break;
463  }
464  }
465  // warning if unformatted (-> theNumber stays at 0) does not exist
466  if (theNumber == 0 && (files.empty() || files.back() != plainFile)) {
467  edm::LogWarning("Alignment") << "The input file '" << plainFile << "' does not exist.";
468  }
469  }
470  return files;
471 }
Log< level::Warning, false > LogWarning

◆ globalDerivativesCalibration()

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 968 of file MillePedeAlignmentAlgorithm.cc.

References dumpTauVariables_cfi::eventInfo, rpcPointValidation_cfi::recHit, singleTopDQM_cfi::setup, theCalibrations, and thePedeLabels.

Referenced by addMeasurementData().

974  {
975  std::vector<IntegratedCalibrationBase::ValuesIndexPair> derivs;
976  for (auto iCalib = theCalibrations.begin(); iCalib != theCalibrations.end(); ++iCalib) {
977  // get all derivatives of this calibration // const unsigned int num =
978  (*iCalib)->derivatives(derivs, *recHit, tsos, setup, eventInfo);
979  for (auto iValuesInd = derivs.begin(); iValuesInd != derivs.end(); ++iValuesInd) {
980  // transfer label and x/y derivatives
981  globalLabels.push_back(thePedeLabels->calibrationLabel(*iCalib, iValuesInd->second));
982  globalDerivativesX.push_back(iValuesInd->first.first);
983  globalDerivativesY.push_back(iValuesInd->first.second);
984  }
985  }
986 }
std::shared_ptr< PedeLabelerBase > thePedeLabels
std::vector< IntegratedCalibrationBase * > theCalibrations
eventInfo
add run, event number and lumi section

◆ globalDerivativesHierarchy() [1/2]

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 851 of file MillePedeAlignmentAlgorithm.cc.

References Alignable::alignmentParameters(), dumpTauVariables_cfi::eventInfo, kLocalX, kLocalY, Alignable::mother(), submitPVValidationJobs::params, theMonitor, thePedeLabels, and thePedeSteer.

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

858  {
859  // derivatives and labels are recursively attached
860  if (!ali)
861  return true; // no mother might be OK
862 
863  if (false && theMonitor && alidet != ali)
864  theMonitor->fillFrameToFrame(alidet, ali);
865 
867 
868  if (params) {
869  if (!lowestParams)
870  lowestParams = params; // set parameters of lowest level
871 
872  bool hasSplitParameters = thePedeLabels->hasSplitParameters(ali);
873  const unsigned int alignableLabel = thePedeLabels->alignableLabel(ali);
874 
875  if (0 == alignableLabel) { // FIXME: what about regardAllHits in Markus' code?
876  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
877  << "Label not found, skip Alignable.";
878  return false;
879  }
880 
881  const std::vector<bool> &selPars = params->selector();
882  const AlgebraicMatrix derivs(params->derivatives(tsos, alidet));
883 
884  // cols: 2, i.e. x&y, rows: parameters, usually RigidBodyAlignmentParameters::N_PARAM
885  for (unsigned int iSel = 0; iSel < selPars.size(); ++iSel) {
886  if (selPars[iSel]) {
887  globalDerivativesX.push_back(derivs[iSel][kLocalX] / thePedeSteer->cmsToPedeFactor(iSel));
888  if (hasSplitParameters == true) {
889  globalLabels.push_back(thePedeLabels->parameterLabel(ali, iSel, eventInfo, tsos));
890  } else {
891  globalLabels.push_back(thePedeLabels->parameterLabel(alignableLabel, iSel));
892  }
893  globalDerivativesY.push_back(derivs[iSel][kLocalY] / thePedeSteer->cmsToPedeFactor(iSel));
894  }
895  }
896  // Exclude mothers if Alignable selected to be no part of a hierarchy:
897  if (thePedeSteer->isNoHiera(ali))
898  return true;
899  }
900  // Call recursively for mother, will stop if mother == 0:
901  return this->globalDerivativesHierarchy(
902  eventInfo, tsos, ali->mother(), alidet, globalDerivativesX, globalDerivativesY, globalLabels, lowestParams);
903 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91
std::unique_ptr< MillePedeMonitor > theMonitor
std::shared_ptr< PedeLabelerBase > thePedeLabels
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
CLHEP::HepMatrix AlgebraicMatrix
std::unique_ptr< PedeSteerer > thePedeSteer
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning

◆ globalDerivativesHierarchy() [2/2]

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 906 of file MillePedeAlignmentAlgorithm.cc.

References Alignable::alignmentParameters(), dumpTauVariables_cfi::eventInfo, globalDerivativesHierarchy(), kLocalX, kLocalY, Alignable::mother(), submitPVValidationJobs::params, theMonitor, thePedeLabels, and thePedeSteer.

913  {
914  // derivatives and labels are recursively attached
915  if (!ali)
916  return true; // no mother might be OK
917 
918  if (false && theMonitor && alidet != ali)
919  theMonitor->fillFrameToFrame(alidet, ali);
920 
922 
923  if (params) {
924  if (!lowestParams)
925  lowestParams = params; // set parameters of lowest level
926 
927  bool hasSplitParameters = thePedeLabels->hasSplitParameters(ali);
928  const unsigned int alignableLabel = thePedeLabels->alignableLabel(ali);
929 
930  if (0 == alignableLabel) { // FIXME: what about regardAllHits in Markus' code?
931  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
932  << "Label not found, skip Alignable.";
933  return false;
934  }
935 
936  const std::vector<bool> &selPars = params->selector();
937  const AlgebraicMatrix derivs(params->derivatives(tsos, alidet));
938  int globalLabel;
939 
940  // cols: 2, i.e. x&y, rows: parameters, usually RigidBodyAlignmentParameters::N_PARAM
941  for (unsigned int iSel = 0; iSel < selPars.size(); ++iSel) {
942  if (selPars[iSel]) {
943  if (hasSplitParameters == true) {
944  globalLabel = thePedeLabels->parameterLabel(ali, iSel, eventInfo, tsos);
945  } else {
946  globalLabel = thePedeLabels->parameterLabel(alignableLabel, iSel);
947  }
948  if (globalLabel > 0 && globalLabel <= 2147483647) {
949  globalLabels.push_back(globalLabel);
950  globalDerivativesX.push_back(derivs[iSel][kLocalX] / thePedeSteer->cmsToPedeFactor(iSel));
951  globalDerivativesY.push_back(derivs[iSel][kLocalY] / thePedeSteer->cmsToPedeFactor(iSel));
952  } else {
953  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::globalDerivativesHierarchy"
954  << "Invalid label " << globalLabel << " <= 0 or > 2147483647";
955  }
956  }
957  }
958  // Exclude mothers if Alignable selected to be no part of a hierarchy:
959  if (thePedeSteer->isNoHiera(ali))
960  return true;
961  }
962  // Call recursively for mother, will stop if mother == 0:
963  return this->globalDerivativesHierarchy(
964  eventInfo, tsos, ali->mother(), alidet, globalDerivativesX, globalDerivativesY, globalLabels, lowestParams);
965 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:91
std::unique_ptr< MillePedeMonitor > theMonitor
std::shared_ptr< PedeLabelerBase > thePedeLabels
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
Log< level::Error, false > LogError
CLHEP::HepMatrix AlgebraicMatrix
std::unique_ptr< PedeSteerer > thePedeSteer
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning

◆ initialize()

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 136 of file MillePedeAlignmentAlgorithm.cc.

References addPxbSurvey(), edm::ParameterSet::addUntrackedParameter(), AlignmentParameterStore::alignables(), aliThrToken_, AlignmentParameterStore::applyParameters(), cond::TimeTypeSpecs::beginValue, buildUserVariables(), relativeConstraints::empty, cond::TimeTypeSpecs::endValue, enforceSingleIOVInput_, Exception, edm::ParameterSet::exists(), geomToken_, get, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isMode(), crabWrapper::key, cond::time::MAX_VAL(), cond::time::MIN_VAL(), HLT_2022v15_cff::muon, myMilleBit, myPedeSteerBit, pixelTopologyMap, readFromPede(), AlignmentParameterStore::resetParameters(), runAtPCL_, cond::runnumber, singleTopDQM_cfi::setup, storeThresholds(), AlCaHLTBitMon_QueryRunRegistry::string, theAlignableNavigator, theAlignables, theAlignmentParameterStore, theConfig, theDir, theDoSurveyPixelBarrel, theMonitor, thePedeLabels, thePedeSteer, theThresholds, cond::persistency::throwException(), cond::timeTypeSpecs, topoToken_, and PbPb_ZMuSkimMuonDPG_cff::tracker.

140  {
141  if (muon) {
142  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
143  << "Running with AlignabeMuon not yet tested.";
144  }
145 
149  const auto &iov_alignments = setup.get<TrackerAlignmentRcd>().validityInterval();
150  const auto &iov_surfaces = setup.get<TrackerSurfaceDeformationRcd>().validityInterval();
151  const auto &iov_errors = setup.get<TrackerAlignmentErrorExtendedRcd>().validityInterval();
152 
153  std::ostringstream message;
154  bool throwException{false};
155  if (iov_alignments.first().eventID().run() != MIN_VAL || iov_alignments.last().eventID().run() != MAX_VAL) {
156  message << "\nTrying to apply " << setup.get<TrackerAlignmentRcd>().key().name()
157  << " with multiple IOVs in tag without specifying 'RunRangeSelection'.\n"
158  << "Validity range is " << iov_alignments.first().eventID().run() << " - "
159  << iov_alignments.last().eventID().run() << "\n";
160  throwException = true;
161  }
162  if (iov_surfaces.first().eventID().run() != MIN_VAL || iov_surfaces.last().eventID().run() != MAX_VAL) {
163  message << "\nTrying to apply " << setup.get<TrackerSurfaceDeformationRcd>().key().name()
164  << " with multiple IOVs in tag without specifying 'RunRangeSelection'.\n"
165  << "Validity range is " << iov_surfaces.first().eventID().run() << " - "
166  << iov_surfaces.last().eventID().run() << "\n";
167  throwException = true;
168  }
169  if (iov_errors.first().eventID().run() != MIN_VAL || iov_errors.last().eventID().run() != MAX_VAL) {
170  message << "\nTrying to apply " << setup.get<TrackerAlignmentErrorExtendedRcd>().key().name()
171  << " with multiple IOVs in tag without specifying 'RunRangeSelection'.\n"
172  << "Validity range is " << iov_errors.first().eventID().run() << " - "
173  << iov_errors.last().eventID().run() << "\n";
174  throwException = true;
175  }
176  if (throwException) {
177  throw cms::Exception("DatabaseError") << "@SUB=MillePedeAlignmentAlgorithm::initialize" << message.str();
178  }
179  }
180 
181  //Retrieve tracker topology from geometry
182  const TrackerTopology *const tTopo = &setup.getData(topoToken_);
183 
184  //Retrieve the thresolds cuts from DB for the PCL
185  if (runAtPCL_) {
186  const auto &th = &setup.getData(aliThrToken_);
187  theThresholds = std::make_shared<AlignPCLThresholdsHG>();
188  storeThresholds(th->getNrecords(), th->getThreshold_Map(), th->getFloatMap());
189 
190  //Retrieve tracker geometry
191  const TrackerGeometry *tGeom = &setup.getData(geomToken_);
192  //Retrieve PixelTopologyMap
193  pixelTopologyMap = std::make_shared<PixelTopologyMap>(tGeom, tTopo);
194  }
195 
196  theAlignableNavigator = std::make_unique<AlignableNavigator>(extras, tracker, muon);
199 
200  edm::ParameterSet pedeLabelerCfg(theConfig.getParameter<edm::ParameterSet>("pedeLabeler"));
201  edm::VParameterSet RunRangeSelectionVPSet(theConfig.getUntrackedParameter<edm::VParameterSet>("RunRangeSelection"));
202  pedeLabelerCfg.addUntrackedParameter<edm::VParameterSet>("RunRangeSelection", RunRangeSelectionVPSet);
203 
204  std::string labelerPlugin = "PedeLabeler";
205  if (!RunRangeSelectionVPSet.empty()) {
206  labelerPlugin = "RunRangeDependentPedeLabeler";
207  if (pedeLabelerCfg.exists("plugin")) {
208  std::string labelerPluginCfg = pedeLabelerCfg.getParameter<std::string>("plugin");
209  if ((labelerPluginCfg != "PedeLabeler" && labelerPluginCfg != "RunRangeDependentPedeLabeler") ||
210  !pedeLabelerCfg.getUntrackedParameter<edm::VParameterSet>("parameterInstances").empty()) {
211  throw cms::Exception("BadConfig") << "MillePedeAlignmentAlgorithm::initialize"
212  << "both RunRangeSelection and generic labeler specified in config file. "
213  << "Please get rid of either one of them.\n";
214  }
215  }
216  } else {
217  if (pedeLabelerCfg.exists("plugin")) {
218  labelerPlugin = pedeLabelerCfg.getParameter<std::string>("plugin");
219  }
220  }
221 
222  if (!pedeLabelerCfg.exists("plugin")) {
223  pedeLabelerCfg.addUntrackedParameter<std::string>("plugin", labelerPlugin);
224  }
225 
226  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
227  << "Using plugin '" << labelerPlugin << "' to generate labels.";
228 
229  thePedeLabels = std::shared_ptr<PedeLabelerBase>(PedeLabelerPluginFactory::get()->create(
230  labelerPlugin, PedeLabelerBase::TopLevelAlignables(tracker, muon, extras), pedeLabelerCfg));
231 
232  // 1) Create PedeSteerer: correct alignable positions for coordinate system selection
233  edm::ParameterSet pedeSteerCfg(theConfig.getParameter<edm::ParameterSet>("pedeSteerer"));
234  thePedeSteer = std::make_unique<PedeSteerer>(tracker,
235  muon,
236  extras,
238  thePedeLabels.get(),
239  pedeSteerCfg,
240  theDir,
241  !this->isMode(myPedeSteerBit));
242 
243  // 2) If requested, directly read in and apply result of previous pede run,
244  // assuming that correction from 1) was also applied to create the result:
245  const std::vector<edm::ParameterSet> mprespset(
246  theConfig.getParameter<std::vector<edm::ParameterSet> >("pedeReaderInputs"));
247  if (!mprespset.empty()) {
248  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::initialize"
249  << "Apply " << mprespset.end() - mprespset.begin()
250  << " previous MillePede constants from 'pedeReaderInputs'.";
251  }
252 
253  // FIXME: add selection of run range via 'pedeReaderInputs'
254  // Note: Results for parameters of IntegratedCalibration's cannot be treated...
256  for (std::vector<edm::ParameterSet>::const_iterator iSet = mprespset.begin(), iE = mprespset.end(); iSet != iE;
257  ++iSet) {
258  // This read will ignore calibrations as long as they are not yet passed to Millepede
259  // during/before initialize(..) - currently addCalibrations(..) is called later in AlignmentProducer
260  if (!this->readFromPede((*iSet), false, runrange)) { // false: do not erase SelectionUserVariables
261  throw cms::Exception("BadConfig")
262  << "MillePedeAlignmentAlgorithm::initialize: Problems reading input constants of "
263  << "pedeReaderInputs entry " << iSet - mprespset.begin() << '.';
264  }
266  // Needed to shut up later warning from checkAliParams:
268  }
269 
270  // 3) Now create steerings with 'final' start position:
271  thePedeSteer->buildSubSteer(tracker, muon, extras);
272 
273  // After (!) 1-3 of PedeSteerer which uses the SelectionUserVariables attached to the parameters:
274  this->buildUserVariables(theAlignables); // for hit statistics and/or pede result
275 
276  if (this->isMode(myMilleBit)) {
277  if (!theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles").empty() ||
278  !theConfig.getParameter<std::vector<std::string> >("mergeTreeFiles").empty()) {
279  throw cms::Exception("BadConfig") << "'vstring mergeTreeFiles' and 'vstring mergeBinaryFiles' must be empty for "
280  << "modes running mille.";
281  }
282  const std::string moniFile(theConfig.getUntrackedParameter<std::string>("monitorFile"));
283  if (!moniFile.empty())
284  theMonitor = std::make_unique<MillePedeMonitor>(tTopo, (theDir + moniFile).c_str());
285 
286  // Get trajectory factory. In case nothing found, FrameWork will throw...
287  }
288 
289  if (this->isMode(myPedeSteerBit)) {
290  // Get config for survey and set flag accordingly
291  const edm::ParameterSet pxbSurveyCfg(theConfig.getParameter<edm::ParameterSet>("surveyPixelBarrel"));
292  theDoSurveyPixelBarrel = pxbSurveyCfg.getParameter<bool>("doSurvey");
294  this->addPxbSurvey(pxbSurveyCfg);
295  }
296 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
std::shared_ptr< AlignPCLThresholdsHG > theThresholds
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void resetParameters(void)
reset parameters, correlations, user variables
std::unique_ptr< MillePedeMonitor > theMonitor
Time_t beginValue
Definition: Time.h:41
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
const Time_t MIN_VAL(0)
std::shared_ptr< PedeLabelerBase > thePedeLabels
const align::Alignables & alignables(void) const
get all alignables
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
bool isMode(unsigned int testMode) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
T getUntrackedParameter(std::string const &, T const &) const
virtual bool storeThresholds(const int &nRecords, const AlignPCLThresholdsHG::threshold_map &thresholdMap, const AlignPCLThresholdsHG::param_map &floatMap)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
std::shared_ptr< PixelTopologyMap > pixelTopologyMap
const edm::ESGetToken< AlignPCLThresholdsHG, AlignPCLThresholdsHGRcd > aliThrToken_
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
std::unique_ptr< PedeSteerer > thePedeSteer
Log< level::Info, false > LogInfo
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 align::Alignables &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)
void addPxbSurvey(const edm::ParameterSet &pxbSurveyCfg)
add measurement data from PXB survey
#define get
std::unique_ptr< AlignableNavigator > theAlignableNavigator
Log< level::Warning, false > LogWarning
Time_t endValue
Definition: Time.h:42
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ is2D()

bool MillePedeAlignmentAlgorithm::is2D ( const TransientTrackingRecHit::ConstRecHitPointer recHit) const
private

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

Definition at line 1023 of file MillePedeAlignmentAlgorithm.cc.

References rpcPointValidation_cfi::recHit.

Referenced by callMille2D().

1023  {
1024  // FIXME: Check whether this is a reliable and recommended way to find out...
1025 
1026  if (recHit->dimension() < 2) {
1027  return false; // some muon and TIB/TOB stuff really has RecHit1D
1028  } else if (recHit->detUnit()) { // detunit in strip is 1D, in pixel 2D
1029  return recHit->detUnit()->type().isTrackerPixel();
1030  } else { // stereo strips (FIXME: endcap trouble due to non-parallel strips (wedge sensors)?)
1031  if (dynamic_cast<const ProjectedSiStripRecHit2D *>(recHit->hit())) { // check persistent hit
1032  // projected: 1D measurement on 'glued' module
1033  return false;
1034  } else {
1035  return true;
1036  }
1037  }
1038 }

◆ isMode()

bool MillePedeAlignmentAlgorithm::isMode ( unsigned int  testMode) const
inlineprivate

◆ makeGlobDerivMatrix()

template<typename GlobalDerivativeMatrix >
void MillePedeAlignmentAlgorithm::makeGlobDerivMatrix ( const std::vector< float > &  globalDerivativesx,
const std::vector< float > &  globalDerivativesy,
Eigen::MatrixBase< GlobalDerivativeMatrix > &  aGlobalDerivativesM 
)
private

Definition at line 1254 of file MillePedeAlignmentAlgorithm.cc.

References mps_fire::i.

Referenced by callMille2D().

1256  {
1257  static_assert(GlobalDerivativeMatrix::RowsAtCompileTime == 2, "global derivative matrix must have two rows");
1258 
1259  for (size_t i = 0; i < globalDerivativesx.size(); ++i) {
1260  aGlobalDerivativesM(0, i) = globalDerivativesx[i];
1261  aGlobalDerivativesM(1, i) = globalDerivativesy[i];
1262  }
1263 }

◆ processesEvents()

bool MillePedeAlignmentAlgorithm::processesEvents ( )
overridevirtual

Returns whether MP should process events in the current configuration.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 318 of file MillePedeAlignmentAlgorithm.cc.

References isMode(), and myMilleBit.

318  {
319  if (isMode(myMilleBit)) {
320  return true;
321  } else {
322  return false;
323  }
324 }
bool isMode(unsigned int testMode) const

◆ readFromPede()

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 1041 of file MillePedeAlignmentAlgorithm.cc.

References areEmptyParams(), MillePedeFileConverter_cfg::out, DQM::reader, theAlignables, thePedeLabels, and thePedeSteer.

Referenced by initialize(), and setParametersForRunRange().

1043  {
1044  bool allEmpty = this->areEmptyParams(theAlignables);
1045 
1046  PedeReader reader(mprespset, *thePedeSteer, *thePedeLabels, runrange);
1047  align::Alignables alis;
1048  bool okRead = reader.read(alis, setUserVars); // also may set params of IntegratedCalibration's
1049  bool numMatch = true;
1050 
1051  std::stringstream out;
1052  out << "Read " << alis.size() << " alignables";
1053  if (alis.size() != theAlignables.size()) {
1054  out << " while " << theAlignables.size() << " in store";
1055  numMatch = false; // FIXME: Should we check one by one? Or transfer 'alis' to the store?
1056  }
1057  if (!okRead)
1058  out << ", but problems in reading";
1059  if (!allEmpty)
1060  out << ", possibly overwriting previous settings";
1061  out << ".";
1062 
1063  if (okRead && allEmpty) {
1064  if (numMatch) { // as many alignables with result as trying to align
1065  edm::LogInfo("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
1066  } else if (!alis.empty()) { // dead module do not get hits and no pede result
1067  edm::LogWarning("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
1068  } else { // serious problem: no result read - and not all modules can be dead...
1069  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
1070  return false;
1071  }
1072  return true;
1073  }
1074  // the rest is not OK:
1075  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::readFromPede" << out.str();
1076  return false;
1077 }
bool areEmptyParams(const align::Alignables &alignables) const
std::shared_ptr< PedeLabelerBase > thePedeLabels
reader
Definition: DQM.py:105
Log< level::Error, false > LogError
std::unique_ptr< PedeSteerer > thePedeSteer
Log< level::Info, false > LogInfo
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
Log< level::Warning, false > LogWarning

◆ run()

void MillePedeAlignmentAlgorithm::run ( const edm::EventSetup setup,
const EventInfo eventInfo 
)
overridevirtual

Run the algorithm on trajectories and tracks.

Implements AlignmentAlgorithmBase.

Definition at line 475 of file MillePedeAlignmentAlgorithm.cc.

References addReferenceTrajectory(), dumpTauVariables_cfi::eventInfo, isMode(), myMilleBit, hltrates_dqm_sourceclient-live_cfg::offset, edm::second(), singleTopDQM_cfi::setup, theMonitor, theTrajectoryFactory, pwdgSkimBPark_cfi::tracks, FastTrackerRecHitMaskProducer_cfi::trajectories, and AlignmentAlgorithmBase::EventInfo::trajTrackPairs().

Referenced by DTWorkflow.DTWorkflow::all(), beginRun(), Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), o2olib.O2OTool::execute(), and terminate().

475  {
476  if (!this->isMode(myMilleBit))
477  return; // no theMille created...
478  const auto &tracks = eventInfo.trajTrackPairs();
479 
480  if (theMonitor) { // monitor input tracks
481  for (const auto &iTrajTrack : tracks) {
482  theMonitor->fillTrack(iTrajTrack.second);
483  }
484  }
485 
486  const RefTrajColl trajectories(theTrajectoryFactory->trajectories(setup, tracks, eventInfo.beamSpot()));
487 
488  // Now loop over ReferenceTrajectoryCollection
489  unsigned int refTrajCount = 0; // counter for track monitoring
490  const auto tracksPerTraj = theTrajectoryFactory->tracksPerTrajectory();
491  for (auto iRefTraj = trajectories.cbegin(), iRefTrajE = trajectories.cend(); iRefTraj != iRefTrajE;
492  ++iRefTraj, ++refTrajCount) {
493  const RefTrajColl::value_type &refTrajPtr = *iRefTraj;
494  if (theMonitor)
495  theMonitor->fillRefTrajectory(refTrajPtr);
496 
497  const auto nHitXy = this->addReferenceTrajectory(setup, eventInfo, refTrajPtr);
498 
499  if (theMonitor && (nHitXy.first || nHitXy.second)) {
500  // if trajectory used (i.e. some hits), fill monitoring
501  const auto offset = tracksPerTraj * refTrajCount;
502  for (unsigned int iTrack = 0; iTrack < tracksPerTraj; ++iTrack) {
503  theMonitor->fillUsedTrack(tracks[offset + iTrack].second, nHitXy.first, nHitXy.second);
504  }
505  }
506 
507  } // end of reference trajectory and track loop
508 }
const ConstTrajTrackPairCollection & trajTrackPairs() const
std::unique_ptr< MillePedeMonitor > theMonitor
TrajectoryFactoryBase::ReferenceTrajectoryCollection RefTrajColl
std::unique_ptr< TrajectoryFactoryBase > theTrajectoryFactory
bool isMode(unsigned int testMode) const
U second(std::pair< T, U > const &p)
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) ...
eventInfo
add run, event number and lumi section

◆ setParametersForRunRange()

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 345 of file MillePedeAlignmentAlgorithm.cc.

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

345  {
346  if (this->isMode(myPedeReadBit)) {
347  if (not theAlignmentParameterStore) {
348  return false;
349  }
350  // restore initial positions, rotations and deformations
353  } else {
355  }
356 
357  // Needed to shut up later warning from checkAliParams:
359  // To avoid that they keep values from previous IOV if no new one in pede result
361 
362  if (!this->readFromPede(theConfig.getParameter<edm::ParameterSet>("pedeReader"), true, runrange)) {
363  edm::LogError("Alignment") << "@SUB=MillePedeAlignmentAlgorithm::setParametersForRunRange"
364  << "Problems reading pede result, but applying!";
365  }
367 
368  this->doIO(++theLastWrittenIov); // pre-increment!
369  }
370 
371  return true;
372 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void resetParameters(void)
reset parameters, correlations, user variables
void restoreCachedTransformations(void)
restore the previously cached position, rotation and other parameters
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
bool isMode(unsigned int testMode) const
Log< level::Error, false > LogError
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 align::Alignables &alignables) const
add MillePedeVariables for each AlignmentParameters (exception if no parameters...)

◆ storeAlignments()

bool MillePedeAlignmentAlgorithm::storeAlignments ( )
overridevirtual

Returns whether MP produced results to be stored.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 327 of file MillePedeAlignmentAlgorithm.cc.

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

327  {
328  if (isMode(myPedeReadBit)) {
329  if (runAtPCL_) {
330  MillePedeFileReader mpReader(theConfig.getParameter<edm::ParameterSet>("MillePedeFileReader"),
334  mpReader.read();
335  return mpReader.storeAlignments();
336  } else {
337  return true;
338  }
339  } else {
340  return false;
341  }
342 }
std::shared_ptr< AlignPCLThresholdsHG > theThresholds
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::shared_ptr< PedeLabelerBase > thePedeLabels
bool isMode(unsigned int testMode) const
std::shared_ptr< PixelTopologyMap > pixelTopologyMap

◆ storeThresholds()

bool MillePedeAlignmentAlgorithm::storeThresholds ( const int &  nRecords,
const AlignPCLThresholdsHG::threshold_map thresholdMap,
const AlignPCLThresholdsHG::param_map floatMap 
)
virtual

Definition at line 309 of file MillePedeAlignmentAlgorithm.cc.

References theThresholds.

Referenced by initialize().

311  {
312  theThresholds->setAlignPCLThresholds(nRecords, thresholdMap);
313  theThresholds->setFloatMap(floatMap);
314  return true;
315 }
std::shared_ptr< AlignPCLThresholdsHG > theThresholds

◆ supportsCalibrations()

bool MillePedeAlignmentAlgorithm::supportsCalibrations ( )
overridevirtual

Returns whether MP supports calibrations.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 299 of file MillePedeAlignmentAlgorithm.cc.

299 { return true; }

◆ terminate() [1/2]

void MillePedeAlignmentAlgorithm::terminate ( const edm::EventSetup iSetup)
overridevirtual

Called at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 376 of file MillePedeAlignmentAlgorithm.cc.

References terminate().

376 { terminate(); }
void terminate() override
Called at end of job.

◆ terminate() [2/2]

void MillePedeAlignmentAlgorithm::terminate ( )
overridevirtual

Called at end of job.

Reimplemented from AlignmentAlgorithmBase.

Definition at line 377 of file MillePedeAlignmentAlgorithm.cc.

References cachedRuns_, AlignmentParameterStore::cacheTransformations(), doIO(), enableAlignableUpdates_, Exception, geometryDiff::file, submitPVResolutionJobs::files, spr::find(), getExistingFormattedFiles(), edm::ParameterSet::getParameter(), isMode(), lastProcessedRun_, myMilleBit, myPedeReadBit, myPedeRunBit, AlignmentParameterStore::restoreCachedTransformations(), run(), crab_NZS2018C_1::runRange, AlCaHLTBitMon_QueryRunRegistry::string, theAlignmentParameterStore, theBinary, theConfig, theDir, theLastWrittenIov, theMille, thePedeSteer, and uniqueRunRanges_.

Referenced by terminate().

377  {
378  theMille.reset(); // delete to close binary before running pede below (flush would be enough...)
379  theBinary.reset();
380 
381  std::vector<std::string> files;
382  if (this->isMode(myMilleBit) || !theConfig.getParameter<std::string>("binaryFile").empty()) {
383  files.push_back(theDir + theConfig.getParameter<std::string>("binaryFile"));
384  } else {
385  const std::vector<std::string> plainFiles(theConfig.getParameter<std::vector<std::string> >("mergeBinaryFiles"));
386  files = getExistingFormattedFiles(plainFiles, theDir);
387  // Do some logging:
388  std::string filesForLogOutput;
389  for (const auto &file : files)
390  filesForLogOutput += " " + file + ",";
391  if (filesForLogOutput.length() != 0)
392  filesForLogOutput.pop_back();
393  edm::LogInfo("Alignment") << "Based on the config parameter mergeBinaryFiles, using the following "
394  << "files as input (assigned weights are indicated by ' -- <weight>'):"
395  << filesForLogOutput;
396  }
397 
399  return;
400 
401  // cache all positions, rotations and deformations
404  if (lastProcessedRun_ < uniqueRunRanges_.back().first) {
405  throw cms::Exception("BadConfig") << "@SUB=MillePedeAlignmentAlgorithm::terminate\n"
406  << "Last IOV of 'RunRangeSelection' has not been processed. "
407  << "Please reconfigure your source to process the runs at least up to "
408  << uniqueRunRanges_.back().first << ".";
409  }
410  auto lastCachedRun = uniqueRunRanges_.front().first;
411  for (const auto &runRange : uniqueRunRanges_) {
412  const auto run = runRange.first;
413  if (std::find(cachedRuns_.begin(), cachedRuns_.end(), run) == cachedRuns_.end()) {
416  } else {
417  lastCachedRun = run;
418  }
419  }
421  }
422 
423  const std::string masterSteer(thePedeSteer->buildMasterSteer(files)); // do only if myPedeSteerBit?
424  if (this->isMode(myPedeRunBit)) {
425  thePedeSteer->runPede(masterSteer);
426  }
427 
428  // parameters from pede are not yet applied,
429  // so we can still write start positions (but with hit statistics in case of mille):
430  this->doIO(0);
431  theLastWrittenIov = 0;
432 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< gbl::MilleBinary > theBinary
void restoreCachedTransformations(void)
restore the previously cached position, rotation and other parameters
std::vector< std::string > getExistingFormattedFiles(const std::vector< std::string > &plainFiles, const std::string &theDir)
bool isMode(unsigned int testMode) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< align::RunNumber > cachedRuns_
AlignmentParameterStore * theAlignmentParameterStore
directory for all kind of files
std::unique_ptr< PedeSteerer > thePedeSteer
Log< level::Info, false > LogInfo
void run(const edm::EventSetup &setup, const EventInfo &eventInfo) override
Run the algorithm on trajectories and tracks.
void cacheTransformations(void)
cache the current position, rotation and other parameters

Member Data Documentation

◆ aliThrToken_

const edm::ESGetToken<AlignPCLThresholdsHG, AlignPCLThresholdsHGRcd> MillePedeAlignmentAlgorithm::aliThrToken_
private

Definition at line 280 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

◆ cachedRuns_

std::vector<align::RunNumber> MillePedeAlignmentAlgorithm::cachedRuns_
private

Definition at line 324 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun(), and terminate().

◆ enableAlignableUpdates_

const bool MillePedeAlignmentAlgorithm::enableAlignableUpdates_
private

Definition at line 308 of file MillePedeAlignmentAlgorithm.h.

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

◆ enforceSingleIOVInput_

const bool MillePedeAlignmentAlgorithm::enforceSingleIOVInput_
private

Definition at line 323 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

◆ firstIOV_

const align::RunNumber MillePedeAlignmentAlgorithm::firstIOV_
private

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

Definition at line 306 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun().

◆ geomToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> MillePedeAlignmentAlgorithm::geomToken_
private

Definition at line 281 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

◆ ignoreFirstIOVCheck_

const bool MillePedeAlignmentAlgorithm::ignoreFirstIOVCheck_
private

Definition at line 307 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun().

◆ ignoreHitsWithoutGlobalDerivatives_

const bool MillePedeAlignmentAlgorithm::ignoreHitsWithoutGlobalDerivatives_
private

Definition at line 319 of file MillePedeAlignmentAlgorithm.h.

Referenced by addMeasurementData().

◆ lastProcessedRun_

align::RunNumber MillePedeAlignmentAlgorithm::lastProcessedRun_
private

Definition at line 325 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun(), and terminate().

◆ pixelTopologyMap

std::shared_ptr<PixelTopologyMap> MillePedeAlignmentAlgorithm::pixelTopologyMap
private

Definition at line 302 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize(), and storeAlignments().

◆ runAtPCL_

const bool MillePedeAlignmentAlgorithm::runAtPCL_
private

◆ skipGlobalPositionRcdCheck_

const bool MillePedeAlignmentAlgorithm::skipGlobalPositionRcdCheck_
private

Definition at line 320 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun().

◆ theAlignableNavigator

std::unique_ptr<AlignableNavigator> MillePedeAlignmentAlgorithm::theAlignableNavigator
private

◆ theAlignables

align::Alignables MillePedeAlignmentAlgorithm::theAlignables
private

◆ theAlignmentParameterStore

AlignmentParameterStore* MillePedeAlignmentAlgorithm::theAlignmentParameterStore
private

directory for all kind of files

Definition at line 292 of file MillePedeAlignmentAlgorithm.h.

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

◆ theBinary

std::unique_ptr<gbl::MilleBinary> MillePedeAlignmentAlgorithm::theBinary
private

◆ theCalibrations

std::vector<IntegratedCalibrationBase *> MillePedeAlignmentAlgorithm::theCalibrations
private

◆ theConfig

edm::ParameterSet MillePedeAlignmentAlgorithm::theConfig
private

◆ theDir

std::string MillePedeAlignmentAlgorithm::theDir
private

◆ theDoSurveyPixelBarrel

bool MillePedeAlignmentAlgorithm::theDoSurveyPixelBarrel
private

Definition at line 313 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

◆ theFloatBufferX

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

Definition at line 310 of file MillePedeAlignmentAlgorithm.h.

Referenced by addLasBeam(), and addMeasurementData().

◆ theFloatBufferY

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

Definition at line 311 of file MillePedeAlignmentAlgorithm.h.

Referenced by addLasBeam(), and addMeasurementData().

◆ theGblDoubleBinary

bool MillePedeAlignmentAlgorithm::theGblDoubleBinary
private

Definition at line 316 of file MillePedeAlignmentAlgorithm.h.

Referenced by MillePedeAlignmentAlgorithm().

◆ theIntBuffer

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

Definition at line 312 of file MillePedeAlignmentAlgorithm.h.

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

◆ theLastWrittenIov

int MillePedeAlignmentAlgorithm::theLastWrittenIov
private

Definition at line 309 of file MillePedeAlignmentAlgorithm.h.

Referenced by setParametersForRunRange(), and terminate().

◆ theMaximalCor2D

double MillePedeAlignmentAlgorithm::theMaximalCor2D
private

Definition at line 304 of file MillePedeAlignmentAlgorithm.h.

Referenced by callMille2D().

◆ theMille

std::unique_ptr<Mille> MillePedeAlignmentAlgorithm::theMille
private

◆ theMinNumHits

unsigned int MillePedeAlignmentAlgorithm::theMinNumHits
private

Definition at line 303 of file MillePedeAlignmentAlgorithm.h.

Referenced by addReferenceTrajectory().

◆ theMode

unsigned int MillePedeAlignmentAlgorithm::theMode
private

Definition at line 290 of file MillePedeAlignmentAlgorithm.h.

Referenced by isMode().

◆ theMonitor

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

◆ thePedeLabels

std::shared_ptr<PedeLabelerBase> MillePedeAlignmentAlgorithm::thePedeLabels
private

◆ thePedeSteer

std::unique_ptr<PedeSteerer> MillePedeAlignmentAlgorithm::thePedeSteer
private

◆ theThresholds

std::shared_ptr<AlignPCLThresholdsHG> MillePedeAlignmentAlgorithm::theThresholds
private

Definition at line 301 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize(), storeAlignments(), and storeThresholds().

◆ theTrajectoryFactory

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

Definition at line 299 of file MillePedeAlignmentAlgorithm.h.

Referenced by run().

◆ topoToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> MillePedeAlignmentAlgorithm::topoToken_
private

Definition at line 279 of file MillePedeAlignmentAlgorithm.h.

Referenced by initialize().

◆ uniqueRunRanges_

const align::RunRanges MillePedeAlignmentAlgorithm::uniqueRunRanges_
private

Definition at line 322 of file MillePedeAlignmentAlgorithm.h.

Referenced by beginRun(), and terminate().