Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaReactionPoint.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 13-Mar-03
2
4//
5// THaReactionPoint
6//
7// Calculate vertex for all the tracks from a single spectrometer.
8//
9// This module assumes a small-acceptance pointing-type spectrometer
10// that generates tracks in TRANSPORT coordinates.
11// It is assumed that the spectrometer only reconstructs the
12// position at the target transverse to the bend plane, i.e. y_tg, with
13// relatively high precision. Any reconstructed or estimated x_tg is ignored.
14// The vertex is then defined as the intersection point of the
15// "track plane" and the beam ray. The "track plane" is the plane
16// spanned by the reconstructed momentum vector and the TRANSPORT x-axis
17// (vertical) whose origin is the y_tg point.
18// The beam ray is given by the measured beam positions and angles
19// for this event. If no beam position measurement is available, beam
20// positions and angles are assumed to be zero.
21// The spectrometer pointing offset is taken into account.
22//
24
25#include "THaReactionPoint.h"
26#include "THaSpectrometer.h"
27#include "THaTrack.h"
28#include "THaBeam.h"
29#include "TMath.h"
30
32
33//_____________________________________________________________________________
34THaReactionPoint::THaReactionPoint( const char* name, const char* description,
35 const char* spectro, const char* beam ) :
36 THaPhysicsModule(name,description), fSpectroName(spectro),
37 fBeamName(beam), fSpectro(nullptr), fBeam(nullptr)
38{
39 // Normal constructor.
40
41}
42
43//_____________________________________________________________________________
45{
46 // Destructor
47
49}
50
51//_____________________________________________________________________________
53{
54 // Clear all event-by-event variables.
55
58}
59
60//_____________________________________________________________________________
62{
63 // Define/delete analysis variables
64
66}
67
68//_____________________________________________________________________________
70{
71 // Initialize the module.
72 // Locate the spectrometer apparatus named in fSpectroName and save
73 // pointer to it.
74
75 // Standard initialization. Calls this object's DefineVariables().
76 if( THaPhysicsModule::Init( run_time ) != kOK )
77 return fStatus;
78
79 fSpectro = static_cast<THaSpectrometer*>
80 ( FindModule( fSpectroName.Data(), "THaSpectrometer"));
81 if( !fSpectro )
82 return fStatus;
83
84 if( fBeamName.Length() > 0 )
85 fBeam = static_cast<THaBeam*>( FindModule( fBeamName.Data(), "THaBeam") );
86
87 return fStatus;
88}
89
90//_____________________________________________________________________________
92{
93 // Calculate the vertex coordinates.
94
95 if( !IsOK() ) return -1;
96
97 Int_t ntracks = fSpectro->GetNTracks();
98 if( ntracks == 0 ) return 0;
99
101 if( !tracks ) return -2;
102
103 TVector3 beam_org, beam_ray( 0.0, 0.0, 1.0 );
104 if( fBeam ) {
105 beam_org = fBeam->GetPosition();
106 beam_ray = fBeam->GetDirection();
107 }
108 static const TVector3 yax( 0.0, 1.0, 0.0 );
109 TVector3 org, v;
110
111 for( Int_t i = 0; i<ntracks; i++ ) {
112 auto* theTrack = static_cast<THaTrack*>( tracks->At(i) );
113 // Ignore junk tracks
114 if( !theTrack || !theTrack->HasTarget() )
115 continue;
116 org.SetXYZ( 0.0, theTrack->GetTY(), 0.0 );
119 Double_t t = 0; // dummy
120 if( !IntersectPlaneWithRay( theTrack->GetPvect(), yax, org,
121 beam_org, beam_ray, t, v ))
122 continue; // Oops, track and beam parallel?
123 theTrack->SetVertex(v);
124
125 // FIXME: preliminary
126 if( theTrack == fSpectro->GetGoldenTrack() ) {
127 fVertex = theTrack->GetVertex();
128 fVertexOK = true;
129 }
130 // FIXME: calculate vertex coordinate errors here (need beam errors)
131
132
133 // The following is more efficient but less general
134 // and requires the tangents of the beam angles (TRANSPORT style)
135
136// Double_t x0 = (fSpectro->GetPointingOffset()).X() +
137// (fSpectro->GetToLabRot()).XY() * theTrack->GetTY();
138// Double_t z0 = (fSpectro->GetPointingOffset()).Z() +
139// (fSpectro->GetToLabRot()).ZY() * theTrack->GetTY();
140// Double_t dx = beam_x + beam_th*z0 - x0;
141// Double_t dz = dx /( theTrack->GetLabPx()/theTrack->GetLabPz() - beam_th );
142// Double_t z = z0 + dz;
143// theTrack->SetVertex( beam_x+beam_th*z, beam_y+beam_ph*z, z );
144 }
145 return 0;
146}
147
int Int_t
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
char name[80]
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="")
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
static Bool_t IntersectPlaneWithRay(const TVector3 &xax, const TVector3 &yax, const TVector3 &org, const TVector3 &ray_start, const TVector3 &ray_vect, Double_t &length, TVector3 &intersect)
Bool_t IsOK() const
virtual const TVector3 & GetDirection() const
Definition THaBeam.h:24
virtual const TVector3 & GetPosition() const
Definition THaBeam.h:23
virtual void Clear(Option_t *opt="")
THaReactionPoint(const char *name, const char *description, const char *spectro="", const char *beam="")
THaSpectrometer * fSpectro
virtual Int_t Process(const THaEvData &)
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual void Clear(Option_t *opt="")
THaTrack * GetGoldenTrack() const
Int_t GetNTracks() const
TClonesArray * GetTracks() const
const TRotation & GetToLabRot() const
const TVector3 & GetPointingOffset() const
virtual void VertexClear()
static const RVarDef * GetRVarDef()
Ssiz_t Length() const
const char * Data() const
v
ClassImp(TPyArg)
void tracks()