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/LASBarrelAlignmentParameterSet.h"
0003 
0004 ///
0005 ///
0006 ///
0007 LASBarrelAlignmentParameterSet::LASBarrelAlignmentParameterSet() { Init(); }
0008 
0009 ///
0010 /// whatever initialization is needed
0011 ///
0012 void LASBarrelAlignmentParameterSet::Init(void) {
0013   // could use a single vector<vector<vector<pair<> > > >
0014   // but better split it in 6 parts
0015   for (int i = 0; i < 2; ++i) {  // twice; once for each endface
0016     tecPlusParameters.push_back(std::vector<std::pair<double, double> >(3));
0017     tecMinusParameters.push_back(std::vector<std::pair<double, double> >(3));
0018     tibPlusParameters.push_back(std::vector<std::pair<double, double> >(3));
0019     tibMinusParameters.push_back(std::vector<std::pair<double, double> >(3));
0020     tobPlusParameters.push_back(std::vector<std::pair<double, double> >(3));
0021     tobMinusParameters.push_back(std::vector<std::pair<double, double> >(3));
0022   }
0023 
0024   // the beam parameters (8 beams * 2 pars) are stored in one single container
0025   for (int i = 0; i < 8; ++i) {
0026     beamParameters.push_back(std::vector<std::pair<double, double> >(2));
0027   }
0028 }
0029 
0030 ///
0031 /// function for accessing a single parameter (pair<>);
0032 /// indices are:
0033 ///  * aSubdetector = 0 (TEC+), 1 (TEC-), 2 (TIB+), 3 (TIB-), 4 (TOB+), 5 (TOB-)
0034 ///  * aDisk = 0 (lower z), 1 (upper z)
0035 ///  * aParameter: 0 (rotation angle), 1 (x displacement), 2 (y displacement)
0036 ///
0037 std::pair<double, double>& LASBarrelAlignmentParameterSet::GetParameter(int aSubdetector, int aDisk, int aParameter) {
0038   if (aSubdetector < 0 || aSubdetector > 5) {
0039     throw cms::Exception("Laser Alignment")
0040         << " [LASBarrelAlignmentParameterSet::GetParameter] ERROR ** Illegal subdetector index: " << aSubdetector << "."
0041         << std::endl;
0042   }
0043 
0044   if (aDisk < 0 || aDisk > 1) {
0045     throw cms::Exception("Laser Alignment")
0046         << " [LASBarrelAlignmentParameterSet::GetParameter] ERROR ** Illegal endface index: " << aDisk << "."
0047         << std::endl;
0048   }
0049 
0050   if (aParameter < 0 || aParameter > 2) {
0051     throw cms::Exception("Laser Alignment")
0052         << " [LASBarrelAlignmentParameterSet::GetParameter] ERROR ** Illegal parameter index: " << aParameter << "."
0053         << std::endl;
0054   }
0055 
0056   // would use a switch here, but this creates problems..
0057   if (aSubdetector == 0)
0058     return tecPlusParameters.at(aDisk).at(aParameter);
0059   else if (aSubdetector == 1)
0060     return tecMinusParameters.at(aDisk).at(aParameter);
0061   else if (aSubdetector == 2)
0062     return tibPlusParameters.at(aDisk).at(aParameter);
0063   else if (aSubdetector == 3)
0064     return tibMinusParameters.at(aDisk).at(aParameter);
0065   else if (aSubdetector == 4)
0066     return tobPlusParameters.at(aDisk).at(aParameter);
0067   else
0068     return tobMinusParameters.at(aDisk).at(aParameter);
0069 }
0070 
0071 ///
0072 /// return a single beam parameter (pair<> for value, error).
0073 /// we have eight beams with two parameters each (phi1, phi2)
0074 ///
0075 std::pair<double, double>& LASBarrelAlignmentParameterSet::GetBeamParameter(int aBeam, int aParameter) {
0076   if (aBeam < 0 || aBeam > 7) {
0077     throw cms::Exception("Laser Alignment")
0078         << " [LASBarrelAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal beam index: " << aBeam << "."
0079         << std::endl;
0080   }
0081 
0082   if (aParameter < 0 || aParameter > 1) {
0083     throw cms::Exception("Laser Alignment")
0084         << " [LASBarrelAlignmentParameterSet::GetBeamParameter] ERROR ** Illegal beam parameter index: " << aParameter
0085         << "." << std::endl;
0086   }
0087 
0088   return beamParameters.at(aBeam).at(aParameter);
0089 }
0090 
0091 ///
0092 /// pretty-print all parameter and error values
0093 ///
0094 void LASBarrelAlignmentParameterSet::Print(void) {
0095   std::cout << std::endl << " [LASBarrelAlignmentParameterSet::Print] -- Parameter list [rad/mm]: " << std::endl;
0096 
0097   const std::string subdetNames[6] = {" TEC+  ", " TEC-  ", " TIB+  ", " TIB-  ", " TOB+  ", " TOB-  "};
0098 
0099   std::cout << " Detector parameters: " << std::endl;
0100   std::cout << " --------------------" << std::endl;
0101   std::cout << " Values:     PHI1         X1          Y1         PHI2         X2          Y2   " << std::endl;
0102   for (int subdet = 0; subdet < 6; ++subdet) {
0103     std::cout << subdetNames[subdet];
0104     for (int par = 0; par < 3; ++par)
0105       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0106                 << GetParameter(subdet, 0, par).first;
0107     for (int par = 0; par < 3; ++par)
0108       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0109                 << GetParameter(subdet, 1, par).first;
0110     std::cout << std::endl;
0111   }
0112 
0113   std::cout << " Errors:     PHI1         X1          Y1         PHI2         X2          Y2   " << std::endl;
0114   for (int subdet = 0; subdet < 6; ++subdet) {
0115     std::cout << subdetNames[subdet];
0116     for (int par = 0; par < 3; ++par)
0117       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0118                 << GetParameter(subdet, 0, par).second;
0119     for (int par = 0; par < 3; ++par)
0120       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0121                 << GetParameter(subdet, 1, par).second;
0122     std::cout << std::endl;
0123   }
0124 
0125   std::cout << std::endl;
0126   std::cout << " Beam parameters: " << std::endl;
0127   std::cout << " ----------------" << std::endl;
0128   std::cout << " Values:     PHI1        PHI2" << std::endl;
0129   for (int beam = 0; beam < 8; ++beam) {
0130     std::cout << " beam " << beam;
0131     for (int par = 0; par < 2; ++par)
0132       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0133                 << GetBeamParameter(beam, par).first;
0134     std::cout << std::endl;
0135   }
0136 
0137   std::cout << " Errors:     PHI1        PHI2" << std::endl;
0138   for (int beam = 0; beam < 8; ++beam) {
0139     std::cout << " beam " << beam;
0140     for (int par = 0; par < 2; ++par)
0141       std::cout << std::right << std::setw(12) << std::setprecision(6) << std::fixed
0142                 << GetBeamParameter(beam, par).second;
0143     std::cout << std::endl;
0144   }
0145 
0146   std::cout << " [LASBarrelAlignmentParameterSet::Print] -- End parameter list." << std::endl;
0147 }