StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEmcGeomSimple.h
1 // Hey Emacs this is really -*-c++-*- !
2 // \class EEmcGeomSimple
3 // \author Piotr A. Zolnierczuk
4 // \date Jan 14, 2003
5 #ifndef EEmcGeomSimple_h
6 #define EEmcGeomSimple_h
7 /*********************************************************************
8  * $Id: EEmcGeomSimple.h,v 1.27 2010/08/26 22:48:47 ogrebeny Exp $
9  *********************************************************************
10  * Description:
11  * STAR Endcap Electromagnetic Calorimeter Simple Geometry Class
12  *********************************************************************
13  */
14 
15 
16 #include "TObject.h"
17 #include "TVector3.h"
18 #include "TMath.h"
19 #include <math.h>
20 #include <StMessMgr.h>
21 
22 class EEmcGeomSimple : public TObject {
23 public:
24 
26  enum Chiral_t { CounterClockwise=-1, Clockwise=1, Undefined=0};
27 
31  virtual ~EEmcGeomSimple();
32 
38  TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const;
39 
47  TVector3 getDirection (const Float_t detaBin, const Float_t dphiBin) const;
48 
57  bool getTower(const TVector3& r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const;
58 
65  bool getTower(const TVector3& r, int &sec, int &sub, int &etabin) const {
66  Float_t dphi,deta;
67  return getTower(r,sec,sub,etabin,dphi,deta);
68  };
69 
70  const Float_t *getEtaBinRangeArray() const { return mEtaBin;}
71 
73  inline Float_t getZ1() const { return mZ1; };
75  inline Float_t getZ2() const { return mZ2; };
77  inline Float_t getZSMD() const { return mZSMD;};
79  inline Float_t getEtaMin() const { return mEtaBin[0]; };
81  inline Float_t getEtaMax() const { return mEtaBin[mNumEta]; };
82 
85  inline Float_t getEtaMean(UInt_t eta) const {
86  if (mNumEta<=eta) {
87  LOG_ERROR << "getEtaHalfWidth: invalid eta index " << eta << endm;
88  return 0;
89  } else {
90  return 0.5 * ( mEtaBin[eta] + mEtaBin[eta+1] );
91  }
92  }
93 
96  inline Float_t getEtaHalfWidth(UInt_t eta) const {
97  if(mNumEta<=eta) {
98  LOG_ERROR << "getEtaHalfWidth: invalid eta index" << eta << endm;
99  return 0;
100  } else {
101  return 0.5 * fabs( mEtaBin[eta] - mEtaBin[eta+1] );
102  }
103  }
104 
107  inline Float_t getPhiMean(UInt_t sec) const {
108  //const double dPhi=2.0*M_PI/mNumSec;
109  const double dPhi= TMath::TwoPi()/mNumSec;
110  if(mNumSec<=sec) {
111  LOG_ERROR << "getPhiMean: invalid sector index" << sec << endm;
112  return 0;
113  } else {
114  return AdjustAngle(mClock*(sec+0.5L)*dPhi+mPhi0);
115  }
116  }
117 
121  inline Float_t getPhiMean(UInt_t sec, UInt_t ssec) const {
122  //const double dPhi=2.0*M_PI/mNumSec;
123  const double dPhi=TMath::TwoPi()/mNumSec;
124  if(mNumSec <=sec ) {
125  LOG_ERROR << "getPhiMean: invalid sector index " << sec << endm;
126  return 0;
127  } else if(mNumSSec<=ssec) {
128  LOG_ERROR << "getPhiMean: invalid subsector index " << ssec << endm;
129  return 0;
130  } else {
131  return AdjustAngle(mClock*(Double_t(sec)+(ssec+0.5L)/mNumSSec)*dPhi+mPhi0);
132  }
133  }
134 
138  inline Float_t getPhiHalfWidth(UInt_t sec=0, UInt_t ssec=0) const {
139  //const double dPhi=2.0*M_PI/mNumSec;
140  const double dPhi=TMath::TwoPi()/mNumSec;
141  if(mNumSec <=sec ) {
142  LOG_ERROR << "getPhiMean: invalid sector index " << sec << endm;
143  return 0;
144  } else if(mNumSSec<=ssec) {
145  LOG_ERROR << "getPhiMean: invalid subsector index " << ssec << endm;
146  return 0;
147  } else {
148  return (Float_t)(0.5L/mNumSSec*dPhi);
149  }
150  }
151 
153  inline Float_t getZMean() const {
154  return (Float_t)(0.5L*(mZ1+mZ2));
155  }
156 
158  inline Float_t getZHalfWidth() const {
159  return (Float_t)(0.5L*fabs(mZ1-mZ2));
160  }
161 
162 
164  inline Int_t getNumberOfEtas() const { return mNumEta; }
166  inline Int_t getNumberOfSectors() const { return mNumSec; }
168  inline Int_t getNumberOfSubSectors() const { return mNumSSec; }
171  inline Float_t getPhi0() const { return mPhi0; };
173  inline Bool_t isClockwise() const { return ( mClock == Clockwise ); };
175  inline Bool_t isCounterClockwise() const { return ( mClock == CounterClockwise ); }
176 
178  static EEmcGeomSimple& Instance() { return sInstance; }
179 
180 
181 
182 protected:
183  Float_t mZ1 ; // z preshower)
184  Float_t mZ2 ; // z postshower)
185  Float_t mZSMD ; // z smd
186  Float_t *mEtaBin; // eta bins [0,mNumEta)
187  UInt_t mNumEta; // number of eta bins
188  UInt_t mNumSec; // number of sectors (in phi)
189  UInt_t mNumSSec; // number of subsectors (in phi)
190  Double_t mPhi0; // phi0 of the 0th sector
191  Chiral_t mClock; // +1 == clockwise -1 == counter-clockwise
192 
193  void useDefaultGeometry();
194 
195  // adjust angle so it falls into [-pi,pi] interval
196  static inline double AdjustAngle(double alpha) {
197  while(alpha<-TMath::Pi() ) alpha += TMath::TwoPi();
198  while(alpha> TMath::Pi() ) alpha -= TMath::TwoPi();
199  return alpha;
200  }
201 
202 
203 private:
204  static EEmcGeomSimple sInstance;
205 
206 
207  ClassDef(EEmcGeomSimple,2) // STAR Endcap Electromagnetic Calorimeter Simple Geometry Class
208 
209 };
210 
211 #endif
212 
213 
214 /*********************************************************************
215  * $Log: EEmcGeomSimple.h,v $
216  * Revision 1.27 2010/08/26 22:48:47 ogrebeny
217  * Improved constness
218  *
219  * Revision 1.26 2009/02/11 20:04:24 ogrebeny
220  * 1. Fix the sectors initialization.
221  * 2. Remove exceptions from the geom code.
222  *
223  * Revision 1.25 2007/07/12 19:30:14 fisyak
224  * Add includes for ROOT 5.16
225  *
226  * Revision 1.24 2005/07/15 20:53:09 balewski
227  * more get methods
228  *
229  * Revision 1.23 2005/02/07 19:44:37 jwebb
230  * *** empty log message ***
231  *
232  * Revision 1.22 2005/02/07 19:26:09 jwebb
233  * Clarified documentation for EEmcGeomSimple::getDirection(...).
234  *
235  * Revision 1.21 2005/02/05 00:57:38 perev
236  * TMath is namespace now
237  *
238  * Revision 1.20 2004/06/03 20:59:54 zolnie
239  * - phi angle now adjusted to [-pi,pi] interval in accordace to TVecror3 convention
240  * - replaced Jan's interesting implementation of direction2tower method with
241  * a resurrected getTower (formerly getHit) method see EEmcGeomSimple.h
242  *
243  * Revision 1.19 2004/06/01 21:20:49 balewski
244  * direction2tower ()
245  *
246  * Revision 1.18 2004/05/25 15:32:37 zolnie
247  * phi angles adjusted to [0,2pi] interval
248  *
249  * Revision 1.17 2004/05/24 18:33:40 zolnie
250  * comment cleanup, added a small exception class
251  * more argument checking, exception thrown when argument invalid
252  *
253  * Revision 1.16 2004/05/20 21:12:08 zolnie
254  * added a static instance of EEmcGeomSimple
255  *
256  * Revision 1.15 2004/01/26 21:12:19 zolnie
257  * added one one more quick member getPhiMean with one argument
258  * returns phi for a sector rather than a subsector
259  *
260  * Revision 1.14 2004/01/19 20:19:44 zolnie
261  * added getEtaMin and getEtaMax inline members
262  *
263  * Revision 1.13 2003/05/23 22:13:04 zolnie
264  * SUN does not like inlines (why??)
265  *
266  * Revision 1.12 2003/04/25 15:53:54 zolnie
267  * always initalize
268  *
269  * Revision 1.11 2003/04/23 18:11:31 balewski
270  * 'continous' eta & phi bins added
271  *
272  * Revision 1.10 2003/03/22 23:59:00 zolnie
273  * standalone modifications
274  *
275  * Revision 1.9 2003/03/22 22:44:57 zolnie
276  * make it standalone library
277  *
278  * Revision 1.8 2003/03/06 18:54:21 zolnie
279  * improvements for track/tower matching
280  *
281  * Revision 1.7 2003/02/20 21:47:25 zolnie
282  * *** empty log message ***
283  *
284  * Revision 1.4 2003/01/19 03:47:11 zolnie
285  * still further improvements
286  *
287  * Revision 1.3 2003/01/18 02:35:54 zolnie
288  * further modifications
289  *
290  * Revision 1.1 2003/01/16 19:33:51 zolnie
291  * added a simple Geom class to conver a track hit -> tower hit
292  *
293  ********************************************************************
294 */
295 
Bool_t isClockwise() const
is endcap labeling clockwise?
Int_t getNumberOfSectors() const
gets number of sectors
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
Float_t getZHalfWidth() const
returns the half-width of EEMC (in z-direction)
Float_t getZ1() const
gets lower Z edge of EEMC (preshower)
Float_t getZ2() const
gets upper Z edge of EEMC (postshower)
Float_t getEtaMin() const
gets lower eta limit
static EEmcGeomSimple & Instance()
returns a reference to a static instance of EEmcGeomSimple
Chiral_t
chirality defined
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin) const
Float_t getEtaHalfWidth(UInt_t eta) const
Float_t getZMean() const
returns the center of EEMC in z direction
Float_t getPhi0() const
EEmcGeomSimple()
default constructor
Int_t getNumberOfEtas() const
gets number of tiles (eta bins)
virtual ~EEmcGeomSimple()
the destructor
Float_t getPhiMean(UInt_t sec) const
Float_t getZSMD() const
gets z-depth of the SMD layer in EEMC
TVector3 getDirection(const Float_t detaBin, const Float_t dphiBin) const
Float_t getPhiHalfWidth(UInt_t sec=0, UInt_t ssec=0) const
EEMC simple geometry.
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
Float_t getEtaMax() const
gets upper eta bound
Float_t getPhiMean(UInt_t sec, UInt_t ssec) const
Int_t getNumberOfSubSectors() const
gets number of subsectors
Bool_t isCounterClockwise() const
is endcap labeling clockwise?
Float_t getEtaMean(UInt_t eta) const