CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Alignment/LaserAlignment/interface/LASGlobalData.h

Go to the documentation of this file.
00001 
00002 #ifndef __LASGLOBALDATA_H
00003 #define __LASGLOBALDATA_H
00004 
00005 #include<vector>
00006 #include<iostream>
00007 #include "TNamed.h"
00008 
00029 
00030 template <class T> 
00031 class LASGlobalData : public TNamed
00032 {
00033 
00034  public:
00035   // enums not in use so far...
00036   enum Subdetector { TECPLUS, TECMINUS, TIB, TOB };
00037   enum TecRing { RING4, RING6 };
00038   enum Beam { BEAM0, BEAM1, BEAM2, BEAM3, BEAM4, BEAM5, BEAM6, BEAM7 };
00039   enum TecDisk { DISK1, DISK2, DISK3, DISK4, DISK5, DISK6, DISK7, DISK8, DISK9 };
00040   enum TibTobPosition { MINUS3, MINUS2, MINUS1, PLUS1, PLUS2, PLUS3 };
00041   LASGlobalData();
00042   LASGlobalData(const T&);
00043   T& GetTECEntry( int subdetector, int tecRing, int beam, int tecDisk );
00044   T& GetTIBTOBEntry( int subdetector, int beam, int tibTobPosition );
00045   T& GetTEC2TECEntry( int subdetector, int beam, int tecDisk );
00046   void SetTECEntry( int subdetector, int tecRing, int beam, int tecDisk, T );
00047   void SetTIBTOBEntry( int subdetector, int beam, int tibTobPosition, T );
00048   void SetTEC2TECEntry( int subdetector, int beam, int tecDisk, T );
00049   //  LASGlobalData<T>& operator=( LASGlobalData<T>& );
00050 
00051  private:
00052   //void Init( void );
00053   void Init( const T& in=T());
00054   std::vector<std::vector<std::vector<T> > > tecPlusData; // ring<beam<disk<T>>>
00055   std::vector<std::vector<std::vector<T> > > tecMinusData; // ring<beam<disk<T>>>
00056   std::vector<std::vector<T> > tecPlusATData; // beam<disk<T>>
00057   std::vector<std::vector<T> > tecMinusATData; // beam<disk<T>>
00058   std::vector<std::vector<T> > tibData; // beam<pos<T>>
00059   std::vector<std::vector<T> > tobData; // beam<pos<T>>
00060 
00061   ClassDef( LASGlobalData, 2 );
00062 };
00063 
00064 // since this is a template
00065 //#include "Alignment/LaserAlignment/src/LASGlobalData.cc"
00066 
00067 
00068 template <class T>
00069 LASGlobalData<T>::LASGlobalData() {
00073 
00074   Init();
00075 
00076 }
00077 
00078 template <class T>
00079 LASGlobalData<T>::LASGlobalData(const T& in)
00080 {
00081   Init(in);
00082 }
00083 
00084 
00085 
00090 template <class T>
00091 T& LASGlobalData<T>::GetTECEntry( int theDetector, int theRing, int theBeam, int theDisk ) {
00092   
00093   // do a range check first
00094   if( !( ( theDetector == 0 || theDetector == 1 ) &&        // TEC+ or TEC-
00095          ( theRing == 0 || theRing == 1 )         &&        // ring4 or ring6
00096          ( theBeam >= 0 && theBeam < 8 )          &&        // eight beams in a TEC
00097          ( theDisk >= 0 && theDisk < 9 )             ) ) {  // disk1..disk9
00098     std::cerr << " [LASGlobalData::GetTECEntry] ** ERROR: illegal input coordinates:" << std::endl;
00099     std::cerr << "   detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
00100     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00101   }
00102   else {
00103     if( theDetector == 0 ) return( tecPlusData.at( theRing ).at( theBeam ).at( theDisk ) );
00104     else return( tecMinusData.at( theRing ).at( theBeam ).at( theDisk ) );
00105   }
00106 
00107 }
00108 
00109 
00110 
00111 
00116 template <class T>
00117 T& LASGlobalData<T>::GetTIBTOBEntry( int theDetector, int theBeam, int thePosition ) {
00118 
00119   // do a range check first
00120   if( !( ( theDetector == 2 || theDetector == 3 ) &&        // TIB or TOB
00121          ( theBeam >= 0 && theBeam < 8 )          &&        // there are eight AT beams
00122          ( thePosition >= 0 && thePosition < 6 )     ) ) {  // z-pos -3 .. z-pos +3
00123     std::cerr << " [LASGlobalData::GetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
00124     std::cerr << "   detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "." << std::endl;
00125     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00126   }
00127   else {
00128     if( theDetector == 2 ) return( tibData.at( theBeam ).at( thePosition ) );
00129     else return( tobData.at( theBeam ).at( thePosition ) );
00130   }
00131 
00132 }
00133 
00134 
00135 
00136 
00141 template <class T>
00142 T& LASGlobalData<T>::GetTEC2TECEntry( int theDetector, int theBeam, int theDisk ) {
00143 
00144   // do a range check first
00145   if( !( ( theDetector == 0 || theDetector == 1 ) &&        // TEC+ or TEC-
00146          ( theBeam >= 0 && theBeam < 8 )          &&        // eight AT beams in a TEC
00147          ( theDisk >= 0 && theDisk < 6 )     ) ) {          // disk1...disk5 are hit by AT
00148     std::cerr << " [LASGlobalData::GetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
00149     std::cerr << "   detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
00150     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00151   }
00152   else {
00153     if( theDetector == 0 ) return( tecPlusATData.at( theBeam ).at( theDisk ) );
00154     else return( tecMinusATData.at( theBeam ).at( theDisk ) );
00155   }
00156 
00157 }
00158 
00159 
00160 
00161 
00162 
00167 template <class T>
00168 void LASGlobalData<T>::SetTECEntry( int theDetector, int theRing, int theBeam, int theDisk, T theEntry ) {
00169   
00170   // do a range check first
00171   if( !( ( theDetector == 0 || theDetector == 1 ) &&        // TEC+ or TEC-
00172          ( theRing == 0 || theRing == 1 )         &&        // ring4 or ring6
00173          ( theBeam >= 0 && theBeam < 8 )          &&        // eight beams in a TEC
00174          ( theDisk >= 0 && theDisk < 9 )             ) ) {  // disk1..disk9
00175     std::cerr << " [LASGlobalData::SetTECEntry] ** ERROR: illegal coordinates:" << std::endl;
00176     std::cerr << "   detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
00177     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00178   }
00179   else {
00180     if( theDetector == 0 ) tecPlusData.at( theRing ).at( theBeam ).at( theDisk ) = theEntry;
00181     else tecMinusData.at( theRing ).at( theBeam ).at( theDisk ) = theEntry;
00182   }
00183 
00184 }
00185 
00186 
00187 
00188 
00189 
00194 template <class T>
00195 void LASGlobalData<T>::SetTIBTOBEntry( int theDetector, int theBeam, int thePosition, T theEntry ) {
00196 
00197   // do a range check first
00198   if( !( ( theDetector == 2 || theDetector == 3 ) &&        // TIB or TOB
00199          ( theBeam >= 0 && theBeam < 8 )          &&        // there are eight AT beams
00200          ( thePosition >= 0 && thePosition < 6 )     ) ) {  // pos-3..pos+3
00201     std::cerr << " [LASGlobalData::SetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
00202     std::cerr << "   detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "." << std::endl;
00203     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00204   }
00205   else {
00206     if( theDetector == 2 ) tibData.at( theBeam ).at( thePosition ) = theEntry;
00207     else tobData.at( theBeam ).at( thePosition ) = theEntry;
00208   }
00209 
00210 }
00211 
00212 
00213 
00214 
00215 
00220 template <class T>
00221 void LASGlobalData<T>::SetTEC2TECEntry( int theDetector, int theBeam, int theDisk, T theEntry ) {
00222 
00223   // do a range check first
00224   if( !( ( theDetector == 0 || theDetector == 1 ) &&        // TEC+ or TEC-
00225          ( theBeam >= 0 && theBeam < 8 )          &&        // eight beams in a TEC
00226          ( theDisk >= 0 && theDisk < 6 )             ) ) {  // disk1..disk5 for TEC AT
00227     std::cerr << " [LASGlobalData::SetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
00228     std::cerr << "   detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
00229     throw   "   Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
00230   }
00231   else {
00232     if( theDetector == 0 ) tecPlusATData.at( theBeam ).at( theDisk ) = theEntry;
00233     else tecMinusATData.at( theBeam ).at( theDisk ) = theEntry;
00234   }
00235 
00236 }
00237 
00238 
00239 
00240 
00241 
00242 // ///
00243 // /// element wise assignment operator
00244 // ///
00245 // template <class T>
00246 // LASGlobalData<T>& LASGlobalData<T>::operator=( LASGlobalData<T>& anotherGlobalData ) {
00247 
00248 //   // TEC copy
00249 //   for( int det = 0; det < 2; ++det ) {
00250 //     for( int ring = 0; ring < 2; ++ring ) {
00251 //       for( int beam = 0; beam < 8; ++ beam ) {
00252 //      for( int disk = 0; disk < 9; ++ disk ) {
00253 //        this->SetTECEntry( det, ring, beam, disk, anotherGlobalData.GetTECEntry( det, ring, beam, disk ) );
00254 //      }
00255 //       }
00256 //     }
00257 //   }
00258 
00259 //   // TIBTOB copy
00260 //   for( int det = 2; det < 4; ++det ) {
00261 //     for( int beam = 0; beam < 8; ++ beam ) {
00262 //       for( int pos = 0; pos < 6; ++ pos ) {
00263 //      this->SetTIBTOBEntry( det, beam, pos, anotherGlobalData.GetTIBTOBEntry( det, beam, pos ) );
00264 //       }
00265 //     }
00266 //   }
00267   
00268 //   // TEC2TEC copy
00269 //   for( int det = 2; det < 4; ++det ) {
00270 //     for( int beam = 0; beam < 8; ++ beam ) {
00271 //       for( int disk = 0; disk < 9; ++ disk ) {
00272 //      this->SetTEC2TECEntry( det, beam, disk, anotherGlobalData.GetTEC2TECEntry( det, beam, disk ) );
00273 //       }
00274 //     }
00275 //   }
00276 
00277 // }
00278 
00279 
00280 
00281 template <class T>
00282 void LASGlobalData<T>::Init( const T& in ) {
00283 
00284   // create TEC+ subdetector "multi"-vector of T
00285   tecPlusData.resize( 2 ); // create ring4 and ring6
00286   for( unsigned int ring = 0; ring < tecPlusData.size(); ++ring ) {
00287     tecPlusData.at( ring ).resize( 8 ); // create 8 beams for each ring
00288     for( unsigned int beam = 0; beam < tecPlusData.at( ring ).size(); ++beam ) {
00289       tecPlusData.at( ring ).at( beam ).resize( 9 , in); // create 9 disks for each beam
00290     }
00291   }
00292 
00293   // same for TEC-
00294   tecMinusData.resize( 2 ); // create ring4 and ring6
00295   for( unsigned int ring = 0; ring < tecMinusData.size(); ++ring ) {
00296     tecMinusData.at( ring ).resize( 8 ); // create 8 beams for each ring
00297     for( unsigned int beam = 0; beam < tecMinusData.at( ring ).size(); ++beam ) {
00298       tecMinusData.at( ring ).at( beam ).resize( 9, in ); // create 9 disks for each beam
00299     }
00300   }
00301   
00302   // same for TEC+ AT
00303   tecPlusATData.resize( 8 ); // create 8 beams
00304   for( unsigned int beam = 0; beam < tecPlusATData.size(); ++beam ) {
00305     tecPlusATData.at( beam ).resize( 5, in ); // five TEC disks hit by each AT beam
00306   }
00307 
00308   // same for TEC- AT
00309   tecMinusATData.resize( 8 ); // create 8 beams
00310   for( unsigned int beam = 0; beam < tecMinusATData.size(); ++beam ) {
00311     tecMinusATData.at( beam ).resize( 5, in ); // five TEC disks hit by each AT beam
00312   }
00313 
00314   // same for TIB..
00315   tibData.resize( 8 ); // create 8 beams
00316   for( unsigned int beam = 0; beam < tibData.size(); ++ beam ) {
00317     tibData.at( beam ).resize( 6, in ); // six TIB modules hit by each beam
00318   }
00319 
00320   // ..and for TOB
00321   tobData.resize( 8 ); // create 8 beams
00322   for( unsigned int beam = 0; beam < tobData.size(); ++ beam ) {
00323     tobData.at( beam ).resize( 6, in ); // six TOB modules hit by each beam
00324   }
00325 }
00326 
00327 
00328 #endif