Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
SimDecoder.h
Go to the documentation of this file.
1//*-- Author: Ole Hansen<mailto:ole@jlab.org>; Jefferson Lab; 5-Jul-2014
2//
3#ifndef Podd_SimDecoder_h_
4#define Podd_SimDecoder_h_
5
7//
8// Podd::SimDecoder
9//
10// Generic simulation decoder interface
11//
13
14#include "THaEvData.h"
15#include "THaAnalysisObject.h"
16#include "DataType.h" // for kBig
17#include "TClonesArray.h"
18#include "TVector3.h"
19
20namespace Podd {
21
22// Recommended prefix of MC global variables (MC truth data)
23extern const char* const MC_PREFIX;
24
25// Support classes for SimDecoder. These need to be ROOT classes so that
26// CINT doesn't choke on the return values of the respective Get functions
27
28//_____________________________________________________________________________
29// A generic Monte Carlo physics track. fMCTracks must contain either objects
30// of this class or objects that inherit from it
31class MCTrack : public TObject {
32public:
33 MCTrack( Int_t number, Int_t pid,
34 const TVector3& vertex, const TVector3& momentum );
35 MCTrack();
36
37 Double_t VX() const { return fOrigin.X(); }
38 Double_t VY() const { return fOrigin.Y(); }
39 Double_t VZ() const { return fOrigin.Z(); }
40 Double_t P() const { return fMomentum.Mag(); }
41 Double_t PTheta() const { return fMomentum.Theta(); }
42 Double_t PPhi() const { return fMomentum.Phi(); }
43
44 virtual void Print( const Option_t* opt="" ) const;
45
46 // Physics truth data
47 Int_t fNumber; // Track counter
48 Int_t fPID; // Track particle ID (PDG)
49 TVector3 fOrigin; // Vertex position (m)
50 TVector3 fMomentum; // Momentum (GeV)
51
52 // Interaction with detector
53 Int_t fNHits; // Number of hits (typ.: in tracker planes)
54 Int_t fHitBits; // Bitpattern of plane nums hit by this track
55
56 // Reconstruction status (implementation-dependent)
57 Int_t fNHitsFound; // Number of reconstructed hits
58 Int_t fFoundBits; // Bitpattern of plane numbers with found hits
59 Int_t fReconFlags; // Reconstruction status flags
60 Int_t fContamFlags; // Flags indicating contaminated fits
61 Double_t fMatchval; // Projection matchvalue, if applicable
62 Int_t fFitRank; // Rank of final track fit (0=best)
63 Int_t fTrackRank; // Rank of final track after pruning (0=best)
64
65 // Reconstruction fit quality checks (implementation-dependent)
66 static const Int_t NFP = 16;
67 Double_t fMCFitPar[NFP]; // Results of fit(s) to MC hits
68 Double_t fRcFitPar[NFP]; // Results of fit(s) to reconstructed hits
69
70 ClassDef(MCTrack,2) // An MC physics track
71};
72
73//_____________________________________________________________________________
74// Track points typically are hits of the physics tracks (recorded in fMCTracks)
75// recorded in tracker planes. They are stored for every track and can be
76// exported as global variables. This is opposed to MCHitInfo, which is the
77// _digitized_ hit information for any MC hits (primaries, secondaries,
78// background) and which generated on demand for certain hardware channels,
79// typically to compare measured to true hit data
80
81// MC truth information for digitized detector hits
82class MCHitInfo {
83public:
84 MCHitInfo() : fMCTrack(0), fContam(0), fMCPos(0), fMCTime(0) {}
85 MCHitInfo( Int_t mctrk, Double_t mcpos, Double_t time, Int_t contam = 0 )
86 : fMCTrack(mctrk), fContam(contam), fMCPos(mcpos), fMCTime(time) {}
87 virtual ~MCHitInfo() = default;
88
89 void MCPrint() const;
90 void MCClear() { fMCTrack = fContam = 0; fMCPos = fMCTime = 0; }
91
92 Int_t fMCTrack; // MC signal track number generating this hit
93 Int_t fContam; // Indicator for contributions other than signal
94 Double_t fMCPos; // True MC track crossing position (m)
95 Double_t fMCTime; // Hit time (s)
96
97 ClassDef(MCHitInfo,1) // Generic Monte Carlo hit info
98};
99
100//_____________________________________________________________________________
101// A MC physics track's interaction point at a tracker plane in the lab system.
102class MCTrackPoint : public TObject {
103public:
108 MCTrackPoint( Int_t mctrk, Int_t plane, Int_t type, const TVector3& point,
109 const TVector3& pvect )
110 : fMCTrack(mctrk), fPlane(plane), fType(type), fStatus(0), fNFound(0),
111 fClustSize(0), fMCPoint(point), fMCP(pvect), fMCTime(kBig), fDeltaE(kBig),
113 virtual ~MCTrackPoint() = default;
114
115 virtual Int_t Compare( const TObject* obj ) const;
116 virtual Bool_t IsSortable() const { return true; }
117 virtual void Print( Option_t* opt ) const;
118
119 Double_t X() const { return fMCPoint.X(); }
120 Double_t Y() const { return fMCPoint.Y(); }
121 Double_t P() const { return fMCP.Mag(); }
122 Double_t ThetaT() const { return fMCP.Px()/fMCP.Pz(); }
123 Double_t PhiT() const { return fMCP.Py()/fMCP.Pz(); }
124 Double_t R() const { return fMCPoint.Perp(); }
125 Double_t Theta() const { return fMCPoint.Theta(); }
126 Double_t Phi() const { return fMCPoint.Phi(); }
127 Double_t ThetaDir() const { return fMCP.Theta(); }
128 Double_t PhiDir() const { return fMCP.Phi(); }
129
130 // Bits for fStatus. "Found" refers to reconstructed hits
131 enum { kDigitized = 0, // Digitized (signal in electronics)
132 kFound = 1, // Hit found in search window
133 kCorrectFound = 2, // Found hit from the correct MC track
134 // (not necessarily closest or in window)
135 kCorrectClosest = 3, // Correct hit is also the closest and in window
136 kContaminated = 4, // Correct hit contains background
137 kUsedInTrack = 5, // Correct hit used in a final track
138 kCorrectFarAway = 6, // Correct hit lies outside of search window!
139 kWrongTrack = 7 // Closest hit is from wrong MC track
140 };
141
142 Int_t fMCTrack; // MC track number generating this point
143 Int_t fPlane; // Tracker plane/layer number
144 Int_t fType; // Plane type (u,v,x etc.)
145 Int_t fStatus; // Reconstruction status bits
146 Int_t fNFound; // Number of reconstructed hits found near this one
147 Int_t fClustSize;// Size of reconstructed hit/cluster
148 TVector3 fMCPoint; // Truth position of MC physics track in tracker plane (m)
149 TVector3 fMCP; // True momentum vector at this position (GeV)
150 Double_t fMCTime; // Arrival time wrt trigger (s)
151 Double_t fDeltaE; // Energy loss wrt prior plane, kBig if unknown (GeV)
152 Double_t fDeflect; // Deflection angle wrt prior plane (rad) or kBig
153 Double_t fToF; // Time-of-flight from prior plane (s) or kBig
154 Double_t fHitResid; // True residual nearest reconstr. hit pos - MC hit pos (m)
155 Double_t fTrackResid; // True residual reconstructed track - MC hit pos (m)
156
157 static Double_t fgWindowSize; // Half-size of search window (m)
158
159 ClassDef(MCTrackPoint,3) // Monte Carlo track interaction coordinates
160};
161
162//_____________________________________________________________________________
163// Simulation decoder class
164class SimDecoder : public THaEvData {
165 public:
166 SimDecoder();
167 virtual ~SimDecoder();
168
169 virtual void Clear( Option_t* opt="" );
170 virtual MCHitInfo GetMCHitInfo( Int_t crate, Int_t slot, Int_t chan ) const;
173
174 Double_t GetWeight() const { return fWeight; }
175
176 TObject* GetMCHit( Int_t i ) const {
177 return (fMCHits) ? fMCHits->UncheckedAt(i) : nullptr;
178 }
180 return (fMCTracks) ? fMCTracks->UncheckedAt(i) : nullptr;
181 }
183 return (fMCPoints) ?
184 static_cast<Podd::MCTrackPoint*>(fMCPoints->UncheckedAt(i)) : nullptr;
185 }
187 return (fMCHits) ? fMCHits->GetLast()+1 : 0;
188 }
190 return (fMCTracks) ? fMCTracks->GetLast()+1 : 0;
191 }
193 return (fMCPoints) ? fMCPoints->GetLast()+1 : 0;
194 }
195
196protected:
197
198 Double_t fWeight; // Event weight
199
200 TClonesArray* fMCHits; //-> MC hits
201 TClonesArray* fMCTracks; //-> MC physics tracks
202 TClonesArray* fMCPoints; //-> MC physics track points
203 Bool_t fIsSetup; // DefineVariables has run
204
205 ClassDef(SimDecoder,0) // Generic decoder for simulation data
206};
207
209
210} // end namespace Podd
211
212#endif
int Int_t
const Data_t kBig
Definition DataType.h:15
uint32_t time
uint32_t chan
bool Bool_t
double Double_t
const char Option_t
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
MCHitInfo(Int_t mctrk, Double_t mcpos, Double_t time, Int_t contam=0)
Definition SimDecoder.h:85
Double_t fMCTime
Definition SimDecoder.h:95
void MCPrint() const
virtual ~MCHitInfo()=default
Double_t fMCPos
Definition SimDecoder.h:94
virtual ~MCTrackPoint()=default
Double_t PhiDir() const
Definition SimDecoder.h:128
Double_t PhiT() const
Definition SimDecoder.h:123
MCTrackPoint(Int_t mctrk, Int_t plane, Int_t type, const TVector3 &point, const TVector3 &pvect)
Definition SimDecoder.h:108
virtual Bool_t IsSortable() const
Definition SimDecoder.h:116
static Double_t fgWindowSize
Definition SimDecoder.h:157
Double_t X() const
Definition SimDecoder.h:119
Double_t ThetaDir() const
Definition SimDecoder.h:127
Double_t Y() const
Definition SimDecoder.h:120
Double_t ThetaT() const
Definition SimDecoder.h:122
virtual Int_t Compare(const TObject *obj) const
Double_t Phi() const
Definition SimDecoder.h:126
virtual void Print(Option_t *opt) const
Double_t R() const
Definition SimDecoder.h:124
Double_t Theta() const
Definition SimDecoder.h:125
Double_t P() const
Definition SimDecoder.h:121
Double_t PPhi() const
Definition SimDecoder.h:42
TVector3 fOrigin
Definition SimDecoder.h:49
Double_t fRcFitPar[NFP]
Definition SimDecoder.h:68
Double_t fMatchval
Definition SimDecoder.h:61
Double_t VZ() const
Definition SimDecoder.h:39
Double_t PTheta() const
Definition SimDecoder.h:41
Int_t fNHitsFound
Definition SimDecoder.h:57
Double_t VY() const
Definition SimDecoder.h:38
virtual void Print(const Option_t *opt="") const
static const Int_t NFP
Definition SimDecoder.h:66
Double_t fMCFitPar[NFP]
Definition SimDecoder.h:67
Int_t fReconFlags
Definition SimDecoder.h:59
Int_t fTrackRank
Definition SimDecoder.h:63
Int_t fFoundBits
Definition SimDecoder.h:58
Double_t P() const
Definition SimDecoder.h:40
Double_t VX() const
Definition SimDecoder.h:37
Int_t fContamFlags
Definition SimDecoder.h:60
TVector3 fMomentum
Definition SimDecoder.h:50
virtual ~SimDecoder()
TObject * GetMCTrack(Int_t i) const
Definition SimDecoder.h:179
virtual void Clear(Option_t *opt="")
Double_t GetWeight() const
Definition SimDecoder.h:174
TObject * GetMCHit(Int_t i) const
Definition SimDecoder.h:176
Int_t GetNMCPoints() const
Definition SimDecoder.h:192
Int_t GetNMCTracks() const
Definition SimDecoder.h:189
TClonesArray * fMCTracks
Definition SimDecoder.h:201
MCTrackPoint * GetMCPoint(Int_t i) const
Definition SimDecoder.h:182
virtual MCHitInfo GetMCHitInfo(Int_t crate, Int_t slot, Int_t chan) const
Int_t GetNMCHits() const
Definition SimDecoder.h:186
TClonesArray * fMCPoints
Definition SimDecoder.h:202
TClonesArray * fMCHits
Definition SimDecoder.h:200
virtual Int_t DefineVariables(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine)
TObject * UncheckedAt(Int_t i) const
Int_t GetLast() const override
Double_t Z() const
Double_t Px() const
Double_t Phi() const
Double_t Y() const
Double_t Py() const
Double_t X() const
Double_t Pz() const
Double_t Mag() const
Double_t Theta() const
Double_t Perp() const
const char *const MC_PREFIX
double * vertex