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
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
00050
00051 private:
00052
00053 void Init( const T& in=T());
00054 std::vector<std::vector<std::vector<T> > > tecPlusData;
00055 std::vector<std::vector<std::vector<T> > > tecMinusData;
00056 std::vector<std::vector<T> > tecPlusATData;
00057 std::vector<std::vector<T> > tecMinusATData;
00058 std::vector<std::vector<T> > tibData;
00059 std::vector<std::vector<T> > tobData;
00060
00061 ClassDef( LASGlobalData, 2 );
00062 };
00063
00064
00065
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
00094 if( !( ( theDetector == 0 || theDetector == 1 ) &&
00095 ( theRing == 0 || theRing == 1 ) &&
00096 ( theBeam >= 0 && theBeam < 8 ) &&
00097 ( theDisk >= 0 && theDisk < 9 ) ) ) {
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.";
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
00120 if( !( ( theDetector == 2 || theDetector == 3 ) &&
00121 ( theBeam >= 0 && theBeam < 8 ) &&
00122 ( thePosition >= 0 && thePosition < 6 ) ) ) {
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.";
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
00145 if( !( ( theDetector == 0 || theDetector == 1 ) &&
00146 ( theBeam >= 0 && theBeam < 8 ) &&
00147 ( theDisk >= 0 && theDisk < 6 ) ) ) {
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.";
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
00171 if( !( ( theDetector == 0 || theDetector == 1 ) &&
00172 ( theRing == 0 || theRing == 1 ) &&
00173 ( theBeam >= 0 && theBeam < 8 ) &&
00174 ( theDisk >= 0 && theDisk < 9 ) ) ) {
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.";
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
00198 if( !( ( theDetector == 2 || theDetector == 3 ) &&
00199 ( theBeam >= 0 && theBeam < 8 ) &&
00200 ( thePosition >= 0 && thePosition < 6 ) ) ) {
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.";
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
00224 if( !( ( theDetector == 0 || theDetector == 1 ) &&
00225 ( theBeam >= 0 && theBeam < 8 ) &&
00226 ( theDisk >= 0 && theDisk < 6 ) ) ) {
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.";
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
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 template <class T>
00282 void LASGlobalData<T>::Init( const T& in ) {
00283
00284
00285 tecPlusData.resize( 2 );
00286 for( unsigned int ring = 0; ring < tecPlusData.size(); ++ring ) {
00287 tecPlusData.at( ring ).resize( 8 );
00288 for( unsigned int beam = 0; beam < tecPlusData.at( ring ).size(); ++beam ) {
00289 tecPlusData.at( ring ).at( beam ).resize( 9 , in);
00290 }
00291 }
00292
00293
00294 tecMinusData.resize( 2 );
00295 for( unsigned int ring = 0; ring < tecMinusData.size(); ++ring ) {
00296 tecMinusData.at( ring ).resize( 8 );
00297 for( unsigned int beam = 0; beam < tecMinusData.at( ring ).size(); ++beam ) {
00298 tecMinusData.at( ring ).at( beam ).resize( 9, in );
00299 }
00300 }
00301
00302
00303 tecPlusATData.resize( 8 );
00304 for( unsigned int beam = 0; beam < tecPlusATData.size(); ++beam ) {
00305 tecPlusATData.at( beam ).resize( 5, in );
00306 }
00307
00308
00309 tecMinusATData.resize( 8 );
00310 for( unsigned int beam = 0; beam < tecMinusATData.size(); ++beam ) {
00311 tecMinusATData.at( beam ).resize( 5, in );
00312 }
00313
00314
00315 tibData.resize( 8 );
00316 for( unsigned int beam = 0; beam < tibData.size(); ++ beam ) {
00317 tibData.at( beam ).resize( 6, in );
00318 }
00319
00320
00321 tobData.resize( 8 );
00322 for( unsigned int beam = 0; beam < tobData.size(); ++ beam ) {
00323 tobData.at( beam ).resize( 6, in );
00324 }
00325 }
00326
00327
00328 #endif