123 #include "TRestDetectorHitsAnalysisProcess.h"
129 TRestDetectorHitsAnalysisProcess::TRestDetectorHitsAnalysisProcess() { Initialize(); }
131 TRestDetectorHitsAnalysisProcess::TRestDetectorHitsAnalysisProcess(
const char* configFilename) {
133 if (LoadConfigFromFile(configFilename) == -1) {
138 TRestDetectorHitsAnalysisProcess::~TRestDetectorHitsAnalysisProcess() {
delete fOutputHitsEvent; }
140 void TRestDetectorHitsAnalysisProcess::LoadDefaultConfig() { SetTitle(
"Default config"); }
143 SetSectionName(this->ClassName());
144 SetLibraryVersion(LIBRARY_VERSION);
146 fInputHitsEvent =
nullptr;
149 fPrismFiducial =
false;
150 fCylinderFiducial =
false;
153 void TRestDetectorHitsAnalysisProcess::LoadConfig(
const string& configFilename,
const string& name) {
154 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
164 TRestHits* hits = fInputHitsEvent->GetHits();
165 for (
unsigned int n = 0; n < hits->GetNumberOfHits(); n++) {
166 Double_t eDep = hits->GetEnergy(n);
168 Double_t x = hits->GetX(n);
169 Double_t y = hits->GetY(n);
170 Double_t z = hits->GetZ(n);
172 auto time = hits->GetTime(n);
173 auto type = hits->GetType(n);
179 fOutputHitsEvent->AddHit({x, y, z}, eDep, time, type);
182 Double_t energy = fOutputHitsEvent->GetTotalEnergy();
183 TVector3 meanPosition = fOutputHitsEvent->GetMeanPosition();
184 Double_t sigmaX = fOutputHitsEvent->GetSigmaX();
185 Double_t sigmaY = fOutputHitsEvent->GetSigmaY();
186 Double_t sigmaXY2 = fOutputHitsEvent->GetSigmaXY2();
187 Double_t sigmaZ2 = fOutputHitsEvent->GetSigmaZ2();
188 Double_t skewXY = fOutputHitsEvent->GetSkewXY();
189 Double_t skewZ = fOutputHitsEvent->GetSkewZ();
190 Double_t energyX = fOutputHitsEvent->GetEnergyX();
191 Double_t energyY = fOutputHitsEvent->GetEnergyY();
192 Double_t maxEnergy = fOutputHitsEvent->GetMaximumHitEnergy();
193 Double_t minEnergy = fOutputHitsEvent->GetMinimumHitEnergy();
194 Double_t meanEnergy = fOutputHitsEvent->GetMeanHitEnergy();
195 Int_t nHits = fOutputHitsEvent->GetNumberOfHits();
196 Int_t nHitsX = fOutputHitsEvent->GetNumberOfHitsX();
197 Int_t nHitsY = fOutputHitsEvent->GetNumberOfHitsY();
199 SetObservableValue(
"nHits", nHits);
201 SetObservableValue(
"nHitsX", nHitsX);
203 SetObservableValue(
"nHitsY", nHitsY);
205 SetObservableValue(
"balanceXYnHits", (nHitsX - nHitsY) /
double(nHitsX + nHitsY));
207 if ((nHits == nHitsX) || (nHits == nHitsY))
208 SetObservableValue(
"nHitsSizeXY", (
double)nHits);
210 SetObservableValue(
"nHitsSizeXY", TMath::Sqrt(nHitsX * nHitsX + nHitsY * nHitsY));
213 if (fCylinderFiducial) {
214 TVector3 meanPositionInCylinder =
215 fOutputHitsEvent->GetMeanPositionInCylinder(fFid_x0, fFid_x1, fFid_R);
217 Int_t isInsideCylinder = 0;
218 if (fOutputHitsEvent->anyHitInsideCylinder(fFid_x0, fFid_x1, fFid_R)) isInsideCylinder = 1;
220 Int_t nCylVol = fOutputHitsEvent->GetNumberOfHitsInsideCylinder(fFid_x0, fFid_x1, fFid_R);
222 Double_t enCylVol = fOutputHitsEvent->GetEnergyInCylinder(fFid_x0, fFid_x1, fFid_R);
224 SetObservableValue(
"isInsideCylindricalVolume", isInsideCylinder);
226 SetObservableValue(
"nInsideCylindricalVolume", nCylVol);
228 SetObservableValue(
"energyInsideCylindricalVolume", enCylVol);
231 SetObservableValue(
"xMeanInCylinder", meanPositionInCylinder.X());
233 SetObservableValue(
"yMeanInCylinder", meanPositionInCylinder.Y());
235 SetObservableValue(
"zMeanInCylinder", meanPositionInCylinder.Z());
239 if (fPrismFiducial) {
240 TVector3 meanPositionInPrism =
241 fOutputHitsEvent->GetMeanPositionInPrism(fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
243 Int_t isInsidePrism = 0;
244 if (fOutputHitsEvent->anyHitInsidePrism(fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta))
248 fOutputHitsEvent->GetNumberOfHitsInsidePrism(fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
250 Double_t enPrismVol =
251 fOutputHitsEvent->GetEnergyInPrism(fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
253 SetObservableValue(
"isInsidePrismVolume", isInsidePrism);
255 SetObservableValue(
"nInsidePrismVolume", nPrismVol);
257 SetObservableValue(
"energyInsidePrismVolume", enPrismVol);
261 SetObservableValue(
"xMeanInPrism", meanPositionInPrism.X());
263 SetObservableValue(
"yMeanInPrism", meanPositionInPrism.Y());
265 SetObservableValue(
"zMeanInPrism", meanPositionInPrism.Z());
270 if (fCylinderFiducial) {
272 Double_t dToCylWall =
273 fOutputHitsEvent->GetClosestHitInsideDistanceToCylinderWall(fFid_x0, fFid_x1, fFid_R);
275 fOutputHitsEvent->GetClosestHitInsideDistanceToCylinderTop(fFid_x0, fFid_x1, fFid_R);
276 Double_t dToCylBottom =
277 fOutputHitsEvent->GetClosestHitInsideDistanceToCylinderBottom(fFid_x0, fFid_x1, fFid_R);
279 SetObservableValue(
"distanceToCylinderWall", dToCylWall);
280 SetObservableValue(
"distanceToCylinderTop", dToCylTop);
281 SetObservableValue(
"distanceToCylinderBottom", dToCylBottom);
284 if (fPrismFiducial) {
286 Double_t dToPrismWall = fOutputHitsEvent->GetClosestHitInsideDistanceToPrismWall(
287 fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
288 Double_t dToPrismTop = fOutputHitsEvent->GetClosestHitInsideDistanceToPrismTop(
289 fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
290 Double_t dToPrismBottom = fOutputHitsEvent->GetClosestHitInsideDistanceToPrismBottom(
291 fFid_x0, fFid_x1, fFid_sX, fFid_sY, fFid_theta);
293 SetObservableValue(
"distanceToPrismWall", dToPrismWall);
295 SetObservableValue(
"distanceToPrismTop", dToPrismTop);
297 SetObservableValue(
"distanceToPrismBottom", dToPrismBottom);
302 SetObservableValue(
"energy", energy);
303 SetObservableValue(
"energyX", energyX);
304 SetObservableValue(
"energyY", energyY);
305 SetObservableValue(
"balanceXYenergy", (energyX - energyY) / (energyX + energyY));
307 SetObservableValue(
"maxHitEnergy", maxEnergy);
308 SetObservableValue(
"minHitEnergy", minEnergy);
309 SetObservableValue(
"meanHitEnergy", meanEnergy);
310 SetObservableValue(
"meanHitEnergyBalance", meanEnergy / energy);
312 SetObservableValue(
"xMean", meanPosition.X());
314 SetObservableValue(
"yMean", meanPosition.Y());
316 SetObservableValue(
"zMean", meanPosition.Z());
317 SetObservableValue(
"xy2Sigma", sigmaXY2);
318 SetObservableValue(
"xSigma", sigmaX);
319 SetObservableValue(
"ySigma", sigmaY);
320 SetObservableValue(
"xySigmaBalance", (sigmaX - sigmaY) / (sigmaX + sigmaY));
322 SetObservableValue(
"z2Sigma", sigmaZ2);
324 SetObservableValue(
"xySkew", skewXY);
325 SetObservableValue(
"zSkew", skewZ);
328 fOutputHitsEvent->PrintEvent(1000);
332 if (fOutputHitsEvent->GetNumberOfHits() == 0) {
336 for (
unsigned int n = 0; n < hits->GetNumberOfHits(); n++) {
337 Double_t eDep = hits->GetEnergy(n);
339 Double_t x = hits->GetX(n);
340 Double_t y = hits->GetY(n);
341 Double_t z = hits->GetZ(n);
343 auto time = hits->GetTime(n);
344 auto type = hits->GetType(n);
350 fOutputHitsEvent->AddHit({x, y, z}, eDep, time, type);
353 return fOutputHitsEvent;
366 fFid_x0 = Get3DVectorParameterWithUnits(
"fiducial_x0", TVector3(0, 0, 0));
367 fFid_x1 = Get3DVectorParameterWithUnits(
"fiducial_x1", TVector3(0, 0, 0));
369 fFid_R = GetDblParameterWithUnits(
"fiducial_R", 1);
370 fFid_sX = GetDblParameterWithUnits(
"fiducial_sX", 1);
371 fFid_sY = GetDblParameterWithUnits(
"fiducial_sY", 1);
373 fFid_theta = GetDblParameterWithUnits(
"fiducial_theta", 0.0);
375 if (GetParameter(
"cylinderFiducialization",
"false") ==
"true") {
376 fCylinderFiducial =
true;
379 if (GetParameter(
"prismFiducialization",
"false") ==
"true") {
380 fPrismFiducial =
true;
An analysis REST process to extract valuable information from Hits type of data.
void Initialize() override
Making default settings.
void EndProcess() override
To be executed at the end of the run (outside event loop)
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
A base class for any REST event.
It saves a 3-coordinate position and an energy for each punctual deposition.
@ REST_Extreme
show everything
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.