CMS 3D CMS Logo

AlignableDataIO.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignment/interface/Alignable.h"
00002 #include "Alignment/CommonAlignment/interface/AlignmentParameters.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 // this class's header
00006 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignableDataIO.h"
00007 
00008 // ----------------------------------------------------------------------------
00009 AlignableAbsData AlignableDataIO::readAbsPos(Alignable* ali, int& ierr)
00010 { 
00011   return readAbsRaw(ali,ierr);
00012 }
00013 
00014 
00015 // ----------------------------------------------------------------------------
00016 AlignableAbsData AlignableDataIO::readOrgPos(Alignable* ali, int& ierr)
00017 { 
00018   return readAbsRaw(ali,ierr);
00019 }
00020 
00021 
00022 // ----------------------------------------------------------------------------
00023 AlignableRelData AlignableDataIO::readRelPos(Alignable* ali, int& ierr)
00024 { 
00025   return readRelRaw(ali,ierr);
00026 }
00027 
00028 
00029 // ----------------------------------------------------------------------------
00030 int AlignableDataIO::writeAbsPos(Alignable* ali, bool validCheck)
00031 {
00032   
00033   if ( !(validCheck) || ali->alignmentParameters()->isValid() ) 
00034     {
00035       // position in global frame
00036       align::PositionType pos = ali->surface().position();
00037       // global rotation
00038       align::RotationType rot = ali->surface().rotation();
00039       // write
00040       return writeAbsRaw( 
00041                          AlignableAbsData( pos,rot,
00042                                            ali->id(),
00043                                            ali->alignableObjectId() )
00044                          );
00045     }
00046 
00047   return 1;
00048 }
00049 
00050 
00051 // ----------------------------------------------------------------------------
00052 int AlignableDataIO::writeRelPos(Alignable* ali, bool validCheck)
00053 {
00054   if ( !(validCheck) || ali->alignmentParameters()->isValid() ) 
00055     {
00056       // rel. shift in global frame
00057       align::GlobalVector pos = ali->displacement();
00058       // rel. rotation in global frame
00059       align::RotationType rot = ali->rotation();
00060       // write
00061       return writeRelRaw(AlignableRelData(pos,rot,ali->id(),
00062                                           ali->alignableObjectId()));
00063     }
00064 
00065   return 1;
00066 }
00067 
00068 
00069 // ----------------------------------------------------------------------------
00070 int AlignableDataIO::writeOrgPos(Alignable* ali, bool validCheck)
00071 {
00072   if ( !(validCheck) || ali->alignmentParameters()->isValid() ) 
00073     {
00074       // orig position
00075       align::PositionType pos = ali->globalPosition() - ali->displacement();
00076       // orig rotation
00077       align::RotationType rot = ali->globalRotation() * ali->rotation().transposed();
00078       // write
00079       return writeAbsRaw(AlignableAbsData(pos,rot,ali->id(),
00080                                           ali->alignableObjectId()));
00081     }
00082 
00083   return 1;
00084 }
00085 
00086 
00087 // ----------------------------------------------------------------------------
00088 int AlignableDataIO::writeAbsPos(const align::Alignables& alivec, 
00089                                  bool validCheck)
00090 {
00091 
00092   int icount=0;
00093   for( align::Alignables::const_iterator it=alivec.begin();
00094        it!=alivec.end(); it++ ) 
00095     {
00096       int iret = writeAbsPos(*it,validCheck);
00097       if (iret==0) icount++;
00098     }
00099   LogDebug("WriteAbsPos") << "all,written: " << alivec.size() <<","<< icount;
00100 
00101   return 0;
00102 
00103 }
00104 
00105 
00106 // ----------------------------------------------------------------------------
00107 AlignablePositions 
00108 AlignableDataIO::readAbsPos(const align::Alignables& alivec, int& ierr) 
00109 {
00110  
00111   AlignablePositions retvec;
00112   int ierr2=0;
00113   ierr=0;
00114   for( align::Alignables::const_iterator it=alivec.begin();
00115        it!=alivec.end(); it++ ) 
00116     {
00117       AlignableAbsData ad=readAbsPos(*it, ierr2);
00118       if (ierr2==0) retvec.push_back(ad);
00119     }
00120   
00121   LogDebug("ReadAbsPos") << "all,written: " << alivec.size() <<"," << retvec.size();
00122 
00123   return retvec;
00124 
00125 }
00126 
00127 
00128 // ----------------------------------------------------------------------------
00129 int AlignableDataIO::writeOrgPos( const align::Alignables& alivec, 
00130                                   bool validCheck )
00131 {
00132 
00133   int icount=0;
00134   for( align::Alignables::const_iterator it=alivec.begin();
00135        it!=alivec.end(); it++ ) 
00136     {
00137       int iret=writeOrgPos(*it,validCheck);
00138       if (iret==0) icount++;
00139     }
00140   
00141   LogDebug("WriteOrgPos") << "all,written: " << alivec.size() <<"," << icount;
00142   return 0;
00143 
00144 }
00145 
00146 
00147 // ----------------------------------------------------------------------------
00148 AlignablePositions 
00149 AlignableDataIO::readOrgPos(const align::Alignables& alivec, int& ierr) 
00150 {
00151 
00152   AlignablePositions retvec;
00153   int ierr2=0;
00154   ierr=0;
00155   for( align::Alignables::const_iterator it=alivec.begin();
00156        it!=alivec.end(); it++ ) 
00157     {
00158       AlignableAbsData ad=readOrgPos(*it, ierr2);
00159       if (ierr2==0) retvec.push_back(ad);
00160     }
00161 
00162   LogDebug("ReadOrgPos") << "all,read: " << alivec.size() <<", "<< retvec.size();
00163 
00164   return retvec;
00165 
00166 }
00167 
00168 
00169 // ----------------------------------------------------------------------------
00170 int AlignableDataIO::writeRelPos(const align::Alignables& alivec, 
00171                                  bool validCheck )
00172 {
00173 
00174   int icount=0;
00175   for( align::Alignables::const_iterator it=alivec.begin();
00176        it!=alivec.end(); it++ ) {
00177     int iret=writeRelPos(*it,validCheck);
00178     if (iret==0) icount++;
00179   }
00180   LogDebug("WriteRelPos") << "all,written: " << alivec.size() <<", "<< icount;
00181   return 0;
00182 
00183 }
00184 
00185 
00186 // ----------------------------------------------------------------------------
00187 AlignableShifts 
00188 AlignableDataIO::readRelPos(const align::Alignables& alivec, int& ierr) 
00189 {
00190 
00191   AlignableShifts retvec;
00192   int ierr2=0;
00193   ierr=0;
00194   for( align::Alignables::const_iterator it=alivec.begin();
00195        it!=alivec.end(); it++ ) 
00196     {
00197       AlignableRelData ad=readRelPos(*it, ierr2);
00198       if (ierr2==0) retvec.push_back(ad);
00199     }
00200   LogDebug("ReadRelPos") << "all,read: " << alivec.size() <<", "<< retvec.size();
00201 
00202   return retvec;
00203 
00204 }

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