StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiDetector.h
1 #ifndef STI_DETECTOR_H
2 #define STI_DETECTOR_H
3 #include <vector>
4 #include <string>
5 #include <math.h>
6 #include "Stiostream.h"
7 using std::string;
8 #include "Sti/Base/Named.h"
9 #include "Sti/StiPlacement.h"
10 #include "StiIsActiveFunctor.h"
11 #include "StDetectorDbMaker/StiTrackingParameters.h"
12 #include "TString.h"
13 
14 class StiMaterial;
15 class StiShape;
16 template<class T> class StiCompositeTreeNode;
18 class StiElossCalculator;
19 class StiDetector;
20 
21 typedef std::vector<StiDetector*> StiDetVect;
22 
23 
29 class StiDetector : public Named
30 {
31 
32 public:
33 
34  friend class StiHit;
35 
36  // con/destructor
37  StiDetector();
38  virtual ~StiDetector();
39  void reset();
40  void unset(){;}
41  int splitIt(StiDetVect &vect,double thick=0.2,int nMax=20);
42 
43  // accessors
44  bool isOn() const { return true;}
45  inline bool isActive(double dYlocal, double dZlocal) const {return (*isActiveFunctor)(dYlocal, dZlocal);}
46  inline bool isActive() const { return isActiveFunctor->isActive();}
47  bool isDiscreteScatterer() const { return 0; }
48  int insideL(const double xl[3],int mode=1,double fakt=1) const ;
49  int insideG(const double xl[3],int mode=1,double fakt=1) const ;
50 
51 // Gas is under detector
52  StiMaterial* getGas() const { assert(gas); return gas; }
53  StiMaterial* getMaterial() const { assert(material) ;return material; }
54  double getCos() const { return _cos; }
55  double getSin() const { return _sin; }
56 
57  StiShape* getShape() const { return shape; }
58  StiPlacement* getPlacement() const { return placement; }
59 
60  StiIsActiveFunctor* getIsActiveFunctor() {return isActiveFunctor;}
61 
62  // mutators
63  void setIsOn(bool ) {;}
64  void setIsActive(StiIsActiveFunctor *val) { isActiveFunctor = val; }
65  void setIsContinuousMedium(bool ) {;}
66  void setIsDiscreteScatterer(bool) {;}
67 
68  void setGas(StiMaterial *val) { gas = val; }
69  void setMaterial(StiMaterial *val) { material = val; }
70 
71  void setShape(StiShape *val) { shape = val; }
72  void setPlacement(StiPlacement *val);
73  void setProperties(std::string name, StiIsActiveFunctor* activeFunctor, StiShape* shape, StiPlacement* placement,
75 
76  //action
77  virtual void build(){} //for now, build from SCL parsable ascii file
78 
79  virtual void copy(StiDetector &detector);
80 
81  //This is a bit of a hack, but we leave ourselves a reverse connection between
82  // a detector and the tree node that it's stored on.
83  void setTreeNode( StiCompositeTreeNode<StiDetector> * val) {mNode=val;}
84  StiCompositeTreeNode<StiDetector> * getTreeNode() const {return mNode;}
85 
86  void setHitErrorCalculator(const StiHitErrorCalculator * calculator) {_hitErrorCalculator = calculator;}
87  const StiHitErrorCalculator * getHitErrorCalculator() const {return _hitErrorCalculator;}
88 
89  void setGroupId(int id) { _groupId = _groupId < 0 ? id : _groupId; }
90  int getGroupId() const {return _groupId;}
91 
92  void setTrackingParameters(const StiTrackingParameters * pars) {_pars = pars;}
93  const StiTrackingParameters * getTrackingParameters() const {return _pars;}
94 
95  friend ostream& operator<<(ostream&os, const StiDetector & det);
96 
97  void setKey(int index,int value);
98  int getKey(int index) const;
99 
100  double getVolume() const;
101  double getWeight() const;
102  void getDetPlane(double plane[4]) const;
103 
104  static int mgIndex;
105  static double mgValue[2];
106 
107  protected:
108 
109  char mBeg[1];
110 
115 
118 
123 
130 
132  double _cos;
134  double _sin;
136  int _groupId = -1;
137  const StiTrackingParameters * _pars;
138  int _key1, _key2;
139 
140  char mEnd[1];
141 };
142 
143 
144 inline void StiDetector::setPlacement(StiPlacement *val)
145 {
146  placement = val;
147  _cos = cos(val->getNormalRefAngle());
148  _sin = sin(val->getNormalRefAngle());
149 }
150 
151 
152 inline void StiDetector::setKey(int index,int value)
153 {
154 switch (index)
155  {
156  case 1: _key1 = value; break;
157  case 2: _key2 = value; break;
158  }
159 }
160 
161 
162 inline int StiDetector::getKey(int index) const
163 {
164 switch (index)
165  {
166  case 1: return _key1;
167  case 2: return _key2;
168  }
169 return -1;
170 }
171 
172 #endif
void setProperties(std::string name, StiIsActiveFunctor *activeFunctor, StiShape *shape, StiPlacement *placement, StiMaterial *gas, StiMaterial *material)
friend ostream & operator<<(ostream &os, const StiHit &h)
Definition: StiHit.cxx:89
double _cos
Convenience storage of cos(refAngle)
Definition: StiDetector.h:132
int _groupId
Detector group identifier.
Definition: StiDetector.h:136
StiIsActiveFunctor * isActiveFunctor
Definition: StiDetector.h:114
StiCompositeTreeNode< StiDetector > * mNode
Pointer to the parent detector node.
Definition: StiDetector.h:129
Definition: StiHit.h:51
Definition: Named.h:16
const StiDetector * detector() const
Definition: StiHit.h:96
virtual Bool_t isActive() const
Returns whether the object is active.
StiMaterial * material
Discrete scatterer attributes.
Definition: StiDetector.h:122
StiPlacement * placement
Physical position and orientation of this detector or volume.
Definition: StiDetector.h:127
const StiHitErrorCalculator * _hitErrorCalculator
Hit Error Calculator for this detector.
Definition: StiDetector.h:117
StiMaterial * gas
Continuous scatter attributes.
Definition: StiDetector.h:120
function object for determine a detector&#39;s active regions
double _sin
Convenience storage of sin(refAngle)
Definition: StiDetector.h:134
StiShape * shape
Physical Shape attribute of this detector or voloume.
Definition: StiDetector.h:125