00001 // H4Geom.h 00002 // 00003 // Class which manages geometry information of the super-module 00004 // 00005 // last change : $Date: 2006/04/21 10:16:51 $ 00006 // by : $Author: meridian $ 00007 // 00008 00009 #ifndef H4Geom_H 00010 #define H4Geom_H 00011 00012 00013 #include "TObject.h" 00014 #include <string> 00015 00016 class H4Geom: public TObject 00017 { 00018 public: 00019 // Geometry is period dependent. The different geometries are listed below 00020 enum GeomPeriod_t { 00021 Undef, // Cause the program to crash 00022 Year2003, // Test beam during 2003: SM0 and SM1 00023 Spring2004, // June-July 2004: E0' tests 00024 Automn2004 // Tests of one full supermodule 00025 }; 00026 00027 // Constants defining supermodule geometry 00028 enum SMGeom_t { 00029 kModules = 4, // Number of modules per supermodule 00030 kTriggerTowers = 68, // Number of trigger towers per supermodule 00031 kTowersInPhi = 4, // Number of trigger towers in phi 00032 kTowersInEta = 17, // Number of trigger towers in eta 00033 kCrystals = 1700, // Number of crystals per supermodule 00034 kCrystalsInPhi = 20, // Number of crystals in phi 00035 kCrystalsInEta = 85, // Number of crystals in eta 00036 kCrystalsPerTower = 25, // Number of crystals per trigger tower 00037 kCardsPerTower = 5, // Number of VFE cards per trigger tower 00038 kChannelsPerCard = 5 // Number of channels per VFE card 00039 }; 00040 00041 // Default Constructor, mainly for Root 00042 H4Geom() ; 00043 00044 // Destructor: Does nothing? 00045 virtual ~H4Geom(); 00046 00047 // Initialize geometry with config file 00048 bool init(); 00049 00050 // Retuns the crystal number in the super module for a given 00051 // tower number in the super module and crystal number in the tower 00052 int getSMCrystalNumber(int tower, int crystal) const ; 00053 00054 // Retuns the crystal number in a tower for a given 00055 // crystal number in the super module 00056 void getTowerCrystalNumber(int &tower, int &crystal, int smCrystal) const ; 00057 00058 // Returns the crystal number (readout order) in a tower 00059 // for a given position in the tower (crystalNbGeom=0 is the 00060 // lower-right corner and crystalNbGeom=24 is the upper-left corner) 00061 int getTowerCrystalNumber(int smTowerNb, int crystalNbGeom) const ; 00062 00063 // Returns the crystal coordinates (eta, phi index) for a given 00064 // crystal number in the super module 00065 void getCrystalCoord(int &eta, int &phi, int smCrystal) const ; 00066 00067 // Retuns the crystal number in the super module for given coordinates 00068 int getSMCrystalFromCoord(int eta, int phi) const ; 00069 00070 // Returns left neighbour of a sm crystal. 00071 // Input and output are crystal numbers in the super module. 00072 // A negative output means outside of the supermodule. 00073 int getLeft(int smCrystal) const ; 00074 00075 // Returns right neighbour of a sm crystal. 00076 // Input and output are crystal numbers in the super module. 00077 // A negative output means outside of the supermodule. 00078 int getRight(int smCrystal) const ; 00079 00080 // Returns upper neighbour of a sm crystal. 00081 // Input and output are crystal numbers in the super module. 00082 // A negative output means outside of the supermodule. 00083 int getUpper(int smCrystal) const ; 00084 00085 // Returns lower neighbour of a sm crystal. 00086 // Input and output are crystal numbers in the super module. 00087 // A negative output means outside of the supermodule. 00088 int getLower(int smCrystal) const ; 00089 00090 // Returns left neighbour of a crystal referenced by its coordinates. 00091 // New coordonates overwrite the old ones. No check is done to see 00092 // if it corresponds to a real crystal. To be used with caution. 00093 void mvLeft(int &eta, int &phi) const ; 00094 00095 // Returns right neighbour of a crystal referenced by its coordinates. 00096 // New coordonates overwrite the old ones. No check is done to see 00097 // if it corresponds to a real crystal. To be used with caution. 00098 void mvRight(int &eta, int &phi) const ; 00099 00100 // Returns upper neighbour of a crystal referenced by its coordinates. 00101 // New coordonates overwrite the old ones. No check is done to see 00102 // if it corresponds to a real crystal. To be used with caution. 00103 void mvUp(int &eta, int &phi) const ; 00104 00105 00106 // Returns lower neighbour of a crystal referenced by its coordinates. 00107 // New coordonates overwrite the old ones. No check is done to see 00108 // if it corresponds to a real crystal. To be used with caution. 00109 void mvDown(int &eta, int &phi) const ; 00110 00111 // Returns the 25 crystals of tower towerNb in the super module. 00112 // Output are crystal numbers in the super module. 00113 // By default, the order in the output array (tower) corresponds to 00114 // geometric order (index 0 is lower-right corner). 00115 // if order=readout, the order in the output array (tower) 00116 // corresponds to the readout scheme (depends on the kind of tower) 00117 void getTower(int * tower, int towerNb, std::string order = "geom") const ; 00118 00119 // Returns the 5 crystals belonging to the same VFE board as smCrystal. 00120 // Input and output are crystal numbers in the super module. 00121 // By default, the order in the output array (VFE) corresponds to 00122 // The geometric order (index 0 is lower-right corner). 00123 // if order=readout, the order in the output array (VFE) 00124 // corresponds to the readout scheme (depends on the kind of tower) 00125 void getVFE(int * VFE, int smCrystal, std::string order = "geom") const ; 00126 00127 // Returns sm crystal numbers for crystals in a window of 00128 // size widthxheight centered around a given smCrystal. 00129 // width and height must be odd. 00130 // The order in the output array (window) is defined 00131 // by the geometric order (index 0 is lower-right corner). 00132 void getWindow(int * window, int smCrystal, int width, int height) const ; 00133 00134 // Tests if low voltage board is on the right size of the tower. 00135 // Readout scheme depends on that. 00136 bool rightTower(int tower) const ; 00137 00138 // Tests if low voltage board is on the left size of the tower 00139 // Readout scheme depends on that. 00140 bool leftTower(int tower) const ; 00141 00142 GeomPeriod_t GetGeomPeriod() const {return geometry_;} 00143 00144 static void SetGeomPeriod(GeomPeriod_t geometry); 00145 00146 private: 00147 bool IsGeomPeriodDefined() const; 00148 00149 const static int crystalChannelMap[5][5]; 00150 const static int crystalMap[25]; 00151 static GeomPeriod_t geometry_; 00152 00153 ClassDef(H4Geom,1) // Class to navigate in a SM 00154 }; 00155 00156 #endif