StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRpsTrack.cxx
1 /***************************************************************************
2  *
3  * $Id: StRpsTrack.cxx,v 2.3 2015/10/22 20:37:34 ullrich Exp $
4  *
5  * Author: Rafal Sikora, 1 Oct 2015
6  *
7  ***************************************************************************
8  *
9  * Description: StRpsTrack class representing reconstructed track in
10  * the Roman Pot system, with all associated observables, such as
11  * momentum (px, py, pz) etc..
12  *
13  ***************************************************************************
14  *
15  * $Log: StRpsTrack.cxx,v $
16  * Revision 2.3 2015/10/22 20:37:34 ullrich
17  * Moved t(double) to header file made inline. Modified t code.
18  *
19  * Revision 2.2 2015/10/07 17:30:11 ullrich
20  * Changed const to enums and related changes.
21  *
22  * Revision 2.1 2015/10/02 19:48:14 ullrich
23  * Initial Revision.
24  *
25  ***************************************************************************/
26 #include "StRpsTrackPoint.h"
27 #include "StRpsTrack.h"
28 #include <cmath>
29 
30 ClassImp(StRpsTrack)
31 
33  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i)
34  mTrackPoints.push_back(nullptr);
35  mBranch = -1;
36  mType = rpsUndefined;
37 }
38 
39 StRpsTrack::StRpsTrack(const StRpsTrack& track) {
40  *this = track;
41 }
42 
43 StRpsTrack::~StRpsTrack() { /* no op */ }
44 
45 StRpsTrack& StRpsTrack::operator=(const StRpsTrack& track) {
46  if (this != &track) {
47  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i)
48  mTrackPoints[i] = track.trackPoint(i);
49  mP = track.pVec();
50  mType = track.type();
51  }
52  return *this;
53 }
54 
55 unsigned int StRpsTrack::planesUsed() const {
56  unsigned int nPlanes = 0;
57  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i)
58  nPlanes += mTrackPoints[i] ? mTrackPoints[i]->planesUsed() : 0;
59  return nPlanes;
60 }
61 
62 double StRpsTrack::thetaRp(unsigned int coordinate) const {
63  if(coordinate>rpsAngleTheta) return 0.0;
64  if(mType==rpsLocal) return theta(coordinate);
65  StThreeVectorF deltaVector = mTrackPoints[1]->positionVec() - mTrackPoints[0]->positionVec();
66  return atan((coordinate<rpsAngleTheta ? deltaVector[coordinate] : deltaVector.perp())/abs(deltaVector.z()));
67 }
68 
69 double StRpsTrack::phiRp() const{
70  if(mType==rpsLocal) return phi();
71  StThreeVectorF deltaVector = mTrackPoints[1]->positionVec() - mTrackPoints[0]->positionVec();
72  return deltaVector.phi();
73 }
74 
75 double StRpsTrack::time() const{
76  double sumTime=0.0;
77  unsigned int numberOfPmtsWithSignal=0;
78  for(unsigned int i=0; i<mNumberOfStationsInBranch; ++i){
79  if(mTrackPoints[i])
80  for(int j=0; j<mTrackPoints[i]->mNumberOfPmtsInRp; ++j){
81  if(mTrackPoints[i]->time(j)>0){
82  sumTime += mTrackPoints[i]->time(j);
83  ++numberOfPmtsWithSignal;
84  }
85  }
86  }
87  return numberOfPmtsWithSignal>0 ? sumTime/numberOfPmtsWithSignal : -1;
88 }
89 
90 double StRpsTrack::theta(unsigned int coordinate) const
91 {
92  return coordinate < mNumberOfAngleTypes ? atan((coordinate<rpsAngleTheta ? mP[coordinate] : mP.perp())/abs(mP.z())) : 0.0;
93 }