00001
00011 #include <iostream>
00012
00013 #include <TH3F.h>
00014 #include <TH2F.h>
00015 #include <TCutG.h>
00016
00017 #include "TDsssdDetector.h"
00018 #include "TSubEvent.h"
00019 #include "THit.h"
00020
00021 using std::cout;
00022 using std::endl;
00023
00024 TDsssdDetector::TDsssdDetector(const Char_t *name, UInt_t channels,
00025 Float_t stripWidth, Float_t stripSpacing)
00026 : THiDetector(name, channels), fStripWidth(stripWidth),
00027 fStripSpacing(stripSpacing)
00028 {
00038 }
00039
00040 TDsssdDetector::~TDsssdDetector()
00041 {
00044 }
00045
00046 void TDsssdDetector::Print(const Char_t *option) const
00047 {
00054 cout <<"DSSSD detector:" << endl;
00055 THiDetector::Print(option);
00056 }
00057
00058 void TDsssdDetector::SetSignals(const TSubEvent &subEvent)
00059 {
00068 const vector<TDataItem<UShort_t> > &adcs = subEvent.GetAdcs();
00069 const vector<TDataItem<UShort_t> > &tdcs = subEvent.GetTdcs();
00070
00071 for (UInt_t i = 0; i < adcs.size(); i++)
00072 if (fCalib.GetAdc().TestChannel(adcs[i].GetChannel())) {
00073 fAdcs.push_back(&adcs[i]);
00074 fHit = true;
00075 }
00076 for (UInt_t i = 0; i < tdcs.size(); i++)
00077 if (fCalib.GetTdc().TestChannel(tdcs[i].GetChannel())) {
00078 fTdcs.push_back(&tdcs[i]);
00079 }
00080 }
00081
00082 void TDsssdDetector::FindHits(vector<THit> *hits) const
00083 {
00094
00095
00096
00097
00098 UShort_t chansOneSide = GetChannels() / 2;
00099 THit p;
00100
00101
00102
00103
00104
00105 vector<const TDataItem<Float_t> *> hitsB;
00106 vector<const TDataItem<Float_t> *> hitsF;
00107
00108 for (UInt_t i = 0; i < fEnergies.size(); i++)
00109 fEnergies[i]->GetChannel() < chansOneSide ?
00110 hitsF.push_back(fEnergies[i]) : hitsB.push_back(fEnergies[i]);
00111 sort(hitsF.begin(), hitsF.end(), GreaterValue<Float_t>());
00112 sort(hitsB.begin(), hitsB.end(), GreaterValue<Float_t>());
00113
00114
00115
00116
00117
00118 for (UInt_t i = 0; i < hitsF.size(); i++) {
00119 p.SetDetector(GetName());
00120 p.SetEnergy(hitsF[i]->GetValue());
00121 for (UInt_t j = 0; j < fTimes.size(); j++)
00122 if (fTimes[j]->GetChannel() == hitsF[i]->GetChannel()) {
00123 p.SetTime(fTimes[j]->GetValue());
00124 break;
00125 }
00126 if (i < hitsB.size()) {
00127 TVector3 xyz = GetPosition(hitsF[i]->GetChannel(),
00128 hitsB[i]->GetChannel() - chansOneSide);
00129 p.SetPosition(xyz.x(), xyz.y(), xyz.z());
00130 }
00131 hits->push_back(p);
00132 }
00133 }
00134
00135 void TDsssdDetector::GetStripsXY(vector<UShort_t> &stripsX,
00136 vector<UShort_t> &stripsY) const
00137 {
00146 for (UInt_t i = 0; i < fEnergies.size(); i++)
00147 if (fEnergies[i]->GetChannel() < GetChannels() / 2)
00148 stripsX.push_back(fEnergies[i]->GetChannel());
00149 for (UInt_t i = 0; i < fEnergies.size(); i++)
00150 if (fEnergies[i]->GetChannel() >= GetChannels() / 2)
00151 stripsY.push_back(fEnergies[i]->GetChannel());
00152 }
00153
00154 TVector3 TDsssdDetector::GetPosition(UShort_t stripF,
00155 UShort_t stripB) const
00156 {
00164 Float_t x = (stripF + 0.5) * fStripWidth + stripF * fStripSpacing;
00165 Float_t y = (stripB + 0.5) * fStripWidth + stripB * fStripSpacing;
00166 Float_t z = fCoordinates.Z();
00167 UShort_t frontStrips = GetChannels() / 2;
00168 Float_t width = frontStrips * fStripWidth + (frontStrips - 1) * fStripSpacing;
00169
00170 x -= width / 2 + fCoordinates.X();
00171 y -= width / 2 + fCoordinates.Y();
00172 return TVector3(x, y, z);
00173 }
00174
00175 Bool_t TDsssdDetector::PlotAdcTdcHitPattern(TH2F *hist, const TCutG *cut,
00176 Bool_t option) const
00177 {
00190 Bool_t status = false;
00191
00192 for (UInt_t i = 0; i < fEnergies.size(); i++)
00193 for (UInt_t j = 0; j < fTimes.size(); j++) {
00194 UInt_t x = fCalib.GetTdc().GetHistogramMap(fTimes[j]->GetChannel());
00195 UInt_t y = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel());
00196 if (cut && cut->IsInside(x, y))
00197 status = true;
00198 if (option || status)
00199 hist->Fill(x, y);
00200 }
00201 return status;
00202 }
00203
00204 Bool_t TDsssdDetector::PlotAdcHitPattern(TH2F *hist, const TCutG *cut,
00205 Bool_t option) const
00206 {
00219 Bool_t status = false;
00220
00221 for (UInt_t i = 0; i < fEnergies.size(); i++) {
00222 UInt_t x;
00223 UInt_t y;
00224 if ((x = fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel())) <
00225 GetChannels() / 2)
00226 for (UInt_t j = 0; j < fEnergies.size(); j++)
00227 if ((y = fCalib.GetAdc().GetHistogramMap(fEnergies[j]->GetChannel()))
00228 >= GetChannels() / 2) {
00229 if (cut && cut->IsInside(x, y))
00230 status = true;
00231 if (option || status)
00232 hist->Fill(x, y);
00233 }
00234 }
00235 return status;
00236 }
00237
00238 Bool_t TDsssdDetector::PlotFrontEvT(TH2F *hist, Float_t time,
00239 const TCutG *cut, Bool_t option) const
00240 {
00253 Bool_t status = false;
00254
00255 for (UInt_t i = 0; i < fEnergies.size(); i++)
00256 if (fEnergies[i]->GetChannel() < GetChannels() / 2) {
00257 Float_t energy = fEnergies[i]->GetValue();
00258 if (cut && cut->IsInside(time, energy))
00259 status = true;
00260 if (option || status)
00261 hist->Fill(time, energy);
00262 }
00263 return status;
00264 }
00265
00266 void TDsssdDetector::PlotAdcNAdcPEnergyP(TH3F *hist) const
00267 {
00272 for (UInt_t i = 0; i < fEnergies.size(); i++)
00273 if (fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel()) <
00274 GetChannels() / 2)
00275 for (UInt_t j = 0; j < fEnergies.size(); j++)
00276 if (fCalib.GetAdc().GetHistogramMap(fEnergies[j]->GetChannel()) >=
00277 GetChannels() / 2)
00278 hist->Fill(
00279 fCalib.GetAdc().GetHistogramMap(fEnergies[i]->GetChannel()),
00280 fCalib.GetAdc().GetHistogramMap(fEnergies[j]->GetChannel()),
00281 fEnergies[i]->GetValue());
00282 }