CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes | Private Attributes

AlignmentParameterStore Class Reference

#include <AlignmentParameterStore.h>

List of all members.

Public Types

typedef std::map< std::pair
< Alignable *, Alignable * >
, AlgebraicMatrix
Correlations
typedef std::vector< unsigned int > DetIds
typedef std::pair< Alignable
*, unsigned int > 
ParameterId
 a single alignable parameter of an Alignable
typedef std::vector
< AlignmentParameters * > 
Parameters

Public Member Functions

void acquireRelativeParameters (void)
AlignablealignableFromAlignableDet (AlignableDetOrUnitPtr alignableDet) const
 Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.
const align::Alignablesalignables (void) const
 get all alignables
 AlignmentParameterStore (const align::Alignables &alis, const edm::ParameterSet &config)
 constructor
void applyAlignableAbsolutePositions (const align::Alignables &alis, const AlignablePositions &newpos, int &ierr)
 apply absolute positions to alignables
void applyAlignableRelativePositions (const align::Alignables &alivec, const AlignableShifts &shifts, int &ierr)
 apply relative shifts to alignables
void applyParameters (void)
 Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
void applyParameters (Alignable *alignable)
 apply parameters of a given alignable
void attachAlignmentParameters (const align::Alignables &alivec, const Parameters &parvec, int &ierr)
 Attach alignment parameters to given alignables.
void attachAlignmentParameters (const Parameters &parvec, int &ierr)
 Attach alignment parameters to alignables.
void attachCorrelations (const align::Alignables &alivec, const Correlations &cormap, bool overwrite, int &ierr)
 Attach correlations to given alignables.
void attachCorrelations (const Correlations &cormap, bool overwrite, int &ierr)
 Attach correlations to alignables.
void attachUserVariables (const align::Alignables &alivec, const std::vector< AlignmentUserVariables * > &uvarvec, int &ierr)
 Attach User Variables to given alignables.
void cacheTransformations (void)
 cache the current position, rotation and other parameters
AlignmentCorrelationsStorecorrelationsStore (void) const
 get full correlation map
bool hierarchyConstraints (const Alignable *aliMaster, const align::Alignables &aliComps, std::vector< std::vector< ParameterId > > &paramIdsVecOut, std::vector< std::vector< double > > &factorsVecOut, bool all, double epsilon) const
const unsigned int numCorrelations (void) const
 get number of correlations between alignables
int numObjects (void) const
 returns number of alignables
void resetParameters (Alignable *ali)
 reset parameters of a given alignable
void resetParameters (void)
 reset parameters, correlations, user variables
void restoreCachedTransformations (void)
 restore the previously cached position, rotation and other parameters
CompositeAlignmentParameters selectParameters (const std::vector< AlignableDetOrUnitPtr > &alignabledets) const
 select parameters
CompositeAlignmentParameters selectParameters (const std::vector< Alignable * > &alignables) const
 select parameters
CompositeAlignmentParameters selectParameters (const std::vector< AlignableDet * > &alignabledets) const
void setAlignmentPositionError (const align::Alignables &alivec, double valshift, double valrot)
 Set Alignment position error.
std::pair< int, int > typeAndLayer (const Alignable *ali) const
 Obtain type and layer from Alignable.
void updateParameters (const CompositeAlignmentParameters &aap, bool updateCorrelations=true)
 update parameters
align::Alignables validAlignables (void) const
 get all alignables with valid parameters
virtual ~AlignmentParameterStore ()
 destructor

Protected Attributes

AlignmentCorrelationsStoretheCorrelationsStore

Private Attributes

align::Alignables theAlignables
 alignables

Detailed Description

Basic class for management of alignment parameters and correlations

Date:
2011/05/23 20:50:31
Revision:
1.19

(last update by

Author:
mussgill

)

Definition at line 20 of file AlignmentParameterStore.h.


Member Typedef Documentation

Definition at line 26 of file AlignmentParameterStore.h.

typedef std::vector<unsigned int> AlignmentParameterStore::DetIds

Definition at line 27 of file AlignmentParameterStore.h.

typedef std::pair<Alignable*, unsigned int> AlignmentParameterStore::ParameterId

a single alignable parameter of an Alignable

Definition at line 127 of file AlignmentParameterStore.h.

Definition at line 25 of file AlignmentParameterStore.h.


Constructor & Destructor Documentation

AlignmentParameterStore::AlignmentParameterStore ( const align::Alignables alis,
const edm::ParameterSet config 
)

constructor

Definition at line 26 of file AlignmentParameterStore.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), theAlignables, and theCorrelationsStore.

                                                                                  :
  theAlignables(alis)
{
  if (config.getUntrackedParameter<bool>("UseExtendedCorrelations")) {
    theCorrelationsStore = new AlignmentExtendedCorrelationsStore
      (config.getParameter<edm::ParameterSet>("ExtendedCorrelationsConfig"));
  } else {
    theCorrelationsStore = new AlignmentCorrelationsStore();
  }

  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterStore"
                            << "Created with " << theAlignables.size() << " alignables.";
}
AlignmentParameterStore::~AlignmentParameterStore ( ) [virtual]

destructor

Definition at line 42 of file AlignmentParameterStore.cc.

References theCorrelationsStore.


Member Function Documentation

void AlignmentParameterStore::acquireRelativeParameters ( void  )

acquire shifts/rotations from alignables of the store and copy into alignment parameters (local frame)

Definition at line 344 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), RigidBodyAlignmentParameters::clone(), Alignable::displacement(), Exception, i, Alignable::rotation(), Alignable::setAlignmentParameters(), AlignmentParameters::size(), Alignable::surface(), theAlignables, align::toAngles(), AlignableSurface::toLocal(), TkRotation< T >::x(), and Basic3DVector< T >::y().

{

  unsigned int nAlignables = theAlignables.size();

  for (unsigned int i = 0; i < nAlignables; ++i)
  {
    Alignable* ali = theAlignables[i];

    RigidBodyAlignmentParameters* ap = 
      dynamic_cast<RigidBodyAlignmentParameters*>( ali->alignmentParameters() );

    if ( !ap )
      throw cms::Exception("BadAlignable") 
        << "acquireRelativeParameters: "
        << "provided alignable does not have rigid body alignment parameters";

    AlgebraicVector par( ap->size(),0 );
    AlgebraicSymMatrix cov( ap->size(), 0 );
          
    // Get displacement and transform global->local
    align::LocalVector dloc = ali->surface().toLocal( ali->displacement() );
    par[0]=dloc.x();
    par[1]=dloc.y();
    par[2]=dloc.z();

    // Transform to local euler angles
    align::EulerAngles euloc = align::toAngles( ali->surface().toLocal( ali->rotation() ) );
    par[3]=euloc(1);
    par[4]=euloc(2);
    par[5]=euloc(3);
          
    // Clone parameters
    RigidBodyAlignmentParameters* apnew = ap->clone(par,cov);
          
    ali->setAlignmentParameters(apnew);
  }
}
Alignable * AlignmentParameterStore::alignableFromAlignableDet ( AlignableDetOrUnitPtr  alignableDet) const

Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet.

get Alignable corresponding to given AlignableDet (non-const ref. argument since might be returned)

Definition at line 253 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), and Alignable::mother().

Referenced by KalmanAlignmentUpdator::alignablesFromAlignableDets(), and selectParameters().

{
  Alignable *mother = alignableDet;
  while (mother) {
    if (mother->alignmentParameters()) return mother;
    mother = mother->mother();
  }

  return 0;
}
const align::Alignables& AlignmentParameterStore::alignables ( void  ) const [inline]
void AlignmentParameterStore::applyAlignableAbsolutePositions ( const align::Alignables alis,
const AlignablePositions newpos,
int &  ierr 
)

apply absolute positions to alignables

Definition at line 397 of file AlignmentParameterStore.cc.

References Alignable::alignableObjectId(), newFWLiteAna::found, Alignable::globalPosition(), Alignable::globalRotation(), Alignable::id(), LogDebug, Alignable::move(), TkRotation< T >::multiplyInverse(), align::rectify(), TkRotation< T >::rot, and Alignable::rotateInGlobalFrame().

Referenced by HIPAlignmentAlgorithm::startNewLoop().

{
  unsigned int nappl=0;
  ierr=0;

  // Iterate over list of alignables
  for (align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali) { 
    Alignable* ali = *iali;
    align::ID id = ali->id();
    align::StructureType typeId = ali->alignableObjectId();

    // Find corresponding entry in AlignablePositions
    bool found=false;
    for (AlignablePositions::const_iterator ipos = newpos.begin(); ipos != newpos.end(); ++ipos) {
      if (id == ipos->id() && typeId == ipos->objId()) {
        if (found) {
          edm::LogError("DuplicatePosition")
            << "New positions for alignable found more than once!";
        } else {
          // New position/rotation
          const align::PositionType& pnew = ipos->pos();
          const align::RotationType& rnew = ipos->rot();
          // Current position / rotation
          const align::PositionType& pold = ali->globalPosition();
          const align::RotationType& rold = ali->globalRotation();
                                
          // shift needed to move from current to new position
          align::GlobalVector posDiff = pnew - pold;
          align::RotationType rotDiff = rold.multiplyInverse(rnew);
          align::rectify(rotDiff); // correct for rounding errors 
          ali->move( posDiff );
          ali->rotateInGlobalFrame( rotDiff );
          LogDebug("NewPosition") << "moving by:" << posDiff;
          LogDebug("NewRotation") << "rotating by:\n" << rotDiff;

          // add position error
          // AlignmentPositionError ape(shift.x(),shift.y(),shift.z());
          // (*iali)->addAlignmentPositionError(ape);
          // (*iali)->addAlignmentPositionErrorFromRotation(rot);
                                
          found=true;
          ++nappl;
        }
      }
    }
  }

  if ( nappl< newpos.size() )
    edm::LogError("Mismatch") << "Applied only " << nappl << " new positions" 
                              << " out of " << newpos.size();

  LogDebug("NewPositions") << "Applied new positions for " << nappl
                           << " out of " << alivec.size() <<" alignables.";

}
void AlignmentParameterStore::applyAlignableRelativePositions ( const align::Alignables alivec,
const AlignableShifts shifts,
int &  ierr 
)

apply relative shifts to alignables

Definition at line 458 of file AlignmentParameterStore.cc.

References Alignable::alignableObjectId(), newFWLiteAna::found, i, Alignable::id(), LogDebug, Alignable::move(), and Alignable::rotateInGlobalFrame().

{

  ierr=0;
  unsigned int nappl=0;
  unsigned int nAlignables = alivec.size();

  for (unsigned int i = 0; i < nAlignables; ++i) {
    Alignable* ali = alivec[i];

    align::ID id = ali->id();
    align::StructureType typeId = ali->alignableObjectId();

    // Find corresponding entry in AlignableShifts
    bool found = false;
    for (AlignableShifts::const_iterator ipos = shifts.begin(); ipos != shifts.end(); ++ipos) {
      if (id == ipos->id() && typeId == ipos->objId()) {
        if (found) {
          edm::LogError("DuplicatePosition")
            << "New positions for alignable found more than once!";
        } else {
          ali->move( ipos->pos() );
          ali->rotateInGlobalFrame( ipos->rot() );
          
          // Add position error
          //AlignmentPositionError ape(pnew.x(),pnew.y(),pnew.z());
          //ali->addAlignmentPositionError(ape);
          //ali->addAlignmentPositionErrorFromRotation(rnew);
          
          found=true;
          ++nappl;
        }
      }
    }
  }
  
  if ( nappl < shifts.size() )
    edm::LogError("Mismatch") << "Applied only " << nappl << " new positions" 
                              << " out of " << shifts.size();

  LogDebug("NewPositions") << "Applied new positions for " << nappl << " alignables.";
}
void AlignmentParameterStore::applyParameters ( void  )

Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.

apply all valid parameters to their alignables

Definition at line 265 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by CSCAlignmentCorrections::applyAlignment(), MuonAlignmentFromReference::fitAndAlign(), MillePedeAlignmentAlgorithm::initialize(), CSCChamberFitter::radiusCorrection(), MillePedeAlignmentAlgorithm::setParametersForRunRange(), MuonMillepedeAlgorithm::terminate(), and HIPAlignmentAlgorithm::terminate().

{
  align::Alignables::const_iterator iali;
  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali) 
    applyParameters( *iali );
}
void AlignmentParameterStore::applyParameters ( Alignable alignable)

apply parameters of a given alignable

Definition at line 274 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), AlignmentParameters::apply(), and Exception.

{

  AlignmentParameters *pars = (alignable ? alignable->alignmentParameters() : 0);
  if (!pars) {
    throw cms::Exception("BadAlignable") 
      << "applyParameters: provided alignable does not have alignment parameters";
  }
  pars->apply();
}
void AlignmentParameterStore::attachAlignmentParameters ( const align::Alignables alivec,
const Parameters parvec,
int &  ierr 
)

Attach alignment parameters to given alignables.

Definition at line 512 of file AlignmentParameterStore.cc.

References AlignmentParameters::alignable(), newFWLiteAna::found, and LogDebug.

Referenced by attachAlignmentParameters().

{
  int ipass = 0;
  int ifail = 0;
  ierr = 0;

  // Iterate over alignables
  for ( align::Alignables::const_iterator iali = alivec.begin(); iali != alivec.end(); ++iali ) 
  {
    // Iterate over Parameters
    bool found=false;
    for ( Parameters::const_iterator ipar = parvec.begin(); ipar != parvec.end(); ++ipar) 
    {
      // Get new alignment parameters
      AlignmentParameters* ap = *ipar; 

      // Check if parameters belong to alignable 
      if ( ap->alignable() == (*iali) )
      {
        if (!found) 
        {
          (*iali)->setAlignmentParameters(ap);
          ++ipass;
          found=true;
        } 
        else edm::LogError("Alignment") << "@SUB=AlignmentParameterStore::attachAlignmentParameters" 
                                        << "More than one parameters for Alignable.";
      }
    }
    if (!found) ++ifail;
  }
  if (ifail>0) ierr=-1;
  
  LogDebug("attachAlignmentParameters") << " Parameters, Alignables: " << parvec.size() << ","
                                        << alivec.size() << "\n pass,fail: " << ipass << ","<< ifail;
}
void AlignmentParameterStore::attachAlignmentParameters ( const Parameters parvec,
int &  ierr 
)

Attach alignment parameters to alignables.

Definition at line 504 of file AlignmentParameterStore.cc.

References attachAlignmentParameters(), and theAlignables.

void AlignmentParameterStore::attachCorrelations ( const Correlations cormap,
bool  overwrite,
int &  ierr 
)

Attach correlations to alignables.

Definition at line 552 of file AlignmentParameterStore.cc.

References attachCorrelations(), and theAlignables.

{
  attachCorrelations( theAlignables, cormap, overwrite, ierr );
}
void AlignmentParameterStore::attachCorrelations ( const align::Alignables alivec,
const Correlations cormap,
bool  overwrite,
int &  ierr 
)

Attach correlations to given alignables.

Definition at line 560 of file AlignmentParameterStore.cc.

References AlignmentCorrelationsStore::correlationsAvailable(), spr::find(), LogDebug, AlignmentCorrelationsStore::setCorrelations(), and theCorrelationsStore.

Referenced by attachCorrelations().

{
  ierr=0;
  int icount=0;

  // Iterate over correlations
  for ( Correlations::const_iterator icor = cormap.begin(); icor!=cormap.end(); ++icor ) 
  {
    AlgebraicMatrix mat=(*icor).second;
    Alignable* ali1 = (*icor).first.first;
    Alignable* ali2 = (*icor).first.second;

    // Check if alignables exist
    if ( find( alivec.begin(), alivec.end(), ali1 ) != alivec.end() && 
         find( alivec.begin(), alivec.end(), ali2 ) != alivec.end() )
    {
      // Check if correlations already existing between these alignables
      if ( !theCorrelationsStore->correlationsAvailable(ali1,ali2) || (overwrite) ) 
       {
         theCorrelationsStore->setCorrelations(ali1,ali2,mat);
         ++icount;
       }
      else edm::LogInfo("AlreadyExists") << "Correlation existing and not overwritten";
    }
    else edm::LogInfo("IgnoreCorrelation") << "Ignoring correlation with no alignables!";
  }

  LogDebug( "attachCorrelations" ) << " Alignables,Correlations: " << alivec.size() <<","<< cormap.size() 
                                   << "\n applied: " << icount ;

}
void AlignmentParameterStore::attachUserVariables ( const align::Alignables alivec,
const std::vector< AlignmentUserVariables * > &  uvarvec,
int &  ierr 
)

Attach User Variables to given alignables.

Definition at line 597 of file AlignmentParameterStore.cc.

References LogDebug, and AlignmentParameters::setUserVariables().

Referenced by HIPAlignmentAlgorithm::collector().

{
  ierr=0;

  LogDebug("DumpArguments") << "size of alivec:   "  << alivec.size()
                            << "\nsize of uvarvec: " << uvarvec.size();

  std::vector<AlignmentUserVariables*>::const_iterator iuvar=uvarvec.begin();

  for ( align::Alignables::const_iterator iali=alivec.begin(); iali!=alivec.end(); ++iali, ++iuvar ) 
  {
    AlignmentParameters* ap = (*iali)->alignmentParameters();
    AlignmentUserVariables* uvarnew = (*iuvar);
    ap->setUserVariables(uvarnew);
  }
}
void AlignmentParameterStore::cacheTransformations ( void  )

cache the current position, rotation and other parameters

Definition at line 327 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by MillePedeAlignmentAlgorithm::terminate().

{
  align::Alignables::const_iterator iali;
  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali) 
    (*iali)->cacheTransformation();
}
AlignmentCorrelationsStore* AlignmentParameterStore::correlationsStore ( void  ) const [inline]

get full correlation map

Definition at line 59 of file AlignmentParameterStore.h.

References theCorrelationsStore.

bool AlignmentParameterStore::hierarchyConstraints ( const Alignable aliMaster,
const align::Alignables aliComps,
std::vector< std::vector< ParameterId > > &  paramIdsVecOut,
std::vector< std::vector< double > > &  factorsVecOut,
bool  all,
double  epsilon 
) const

Assuming aliMaster has (sub-)components aliComps with alignment parameters (cf. Alignable::firstParamComponents), paramIdsVecOut and factorsVecOut will be filled (in parallel) with constraints on the selected alignment parameters of aliMaster to get rid of the additionally introduced degrees of freedom: The 'vector product' of the parameters identified by ParameterId in std::vector<ParameterId> and the factors in std::vector<double> has to vanish (i.e. == 0.), |factor| < epsilon will be treated as 0. If all == false, skip constraint on aliMaster's degree of freedom 'i' if 'i'th alignment parameter of aliMaster is not selected, i.e. constrain only for otherwise doubled d.o.f. If all == true, produce one constraint for each of the aliMaster's parameters irrespective of whether they are selecte dor not. paramIdsVecOut and factorsVecOut contain exactly one std::vector per selected alignment parameter of aliMaster, but in principle these can be empty... Note that not all combinations of AlignmentParameters classes ar supported. If not there will be an exception (and false returned...)

Definition at line 650 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), Exception, ParametersToParametersDerivatives::isOK(), and AlignmentParameters::selector().

Referenced by PedeSteerer::hierarchyConstraint().

{
  // Weak point if all = false:
  // Ignores constraints between non-subsequent levels in case the parameter is not considered in
  // the intermediate level, e.g. global z for dets and layers is aligned, but not for rods!
  if (!ali || !ali->alignmentParameters()) return false;

  const std::vector<bool> &aliSel= ali->alignmentParameters()->selector();
  paramIdsVecOut.clear();
  factorsVecOut.clear();

  bool firstComp = true;
  for (align::Alignables::const_iterator iComp = aliComps.begin(), iCompE = aliComps.end();
       iComp != iCompE; ++iComp) {

    const ParametersToParametersDerivatives p2pDerivs(**iComp, *ali);
    if (!p2pDerivs.isOK()) {
      throw cms::Exception("BadConfig")
        << "AlignmentParameterStore::hierarchyConstraints"
        << " Bad match of types of AlignmentParameters classes.\n";
      return false;
    }
    const std::vector<bool> &aliCompSel = (*iComp)->alignmentParameters()->selector();
    for (unsigned int iParMast = 0, iParMastUsed = 0; iParMast < aliSel.size(); ++iParMast) {
      if (!all && !aliSel[iParMast]) continue;// no higher level parameter & constraint deselected
      if (firstComp) { // fill output with empty arrays 
        paramIdsVecOut.push_back(std::vector<ParameterId>());
        factorsVecOut.push_back(std::vector<double>());
      }
      for (unsigned int iParComp = 0; iParComp < aliCompSel.size(); ++iParComp) {
        if (aliCompSel[iParComp]) {
          const double factor = p2pDerivs(iParMast, iParComp);
          if (fabs(factor) > epsilon) {
            paramIdsVecOut[iParMastUsed].push_back(ParameterId(*iComp, iParComp));
            factorsVecOut[iParMastUsed].push_back(factor);
          }
        }
      }
      ++iParMastUsed;
    }
    firstComp = false;
  } // end loop on components

  return true;
}
const unsigned int AlignmentParameterStore::numCorrelations ( void  ) const [inline]

get number of correlations between alignables

Definition at line 62 of file AlignmentParameterStore.h.

References AlignmentCorrelationsStore::size(), and theCorrelationsStore.

Referenced by SingleTrajectoryUpdator::process().

{ return theCorrelationsStore->size(); }
int AlignmentParameterStore::numObjects ( void  ) const [inline]

returns number of alignables

Definition at line 56 of file AlignmentParameterStore.h.

References theAlignables.

{ return theAlignables.size(); }
void AlignmentParameterStore::resetParameters ( void  )

reset parameters, correlations, user variables

Definition at line 287 of file AlignmentParameterStore.cc.

References AlignmentCorrelationsStore::resetCorrelations(), theAlignables, and theCorrelationsStore.

Referenced by MillePedeAlignmentAlgorithm::initialize(), and MillePedeAlignmentAlgorithm::setParametersForRunRange().

{
  // Erase contents of correlation map
  theCorrelationsStore->resetCorrelations();

  // Iterate over alignables in the store and reset parameters
  align::Alignables::const_iterator iali;
  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali )
    resetParameters( *iali );
}
void AlignmentParameterStore::resetParameters ( Alignable ali)

reset parameters of a given alignable

Definition at line 300 of file AlignmentParameterStore.cc.

References Alignable::alignmentParameters(), AlignmentParameters::cloneFromSelected(), AlignmentParameters::numSelected(), Alignable::setAlignmentParameters(), and AlignmentParameters::setValid().

{
  if ( ali ) 
  {
    // Get alignment parameters for this alignable
    AlignmentParameters* ap = ali->alignmentParameters();
    if ( ap ) 
    {
      int npar=ap->numSelected();
          
      AlgebraicVector par(npar,0);
      AlgebraicSymMatrix cov(npar,0);
      AlignmentParameters* apnew = ap->cloneFromSelected(par,cov);
      ali->setAlignmentParameters(apnew);
      apnew->setValid(false);
    }
    else 
      edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
                                   << "alignable has no alignment parameter";
  }
  else
    edm::LogError("BadArgument") << "@SUB=AlignmentParameterStore::resetParameters"
                                 << "argument is NULL";
}
void AlignmentParameterStore::restoreCachedTransformations ( void  )

restore the previously cached position, rotation and other parameters

Definition at line 336 of file AlignmentParameterStore.cc.

References theAlignables.

Referenced by MillePedeAlignmentAlgorithm::setParametersForRunRange().

{
  align::Alignables::const_iterator iali;
  for ( iali = theAlignables.begin(); iali != theAlignables.end(); ++iali) 
    (*iali)->restoreCachedTransformation();
}
CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< AlignableDet * > &  alignabledets) const

select parameters (for backward compatibility, use with vector<AlignableDetOrUnitPtr> as argument instead)

Definition at line 49 of file AlignmentParameterStore.cc.

Referenced by SingleTrajectoryUpdator::process(), HIPAlignmentAlgorithm::run(), and MuonMillepedeAlgorithm::run().

{
  std::vector<AlignableDetOrUnitPtr> detOrUnits;
  detOrUnits.reserve(alignabledets.size());

  std::vector<AlignableDet*>::const_iterator it, iEnd;
  for ( it = alignabledets.begin(), iEnd = alignabledets.end(); it != iEnd; ++it)
    detOrUnits.push_back(AlignableDetOrUnitPtr(*it));

  return this->selectParameters(detOrUnits);
}
CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< AlignableDetOrUnitPtr > &  alignabledets) const

select parameters

Definition at line 63 of file AlignmentParameterStore.cc.

References alignableFromAlignableDet(), alignables(), Alignable::alignmentParameters(), AlignmentCorrelationsStore::correlations(), AlCaHLTBitMon_QueryRunRegistry::data, spr::find(), AlignmentParameters::numSelected(), AlignmentParameters::selectedCovariance(), AlignmentParameters::selectedParameters(), and theCorrelationsStore.

{

  align::Alignables alignables;
  std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap;
  std::map <Alignable*,int> aliposmap;
  std::map <Alignable*,int> alilenmap;
  int nparam=0;

  // iterate over AlignableDet's
  for( std::vector<AlignableDetOrUnitPtr>::const_iterator iad = alignabledets.begin();
       iad != alignabledets.end(); ++iad ) 
  {
    Alignable* ali = alignableFromAlignableDet( *iad );
    if ( ali ) 
    {
      alidettoalimap[ *iad ] = ali; // Add to map
      // Check if Alignable already there, insert into vector if not
      if ( find(alignables.begin(),alignables.end(),ali) == alignables.end() ) 
      {
        alignables.push_back(ali);
        AlignmentParameters* ap = ali->alignmentParameters();
        nparam += ap->numSelected();
      }
    }
  }

  AlgebraicVector* selpar = new AlgebraicVector( nparam, 0 );
  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix( nparam, 0 );

  // Fill in parameters and corresponding covariance matricess
  int ipos = 1; // NOTE: .sub indices start from 1
  align::Alignables::const_iterator it1;
  for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 ) 
  {
    AlignmentParameters* ap = (*it1)->alignmentParameters();
    selpar->sub( ipos, ap->selectedParameters() );
    selcov->sub( ipos, ap->selectedCovariance() );
    int npar = ap->numSelected();
    aliposmap[*it1]=ipos;
    alilenmap[*it1]=npar;
    ipos +=npar;
  }

  // Fill in the correlations. Has to be an extra loop, because the
  // AlignmentExtendedCorrelationsStore (if used) needs the
  // alignables' covariance matrices already present.
  ipos = 1;
  for( it1 = alignables.begin(); it1 != alignables.end(); ++it1 ) 
  {
    int jpos=1;

    // Look for correlations between alignables
    align::Alignables::const_iterator it2;
    for( it2 = alignables.begin(); it2 != it1; ++it2 ) 
    {
      theCorrelationsStore->correlations( *it1, *it2, *selcov, ipos-1, jpos-1 );
      jpos += (*it2)->alignmentParameters()->numSelected();
    }

    ipos += (*it1)->alignmentParameters()->numSelected();
  }

  AlignmentParametersData::DataContainer data( new AlignmentParametersData( selpar, selcov ) );
  CompositeAlignmentParameters aap( data, alignables, alidettoalimap, aliposmap, alilenmap );

  return aap;
}
CompositeAlignmentParameters AlignmentParameterStore::selectParameters ( const std::vector< Alignable * > &  alignables) const

select parameters

Definition at line 135 of file AlignmentParameterStore.cc.

References AlignmentCorrelationsStore::correlations(), AlCaHLTBitMon_QueryRunRegistry::data, spr::find(), AlignmentParameters::numSelected(), AlignmentParameters::selectedCovariance(), AlignmentParameters::selectedParameters(), and theCorrelationsStore.

{

  align::Alignables selectedAlignables;
  std::map <AlignableDetOrUnitPtr,Alignable*> alidettoalimap; // This map won't be filled!!!
  std::map <Alignable*,int> aliposmap;
  std::map <Alignable*,int> alilenmap;
  int nparam=0;

  // iterate over Alignable's
  align::Alignables::const_iterator ita;
  for ( ita = alignables.begin(); ita != alignables.end(); ++ita ) 
  {
    // Check if Alignable already there, insert into vector if not
    if ( find(selectedAlignables.begin(), selectedAlignables.end(), *ita) == selectedAlignables.end() ) 
    {
      selectedAlignables.push_back( *ita );
      AlignmentParameters* ap = (*ita)->alignmentParameters();
      nparam += ap->numSelected();
    }
  }

  AlgebraicVector* selpar = new AlgebraicVector( nparam, 0 );
  AlgebraicSymMatrix* selcov = new AlgebraicSymMatrix( nparam, 0 );

  // Fill in parameters and corresponding covariance matrices
  int ipos = 1; // NOTE: .sub indices start from 1
  align::Alignables::const_iterator it1;
  for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 ) 
  {
    AlignmentParameters* ap = (*it1)->alignmentParameters();
    selpar->sub( ipos, ap->selectedParameters() );
    selcov->sub( ipos, ap->selectedCovariance() );
    int npar = ap->numSelected();
    aliposmap[*it1]=ipos;
    alilenmap[*it1]=npar;
    ipos +=npar;
  }

  // Fill in the correlations. Has to be an extra loop, because the
  // AlignmentExtendedCorrelationsStore (if used) needs the
  // alignables' covariance matrices already present.
  ipos = 1;
  for( it1 = selectedAlignables.begin(); it1 != selectedAlignables.end(); ++it1 ) 
  {
    int jpos=1;

    // Look for correlations between alignables
    align::Alignables::const_iterator it2;
    for( it2 = selectedAlignables.begin(); it2 != it1; ++it2 ) 
    {
      theCorrelationsStore->correlations( *it1, *it2, *selcov, ipos-1, jpos-1 );
      jpos += (*it2)->alignmentParameters()->numSelected();
    }

    ipos += (*it1)->alignmentParameters()->numSelected();
  }

  AlignmentParametersData::DataContainer data( new AlignmentParametersData( selpar, selcov ) );
  CompositeAlignmentParameters aap( data, selectedAlignables, alidettoalimap, aliposmap, alilenmap );

  return aap;
}
void AlignmentParameterStore::setAlignmentPositionError ( const align::Alignables alivec,
double  valshift,
double  valrot 
)

Set Alignment position error.

Definition at line 617 of file AlignmentParameterStore.cc.

References Alignable::addAlignmentPositionError(), Alignable::addAlignmentPositionErrorFromRotation(), i, LogDebug, alignCSCRings::r, Alignable::setAlignmentPositionError(), and align::toMatrix().

Referenced by MuonAlignmentFromReference::fitAndAlign(), MuonAlignmentFromReference::initialize(), and HIPAlignmentAlgorithm::setAlignmentPositionError().

{
  unsigned int nAlignables = alivec.size();

  for (unsigned int i = 0; i < nAlignables; ++i)
  {
    Alignable* ali = alivec[i];

    // First reset APE   
    AlignmentPositionError nulApe(0,0,0);        
    ali->setAlignmentPositionError(nulApe, true);

    // Set APE from displacement
    AlignmentPositionError ape(valshift,valshift,valshift);
    if ( valshift > 0. ) ali->addAlignmentPositionError(ape, true);
    else ali->setAlignmentPositionError(ape, true);
    // GF: Resetting and setting as above does not really make sense to me, 
    //     and adding to zero or setting is the same! I'd just do 
    //ali->setAlignmentPositionError(AlignmentPositionError ape(valshift,valshift,valshift),true);

    // Set APE from rotation
    align::EulerAngles r(3);
    r(1)=valrot; r(2)=valrot; r(3)=valrot;
    ali->addAlignmentPositionErrorFromRotation(align::toMatrix(r), true);
  }

  LogDebug("StoreAPE") << "Store APE from shift: " << valshift
                       << "\nStore APE from rotation: " << valrot;
}
std::pair< int, int > AlignmentParameterStore::typeAndLayer ( const Alignable ali) const

Obtain type and layer from Alignable.

Definition at line 389 of file AlignmentParameterStore.cc.

References Alignable::id(), and TrackerAlignableId::typeAndLayerFromDetId().

Referenced by HIPAlignmentAlgorithm::fillRoot().

void AlignmentParameterStore::updateParameters ( const CompositeAlignmentParameters aap,
bool  updateCorrelations = true 
)

update parameters

Definition at line 201 of file AlignmentParameterStore.cc.

References alignables(), AlignmentParameters::cloneFromSelected(), CompositeAlignmentParameters::components(), CompositeAlignmentParameters::covariance(), AlignmentParameters::numSelected(), CompositeAlignmentParameters::parameters(), Parameters::parameters, AlignmentCorrelationsStore::setCorrelations(), and theCorrelationsStore.

Referenced by SingleTrajectoryUpdator::process().

{

  align::Alignables alignables = aap.components();
  const AlgebraicVector& parameters = aap.parameters();
  const AlgebraicSymMatrix& covariance = aap.covariance();

  int ipos = 1; // NOTE: .sub indices start from 1

  // Loop over alignables
  for( align::Alignables::const_iterator it=alignables.begin(); it != alignables.end(); ++it ) 
  {
    // Update parameters and local covariance   
    AlignmentParameters* ap = (*it)->alignmentParameters();
    int nsel = ap->numSelected();
    AlgebraicVector subvec = parameters.sub( ipos, ipos+nsel-1 );
    AlgebraicSymMatrix subcov = covariance.sub( ipos, ipos+nsel-1 );
    AlignmentParameters* apnew = ap->cloneFromSelected( subvec, subcov );
    (*it)->setAlignmentParameters( apnew );
          
    // Now update correlations between detectors
    if ( updateCorrelations )
    {
      int jpos = 1;
      for( align::Alignables::const_iterator it2 = alignables.begin(); it2 != it; ++it2 ) 
      {
        theCorrelationsStore->setCorrelations( *it, *it2, covariance, ipos-1, jpos-1 );
        jpos += (*it2)->alignmentParameters()->numSelected();
      }
    }

    ipos+=nsel;
  }

}
align::Alignables AlignmentParameterStore::validAlignables ( void  ) const

get all alignables with valid parameters

Definition at line 239 of file AlignmentParameterStore.cc.

References LogDebug, query::result, and theAlignables.

{ 
  align::Alignables result;
  for (align::Alignables::const_iterator iali = theAlignables.begin();
       iali != theAlignables.end(); ++iali)
    if ( (*iali)->alignmentParameters()->isValid() ) result.push_back(*iali);

  LogDebug("Alignment") << "@SUB=AlignmentParameterStore::validAlignables"
                        << "Valid alignables: " << result.size()
                        << "out of " << theAlignables.size();
  return result;
}

Member Data Documentation