00001
00011 #include <iostream>
00012
00013 #include <TCutG.h>
00014 #include <TH2F.h>
00015
00016 #include "THiDetector.h"
00017 #include "TCalibration.h"
00018 #include "TSubEvent.h"
00019
00020 using std::cout;
00021 using std::endl;
00022
00023 THiDetector::THiDetector(const Char_t *name, UInt_t channels)
00024 : TDetector(name, channels), fCalib(channels)
00025 {
00034 fAdcs.reserve(channels);
00035 fTdcs.reserve(channels);
00036 }
00037
00038 THiDetector::THiDetector(const THiDetector &rhs) : TDetector(rhs)
00039 {
00044 fAdcs = rhs.fAdcs;
00045 fTdcs = rhs.fTdcs;
00046 fCalib = rhs.fCalib;
00047 }
00048
00049 THiDetector::~THiDetector()
00050 {
00053 }
00054
00055 THiDetector & THiDetector::operator=(const THiDetector &rhs)
00056 {
00062 if (&rhs != this) {
00063 TDetector::operator=(rhs);
00064 fAdcs = rhs.fAdcs;
00065 fTdcs = rhs.fTdcs;
00066 fCalib = rhs.fCalib;
00067 }
00068 return *this;
00069 }
00070
00071 void THiDetector::Clear(const Char_t *option)
00072 {
00076 TDetector::Clear();
00077 fAdcs.clear();
00078 fTdcs.clear();
00079 }
00080
00081 void THiDetector::Print(const Char_t *option) const
00082 {
00089 TDetector::Print(option);
00090 fCalib.Print(option);
00091 if (option[0] == 'a')
00092 PrintData();
00093 }
00094
00095 void THiDetector::PrintData() const
00096 {
00099 cout << "THiDetector data:" << endl;
00100 for (vector<const TDataItem<UShort_t> *>::const_iterator it =
00101 fAdcs.begin(), end = fAdcs.end(); it < end; it++)
00102 (*it)->Print("adc: ");
00103 for (vector<const TDataItem<UShort_t> *>::const_iterator it =
00104 fTdcs.begin(), end = fTdcs.end(); it < end; it++)
00105 (*it)->Print("tdc: ");
00106 for (vector<const TDataItem<Float_t> *>::const_iterator it =
00107 fEnergies.begin(), end = fEnergies.end(); it < end; it++)
00108 (*it)->Print("energy: ");
00109 for (vector<const TDataItem<Float_t> *>::const_iterator it =
00110 fTimes.begin(), end = fTimes.end(); it < end; it++)
00111 (*it)->Print("time: ");
00112 }
00113
00114 void THiDetector::SetSignals(const TSubEvent &subEvent)
00115 {
00123 }
00124
00125 void THiDetector::Calibrate()
00126 {
00129 fCalib.GetAdc().Calibrate(fAdcs, fEnergies);
00130 fCalib.GetTdc().Calibrate(fTdcs, fTimes);
00131 }
00132
00133 Bool_t
00134 THiDetector::PlotEnergies(TH2F *hist, const TCutG *cut, Bool_t option) const
00135 {
00146 Bool_t status = false;
00147
00148 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00149 Float_t val = fEnergies[i]->GetValue();
00150 UShort_t chan = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00151 if (cut && cut->IsInside(val, chan))
00152 status = true;
00153 if (option || status)
00154 hist->Fill(val, chan);
00155 }
00156 return status;
00157 }
00158
00159 Bool_t THiDetector::PlotTimes(TH2F *hist, const TCutG *cut, Bool_t option) const
00160 {
00171 Bool_t status = false;
00172
00173 for (UInt_t i = 0; i < fTimes.size(); i++) {
00174 Float_t val = fTimes[i]->GetValue();
00175 UShort_t chan = fCalib.GetTdc().GetHistogramMap(fTimes[i]->GetChannel());
00176 if (cut && cut->IsInside(val, chan))
00177 status = true;
00178 if (option || status)
00179 hist->Fill(val, chan);
00180 }
00181 return status;
00182 }
00183
00184 Bool_t THiDetector::PlotEvT(TH2F *hist, Float_t time, const TCutG *cut,
00185 Bool_t option) const
00186 {
00199 Bool_t status = false;
00200
00201 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00202 Float_t val = fEnergies[i]->GetValue();
00203 if (cut && cut->IsInside(time, val))
00204 status = true;
00205 if (option || status)
00206 hist->Fill(time, val);
00207 }
00208 return status;
00209 }