Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaTwoarmVertex.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 13-Mar-03
2
4//
5// THaTwoarmVertex
6//
7// Calculate the intersection of the Golden Track from two spectrometers.
8// The resulting vertex coordinates are in global variables x,y,z.
9//
10// This module assumes that the spectrometers only reconstruct the
11// target position transverse to the bend plane (y_tg) with relatively
12// high precision. Each spectrometer therefore reconstructs a
13// "track plane" spanned by the particle's momentum vector and the
14// TRANSPORT x-vector, whose origin is the y-target point.
15//
16// The intersection of the two Golden Tracks is thus actually a line
17// with undefined y_lab coordinate. This module always sets y to zero.
18// The actual y_lab position can be derived from the beam position and
19// is calculated in the THaPhysVertex and THaPhysAvgVertex modules.
20//
22
23#include "THaTwoarmVertex.h"
24#include "THaSpectrometer.h"
25#include "THaTrackInfo.h"
26#include "THaTrack.h"
27#include "TMath.h"
28
29#include <iostream>
30
31using namespace std;
32
33//_____________________________________________________________________________
34THaTwoarmVertex::THaTwoarmVertex( const char* name, const char* description,
35 const char* spectro1, const char* spectro2 ) :
36 THaPhysicsModule(name,description),
37 fName1(spectro1), fName2(spectro2), fSpectro1(nullptr), fSpectro2(nullptr)
38{
39 // Normal constructor.
40
41 Clear();
42}
43
44//_____________________________________________________________________________
46{
47 // Destructor
48
50}
51
52//_____________________________________________________________________________
54{
55 // Clear all internal variables.
56
59}
60
61//_____________________________________________________________________________
63{
64 // Define/delete global variables for this module
65
67}
68
69//_____________________________________________________________________________
71{
72 // Initialize the module.
73 // Locate the spectrometer apparatus named in fSpectroName and save
74 // pointer to it.
75
76 // Standard initialization. Calls this object's DefineVariables().
77 if( THaPhysicsModule::Init( run_time ) != kOK )
78 return fStatus;
79
80 fSpectro1 = dynamic_cast<THaTrackingModule*>
81 ( FindModule( fName1.Data(), "THaTrackingModule"));
82 if( !fSpectro1 )
83 return fStatus;
84
85 fSpectro2 = dynamic_cast<THaTrackingModule*>
86 ( FindModule( fName2.Data(), "THaTrackingModule"));
87
88 return fStatus;
89}
90
91//_____________________________________________________________________________
93{
94 // Calculate the intersection point.
95
96 if( !IsOK() ) return -1;
97
99 if( !t1 || !t1->IsOK()) return 1;
101 if( !t2 || !t2->IsOK()) return 2;
102 THaSpectrometer* s1 = t1->GetSpectrometer();
104 if( !s1 || !s2 ) return 4;
105
106 static const TVector3 yax( 0.0, 1.0, 0.0 );
107
108 TVector3 p1( 0.0, t1->GetY(), 0.0 );
109 TVector3 p2( 0.0, t2->GetY(), 0.0 );
110 p1 *= s1->GetToLabRot();
111 p1 += s1->GetPointingOffset();
112 p2 *= s2->GetToLabRot();
113 p2 += s2->GetPointingOffset();
114 Double_t t = 0; // dummy
115 if( !IntersectPlaneWithRay( t1->GetPvect(), yax, p1,
116 p2, t2->GetPvect(), t, fVertex ))
117 return 3; // Oops, track planes are parallel?
118 fVertexOK = true;
119
120#ifdef WITH_DEBUG
121 if( fDebug<2 )
122#endif
123 fVertex.SetY( 0.0 );
124
125#ifdef WITH_DEBUG
126 //DEBUG code
127 else {
128 cout << "============Two-arm vertex:===========" << endl;
129 cout << "--o1\n"; p1.Dump();
130 cout << "--o2\n"; p2.Dump();
131 cout << "--p1\n"; (t1->GetPvect()).Dump();
132 cout << "--p2\n"; (t2->GetPvect()).Dump();
133 THaTrack* tr1 = fSpectro1->GetTrack();
134 THaTrack* tr2 = fSpectro2->GetTrack();
135 if( tr1->HasVertex() ){
136 cout << "--v1\n"; (tr1->GetVertex()).Dump(); }
137 if( tr2->HasVertex() ){
138 cout << "--v2\n"; (tr2->GetVertex()).Dump(); }
139 cout << "--twoarm\n";
140 fVertex.Dump();
141
142 // consistency check
143 TVector3 v2;
144 if(!IntersectPlaneWithRay( t2->GetPvect(), yax, p2,
145 p1, t1->GetPvect(), t, v2 ))
146 return 3;
147 cout << "--twoarm_alt\n";
148 v2.Dump();
149 }
150#endif
151 fDataValid = true;
152 return 0;
153}
154
int Int_t
#define s1(x)
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
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 void Clear(Option_t *opt="")
const TRotation & GetToLabRot() const
const TVector3 & GetPointingOffset() const
THaSpectrometer * GetSpectrometer() const
Double_t GetY() const
const TVector3 & GetPvect() const
Bool_t IsOK() const
bool HasVertex() const
Definition THaTrack.h:139
TVector3 & GetVertex()
Definition THaTrack.h:120
THaTrackInfo * GetTrackInfo()
virtual void Clear(Option_t *opt="")
THaTrackingModule * fSpectro1
virtual Int_t Process(const THaEvData &)
THaTrackingModule * fSpectro2
virtual ~THaTwoarmVertex()
virtual Int_t DefineVariables(EMode mode=kDefine)
THaTwoarmVertex(const char *name, const char *description, const char *spectro1="", const char *spectro2="")
virtual void VertexClear()
static const RVarDef * GetRVarDef()
virtual void Dump() const
const char * Data() const
void SetY(Double_t)
STL namespace.
v2
auto * t1
ClassImp(TPyArg)