QwAnalysis
QwTreeLine.h
Go to the documentation of this file.
1 /**
2  * \file QwTreeLine.h
3  * \brief Definition of the one-dimensional track stubs
4  *
5  * \author Wouter Deconinck <wdconinc@mit.edu>
6  * \author Jie Pan <jpan@jlab.org>
7  * \date Sun May 24 11:05:29 CDT 2009
8  */
9 
10 #ifndef QWTREELINE_H
11 #define QWTREELINE_H
12 
13 // System headers
14 #include <vector>
15 #include <utility>
16 
17 // ROOT headers
18 #include <TClonesArray.h>
19 #include <TObjArray.h>
20 #include <TRefArray.h>
21 
22 // Qweak headers
23 #include "VQwTrackingElement.h"
24 #include "QwTypes.h"
25 #include "QwObjectCounter.h"
26 #include "QwHit.h"
27 #include "globals.h"
28 #include "QwHitPattern.h"
29 
30 // Maximum number of detectors combined for left-right ambiguity resolution
31 #define TREELINE_MAX_NUM_LAYERS 8
32 
33 // Forward declarations
34 class QwHit;
35 // class QwHitPattern;
36 class QwHitContainer;
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39 
40 /**
41  * \class QwTreeLine
42  * \ingroup QwTracking
43  * \brief One-dimensional (u, v, or x) track stubs and associated hits
44  *
45  * The QwTreeLine has a pointer to a set of hits. It is passed to
46  * various track fitting procedures and carries around the fit results.
47  *
48  * \todo This class needs a non-trivial copy constructor which ensures
49  * that the hits are copied correctly.
50  */
51 class QwTreeLine: public VQwTrackingElement, public QwObjectCounter<QwTreeLine> {
52 
53  private:
54 
55  //! Number of hits in this tree line
56  Int_t fNQwHits;
57  //! List of hits in this tree line
58  std::vector<QwHit*> fQwHits;
59 
60  public:
61 
62 
63  /// Default constructor
64  QwTreeLine();
65  /// Constructor with tree search results
66  QwTreeLine(int _a_beg, int _a_end , int _b_beg, int _b_end);
67  /// Constructor with offset and slope
68  QwTreeLine(double offset, double slope);
69  /// Copy constructor
70  QwTreeLine(const QwTreeLine& that);
71  /// Copy constructor
72  QwTreeLine(const QwTreeLine* that);
73  /// Destructor
74  virtual ~QwTreeLine();
75 
76  /// Assignment operator
77  QwTreeLine& operator=(const QwTreeLine& treeline);
78 
79  private:
80 
81  /// Initialization
82  void Initialize();
83 
84  public:
85 
86  //! Is this tree line void?
87  bool IsVoid() const { return fIsVoid; }
88  void SetVoid(const bool isvoid = true) { fIsVoid = isvoid; }
89  //! Is this tree line valid?
90  bool IsValid() const { return ! fIsVoid; }
91  void SetValid(const bool isvoid = false) { fIsVoid = isvoid; }
92  //! Is this tree line not void?
93  bool IsNotVoid() const { return ! fIsVoid; }
94  void SetNotVoid(const bool isvoid = false) { fIsVoid = isvoid; }
95  //! Is this tree line used?
96  bool IsUsed() const { return fIsUsed; }
97  void SetUsed(const bool isused = true) { fIsUsed = isused; }
98  //! Is this tree line not used?
99  bool IsNotUsed() const { return ! fIsUsed; }
100  void SetNotUsed(const bool isused = false) { fIsUsed = isused; }
101 
102  //! \name Creating, adding, and getting hits and hit containers
103  // @{
104  //! \brief Add a single hit
105  void AddHit(const QwHit* hit);
106  //! \brief Add a list of hits
107  void AddHitList(const std::vector<QwHit*> &fQwHits);
108  //! \brief Get the number of hits
109  Int_t GetNumberOfHits() const { return fNQwHits; }
110  //! \brief Get a specific hit
111  QwHit* GetHit(int i = 0);
112  //! \brief Get a specific hit (const version)
113  const QwHit* GetHit(int i = 0) const;
114  //! \brief Get the list of hits
115  const std::vector<QwHit*>& GetListOfHits() const { return fQwHits; };
116  //! \brief Clear the list of hits without deleting
117  void ClearHits();
118  //! \brief Delete a single hit
119  void DeleteHit(const size_t i);
120  //! \brief Delete the hits in the list
121  void DeleteHits();
122  // @}
123 
124  //! \brief Get the weighted chi^2
125  double GetChiWeight ();
126 
127  //! \brief Get the hit with the smallest drift distance
128  QwHit* GetBestWireHit (double offset = 0.0);
129 
130  void Print(const Option_t* options = 0) const;
131  void PrintValid();
132 
133  //! \brief Output stream operator
134  friend std::ostream& operator<< (std::ostream& stream, const QwTreeLine& tl);
135 
136  //! \name Positions and resolutions in wire planes
137  // @{
138  //! Returns position at the first detector plane
139  // binwidth=0.2921 here, might be changed later
140  double GetPositionFirst (const double binwidth) {
141  //return 0.5 * (a_beg + a_end) * binwidth + 0.5*binwidth;
142  return 0.5*(a_beg + a_end)*binwidth;
143  }
144  //! Returns position at the last detector plane
145  double GetPositionLast (const double binwidth) {
146  return 0.5*(b_beg+b_end)*binwidth;
147  //return 0.5 * (b_beg + b_end) * binwidth + 0.5*binwidth;
148 
149  }
150  //! Returns resolution at the first detector plane
151  double GetResolutionFirst (const double binwidth) {
152  return (a_end - a_beg) * binwidth;
153  }
154  //! Returns resolution at the last detector plane
155  double GetResolutionLast (const double binwidth) {
156  return (b_end - b_beg) * binwidth;
157  }
158  // @}
159 
160  //! \name Calculate the residuals
161  // @{
162  //! Get the average residuals
163  double GetAverageResidual() const { return fAverageResidual; }
164  //! Set the average residuals
165  void SetAverageResidual(const double residual) { fAverageResidual = residual; }
166  //! Calculate the average residuals
167  double CalculateAverageResidual();
168  //! Calculate and set the average residuals
170  // @}
171 
172  //! Set the offset
173  void SetOffset(const double offset) { fOffset = offset; }
174  //! Get the offset
175  double GetOffset() const { return fOffset; }
176  //! Set the slope
177  void SetSlope(const double slope) { fSlope = slope; }
178  //! Get the slope
179  double GetSlope() const { return fSlope; }
180  //! Set the chi^2
181  void SetChi(const double chi) { fChi = chi; }
182  //! Get the chi^2
183  double GetChi() const { return fChi; }
184  //! Set the covariance
185  void SetCov(const double* cov) { fCov[0] = cov[0]; fCov[1] = cov[1]; fCov[2] = cov[2]; }
186  //! Get the covariance
187  const double* GetCov() const { return fCov; }
188  /// Set the matching pattern
189  void SetMatchingPattern(std::vector<int>& box);
190  /// calculate the upper and lower bound of the drift distance give the row number
191  std::pair<double,double> CalculateDistance(int row,double width,unsigned int bins,double error);
192 
193  /// Get vector for linked list of treelines
194  std::vector<QwTreeLine*> GetListAsVector() const {
195  std::vector<QwTreeLine*> list;
196  QwTreeLine* treeline = const_cast<QwTreeLine*>(this);
197  while (treeline) {
198  list.push_back(treeline);
199  treeline = treeline->next;
200  }
201  return list;
202  }
203 
204  private:
205 
206  bool fIsVoid; ///< has been found void
207  bool fIsUsed; ///< has been used (part of parttrack)
208 
209  public:
210 
211 // QwHitPattern* fMatchingPattern; //! ///< matching hit pattern
212  std::vector<int> fMatchingPattern;
213  double fOffset; ///< track offset
214  double fSlope; ///< track slope
215  double fChi; ///< chi squared(?)
216  double fCov[3]; ///< covariance matrix of offset and slope
217 
218  int a_beg, a_end; ///< bin in first layer
219  int b_beg, b_end; ///< bin in last layer
220 
221  int fNumHits; ///< number of hits on this treeline
222  int fNumMiss; ///< number of planes without hits
223 
224  QwHit* fHits[2*MAX_LAYERS]; //! ///< all hits that satisfy road requirement
225 
226  int fHashArray[2*MAX_LAYERS]; //!
227 
228  int fR3Offset; ///< offset of demultiplexed group of 8
229  int fR3FirstWire, fR3LastWire; ///< first and last wire in group of 8
230 
231  QwTreeLine *next; //! ///< link to next list element
232 
233  private:
234 
235  double fAverageResidual; ///< average residual over all used hits
236 
237  ClassDef(QwTreeLine,1);
238 
239 }; // class QwTreeLine
240 
242 
244 
245 #endif // QWTREELINE_H
double fChi
chi squared(?)
Definition: QwTreeLine.h:215
QwTreeLine QwTrackingTreeLine
Definition: QwTreeLine.h:241
bool IsNotVoid() const
Is this tree line not void?
Definition: QwTreeLine.h:93
int fHashArray[2 *MAX_LAYERS]
///&lt; all hits that satisfy road requirement
Definition: QwTreeLine.h:226
double fOffset
track offset
Definition: QwTreeLine.h:213
const std::vector< QwHit * > & GetListOfHits() const
Get the list of hits.
Definition: QwTreeLine.h:115
void SetNotVoid(const bool isvoid=false)
Definition: QwTreeLine.h:94
void SetMatchingPattern(std::vector< int > &box)
Set the matching pattern.
Definition: QwTreeLine.cc:367
bool fIsUsed
has been used (part of parttrack)
Definition: QwTreeLine.h:207
void DeleteHits()
Delete the hits in the list.
Definition: QwTreeLine.cc:201
int fR3Offset
offset of demultiplexed group of 8
Definition: QwTreeLine.h:228
Int_t GetNumberOfHits() const
Get the number of hits.
Definition: QwTreeLine.h:109
bool fIsVoid
has been found void
Definition: QwTreeLine.h:206
QwHit * GetBestWireHit(double offset=0.0)
Get the hit with the smallest drift distance.
Definition: QwTreeLine.cc:277
double fAverageResidual
///&lt; link to next list element
Definition: QwTreeLine.h:235
double GetResolutionLast(const double binwidth)
Returns resolution at the last detector plane.
Definition: QwTreeLine.h:155
std::vector< QwHit * > fQwHits
List of hits in this tree line.
Definition: QwTreeLine.h:58
double fCov[3]
covariance matrix of offset and slope
Definition: QwTreeLine.h:216
double GetAverageResidual() const
Get the average residuals.
Definition: QwTreeLine.h:163
double GetOffset() const
Get the offset.
Definition: QwTreeLine.h:175
double GetChiWeight()
Get the weighted chi^2.
Definition: QwTreeLine.cc:257
void SetSlope(const double slope)
Set the slope.
Definition: QwTreeLine.h:177
double fSlope
track slope
Definition: QwTreeLine.h:214
VQwTrackingElementContainer< QwTreeLine > QwTreeLineContainer
Definition: QwTreeLine.h:243
double GetPositionLast(const double binwidth)
Returns position at the last detector plane.
Definition: QwTreeLine.h:145
void SetVoid(const bool isvoid=true)
Definition: QwTreeLine.h:88
bool IsUsed() const
Is this tree line used?
Definition: QwTreeLine.h:96
const double * GetCov() const
Get the covariance.
Definition: QwTreeLine.h:187
int fR3LastWire
first and last wire in group of 8
Definition: QwTreeLine.h:229
void SetAverageResidual(const double residual)
Set the average residuals.
Definition: QwTreeLine.h:165
Memory management structure to count objects.
void AddHitList(const std::vector< QwHit * > &fQwHits)
Add a list of hits.
Definition: QwTreeLine.cc:226
Definition of the hit patterns used in the tracking tree search.
void SetChi(const double chi)
Set the chi^2.
Definition: QwTreeLine.h:181
void SetValid(const bool isvoid=false)
Definition: QwTreeLine.h:91
QwHit * GetHit(int i=0)
Get a specific hit.
Definition: QwTreeLine.cc:234
void SetNotUsed(const bool isused=false)
Definition: QwTreeLine.h:100
Draft skeleton for the decoding-to-QTR interface class.
double GetChi() const
Get the chi^2.
Definition: QwTreeLine.h:183
void Print(const Option_t *options=0) const
Definition: QwTreeLine.cc:317
Memory management class to count object instantiations.
double GetPositionFirst(const double binwidth)
Returns position at the first detector plane.
Definition: QwTreeLine.h:140
int b_end
bin in last layer
Definition: QwTreeLine.h:219
void PrintValid()
Definition: QwTreeLine.cc:327
int fNumHits
number of hits on this treeline
Definition: QwTreeLine.h:221
void SetOffset(const double offset)
Set the offset.
Definition: QwTreeLine.h:173
void Initialize()
Initialization.
Definition: QwTreeLine.cc:101
bool IsNotUsed() const
Is this tree line not used?
Definition: QwTreeLine.h:99
double GetSlope() const
Get the slope.
Definition: QwTreeLine.h:179
bool IsVoid() const
Is this tree line void?
Definition: QwTreeLine.h:87
std::vector< int > fMatchingPattern
Definition: QwTreeLine.h:212
double GetResolutionFirst(const double binwidth)
Returns resolution at the first detector plane.
Definition: QwTreeLine.h:151
One-dimensional (u, v, or x) track stubs and associated hits.
Definition: QwTreeLine.h:51
int fNumMiss
number of planes without hits
Definition: QwTreeLine.h:222
std::pair< double, double > CalculateDistance(int row, double width, unsigned int bins, double error)
calculate the upper and lower bound of the drift distance give the row number
Definition: QwTreeLine.cc:374
QwTreeLine()
Default constructor.
Definition: QwTreeLine.cc:23
void SetCov(const double *cov)
Set the covariance.
Definition: QwTreeLine.h:185
void DeleteHit(const size_t i)
Delete a single hit.
Definition: QwTreeLine.cc:209
friend std::ostream & operator<<(std::ostream &stream, const QwTreeLine &tl)
Output stream operator.
Definition: QwTreeLine.cc:340
QwTreeLine & operator=(const QwTreeLine &treeline)
Assignment operator.
Definition: QwTreeLine.cc:141
ClassDef(QwTreeLine, 1)
Definition of virtual base class for all tracking elements.
void AddHit(const QwHit *hit)
Add a single hit.
Definition: QwTreeLine.cc:219
virtual ~QwTreeLine()
Destructor.
Definition: QwTreeLine.cc:84
int fR3FirstWire
Definition: QwTreeLine.h:229
bool IsValid() const
Is this tree line valid?
Definition: QwTreeLine.h:90
QwTreeLine * next
Definition: QwTreeLine.h:231
QwHit * fHits[2 *MAX_LAYERS]
Definition: QwTreeLine.h:224
void SetAverageResidual()
Calculate and set the average residuals.
Definition: QwTreeLine.h:169
Hit structure uniquely defining each hit.
Definition: QwHit.h:43
void SetUsed(const bool isused=true)
Definition: QwTreeLine.h:97
#define MAX_LAYERS
Definition: globals.h:8
int a_end
bin in first layer
Definition: QwTreeLine.h:218
std::vector< QwTreeLine * > GetListAsVector() const
Get vector for linked list of treelines.
Definition: QwTreeLine.h:194
Int_t fNQwHits
Number of hits in this tree line.
Definition: QwTreeLine.h:56
double CalculateAverageResidual()
Calculate the average residuals.
Definition: QwTreeLine.cc:296
void ClearHits()
Clear the list of hits without deleting.
Definition: QwTreeLine.cc:194
Virtual base class for all tracking elements.