Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaTrackingDetector.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 7-Sep-00
2
4//
5// THaTrackingDetector
6//
7// Abstract base class for a generic tracking detector.
8//
9// This is a special THaSpectrometerDetector that is capable of
10// finding particle tracks. It does not need to find track vertices
11// (target coordinates) - this is usually done by the enclosing apparatus.
12//
13// Note: The FPP is NOT a "tracking detector" in this scheme because,
14// with the present FPP algorithms, it is not used for calculating the
15// fp coordinates.
16//
18
19#include "TClonesArray.h"
20#include "THaTrackingDetector.h"
21#include "THaPIDinfo.h"
22#include "THaTrack.h"
23#include "THaSpectrometer.h"
24#include "TError.h"
25
27
28//_____________________________________________________________________________
30 const char* description,
31 THaApparatus* apparatus )
32 : THaSpectrometerDetector(name,description,apparatus)
33{
34 // Constructor
35
36}
37
38//_____________________________________________________________________________
41{
42 // Constructor for ROOT I/O only
43}
44
45//_____________________________________________________________________________
47
48//_____________________________________________________________________________
50 Double_t x, Double_t y,
51 Double_t theta, Double_t phi,
52 THaTrackID* ID )
53{
54 // Add a track with the given parameters to the array of tracks
55 // Returns the index of the created track in the TClonesArray.
56
57 Int_t i = tracks.GetLast()+1;
58 THaPIDinfo* pid = nullptr;
59 auto* spect = static_cast<THaSpectrometer*>( GetApparatus() );
60
61 if( spect ) {
62 if( spect->IsPID() ) {
63 // Create new PIDinfo and vertex objects if necessary
64
65 UInt_t ndet = spect->GetNpidDetectors();
66 UInt_t npart = spect->GetNpidParticles();
67 TClonesArray& c = *spect->GetTrackPID();
68
69 // caution: c[i] creates an empty object at i if slot i was empty,
70 // so use At(i) to check.
71
72 if( i > c.GetLast() || !c.At(i) ) new(c[i]) THaPIDinfo(ndet, npart);
73 pid = static_cast<THaPIDinfo*>( c.At(i) );
74 }
75 } else if( fDebug>0 ) {
76 ::Warning("THaTrackingDetector::AddTrack", "No spectrometer defined for "
77 "detector %s. Track has no PID and vertex info.", GetName());
78 }
79
80 // Create the track
81
82 return new( tracks[i] ) THaTrack( x, y, theta, phi, this, ID, pid );
83
84}
85
int Int_t
unsigned int UInt_t
#define c(i)
double Double_t
char name[80]
THaApparatus * GetApparatus() const
Int_t GetNpidDetectors() const
virtual THaTrack * AddTrack(TClonesArray &tracks, Double_t x, Double_t y, Double_t theta, Double_t phi, THaTrackID *ID=nullptr)
virtual ~THaTrackingDetector()
const char * GetName() const override
Double_t y[n]
Double_t x[n]
ClassImp(TPyArg)
void tracks()