CMS 3D CMS Logo

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

#include <PedeSteerer.h>

Public Member Functions

std::string buildMasterSteer (const std::vector< std::string > &binaryFiles)
 construct (and return name of) master steering file from config, binaryFiles etc. More...
 
void buildSubSteer (AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
 construct steering files about hierarchy, fixing etc. an keep track of their names More...
 
double cmsToPedeFactor (unsigned int parNum) const
 
void correctToReferenceSystem ()
 
const std::string & directory () const
 directory from constructor input, '/' is attached if needed More...
 
bool isCorrectToRefSystem (const align::Alignables &coordDefiners) const
 
bool isNoHiera (const Alignable *ali) const
 True if 'ali' was deselected from hierarchy and any ancestor (e.g. mother) has parameters. More...
 
int parameterSign () const
 results from pede (and start values for pede) might need a sign flip More...
 
 PedeSteerer (AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras, AlignmentParameterStore *store, const PedeLabelerBase *labels, const edm::ParameterSet &config, const std::string &defaultDir, bool noSteerFiles)
 
int runPede (const std::string &masterSteer) const
 run pede, masterSteer should be as returned from buildMasterSteer(...) More...
 
 ~PedeSteerer ()
 

Private Types

typedef std::map< const
Alignable *, std::vector
< float > > 
AlignablePresigmasMap
 

Private Member Functions

unsigned int buildNoHierarchyCollection (const align::Alignables &)
 
bool checkParameterChoices (const align::Alignables &) const
 
std::ofstream * createSteerFile (const std::string &name, bool addToList)
 create and open file with name, if (addToList) append to mySteeringFiles More...
 
void defineCoordinates (const align::Alignables &, Alignable *aliMaster, const std::string &fileName)
 
std::string fileName (const std::string &addendum) const
 full name with directory and 'idenitfier' More...
 
int fixParameter (Alignable *ali, unsigned int iRunRange, unsigned int iParam, char selector, std::ofstream *&filePtr, const std::string &fileName)
 
std::pair< unsigned int,
unsigned int > 
fixParameters (const align::Alignables &, const std::string &file)
 
void hierarchyConstraint (const Alignable *ali, const align::Alignables &components, std::ofstream &file) const
 
unsigned int hierarchyConstraints (const align::Alignables &, const std::string &file)
 
unsigned int presigmas (const std::vector< edm::ParameterSet > &cffPresi, const std::string &fileName, const align::Alignables &, AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
 interprete content of presigma VPSet 'cffPresi' and call presigmasFile More...
 
unsigned int presigmasFile (const std::string &fileName, const align::Alignables &, const AlignablePresigmasMap &aliPresisMap)
 look for active 'alis' in map of presigma values and create steering file More...
 
align::Alignables selectCoordinateAlis (const align::Alignables &) const
 

Private Attributes

const AlignableObjectId alignableObjectId_
 pointer to labeler (not the owner) More...
 
const edm::ParameterSet myConfig
 
std::string myDirectory
 
bool myIsSteerFileDebug
 flag to write steering files to /dev/null More...
 
const PedeLabelerBasemyLabels
 not the owner! More...
 
std::set< const Alignable * > myNoHieraCollection
 keeps track of created 'secondary' steering files More...
 
bool myNoSteerFiles
 directory of all files More...
 
int myParameterSign
 whether or not to fill pede steering files with debug info More...
 
const AlignmentParameterStoremyParameterStore
 
std::vector< std::string > mySteeringFiles
 precision for writing constraints to text file More...
 
unsigned int theConstrPrecision
 hierarchy constraints with less params are ignored More...
 
align::Alignables theCoordDefiners
 master coordinates, must (?) be global frame More...
 
AlignabletheCoordMaster
 Alignables deselected for hierarchy constr. More...
 
double theMinHieraConstrCoeff
 old pede versions (before May '07) need a sign flip... More...
 
unsigned int theMinHieraParPerConstr
 min absolute value of coefficients in hierarchy constraints More...
 

Detailed Description

provides steering for pede according to configuration

Author
: Gero Flucke date : October 2006
Date:
2013/06/18 13:31:29
Revision:
1.29

(last update by

Author:
jbehr

)

Definition at line 37 of file PedeSteerer.h.

Member Typedef Documentation

typedef std::map<const Alignable *, std::vector<float> > PedeSteerer::AlignablePresigmasMap
private

Definition at line 73 of file PedeSteerer.h.

Constructor & Destructor Documentation

PedeSteerer::PedeSteerer ( AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras aliExtras,
AlignmentParameterStore store,
const PedeLabelerBase labels,
const edm::ParameterSet config,
const std::string &  defaultDir,
bool  noSteerFiles 
)

constructor from AlignableTracker/AlignableMuon, their AlignmentParameterStore and the labeler (NOTE: The latter two must live longer than the constructed PedeSteerer!)

Definition at line 53 of file PedeSteerer.cc.

References AlignableObjectId::commonObjectIdProvider().

61  : myParameterStore(store),
62  myLabels(labels),
64  myConfig(config),
66  myNoSteerFiles(noSteerFiles),
67  myIsSteerFileDebug(myConfig.getUntrackedParameter<bool>("steerFileDebug")),
68  myParameterSign(myConfig.getUntrackedParameter<int>("parameterSign")),
69  theMinHieraConstrCoeff(myConfig.getParameter<double>("minHieraConstrCoeff")),
70  theMinHieraParPerConstr(myConfig.getParameter<unsigned int>("minHieraParPerConstr")),
71  theConstrPrecision(myConfig.getParameter<unsigned int>("constrPrecision")),
72  theCoordMaster(nullptr) {
73  if (myParameterSign != 1 && myParameterSign != -1) {
74  cms::Exception("BadConfig") << "Expect PedeSteerer.parameterSign = +/-1, "
75  << "found " << myParameterSign << ".";
76  }
77 
78  // Correct directory, needed before asking for fileName(..):
79  if (myDirectory.empty())
80  myDirectory = defaultDir;
81  if (!myDirectory.empty() && myDirectory.find_last_of('/') != myDirectory.size() - 1) {
82  myDirectory += '/'; // directory may need '/'
83  }
84 
85  const auto &alis = myParameterStore->alignables();
86  if (!this->checkParameterChoices(alis)) {
87  } // anyway thrown exception
88 
89  // Coordinate system selection and correction before everything
91  if (!theCoordDefiners.empty()) { // Create steering with constraints to define coordinate system:
92  // OK, some hacks:
93  // - we want a composite with global coordinates where tracker and muon are components
94  // (to call RigidBodyAl.Param.->globalParameters() in correctToReferenceSystem(..))
95  // - so we create a AlignableComposite and add tracker and muon
96  // - but the addComponent(..) method is so cute that it calculates position from
97  // daughters' deepComponents()
98  // - so we want to move it back to (0,0,0), but ali->move(..) would move daughters as well
99  // => move only the surface back
100  // - this master object does not have a label for its parameters
101  // => some warnings if debug output selected in pedeSteer files
102  // - we must not delete our new master (little mem. leak...) since that would delete
103  // the daughters as well!
104  if (aliTracker) {
105  theCoordMaster = new AlignableComposite(aliTracker->id(), align::invalid);
106  theCoordMaster->addComponent(aliTracker);
107  } else if (aliMuon) {
109  } else {
110  throw cms::Exception("BadConfig") << "[PedeSteerer]"
111  << "Cannot define global coordinate system "
112  << "with neither tracker nor muon!";
113  }
114  if (aliMuon)
115  theCoordMaster->addComponent(aliMuon); // tracker is already added if existing
116  if (aliExtras) { // tracker and/or muon are already added if existing
117  align::Alignables allExtras = aliExtras->components();
118  for (const auto &it : allExtras)
120  }
121 
123 
124  if (this->isCorrectToRefSystem(theCoordDefiners)) { // defined by 's' (MC): 'correct' misalignment
125  this->correctToReferenceSystem(); // really before 'defineCoordinates'?
126  }
127  }
128 }
void correctToReferenceSystem()
Definition: PedeSteerer.cc:393
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
T getUntrackedParameter(std::string const &, T const &) const
const edm::ParameterSet myConfig
Definition: PedeSteerer.h:127
static AlignableObjectId commonObjectIdProvider(const AlignableObjectId &, const AlignableObjectId &)
Alignable * theCoordMaster
Alignables deselected for hierarchy constr.
Definition: PedeSteerer.h:139
std::string myDirectory
Definition: PedeSteerer.h:128
align::Alignables selectCoordinateAlis(const align::Alignables &) const
Definition: PedeSteerer.cc:304
unsigned int theMinHieraParPerConstr
min absolute value of coefficients in hierarchy constraints
Definition: PedeSteerer.h:133
virtual void recenterSurface()
Recenter surface object without moving possible components.
Definition: Alignable.cc:295
bool isCorrectToRefSystem(const align::Alignables &coordDefiners) const
Definition: PedeSteerer.cc:366
const PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
const AlignableObjectId alignableObjectId_
pointer to labeler (not the owner)
Definition: PedeSteerer.h:125
virtual void addComponent(Alignable *)=0
const Alignables & components() const
int myParameterSign
whether or not to fill pede steering files with debug info
Definition: PedeSteerer.h:131
double theMinHieraConstrCoeff
old pede versions (before May &#39;07) need a sign flip...
Definition: PedeSteerer.h:132
unsigned int theConstrPrecision
hierarchy constraints with less params are ignored
Definition: PedeSteerer.h:134
const AlignmentParameterStore * myParameterStore
Definition: PedeSteerer.h:123
bool myNoSteerFiles
directory of all files
Definition: PedeSteerer.h:129
align::Alignables theCoordDefiners
master coordinates, must (?) be global frame
Definition: PedeSteerer.h:140
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
bool checkParameterChoices(const align::Alignables &) const
Definition: PedeSteerer.cc:205
bool myIsSteerFileDebug
flag to write steering files to /dev/null
Definition: PedeSteerer.h:130
const align::Alignables & alignables(void) const
get all alignables
PedeSteerer::~PedeSteerer ( )

non-virtual destructor: do not inherit from this class

Definition at line 131 of file PedeSteerer.cc.

131  {
132  // delete theCoordMaster; NO, see above
133 }

Member Function Documentation

std::string PedeSteerer::buildMasterSteer ( const std::vector< std::string > &  binaryFiles)

construct (and return name of) master steering file from config, binaryFiles etc.

Definition at line 746 of file PedeSteerer.cc.

References createSteerFile(), fileName(), edm::ParameterSet::getParameter(), mps_fire::i, myConfig, mySteeringFiles, runTheMatrix::opt, and AlCaHLTBitMon_QueryRunRegistry::string.

746  {
747  const std::string nameMasterSteer(this->fileName("Master"));
748  std::ofstream *mainSteerPtr = this->createSteerFile(nameMasterSteer, false);
749  if (!mainSteerPtr)
750  return "";
751 
752  // add external steering files, if any
753  std::vector<std::string> addfiles = myConfig.getParameter<std::vector<std::string> >("additionalSteerFiles");
754  mySteeringFiles.insert(mySteeringFiles.end(), addfiles.begin(), addfiles.end());
755 
756  // add steering files to master steering file
757  std::ofstream &mainSteerRef = *mainSteerPtr;
758  for (unsigned int iFile = 0; iFile < mySteeringFiles.size(); ++iFile) {
759  mainSteerRef << mySteeringFiles[iFile] << "\n";
760  }
761 
762  // add binary files to master steering file
763  mainSteerRef << "\nCfiles\n";
764  for (unsigned int iFile = 0; iFile < binaryFiles.size(); ++iFile) {
765  mainSteerRef << binaryFiles[iFile] << "\n";
766  }
767 
768  // add method
769  mainSteerRef << "\nmethod " << myConfig.getParameter<std::string>("method") << "\n";
770 
771  // add further options
772  const std::vector<std::string> opt(myConfig.getParameter<std::vector<std::string> >("options"));
773  mainSteerRef << "\n* Outlier treatment and other options \n";
774  for (unsigned int i = 0; i < opt.size(); ++i) {
775  mainSteerRef << opt[i] << "\n";
776  }
777 
778  delete mainSteerPtr; // close (and flush) again
779 
780  return nameMasterSteer;
781 }
const edm::ParameterSet myConfig
Definition: PedeSteerer.h:127
std::ofstream * createSteerFile(const std::string &name, bool addToList)
create and open file with name, if (addToList) append to mySteeringFiles
Definition: PedeSteerer.cc:642
std::vector< std::string > mySteeringFiles
precision for writing constraints to text file
Definition: PedeSteerer.h:136
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
unsigned int PedeSteerer::buildNoHierarchyCollection ( const align::Alignables alis)
private

Store Alignables that have SelectionUserVariables attached to their AlignmentParameters (these must exist) that indicate removal from hierarchy, i.e. make it 'top level'.

Definition at line 161 of file PedeSteerer.cc.

References Exception, SelectionUserVariables::fullSelection(), myNoHieraCollection, submitPVValidationJobs::params, AlignmentParameters::size(), and AlignmentParameters::userVariables().

Referenced by buildSubSteer().

161  {
162  myNoHieraCollection.clear(); // just in case of re-use...
163 
164  for (const auto &iAli : alis) {
165  AlignmentParameters *params = iAli->alignmentParameters();
166  SelectionUserVariables *selVar = dynamic_cast<SelectionUserVariables *>(params->userVariables());
167  if (!selVar)
168  continue;
169  // Now check whether taking out of hierarchy is selected - must be consistent!
170  unsigned int numNoHieraPar = 0;
171  unsigned int numHieraPar = 0;
172  for (unsigned int iParam = 0; static_cast<int>(iParam) < params->size(); ++iParam) {
173  const char selector = selVar->fullSelection()[iParam];
174  if (selector == 'C' || selector == 'F' || selector == 'H') {
175  ++numNoHieraPar;
176  } else if (selector == 'c' || selector == 'f' || selector == '1' || selector == 'r' || selector == 's') {
177  ++numHieraPar;
178  } // else ... accept '0' as undetermined
179  }
180  if (numNoHieraPar) { // Selected to be taken out.
181  if (numHieraPar) { // Inconsistent: Some parameters still in hierarchy ==> exception!
182  throw cms::Exception("BadConfig")
183  << "[PedeSteerer::buildNoHierarchyCollection] All active parameters of alignables to be "
184  << " taken out of the hierarchy must be marked with capital letters 'C', 'F' or 'H'!";
185  }
186  bool isInHiera = false; // Check whether Alignable is really part of hierarchy:
187  auto mother = iAli;
188  while ((mother = mother->mother())) {
189  if (mother->alignmentParameters())
190  isInHiera = true; // could 'break;', but loop is short
191  }
192  // Complain, but keep collection short if not in hierarchy:
193  if (isInHiera)
194  myNoHieraCollection.insert(iAli);
195  else
196  edm::LogWarning("Alignment") << "@SUB=PedeSteerer::buildNoHierarchyCollection"
197  << "Alignable not in hierarchy, no need to remove it!";
198  }
199  } // end loop on alignables
200 
201  return myNoHieraCollection.size();
202 }
std::set< const Alignable * > myNoHieraCollection
keeps track of created &#39;secondary&#39; steering files
Definition: PedeSteerer.h:138
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const std::vector< char > & fullSelection() const
int size(void) const
Get number of parameters.
Log< level::Warning, false > LogWarning
void PedeSteerer::buildSubSteer ( AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras aliExtras 
)

construct steering files about hierarchy, fixing etc. an keep track of their names

Definition at line 668 of file PedeSteerer.cc.

References AlignmentParameterStore::alignables(), buildNoHierarchyCollection(), PedeSteererWeakModeConstraints::constructConstraints(), defineCoordinates(), fileName(), fixParameters(), PedeSteererWeakModeConstraints::getConfigData(), edm::ParameterSet::getParameter(), hierarchyConstraints(), myConfig, myLabels, myNoHieraCollection, myParameterStore, presigmas(), AlCaHLTBitMon_QueryRunRegistry::string, theCoordDefiners, and theCoordMaster.

668  {
669  const auto &alis = myParameterStore->alignables();
670 
671  if (theCoordMaster && !theCoordDefiners.empty()) {
672  const std::string nameCoordFile(this->fileName("Coord"));
673  this->defineCoordinates(theCoordDefiners, theCoordMaster, nameCoordFile);
674  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer" << theCoordDefiners.size()
675  << " highest level objects define the "
676  << "coordinate system, steering file " << nameCoordFile << ".";
677  }
678 
679  const std::string nameFixFile(this->fileName("FixPara"));
680  const std::pair<unsigned int, unsigned int> nFixFixCor(this->fixParameters(alis, nameFixFile));
681  if (nFixFixCor.first != 0 || nFixFixCor.second != 0) {
682  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer" << nFixFixCor.first << " parameters fixed at 0. and "
683  << nFixFixCor.second << " at 'original' position, "
684  << "steering file " << nameFixFile << ".";
685  }
686 
687  if (this->buildNoHierarchyCollection(alis)) { // before hierarchyConstraints(..)
688  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer" << myNoHieraCollection.size()
689  << " alignables taken out of hierarchy.";
690  }
691 
692  const std::string nameHierarchyFile(this->fileName("Hierarchy"));
693  unsigned int nConstraint = this->hierarchyConstraints(alis, nameHierarchyFile);
694  if (nConstraint) {
695  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer"
696  << "Hierarchy constraints for " << nConstraint << " alignables, "
697  << "steering file " << nameHierarchyFile << ".";
698  }
699 
700  //construct the systematic geometry deformations
701  if (!(myConfig.getParameter<std::vector<edm::ParameterSet> >("constraints")).empty()) {
702  PedeSteererWeakModeConstraints GeometryConstraints(
703  aliTracker,
704  myLabels,
705  myConfig.getParameter<std::vector<edm::ParameterSet> >("constraints"),
706  myConfig.getParameter<std::string>("steerFile"));
707 
708  //prepare the output files
709  //Get the data structure in which the configuration data are stored.
710  //The relation between the ostream* and the corresponding file name needs to be filled
711  auto &ConstraintsConfigContainer = GeometryConstraints.getConfigData();
712 
713  //loop over all configured constraints
714  for (auto &it : ConstraintsConfigContainer) {
715  //each level has its own constraint which means the output is stored in a separate file
716  for (const auto &ilevelsFilename : it.levelsFilenames_) {
717  it.mapFileName_.insert(
718  std::make_pair(ilevelsFilename.second, this->createSteerFile(ilevelsFilename.second, true)));
719  }
720  }
721 
722  unsigned int nGeometryConstraint = GeometryConstraints.constructConstraints(alis);
723  if (nGeometryConstraint) {
724  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer"
725  << "Geometry constraints for " << nGeometryConstraint << " alignables.";
726  }
727  }
728 
729  const std::string namePresigmaFile(this->fileName("Presigma"));
730  unsigned int nPresigma = this->presigmas(myConfig.getParameter<std::vector<edm::ParameterSet> >("Presigmas"),
731  namePresigmaFile,
732  alis,
733  aliTracker,
734  aliMuon,
735  aliExtras);
736  if (nPresigma) {
737  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::buildSubSteer"
738  << "Presigma values set for " << nPresigma << " parameters, "
739  << "steering file " << namePresigmaFile << ".";
740  }
741 
742  // Delete all SelectionUserVariables now? They will anyway be overwritten by MillePedeVariables...
743 }
std::set< const Alignable * > myNoHieraCollection
keeps track of created &#39;secondary&#39; steering files
Definition: PedeSteerer.h:138
const edm::ParameterSet myConfig
Definition: PedeSteerer.h:127
std::pair< unsigned int, unsigned int > fixParameters(const align::Alignables &, const std::string &file)
Definition: PedeSteerer.cc:232
unsigned int presigmas(const std::vector< edm::ParameterSet > &cffPresi, const std::string &fileName, const align::Alignables &, AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
interprete content of presigma VPSet &#39;cffPresi&#39; and call presigmasFile
Definition: PedeSteerer.cc:542
Alignable * theCoordMaster
Alignables deselected for hierarchy constr.
Definition: PedeSteerer.h:139
unsigned int hierarchyConstraints(const align::Alignables &, const std::string &file)
Definition: PedeSteerer.cc:440
const PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
Log< level::Info, false > LogInfo
const AlignmentParameterStore * myParameterStore
Definition: PedeSteerer.h:123
align::Alignables theCoordDefiners
master coordinates, must (?) be global frame
Definition: PedeSteerer.h:140
void defineCoordinates(const align::Alignables &, Alignable *aliMaster, const std::string &fileName)
Definition: PedeSteerer.cc:346
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
unsigned int buildNoHierarchyCollection(const align::Alignables &)
Definition: PedeSteerer.cc:161
const align::Alignables & alignables(void) const
get all alignables
bool PedeSteerer::checkParameterChoices ( const align::Alignables alis) const
private

Checks whether SelectionUserVariables that might be attached to alis' AlignmentParameters (these must exist) are all known.

Definition at line 205 of file PedeSteerer.cc.

References Exception, SelectionUserVariables::fullSelection(), EgammaValidation_Wenu_cff::sel, AlignmentParameters::size(), and AlignmentParameters::userVariables().

205  {
206  for (const auto &iAli : alis) {
207  AlignmentParameters *paras = iAli->alignmentParameters();
208  SelectionUserVariables *selVar = dynamic_cast<SelectionUserVariables *>(paras->userVariables());
209  if (!selVar)
210  continue;
211  for (unsigned int iParam = 0; static_cast<int>(iParam) < paras->size(); ++iParam) {
212  const char sel = selVar->fullSelection()[iParam];
213  if (sel != 'f' && sel != 'F' && sel != 'c' && sel != 'C' && sel != '0' && sel != '1' && sel != 'H' &&
214  sel != 'r' && sel != 's') {
215  throw cms::Exception("BadConfig")
216  << "[PedeSteerer::unknownParameterChoices] "
217  << "Unexpected parameter selector '" << sel
218  << "', use \n'f/F' (fix),\n'c/C' (fix at correct pos.),\n'1/H' (free),\n"
219  << "'r/s' (free, but defining reference system, trying to correct misalignment if 's')"
220  << " or \n'0' (ignore).\n"
221  << "Capital letters mean that the Alignable is taken out of a possible hierarchy,\n"
222  << "but must be used consistently for all its parameters.";
223  return false; // unreached
224  }
225  }
226  }
227 
228  return true;
229 }
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const std::vector< char > & fullSelection() const
int size(void) const
Get number of parameters.
double PedeSteerer::cmsToPedeFactor ( unsigned int  parNum) const

Definition at line 141 of file PedeSteerer.cc.

References RigidBodyAlignmentParameters::dalpha, RigidBodyAlignmentParameters::dbeta, RigidBodyAlignmentParameters::dgamma, RigidBodyAlignmentParameters::dx, RigidBodyAlignmentParameters::dy, and RigidBodyAlignmentParameters::dz.

Referenced by fixParameter(), presigmasFile(), and PedeReader::setParameter().

141  {
142  return 1.; // mmh, otherwise would need to FIXME hierarchyConstraint...
143 
144  switch (parNum) {
147  return 1000.; // cm to mum *1/10 to get smaller values
149  return 2500.; // cm to mum *1/4
152  return 1000.; // rad to mrad (no first guess for sensitivity yet)
154  return 10000.; // rad to mrad *10 to get larger values
155  default:
156  return 1.;
157  }
158 }
void PedeSteerer::correctToReferenceSystem ( )

If reference alignables have been configured, shift everything such that mean position and orientation of dets in these alignables are zero.

Definition at line 393 of file PedeSteerer.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, alignCSCRings::e, Alignable::move(), Alignable::rotateInGlobalFrame(), theCoordDefiners, theCoordMaster, and align::toMatrix().

393  {
394  typedef RigidBodyAlignmentParameters RbPars;
395  if (!theCoordMaster || theCoordDefiners.empty())
396  return; // nothing was defined
397 
398  align::Alignables definerDets; // or ...DetUnits
399  for (const auto &it :
400  theCoordDefiners) { // find lowest level objects of alignables that define the coordinate system
401  const auto &comp = it->deepComponents();
402  definerDets.insert(definerDets.end(), comp.begin(), comp.end());
403  }
404 
405  for (unsigned int iLoop = 0;; ++iLoop) { // iterate: shifts and rotations are not independent
406  AlgebraicVector meanPars(RbPars::N_PARAM);
407  for (const auto &it : definerDets) { // sum up mean displacements/misrotations:
408  meanPars += RbPars(it, true).globalParameters(); // requires theCoordMaster has global frame
409  }
410  meanPars /= definerDets.size();
411  const align::Scalar squareSum = meanPars.normsq();
412 
413  if (squareSum < 1.e-20)
414  break; // sqrt(1.e-20)=1.e-10: close enough to stop iterating
415  if (iLoop == 0) {
416  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::correctToReferenceSystem"
417  << "Loop " << iLoop << " "
418  << "Mean misalignment of dets of defined coordinate system"
419  << (squareSum < 1.e-20 ? ":" : " (will be iteratively corrected to < 1.e-10):")
420  << meanPars;
421  }
422  if (iLoop >= 5) { // 3 iterations should be safe, use 5 for 'more' safety...
423  edm::LogError("Alignment") << "@SUB=PedeSteerer::correctToReferenceSystem"
424  << "No convergence in " << iLoop << " iterations, "
425  << "remaining misalignment: " << meanPars;
426  break;
427  }
428 
429  const GlobalVector globalShift(meanPars[RbPars::dx], meanPars[RbPars::dy], meanPars[RbPars::dz]);
430  theCoordMaster->move(-globalShift); // sign to revert
431  align::EulerAngles globalAngles(3);
432  globalAngles[0] = meanPars[RbPars::dalpha];
433  globalAngles[1] = meanPars[RbPars::dbeta];
434  globalAngles[2] = meanPars[RbPars::dgamma];
435  theCoordMaster->rotateInGlobalFrame(align::toMatrix(-globalAngles)); // sign to revert
436  }
437 }
double Scalar
Definition: Definitions.h:25
Alignable * theCoordMaster
Alignables deselected for hierarchy constr.
Definition: PedeSteerer.h:139
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:34
align::Alignables theCoordDefiners
master coordinates, must (?) be global frame
Definition: PedeSteerer.h:140
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:34
std::ofstream * PedeSteerer::createSteerFile ( const std::string &  name,
bool  addToList 
)
private

create and open file with name, if (addToList) append to mySteeringFiles

Definition at line 642 of file PedeSteerer.cc.

References Exception, myNoSteerFiles, mySteeringFiles, submitPVResolutionJobs::out, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildMasterSteer(), defineCoordinates(), fixParameter(), hierarchyConstraints(), and presigmasFile().

642  {
643  const std::string realName(myNoSteerFiles ? "/dev/null" : name.c_str());
644 
645  std::ofstream *result = new std::ofstream(realName.c_str(), std::ios::out);
646  if (!result || !result->is_open()) {
647  delete result; // needed before exception in case just open failed
648  throw cms::Exception("FileOpenProblem") << "[PedeSteerer::createSteerFile]"
649  << "Could not open " << realName << " as output file.";
650  } else if (addToList) {
651  mySteeringFiles.push_back(realName); // keep track
652  }
653 
654  return result;
655 }
tuple result
Definition: mps_fire.py:311
bool myNoSteerFiles
directory of all files
Definition: PedeSteerer.h:129
std::vector< std::string > mySteeringFiles
precision for writing constraints to text file
Definition: PedeSteerer.h:136
void PedeSteerer::defineCoordinates ( const align::Alignables alis,
Alignable aliMaster,
const std::string &  fileName 
)
private

Create steering file with constraints defining coordinate system via hierarchy constraints between 'aliMaster' and 'alis'; 'aliMaster' must not have parameters: would not make sense!

Definition at line 346 of file PedeSteerer.cc.

References Alignable::alignmentParameters(), createSteerFile(), Exception, hierarchyConstraint(), myIsSteerFileDebug, and Alignable::setAlignmentParameters().

Referenced by buildSubSteer().

346  {
347  std::ofstream *filePtr = this->createSteerFile(fileName, true);
348  (*filePtr) << "* Constraints to define coordinate system:\n";
349  if (!aliMaster || aliMaster->alignmentParameters()) {
350  throw cms::Exception("BadConfig") << "[PedeSteerer::defineCoordinates] "
351  << "No master alignable or it has parameters!";
352  }
353  if (myIsSteerFileDebug) { // See constructor comments about hack:
354  edm::LogError("Alignment") << "@SUB=PedeSteerer::defineCoordinates"
355  << "Ignore following LogicErrors from PedeLabeler.";
356  }
357  AlignmentParameters *par = new RigidBodyAlignmentParameters(aliMaster, false);
358  aliMaster->setAlignmentParameters(par); // hierarchyConstraint needs parameters
359  this->hierarchyConstraint(aliMaster, alis, *filePtr);
360  aliMaster->setAlignmentParameters(nullptr); // erase dummy parameters
361 
362  delete filePtr; // automatically flushes, no problem if NULL ptr.
363 }
Log< level::Error, false > LogError
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
std::ofstream * createSteerFile(const std::string &name, bool addToList)
create and open file with name, if (addToList) append to mySteeringFiles
Definition: PedeSteerer.cc:642
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:123
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
bool myIsSteerFileDebug
flag to write steering files to /dev/null
Definition: PedeSteerer.h:130
void hierarchyConstraint(const Alignable *ali, const align::Alignables &components, std::ofstream &file) const
Definition: PedeSteerer.cc:474
const std::string& PedeSteerer::directory ( ) const
inline

directory from constructor input, '/' is attached if needed

Definition at line 70 of file PedeSteerer.h.

References myDirectory.

Referenced by PedeReader::PedeReader().

70 { return myDirectory; }
std::string myDirectory
Definition: PedeSteerer.h:128
std::string PedeSteerer::fileName ( const std::string &  addendum) const
private

full name with directory and 'idenitfier'

Definition at line 658 of file PedeSteerer.cc.

References edm::ParameterSet::getParameter(), myConfig, myDirectory, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildMasterSteer(), buildSubSteer(), and fixParameters().

658  {
660  name += myConfig.getParameter<std::string>("steerFile");
661  name += addendum;
662  name += ".txt";
663 
664  return name;
665 }
const edm::ParameterSet myConfig
Definition: PedeSteerer.h:127
std::string myDirectory
Definition: PedeSteerer.h:128
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int PedeSteerer::fixParameter ( Alignable ali,
unsigned int  iRunRange,
unsigned int  iParam,
char  selector,
std::ofstream *&  filePtr,
const std::string &  fileName 
)
private

If 'selector' means fixing, create corresponding steering file line in file pointed to by 'filePtr'. If 'filePtr == 0' create file with name 'fileName' (and return pointer via reference).

Definition at line 264 of file PedeSteerer.cc.

References PedeLabelerBase::alignableLabelFromParamAndInstance(), Alignable::alignmentParameters(), cmsToPedeFactor(), createSteerFile(), Exception, mergeVDriftHistosByStation::file, Alignable::globalPosition(), Alignable::id(), AlignmentParametersFactory::kRigidBody, myIsSteerFileDebug, myLabels, PedeLabelerBase::parameterLabel(), AlignmentParameters::parameters(), parameterSign(), position, mps_fire::result, and AlignmentParameters::type().

Referenced by fixParameters().

269  {
270  int result = 0;
271  float fixAt = 0.;
272  if (selector == 'c' || selector == 'C') {
274  throw cms::Exception("BadConfig")
275  << "PedeSteerer::fixParameter: correction (c/C) possible only for RigidBodyParameters";
276  }
277  fixAt = -this->parameterSign() * RigidBodyAlignmentParameters(ali, true).parameters()[iParam];
278  result = -1;
279  } else if (selector == 'f' || selector == 'F') {
280  result = 1;
281  }
282 
283  if (result) {
284  if (!filePtr) {
285  filePtr = this->createSteerFile(fileName, true);
286  (*filePtr) << "Parameter\n";
287  }
288  std::ofstream &file = *filePtr;
289 
290  const unsigned int aliLabel = myLabels->alignableLabelFromParamAndInstance(ali, iParam, iInstance);
291  file << myLabels->parameterLabel(aliLabel, iParam) << " " << fixAt * this->cmsToPedeFactor(iParam) << " -1.0";
292  if (myIsSteerFileDebug) { // debug
293  const GlobalPoint position(ali->globalPosition());
294  file << " * id " << ali->id() << ", eta " << position.eta() << ", z " << position.z() << ", r "
295  << position.perp() << ", phi " << position.phi();
296  }
297  file << "\n";
298  }
299 
300  return result;
301 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
tuple result
Definition: mps_fire.py:311
virtual unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const =0
returns the label for a given alignable parameter number combination
const AlgebraicVector & parameters(void) const
Get alignment parameters.
std::ofstream * createSteerFile(const std::string &name, bool addToList)
create and open file with name, if (addToList) append to mySteeringFiles
Definition: PedeSteerer.cc:642
const PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
virtual unsigned int alignableLabelFromParamAndInstance(Alignable *alignable, unsigned int param, unsigned int instance) const =0
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
double cmsToPedeFactor(unsigned int parNum) const
Definition: PedeSteerer.cc:141
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
bool myIsSteerFileDebug
flag to write steering files to /dev/null
Definition: PedeSteerer.h:130
static int position[264][3]
Definition: ReadPGInfo.cc:289
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
int parameterSign() const
results from pede (and start values for pede) might need a sign flip
Definition: PedeSteerer.h:68
std::pair< unsigned int, unsigned int > PedeSteerer::fixParameters ( const align::Alignables alis,
const std::string &  file 
)
private

Checks whether 'alignables' have SelectionUserVariables attached to their AlignmentParameters (these must exist) that indicate fixation of a parameter, a steering 'file' is created accordingly. Returns number of parameters fixed at 0 and at 'nominal truth'.

Definition at line 232 of file PedeSteerer.cc.

References fileName(), fixParameter(), SelectionUserVariables::fullSelection(), myLabels, PedeLabelerBase::numberOfParameterInstances(), submitPVValidationJobs::params, AlignmentParameters::size(), and AlignmentParameters::userVariables().

Referenced by buildSubSteer().

233  {
234  // return number of parameters fixed at 0. and fixed at original position
235  std::pair<unsigned int, unsigned int> numFixNumFixCor(0, 0);
236 
237  std::ofstream *filePtr = nullptr;
238 
239  for (const auto &iAli : alis) {
240  AlignmentParameters *params = iAli->alignmentParameters();
241  SelectionUserVariables *selVar = dynamic_cast<SelectionUserVariables *>(params->userVariables());
242  if (!selVar)
243  continue;
244 
245  for (unsigned int iParam = 0; static_cast<int>(iParam) < params->size(); ++iParam) {
246  const unsigned int nInstances = myLabels->numberOfParameterInstances(iAli, iParam);
247  for (unsigned int iInstance = 0; iInstance < nInstances; ++iInstance) {
248  int whichFix = this->fixParameter(iAli, iInstance, iParam, selVar->fullSelection()[iParam], filePtr, fileName);
249  if (whichFix == 1) {
250  ++(numFixNumFixCor.first);
251  } else if (whichFix == -1) {
252  ++(numFixNumFixCor.second);
253  }
254  }
255  }
256  }
257 
258  delete filePtr; // automatically flushes, no problem if NULL ptr.
259 
260  return numFixNumFixCor;
261 }
int fixParameter(Alignable *ali, unsigned int iRunRange, unsigned int iParam, char selector, std::ofstream *&filePtr, const std::string &fileName)
Definition: PedeSteerer.cc:264
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const std::vector< char > & fullSelection() const
const PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
int size(void) const
Get number of parameters.
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
virtual unsigned int numberOfParameterInstances(Alignable *alignable, int param=-1) const =0
returns the number of instances for a given parameter
void PedeSteerer::hierarchyConstraint ( const Alignable ali,
const align::Alignables components,
std::ofstream &  file 
) const
private

Definition at line 474 of file PedeSteerer.cc.

References PedeLabelerBase::alignableLabel(), Alignable::alignableObjectId(), alignableObjectId_, Alignable::globalPosition(), AlignmentParameterStore::hierarchyConstraints(), AlignableObjectId::idToString(), isNoHiera(), myIsSteerFileDebug, myLabels, myParameterStore, PedeLabelerBase::parameterLabel(), PV3DBase< T, PVType, FrameType >::perp(), theConstrPrecision, theMinHieraConstrCoeff, and theMinHieraParPerConstr.

Referenced by defineCoordinates(), and hierarchyConstraints().

476  {
477  typedef AlignmentParameterStore::ParameterId ParameterId;
478 
479  std::vector<std::vector<ParameterId> > paramIdsVec;
480  std::vector<std::vector<double> > factorsVec;
481  const bool allConstr = false; // true; // make configurable?
482  static std::atomic<bool> allConstrWarning{false};
483  bool expected{false};
484  if (allConstr && allConstrWarning.compare_exchange_strong(expected, true)) {
485  edm::LogWarning("Alignment") << "@SUB=PedeSteerer::hierarchyConstraint"
486  << "changed to use all 6 constraints";
487  }
489  ali, components, paramIdsVec, factorsVec, allConstr, theMinHieraConstrCoeff)) {
490  edm::LogWarning("Alignment") << "@SUB=PedeSteerer::hierarchyConstraint"
491  << "Problems from store.";
492  }
493 
494  for (unsigned int iConstr = 0; iConstr < paramIdsVec.size(); ++iConstr) {
495  std::ostringstream aConstr;
496 
497  const std::vector<ParameterId> &parIds = paramIdsVec[iConstr];
498  const std::vector<double> &factors = factorsVec[iConstr];
499  unsigned int nParPerConstr = 0; // keep track of used factor/parId pair
500  // parIds.size() == factors.size() granted by myParameterStore->hierarchyConstraints
501  for (unsigned int iParam = 0; iParam < parIds.size(); ++iParam) {
502  Alignable *aliSubComp = parIds[iParam].first;
503  const unsigned int compParNum = parIds[iParam].second;
504  if (this->isNoHiera(aliSubComp)) {
505  if (myIsSteerFileDebug)
506  aConstr << "* Taken out of hierarchy: ";
507  continue;
508  }
509  const unsigned int aliLabel = myLabels->alignableLabel(aliSubComp);
510  const unsigned int paramLabel = myLabels->parameterLabel(aliLabel, compParNum);
511  // FIXME: multiply by cmsToPedeFactor(subcomponent)/cmsToPedeFactor(mother) (or vice a versa?)
512  if (theConstrPrecision > 0)
513  aConstr << paramLabel << " " << std::setprecision(theConstrPrecision) << factors[iParam];
514  else
515  aConstr << paramLabel << " " << factors[iParam];
516  if (myIsSteerFileDebug) { // debug
517  aConstr << " ! for param " << compParNum << " of a "
518  << alignableObjectId_.idToString(aliSubComp->alignableObjectId()) << " at "
519  << aliSubComp->globalPosition() << ", r=" << aliSubComp->globalPosition().perp();
520  }
521  aConstr << "\n";
522  ++nParPerConstr; // OK, we used one.
523  } // end loop on params
524 
525  //
526  if (nParPerConstr && nParPerConstr >= theMinHieraParPerConstr) { // Enough to make sense?
527  if (myIsSteerFileDebug) { //debug
528  file << "\n* Nr. " << iConstr << " of a '" << alignableObjectId_.idToString(ali->alignableObjectId())
529  << "' (label " << myLabels->alignableLabel(const_cast<Alignable *>(ali)) // ugly cast: FIXME!
530  << "), position " << ali->globalPosition() << ", r = " << ali->globalPosition().perp();
531  }
532  file << "\nConstraint 0.\n" << aConstr.str(); // in future 'Wconstraint'?
533  } else if (nParPerConstr > 0) { // no warning for trivial case...
534  edm::LogWarning("Alignment") << "@SUB=PedeSteerer::hierarchyConstraint"
535  << "Skip constraint on " << nParPerConstr << " parameter(s):\n"
536  << aConstr.str();
537  }
538  } // end loop on constraints
539 }
T perp() const
Definition: PV3DBase.h:69
std::pair< Alignable *, unsigned int > ParameterId
a single alignable parameter of an Alignable
virtual unsigned int alignableLabel(Alignable *alignable) const =0
unsigned int theMinHieraParPerConstr
min absolute value of coefficients in hierarchy constraints
Definition: PedeSteerer.h:133
virtual unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const =0
returns the label for a given alignable parameter number combination
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 PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const AlignableObjectId alignableObjectId_
pointer to labeler (not the owner)
Definition: PedeSteerer.h:125
double theMinHieraConstrCoeff
old pede versions (before May &#39;07) need a sign flip...
Definition: PedeSteerer.h:132
unsigned int theConstrPrecision
hierarchy constraints with less params are ignored
Definition: PedeSteerer.h:134
const AlignmentParameterStore * myParameterStore
Definition: PedeSteerer.h:123
const char * idToString(align::StructureType type) const
bool isNoHiera(const Alignable *ali) const
True if &#39;ali&#39; was deselected from hierarchy and any ancestor (e.g. mother) has parameters.
Definition: PedeSteerer.cc:136
bool myIsSteerFileDebug
flag to write steering files to /dev/null
Definition: PedeSteerer.h:130
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
Log< level::Warning, false > LogWarning
unsigned int PedeSteerer::hierarchyConstraints ( const align::Alignables alis,
const std::string &  file 
)
private

Definition at line 440 of file PedeSteerer.cc.

References alignableObjectId_, createSteerFile(), hierarchyConstraint(), and AlignableObjectId::idToString().

Referenced by buildSubSteer().

440  {
441  std::ofstream *filePtr = nullptr;
442 
443  unsigned int nConstraints = 0;
444  align::Alignables aliDaughts;
445  for (const auto &iA : alis) {
446  aliDaughts.clear();
447  if (!(iA->firstCompsWithParams(aliDaughts))) {
448  edm::LogWarning("Alignment") << "@SUB=PedeSteerer::hierarchyConstraints"
449  << "Some but not all daughters of "
450  << alignableObjectId_.idToString(iA->alignableObjectId()) << " with params!";
451  }
452  // edm::LogInfo("Alignment") << "@SUB=PedeSteerer::hierarchyConstraints"
453  // << aliDaughts.size() << " ali param components";
454  if (aliDaughts.empty())
455  continue;
456  // edm::LogInfo("Alignment") << "@SUB=PedeSteerer::hierarchyConstraints"
457  // << aliDaughts.size() << " alignable components ("
458  // << iA->size() << " in total) for "
459  // << aliId.alignableTypeName(iA)
460  // << ", layer " << aliId.typeAndLayerFromAlignable(iA).second
461  // << ", position " << (iA)->globalPosition()
462  // << ", r = " << (iA)->globalPosition().perp();
463  if (!filePtr)
464  filePtr = this->createSteerFile(fileName, true);
465  ++nConstraints;
466  this->hierarchyConstraint(iA, aliDaughts, *filePtr);
467  }
468 
469  delete filePtr; // automatically flushes, no problem if NULL ptr.
470 
471  return nConstraints;
472 }
std::ofstream * createSteerFile(const std::string &name, bool addToList)
create and open file with name, if (addToList) append to mySteeringFiles
Definition: PedeSteerer.cc:642
const AlignableObjectId alignableObjectId_
pointer to labeler (not the owner)
Definition: PedeSteerer.h:125
const char * idToString(align::StructureType type) const
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
void hierarchyConstraint(const Alignable *ali, const align::Alignables &components, std::ofstream &file) const
Definition: PedeSteerer.cc:474
Log< level::Warning, false > LogWarning
bool PedeSteerer::isCorrectToRefSystem ( const align::Alignables coordDefiners) const

Definition at line 366 of file PedeSteerer.cc.

References Exception, SelectionUserVariables::fullSelection(), and mps_fire::i.

366  {
367  bool doCorrect = false;
368  bool doNotCorrect = false;
369  for (const auto &it : coordDefiners) {
370  SelectionUserVariables *selVar =
371  (it->alignmentParameters() ? dynamic_cast<SelectionUserVariables *>(it->alignmentParameters()->userVariables())
372  : nullptr);
373  if (!selVar)
374  continue; // is an error!?
375 
376  for (unsigned int i = 0; i < selVar->fullSelection().size(); ++i) {
377  if (selVar->fullSelection()[i] == 'r')
378  doNotCorrect = true;
379  else if (selVar->fullSelection()[i] == 's')
380  doCorrect = true;
381  }
382  }
383 
384  if (doCorrect && doNotCorrect) {
385  throw cms::Exception("BadConfig")
386  << "[PedeSteerer::doCorrectToRefSystem]: Parameter selection 's' and 'r' must not coexist!";
387  }
388 
389  return doCorrect;
390 }
const std::vector< char > & fullSelection() const
bool PedeSteerer::isNoHiera ( const Alignable ali) const

True if 'ali' was deselected from hierarchy and any ancestor (e.g. mother) has parameters.

Definition at line 136 of file PedeSteerer.cc.

References myNoHieraCollection.

Referenced by hierarchyConstraint().

136  {
137  return (myNoHieraCollection.find(ali) != myNoHieraCollection.end());
138 }
std::set< const Alignable * > myNoHieraCollection
keeps track of created &#39;secondary&#39; steering files
Definition: PedeSteerer.h:138
int PedeSteerer::parameterSign ( ) const
inline

results from pede (and start values for pede) might need a sign flip

Definition at line 68 of file PedeSteerer.h.

References myParameterSign.

Referenced by fixParameter(), PedeReader::setCalibrationParameter(), and PedeReader::setParameter().

68 { return myParameterSign; }
int myParameterSign
whether or not to fill pede steering files with debug info
Definition: PedeSteerer.h:131
unsigned int PedeSteerer::presigmas ( const std::vector< edm::ParameterSet > &  cffPresi,
const std::string &  fileName,
const align::Alignables alis,
AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras aliExtras 
)
private

interprete content of presigma VPSet 'cffPresi' and call presigmasFile

Definition at line 542 of file PedeSteerer.cc.

References AlignmentParameterSelector::addSelections(), alignableObjectId_, AlignmentParameterSelector::clear(), Exception, AlignableObjectId::idToString(), presigmasFile(), AlignmentParameterSelector::selectedAlignables(), and AlignmentParameterSelector::selectedParameters().

Referenced by buildSubSteer(), and presigmasFile().

547  {
548  // We loop on given PSet's, each containing a parameter selection and the presigma value
549  // The resulting presigmas are stored in a map with Alignable* as key.
550  // This map, 'fileName' and 'alis' are passed further to create the steering file.
551 
552  AlignmentParameterSelector selector(aliTracker, aliMuon, aliExtras);
553  AlignablePresigmasMap aliPresiMap; // map to store alis with presigmas of their parameters
554  for (std::vector<edm::ParameterSet>::const_iterator iSet = cffPresi.begin(), iE = cffPresi.end(); iSet != iE;
555  ++iSet) { // loop on individual PSets defining ali-params with their presigma
556  selector.clear();
557  selector.addSelections((*iSet).getParameter<edm::ParameterSet>("Selector"));
558  const auto &alis = selector.selectedAlignables();
559  const std::vector<std::vector<char> > &sels = selector.selectedParameters();
560  const float presigma = (*iSet).getParameter<double>("presigma");
561  if (presigma <= 0.) { // given presigma > 0., 0. later used if not (yet) chosen for parameter
562  throw cms::Exception("BadConfig") << "[PedeSteerer::presigmas]: Pre-sigma must be > 0., but is " << presigma
563  << ".";
564  }
565  // now loop on alis of present selection
566  for (unsigned int iAli = 0; iAli < alis.size(); ++iAli) {
567  std::vector<float> &presigmas = aliPresiMap[alis[iAli]]; // existing or empty, so ensure length:
568  if (presigmas.size() < sels[iAli].size())
569  presigmas.resize(sels[iAli].size(), 0.);
570  for (unsigned int iParam = 0; iParam < sels[iAli].size(); ++iParam) { // loop on parameters
571  if (sels[iAli][iParam] != '0') { // all but '0' means to apply the chosen presigma
572  if (presigmas[iParam] != 0.) { // reset forbidden (would make it order dependent!)
573  throw cms::Exception("BadConfig")
574  << "[PedeSteerer::presigmas]: Try to set pre-sigma " << presigma << ", but already "
575  << "set " << presigmas[iParam] << " (for a "
576  << alignableObjectId_.idToString(alis[iAli]->alignableObjectId()) << ").";
577  }
578  presigmas[iParam] = presigma;
579  } // end if selected for presigma
580  } // end loop on params
581  } // end loop on alignables for given selection and presigma
582  } // end loop on PSets
583 
584  if (aliPresiMap.empty())
585  return 0;
586  else
587  return this->presigmasFile(fileName, alis, aliPresiMap);
588 }
unsigned int presigmas(const std::vector< edm::ParameterSet > &cffPresi, const std::string &fileName, const align::Alignables &, AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
interprete content of presigma VPSet &#39;cffPresi&#39; and call presigmasFile
Definition: PedeSteerer.cc:542
unsigned int presigmasFile(const std::string &fileName, const align::Alignables &, const AlignablePresigmasMap &aliPresisMap)
look for active &#39;alis&#39; in map of presigma values and create steering file
Definition: PedeSteerer.cc:591
const AlignableObjectId alignableObjectId_
pointer to labeler (not the owner)
Definition: PedeSteerer.h:125
const char * idToString(align::StructureType type) const
std::map< const Alignable *, std::vector< float > > AlignablePresigmasMap
Definition: PedeSteerer.h:73
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
unsigned int PedeSteerer::presigmasFile ( const std::string &  fileName,
const align::Alignables alis,
const AlignablePresigmasMap aliPresisMap 
)
private

look for active 'alis' in map of presigma values and create steering file

Definition at line 591 of file PedeSteerer.cc.

References PedeLabelerBase::alignableLabel(), alignableObjectId_, cmsToPedeFactor(), createSteerFile(), SelectionUserVariables::fullSelection(), AlignableObjectId::idToString(), myIsSteerFileDebug, myLabels, PedeLabelerBase::parameterLabel(), and presigmas().

Referenced by presigmas().

593  {
594  // Check if 'alis' are in aliPresiMap,
595  // if yes apply presigma - but NOT if parameter is fixed!
596  std::ofstream *filePtr = nullptr;
597 
598  unsigned int nPresiParam = 0;
599  for (const auto &iAli : alis) {
600  // Any presigma chosen for alignable?
601  AlignablePresigmasMap::const_iterator presigmasIt = aliPresiMap.find(iAli);
602  if (presigmasIt == aliPresiMap.end())
603  continue; // no presigma chosen for alignable
604 
605  // Why does the following not work? It does with CMSSW_1_3_X on SLC3...
606  // const AlignablePresigmasMap::data_type &presigmas = presigmasIt->second;
607  const std::vector<float> &presigmas = presigmasIt->second; // I want to hide float or double...
608  for (unsigned int iParam = 0; iParam < presigmas.size(); ++iParam) {
609  // Now check whether a presigma value > 0. chosen:
610  if (presigmas[iParam] <= 0.)
611  continue; // must be positive, '<' checked above
612  // Do not apply presigma to inactive or fixed values.
613  if (!(iAli->alignmentParameters()->selector()[iParam]))
614  continue;
615  SelectionUserVariables *selVar =
616  dynamic_cast<SelectionUserVariables *>(iAli->alignmentParameters()->userVariables());
617  const char selChar = (selVar ? selVar->fullSelection()[iParam] : '1');
618  if (selChar == 'f' || selChar == 'F' || selChar == 'c' || selChar == 'C')
619  continue;
620  // Finally create and write steering file:
621  if (!filePtr) {
622  filePtr = this->createSteerFile(fileName, true);
623  (*filePtr) << "* Presigma values for active parameters: \nParameter\n";
624  }
625  const unsigned int aliLabel = myLabels->alignableLabel(iAli);
626  (*filePtr) << myLabels->parameterLabel(aliLabel, iParam) << " 0. "
627  << presigmas[iParam] * fabs(this->cmsToPedeFactor(iParam));
628  if (myIsSteerFileDebug) {
629  (*filePtr) << " ! for a " << alignableObjectId_.idToString((iAli)->alignableObjectId());
630  }
631  (*filePtr) << '\n';
632 
633  ++nPresiParam;
634  } // end loop on parameters for alignables with chosen presigmas
635  } // end loop on alignables
636 
637  delete filePtr; // close properly file
638  return nPresiParam;
639 }
unsigned int presigmas(const std::vector< edm::ParameterSet > &cffPresi, const std::string &fileName, const align::Alignables &, AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *aliExtras)
interprete content of presigma VPSet &#39;cffPresi&#39; and call presigmasFile
Definition: PedeSteerer.cc:542
virtual unsigned int alignableLabel(Alignable *alignable) const =0
virtual unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const =0
returns the label for a given alignable parameter number combination
std::ofstream * createSteerFile(const std::string &name, bool addToList)
create and open file with name, if (addToList) append to mySteeringFiles
Definition: PedeSteerer.cc:642
const std::vector< char > & fullSelection() const
const PedeLabelerBase * myLabels
not the owner!
Definition: PedeSteerer.h:124
const AlignableObjectId alignableObjectId_
pointer to labeler (not the owner)
Definition: PedeSteerer.h:125
const char * idToString(align::StructureType type) const
double cmsToPedeFactor(unsigned int parNum) const
Definition: PedeSteerer.cc:141
std::string fileName(const std::string &addendum) const
full name with directory and &#39;idenitfier&#39;
Definition: PedeSteerer.cc:658
bool myIsSteerFileDebug
flag to write steering files to /dev/null
Definition: PedeSteerer.h:130
int PedeSteerer::runPede ( const std::string &  masterSteer) const

run pede, masterSteer should be as returned from buildMasterSteer(...)

Definition at line 784 of file PedeSteerer.cc.

References mps_check::command, remoteMonitoring_LASER_era2018_cfg::dump, edm::ParameterSet::getUntrackedParameter(), myConfig, myDirectory, and AlCaHLTBitMon_QueryRunRegistry::string.

784  {
785  if (masterSteer.empty()) {
786  edm::LogError("Alignment") << "@SUB=PedeSteerer::runPede"
787  << "Empty master steer file, stop";
788  return 0; //false;
789  }
790 
792  (command += " ") += masterSteer;
794  if (!dump.empty()) {
795  command += " > ";
796  (command += myDirectory) += dump;
797  }
798 
799  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::runPede"
800  << "Start running " << command;
801  // FIXME: Recommended interface to system commands?
802  int shellReturn = gSystem->Exec(command.c_str());
803  edm::LogInfo("Alignment") << "@SUB=PedeSteerer::runPede"
804  << "Command returns " << shellReturn;
805 
806  return shellReturn;
807 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::ParameterSet myConfig
Definition: PedeSteerer.h:127
std::string myDirectory
Definition: PedeSteerer.h:128
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
list command
Definition: mps_check.py:25
tuple dump
OutputFilePath = cms.string(&#39;/tmp/zhokin/&#39;), OutputFileExt = cms.string(&#39;&#39;),.
align::Alignables PedeSteerer::selectCoordinateAlis ( const align::Alignables alis) const
private

Return 'alignables' that have SelectionUserVariables attached to their AlignmentParameters (these must exist) that indicate a definition of a coordinate system. Throws if ill defined reference objects.

Definition at line 304 of file PedeSteerer.cc.

References Exception, SelectionUserVariables::fullSelection(), submitPVValidationJobs::params, AlignmentParameters::size(), and AlignmentParameters::userVariables().

304  {
305  align::Alignables coordAlis;
306 
307  for (const auto &iAli : alis) {
308  AlignmentParameters *params = iAli->alignmentParameters();
309  SelectionUserVariables *selVar = dynamic_cast<SelectionUserVariables *>(params->userVariables());
310  if (!selVar)
311  continue;
312  unsigned int refParam = 0;
313  unsigned int nonRefParam = 0;
314  for (unsigned int iParam = 0; static_cast<int>(iParam) < params->size(); ++iParam) {
315  const char selector = selVar->fullSelection()[iParam];
316  if (selector == 'r' || selector == 's') {
317  ++refParam;
318  } else if (selector != '0' && selector != 'f') { // allow also 'c'?
319  ++nonRefParam;
320  }
321  }
322  // Check whether some 'r/s' selection string. If yes and selection makes sense, add to result:
323  if (refParam) {
324  if (nonRefParam) {
325  throw cms::Exception("BadConfig")
326  << "[PedeSteerer::selectCoordinateAlis] All active parameters of alignables defining "
327  << "the coordinate system must be marked with 'r/s' (or fixed, 'f')!";
328  } else {
329  auto mother = iAli;
330  while ((mother = mother->mother())) {
331  if (mother->alignmentParameters()) {
332  throw cms::Exception("BadConfig") << "[PedeSteerer::selectCoordinateAlis] "
333  << "Alignables defining the coordinate system must "
334  << "be highest level!";
335  }
336  }
337  coordAlis.push_back(iAli);
338  }
339  }
340  } // end loop on alignables
341 
342  return coordAlis;
343 }
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const std::vector< char > & fullSelection() const
int size(void) const
Get number of parameters.
std::vector< Alignable * > Alignables
Definition: Utilities.h:31

Member Data Documentation

const AlignableObjectId PedeSteerer::alignableObjectId_
private

pointer to labeler (not the owner)

Definition at line 125 of file PedeSteerer.h.

Referenced by hierarchyConstraint(), hierarchyConstraints(), presigmas(), and presigmasFile().

const edm::ParameterSet PedeSteerer::myConfig
private

Definition at line 127 of file PedeSteerer.h.

Referenced by buildMasterSteer(), buildSubSteer(), fileName(), and runPede().

std::string PedeSteerer::myDirectory
private

Definition at line 128 of file PedeSteerer.h.

Referenced by directory(), fileName(), and runPede().

bool PedeSteerer::myIsSteerFileDebug
private

flag to write steering files to /dev/null

Definition at line 130 of file PedeSteerer.h.

Referenced by defineCoordinates(), fixParameter(), hierarchyConstraint(), and presigmasFile().

const PedeLabelerBase* PedeSteerer::myLabels
private

not the owner!

Definition at line 124 of file PedeSteerer.h.

Referenced by buildSubSteer(), fixParameter(), fixParameters(), hierarchyConstraint(), and presigmasFile().

std::set<const Alignable *> PedeSteerer::myNoHieraCollection
private

keeps track of created 'secondary' steering files

Definition at line 138 of file PedeSteerer.h.

Referenced by buildNoHierarchyCollection(), buildSubSteer(), and isNoHiera().

bool PedeSteerer::myNoSteerFiles
private

directory of all files

Definition at line 129 of file PedeSteerer.h.

Referenced by createSteerFile().

int PedeSteerer::myParameterSign
private

whether or not to fill pede steering files with debug info

Definition at line 131 of file PedeSteerer.h.

Referenced by parameterSign().

const AlignmentParameterStore* PedeSteerer::myParameterStore
private

Definition at line 123 of file PedeSteerer.h.

Referenced by buildSubSteer(), and hierarchyConstraint().

std::vector<std::string> PedeSteerer::mySteeringFiles
private

precision for writing constraints to text file

Definition at line 136 of file PedeSteerer.h.

Referenced by buildMasterSteer(), and createSteerFile().

unsigned int PedeSteerer::theConstrPrecision
private

hierarchy constraints with less params are ignored

Definition at line 134 of file PedeSteerer.h.

Referenced by hierarchyConstraint().

align::Alignables PedeSteerer::theCoordDefiners
private

master coordinates, must (?) be global frame

Definition at line 140 of file PedeSteerer.h.

Referenced by buildSubSteer(), and correctToReferenceSystem().

Alignable* PedeSteerer::theCoordMaster
private

Alignables deselected for hierarchy constr.

Definition at line 139 of file PedeSteerer.h.

Referenced by buildSubSteer(), and correctToReferenceSystem().

double PedeSteerer::theMinHieraConstrCoeff
private

old pede versions (before May '07) need a sign flip...

Definition at line 132 of file PedeSteerer.h.

Referenced by hierarchyConstraint().

unsigned int PedeSteerer::theMinHieraParPerConstr
private

min absolute value of coefficients in hierarchy constraints

Definition at line 133 of file PedeSteerer.h.

Referenced by hierarchyConstraint().