00001
00011 #include <iostream>
00012
00013 #include <TCutG.h>
00014 #include <TH2F.h>
00015
00016 #include "TGrDetector.h"
00017 #include "TCalibration.h"
00018 #include "TSubEvent.h"
00019
00020 using std::cout;
00021 using std::endl;
00022
00023 TGrDetector::TGrDetector(const Char_t *name, UInt_t channels)
00024 : TDetector(name, channels), fCalib(channels)
00025 {
00035 fAdcs.reserve(channels);
00036 fLeTdcs.reserve(channels);
00037 fCfTdcs.reserve(channels);
00038 }
00039
00040 TGrDetector::TGrDetector(const TGrDetector &rhs) : TDetector(rhs)
00041 {
00046 fAdcs = rhs.fAdcs;
00047 fLeTdcs = rhs.fLeTdcs;
00048 fCfTdcs = rhs.fCfTdcs;
00049 fCalib = rhs.fCalib;
00050 }
00051
00052 TGrDetector::~TGrDetector()
00053 {
00056 }
00057
00058 TGrDetector & TGrDetector::operator=(const TGrDetector &rhs)
00059 {
00065 if (&rhs != this) {
00066 TDetector::operator=(rhs);
00067 fAdcs = rhs.fAdcs;
00068 fLeTdcs = rhs.fLeTdcs;
00069 fCfTdcs = rhs.fCfTdcs;
00070 fCalib = rhs.fCalib;
00071 }
00072 return *this;
00073 }
00074
00075 void TGrDetector::Clear(const Char_t *option)
00076 {
00082 TDetector::Clear();
00083 fAdcs.clear();
00084 fLeTdcs.clear();
00085 fCfTdcs.clear();
00086 }
00087
00088 void TGrDetector::Print(const Char_t *option) const
00089 {
00096 TDetector::Print(option);
00097 fCalib.Print(option);
00098 if (option[0] == 'a')
00099 PrintData();
00100 }
00101
00102 void TGrDetector::PrintData() const
00103 {
00106 cout << "TGrDetector data:" << endl;
00107 for (vector<const TDataItem<UShort_t> *>::const_iterator it =
00108 fAdcs.begin(), end = fAdcs.end(); it < end; it++)
00109 (*it)->Print("adc: ");
00110 for (vector<const TDataItem<UShort_t> *>::const_iterator it =
00111 fLeTdcs.begin(), end = fLeTdcs.end(); it < end; it++)
00112 (*it)->Print("leTdc: ");
00113 for (vector<const TDataItem<UShort_t> *>::const_iterator it =
00114 fCfTdcs.begin(), end = fCfTdcs.end(); it < end; it++)
00115 (*it)->Print("cfTdc: ");
00116 for (vector<const TDataItem<Float_t> *>::const_iterator it =
00117 fEnergies.begin(), end = fEnergies.end(); it < end; it++)
00118 (*it)->Print("energy: ");
00119 for (vector<const TDataItem<Float_t> *>::const_iterator it =
00120 fTimes.begin(), end = fTimes.end(); it < end; it++)
00121 (*it)->Print("time: ");
00122 }
00123
00124 void TGrDetector::SetSignals(const TSubEvent &subEvent)
00125 {
00133 }
00134
00135 void TGrDetector::Calibrate()
00136 {
00140 fCalib.GetAdc().Calibrate(fAdcs, fEnergies);
00141 fCalib.GetLeTdc().Calibrate(fLeTdcs, fTimes);
00142 fCalib.GetCfTdc().Calibrate(fCfTdcs, fTimes);
00143 }
00144
00145 Bool_t
00146 TGrDetector::PlotEnergies(TH2F *hist, const TCutG *cut, Bool_t option) const
00147 {
00158 Bool_t status = false;
00159
00160 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00161 Float_t val = fEnergies[i]->GetValue();
00162 UShort_t chan = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00163 if (cut && cut->IsInside(val, chan))
00164 status = true;
00165 if (option || status)
00166 hist->Fill(val, chan);
00167 }
00168 return status;
00169 }
00170
00171 Bool_t TGrDetector::PlotChannels(TH1F *hist, Int_t lower,
00172 Int_t upper, Bool_t option) const
00173 {
00185 Bool_t status = false;
00186
00187 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00188 UShort_t channel =
00189 fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00190 if (lower != upper && channel >= lower && channel <= upper)
00191 status = true;
00192 if (option || status)
00193 hist->Fill(channel);
00194 }
00195 return status;
00196 }