Hall C ROOT/C++ Analyzer (hcana)
THcDCHit.cxx
Go to the documentation of this file.
1 
7 #include "THcDCHit.h"
8 #include "THcDCTimeToDistConv.h"
9 
10 #include <iostream>
11 
12 using std::cout;
13 using std::endl;
14 
15 const Double_t THcDCHit::kBig = 1.e38; // Arbitrary large value
16 
17 //_____________________________________________________________________________
18 void THcDCHit::Print( Option_t* opt ) const
19 {
20  // Print hit info
21 
22  cout << "Hit: wire=" << GetWireNum()
23  << "/" << (fWirePlane ? fWirePlane->GetName() : "??")
24  << " wpos=" << GetPos()
25  << " time=" << GetTime()
26  << " drift=" << GetDist();
27  // << " res=" << GetResolution()
28  // << " z=" << GetZ()
29  if( *opt != 'C' )
30  cout << endl;
31 }
32 
33 //_____________________________________________________________________________
35 {
36  // Converts TDC time to drift distance
37  // Takes the (estimated) slope of the track as an argument
38 
39  THcDCTimeToDistConv* ttdConv = (fWire) ? fWire->GetTTDConv() : NULL;
40 
41  if (ttdConv) {
42  // If a time to distance algorithm exists, use it to convert the TDC time
43  // to the drift distance
44  fDist = ttdConv->ConvertTimeToDist(fTime);
45  return fDist;
46  }
47 
48  Error("ConvertTimeToDist()", "No Time to dist algorithm available");
49  return 0.0;
50 
51 }
52 
53 //_____________________________________________________________________________
54 Int_t THcDCHit::Compare( const TObject* obj ) const
55 {
56  // Used to sort hits
57  // A hit is "less than" another hit if it occurred on a lower wire number.
58  // Also, for hits on the same wire, the first hit on the wire (the one with
59  // the smallest time) is "less than" one with a higher time. If the hits
60  // are sorted according to this scheme, they will be in order of increasing
61  // wire number and, for each wire, will be in the order in which they hit
62  // the wire
63 
64  if( !obj || IsA() != obj->IsA() || !fWire )
65  return -1;
66 
67  const THcDCHit* hit = static_cast<const THcDCHit*>( obj );
68 
69  Int_t myWireNum = fWire->GetNum();
70  Int_t hitWireNum = hit->GetWire()->GetNum();
71  Int_t myPlaneNum = GetPlaneNum();
72  Int_t hitPlaneNum = hit->GetPlaneNum();
73  if (myPlaneNum < hitPlaneNum) return -1;
74  if (myPlaneNum > hitPlaneNum) return 1;
75  // If planes are the same, compare wire numbers
76  if (myWireNum < hitWireNum) return -1;
77  if (myWireNum > hitWireNum) return 1;
78  // If wire numbers are the same, compare times
79  Double_t hitTime = hit->GetTime();
80  if (fTime < hitTime) return -1;
81  if (fTime > hitTime) return 1;
82  return 0;
83 }
84 
86 
87 
Drift chamber wire hit info.
Definition: THcDCHit.h:16
static const Double_t kBig
Definition: THcDCHit.h:66
const char Option_t
Int_t Compare(const TObject *obj) const
Definition: THcDCHit.cxx:54
THcDCWire * GetWire() const
Definition: THcDCHit.h:34
THcDriftChamberPlane * fWirePlane
Definition: THcDCHit.h:72
Double_t fDist
Pointer to parent wire plane.
Definition: THcDCHit.h:73
int Int_t
Int_t GetWireNum() const
Definition: THcDCHit.h:36
virtual Double_t ConvertTimeToDist(Double_t time)=0
Double_t fTime
Definition: THcDCHit.h:71
Base class for algorithms to convert time into perpendicular drift distance.
virtual void Error(const char *method, const char *msgfmt,...) const
Int_t GetPlaneNum() const
Definition: THcDCHit.h:58
THcDCTimeToDistConv * GetTTDConv()
Definition: THcDCWire.h:31
Double_t GetTime() const
Definition: THcDCHit.h:39
Double_t GetPos() const
Definition: THcDCHit.h:41
virtual void Print(Option_t *opt="") const
Definition: THcDCHit.cxx:18
double Double_t
ClassImp(THcDCLookupTTDConv) THcDCLookupTTDConv
Int_t GetNum() const
Definition: THcDCWire.h:25
virtual Double_t ConvertTimeToDist()
Definition: THcDCHit.cxx:34
THcDCWire * fWire
Definition: THcDCHit.h:68
Double_t GetDist() const
Definition: THcDCHit.h:40