StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEmcSmdMap.h
1 #ifndef __EEmcSmdMap__
2 #define __EEmcSmdMap__
3 
4 /*
5  *
6  * \class EEmcSmdMap
7  * \date 12/02/03
8  * \author jwebb
9  *
10  * This class provides the range of SMD strips which fall within the
11  * fiducial volume of a specified EEMC tower. It is designed to access
12  * a lookup table. The entries in the table were determined by
13  * calculating the crossing point of all SMD U and V strip pairs.
14  * Crossing points which fell within the fiducical limits of a given
15  * tower at a plane centered on the mean-z of the U and V planes
16  * were used to determine the allowable range of U and V strips.
17  *
18  * This class is implemented as a singleton... i.e., get a pointer to
19  * the class by EEmcSmdMap *map = EEmcSmdMap::instance(), instead of
20  * calling the constructor.
21  *
22  * Usage:
23  *
24  * EEmcSmdMap *map = EEmcSmdMap::instance();
25  * Int_t uMin,uMax,vMin,vMax;
26  * map -> getRangeU( sector, subsector, etabin, uMin, uMax); // all arguements
27  * map -> getRangeV( sector, subsector, etabin, vMin, vMax); // indexed from 0
28  *
29  * Int_t iuv;
30  * map -> getRange( sector, subsector, etabin, iuv, vMin, vMax); // to be retired due to nonunique name, see below,JB
31  * map -> getRangeTw2Smd( isector, isubsector, ietabin, iuv, ivMin, ivMax);
32  *
33  * map -> getRangeSmd2Smd( isector, iuv, istrip, juv, jMin, jMax);
34  * returns range of strips from the other plane , all counts from 0.
35  * Input: arguments with prefix 'i', output with prefix 'j'
36  *
37  * Limitations:
38  *
39  * 1. Strip ranges are approximate and should not be trusted to more
40  * than two or three strips. This should be sufficient for most
41  * purposes.
42  *
43  * 2. Only U-V planes which are nominally within a given sector are
44  * considered. In other words, this class does not currently
45  * provide any information on strips which overlap from adjacent
46  * sectors near the tie-rods.
47  *
48  */
49 
50 #include <TObject.h>
51 #include <TString.h>
52 
53 #include <vector>
54 #include <assert.h>
55 
56 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
58 
59 //-- Structure to map strip ranges to towers --
61  const Char_t *tower;
62  Int_t uMin; // minimum u strip, all indexed from 0
63  Int_t uMax; // maximum u strip
64  Int_t vMin; // minimum v strip
65  Int_t vMax; // maximum v strip
66 };
67 
68 //-- Maps towers to individual strips --
70  EEmcTowerMapItem() : nTower(0) {}
71  Int_t nTower; // Number of towers which match strip
72  std::vector<TString> towers; // [nTower] array of tower names, eg 01TA01
73  std::vector<Int_t> sector; // [nTower] array of sectors
74  std::vector<Int_t> subsector; // [nTower] array of subsectors
75  std::vector<Int_t> etabin; // [nTower] array of etabins
76 };
77 
78 
79 
80 class EEmcSmdMap : public TObject
81 {
82 public:
83 
84  EEmcSmdMap();
85  virtual ~EEmcSmdMap(){ /* nada */ };
86 
87  // return the single instance of this class
88  static EEmcSmdMap *instance();
89 
91  //
92  // Get min and max strips in each orientation which
93  // match the given tower. All arguements are c++
94  // indices (i.e. sector runs from 0-11 not 1-12).
95  //
96  // Min and max returned via reference.
97  //
98  void getRangeU( Int_t sector,
99  Int_t subsector,
100  Int_t etabin,
101  Int_t &uMin,
102  Int_t &uMax ) const {
103 
104  uMin = mSmdMap[sector][subsector][etabin].uMin;
105  uMax = mSmdMap[sector][subsector][etabin].uMax;
106 
107  }
108  void getRangeV( Int_t sector,
109  Int_t subsector,
110  Int_t etabin,
111  Int_t &vMin,
112  Int_t &vMax ) const {
113 
114  vMin = mSmdMap[sector][subsector][etabin].vMin;
115  vMax = mSmdMap[sector][subsector][etabin].vMax;
116 
117  }
118  // Min and max returned via reference.
119  //
120 
121  void getRangeTw2Smd ( Int_t sector,
122  Int_t subsector,
123  Int_t etabin,
124  Int_t iuv,
125  Int_t &Min,
126  Int_t &Max ) const {
127  switch(iuv) {
128  case 0: return getRangeU( sector, subsector, etabin, Min, Max);
129  case 1: return getRangeV( sector, subsector, etabin, Min, Max);
130  default: {assert(2==3);}
131  }
132  }
133 
134  // to be retired seeon,JB
135  void getRange ( Int_t sector,
136  Int_t subsector,
137  Int_t etabin,
138  Int_t iuv,
139  Int_t &Min,
140  Int_t &Max ) const {
141  getRangeTw2Smd (sector, subsector, etabin, iuv, Min, Max);
142  }
143 
144  // Central strip(s) returned vis reference.
145  //
146  void getMiddleU ( Int_t sector,
147  Int_t subsector,
148  Int_t etabin,
149  Int_t &umid ) const {
150  umid = (
151  mSmdMap[sector][subsector][etabin].uMin +
152  mSmdMap[sector][subsector][etabin].uMax ) / 2;
153 
154  }
155  void getMiddleV ( Int_t sector,
156  Int_t subsector,
157  Int_t etabin,
158  Int_t &vmid ) const {
159  vmid = (
160  mSmdMap[sector][subsector][etabin].vMin +
161  mSmdMap[sector][subsector][etabin].vMax ) / 2;
162 
163  }
164  //
166 
167 
169  //
170  // Get min and max strips in the other plane
171  // match the a given strips. All arguements are c++
172  // indices (i.e. sector runs from 0-11 not 1-12).
173  //
174  // juv, jMin and jMax returned via reference.
175  //
176  void getRangeSmd2Smd( Int_t isector, Int_t iuv, Int_t istrip,
177  Int_t &juv, Int_t &jMin, Int_t &jMax ) const;
178 
179  //
181 
183  //
184  // Get the number of towers which "belong" to this
185  // strip. "sec", "plane" and "strip" are counted
186  // from 0.
187  //
188  Int_t getNTowers( Int_t sec,
189  Int_t plane,
190  Int_t strip ) const {
191  return mTowerMap[sec][plane][strip].nTower;
192  }
193 
194  // For the specified sector, plane and strip (numbered
195  // from 0), return the "nth" tower's subsector and
196  // eta bin.
197  void getTower( Int_t sec, Int_t plane, Int_t strip,
198  Int_t ntow, Int_t &sub, Int_t &eta ) const {
199  sub = mTowerMap[sec][plane][strip].subsector[ntow];
200  eta = mTowerMap[sec][plane][strip].etabin[ntow];
201  return;
202  }
203  void getTower( Int_t sec, Int_t plane, Int_t strip,
204  Int_t ntow, Int_t &sub, Int_t &eta, TString &name ) const {
205  sub = mTowerMap[sec][plane][strip].subsector[ntow];
206  eta = mTowerMap[sec][plane][strip].etabin[ntow];
207  name = mTowerMap[sec][plane][strip].towers[ntow];
208  return;
209  }
210 
211 private:
212 
213  void InitStrip2Strip();
214  static EEmcSmdMap *sInstance;
215 
216  EEmcStripMapItem mSmdMap[ kEEmcNumSectors ][ kEEmcNumSubSectors ][ kEEmcNumEtas ];
217  EEmcTowerMapItem mTowerMap[ kEEmcNumSectors ][ kEEmcNumSmdUVs ][ kEEmcNumStrips ];
218 
219  enum { mxS=3,mxI=2};
220 
221  EEmcStrip2StripMapItem *mSmd2SmdMap[ kEEmcNumSectors][kEEmcNumSmdUVs];
222  void Init();
223 
224  ClassDef(EEmcSmdMap,1);
225 };
226 
227 #endif