Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:00

0001 
0002 #ifndef __LASGLOBALDATA_H
0003 #define __LASGLOBALDATA_H
0004 
0005 #include <vector>
0006 #include <iostream>
0007 #include "TNamed.h"
0008 
0009 ///
0010 /// Container class for storing and easy access to global LAS data
0011 ///
0012 /// There is one entry of type T for each LAS module, e.g. beam profiles, position, name, ...
0013 /// All identifiers (beam,subdetector,position,...) start with index 0. Note that some ring 4
0014 /// TEC modules are hit by either TEC internal as well as by AT beams and are therefore
0015 /// considered twice in the container (once in tec<X>Data and once in tec<X>ATData).
0016 /// Do not instantiate this class with bool.
0017 ///
0018 /// Short LAS geometry reminder:<BR>
0019 /// <UL>
0020 /// <LI>TEC internal alignment:<BR>
0021 ///   8 beams each hit ring 6 modules on 9 disks per endcap<BR>
0022 ///   8 beams each hit ring 4 modules on 9 disks per endcap<BR>
0023 /// <LI>Barrel AT alignment:<BR>
0024 ///   8 AT beams each hit 6 TIb and 6 TOB modules<BR>
0025 /// <LI>TEC AT (TEC2TEC inter-) alignment:<BR>
0026 ///   8 barrel (AT) beams each hit 5 ring 4 modules per endcap<BR>
0027 /// </UL>
0028 ///
0029 
0030 template <class T>
0031 class LASGlobalData : public TNamed {
0032 public:
0033   // enums not in use so far...
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   //  LASGlobalData<T>& operator=( LASGlobalData<T>& );
0048 
0049 private:
0050   //void Init( void );
0051   void Init(const T& in = T());
0052   std::vector<std::vector<std::vector<T> > > tecPlusData;   // ring<beam<disk<T>>>
0053   std::vector<std::vector<std::vector<T> > > tecMinusData;  // ring<beam<disk<T>>>
0054   std::vector<std::vector<T> > tecPlusATData;               // beam<disk<T>>
0055   std::vector<std::vector<T> > tecMinusATData;              // beam<disk<T>>
0056   std::vector<std::vector<T> > tibData;                     // beam<pos<T>>
0057   std::vector<std::vector<T> > tobData;                     // beam<pos<T>>
0058 
0059   ClassDef(LASGlobalData, 2);
0060 };
0061 
0062 // since this is a template
0063 //#include "Alignment/LaserAlignment/src/LASGlobalData.cc"
0064 
0065 template <class T>
0066 LASGlobalData<T>::LASGlobalData() {
0067   ///
0068   /// def constructor
0069   ///
0070 
0071   Init();
0072 }
0073 
0074 template <class T>
0075 LASGlobalData<T>::LASGlobalData(const T& in) {
0076   Init(in);
0077 }
0078 
0079 ///
0080 /// get a tec entry from the container according to
0081 /// subdetector, ring, beam and disk number
0082 ///
0083 template <class T>
0084 T& LASGlobalData<T>::GetTECEntry(int theDetector, int theRing, int theBeam, int theDisk) {
0085   // do a range check first
0086   if (!((theDetector == 0 || theDetector == 1) &&  // TEC+ or TEC-
0087         (theRing == 0 || theRing == 1) &&          // ring4 or ring6
0088         (theBeam >= 0 && theBeam < 8) &&           // eight beams in a TEC
0089         (theDisk >= 0 && theDisk < 9))) {          // disk1..disk9
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 /// get a tib/tob entry from the container according to
0104 /// subdetector, beam and position (z) number
0105 ///
0106 template <class T>
0107 T& LASGlobalData<T>::GetTIBTOBEntry(int theDetector, int theBeam, int thePosition) {
0108   // do a range check first
0109   if (!((theDetector == 2 || theDetector == 3) &&  // TIB or TOB
0110         (theBeam >= 0 && theBeam < 8) &&           // there are eight AT beams
0111         (thePosition >= 0 && thePosition < 6))) {  // z-pos -3 .. z-pos +3
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 /// get a tec AT entry (ring 4) from the container according to
0126 /// subdetector, beam and disk number
0127 ///
0128 template <class T>
0129 T& LASGlobalData<T>::GetTEC2TECEntry(int theDetector, int theBeam, int theDisk) {
0130   // do a range check first
0131   if (!((theDetector == 0 || theDetector == 1) &&  // TEC+ or TEC-
0132         (theBeam >= 0 && theBeam < 8) &&           // eight AT beams in a TEC
0133         (theDisk >= 0 && theDisk < 6))) {          // disk1...disk5 are hit by AT
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 /// set a tec entry int the container according to
0147 /// subdetector, ring, beam and disk number
0148 ///
0149 template <class T>
0150 void LASGlobalData<T>::SetTECEntry(int theDetector, int theRing, int theBeam, int theDisk, T theEntry) {
0151   // do a range check first
0152   if (!((theDetector == 0 || theDetector == 1) &&  // TEC+ or TEC-
0153         (theRing == 0 || theRing == 1) &&          // ring4 or ring6
0154         (theBeam >= 0 && theBeam < 8) &&           // eight beams in a TEC
0155         (theDisk >= 0 && theDisk < 9))) {          // disk1..disk9
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 ///  set a tib/tob entry in the container accord
0170 ///  subdetector, beam and position (z) number
0171 ///
0172 template <class T>
0173 void LASGlobalData<T>::SetTIBTOBEntry(int theDetector, int theBeam, int thePosition, T theEntry) {
0174   // do a range check first
0175   if (!((theDetector == 2 || theDetector == 3) &&  // TIB or TOB
0176         (theBeam >= 0 && theBeam < 8) &&           // there are eight AT beams
0177         (thePosition >= 0 && thePosition < 6))) {  // pos-3..pos+3
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 /// set a tec AT entry (ring 4) in the container according to
0192 /// subdetector, beam and disk number
0193 ///
0194 template <class T>
0195 void LASGlobalData<T>::SetTEC2TECEntry(int theDetector, int theBeam, int theDisk, T theEntry) {
0196   // do a range check first
0197   if (!((theDetector == 0 || theDetector == 1) &&  // TEC+ or TEC-
0198         (theBeam >= 0 && theBeam < 8) &&           // eight beams in a TEC
0199         (theDisk >= 0 && theDisk < 6))) {          // disk1..disk5 for TEC AT
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.";  // @@@ REPLACE THIS BY cms::Exception (<FWCore/Utilities/interface/Exception.h> in 1_3_6)
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 // /// element wise assignment operator
0213 // ///
0214 // template <class T>
0215 // LASGlobalData<T>& LASGlobalData<T>::operator=( LASGlobalData<T>& anotherGlobalData ) {
0216 
0217 //   // TEC copy
0218 //   for( int det = 0; det < 2; ++det ) {
0219 //     for( int ring = 0; ring < 2; ++ring ) {
0220 //       for( int beam = 0; beam < 8; ++ beam ) {
0221 //  for( int disk = 0; disk < 9; ++ disk ) {
0222 //    this->SetTECEntry( det, ring, beam, disk, anotherGlobalData.GetTECEntry( det, ring, beam, disk ) );
0223 //  }
0224 //       }
0225 //     }
0226 //   }
0227 
0228 //   // TIBTOB copy
0229 //   for( int det = 2; det < 4; ++det ) {
0230 //     for( int beam = 0; beam < 8; ++ beam ) {
0231 //       for( int pos = 0; pos < 6; ++ pos ) {
0232 //  this->SetTIBTOBEntry( det, beam, pos, anotherGlobalData.GetTIBTOBEntry( det, beam, pos ) );
0233 //       }
0234 //     }
0235 //   }
0236 
0237 //   // TEC2TEC copy
0238 //   for( int det = 2; det < 4; ++det ) {
0239 //     for( int beam = 0; beam < 8; ++ beam ) {
0240 //       for( int disk = 0; disk < 9; ++ disk ) {
0241 //  this->SetTEC2TECEntry( det, beam, disk, anotherGlobalData.GetTEC2TECEntry( det, beam, disk ) );
0242 //       }
0243 //     }
0244 //   }
0245 
0246 // }
0247 
0248 template <class T>
0249 void LASGlobalData<T>::Init(const T& in) {
0250   // create TEC+ subdetector "multi"-vector of T
0251   tecPlusData.resize(2);  // create ring4 and ring6
0252   for (unsigned int ring = 0; ring < tecPlusData.size(); ++ring) {
0253     tecPlusData.at(ring).resize(8);  // create 8 beams for each ring
0254     for (unsigned int beam = 0; beam < tecPlusData.at(ring).size(); ++beam) {
0255       tecPlusData.at(ring).at(beam).resize(9, in);  // create 9 disks for each beam
0256     }
0257   }
0258 
0259   // same for TEC-
0260   tecMinusData.resize(2);  // create ring4 and ring6
0261   for (unsigned int ring = 0; ring < tecMinusData.size(); ++ring) {
0262     tecMinusData.at(ring).resize(8);  // create 8 beams for each ring
0263     for (unsigned int beam = 0; beam < tecMinusData.at(ring).size(); ++beam) {
0264       tecMinusData.at(ring).at(beam).resize(9, in);  // create 9 disks for each beam
0265     }
0266   }
0267 
0268   // same for TEC+ AT
0269   tecPlusATData.resize(8);  // create 8 beams
0270   for (unsigned int beam = 0; beam < tecPlusATData.size(); ++beam) {
0271     tecPlusATData.at(beam).resize(5, in);  // five TEC disks hit by each AT beam
0272   }
0273 
0274   // same for TEC- AT
0275   tecMinusATData.resize(8);  // create 8 beams
0276   for (unsigned int beam = 0; beam < tecMinusATData.size(); ++beam) {
0277     tecMinusATData.at(beam).resize(5, in);  // five TEC disks hit by each AT beam
0278   }
0279 
0280   // same for TIB..
0281   tibData.resize(8);  // create 8 beams
0282   for (unsigned int beam = 0; beam < tibData.size(); ++beam) {
0283     tibData.at(beam).resize(6, in);  // six TIB modules hit by each beam
0284   }
0285 
0286   // ..and for TOB
0287   tobData.resize(8);  // create 8 beams
0288   for (unsigned int beam = 0; beam < tobData.size(); ++beam) {
0289     tobData.at(beam).resize(6, in);  // six TOB modules hit by each beam
0290   }
0291 }
0292 
0293 #endif