15#include "TRestDetectorReadoutEventViewer.h"
23 TRestDetectorReadoutEventViewer::TRestDetectorReadoutEventViewer() {
27TRestDetectorReadoutEventViewer::~TRestDetectorReadoutEventViewer() {}
29void TRestDetectorReadoutEventViewer::Initialize() {
30 TRestEventViewer::Initialize();
32 fCanvasXY =
new TCanvas(
"ReadoutMap",
"ReadoutMap");
33 fCanvasXZYZ =
new TCanvas(
"XZYZ",
"XZYZ");
34 fCanvasXZYZ->Divide(2, 1);
40 SetEvent(fSignalEvent);
46 cout <<
"WARNING : Only plane 0 is drawn. Implementation to draw several "
47 "planes or to choose the plane must be implemented."
55void TRestDetectorReadoutEventViewer::AddEvent(
TRestEvent* ev) {
59 TRestEventViewer::AddEvent(ev);
61 if (fPad ==
nullptr)
return;
68 if (fHistoXZ !=
nullptr) {
72 if (fHistoYZ !=
nullptr) {
79 fHistoXY->Draw(
"COLZ");
83 fHistoXZ->Draw(
"CONTZ");
85 fHistoYZ->Draw(
"CONTZ");
86 fCanvasXZYZ->Update();
89void TRestDetectorReadoutEventViewer::DrawReadoutPulses() {
90 int readoutChannel, daqChannel;
99 zmin = std::numeric_limits<Double_t>::max();
103 for (
int i = 0; i < fSignalEvent->GetNumberOfSignals(); i++)
104 for (
int j = 0; j < fSignalEvent->GetSignal(i)->GetNumberOfPoints(); j++) {
105 z = fSignalEvent->GetSignal(i)->GetTime(j);
106 if (z < zmin) zmin = z;
107 if (z > zmax) zmax = z;
113 fHistoXZ =
new TH2D(
"XZ",
"XZ", 100, xmin, xmax, 100, zmin, zmax);
114 fHistoYZ =
new TH2D(
"YZ",
"YZ", 100, ymin, ymax, 100, zmin, zmax);
116 for (
int i = 0; i < fSignalEvent->GetNumberOfSignals(); i++) {
117 daqChannel = fSignalEvent->GetSignal(i)->GetSignalID();
121 module = &(*plane)[m];
128 cout <<
"daqChannel " << daqChannel <<
" readoutChannel " << readoutChannel << endl;
130 if ((channel = GetChannel(readoutChannel)) ==
nullptr) {
136 Double_t xRead = plane->
GetX(modId, readoutChannel);
137 Double_t yRead = plane->
GetY(modId, readoutChannel);
142 if (TMath::IsNaN(yRead)) xStrip = 1;
143 if (TMath::IsNaN(xRead)) yStrip = 1;
144 if (xStrip == 0 && yStrip == 0) {
145 for (
int j = 0; j < fSignalEvent->GetSignal(i)->GetNumberOfPoints(); j++)
146 fHistoXZ->Fill(xRead, fSignalEvent->GetSignal(i)->GetTime(j),
147 fSignalEvent->GetSignal(i)->GetData(j));
148 for (
int j = 0; j < fSignalEvent->GetSignal(i)->GetNumberOfPoints(); j++)
149 fHistoYZ->Fill(yRead, fSignalEvent->GetSignal(i)->GetTime(j),
150 fSignalEvent->GetSignal(i)->GetData(j));
155 for (
int j = 0; j < fSignalEvent->GetSignal(i)->GetNumberOfPoints(); j++)
156 fHistoXZ->Fill(xRead, fSignalEvent->GetSignal(i)->GetTime(j),
157 fSignalEvent->GetSignal(i)->GetData(j));
158 }
else if (xStrip == 0) {
159 for (
int j = 0; j < fSignalEvent->GetSignal(i)->GetNumberOfPoints(); j++) {
160 fHistoYZ->Fill(yRead, fSignalEvent->GetSignal(i)->GetTime(j),
161 fSignalEvent->GetSignal(i)->GetData(j));
167 maxIndex = fSignalEvent->GetSignal(i)->GetMaxIndex();
168 charge = fSignalEvent->GetSignal(i)->GetData(maxIndex);
170 for (
int px = 0; px < nPixels; px++) {
183 if ((*plane)[n].GetChannel(readoutChannel) ==
nullptr)
continue;
184 return (*plane)[n].GetChannel(readoutChannel);
187 cout <<
"Readout channel " << readoutChannel <<
" not found" << endl;
194 if ((*plane)[n].GetChannel(readoutChannel) ==
nullptr)
continue;
198 cout <<
"Readout channel " << readoutChannel <<
" not found" << endl;
Int_t GetNumberOfPixels()
Returns the total number of pixels inside the readout channel.
Int_t GetModuleID() const
Returns the module id.
TVector2 GetPixelCenter(Int_t channel, Int_t pixel)
Returns the center pixel position for a given channel and pixel indexes.
Bool_t IsDaqIDInside(Int_t daqID)
Determines if a given daqID number is in the range of the module.
Int_t DaqToReadoutChannel(Int_t daqChannel)
Returns the physical readout channel index for a given daq id channel number.
TH2Poly * GetReadoutHistogram()
Creates and returns a TH2Poly object with the readout pixel description.
size_t GetNumberOfModules() const
Returns the total number of modules in the readout plane.
Double_t GetX(Int_t modID, Int_t chID)
Returns the X coordinate of a given channel in a given module using their internal module and channel...
void GetBoundaries(double &xmin, double &xmax, double &ymin, double &ymax)
Finds the xy boundaries of the readout plane delimited by the modules.
Double_t GetY(Int_t modID, Int_t chID)
Returns the Y coordinate of a given channel in a given module using their internal module and channel...
A metadata class to generate/store a readout description.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
Int_t GetNumberOfModules()
Returns the total number of modules implemented in all the readout planes.
A base class for any REST event.