00001
00012 #include <iostream>
00013
00014 #include <TH2F.h>
00015 #include <TCutG.h>
00016
00017 #include "TBgoDetector.h"
00018 #include "TSubEvent.h"
00019 #include "THit.h"
00020
00021 using std::cout;
00022 using std::endl;
00023
00024 TBgoDetector::TBgoDetector(const Char_t *name, UInt_t channels)
00025 : TGrDetector(name, channels)
00026 {
00034 }
00035
00036 TBgoDetector::~TBgoDetector()
00037 {
00040 }
00041
00042 void TBgoDetector::Print(const Char_t *option) const
00043 {
00050 cout << "BGO detector:" << endl;
00051 TGrDetector::Print(option);
00052 }
00053
00054 void TBgoDetector::SetSignals(const TSubEvent &subEvent)
00055 {
00064 const vector<TDataItem<UShort_t> > &adcs = subEvent.GetAdcs();
00065 const vector<TDataItem<UShort_t> > &tdcs = subEvent.GetTdcs();
00066
00067 for (UInt_t i = 0; i < adcs.size(); i++)
00068 if (fCalib.GetAdc().TestChannel(adcs[i].GetChannel())) {
00069 fAdcs.push_back(&adcs[i]);
00070 fHit = true;
00071 }
00072 for (UInt_t i = 0; i < tdcs.size(); i++)
00073 if (fCalib.GetLeTdc().TestChannel(tdcs[i].GetChannel())) {
00074 fLeTdcs.push_back(&tdcs[i]);
00075 }
00076 for (UInt_t i = 0; i < tdcs.size(); i++)
00077 if (fCalib.GetCfTdc().TestChannel(tdcs[i].GetChannel())) {
00078 fCfTdcs.push_back(&tdcs[i]);
00079 }
00080 }
00081
00082 void TBgoDetector::FindHits(vector<THit> *hits) const
00083 {
00092
00093
00094
00095 THit p;
00096
00097 if (fEnergies.size() && fEnergies[0]->GetValue() > 0) {
00098 p.SetEnergy(fEnergies[0]->GetValue());
00099 if (fTimes.size())
00100 p.SetTime(fTimes[0]->GetValue());
00101 p.SetDetector(GetName());
00102 p.SetPosition(fCoordinates.X(), fCoordinates.Y(), fCoordinates.Z());
00103 hits->push_back(p);
00104 }
00105 }
00106
00107 void TBgoDetector::SetXYZ(Int_t x, Int_t y, Int_t z)
00108 {
00116 fCoordinates.SetXYZ(x, y, z);
00117 }
00118
00119 Bool_t TBgoDetector::PlotShiftedEnergies(TH2F *hist, Float_t valueShift,
00120 const TCutG *cut, Bool_t option) const
00121 {
00126 Bool_t status = false;
00127
00128 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00129 Float_t val = fEnergies[i]->GetValue();
00130 UShort_t chan = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00131 val += valueShift;
00132 if (cut && cut->IsInside(val, chan))
00133 status = true;
00134 if (option || status)
00135 hist->Fill(val, chan);
00136 }
00137 return status;
00138 }