Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:26

0001 
0002 #include "Alignment/LaserAlignment/interface/LASEndcapAlignmentParameterSet.h"
0003 
0004 ///
0005 ///
0006 ///
0007 LASEndcapAlignmentParameterSet::LASEndcapAlignmentParameterSet() { Init(); }
0008 
0009 ///
0010 /// whatever initialization is needed
0011 ///
0012 void LASEndcapAlignmentParameterSet::Init(void) {
0013   // could use a single vector<vector<vector<pair<> > > >
0014   // but better split it in 2 parts
0015 
0016   for (unsigned int disk = 0; disk < 9; ++disk) {  // nine times; once for each disk
0017     tecPlusDiskParameters.push_back(std::vector<std::pair<double, double> >(3));
0018     tecMinusDiskParameters.push_back(std::vector<std::pair<double, double> >(3));
0019 
0020     // compiler won't let me init the pairs within push_back call..
0021     for (unsigned int par = 0; par < 3; ++par) {
0022       tecPlusDiskParameters.at(disk).at(par) = std::pair<double, double>(0., 0.);
0023       tecMinusDiskParameters.at(disk).at(par) = std::pair<double, double>(0., 0.);
0024     }
0025   }
0026 
0027   // once for each parameter
0028   for (unsigned int par = 0; par < 6; ++par) {
0029     tecPlusGlobalParameters.push_back(std::pair<double, double>(0., 0.));
0030     tecMinusGlobalParameters.push_back(std::pair<double, double>(0., 0.));
0031   }
0032 
0033   // beam parameters
0034   tecPlusBeamParameters.resize(8);
0035   tecMinusBeamParameters.resize(8);
0036 
0037   // now once for each beam: the 2 rings
0038   for (unsigned int beam = 0; beam < 8; ++beam) {
0039     tecPlusBeamParameters.at(beam).resize(2);
0040     tecMinusBeamParameters.at(beam).resize(2);
0041 
0042     // now once for each ring: the 2 parameters
0043     for (unsigned int ring = 0; ring < 2; ++ring) {
0044       tecPlusBeamParameters.at(beam).at(ring).resize(2);
0045       tecMinusBeamParameters.at(beam).at(ring).resize(2);
0046 
0047       // now once for each parameter: the pairs (value/error)
0048       for (unsigned int par = 0; par < 2; ++par) {
0049         tecPlusBeamParameters.at(beam).at(ring).at(par) = std::pair<double, double>(0., 0.);
0050         tecMinusBeamParameters.at(beam).at(ring).at(par) = std::pair<double, double>(0., 0.);
0051       }
0052     }
0053   }
0054 }
0055 
0056 ///
0057 /// function for accessing a single disk parameter (pair<>);
0058 /// indices are:
0059 ///  * aSubdetector = 0 (TEC+), 1 (TEC-)
0060 ///  * aDisk = 0..8 (from inner to outer)
0061 ///  * aParameter: 0 (rotation angle), 1 (x displacement), 2 (y displacement)
0062 ///
0063 std::pair<double, double>& LASEndcapAlignmentParameterSet::GetDiskParameter(int aSubdetector,
0064                                                                             int aDisk,
0065                                                                             int aParameter) {
0066   if (aSubdetector < 0 || aSubdetector > 1) {
0067     throw cms::Exception("Laser Alignment")
0068         << " [LASEndcapAlignmentParameterSet::GetDiskParameter] ERROR ** Illegal subdetector index: " << aSubdetector
0069         << "." << std::endl;
0070   }
0071 
0072   if (aDisk < 0 || aDisk > 8) {
0073     throw cms::Exception("Laser Alignment")
0074         << " [LASEndcapAlignmentParameterSet::GetDiskParameter] ERROR ** Illegal disk index: " << aDisk << "."
0075         << std::endl;
0076   }
0077 
0078   if (aParameter < 0 || aParameter > 2) {
0079     throw cms::Exception("Laser Alignment")
0080         << " [LASEndcapAlignmentParameterSet::GetDiskParameter] ERROR ** Illegal parameter index: " << aParameter << "."
0081         << std::endl;
0082   }
0083 
0084   if (aSubdetector == 0)
0085     return tecPlusDiskParameters.at(aDisk).at(aParameter);
0086   return tecMinusDiskParameters.at(aDisk).at(aParameter);
0087 }
0088 
0089 ///
0090 /// function for accessing a single global parameter (pair<>);
0091 /// indices are:
0092 ///  * aSubdetector = 0 (TEC+), 1 (TEC-)
0093 ///  * aParameter: 0 (global rotation), 1 (global torsion),
0094 ///                2 (global x shift),  3 (global x shear),
0095 ///                4 (global y shift),  5 (global y shear)
0096 ///
0097 std::pair<double, double>& LASEndcapAlignmentParameterSet::GetGlobalParameter(int aSubdetector, int aParameter) {
0098   if (aSubdetector < 0 || aSubdetector > 1) {
0099     throw cms::Exception("Laser Alignment")
0100         << " [LASEndcapAlignmentParameterSet::GetGlobalParameter] ERROR ** Illegal subdetector index: " << aSubdetector
0101         << "." << std::endl;
0102   }
0103 
0104   if (aParameter < 0 || aParameter > 5) {
0105     throw cms::Exception("Laser Alignment")
0106         << " [LASEndcapAlignmentParameterSet::GetGlobalParameter] ERROR ** Illegal parameter index: " << aParameter
0107         << "." << std::endl;
0108   }
0109 
0110   if (aSubdetector == 0)
0111     return tecPlusGlobalParameters.at(aParameter);
0112   return tecMinusGlobalParameters.at(aParameter);
0113 }
0114 
0115 ///
0116 /// function for accessing a single beam parameter (pair<>);
0117 /// indices are:
0118 ///  * aSubdetector = 0 (TEC+), 1 (TEC-)
0119 ///  * aBeam = 0..7
0120 ///  * aParameter: 0 (deltaPhi on disk0), 1 (deltaPhi on disk8),
0121 ///
0122 std::pair<double, double>& LASEndcapAlignmentParameterSet::GetBeamParameter(int aSubdetector,
0123                                                                             int aRing,
0124                                                                             int aBeam,
0125                                                                             int aParameter) {
0126   if (aSubdetector < 0 || aSubdetector > 1) {
0127     throw cms::Exception("Laser Alignment")
0128         << " [LASEndcapAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal subdetector index: " << aSubdetector
0129         << "." << std::endl;
0130   }
0131 
0132   if (aRing < 0 || aRing > 1) {
0133     throw cms::Exception("Laser Alignment")
0134         << " [LASEndcapAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal ring index: " << aRing << "."
0135         << std::endl;
0136   }
0137 
0138   if (aBeam < 0 || aBeam > 7) {
0139     throw cms::Exception("Laser Alignment")
0140         << " [LASEndcapAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal beam index: " << aBeam << "."
0141         << std::endl;
0142   }
0143 
0144   if (aParameter < 0 || aParameter > 5) {
0145     throw cms::Exception("Laser Alignment")
0146         << " [LASEndcapAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal parameter index: " << aParameter << "."
0147         << std::endl;
0148   }
0149 
0150   if (aSubdetector == 0)
0151     return tecPlusBeamParameters.at(aBeam).at(aRing).at(aParameter);
0152   return tecMinusBeamParameters.at(aBeam).at(aRing).at(aParameter);
0153 }
0154 
0155 ///
0156 /// pretty-printout of all parameter and error values
0157 ///
0158 void LASEndcapAlignmentParameterSet::Print(void) {
0159   std::cout << " [LASEndcapAlignmentParameterSet::Print] -- Listing parameters:" << std::endl;
0160   std::cout << std::endl;
0161   std::cout << "  Disk parameters:" << std::endl;
0162   std::cout << " ----------------" << std::endl;
0163   for (int det = 0; det < 2; ++det) {
0164     std::cout
0165         << "  " << (det == 0 ? "TEC+" : "TEC-")
0166         << ":          dPHI \xb1  \bE                 dX \xb1  \bE                 dY \xb1  \bE          (rad/mm): "
0167         << std::endl;
0168     for (int disk = 0; disk < 9; ++disk) {
0169       std::cout << "  disk " << disk << ": ";
0170       for (int par = 0; par < 3; ++par)
0171         std::cout << std::right << std::setw(11) << std::fixed << std::setprecision(6)
0172                   << GetDiskParameter(det, disk, par).first << " \xb1 " << std::left << std::setw(9) << std::fixed
0173                   << std::setprecision(6) << GetDiskParameter(det, disk, par).second;
0174       std::cout << std::endl;
0175     }
0176   }
0177 
0178   for (int det = 0; det < 2; ++det) {
0179     std::cout << "  " << (det == 0 ? "TEC+" : "TEC-")
0180               << " global parameters in format: dPhi0\xb1 \be  dPhiT\xb1 \be  dX0\xb1 \be  dXT\xb1 \be  dY0\xb1 \be  "
0181                  "dYT\xb1 \be (rad/mm): "
0182               << std::endl;
0183     for (int par = 0; par < 6; ++par)
0184       std::cout << std::setw(11) << std::setprecision(6) << std::right << GetGlobalParameter(det, par).first << " \xb1 "
0185                 << std::setw(9) << std::setprecision(6) << std::left << GetGlobalParameter(det, par).second;
0186     std::cout << std::endl;
0187   }
0188 
0189   for (int det = 0; det < 2; ++det) {
0190     std::cout << "  " << (det == 0 ? "TEC+" : "TEC-")
0191               << " beam parameters in format: dPhi1\xb1 \be dPhi2\xb1 \be (rad): " << std::endl;
0192     for (int ring = 0; ring < 2; ++ring) {
0193       std::cout << "   ring " << (ring == 0 ? "4" : "6") << ": " << std::endl;
0194       for (int beam = 0; beam < 8; ++beam) {
0195         std::cout << "     beam " << beam << ": ";
0196         for (int par = 0; par < 2; ++par)
0197           std::cout << std::setw(11) << std::setprecision(6) << std::right
0198                     << GetBeamParameter(det, ring, beam, par).first << " \xb1 " << std::setw(9) << std::setprecision(6)
0199                     << std::left << GetBeamParameter(det, ring, beam, par).second;
0200         std::cout << std::endl;
0201       }
0202     }
0203   }
0204 
0205   std::cout << " [LASEndcapAlignmentParameterSet::Print] -- End of list." << std::endl << std::endl;
0206 }