Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaUnRasteredBeam.cxx
Go to the documentation of this file.
1//*-- Author : Bodo Reitz April 2003
2
4//
5// THaUnRasteredBeam
6//
7// Apparatus describing an unrastered beam.
8// can also be used if one only is interested
9// in average beam position for a rastered beam
10// but in that latter case the event by event ext-target
11// corrections need to be skipped
12// (e.g. using an ideal beam for the hrs reconstruction and
13// unrastered beam to fill global variables of the beamline)
14//
16
17#include "THaUnRasteredBeam.h"
18#include "THaBPM.h"
19#include "TList.h"
20
21using namespace std;
22
24
25//_____________________________________________________________________________
26
27THaUnRasteredBeam::THaUnRasteredBeam( const char* name, const char* description,
28 Int_t runningsum_depth, bool do_setup )
29 : THaBeam( name, description ), fRunningSumDepth(runningsum_depth),
30 fRunningSumWrap(false), fRunningSumNext(0)
31{
32
33
34 if( do_setup ) {
35 AddDetector( new THaBPM("BPMA","1st bpm",this) );
36 AddDetector( new THaBPM("BPMB","2nd bpm",this) );
37 }
38
39 if (fRunningSumDepth>1) {
40 fRSPosition.clear();
41 fRSDirection.clear();
42 fRSPosition.resize(fRunningSumDepth);
43 fRSDirection.resize(fRunningSumDepth);
44 } else {
45 fRunningSumDepth=0;
46 }
47}
48
49
50//_____________________________________________________________________________
52{
53
54 // only the first two detectors in the list are used to get
55 // the beam position in two points, and to extrapolate that
56 // to the nominal target point
57 // the following detectors are processed, but not used
58
59 TVector3 pos[2];
60
61 TIter nextDet( fDetectors );
62 nextDet.Reset();
63 for( auto& thePos : pos ) {
64 auto* theBeamDet = dynamic_cast<THaBeamDet*>( nextDet() );
65 if( theBeamDet ) {
66 theBeamDet->Process();
67 thePos = theBeamDet->GetPosition();
68 } else {
69 Error( Here("Reconstruct"),
70 "Beamline Detectors Missing in Detector List" );
71 }
72 }
73
74 // Process any other detectors we may have
75 while( auto* theBeamDet = dynamic_cast<THaBeamDet*>(nextDet()) ) {
76 theBeamDet->Process();
77 }
78
79 if( fRunningSumDepth != 0 ) {
80
81
82 if (fRunningSumWrap) {
85
86 }
87
88 fRSDirection[fRunningSumNext] = pos[1] - pos[0] ;
90 (pos[1](2) / (pos[0](2) - pos[1](2))) * fRSDirection[fRunningSumNext] ;
91
92 if (fRunningSumWrap) {
95 } else {
96 if (fRunningSumNext==0) {
99 } else {
104 }
105 }
108 fRunningSumNext = 0;
109 fRunningSumWrap = true ;
110 }
113
114 } else {
115
116 fDirection = pos[1] - pos[0];
117 fPosition = pos[1] + (pos[1](2) / (pos[0](2) - pos[1](2))) * fDirection ;
118
119 }
120 Update();
121
122 return 0;
123
124}
125
126//_____________________________________________________________________________
int Int_t
char name[80]
virtual const char * Here(const char *) const
TList * fDetectors
virtual Int_t Process()=0
TVector3 fPosition
Definition THaBeam.h:32
virtual void Update()
Definition THaBeam.cxx:85
TVector3 fDirection
Definition THaBeam.h:33
std::vector< TVector3 > fRSPosition
virtual Int_t Reconstruct()
std::vector< TVector3 > fRSDirection
THaUnRasteredBeam(const char *name, const char *description, Int_t runningsum_depth=0, bool do_setup=true)
void Reset()
virtual void Error(const char *method, const char *msgfmt,...) const
STL namespace.
ClassImp(TPyArg)