Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaTrackOut.cxx
Go to the documentation of this file.
1#include "THaTrackOut.h"
2
3#include <TLorentzVector.h>
4#include <TTree.h>
5#include "THaOutput.h"
6#include "THaTrackingModule.h"
7
8using namespace std;
9
10//_____________________________________________________________________________
11THaTrackOut::THaTrackOut(const char* name, const char* description,
12 const char* src, Double_t pmass /* GeV */ ) :
13 THaPhysicsModule(name,description), fM(pmass), fSrcName(src),
14 fP4{new TLorentzVector}, fSrc(nullptr)
15{
16 // Prepare four-vectors for storing the output tracks from "src",
17 // assuming is has mass "pmass".
18 // it is stored in the TTree as name.p4
19}
20
21//_____________________________________________________________________________
23{
24 // clean-up.
25 delete fP4;
26}
27
28//_____________________________________________________________________________
30{
31 // Set vector to default (junk) values
33 fP4->SetXYZT(kBig,kBig,kBig,0); // also gives a large - Mag2()
34}
35
36//_____________________________________________________________________________
38{
39 // I will permit this to change on an event-by-event basis
40 fM = m;
41}
42
43//_____________________________________________________________________________
44void THaTrackOut::SetSpectrometer( const char* name )
45{
46 // can only update BEFORE the initialization takes place
47 if ( !IsInit())
48 fSrcName = name;
49 else
50 PrintInitError("SetSpectrometer()");
51}
52
53//_____________________________________________________________________________
55{
56 // Find the pointer to the tracking module providing the track
57 // and save the pointer
58 fSrc = dynamic_cast<THaTrackingModule*>
59 ( FindModule( fSrcName.Data(), "THaTrackingModule"));
60 if ( !fSrc )
61 return fStatus;
62
63 // Standard initialization. Calls this object's DefineVariables().
64 if( THaPhysicsModule::Init( run_time ) != kOK )
65 return fStatus;
66
67 if( fM == 0.0 ) {
68 Warning( Here("Init"), "Particle mass not defined. Assuming mass of 0.0");
69 }
70 return fStatus;
71}
72
73//_____________________________________________________________________________
75{
76 // Use the tree to store output
77
78 if (fOKOut) return 0; // already initialized.
79 if (!output) {
80 Error("InitOutput","Cannot get THaOutput object. Output initialization FAILED!");
81 return -2;
82 }
83 TTree* tree = output->GetTree();
84 if (!tree) {
85 Error("InitOutput","Cannot get Tree! Output initialization FAILED!");
86 return -3;
87 }
88
89 // create the branches
90 if ( tree->Branch(Form("%s.p4.",GetName()),"TLorentzVector",&fP4,4000) ) {
91 fOKOut = true;
92 }
93
94 if (fOKOut) return 0;
95 return -1;
96}
97
98//_____________________________________________________________________________
100{
101 // Calculate the 4-vector for the golden track from fSrc
102
103 if ( !IsOK() || !gHaRun ) return -1;
104
105 THaTrackInfo *trkifo = fSrc->GetTrackInfo();
106 if ( !trkifo || !trkifo->IsOK() ) return 1;
107
108 fP4->SetVectM( trkifo->GetPvect(), fM );
109 return 0;
110}
111
int Int_t
const Data_t kBig
Definition DataType.h:15
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
char name[80]
R__EXTERN class THaRunBase * gHaRun
Definition THaGlobals.h:16
char * Form(const char *fmt,...)
virtual const char * Here(const char *) const
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
Bool_t IsOK() const
Bool_t IsInit() const
virtual TTree * GetTree() const
Definition THaOutput.h:82
void PrintInitError(const char *here)
virtual void Clear(Option_t *opt="")
const TVector3 & GetPvect() const
Bool_t IsOK() const
void SetMass(Double_t m)
virtual void Clear(Option_t *opt="")
void SetSpectrometer(const char *name)
Double_t fM
Definition THaTrackOut.h:30
virtual Int_t Process(const THaEvData &evdata)
TLorentzVector * fP4
Definition THaTrackOut.h:33
virtual ~THaTrackOut()
virtual Int_t InitOutput(THaOutput *output)
THaTrackOut(const char *name, const char *description, const char *src="", Double_t pmass=0.0)
TString fSrcName
Definition THaTrackOut.h:31
THaTrackingModule * fSrc
Definition THaTrackOut.h:35
THaTrackInfo * GetTrackInfo()
void SetXYZT(Double_t x, Double_t y, Double_t z, Double_t t)
void SetVectM(const TVector3 &spatial, Double_t mass)
const char * GetName() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
STL namespace.
TMarker m
ClassImp(TPyArg)