CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Alignment/CommonAlignmentAlgorithm/src/AlignmentIORoot.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h"
00002 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentCorrelationsIORoot.h"
00003 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignableDataIORoot.h"
00004 
00005 // this class's header
00006 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentIORoot.h"
00007 
00008 // ----------------------------------------------------------------------------
00009 // write alignment parameters 
00010 
00011 void 
00012 AlignmentIORoot::writeAlignmentParameters(const align::Alignables& alivec, 
00013                                           const char* filename, int iter, 
00014                                           bool validCheck, int& ierr)
00015 {
00016   AlignmentParametersIORoot theIO;
00017   ierr=0;
00018   int iret;
00019   iret = theIO.open(filename,iter,true);
00020   if (iret!=0) { ierr=-1; return;}
00021   iret = theIO.write(alivec,validCheck);
00022   if (iret!=0) { ierr=-2; return;}
00023   iret = theIO.close();
00024   if (iret!=0) { ierr=-3; return;}
00025 }
00026 
00027 // ----------------------------------------------------------------------------
00028 // read alignment parameters 
00029 align::Parameters 
00030 AlignmentIORoot::readAlignmentParameters(const align::Alignables& alivec, 
00031                                          const char* filename, int iter, int& ierr)
00032 {
00033   align::Parameters result;
00034 
00035   AlignmentParametersIORoot theIO;
00036   ierr=0;
00037   int iret;
00038   iret = theIO.open(filename,iter,false);
00039   if (iret!=0) { ierr=-1; return result;}
00040   result = theIO.read(alivec,iret);
00041   if (iret!=0) { ierr=-2; return result;}
00042   iret = theIO.close();
00043   if (iret!=0) { ierr=-3; return result;}
00044 
00045   return result;
00046 }
00047 
00048 // ----------------------------------------------------------------------------
00049 // write alignment parameters 
00050 void
00051 AlignmentIORoot::writeOrigRigidBodyAlignmentParameters
00052 (const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr)
00053 {
00054   AlignmentParametersIORoot theIO;
00055   ierr = 0;
00056   int iret = theIO.open(filename, iter, true);
00057   if (iret != 0) { ierr = -1; return;}
00058   iret = theIO.writeOrigRigidBody(alivec, validCheck);
00059   if (iret != 0) { ierr = -2; return;}
00060   iret = theIO.close();
00061   if (iret != 0) { ierr = -3; return;}
00062 }
00063 
00064 
00065 // ----------------------------------------------------------------------------
00066 // write correlations
00067 
00068 void 
00069 AlignmentIORoot::writeCorrelations (const align::Correlations& cormap, 
00070                                     const char* filename, int iter, bool validCheck, int& ierr)
00071 {
00072   AlignmentCorrelationsIORoot theIO;
00073   ierr=0;
00074   int iret;
00075   iret = theIO.open(filename,iter,true);
00076   if (iret!=0) { ierr=-1; return;}
00077   iret = theIO.write(cormap,validCheck);
00078   if (iret!=0) { ierr=-2; return;}
00079   iret = theIO.close();
00080   if (iret!=0) { ierr=-3; return;}
00081 }
00082 
00083 // ----------------------------------------------------------------------------
00084 // read correlations
00085 
00086 align::Correlations 
00087 AlignmentIORoot::readCorrelations (const align::Alignables& alivec, const char* filename, 
00088                                    int iter, int& ierr)
00089 {   
00090   align::Correlations result;
00091 
00092   AlignmentCorrelationsIORoot theIO;
00093   ierr=0;
00094   int iret;
00095   iret = theIO.open(filename,iter,false);
00096   if (iret!=0) { ierr=-1; return result;}
00097   result = theIO.read(alivec,iret);
00098   if (iret!=0) { ierr=-2; return result;}
00099   iret = theIO.close();
00100   if (iret!=0) { ierr=-3; return result;}
00101 
00102   return result;
00103 }
00104 
00105 
00106 // ----------------------------------------------------------------------------
00107 // write absolute position of alignable
00108 
00109 void AlignmentIORoot::writeAlignableAbsolutePositions ( const align::Alignables& alivec, 
00110                                                         const char* filename, int iter, 
00111                                                         bool validCheck, int& ierr)
00112 {
00113   AlignableDataIORoot theIO(AlignableDataIORoot::Abs);
00114   ierr=0;
00115   int iret;
00116   iret = theIO.open(filename,iter,true);
00117   if (iret!=0) { ierr=-1; return;}
00118   iret = theIO.writeAbsPos(alivec,validCheck);
00119   if (iret!=0) { ierr=-2; return;}
00120   iret = theIO.close();
00121   if (iret!=0) { ierr=-3; return;}
00122 }
00123 
00124 // ----------------------------------------------------------------------------
00125 // read absolute position of alignable
00126 
00127 AlignablePositions 
00128 AlignmentIORoot::readAlignableAbsolutePositions (const align::Alignables& alivec, 
00129                                                  const char* filename, int iter, int& ierr)
00130 {
00131   AlignablePositions result;
00132 
00133   AlignableDataIORoot theIO(AlignableDataIORoot::Abs);
00134   ierr=0;
00135   int iret;
00136   iret = theIO.open(filename,iter,false);
00137   if (iret!=0) { ierr=-1; return result;}
00138   result = theIO.readAbsPos(alivec,iret);
00139   if (iret!=0) { ierr=-2; return result;}
00140   iret = theIO.close();
00141   if (iret!=0) { ierr=-3; return result;}
00142 
00143   return result;
00144 }
00145 
00146 // ----------------------------------------------------------------------------
00147 // write original position of alignable
00148 
00149 void AlignmentIORoot::writeAlignableOriginalPositions ( const align::Alignables& alivec, 
00150                                                         const char* filename, int iter, 
00151                                                         bool validCheck, int& ierr)
00152 {
00153   AlignableDataIORoot theIO(AlignableDataIORoot::Org);
00154   ierr=0;
00155   int iret;
00156   iret = theIO.open(filename,iter,true);
00157   if (iret!=0) { ierr=-1; return;}
00158   iret = theIO.writeOrgPos(alivec,validCheck);
00159   if (iret!=0) { ierr=-2; return;}
00160   iret = theIO.close();
00161   if (iret!=0) { ierr=-3; return;}
00162 }
00163 
00164 // ----------------------------------------------------------------------------
00165 // read original position of alignable
00166 
00167 AlignablePositions 
00168 AlignmentIORoot::readAlignableOriginalPositions (const align::Alignables& alivec, 
00169                                                  const char* filename, int iter, int& ierr)
00170 {
00171   AlignablePositions result;
00172 
00173   AlignableDataIORoot theIO(AlignableDataIORoot::Org);
00174   ierr=0;
00175   int iret;
00176   iret = theIO.open(filename,iter,false);
00177   if (iret!=0) { ierr=-1; return result;}
00178   result = theIO.readOrgPos(alivec,iret);
00179   if (iret!=0) { ierr=-2; return result;}
00180   iret = theIO.close();
00181   if (iret!=0) { ierr=-3; return result;}
00182 
00183   return result;
00184 }
00185 
00186 // ----------------------------------------------------------------------------
00187 // write relative position of alignable
00188 
00189 void AlignmentIORoot::writeAlignableRelativePositions( const align::Alignables& alivec,
00190                                                        const char* filename,
00191                                                        int iter, bool validCheck, int& ierr)
00192 {
00193   AlignableDataIORoot theIO(AlignableDataIORoot::Rel);
00194   ierr=0;
00195   int iret;
00196   iret = theIO.open(filename,iter,true);
00197   if (iret!=0) { ierr=-1; return;}
00198   iret = theIO.writeRelPos(alivec,validCheck);
00199   if (iret!=0) { ierr=-2; return;}
00200   iret = theIO.close();
00201   if (iret!=0) { ierr=-3; return;}
00202 }
00203 
00204 // ----------------------------------------------------------------------------
00205 // read relative position of alignable
00206 
00207 AlignableShifts 
00208 AlignmentIORoot::readAlignableRelativePositions (const align::Alignables& alivec, 
00209                                                  const char* filename, int iter, int& ierr)
00210 {
00211   AlignableShifts result;
00212 
00213   AlignableDataIORoot theIO(AlignableDataIORoot::Rel);
00214   ierr=0;
00215   int iret;
00216   iret = theIO.open(filename,iter,false);
00217   if (iret!=0) { ierr=-1; return result;}
00218   result = theIO.readRelPos(alivec,iret);
00219   if (iret!=0) { ierr=-2; return result;}
00220   iret = theIO.close();
00221   if (iret!=0) { ierr=-3; return result;}
00222 
00223   return result;
00224 }
00225 
00226 
00227 
00228 
00229 
00230