CMS 3D CMS Logo

AlignmentParametersIO.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002 
00003 #include "Alignment/CommonAlignment/interface/Alignable.h"
00004 #include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h"
00005 
00006 // this class's header
00007 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIO.h"
00008 
00009 //--------------------------------------------------------------------------------------------------
00010 // write one set of original parameters
00011 int AlignmentParametersIO::writeOneOrigRigidBody(Alignable *ali)
00012 {
00013 
00014   AlignmentParameters *par = ali->alignmentParameters();
00015   AlignmentParameters *parBack = (par ? par->clone(par->parameters(), par->covariance()) : 0);
00016 
00017   ali->setAlignmentParameters(new RigidBodyAlignmentParameters(ali, true));
00018   int iret = this->writeOne(ali);
00019 
00020   ali->setAlignmentParameters(parBack); // deletes the above created RigidBodyAlignmentParameters
00021 
00022   return iret;
00023 }
00024 
00025 
00026 //-----------------------------------------------------------------------------
00027 // write many parameters
00028 int 
00029 AlignmentParametersIO::write(const align::Alignables& alivec, 
00030                              bool validCheck) 
00031 {
00032   int icount=0;
00033   for(align::Alignables::const_iterator it=alivec.begin();
00034           it!=alivec.end(); it++) {
00035     if ((*it)->alignmentParameters()->isValid() || !(validCheck)) {
00036       icount++;
00037       int iret=writeOne(*it);
00038       if (iret!=0) return iret;
00039     }
00040   }
00041   edm::LogInfo("Alignment") << "@SUB=AlignmentParametersIO::write"
00042                             << "Wrote " << icount << " out of " << alivec.size() << " parameters";
00043   return 0;
00044 }
00045 
00046 
00047 //-----------------------------------------------------------------------------
00048 // write many original parameters
00049 int 
00050 AlignmentParametersIO::writeOrigRigidBody(const align::Alignables& alivec, bool validCheck)
00051 {
00052   int icount = 0;
00053   for(align::Alignables::const_iterator it = alivec.begin(); it != alivec.end(); ++it) {
00054     if (!validCheck || (*it)->alignmentParameters()->isValid()) {
00055       ++icount;
00056       int iret = this->writeOneOrigRigidBody(*it);
00057       if (iret != 0) return iret;
00058     }
00059   }
00060   edm::LogInfo("Alignment") << "@SUB=AlignmentParametersIO::writeOrigRigidBody"
00061                             << "Wrote " << icount << " out of " << alivec.size()
00062                             << " original parameters.";
00063   return 0;
00064 }
00065 
00066 //-----------------------------------------------------------------------------
00067 // read many parameters
00068 
00069 align::Parameters 
00070 AlignmentParametersIO::read(const align::Alignables& alivec, int& ierr) 
00071 {
00072   align::Parameters retvec;
00073   int ierr2;
00074   int icount=0;
00075   for(align::Alignables::const_iterator it=alivec.begin();
00076     it!=alivec.end(); it++) {
00077     AlignmentParameters* ad=readOne(*it, ierr2);
00078     if (ad!=0 && ierr2==0) { retvec.push_back(ad); icount++; }
00079   }
00080   edm::LogInfo("Alignment") << "@SUB-AlignmentParametersIO::write"
00081                             << "Read " << icount << " out of " << alivec.size() << " parameters";
00082   return retvec;
00083 }

Generated on Tue Jun 9 17:23:47 2009 for CMSSW by  doxygen 1.5.4