CMS 3D CMS Logo

Geom.h
Go to the documentation of this file.
1 // H4Geom.h
2 //
3 // Class which manages geometry information of the super-module
4 // Author: Giovanni Franzoni
5 //
6 
7 #ifndef H4Geom_H
8 #define H4Geom_H
9 
10 
11 #include <string>
12 
13 class H4Geom
14 {
15  public:
16  // Geometry is period dependent. The different geometries are listed below
17  enum GeomPeriod_t {
18  Undef, // Cause the program to crash
19  Year2003, // Test beam during 2003: SM0 and SM1
20  Spring2004, // June-July 2004: E0' tests
21  Automn2004 // Tests of one full supermodule
22  };
23 
24  // Constants defining supermodule geometry
25  enum SMGeom_t {
26  kSModulesInEcal = 36, // Number of Super Modules in whole ECAL
27  kModules = 4, // Number of modules per supermodule
28  kTriggerTowers = 68, // Number of trigger towers per supermodule
29  kTTandMems = 70, // Number of tt per supermodule, including MEM boxes
30  kTowersInPhi = 4, // Number of trigger towers in phi
31  kTowersInEta = 17, // Number of trigger towers in eta
32  kCrystals = 1700, // Number of crystals per supermodule
33  kCrystalsWithMems = 1750, // Number of channels per supermodule, mem included
34  kCrystalsM1 = 500, // Number of crystals per supermodule
35  kCrystalsM2 = 400, // Number of crystals per supermodule
36  kCrystalsM3 = 400, // Number of crystals per supermodule
37  kCrystalsM4 = 400, // Number of crystals per supermodule
38  kCrystalsInPhi = 20, // Number of crystals in phi
39  kCrystalsInEta = 85, // Number of crystals in eta
40  kCrystalsInEtaM1 = 25, // Number of crystals in eta for module 1
41  kCrystalsInEtaM2 = 20, // Number of crystals in eta for module 2
42  kCrystalsInEtaM3 = 20, // Number of crystals in eta for module 3
43  kCrystalsInEtaM4 = 20, // Number of crystals in eta for module 4
44  kCrystalsPerTower = 25, // Number of crystals per trigger tower
45  kCardsPerTower = 5, // Number of VFE cards per trigger tower
46  kChannelsPerCard = 5, // Number of channels per VFE card
47  kSamplesInEvent = 10, // Number of samples in event
48  kSamplesInPNEvent = 50, // Number of samples in event
49  kPNs = 10 // number of pn diode for laser monitoring (number [0,9])
50  };
51 
52  // Default Constructor, mainly for Root
53  H4Geom() ;
54 
55  // Destructor: Does nothing?
56  virtual ~H4Geom();
57 
58  // Initialize geometry with config file
59  bool init();
60 
61  // Retuns the crystal number in the super module for a given
62  // tower number in the super module and crystal number in the tower
63  int getSMCrystalNumber(int tower, int crystal) const ;
64 
65  // Retuns the crystal number in the super module for a given
66  // tower number, strip_id number and crystal_id number
67  // necessary for output of the data-parser, Ecal Monitoring
68  int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
69 
70  // Retuns the tower number, strip_id number and crystal_id number
71  // for a given crystal in the SM numbering
72  // This is the inverse of int getSMCrystalNumber(int tower, int strip_id, int crystal_id) const ;
73  void getTowerStripChannelNumber(int& tower, int& strip_id, int& crystal_id, int sm_num) const;
74 
75  // Retuns the crystal number in a tower for a given
76  // crystal number in the super module
77  void getTowerCrystalNumber(int &tower, int &crystal, int smCrystal) const ;
78 
79  // Returns the crystal number (readout order) in a tower
80  // for a given position in the tower (crystalNbGeom=0 is the
81  // lower-right corner and crystalNbGeom=24 is the upper-left corner)
82  int getTowerCrystalNumber(int smTowerNb, int crystalNbGeom) const ;
83 
84  // Returns the crystal coordinates (eta, phi index) for a given
85  // crystal number in the super module
86  void getCrystalCoord(int &eta, int &phi, int smCrystal) const ;
87 
88  // Retuns the crystal number in the super module for given coordinates
89  int getSMCrystalFromCoord(int eta, int phi) const ;
90 
91  // Returns left neighbour of a sm crystal.
92  // Input and output are crystal numbers in the super module.
93  // A negative output means outside of the supermodule.
94  int getLeft(int smCrystal) const ;
95 
96  // Returns right neighbour of a sm crystal.
97  // Input and output are crystal numbers in the super module.
98  // A negative output means outside of the supermodule.
99  int getRight(int smCrystal) const ;
100 
101  // Returns upper neighbour of a sm crystal.
102  // Input and output are crystal numbers in the super module.
103  // A negative output means outside of the supermodule.
104  int getUpper(int smCrystal) const ;
105 
106  // Returns lower neighbour of a sm crystal.
107  // Input and output are crystal numbers in the super module.
108  // A negative output means outside of the supermodule.
109  int getLower(int smCrystal) const ;
110 
111  // Returns left neighbour of a crystal referenced by its coordinates.
112  // New coordonates overwrite the old ones. No check is done to see
113  // if it corresponds to a real crystal. To be used with caution.
114  void mvLeft(int &eta, int &phi) const ;
115 
116  // Returns right neighbour of a crystal referenced by its coordinates.
117  // New coordonates overwrite the old ones. No check is done to see
118  // if it corresponds to a real crystal. To be used with caution.
119  void mvRight(int &eta, int &phi) const ;
120 
121  // Returns upper neighbour of a crystal referenced by its coordinates.
122  // New coordonates overwrite the old ones. No check is done to see
123  // if it corresponds to a real crystal. To be used with caution.
124  void mvUp(int &eta, int &phi) const ;
125 
126 
127  // Returns lower neighbour of a crystal referenced by its coordinates.
128  // New coordonates overwrite the old ones. No check is done to see
129  // if it corresponds to a real crystal. To be used with caution.
130  void mvDown(int &eta, int &phi) const ;
131 
132  // Returns the 25 crystals of tower towerNb in the super module.
133  // Output are crystal numbers in the super module.
134  // By default, the order in the output array (tower) corresponds to
135  // geometric order (index 0 is lower-right corner).
136  // if order=readout, the order in the output array (tower)
137  // corresponds to the readout scheme (depends on the kind of tower)
138  void getTower(int * tower, int towerNb, std::string order = "geom") const ;
139 
140  // Returns the 5 crystals belonging to the same VFE board as smCrystal.
141  // Input and output are crystal numbers in the super module.
142  // By default, the order in the output array (VFE) corresponds to
143  // The geometric order (index 0 is lower-right corner).
144  // if order=readout, the order in the output array (VFE)
145  // corresponds to the readout scheme (depends on the kind of tower)
146  void getVFE(int * VFE, int smCrystal, std::string order = "geom") const ;
147 
148  // Returns sm crystal numbers for crystals in a window of
149  // size widthxheight centered around a given smCrystal.
150  // width and height must be odd.
151  // The order in the output array (window) is defined
152  // by the geometric order (index 0 is lower-right corner).
153  void getWindow(int * window, int smCrystal, int width, int height) const ;
154 
155  // Tests if low voltage board is on the right size of the tower.
156  // Readout scheme depends on that.
157  bool rightTower(int tower) const ;
158 
159  // Tests if low voltage board is on the left size of the tower
160  // Readout scheme depends on that.
161  bool leftTower(int tower) const ;
162 
163  // first half of SM, shown by one laser shot
164  bool isInFirstHalf(int numberInSM)
165  {
166  int eta; int phi;
167  getCrystalCoord(eta,phi, numberInSM);
168  if (phi > 19 || eta < 20 )
169  {return true; }
170  else
171  {return false; }
172  };
173 
174 
176 
177  static void SetGeomPeriod(GeomPeriod_t geometry);
178 
179  int getHalf(int TT);
180  private:
181  bool IsGeomPeriodDefined() const;
182 
183  const static int crystalChannelMap[5][5];
184  const static int crystalMap[25];
185  const static int WhichHalf[69];
187 };
188 
189 #endif
int getSMCrystalFromCoord(int eta, int phi) const
int getLower(int smCrystal) const
int getHalf(int TT)
bool IsGeomPeriodDefined() const
virtual ~H4Geom()
void mvDown(int &eta, int &phi) const
bool rightTower(int tower) const
bool init()
void getCrystalCoord(int &eta, int &phi, int smCrystal) const
int getSMCrystalNumber(int tower, int crystal) const
void getTower(int *tower, int towerNb, std::string order="geom") const
void getTowerStripChannelNumber(int &tower, int &strip_id, int &crystal_id, int sm_num) const
SMGeom_t
Definition: Geom.h:25
int getRight(int smCrystal) const
static const int crystalMap[25]
Definition: Geom.h:184
GeomPeriod_t
Definition: Geom.h:17
static const int WhichHalf[69]
Definition: Geom.h:185
int getLeft(int smCrystal) const
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:642
bool isInFirstHalf(int numberInSM)
Definition: Geom.h:164
int getUpper(int smCrystal) const
Definition: Geom.h:13
GeomPeriod_t GetGeomPeriod() const
Definition: Geom.h:175
bool leftTower(int tower) const
void mvRight(int &eta, int &phi) const
static GeomPeriod_t geometry_
Definition: Geom.h:186
void getVFE(int *VFE, int smCrystal, std::string order="geom") const
void getWindow(int *window, int smCrystal, int width, int height) const
void mvUp(int &eta, int &phi) const
void mvLeft(int &eta, int &phi) const
static const int crystalChannelMap[5][5]
Definition: Geom.h:183
void getTowerCrystalNumber(int &tower, int &crystal, int smCrystal) const
static void SetGeomPeriod(GeomPeriod_t geometry)