StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMtdHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StMtdHit.cxx,v 2.3 2015/10/09 17:46:14 ullrich Exp $
4  *
5  * Author: Frank Geurts, April 25, 2011
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StMtdHit.cxx,v $
13  * Revision 2.3 2015/10/09 17:46:14 ullrich
14  * Changed type of mIdTruth from ushort to int.
15  *
16  * Revision 2.2 2012/02/28 01:24:51 perev
17  * tof() implementation added
18  *
19  * Revision 2.1 2011/04/25 21:24:02 ullrich
20  * Initial Revision.
21  *
22  **************************************************************************/
23 #include "StMtdHit.h"
24 #include "StTrack.h"
25 
26 ClassImp(StMtdHit)
27 
29 {
30  mBackLeg = 0;
31  mModule = 0;
32  mCell = 0;
33  mLeadingEdgeTime.first = 0.;
34  mTrailingEdgeTime.second = 0.;
35  mLeadingEdgeTime.first = 0.;
36  mTrailingEdgeTime.second = 0.;
37 
38  mAssociatedTrack = 0;
39  mIdTruth = 0;
40  mQuality = 0;
41 }
42 
43 StMtdHit::~StMtdHit() {/* noop */}
44 
45 int
46 StMtdHit::backleg() const { return mBackLeg; }
47 
48 int
49 StMtdHit::module() const { return mModule; }
50 
51 int
52 StMtdHit::cell() const { return mCell; }
53 
54 pair<double,double>
55 StMtdHit::leadingEdgeTime() const { return mLeadingEdgeTime; }
56 
57 pair<double,double>
58 StMtdHit::trailingEdgeTime() const { return mTrailingEdgeTime; }
59 
60 pair<double,double>
61 StMtdHit::tot() const { return pair<double,double>(mTrailingEdgeTime.first - mLeadingEdgeTime.first, mTrailingEdgeTime.second - mLeadingEdgeTime.second); }
62 
63 double StMtdHit::tof() const { return 0.5*(mLeadingEdgeTime.first+mLeadingEdgeTime.second); }
64 
65 StTrack*
66 StMtdHit::associatedTrack() { return mAssociatedTrack; }
67 
68 const StTrack*
69 StMtdHit::associatedTrack() const { return mAssociatedTrack; }
70 
71 int
72 StMtdHit::idTruth() const { return mIdTruth; }
73 
74 int
75 StMtdHit::qaTruth() const { return mQuality; }
76 
77 void
78 StMtdHit::setBackleg(unsigned char backlegId) { mBackLeg = backlegId; }
79 
80 void
81 StMtdHit::setModule(unsigned char moduleId) { mModule = moduleId; }
82 
83 void
84 StMtdHit::setCell(unsigned char cellId) { mCell = cellId; }
85 
86 void
87 StMtdHit::setLeadingEdgeTime(pair<double,double> time) { mLeadingEdgeTime = time; }
88 
89 void
90 StMtdHit::setTrailingEdgeTime(pair<double,double> time) { mTrailingEdgeTime = time; }
91 
92 void
93 StMtdHit::setAssociatedTrack(StTrack* val) { mAssociatedTrack = val; }
94 
95 void
96 StMtdHit::setIdTruth(int idtru,int qatru)
97 {
98  if (qatru==0) qatru = (idtru>>16);
99  idtru = idtru&((1<<16)-1);
100  mIdTruth = idtru;
101  mQuality = static_cast<UShort_t>(qatru);
102 }
103 
104 ostream&
105 operator<<(ostream &os, const StMtdHit& hit)
106 {
107  os << " Backleg:" << hit.backleg() << " Module:" << hit.module()
108  << " Cell:" << hit.cell() << endl
109  << " LeTime " << hit.leadingEdgeTime().first << " " << hit.leadingEdgeTime().second
110  << " TeTime " << hit.trailingEdgeTime().first << " " << hit.trailingEdgeTime().second << endl
111  << " Track " << (hit.associatedTrack() ? hit.associatedTrack()->key() : 0) << endl
112  << " IdTruth " << hit.idTruth() << " Quality " << hit.qaTruth() << endl;
113  return os;
114 }