StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuRpsTrack.cxx
1 #include "StMuRpsTrackPoint.h"
2 #include "StMuRpsTrack.h"
3 
4 #include "StEvent/StRpsTrackPoint.h"
5 #include "StEvent/StRpsTrack.h"
6 
7 #include <cmath>
8 
9 ClassImp(StMuRpsTrack)
10 
12  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i)
13  mTrackPoints[ i ] = nullptr;
14  mBranch = -1;
15  mType = rpsUndefined;
16 }
17 
18 StMuRpsTrack::StMuRpsTrack(const StMuRpsTrack& track) {
19  *this = track;
20 }
21 
22 StMuRpsTrack::~StMuRpsTrack() { /* no op */ }
23 
24 StMuRpsTrack& StMuRpsTrack::operator=(const StMuRpsTrack& track) {
25  if (this != &track) {
26  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i){
27  mTrackPoints[i] = const_cast<StMuRpsTrackPoint*>(track.trackPoint(i));
28  }
29  mP = track.pVec();
30  mType = track.type();
31  }
32  return *this;
33 }
34 
35 unsigned int StMuRpsTrack::planesUsed() const {
36  unsigned int nPlanes = 0;
37  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i)
38  nPlanes += mTrackPoints[i].GetObject() ? trackPoint(i)->planesUsed() : 0;
39  return nPlanes;
40 }
41 
42 double StMuRpsTrack::thetaRp(unsigned int coordinate) const {
43  if(coordinate>rpsAngleTheta) return 0.0;
44  if(mType==rpsLocal) return theta(coordinate);
45  TVector3 deltaVector = trackPoint(1)->positionVec() - trackPoint(0)->positionVec();
46  return atan((coordinate<rpsAngleTheta ? deltaVector[coordinate] : deltaVector.Perp())/abs(deltaVector.z()));
47 }
48 
49 double StMuRpsTrack::phiRp() const{
50  if(mType==rpsLocal) return phi();
51  TVector3 deltaVector = trackPoint(1)->positionVec() - trackPoint(0)->positionVec();
52  return deltaVector.Phi();
53 }
54 
55 double StMuRpsTrack::time() const{
56  double sumTime=0.0;
57  unsigned int numberOfPmtsWithSignal=0;
58  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i){
59  if(trackPoint(i))
60  for(int j=0; j<trackPoint(i)->mNumberOfPmtsInRp; ++j){
61  if(trackPoint(i)->time(j)>0){
62  sumTime += trackPoint(i)->time(j);
63  ++numberOfPmtsWithSignal;
64  }
65  }
66  }
67  return numberOfPmtsWithSignal>0 ? sumTime/numberOfPmtsWithSignal : -1;
68 }
69 
70 double StMuRpsTrack::theta(unsigned int coordinate) const{
71  return coordinate < mNumberOfAngleTypes ? atan((coordinate<rpsAngleTheta ? mP[coordinate] : mP.Perp())/abs(mP.z())) : 0.0;
72 }