17#include "TRestRawReadoutAnalysisProcess.h"
26TRestRawReadoutAnalysisProcess::TRestRawReadoutAnalysisProcess() {
Initialize(); }
28TRestRawReadoutAnalysisProcess::~TRestRawReadoutAnalysisProcess() {}
34 fSignalEvent =
nullptr;
40 fReadout = GetMetadata<TRestDetectorReadout>();
41 if (fReadout !=
nullptr) {
42 auto iter = fModuleHitMaps.begin();
43 while (iter != fModuleHitMaps.end()) {
46 RESTWarning <<
"REST Warning(TRestRawReadoutAnalysisProcess): readout "
48 << iter->first <<
" not found!" <<
RESTendl;
50 fModuleHitMaps[iter->first] =
51 new TH2D((TString)
"Hitmap_M" + ToString(iter->first),
52 (TString)
"FirstX/Y Hitmap of Module " + ToString(iter->first),
58 new TH1D((TString)
"ActivityX_M" + ToString(iter->first),
59 (TString)
"X Channel Activity of Module " + ToString(iter->first),
63 new TH1D((TString)
"ActivityY_M" + ToString(iter->first),
64 (TString)
"Y Channel Activity of Module " + ToString(iter->first),
69 new TH2D((TString)
"BSLSX_M" + ToString(iter->first),
70 (TString)
"X Channel Baseline Sigma of Module " + ToString(iter->first),
74 new TH2D((TString)
"BSLSY_M" + ToString(iter->first),
75 (TString)
"Y Channel Baseline Sigma of Module " + ToString(iter->first), 100, 0,
86 if (fReadout !=
nullptr) {
87 Double_t firstX_id = -1.;
88 Double_t firstY_id = -1.;
89 Double_t firstX_t = 512.0;
90 Double_t firstY_t = 512.0;
92 Double_t lastX_id = -1.;
93 Double_t lastY_id = -1.;
94 Double_t lastX_t = 0.0;
95 Double_t lastY_t = 0.0;
97 double nan = numeric_limits<double>::quiet_NaN();
103 set<int> TriggeredModuleId;
105 double XEnergySum = 0;
106 double XEnergyPosSum = 0;
107 double YEnergySum = 0;
108 double YEnergyPosSum = 0;
111 for (
int i = 0; i < fSignalEvent->GetNumberOfSignals(); i++) {
115 fReadout->GetPlaneModuleChannel(sgnl->
GetID(), p, m, c);
116 TriggeredModuleId.insert(m);
118 if (!TMath::IsNaN(fReadout->
GetX(sgnl->
GetID()))) {
122 if (!TMath::IsNaN(fReadout->
GetY(sgnl->
GetID()))) {
128 if (!TMath::IsNaN(fReadout->
GetX(sgnl->
GetID()))) {
129 firstX_id = sgnl->
GetID();
134 if (!TMath::IsNaN(fReadout->
GetY(sgnl->
GetID()))) {
135 firstY_id = sgnl->
GetID();
141 if (!TMath::IsNaN(fReadout->
GetX(sgnl->
GetID()))) {
142 lastX_id = sgnl->
GetID();
147 if (!TMath::IsNaN(fReadout->
GetY(sgnl->
GetID()))) {
148 lastY_id = sgnl->
GetID();
154 this->
SetObservableValue(
"MeanX", XEnergySum == 0 ? nan : XEnergyPosSum / XEnergySum);
155 this->
SetObservableValue(
"MeanY", YEnergySum == 0 ? nan : YEnergyPosSum / YEnergySum);
160 map<int, int> modulefirstxchannel;
161 map<int, int> modulefirstychannel;
162 if (firstX_id > -1 && firstY_id > -1) {
163 double firstx = fReadout->
GetX(firstX_id);
164 double firsty = fReadout->
GetY(firstY_id);
165 double lastx = fReadout->
GetX(lastX_id);
166 double lasty = fReadout->
GetY(lastY_id);
172 int mod1 = -1, mod2 = -1;
173 int channel1 = -1, channel2 = -1;
175 fReadout->GetPlaneModuleChannel(firstX_id, plane, mod1, channel1);
176 fReadout->GetPlaneModuleChannel(firstY_id, plane, mod2, channel2);
177 if (mod1 == mod2 && mod1 > -1) {
181 if (channel1 >= n && channel2 < n) {
184 }
else if (channel2 >= n && channel1 < n) {
188 modulefirstxchannel[mod1] = x;
189 modulefirstychannel[mod1] = y;
190 if (fModuleHitMaps.count(mod1) > 0) {
191 if (fModuleHitMaps[mod1] !=
nullptr) fModuleHitMaps[mod1]->Fill(x, y);
198 RESTDebug <<
"TRestRawReadoutAnalysisProcess. Adding point to hitmap of "
201 RESTDebug <<
"Position on module(X, Y) : (" << x <<
", " << y <<
")" <<
RESTendl;
202 RESTDebug <<
"Absolute position:(X, Y) : (" << firstx <<
", " << firsty <<
")" <<
RESTendl;
209 vector<int> moduleid;
210 vector<int> channelid;
211 vector<double> baselinesigma;
212 vector<double> baseline;
213 vector<double> thresholdint;
218 for (
int i = 0; i < fSignalEvent->GetNumberOfSignals(); i++) {
222 int plane = -1, mod = -1, channel = -1;
223 fReadout->GetPlaneModuleChannel(sgn->
GetID(), plane, mod, channel);
224 if (mod != -1 && channel != -1) {
225 moduleid.push_back(mod);
226 channelid.push_back(channel);
231 if (fModuleHitMaps.count(mod) > 0) {
249 if (fReadout !=
nullptr) {
251 auto iter = fModuleHitMaps.begin();
252 while (iter != fModuleHitMaps.end()) {
253 if (fModuleHitMaps[iter->first] !=
nullptr) {
254 TH2D* histo = fModuleHitMaps[iter->first];
255 histo->GetXaxis()->SetTitle(
"X Channel");
256 histo->GetYaxis()->SetTitle(
"Y Channel");
260 if (fModuleCanvasSave !=
"none") {
261 if (fModuleHitMaps[iter->first] !=
nullptr) {
262 TH2D* histo = fModuleHitMaps[iter->first];
264 new TCanvas((TString)
"Can_ModuleHitMap" + ToString(iter->first),
265 (TString)
"Hit Map of Module " + ToString(iter->first), 800, 600);
268 c1->Print((TString)fModuleCanvasSave +
"/M" + ToString(iter->first) +
"_HitMap.png");
272 auto h0 = fModuleHitMaps[iter->first];
281 TCanvas* c1 =
new TCanvas(
282 (TString)
"Can_ModuleActivity" + ToString(iter->first),
283 (TString)
"Channel Activity of Module " + ToString(iter->first), 800, 600);
284 c1->Divide(2, 2, 0, 0);
286 h1->SetFillColor(kBlue);
288 h1->GetYaxis()->SetTitle(
"Counts");
292 h2->SetFillColor(kBlue);
294 h2->GetXaxis()->SetTitle(
"Counts");
300 c1->Print((TString)fModuleCanvasSave +
"/M" + ToString(iter->first) +
310 TCanvas* c1 =
new TCanvas(
311 (TString)
"Can_ModuleBSLS" + ToString(iter->first),
312 (TString)
"Channel Baseline Sigma of Module " + ToString(iter->first), 800, 600);
313 c1->Divide(2, 2, 0, 0);
315 h1->SetFillColor(kBlue);
317 h1->GetYaxis()->SetTitle(
"Baseline Sigma");
321 h2->SetFillColor(kBlue);
323 h2->GetXaxis()->SetTitle(
"Baseline Sigma");
329 c1->Print((TString)fModuleCanvasSave +
"/M" + ToString(iter->first) +
"_BSLS.png");
344 fModuleCanvasSave =
GetParameter(
"outputPlotPath",
"none");
345 if (fModuleCanvasSave !=
"none") {
351 auto histdef =
Split(moduleHist,
":");
352 for (
unsigned int i = 0; i < histdef.size(); i++) {
size_t GetNumberOfChannels() const
Returns the total number of channels defined inside the module.
Double_t GetY(Int_t signalID)
It returns the physical Y-coordinate corresponding to a given signal id in plane coordinates.
TRestDetectorReadoutModule * GetReadoutModuleWithID(int id)
Returns a pointer to the readout module by ID.
Double_t GetX(Int_t signalID)
It returns the physical X-coordinate corresponding to a given signal id in plane coordinates.
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
void EndProcess() override
To be executed at the end of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void Initialize() override
Making default settings.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
std::map< int, TH1D * > fModuleActivityY
[MM id, channel activity]
std::map< int, TH2D * > fModuleBSLSigmaY
[MM id, channel activity]
std::map< int, TH2D * > fModuleBSLSigmaX
[MM id, channel activity]
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
std::map< int, TH1D * > fModuleActivityX
[MM id, channel activity]
An event container for time rawdata signals with fixed length.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
Double_t GetBaseLineSigma() const
Double_t GetThresholdIntegral()
It returns the integral of points identified over threshold. InitializePointsOverThreshold should hav...
Int_t GetID() const
Returns the value of signal ID.
Double_t GetBaseLine() const
Double_t GetIntegral()
It returns the integral of points found in the region defined by fRange. If fRange was not defined th...
Int_t GetMaxPeakBin()
It returns the bin at which the maximum peak amplitude happens.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.
Int_t StringToInteger(std::string in)
Gets an integer from a string.