00001
00010 #include <iostream>
00011
00012 #include <TH2F.h>
00013 #include <TCutG.h>
00014
00015 #include "TMcpDetector.h"
00016 #include "TSubEvent.h"
00017 #include "THit.h"
00018
00019 using std::cout;
00020 using std::endl;
00021
00022 TMcpDetector::TMcpDetector(const Char_t *name, UInt_t channels)
00023 : THiDetector(name, channels)
00024 {
00032 }
00033
00034 TMcpDetector::~TMcpDetector()
00035 {
00038 }
00039
00040 void TMcpDetector::Print(const Char_t *option) const
00041 {
00048 cout << "MCP detector:" << endl;
00049 THiDetector::Print(option);
00050 }
00051
00052 void TMcpDetector::SetSignals(const TSubEvent &subEvent)
00053 {
00062 const vector<TDataItem<UShort_t> > &adcs = subEvent.GetAdcs();
00063
00064 for (UInt_t i = 0; i < adcs.size(); i++)
00065 if (fCalib.GetAdc().TestChannel(adcs[i].GetChannel())) {
00066 fAdcs.push_back(&adcs[i]);
00067 fHit = true;
00068 }
00069 }
00070
00071 void TMcpDetector::FindHits(vector<THit> *hits) const
00072 {
00083 THit p;
00084
00085 if (fEnergies.size() && fEnergies[0]->GetValue() > 0) {
00086 p.SetEnergy(fEnergies[0]->GetValue());
00087 if (fTimes.size())
00088 p.SetTime(fTimes[0]->GetValue());
00089 p.SetDetector(GetName());
00090 p.SetPosition(fCoordinates.X(), fCoordinates.Y(), fCoordinates.Z());
00091 hits->push_back(p);
00092 }
00093 }
00094
00095 Bool_t
00096 TMcpDetector::PlotHitPattern(TH2F *hist, const TCutG *cut, Bool_t option) const
00097 {
00106 Bool_t status = false;
00107
00108 if (fEnergies.size() == GetChannels()) {
00109
00110 Float_t Ia = fEnergies[0]->GetValue();
00111 Float_t Ib = fEnergies[1]->GetValue();
00112 Float_t Ic = fEnergies[2]->GetValue();
00113 Float_t Id = fEnergies[3]->GetValue();
00114 Float_t L = 50;
00115
00116
00117 Float_t x = L/2 * ((Ib + Ic) - (Ia + Id)) / (Ia + Ib + Ic + Id);
00118 Float_t y = L/2 * ((Ia + Ib) - (Ic + Id)) / (Ia + Ib + Ic + Id);
00119 cout << Ia << " " << Ib << " " << Ic << " " << Id << endl;
00120 cout << x << " " << y << endl;
00121 if (cut && cut->IsInside(x, y))
00122 status = true;
00123 if (option || status)
00124 hist->Fill(x, y);
00125 }
00126 return status;
00127 }