Hall C ROOT/C++ Analyzer (hcana)
THcReactionPoint.cxx
Go to the documentation of this file.
1 
10 #include "THcReactionPoint.h"
11 #include "THaSpectrometer.h"
12 #include "THaTrack.h"
13 #include "THaBeam.h"
14 #include "TMath.h"
15 #include <cstring>
16 #include <cstdio>
17 #include <cstdlib>
18 #include <iostream>
19 #include <fstream>
20 
21 
22 using namespace std;
23 
25 
26 //_____________________________________________________________________________
27 THcReactionPoint::THcReactionPoint( const char* name, const char* description,
28  const char* spectro, const char* beam ) :
29 THaReactionPoint(name, description, spectro, beam)
30 {
31  // Normal constructor.
32 
33 }
34 
35 //_____________________________________________________________________________
37 {
38  // Destructor
39 
40  DefineVariables( kDelete );
41 }
42 
43 //_____________________________________________________________________________
45 {
46  // Calculate the vertex coordinates.
47 
48  if( !IsOK() ) return -1;
49 
50  Int_t ntracks = fSpectro->GetNTracks();
51  if( ntracks == 0 ) return 0;
52 
53  TClonesArray* tracks = fSpectro->GetTracks();
54  if( !tracks ) return -2;
55 
56  TVector3 beam_org, beam_ray( 0.0, 0.0, 1.0 );
57  if( fBeam ) {
58  beam_org = fBeam->GetPosition();
59  beam_ray = fBeam->GetDirection();
60  }
61  TVector3 v;
62 
63  for( Int_t i = 0; i<ntracks; i++ ) {
64  THaTrack* theTrack = static_cast<THaTrack*>( tracks->At(i) );
65  // Ignore junk tracks
66  if( !theTrack || !theTrack->HasTarget() )
67  continue;
68  TVector3 pointing_off=fSpectro->GetPointingOffset();
69  Double_t costheta=TMath::Cos(fSpectro->GetThetaSph());
70  Double_t sintheta=TMath::Cos(fSpectro->GetPhiSph())*TMath::Sin(fSpectro->GetThetaSph());
71  Double_t ytar_off=theTrack->GetTY()+pointing_off(1);
72  Double_t yptar = theTrack->GetTPhi();
73  Double_t ztarg=(ytar_off-beam_org(0)*(costheta-yptar*sintheta))/(-sintheta-yptar*costheta);
74  v.SetXYZ(beam_org(0),beam_org(1),ztarg);
75  theTrack->SetVertex(v);
76  if( theTrack == fSpectro->GetGoldenTrack() ) {
77  fVertex = theTrack->GetVertex();
78  fVertexOK = kTRUE;
79  }
80  }
81  return 0;
82 }
83 
const char * v
virtual ~THcReactionPoint()
int Int_t
STL namespace.
void SetXYZ(Double_t x, Double_t y, Double_t z)
Calculate vertex coordinates.
Double_t Cos(Double_t)
double Double_t
Double_t Sin(Double_t)
TObject * At(Int_t idx) const
ClassImp(THcReactionPoint) THcReactionPoint
const Bool_t kTRUE
virtual Int_t Process(const THaEvData &)