REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsGaussAnalysisProcess.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
55#include "TRestDetectorHitsGaussAnalysisProcess.h"
56
57using namespace std;
58
60
65
81 Initialize();
82
83 LoadConfig(configFilename);
84}
85
90 delete fInputHitsEvent;
91 delete fOutputHitsEvent;
92}
93
98 SetName(this->ClassName());
99 SetTitle("Default config");
100}
101
114void TRestDetectorHitsGaussAnalysisProcess::LoadConfig(const string& configFilename, const string& name) {
115 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
116}
117
123 // For example, try to initialize a pointer to existing metadata
124 // accessible from TRestRun
125}
126
132 SetSectionName(this->ClassName());
133 SetLibraryVersion(LIBRARY_VERSION);
134
135 // fHitsEvent = new TRestDetectorHitsEvent();
136 fInputHitsEvent = nullptr;
137 fOutputHitsEvent = new TRestDetectorHitsEvent();
138}
139
145
146 TString obsName;
147
148 // cout << "Event id : " << fInputHitsEvent->GetID() << endl;
149 TRestHits* hits = fInputHitsEvent->GetHits();
150
151 for (unsigned int n = 0; n < hits->GetNumberOfHits(); n++) {
152 Double_t eDep = hits->GetEnergy(n);
153
154 Double_t x = hits->GetX(n);
155 Double_t y = hits->GetY(n);
156 Double_t z = hits->GetZ(n);
157
158 auto time = hits->GetTime(n);
159 auto type = hits->GetType(n);
160
161 fOutputHitsEvent->AddHit(x, y, z, eDep, time, type);
162 }
163
164 Double_t gausSigmaX = fOutputHitsEvent->GetGaussSigmaX(fError, fNHitsMin);
165 Double_t gausSigmaY = fOutputHitsEvent->GetGaussSigmaY(fError, fNHitsMin);
166 Double_t gausSigmaZ = fOutputHitsEvent->GetGaussSigmaZ(fError, fNHitsMin);
167 Double_t xy2SigmaGaus = (gausSigmaX == -1. || gausSigmaY == -1.)
168 ? -1.
169 : (gausSigmaX * gausSigmaX) + (gausSigmaY * gausSigmaY);
170 Double_t xySigmaBalanceGaus = (gausSigmaX == -1. || gausSigmaY == -1.)
171 ? -1.
172 : (gausSigmaX - gausSigmaY) / (gausSigmaX + gausSigmaY);
173
174 if (hits->GetNumberOfHits() > 30 && xy2SigmaGaus < 0.05)
175 RESTDebug << string("Event ID: ") << to_string(fInputHitsEvent->GetID()) << string("||") << RESTendl;
176
177 SetObservableValue("xSigmaGaus", gausSigmaX);
178 SetObservableValue("ySigmaGaus", gausSigmaY);
179 SetObservableValue("zSigmaGaus", gausSigmaZ);
180 SetObservableValue("xy2SigmaGaus", xy2SigmaGaus);
181 SetObservableValue("xySigmaBalanceGaus", xySigmaBalanceGaus);
182
183 // We transform here fHitsEvent if necessary
184
186 fOutputHitsEvent->PrintEvent();
187
189 }
190
191 return fOutputHitsEvent;
192}
193
200
201 // Print output metadata using, metadata << endl;
202 RESTMetadata << "Pitch (mm) : " << fPitch << RESTendl;
203 RESTMetadata << "Error (ADC) : " << fError << RESTendl;
204 RESTMetadata << "Minimum number of hits to apply correction : " << fNHitsMin << RESTendl;
205
206 EndPrintProcess();
207}
virtual void PrintEvent() const
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.
An analysis REST process to extract valuable information from Hits type of data performing gaussian f...
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
Double_t fError
Error assigned to the hits on the sides.
Int_t fNHitsMin
The minimum number of hits required to apply the hit correction.
void InitProcess() override
Function to use in initialization of process members before starting to process the event.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void Initialize() override
Function to initialize input/output event members and define the section name and library version.
void PrintMetadata() override
It prints out the process parameters stored in the metadata structure.
Double_t fPitch
The pitch or size of the strips in mm.
TRestDetectorHitsEvent * fInputHitsEvent
A pointer to the specific TRestDetectorHitsEvent.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void BeginPrintProcess()
[name, cut range]
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
Definition: TRestEvent.h:38
It saves a 3-coordinate position and an energy for each punctual deposition.
Definition: TRestHits.h:39
endl_t RESTendl
Termination flag object for TRestStringOutput.
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
void SetSectionName(std::string sName)
set the section name, clear the section content
@ REST_Debug
+show the defined debug messages
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.