00001 #ifndef STI_DETECTOR_H
00002 #define STI_DETECTOR_H
00003 #include <vector>
00004 #include <string>
00005 #include <math.h>
00006 #include "Stiostream.h"
00007 using std::string;
00008 #include "Sti/Base/Named.h"
00009 #include "Sti/StiPlacement.h"
00010 #include "StiIsActiveFunctor.h"
00011 #include "StDetectorDbMaker/StiTrackingParameters.h"
00012
00013 class StiMaterial;
00014 class StiShape;
00015 template<class T> class StiCompositeTreeNode;
00016 class StiHitErrorCalculator;
00017 class StiElossCalculator;
00018
00024 class StiDetector : public Named
00025 {
00026
00027 public:
00028
00029 friend class StiHit;
00030
00031
00032 StiDetector();
00033 virtual ~StiDetector();
00034 void reset();
00035 void unset(){;}
00036
00037
00038 bool isOn() const { return on;}
00039 inline bool isActive(double dYlocal, double dZlocal) const {return (*isActiveFunctor)(dYlocal, dZlocal);}
00040 inline bool isActive() const {return isActiveFunctor->isActive();}
00041 bool isContinuousMedium() const { return continuousMedium; }
00042 bool isDiscreteScatterer() const { return discreteScatterer; }
00043
00044 StiMaterial* getGas() const { return gas; }
00045 StiMaterial* getMaterial() const { return material; }
00046
00047 StiShape* getShape() const { return shape; }
00048 StiPlacement* getPlacement() const { return placement; }
00049
00050 StiIsActiveFunctor* getIsActiveFunctor() {return isActiveFunctor;}
00051
00052
00053 void setIsOn(bool val) {on = val;}
00054 void setIsActive(StiIsActiveFunctor *val){ isActiveFunctor = val; }
00055 void setIsContinuousMedium(bool val) {continuousMedium = val;}
00056 void setIsDiscreteScatterer(bool val) {discreteScatterer = val;}
00057
00058 void setGas(StiMaterial *val){ gas = val; }
00059 void setMaterial(StiMaterial *val){ material = val; }
00060
00061 void setShape(StiShape *val){ shape = val; }
00062 void setPlacement(StiPlacement *val)
00063 {
00064 placement = val;
00065 _cos = cos(val->getNormalRefAngle());
00066 _sin = sin(val->getNormalRefAngle());
00067 }
00068
00069
00070 virtual void build(){}
00071
00072 virtual void copy(StiDetector &detector);
00073
00074
00075
00076 void setTreeNode( StiCompositeTreeNode<StiDetector> * val) {mNode=val;}
00077 StiCompositeTreeNode<StiDetector> * getTreeNode() const {return mNode;}
00078
00079 void setHitErrorCalculator(const StiHitErrorCalculator * calculator) {_hitErrorCalculator = calculator;}
00080 const StiHitErrorCalculator * getHitErrorCalculator() const {return _hitErrorCalculator;}
00081
00082 void setGroupId(int id) { _groupId = id;}
00083 int getGroupId() const {return _groupId;}
00084
00085 void setTrackingParameters(const StiTrackingParameters * pars) {_pars = pars;}
00086 const StiTrackingParameters * getTrackingParameters() const {return _pars;}
00087
00088 friend ostream& operator<<(ostream&os, const StiDetector & det);
00089
00090 void setKey(int index,int value)
00091 {
00092 switch (index)
00093 {
00094 case 1: _key1 = value; break;
00095 case 2: _key2 = value; break;
00096 }
00097 }
00098
00099 int getKey(int index) const
00100 {
00101 switch (index)
00102 {
00103 case 1: return _key1;
00104 case 2: return _key2;
00105 }
00106 return -1;
00107 }
00108
00109 void setElossCalculator(StiElossCalculator * calculator)
00110 {
00111 _elossCalculator = calculator;
00112 }
00113
00114 StiElossCalculator * getElossCalculator() const
00115 {
00116 return _elossCalculator;
00117 }
00118
00119 protected:
00120
00121 char mBeg[1];
00122
00125 bool on;
00129 StiIsActiveFunctor *isActiveFunctor;
00133 bool continuousMedium;
00137 bool discreteScatterer;
00138
00140 const StiHitErrorCalculator * _hitErrorCalculator;
00141
00143 StiMaterial *gas;
00145 StiMaterial *material;
00146
00148 StiShape *shape;
00150 StiPlacement *placement;
00152 StiCompositeTreeNode<StiDetector> * mNode;
00153
00155 double _cos;
00157 double _sin;
00159 int _groupId;
00160 const StiTrackingParameters * _pars;
00161 int _key1, _key2;
00162
00163 StiElossCalculator * _elossCalculator;
00164 char mEnd[1];
00165 };
00166 #endif