REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrackLineAnalysisProcess.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 
92 
93 #include "TRestTrackLineAnalysisProcess.h"
94 
95 #include "TRestTrackReductionProcess.h"
96 using namespace std;
97 
99 
104 
109 
115  SetSectionName(this->ClassName());
116  SetLibraryVersion(LIBRARY_VERSION);
117 
118  fTrackEvent = nullptr;
119  fOutTrackEvent = new TRestTrackEvent();
120 }
121 
127 
132  fTrackEvent = (TRestTrackEvent*)inputEvent;
133 
134  // Initialize outputTrackEvent
135  for (int t = 0; t < fTrackEvent->GetNumberOfTracks(); t++)
136  fOutTrackEvent->AddTrack(fTrackEvent->GetTrack(t));
137 
138  TRestTrack* tckX = fTrackEvent->GetMaxEnergyTrackInX();
139  TRestTrack* tckY = fTrackEvent->GetMaxEnergyTrackInY();
140 
141  TVector3 orig = TVector3(0, 0, 0), end = TVector3(0, 0, 0);
142  Double_t length = -1;
143  Double_t angle = -10;
144  bool downwards = true;
145  Double_t trackEnergyX = 0, trackEnergyY = 0;
146  Double_t trackBalanceX = 0, trackBalanceY = 0, trackBalance = 0, relZ = 0;
147 
148  if (tckX && tckY) {
149  // Retreive origin and end of the track for the XZ projection
150  if (fLineAnaMethod == "3D") {
151  fTrackEvent->GetMaxTrackBoundaries3D(orig, end);
152  } else {
153  if (fLineAnaMethod != "default") {
154  RESTWarning
155  << "Line analysis method " << fLineAnaMethod
156  << " is not implemented, supported methods are: default and 3D. Falling back to default."
157  << RESTendl;
158  }
159  fTrackEvent->GetMaxTrackBoundaries(orig, end);
160  }
161 
162  RESTDebug << "Origin: " << orig.X() << " y: " << orig.Y() << " z: " << orig.Z() << RESTendl;
163  RESTDebug << "End : " << end.X() << " y: " << end.Y() << " z: " << end.Z() << RESTendl;
164 
165  // Compute some observables
166  double dX = (orig.X() - end.X());
167  double dY = (orig.Y() - end.Y());
168  double dZ = (orig.Z() - end.Z());
169  length = TMath::Sqrt(dX * dX + dY * dY + dZ * dZ);
170  angle = TMath::ACos(dZ / length);
171  downwards = dZ > 0;
172 
173  RESTDebug << "Track length " << length << " angle: " << angle << RESTendl;
174 
175  trackEnergyX = tckX->GetEnergy();
176  trackEnergyY = tckY->GetEnergy();
177 
178  if (trackEnergyX > 0) trackBalanceX = trackEnergyX / fTrackEvent->GetEnergy("X");
179  if (trackEnergyY > 0) trackBalanceY = trackEnergyY / fTrackEvent->GetEnergy("Y");
180  if (trackEnergyX > 0 && trackEnergyY > 0)
181  trackBalance =
182  (trackEnergyX + trackEnergyY) / (fTrackEvent->GetEnergy("X") + fTrackEvent->GetEnergy("Y"));
183  relZ = fTrackEvent->GetMaxTrackRelativeZ();
184  }
185 
186  Double_t trackEnergy = trackEnergyX + trackEnergyY;
187 
188  // A new value for each observable is added
189  SetObservableValue("trackBalanceX", trackBalanceX);
190  SetObservableValue("trackBalanceY", trackBalanceY);
191  SetObservableValue("trackBalance", trackBalance);
192  SetObservableValue("originX", orig.X());
193  SetObservableValue("originY", orig.Y());
194  SetObservableValue("originZ", orig.Z());
195  SetObservableValue("endX", end.X());
196  SetObservableValue("endY", end.Y());
197  SetObservableValue("endZ", end.Z());
198  SetObservableValue("length", length);
199  SetObservableValue("angle", angle);
200  SetObservableValue("downwards", downwards);
201  SetObservableValue("totalEnergy", trackEnergy);
202  SetObservableValue("relativeZ", relZ);
203 
204  if (!tckX || !tckY) return nullptr;
205 
206  // Save most energetic XZ track
207  tckX->SetParentID(tckX->GetTrackID());
208  tckX->SetTrackID(fOutTrackEvent->GetNumberOfTracks() + 1);
209  fOutTrackEvent->AddTrack(tckX);
210 
211  // Save most energetic YZ track
212  tckY->SetParentID(tckY->GetTrackID());
213  tckY->SetTrackID(fOutTrackEvent->GetNumberOfTracks() + 1);
214  fOutTrackEvent->AddTrack(tckY);
215 
216  fOutTrackEvent->SetLevels();
217  return fOutTrackEvent;
218 }
219 
A base class for any REST event.
Definition: TRestEvent.h:38
A process to identify and extrack origin and end of a track assuming a linear track.
void InitProcess() override
Process initialization. Nothing to do...
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
Function to include required actions after all events have been processed. Nothing to do....