Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaNonTrackingDetector.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 7-Sep-00
2
4//
5// THaNonTrackingDetector
6//
7// Abstract base class for a generic non-tracking spectrometer detector.
8//
9// This is a special THaSpectrometerDetector -- any detector that
10// is not a tracking detector. This includes PID detectors.
11//
13
15#include "TClonesArray.h"
16#include "THaTrack.h"
17#include "THaTrackProj.h"
18#include <cassert>
19
20//______________________________________________________________________________
22 const char* description,
23 THaApparatus* apparatus )
24 : THaSpectrometerDetector(name,description,apparatus),
25 fTrackProj(new TClonesArray( "THaTrackProj", 5 ))
26{
27 // Normal constructor with name and description
28}
29
30//______________________________________________________________________________
32 : THaSpectrometerDetector(), fTrackProj(nullptr)
33{
34 // for ROOT I/O only
35}
36
37//______________________________________________________________________________
39{
40 // Destructor
41
43 delete fTrackProj; fTrackProj = nullptr;
44}
45
46//_____________________________________________________________________________
48{
49 // Reset per-event data.
50
52
54}
55
56//_____________________________________________________________________________
58{
59 // Define global analysis variables
60
62 if( ret )
63 return ret;
64
65 // Define analysis variables on our data members
66 RVarDef vars[] = {
67 { "trn", "Number of tracks for hits", "GetNTracks()" },
68 { "trx", "x-position of track in det plane", "fTrackProj.THaTrackProj.fX" },
69 { "try", "y-position of track in det plane", "fTrackProj.THaTrackProj.fY" },
70 { "trpath", "TRCS pathlen of track to det plane","fTrackProj.THaTrackProj.fPathl" },
71 { nullptr }
72 };
73 return DefineVarsFromList( vars, mode );
74}
75
76//_____________________________________________________________________________
78{
79 // Return number of tracks found to be crossing this detector
80
81 Int_t n_cross = 0;
82 for( Int_t i=0; i<fTrackProj->GetLast()+1; i++ ) {
83 auto* proj = static_cast<THaTrackProj*>( fTrackProj->At(i) );
84 assert( proj ); // else logic error in CalcTrackProj
85 if( proj->IsOK() )
86 ++n_cross;
87 }
88 return n_cross;
89}
90
91//_____________________________________________________________________________
93{
94 // Calculate projections of all given tracks onto detector reference plane.
95 //
96 // fTrackProj will hold as many entries as the given track array. Entries
97 // corresponding to non-crossing tracks will have fIsOK = false
98 //
99 // Does not calculate position residual or channel number. This is detector-
100 // specific and should be done in the detector code after calling this
101 // function.
102 //
103 // Returns number of tracks found to cross the detector plane.
104
105 Int_t n_track = tracks.GetLast()+1; // Number of tracks
106
107 fTrackProj->Clear(); // already done in Clear(), but do for safety
108 Int_t n_cross = 0;
109 for( Int_t i=0; i<n_track; i++ ) {
110 auto* theTrack = static_cast<THaTrack*>( tracks.At(i) );
111 assert( theTrack ); // else logic error in tracking detector
112
113 Double_t xc = kBig, yc = kBig, pathl = kBig;
114 Bool_t found = CalcTrackIntercept( theTrack, pathl, xc, yc );
115 auto* proj = new ( (*fTrackProj)[i] ) THaTrackProj(xc,yc,pathl);
116 if( found && !IsInActiveArea(xc,yc) )
117 found = false;
118 proj->SetOK(found);
119 if( found )
120 ++n_cross;
121 }
122 return n_cross;
123}
124
125//_____________________________________________________________________________
int Int_t
const Data_t kBig
Definition DataType.h:15
bool Bool_t
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
char name[80]
void Clear(Option_t *option="") override
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual Bool_t IsInActiveArea(Double_t x, Double_t y) const
virtual Int_t DefineVariables(EMode mode=kDefine)
Int_t CalcTrackProj(TClonesArray &tracks)
virtual void Clear(Option_t *="")
Bool_t CalcTrackIntercept(THaTrack *track, TVector3 &icept, Double_t &pathl)
void SetOK(Bool_t ok)
void Clear(Option_t *option="") override
TObject * At(Int_t idx) const override
Int_t GetLast() const override
ClassImp(TPyArg)
void tracks()