00001
00002
00003
00004
00005
00006
00007 #ifndef TDETECTOR_H
00008 #define TDETECTOR_H
00009
00010 #include <vector>
00011 #include <sstream>
00012
00013 #include <TVector3.h>
00014
00015 #include "TDataItem.h"
00016
00017 class TH1F;
00018 class TH2F;
00019 class TCutG;
00020 class THit;
00021
00022 using std::string;
00023 using std::vector;
00024
00025 class TDetector {
00026 public:
00027 TDetector(const Char_t * = "", UInt_t = 1);
00028 TDetector(const TDetector &);
00029 virtual ~TDetector();
00030 TDetector & operator=(const TDetector &);
00031 virtual void Clear(const Char_t * = "");
00032 virtual void Print(const Char_t * = "") const;
00033 virtual const Char_t * GetName() const;
00034 virtual void PrintData() const = 0;
00035 virtual void Calibrate() = 0;
00036 virtual Bool_t PlotEnergies(TH2F * = 0, const TCutG * = 0, Bool_t = 1) const;
00037 virtual Bool_t PlotTimes(TH2F * = 0, const TCutG * = 0, Bool_t = 1) const;
00038 virtual Bool_t PlotEvT(TH2F * = 0, Float_t = 0,
00039 const TCutG * = 0, Bool_t = 1) const;
00040 virtual void FindHits(vector<THit> *) const;
00041 Float_t GetMaxEnergy() const;
00042 void SetName(const Char_t *);
00043 void SetChannels(UInt_t);
00044 void SetCoordinates(Float_t, Float_t, Float_t);
00045 UInt_t GetChannels() const;
00046 const TVector3 & GetCoordinates() const;
00047 const vector<const TDataItem<Float_t> *> & GetEnergies() const;
00048 const vector<const TDataItem<Float_t> *> & GetTimes() const;
00049 void Hit(Bool_t);
00050 Bool_t IsHit() const;
00051 Bool_t IsName(const Char_t *) const;
00052
00053 protected:
00060 vector<const TDataItem<Float_t> *> fEnergies;
00067 vector<const TDataItem<Float_t> *> fTimes;
00070 TVector3 fCoordinates;
00073 Bool_t fHit;
00074
00075 private:
00078 UInt_t fChannels;
00081 string fName;
00082 };
00083
00084 inline void TDetector::SetName(const Char_t *name)
00085 {
00091 fName = name;
00092 }
00093
00094 inline void TDetector::SetChannels(UInt_t channels)
00095 {
00100 fChannels = (channels > 0 ? channels : 0 );
00101 }
00102
00103 inline void TDetector::SetCoordinates(Float_t x, Float_t y, Float_t z)
00104 {
00110 fCoordinates.SetXYZ(x, y, z);
00111 }
00112
00113 inline const Char_t * TDetector::GetName() const
00114 {
00118 return fName.c_str();
00119 }
00120
00121 inline UInt_t TDetector::GetChannels() const
00122 {
00127 return fChannels;
00128 }
00129
00130 inline const TVector3 & TDetector::GetCoordinates() const
00131 {
00135 return fCoordinates;
00136 }
00137
00138 inline const vector<const TDataItem<Float_t> *> & TDetector::GetEnergies() const
00139 {
00143 return fEnergies;
00144 }
00145
00146 inline const vector<const TDataItem<Float_t> *> & TDetector::GetTimes() const
00147 {
00151 return fTimes;
00152 }
00153
00154 inline void TDetector::Hit(Bool_t status)
00155 {
00160 fHit = status;
00161 }
00162
00163 inline Bool_t TDetector::IsHit() const
00164 {
00168 return fHit;
00169 }
00170
00171 inline Bool_t TDetector::IsName(const Char_t *name) const
00172 {
00176 return string(name) == fName;
00177 }
00178
00188 template<typename T>
00189 class EqualDetector;
00190
00191 template<typename T>
00192 class EqualDetector {
00193 public:
00196 Bool_t operator()(TDetector *) const;
00197 };
00198
00199 template<typename T>
00200 inline Bool_t EqualDetector<T>::operator()(TDetector *a) const
00201 {
00205 return dynamic_cast<T *>(a);
00206 }
00207
00217 class GreaterDetectorE {
00218 public:
00219 Bool_t operator()(TDetector *, TDetector *) const;
00220 };
00221
00222 inline Bool_t GreaterDetectorE::operator()(TDetector *a, TDetector *b) const
00223 {
00229 return a->GetMaxEnergy() > b->GetMaxEnergy();
00230 }
00231
00232 #endif // TDetector.h