QwAnalysis
QwHit.cc
Go to the documentation of this file.
1 /*! \file QwHit.cc
2  * \brief Implementation of the decoding-to-QTR interface class.
3  *
4  * \author Jie Pan
5  * \date Wed Jul 8 16:18:53 CDT 2009
6  */
7 
8 #include "QwHit.h"
10 
11 // Qweak headers
12 #include "QwDetectorInfo.h"
13 
14 /**
15  * Default constructor
16  */
18 {
19  // Initialize
20  Initialize();
21 }
22 
23 
24 /**
25  * Copy-constructor with object argument
26  * @param that Hit object
27  */
28 QwHit::QwHit(const QwHit &that)
29 : VQwTrackingElement(that)
30 {
31  // Initialize
32  Initialize();
33 
34  // Copy
35  *this = that;
36 }
37 
38 
39 /**
40  * Copy-constructor with pointer argument
41  * @param that Pointer to a hit
42  */
43 QwHit::QwHit(const QwHit* that)
44 : VQwTrackingElement(*that)
45 {
46  // Initialize
47  Initialize();
48 
49  // Null pointer
50  if (that == 0) return;
51 
52  // Copy
53  *this = *that;
54 }
55 
56 
57 /**
58  * Constructor with hit parameters
59  * @param bank_index Subbank index
60  * @param slot_num Slot number
61  * @param chan Channel number
62  * @param hitcount Hit number
63  * @param region Region
64  * @param package Package
65  * @param octant Octant number
66  * @param plane Plane number
67  * @param direction Element direction
68  * @param wire Element number
69  * @param rawdata Data block
70  */
71 QwHit::QwHit(Int_t bank_index,
72  Int_t slot_num,
73  Int_t chan,
74  Int_t hitcount,
75  EQwRegionID region,
76  EQwDetectorPackage package,
77  Int_t octant,
78  Int_t plane,
79  EQwDirectionID direction,
80  Int_t wire,
81  UInt_t rawdata)
82 {
83  // Initialize
84  Initialize();
85 
86  // Set specified variables
87  fCrate = bank_index;
88  fModule = slot_num;
89  fChannel = chan;
90  fHitNumber = hitcount;
91 
92  fRegion = region;
93  fPackage = package;
94  fOctant = octant;
95  fDirection = direction;
96  fPlane = plane;
97  fElement = wire;
98 
99  fRawTime = rawdata;
100 }
101 
102 
103 /**
104  * Destructor (no action)
105  */
107 {
108  // Delete object
109 }
110 
111 
113 {
114  fCrate = 0;
115  fModule = 0;
116  fChannel = 0;
117  fHitNumber = 0;
118  fHitNumber_R = 0;
119 
123  fPlane = 0;
124  fElement = 0;
125  fDetectorInfo = 0;
126 
127  fAmbiguousElement = false;
128  fLRAmbiguity = false;
129 
130  fRawTime = 0;
131  fRawRefTime = 0;
132  fTimeNs = 0.0;
133  fTime = 0.0;
134  fTimeRes = 0.0;
135  fDistance = 0.0;
136  fWirePosition = 0.0;
137  fDriftPosition = 0.0;
138  fTreeLinePosition = 0.0;
139  fTreeLineResidual = 0.0;
140  fPartialTrackPosition = 0.0;
141  fPartialTrackResidual = 0.0;
142  fSpatialResolution = 0.0;
143  fTrackResolution = 0.0;
144 
145  fIsUsed = false;
146 }
147 
148 /**
149  * Assignment operator
150  * @param hit Right-hand side
151  * @return Left-hand side
152  */
154 {
155  if(this == & hit)
156  return *this;
157  fCrate = hit.fCrate;
158  fModule = hit.fModule;
159  fChannel = hit.fChannel;
160  fHitNumber = hit.fHitNumber;
162 
163  fRegion = hit.fRegion;
164  fPackage = hit.fPackage;
165  fDirection = hit.fDirection;
166  fPlane = hit.fPlane;
167  fElement = hit.fElement;
169 
172 
173  fRawTime = hit.fRawTime;
174  fRawRefTime = hit.fRawRefTime;
175  fTimeNs = hit.fTimeNs;
176  fTime = hit.fTime;
177  fTimeRes = hit.fTimeRes;
178  fDistance = hit.fDistance;
187 
188  fIsUsed = hit.fIsUsed;
189 
190  return *this;
191 }
192 
193 
194 /**
195  * Ordering operator, with ordering defined as
196  * region -> direction -> package -> plane -> element -> hit order
197  * \author Rakitha
198  * \date 08/23/2008
199  *
200  * @param obj Right-hand side
201  * @return Ordering
202  */
203 Bool_t QwHit::operator<(const QwHit& obj)
204 {
205  Bool_t bCompare = false;
206 
207  if (fRegion < obj.fRegion)
208  {//;
209  bCompare = true;
210  }//;
211  else if (fRegion == obj.fRegion)
212  {//;
213  if (fDirection < obj.fDirection)
214  {//;;
215  bCompare = true;
216  }//;;
217  else if (fDirection == obj.fDirection)
218  {//;;
219  if (fPackage < obj.fPackage)
220  {//;;;
221  bCompare = true;
222  }//;;;
223  else if (fPackage == obj.fPackage)
224  {//;;;
225  if (fPlane < obj.fPlane)
226  {//;;;;
227  bCompare = true;
228  }//;;;;
229  else if (fPlane == obj.fPlane)
230  {//;;;;
231  if (fElement < obj.fElement)
232  {
233  bCompare = true;
234  }
235  else if (fElement == obj.fElement)
236  {
237  if (fHitNumber < obj.fHitNumber) bCompare = true;
238  else bCompare = false;
239  }
240  else
241  {
242  bCompare = false;
243  }
244  }//;;;;
245  else
246  {//;;;;
247  bCompare = false;
248  }//;;;;
249  }//;;;
250  else
251  {//;;;
252  bCompare = false;
253  }//;;;
254  }//;;
255  else
256  {//;;
257  bCompare = false;
258  }//;;
259  }//;
260  else
261  {//;
262  bCompare = false;
263  }//;
264 
265  return bCompare;
266 
267 }
268 
269 
270 /**
271  * Output stream operator
272  * @param stream Stream
273  * @param hit Hit object
274  * @return Output stream
275  */
276 std::ostream& operator<< (std::ostream& stream, const QwHit& hit)
277 {
278  stream << "hit: ";
279  stream << "package " << hit.fPackage << ", ";
280  stream << "octant " << hit.fOctant << ", ";
281  stream << "region " << hit.fRegion << ", ";
282  stream << "dir " << hit.fDirection << ", ";
283  stream << "plane " << hit.fPlane;
284 
285  if (hit.fDetectorInfo) stream << " (det " << hit.fDetectorInfo->GetDetectorName() << "), ";
286  else stream << ", ";
287 
288  stream << "element " << hit.fElement;
289  if (hit.fDistance != 0.0)
290  stream << ", distance " << hit.fDistance/Qw::cm << " cm";
291 
292  if (hit.fTreeLineResidual != 0.0)
293  stream << ", tl |" << hit.fDriftPosition/Qw::cm << " - " << hit.fTreeLinePosition/Qw::cm
294  << "| = " << hit.fTreeLineResidual/Qw::cm << " cm";
295 
296  if (hit.fPartialTrackResidual != 0.0)
297  stream << ", pt |" << hit.fDriftPosition/Qw::cm << " - " << hit.fPartialTrackPosition/Qw::cm
298  << "| = " << hit.fPartialTrackResidual/Qw::cm << " cm";
299 
300  if (hit.fAmbiguousElement) stream << " (?)";
301 
302  if (hit.fDetectorInfo &&
303  hit.fDetectorInfo->GetCrosstalkElement(hit.fElement) > 0) stream << " (X)";
304 
305  return stream;
306 }
307 
308 
309 /**
310  * Print debugging information by using the output stream operator.
311  *
312  * \note The use of the output stream operator is preferred.
313  */
314 void QwHit::Print(const Option_t* options) const
315 {
316  if (! this) return; // do nothing if this is a null object
317  std::cout << *this << std::endl;
318 }
319 
320 
322 {
324 }
325 
326 
328 {
330 }
331 
332 // this function might be modified later
333 void QwHit::SetAmbiguityID (const Bool_t amelement, const Bool_t amlr)
334 {
335  SetAmbiguousElement(amelement);
336  SetLRAmbiguity(amlr);
337 }
338 
339 // below two metods retrieve subsets of QwHitContainer vector
340 // - rakitha (08/2008)
342  EQwDetectorPackage package,
343  Int_t plane)
344 {
345  return (fRegion == region && fPackage == package && fPlane == plane);
346 }
347 
349  EQwDetectorPackage package,
350  EQwDirectionID dir)
351 {
352  return (fRegion == region && fPackage == package && fDirection == dir);
353 }
354 
355 // main use of this method is to count no.of hits for a given wire
356 // and update the fHitNumber - rakitha (08/2008)
358  EQwDetectorPackage package,
359  Int_t plane,
360  Int_t wire)
361 {
362  return (fRegion == region && fPackage == package && fPlane == plane && fElement == wire);
363 }
364 
EQwDirectionID fDirection
Direction.
int fElement
Element number.
void Initialize()
Initialize the hit.
Definition: QwHit.cc:112
const QwDetectorID GetDetectorID() const
Definition: QwHit.cc:321
EQwDetectorPackage fPackage
Package.
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
Definition: QwColor.h:153
void SetLRAmbiguity(const Bool_t amlr)
Definition: QwHit.h:117
int fPlane
Plane number.
std::string GetDetectorName() const
Double_t fDistance
Definition: QwHit.h:184
Bool_t DirMatches(EQwRegionID region, EQwDetectorPackage package, EQwDirectionID dir)
Definition: QwHit.cc:348
Int_t fChannel
Channel number.
Definition: QwHit.h:168
UInt_t fRawRefTime
Time as reported by TDC as a reference time.
Definition: QwHit.h:180
Double_t fSpatialResolution
Spatial resolution.
Definition: QwHit.h:199
int fOctant
Octant number.
Double_t fTimeRes
Resolution of time (if appropriate)
Definition: QwHit.h:183
EQwRegionID fRegion
///&lt; Detector info pointer
Bool_t fLRAmbiguity
Definition: QwHit.h:174
EQwDetectorPackage
Definition: QwTypes.h:70
Double_t fTrackResolution
Track resolution.
Definition: QwHit.h:200
Double_t fTreeLinePosition
Position of the fitted treeline through the drift cell.
Definition: QwHit.h:191
Double_t fDriftPosition
Position of the decoded hit in the drift cell.
Definition: QwHit.h:186
Double_t fTimeNs
Reference Corrected and TimeCalibration time (unit ns)
Definition: QwHit.h:181
Double_t fTreeLineResidual
Definition: QwHit.h:192
QwHit & operator=(const QwHit &hit)
Assignment operator.
Definition: QwHit.cc:153
EQwRegionID
Definition: QwTypes.h:16
Bool_t fIsUsed
Definition: QwHit.h:202
Bool_t operator<(const QwHit &hit)
Ordering operator.
Definition: QwHit.cc:203
Draft skeleton for the decoding-to-QTR interface class.
Int_t fModule
F1TDC slot number, or module index.
Definition: QwHit.h:167
void Print(const Option_t *options=0) const
Print debugging information.
Definition: QwHit.cc:314
Bool_t WireMatches(EQwRegionID region, EQwDetectorPackage package, Int_t plane, Int_t wire)
Definition: QwHit.cc:357
Double_t fTime
Start corrected time, may also be further modified.
Definition: QwHit.h:182
int GetCrosstalkElement(int element) const
void SetAmbiguityID(const Bool_t amelement, const Bool_t amlr)
Definition: QwHit.cc:333
Bool_t fAmbiguousElement
Definition: QwHit.h:172
const QwDetectorInfo * fDetectorInfo
EQwDirectionID
Definition: QwTypes.h:41
ClassImp(QwF1TDC)
Double_t fPartialTrackResidual
Definition: QwHit.h:196
Hit structure uniquely defining each hit.
Definition: QwHit.h:43
Int_t fCrate
ROC number.
Definition: QwHit.h:161
Bool_t PlaneMatches(EQwRegionID region, EQwDetectorPackage package, Int_t plane)
Definition: QwHit.cc:341
void SetAmbiguousElement(const Bool_t amelement)
Definition: QwHit.h:116
Int_t fHitNumber
Index for multiple hits in a single channel on the left.
Definition: QwHit.h:169
Double_t fPartialTrackPosition
Position of the fitted treeline through the drift cell.
Definition: QwHit.h:195
Double_t fWirePosition
Definition: QwHit.h:187
Int_t fHitNumber_R
Index for multiple hits in a single channel on the right.
Definition: QwHit.h:170
virtual ~QwHit()
Destructor.
Definition: QwHit.cc:106
QwHit()
Definition: QwHit.cc:17
static const double cm
Length units: base unit is mm.
Definition: QwUnits.h:61
const QwElectronicsID GetElectronicsID() const
Definition: QwHit.cc:327
Virtual base class for all tracking elements.
UInt_t fRawTime
Time as reported by TDC; it is a raw data word, and is UNSUBTRACTED.
Definition: QwHit.h:179