00001
00010 #include <iostream>
00011 #include <sstream>
00012
00013 #include <TH2F.h>
00014 #include <TCutG.h>
00015
00016 #include "TIcDetector.h"
00017 #include "TSubEvent.h"
00018 #include "THit.h"
00019
00020 using std::cout;
00021 using std::endl;
00022 using std::stringstream;
00023
00024 TIcDetector::TIcDetector(const Char_t *name, UInt_t channels)
00025 : THiDetector(name, channels)
00026 {
00034 stringstream plate;
00035 fPlateNames.assign(channels, name);
00036
00037 for (unsigned int i = 0; i < channels; i++) {
00038 plate << i;
00039 fPlateNames[i].push_back('_');
00040 fPlateNames[i] += plate.str().data();
00041 plate.str(string());
00042 }
00043 }
00044
00045 TIcDetector::~TIcDetector()
00046 {
00049 }
00050
00051 void TIcDetector::Print(const Char_t *option) const
00052 {
00059 cout << "IC detector:" << endl;
00060 THiDetector::Print(option);
00061 }
00062
00063 void TIcDetector::SetSignals(const TSubEvent &subEvent)
00064 {
00073 const vector<TDataItem<UShort_t> > &adcs = subEvent.GetAdcs();
00074
00075 for (UInt_t i = 0; i < adcs.size(); i++)
00076 if (fCalib.GetAdc().TestChannel(adcs[i].GetChannel())) {
00077 fAdcs.push_back(&adcs[i]);
00078 fHit = true;
00079 }
00080 }
00081
00082 void TIcDetector::FindHits(vector<THit> *hits) const
00083 {
00092 THit p;
00093
00094 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00095 p.SetDetector(fPlateNames[fEnergies[i]->GetChannel()].data());
00096 p.SetEnergy(fEnergies[i]->GetValue());
00097 hits->push_back(p);
00098 }
00099 }
00100
00101 Bool_t
00102 TIcDetector::PlotHitPattern(TH2F *hist, const TCutG *cut, Bool_t option) const
00103 {
00113 Bool_t status = false;
00114
00115 for (UInt_t i = 0; i < fEnergies.size(); i++)
00116 for (UInt_t j = 0; j < fTimes.size(); j++) {
00117 UShort_t x = fCalib.GetTdc().GetHistogramMap(fTimes[j]->GetChannel());
00118 UShort_t y = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00119 if (cut && cut->IsInside(x, y))
00120 status = true;
00121 if (option || status)
00122 hist->Fill(x, y);
00123 }
00124 return status;
00125 }
00126
00127 Bool_t TIcDetector::PlotEvT(TH2F *hist, Float_t time,
00128 const TCutG *cut, Bool_t option) const
00129 {
00140 Bool_t status = false;
00141
00142 for (UInt_t i = 0; i < fEnergies.size() &&
00143 fEnergies[i]->GetChannel() == 0; i++) {
00144 Float_t energy = fEnergies[i]->GetValue();
00145 if (cut && cut->IsInside(time, energy))
00146 status = true;
00147 if (option || status)
00148 hist->Fill(time, energy);
00149 }
00150 return status;
00151 }
00152
00153 Bool_t TIcDetector::PlotAnodeSum(TH1F *hist, Int_t lower,
00154 Int_t upper, Bool_t option) const
00155 {
00165 Bool_t status = false;
00166 Float_t sum = 0;
00167
00168 for (UInt_t i = 0; i < fEnergies.size(); i++)
00169 sum += fEnergies[i]->GetValue();
00170 if (lower != upper && sum >= lower && sum <= upper)
00171 status = true;
00172 if (option || status)
00173 hist->Fill(sum);
00174 return status;
00175 }
00176
00177 Bool_t TIcDetector::PlotEdE(TH2F *hist, UShort_t echan, UShort_t dechan,
00178 const TCutG *cut, Bool_t option) const
00179 {
00190 Bool_t status = false;
00191 Float_t e = 0;
00192 Float_t de = 0;
00193
00194 for (UInt_t i = 0; i < fEnergies.size(); i++)
00195 if (fEnergies[i]->GetChannel() == echan)
00196 e = fEnergies[i]->GetValue();
00197 else if (fEnergies[i]->GetChannel() == dechan)
00198 de = fEnergies[i]->GetValue();
00199 if (cut && cut->IsInside(e, de))
00200 status = true;
00201 if ((option || status) && e && de)
00202 hist->Fill(e, de);
00203 return status;
00204 }