Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:40

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 
0003 #include "Alignment/CommonAlignment/interface/Alignable.h"
0004 #include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h"
0005 
0006 // this class's header
0007 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIO.h"
0008 
0009 //--------------------------------------------------------------------------------------------------
0010 // write one set of original parameters
0011 int AlignmentParametersIO::writeOneOrigRigidBody(Alignable* ali) {
0012   AlignmentParameters* par = ali->alignmentParameters();
0013   AlignmentParameters* parBack = (par ? par->clone(par->parameters(), par->covariance()) : nullptr);
0014 
0015   ali->setAlignmentParameters(new RigidBodyAlignmentParameters(ali, true));
0016   int iret = this->writeOne(ali);
0017 
0018   ali->setAlignmentParameters(parBack);  // deletes the above created RigidBodyAlignmentParameters
0019 
0020   return iret;
0021 }
0022 
0023 //-----------------------------------------------------------------------------
0024 // write many parameters
0025 int AlignmentParametersIO::write(const align::Alignables& alivec, bool validCheck) {
0026   int icount = 0;
0027   for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
0028     if ((*it)->alignmentParameters()->isValid() || !(validCheck)) {
0029       icount++;
0030       int iret = writeOne(*it);
0031       if (iret != 0)
0032         return iret;
0033     }
0034   }
0035   edm::LogInfo("Alignment") << "@SUB=AlignmentParametersIO::write"
0036                             << "Wrote " << icount << " out of " << alivec.size() << " parameters";
0037   return 0;
0038 }
0039 
0040 //-----------------------------------------------------------------------------
0041 // write many original parameters
0042 int AlignmentParametersIO::writeOrigRigidBody(const align::Alignables& alivec, bool validCheck) {
0043   int icount = 0;
0044   for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
0045     if (!validCheck || (*it)->alignmentParameters()->isValid()) {
0046       ++icount;
0047       int iret = this->writeOneOrigRigidBody(*it);
0048       if (iret != 0)
0049         return iret;
0050     }
0051   }
0052   edm::LogInfo("Alignment") << "@SUB=AlignmentParametersIO::writeOrigRigidBody"
0053                             << "Wrote " << icount << " out of " << alivec.size() << " original parameters.";
0054   return 0;
0055 }
0056 
0057 //-----------------------------------------------------------------------------
0058 // read many parameters
0059 
0060 align::Parameters AlignmentParametersIO::read(const align::Alignables& alivec, int& ierr) {
0061   align::Parameters retvec;
0062   int ierr2;
0063   int icount = 0;
0064   for (align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
0065     AlignmentParameters* ad = readOne(*it, ierr2);
0066     if (ad != nullptr && ierr2 == 0) {
0067       retvec.push_back(ad);
0068       icount++;
0069     }
0070   }
0071   edm::LogInfo("Alignment") << "@SUB-AlignmentParametersIO::write"
0072                             << "Read " << icount << " out of " << alivec.size() << " parameters";
0073   return retvec;
0074 }