File indexing completed on 2024-04-06 11:56:24
0001
0002 #ifndef __LASGLOBALDATA_H
0003 #define __LASGLOBALDATA_H
0004
0005 #include <vector>
0006 #include <iostream>
0007 #include "TNamed.h"
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template <class T>
0031 class LASGlobalData : public TNamed {
0032 public:
0033
0034 enum Subdetector { TECPLUS, TECMINUS, TIB, TOB };
0035 enum TecRing { RING4, RING6 };
0036 enum Beam { BEAM0, BEAM1, BEAM2, BEAM3, BEAM4, BEAM5, BEAM6, BEAM7 };
0037 enum TecDisk { DISK1, DISK2, DISK3, DISK4, DISK5, DISK6, DISK7, DISK8, DISK9 };
0038 enum TibTobPosition { MINUS3, MINUS2, MINUS1, PLUS1, PLUS2, PLUS3 };
0039 LASGlobalData();
0040 LASGlobalData(const T&);
0041 T& GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk);
0042 T& GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition);
0043 T& GetTEC2TECEntry(int subdetector, int beam, int tecDisk);
0044 void SetTECEntry(int subdetector, int tecRing, int beam, int tecDisk, T);
0045 void SetTIBTOBEntry(int subdetector, int beam, int tibTobPosition, T);
0046 void SetTEC2TECEntry(int subdetector, int beam, int tecDisk, T);
0047
0048
0049 private:
0050
0051 void Init(const T& in = T());
0052 std::vector<std::vector<std::vector<T> > > tecPlusData;
0053 std::vector<std::vector<std::vector<T> > > tecMinusData;
0054 std::vector<std::vector<T> > tecPlusATData;
0055 std::vector<std::vector<T> > tecMinusATData;
0056 std::vector<std::vector<T> > tibData;
0057 std::vector<std::vector<T> > tobData;
0058
0059 ClassDef(LASGlobalData, 2);
0060 };
0061
0062
0063
0064
0065 template <class T>
0066 LASGlobalData<T>::LASGlobalData() {
0067
0068
0069
0070
0071 Init();
0072 }
0073
0074 template <class T>
0075 LASGlobalData<T>::LASGlobalData(const T& in) {
0076 Init(in);
0077 }
0078
0079
0080
0081
0082
0083 template <class T>
0084 T& LASGlobalData<T>::GetTECEntry(int theDetector, int theRing, int theBeam, int theDisk) {
0085
0086 if (!((theDetector == 0 || theDetector == 1) &&
0087 (theRing == 0 || theRing == 1) &&
0088 (theBeam >= 0 && theBeam < 8) &&
0089 (theDisk >= 0 && theDisk < 9))) {
0090 std::cerr << " [LASGlobalData::GetTECEntry] ** ERROR: illegal input coordinates:" << std::endl;
0091 std::cerr << " detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk
0092 << "." << std::endl;
0093 throw " Bailing out.";
0094 } else {
0095 if (theDetector == 0)
0096 return (tecPlusData.at(theRing).at(theBeam).at(theDisk));
0097 else
0098 return (tecMinusData.at(theRing).at(theBeam).at(theDisk));
0099 }
0100 }
0101
0102
0103
0104
0105
0106 template <class T>
0107 T& LASGlobalData<T>::GetTIBTOBEntry(int theDetector, int theBeam, int thePosition) {
0108
0109 if (!((theDetector == 2 || theDetector == 3) &&
0110 (theBeam >= 0 && theBeam < 8) &&
0111 (thePosition >= 0 && thePosition < 6))) {
0112 std::cerr << " [LASGlobalData::GetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
0113 std::cerr << " detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "."
0114 << std::endl;
0115 throw " Bailing out.";
0116 } else {
0117 if (theDetector == 2)
0118 return (tibData.at(theBeam).at(thePosition));
0119 else
0120 return (tobData.at(theBeam).at(thePosition));
0121 }
0122 }
0123
0124
0125
0126
0127
0128 template <class T>
0129 T& LASGlobalData<T>::GetTEC2TECEntry(int theDetector, int theBeam, int theDisk) {
0130
0131 if (!((theDetector == 0 || theDetector == 1) &&
0132 (theBeam >= 0 && theBeam < 8) &&
0133 (theDisk >= 0 && theDisk < 6))) {
0134 std::cerr << " [LASGlobalData::GetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
0135 std::cerr << " detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
0136 throw " Bailing out.";
0137 } else {
0138 if (theDetector == 0)
0139 return (tecPlusATData.at(theBeam).at(theDisk));
0140 else
0141 return (tecMinusATData.at(theBeam).at(theDisk));
0142 }
0143 }
0144
0145
0146
0147
0148
0149 template <class T>
0150 void LASGlobalData<T>::SetTECEntry(int theDetector, int theRing, int theBeam, int theDisk, T theEntry) {
0151
0152 if (!((theDetector == 0 || theDetector == 1) &&
0153 (theRing == 0 || theRing == 1) &&
0154 (theBeam >= 0 && theBeam < 8) &&
0155 (theDisk >= 0 && theDisk < 9))) {
0156 std::cerr << " [LASGlobalData::SetTECEntry] ** ERROR: illegal coordinates:" << std::endl;
0157 std::cerr << " detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk
0158 << "." << std::endl;
0159 throw " Bailing out.";
0160 } else {
0161 if (theDetector == 0)
0162 tecPlusData.at(theRing).at(theBeam).at(theDisk) = theEntry;
0163 else
0164 tecMinusData.at(theRing).at(theBeam).at(theDisk) = theEntry;
0165 }
0166 }
0167
0168
0169
0170
0171
0172 template <class T>
0173 void LASGlobalData<T>::SetTIBTOBEntry(int theDetector, int theBeam, int thePosition, T theEntry) {
0174
0175 if (!((theDetector == 2 || theDetector == 3) &&
0176 (theBeam >= 0 && theBeam < 8) &&
0177 (thePosition >= 0 && thePosition < 6))) {
0178 std::cerr << " [LASGlobalData::SetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
0179 std::cerr << " detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "."
0180 << std::endl;
0181 throw " Bailing out.";
0182 } else {
0183 if (theDetector == 2)
0184 tibData.at(theBeam).at(thePosition) = theEntry;
0185 else
0186 tobData.at(theBeam).at(thePosition) = theEntry;
0187 }
0188 }
0189
0190
0191
0192
0193
0194 template <class T>
0195 void LASGlobalData<T>::SetTEC2TECEntry(int theDetector, int theBeam, int theDisk, T theEntry) {
0196
0197 if (!((theDetector == 0 || theDetector == 1) &&
0198 (theBeam >= 0 && theBeam < 8) &&
0199 (theDisk >= 0 && theDisk < 6))) {
0200 std::cerr << " [LASGlobalData::SetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
0201 std::cerr << " detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
0202 throw " Bailing out.";
0203 } else {
0204 if (theDetector == 0)
0205 tecPlusATData.at(theBeam).at(theDisk) = theEntry;
0206 else
0207 tecMinusATData.at(theBeam).at(theDisk) = theEntry;
0208 }
0209 }
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248 template <class T>
0249 void LASGlobalData<T>::Init(const T& in) {
0250
0251 tecPlusData.resize(2);
0252 for (unsigned int ring = 0; ring < tecPlusData.size(); ++ring) {
0253 tecPlusData.at(ring).resize(8);
0254 for (unsigned int beam = 0; beam < tecPlusData.at(ring).size(); ++beam) {
0255 tecPlusData.at(ring).at(beam).resize(9, in);
0256 }
0257 }
0258
0259
0260 tecMinusData.resize(2);
0261 for (unsigned int ring = 0; ring < tecMinusData.size(); ++ring) {
0262 tecMinusData.at(ring).resize(8);
0263 for (unsigned int beam = 0; beam < tecMinusData.at(ring).size(); ++beam) {
0264 tecMinusData.at(ring).at(beam).resize(9, in);
0265 }
0266 }
0267
0268
0269 tecPlusATData.resize(8);
0270 for (unsigned int beam = 0; beam < tecPlusATData.size(); ++beam) {
0271 tecPlusATData.at(beam).resize(5, in);
0272 }
0273
0274
0275 tecMinusATData.resize(8);
0276 for (unsigned int beam = 0; beam < tecMinusATData.size(); ++beam) {
0277 tecMinusATData.at(beam).resize(5, in);
0278 }
0279
0280
0281 tibData.resize(8);
0282 for (unsigned int beam = 0; beam < tibData.size(); ++beam) {
0283 tibData.at(beam).resize(6, in);
0284 }
0285
0286
0287 tobData.resize(8);
0288 for (unsigned int beam = 0; beam < tobData.size(); ++beam) {
0289 tobData.at(beam).resize(6, in);
0290 }
0291 }
0292
0293 #endif