00001
00010 #include <iostream>
00011 #include <iomanip>
00012
00013 #include "TDetector.h"
00014 #include "THit.h"
00015
00016 using std::cout;
00017 using std::cerr;
00018 using std::endl;
00019 using std::setw;
00020
00021 TDetector::TDetector(const Char_t *name, UInt_t channels)
00022 : fHit(false), fChannels(channels), fName(name)
00023 {
00029 fEnergies.reserve(channels);
00030 fTimes.reserve(channels);
00031 }
00032
00033 TDetector::TDetector(const TDetector &rhs)
00034 {
00039 vector<const TDataItem<Float_t> *>::const_iterator it;
00040 vector<const TDataItem<Float_t> *>::const_iterator end;
00041 for (it = rhs.fEnergies.begin(), end = rhs.fEnergies.end(); it < end; it++)
00042 fEnergies.push_back(*it);
00043 for (it = rhs.fTimes.begin(), end = rhs.fTimes.end(); it < end; it++)
00044 fTimes.push_back(*it);
00045 fCoordinates = rhs.fCoordinates;
00046 fHit = rhs.fHit;
00047 fChannels = rhs.fChannels;
00048 fName = rhs.fName;
00049 }
00050
00051 TDetector::~TDetector()
00052 {
00055 Clear();
00056 }
00057
00058 TDetector & TDetector::operator=(const TDetector &rhs)
00059 {
00065 if (&rhs != this) {
00066 vector<const TDataItem<Float_t> *>::const_iterator it;
00067 vector<const TDataItem<Float_t> *>::const_iterator end;
00068 Clear();
00069 for (it = rhs.fEnergies.begin(), end = rhs.fEnergies.end(); it < end; it++)
00070 fEnergies.push_back(*it);
00071 for (it = rhs.fTimes.begin(), end = rhs.fTimes.end(); it < end; it++)
00072 fTimes.push_back(*it);
00073 fCoordinates = rhs.fCoordinates;
00074 fHit = rhs.fHit;
00075 fChannels = rhs.fChannels;
00076 fName = rhs.fName;
00077 }
00078 return *this;
00079 }
00080
00081 void TDetector::Clear(const Char_t *option)
00082 {
00086 vector<const TDataItem<Float_t> *>::iterator it;
00087 vector<const TDataItem<Float_t> *>::iterator end;
00088 for (it = fEnergies.begin(), end = fEnergies.end(); it < end; it++)
00089 delete *it;
00090 fEnergies.clear();
00091 for (it = fTimes.begin(), end = fTimes.end(); it < end; it++)
00092 delete *it;
00093 fTimes.clear();
00094 fHit = false;
00095 }
00096
00097 void TDetector::Print(const Char_t *option) const
00098 {
00102 if (! fChannels)
00103 cout << "Print: WARNING - detector channels set to 0" << endl;
00104 if (fName.empty())
00105 cout << "Print: WARNING - detector name not set" << endl;
00106 else {
00107 cout << "Detector " << fName << " with " << fChannels;
00108 fChannels != 1 ? cout << " channels" << endl : cout << " channel" << endl;
00109 }
00110 fCoordinates.Print();
00111 }
00112
00113 void TDetector::PrintData() const
00114 {
00118 }
00119
00120 void TDetector::Calibrate()
00121 {
00126 }
00127
00128 Bool_t
00129 TDetector::PlotEnergies(TH2F *hist, const TCutG *cut, Bool_t option) const
00130 {
00141 return false;
00142 }
00143
00144 Bool_t TDetector::PlotTimes(TH2F *hist, const TCutG *cut, Bool_t option) const
00145 {
00156 return false;
00157 }
00158
00159 Bool_t TDetector::PlotEvT(TH2F *hist, Float_t time,
00160 const TCutG *cut, Bool_t option) const
00161 {
00174 return false;
00175 }
00176
00177 void TDetector::FindHits(vector<THit> *hits) const
00178 {
00186 }
00187
00188 Float_t TDetector::GetMaxEnergy() const
00189 {
00193 vector<const TDataItem<Float_t> *>::const_iterator max =
00194 max_element(fEnergies.begin(), fEnergies.end(), GreaterValue<Float_t>());
00195 return (max != fEnergies.end()) ? (*max)->GetValue() : 0;
00196 }