Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParametersIORoot.h"
0002 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentCorrelationsIORoot.h"
0003 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignableDataIORoot.h"
0004 
0005 // this class's header
0006 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentIORoot.h"
0007 
0008 // ----------------------------------------------------------------------------
0009 // write alignment parameters
0010 
0011 void AlignmentIORoot::writeAlignmentParameters(
0012     const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr) {
0013   AlignmentParametersIORoot theIO;
0014   ierr = 0;
0015   int iret;
0016   iret = theIO.open(filename, iter, true);
0017   if (iret != 0) {
0018     ierr = -1;
0019     return;
0020   }
0021   iret = theIO.write(alivec, validCheck);
0022   if (iret != 0) {
0023     ierr = -2;
0024     return;
0025   }
0026   iret = theIO.close();
0027   if (iret != 0) {
0028     ierr = -3;
0029     return;
0030   }
0031 }
0032 
0033 // ----------------------------------------------------------------------------
0034 // read alignment parameters
0035 align::Parameters AlignmentIORoot::readAlignmentParameters(const align::Alignables& alivec,
0036                                                            const char* filename,
0037                                                            int iter,
0038                                                            int& ierr) {
0039   align::Parameters result;
0040 
0041   AlignmentParametersIORoot theIO;
0042   ierr = 0;
0043   int iret;
0044   iret = theIO.open(filename, iter, false);
0045   if (iret != 0) {
0046     ierr = -1;
0047     return result;
0048   }
0049   result = theIO.read(alivec, iret);
0050   if (iret != 0) {
0051     ierr = -2;
0052     return result;
0053   }
0054   iret = theIO.close();
0055   if (iret != 0) {
0056     ierr = -3;
0057     return result;
0058   }
0059 
0060   return result;
0061 }
0062 
0063 // ----------------------------------------------------------------------------
0064 // write alignment parameters
0065 void AlignmentIORoot::writeOrigRigidBodyAlignmentParameters(
0066     const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr) {
0067   AlignmentParametersIORoot theIO;
0068   ierr = 0;
0069   int iret = theIO.open(filename, iter, true);
0070   if (iret != 0) {
0071     ierr = -1;
0072     return;
0073   }
0074   iret = theIO.writeOrigRigidBody(alivec, validCheck);
0075   if (iret != 0) {
0076     ierr = -2;
0077     return;
0078   }
0079   iret = theIO.close();
0080   if (iret != 0) {
0081     ierr = -3;
0082     return;
0083   }
0084 }
0085 
0086 // ----------------------------------------------------------------------------
0087 // write correlations
0088 
0089 void AlignmentIORoot::writeCorrelations(
0090     const align::Correlations& cormap, const char* filename, int iter, bool validCheck, int& ierr) {
0091   AlignmentCorrelationsIORoot theIO;
0092   ierr = 0;
0093   int iret;
0094   iret = theIO.open(filename, iter, true);
0095   if (iret != 0) {
0096     ierr = -1;
0097     return;
0098   }
0099   iret = theIO.write(cormap, validCheck);
0100   if (iret != 0) {
0101     ierr = -2;
0102     return;
0103   }
0104   iret = theIO.close();
0105   if (iret != 0) {
0106     ierr = -3;
0107     return;
0108   }
0109 }
0110 
0111 // ----------------------------------------------------------------------------
0112 // read correlations
0113 
0114 align::Correlations AlignmentIORoot::readCorrelations(const align::Alignables& alivec,
0115                                                       const char* filename,
0116                                                       int iter,
0117                                                       int& ierr) {
0118   align::Correlations result;
0119 
0120   AlignmentCorrelationsIORoot theIO;
0121   ierr = 0;
0122   int iret;
0123   iret = theIO.open(filename, iter, false);
0124   if (iret != 0) {
0125     ierr = -1;
0126     return result;
0127   }
0128   result = theIO.read(alivec, iret);
0129   if (iret != 0) {
0130     ierr = -2;
0131     return result;
0132   }
0133   iret = theIO.close();
0134   if (iret != 0) {
0135     ierr = -3;
0136     return result;
0137   }
0138 
0139   return result;
0140 }
0141 
0142 // ----------------------------------------------------------------------------
0143 // write absolute position of alignable
0144 
0145 void AlignmentIORoot::writeAlignableAbsolutePositions(
0146     const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr) {
0147   AlignableDataIORoot theIO(AlignableDataIORoot::Abs);
0148   ierr = 0;
0149   int iret;
0150   iret = theIO.open(filename, iter, true);
0151   if (iret != 0) {
0152     ierr = -1;
0153     return;
0154   }
0155   iret = theIO.writeAbsPos(alivec, validCheck);
0156   if (iret != 0) {
0157     ierr = -2;
0158     return;
0159   }
0160   iret = theIO.close();
0161   if (iret != 0) {
0162     ierr = -3;
0163     return;
0164   }
0165 }
0166 
0167 // ----------------------------------------------------------------------------
0168 // read absolute position of alignable
0169 
0170 AlignablePositions AlignmentIORoot::readAlignableAbsolutePositions(const align::Alignables& alivec,
0171                                                                    const char* filename,
0172                                                                    int iter,
0173                                                                    int& ierr) {
0174   AlignablePositions result;
0175 
0176   AlignableDataIORoot theIO(AlignableDataIORoot::Abs);
0177   ierr = 0;
0178   int iret;
0179   iret = theIO.open(filename, iter, false);
0180   if (iret != 0) {
0181     ierr = -1;
0182     return result;
0183   }
0184   result = theIO.readAbsPos(alivec, iret);
0185   if (iret != 0) {
0186     ierr = -2;
0187     return result;
0188   }
0189   iret = theIO.close();
0190   if (iret != 0) {
0191     ierr = -3;
0192     return result;
0193   }
0194 
0195   return result;
0196 }
0197 
0198 // ----------------------------------------------------------------------------
0199 // write original position of alignable
0200 
0201 void AlignmentIORoot::writeAlignableOriginalPositions(
0202     const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr) {
0203   AlignableDataIORoot theIO(AlignableDataIORoot::Org);
0204   ierr = 0;
0205   int iret;
0206   iret = theIO.open(filename, iter, true);
0207   if (iret != 0) {
0208     ierr = -1;
0209     return;
0210   }
0211   iret = theIO.writeOrgPos(alivec, validCheck);
0212   if (iret != 0) {
0213     ierr = -2;
0214     return;
0215   }
0216   iret = theIO.close();
0217   if (iret != 0) {
0218     ierr = -3;
0219     return;
0220   }
0221 }
0222 
0223 // ----------------------------------------------------------------------------
0224 // read original position of alignable
0225 
0226 AlignablePositions AlignmentIORoot::readAlignableOriginalPositions(const align::Alignables& alivec,
0227                                                                    const char* filename,
0228                                                                    int iter,
0229                                                                    int& ierr) {
0230   AlignablePositions result;
0231 
0232   AlignableDataIORoot theIO(AlignableDataIORoot::Org);
0233   ierr = 0;
0234   int iret;
0235   iret = theIO.open(filename, iter, false);
0236   if (iret != 0) {
0237     ierr = -1;
0238     return result;
0239   }
0240   result = theIO.readOrgPos(alivec, iret);
0241   if (iret != 0) {
0242     ierr = -2;
0243     return result;
0244   }
0245   iret = theIO.close();
0246   if (iret != 0) {
0247     ierr = -3;
0248     return result;
0249   }
0250 
0251   return result;
0252 }
0253 
0254 // ----------------------------------------------------------------------------
0255 // write relative position of alignable
0256 
0257 void AlignmentIORoot::writeAlignableRelativePositions(
0258     const align::Alignables& alivec, const char* filename, int iter, bool validCheck, int& ierr) {
0259   AlignableDataIORoot theIO(AlignableDataIORoot::Rel);
0260   ierr = 0;
0261   int iret;
0262   iret = theIO.open(filename, iter, true);
0263   if (iret != 0) {
0264     ierr = -1;
0265     return;
0266   }
0267   iret = theIO.writeRelPos(alivec, validCheck);
0268   if (iret != 0) {
0269     ierr = -2;
0270     return;
0271   }
0272   iret = theIO.close();
0273   if (iret != 0) {
0274     ierr = -3;
0275     return;
0276   }
0277 }
0278 
0279 // ----------------------------------------------------------------------------
0280 // read relative position of alignable
0281 
0282 AlignableShifts AlignmentIORoot::readAlignableRelativePositions(const align::Alignables& alivec,
0283                                                                 const char* filename,
0284                                                                 int iter,
0285                                                                 int& ierr) {
0286   AlignableShifts result;
0287 
0288   AlignableDataIORoot theIO(AlignableDataIORoot::Rel);
0289   ierr = 0;
0290   int iret;
0291   iret = theIO.open(filename, iter, false);
0292   if (iret != 0) {
0293     ierr = -1;
0294     return result;
0295   }
0296   result = theIO.readRelPos(alivec, iret);
0297   if (iret != 0) {
0298     ierr = -2;
0299     return result;
0300   }
0301   iret = theIO.close();
0302   if (iret != 0) {
0303     ierr = -3;
0304     return result;
0305   }
0306 
0307   return result;
0308 }