37 : mySteerer(steerer), myLabels(labels), myRunRange(runrange)
40 if (pedeResultFile.empty()) pedeResultFile = steerer.
directory();
41 else if (pedeResultFile.find_last_of(
'/') != pedeResultFile.size() - 1) {
42 pedeResultFile +=
'/';
49 <<
"Problem opening pede output file " << pedeResultFile;
60 std::set<Alignable*> uniqueList;
63 <<
"will read parameters for run range " 67 unsigned int nParam = 0, nParamCalib = 0, nParamUnknown = 0;
70 unsigned int paramLabel = 0;
71 if (!this->readIfSameLine<unsigned int>(
myPedeResult, paramLabel))
continue;
75 unsigned int bufferPos = 0;
77 if (!this->readIfSameLine<float>(
myPedeResult, buffer[bufferPos]))
break;
83 std::pair<IntegratedCalibrationBase*, unsigned int> calibParam
85 if (calibParam.first) {
89 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::read" <<
"Problems setting results of " 90 <<
"parameter " << calibParam.second <<
" to calibration '" 91 << calibParam.first->name() <<
"' ("<< calibParam.first <<
").";
106 uniqueList.insert(alignable);
111 alignables.insert(alignables.end(), uniqueList.begin(), uniqueList.end());
113 std::stringstream
out;
114 out << nParam <<
" parameters for " << alignables.size() <<
" alignables and " << nParamCalib
115 <<
" for calibrations, " << nParamUnknown <<
" parameters are unknown.\n";
119 edm::LogInfo(
"Alignment") <<
"@SUB=PedeReader::read" << out.str();
122 return isAllOk && (nParam + nParamCalib);
132 const int aChar = aStream.get();
133 if (!aStream.good())
return false;
144 if (aStream.fail()) {
146 while (aStream.good() && aStream.get() !=
'\n');
154 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::readIfSameLine" <<
"Should never come here!";
160 unsigned int bufLength,
const float *buf,
161 bool setUserVars)
const 172 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::setParameter" 173 <<
"Label mismatch: paramLabel " << paramLabel
174 <<
" for alignableLabel " << userParams->
label();
184 if (userParams) userParams->
globalCor()[paramNum] = buf[4];
186 if (userParams) userParams->
sigma()[paramNum] = buf[3] / cmsToPede;
187 covMat[paramNum][paramNum] = buf[3]*buf[3] / (cmsToPede*cmsToPede);
190 if (userParams) userParams->
diffBefore()[paramNum] = buf[2] / cmsToPede;
196 userParams->
parameter()[paramNum] = parVec[paramNum];
197 userParams->
preSigma()[paramNum] = buf[1];
198 if (!userParams->
isFixed(paramNum)) {
199 userParams->
preSigma()[paramNum] /= cmsToPede;
200 if (bufLength == 2) {
202 <<
"Param " << paramLabel <<
" (from " 203 <<
typeid(*alignable).name() <<
") without result!";
204 userParams->
isValid()[paramNum] =
false;
213 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::setParameter" 214 <<
"Expect 2 to 5 values, got " << bufLength
215 <<
" for label " << paramLabel;
221 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::setParameter" 222 <<
"No alignable for paramLabel " << paramLabel
223 <<
", probably LasBeam with Id " << lasBeamId
224 <<
",\nparam " << paramNum <<
": " 226 <<
" += " << (bufLength >= 4 ? buf[3] / cmsToPede : -99.);
234 unsigned int bufLength,
const float *buf)
const 236 if (!calib || !buf)
return false;
246 if (bufLength == 2 && buf[1] >= 0.) {
247 edm::LogWarning(
"Alignment") <<
"@SUB=PedeReader::setCalibrationParameter" 248 <<
"Param " << paramNum <<
" of calibration '" 249 << calib->
name() <<
"' without result!";
255 edm::LogError(
"Alignment") <<
"@SUB=PedeReader::setCalibrationParameter" 256 <<
"Expect 2 to 5 values, got " << bufLength <<
".";
268 throw cms::Exception(
"BadConfig") <<
"PedeReader::checkAliParams: " 269 <<
"Alignable without parameters.";
274 if (createUserVars && !dynamic_cast<MillePedeVariables*>(params->
userVariables())) {
275 edm::LogInfo(
"Alignment") <<
"@SUB=PedeReader::checkAliParams" 276 <<
"Add user variables for alignable with label " unsigned int label() const
get alignable label as used by pede
const std::vector< float > & globalCor() const
get global correlation array
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual const RunRange & runRangeFromLabel(unsigned int label) const
PedeReader(const edm::ParameterSet &config, const PedeSteerer &steerer, const PedeLabelerBase &labels, const RunRange &runrange)
AlignmentParameters * checkAliParams(Alignable *alignable, bool createUserVars) const
bool read(std::vector< Alignable * > &alignables, bool setUserVars)
std::string typeToName(align::StructureType type) const
Convert type to name.
bool isFixed(unsigned int nParam) const
true if parameter is fixed
const PedeSteerer & mySteerer
std::ifstream myPedeResult
virtual bool setParameter(unsigned int index, double value)=0
const std::vector< float > & parameter() const
get array of parameters
const std::string & name() const
name of this calibration
virtual unsigned int paramNumFromLabel(unsigned int paramLabel) const =0
parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
const AlgebraicVector & parameters(void) const
Get alignment parameters.
virtual unsigned int lasBeamIdFromLabel(unsigned int label) const =0
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
void setValid(bool v)
Set validity flag.
const std::vector< float > & preSigma() const
get array of presigmas (<= 0: means fixed)
const std::vector< float > & sigma() const
get array of sigmas
Alignable * setParameter(unsigned int paramLabel, unsigned int bufLength, const float *buf, bool setUserVars) const
bool readIfSameLine(std::ifstream &aStream, T &outValue) const
const AlignableTracker * alignableTracker() const
virtual AlignmentParameters * clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Enforce clone methods in derived classes.
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker's geometry.
virtual Alignable * alignableFromLabel(unsigned int label) const =0
const std::vector< float > & diffBefore() const
get array of differences to start value
CLHEP::HepVector AlgebraicVector
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
int size(void) const
Get number of parameters.
virtual unsigned int alignableLabel(Alignable *alignable) const =0
double cmsToPedeFactor(unsigned int parNum) const
PedeLabelerBase::RunRange RunRange
const std::vector< bool > & isValid() const
get valid flag array
CLHEP::HepSymMatrix AlgebraicSymMatrix
static const unsigned int myMaxNumValPerParam
const std::string & directory() const
directory from constructor input, '/' is attached if needed
virtual bool setParameterError(unsigned int index, double value)=0
virtual std::pair< IntegratedCalibrationBase *, unsigned int > calibrationParamFromLabel(unsigned int label) const
bool setCalibrationParameter(IntegratedCalibrationBase *calib, unsigned int paramNum, unsigned int bufLength, const float *buf) const
Set pede results stored in 'buf' to parameter 'paramNum' of IntegratedCalibrationBase.
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
const PedeLabelerBase & myLabels
const RunRange myRunRange
bool setAllDefault(unsigned int nParam)
set default values for all data concerning nParam (false if nParam out of range)
int parameterSign() const
results from pede (and start values for pede) might need a sign flip