CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LASGlobalData.h
Go to the documentation of this file.
1 
2 #ifndef __LASGLOBALDATA_H
3 #define __LASGLOBALDATA_H
4 
5 #include<vector>
6 #include<iostream>
7 #include "TNamed.h"
8 
29 
30 template <class T>
31 class LASGlobalData : public TNamed
32 {
33 
34  public:
35  // enums not in use so far...
37  enum TecRing { RING4, RING6 };
41  LASGlobalData();
42  LASGlobalData(const T&);
43  T& GetTECEntry( int subdetector, int tecRing, int beam, int tecDisk );
44  T& GetTIBTOBEntry( int subdetector, int beam, int tibTobPosition );
45  T& GetTEC2TECEntry( int subdetector, int beam, int tecDisk );
46  void SetTECEntry( int subdetector, int tecRing, int beam, int tecDisk, T );
47  void SetTIBTOBEntry( int subdetector, int beam, int tibTobPosition, T );
48  void SetTEC2TECEntry( int subdetector, int beam, int tecDisk, T );
49  // LASGlobalData<T>& operator=( LASGlobalData<T>& );
50 
51  private:
52  //void Init( void );
53  void Init( const T& in=T());
54  std::vector<std::vector<std::vector<T> > > tecPlusData; // ring<beam<disk<T>>>
55  std::vector<std::vector<std::vector<T> > > tecMinusData; // ring<beam<disk<T>>>
56  std::vector<std::vector<T> > tecPlusATData; // beam<disk<T>>
57  std::vector<std::vector<T> > tecMinusATData; // beam<disk<T>>
58  std::vector<std::vector<T> > tibData; // beam<pos<T>>
59  std::vector<std::vector<T> > tobData; // beam<pos<T>>
60 
61  ClassDef( LASGlobalData, 2 );
62 };
63 
64 // since this is a template
65 //#include "Alignment/LaserAlignment/src/LASGlobalData.cc"
66 
67 
68 template <class T>
73 
74  Init();
75 
76 }
77 
78 template <class T>
80 {
81  Init(in);
82 }
83 
84 
85 
90 template <class T>
91 T& LASGlobalData<T>::GetTECEntry( int theDetector, int theRing, int theBeam, int theDisk ) {
92 
93  // do a range check first
94  if( !( ( theDetector == 0 || theDetector == 1 ) && // TEC+ or TEC-
95  ( theRing == 0 || theRing == 1 ) && // ring4 or ring6
96  ( theBeam >= 0 && theBeam < 8 ) && // eight beams in a TEC
97  ( theDisk >= 0 && theDisk < 9 ) ) ) { // disk1..disk9
98  std::cerr << " [LASGlobalData::GetTECEntry] ** ERROR: illegal input coordinates:" << std::endl;
99  std::cerr << " detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
100  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
101  }
102  else {
103  if( theDetector == 0 ) return( tecPlusData.at( theRing ).at( theBeam ).at( theDisk ) );
104  else return( tecMinusData.at( theRing ).at( theBeam ).at( theDisk ) );
105  }
106 
107 }
108 
109 
110 
111 
116 template <class T>
117 T& LASGlobalData<T>::GetTIBTOBEntry( int theDetector, int theBeam, int thePosition ) {
118 
119  // do a range check first
120  if( !( ( theDetector == 2 || theDetector == 3 ) && // TIB or TOB
121  ( theBeam >= 0 && theBeam < 8 ) && // there are eight AT beams
122  ( thePosition >= 0 && thePosition < 6 ) ) ) { // z-pos -3 .. z-pos +3
123  std::cerr << " [LASGlobalData::GetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
124  std::cerr << " detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "." << std::endl;
125  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
126  }
127  else {
128  if( theDetector == 2 ) return( tibData.at( theBeam ).at( thePosition ) );
129  else return( tobData.at( theBeam ).at( thePosition ) );
130  }
131 
132 }
133 
134 
135 
136 
141 template <class T>
142 T& LASGlobalData<T>::GetTEC2TECEntry( int theDetector, int theBeam, int theDisk ) {
143 
144  // do a range check first
145  if( !( ( theDetector == 0 || theDetector == 1 ) && // TEC+ or TEC-
146  ( theBeam >= 0 && theBeam < 8 ) && // eight AT beams in a TEC
147  ( theDisk >= 0 && theDisk < 6 ) ) ) { // disk1...disk5 are hit by AT
148  std::cerr << " [LASGlobalData::GetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
149  std::cerr << " detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
150  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
151  }
152  else {
153  if( theDetector == 0 ) return( tecPlusATData.at( theBeam ).at( theDisk ) );
154  else return( tecMinusATData.at( theBeam ).at( theDisk ) );
155  }
156 
157 }
158 
159 
160 
161 
162 
167 template <class T>
168 void LASGlobalData<T>::SetTECEntry( int theDetector, int theRing, int theBeam, int theDisk, T theEntry ) {
169 
170  // do a range check first
171  if( !( ( theDetector == 0 || theDetector == 1 ) && // TEC+ or TEC-
172  ( theRing == 0 || theRing == 1 ) && // ring4 or ring6
173  ( theBeam >= 0 && theBeam < 8 ) && // eight beams in a TEC
174  ( theDisk >= 0 && theDisk < 9 ) ) ) { // disk1..disk9
175  std::cerr << " [LASGlobalData::SetTECEntry] ** ERROR: illegal coordinates:" << std::endl;
176  std::cerr << " detector " << theDetector << ", ring " << theRing << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
177  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
178  }
179  else {
180  if( theDetector == 0 ) tecPlusData.at( theRing ).at( theBeam ).at( theDisk ) = theEntry;
181  else tecMinusData.at( theRing ).at( theBeam ).at( theDisk ) = theEntry;
182  }
183 
184 }
185 
186 
187 
188 
189 
194 template <class T>
195 void LASGlobalData<T>::SetTIBTOBEntry( int theDetector, int theBeam, int thePosition, T theEntry ) {
196 
197  // do a range check first
198  if( !( ( theDetector == 2 || theDetector == 3 ) && // TIB or TOB
199  ( theBeam >= 0 && theBeam < 8 ) && // there are eight AT beams
200  ( thePosition >= 0 && thePosition < 6 ) ) ) { // pos-3..pos+3
201  std::cerr << " [LASGlobalData::SetTIBTOBEntry] ** ERROR: illegal coordinates:" << std::endl;
202  std::cerr << " detector " << theDetector << ", beam " << theBeam << ", position " << thePosition << "." << std::endl;
203  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
204  }
205  else {
206  if( theDetector == 2 ) tibData.at( theBeam ).at( thePosition ) = theEntry;
207  else tobData.at( theBeam ).at( thePosition ) = theEntry;
208  }
209 
210 }
211 
212 
213 
214 
215 
220 template <class T>
221 void LASGlobalData<T>::SetTEC2TECEntry( int theDetector, int theBeam, int theDisk, T theEntry ) {
222 
223  // do a range check first
224  if( !( ( theDetector == 0 || theDetector == 1 ) && // TEC+ or TEC-
225  ( theBeam >= 0 && theBeam < 8 ) && // eight beams in a TEC
226  ( theDisk >= 0 && theDisk < 6 ) ) ) { // disk1..disk5 for TEC AT
227  std::cerr << " [LASGlobalData::SetTEC2TECEntry] ** ERROR: illegal coordinates:" << std::endl;
228  std::cerr << " detector " << theDetector << ", beam " << theBeam << ", disk " << theDisk << "." << std::endl;
229  throw " Bailing out."; // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
230  }
231  else {
232  if( theDetector == 0 ) tecPlusATData.at( theBeam ).at( theDisk ) = theEntry;
233  else tecMinusATData.at( theBeam ).at( theDisk ) = theEntry;
234  }
235 
236 }
237 
238 
239 
240 
241 
242 // ///
243 // /// element wise assignment operator
244 // ///
245 // template <class T>
246 // LASGlobalData<T>& LASGlobalData<T>::operator=( LASGlobalData<T>& anotherGlobalData ) {
247 
248 // // TEC copy
249 // for( int det = 0; det < 2; ++det ) {
250 // for( int ring = 0; ring < 2; ++ring ) {
251 // for( int beam = 0; beam < 8; ++ beam ) {
252 // for( int disk = 0; disk < 9; ++ disk ) {
253 // this->SetTECEntry( det, ring, beam, disk, anotherGlobalData.GetTECEntry( det, ring, beam, disk ) );
254 // }
255 // }
256 // }
257 // }
258 
259 // // TIBTOB copy
260 // for( int det = 2; det < 4; ++det ) {
261 // for( int beam = 0; beam < 8; ++ beam ) {
262 // for( int pos = 0; pos < 6; ++ pos ) {
263 // this->SetTIBTOBEntry( det, beam, pos, anotherGlobalData.GetTIBTOBEntry( det, beam, pos ) );
264 // }
265 // }
266 // }
267 
268 // // TEC2TEC copy
269 // for( int det = 2; det < 4; ++det ) {
270 // for( int beam = 0; beam < 8; ++ beam ) {
271 // for( int disk = 0; disk < 9; ++ disk ) {
272 // this->SetTEC2TECEntry( det, beam, disk, anotherGlobalData.GetTEC2TECEntry( det, beam, disk ) );
273 // }
274 // }
275 // }
276 
277 // }
278 
279 
280 
281 template <class T>
282 void LASGlobalData<T>::Init( const T& in ) {
283 
284  // create TEC+ subdetector "multi"-vector of T
285  tecPlusData.resize( 2 ); // create ring4 and ring6
286  for( unsigned int ring = 0; ring < tecPlusData.size(); ++ring ) {
287  tecPlusData.at( ring ).resize( 8 ); // create 8 beams for each ring
288  for( unsigned int beam = 0; beam < tecPlusData.at( ring ).size(); ++beam ) {
289  tecPlusData.at( ring ).at( beam ).resize( 9 , in); // create 9 disks for each beam
290  }
291  }
292 
293  // same for TEC-
294  tecMinusData.resize( 2 ); // create ring4 and ring6
295  for( unsigned int ring = 0; ring < tecMinusData.size(); ++ring ) {
296  tecMinusData.at( ring ).resize( 8 ); // create 8 beams for each ring
297  for( unsigned int beam = 0; beam < tecMinusData.at( ring ).size(); ++beam ) {
298  tecMinusData.at( ring ).at( beam ).resize( 9, in ); // create 9 disks for each beam
299  }
300  }
301 
302  // same for TEC+ AT
303  tecPlusATData.resize( 8 ); // create 8 beams
304  for( unsigned int beam = 0; beam < tecPlusATData.size(); ++beam ) {
305  tecPlusATData.at( beam ).resize( 5, in ); // five TEC disks hit by each AT beam
306  }
307 
308  // same for TEC- AT
309  tecMinusATData.resize( 8 ); // create 8 beams
310  for( unsigned int beam = 0; beam < tecMinusATData.size(); ++beam ) {
311  tecMinusATData.at( beam ).resize( 5, in ); // five TEC disks hit by each AT beam
312  }
313 
314  // same for TIB..
315  tibData.resize( 8 ); // create 8 beams
316  for( unsigned int beam = 0; beam < tibData.size(); ++ beam ) {
317  tibData.at( beam ).resize( 6, in ); // six TIB modules hit by each beam
318  }
319 
320  // ..and for TOB
321  tobData.resize( 8 ); // create 8 beams
322  for( unsigned int beam = 0; beam < tobData.size(); ++ beam ) {
323  tobData.at( beam ).resize( 6, in ); // six TOB modules hit by each beam
324  }
325 }
326 
327 
328 #endif
void SetTEC2TECEntry(int subdetector, int beam, int tecDisk, T)
std::vector< std::vector< std::vector< T > > > tecMinusData
Definition: LASGlobalData.h:55
std::vector< std::vector< T > > tibData
Definition: LASGlobalData.h:58
void Init(const T &in=T())
std::vector< std::vector< T > > tecMinusATData
Definition: LASGlobalData.h:57
ClassDef(LASGlobalData, 2)
std::vector< std::vector< std::vector< T > > > tecPlusData
Definition: LASGlobalData.h:54
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
void SetTIBTOBEntry(int subdetector, int beam, int tibTobPosition, T)
std::vector< std::vector< T > > tobData
Definition: LASGlobalData.h:59
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
std::vector< std::vector< T > > tecPlusATData
Definition: LASGlobalData.h:56
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
Definition: LASGlobalData.h:91
long double T
void SetTECEntry(int subdetector, int tecRing, int beam, int tecDisk, T)