Neutral Particle Spectrometer analysis code
Loading...
Searching...
No Matches
THcNPSTrackInfo.cxx
Go to the documentation of this file.
1// THcNPSTrackInfo
2
3#include "THcNPSTrackInfo.h"
4#include "THcNPSCluster.h"
5#include "THcNPSCalorimeter.h"
6#include "THcNPSApparatus.h"
7#include "THcReactionPoint.h"
8#include "THcParmList.h"
9#include "THcGlobals.h"
10#include "VarDef.h"
11#include "VarType.h"
12
13//_____________________________________________________________________
14THcNPSTrackInfo::THcNPSTrackInfo( const char* name, const char* description,
15 const char* nps_apparatus,
16 const char* vertex_module) :
17 THaPhysicsModule(name, description),
18 fSpectroName(nps_apparatus),
19 fVertexModuleName(vertex_module),
20 fSpectro(nullptr),
21 fNPSCalo(nullptr),
22 fVertexModule(nullptr)
23{
24 // Constructor
25 fHasVertex = false;
27}
28
29//_____________________________________________________________________
35
36//_____________________________________________________________________
38{
40 fNPSTrk.clear();
42 fHasVertex = false;
43}
44
45//_____________________________________________________________________
47{
48
49 fStatus = kOK;
50
51 // Find NPS Apparatus
52 fSpectro = dynamic_cast<THcNPSApparatus*>
53 ( FindModule( fSpectroName.Data(), "THcNPSApparatus") );
54 if(!fSpectro) {
56 return fStatus;
57 }
58
59 // Get NPS calorimeter detector
60 fNPSCalo = dynamic_cast<THcNPSCalorimeter*>(fSpectro->GetDetector("cal"));
62
63 // HMS Vertex Module (ReactionPoint)
64 fVertexModule = dynamic_cast<THcReactionPoint*>
65 ( FindModule( fVertexModuleName.Data(), "THcReactionPoint") );
66 if(!fVertexModule) {
68 return fStatus;
69 }
70
71 if( (fStatus =THaPhysicsModule::Init( run_time )) != kOK ) {
72 return fStatus;
73 }
74
75 return fStatus;
76}
77
78//_____________________________________________________________________
80{
81
82 if( mode == kDefine && fIsSetup ) return kOK;
83 fIsSetup = ( mode == kDefine );
84
85 // vx,vy,vz are same as H.react.x/y/z -- saved for xcheck
86 // trk.x and trk.y are same as the clusX, clusY from NPSCalorimeter -- saved for xcheck
87 RVarDef vars[] = {
88 {"vx", "Vertex x from HMS track", "fVertex.X()"},
89 {"vy", "Vertex y from HMS track", "fVertex.Y()"},
90 {"vz", "Vertex z from HMS track", "fVertex.Z()"},
91 {"px", "Lab momentum px (GeV)", "fNPSTrk.fPx" },
92 {"py", "Lab momentum py (GeV)", "fNPSTrk.fPy" },
93 {"pz", "Lab momentum pz (GeV)", "fNPSTrk.fPz" },
94 {"p", "Lab momentum (GeV)", "fNPSTrk.fP" },
95 {"mult", "Cluster size", "fNPSTrk.fMult"},
96 {"x", "x coordinate in detector front plane", "fNPSTrk.fX"},
97 {"y", "y coordinate in detector front plane", "fNPSTrk.fY"},
98 { 0 }
99 };
100
101 return DefineVarsFromList( vars, mode );
102}
103
104//_____________________________________________________________________
106{
107
108 if( !IsOK() ) return -1;
109
110 fNPSTrk.clear();
111
112 if( fNPSCalo->GetNClusters() == 0 ) return 1;
113
114 if( fVertexModule->HasVertex() ) {
116 fHasVertex = true;
117 }
118
119 TVector3 pvect;
120 for( auto& cluster : fNPSCalo->GetClusters() ) {
121
122 if(fHasVertex) {
123 cluster.RotateToLab(fNPSAngle, fVertex, pvect);
124 cluster.SetVertexFlag(true);
125 }
126 else {
127 // if there is no vertex found from the HMS, it assumes (0,0,0) in THcNPSCluster,
128 // in case one wants to reconstruct the photon momentum vector for NPS single data
129 TVector3 Vtx_tmp(0,0,0);
130 cluster.RotateToLab(fNPSAngle, Vtx_tmp, pvect);
131 cluster.SetVertexFlag(false);
132 }
133
134 fNPSTrk.push_back( { pvect.Mag(), pvect.X(), pvect.Y(), pvect.Z(), cluster.X(), cluster.Y(), cluster.GetSize() } );
135
136 }
137 return 0;
138}
139
140//_____________________________________________________________________
int Int_t
const Data_t kBig
const char Option_t
Option_t Option_t TPoint TPoint const char mode
ClassImp(VDC::AnalyticTTDConv) using namespace std
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)
Bool_t IsOK() const
virtual THaDetector * GetDetector(const char *name)
virtual void Clear(Option_t *opt="")
virtual Bool_t HasVertex() const
virtual const TVector3 & GetVertex() const
A dummy spectrometer apparatus for testing detectors.
Double_t GetNPSAngle()
Generic segmented shower detector.
vector< THcNPSCluster > GetClusters()
std::vector< NPSTrack > fNPSTrk
TString fVertexModuleName
THcReactionPoint * fVertexModule
THcNPSCalorimeter * fNPSCalo
virtual void Clear(Option_t *opt="")
virtual ~THcNPSTrackInfo()
THcNPSApparatus * fSpectro
virtual Int_t DefineVariables(EMode mode=kDefine)
THcNPSTrackInfo(const char *name, const char *description, const char *spectro="", const char *vertex_module="")
virtual Int_t Process(const THaEvData &)
const char * Data() const
Double_t Z() const
void SetXYZ(Double_t x, Double_t y, Double_t z)
Double_t Y() const
Double_t X() const
Double_t Mag() const
constexpr Double_t DegToRad()