StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiPullEvent.cxx
1 #include <assert.h>
2 #include "StiPullEvent.h"
3 #include "RVersion.h"
4 #if ROOT_VERSION_CODE < 331013
5 #include "TCL.h"
6 #else
7 #include "TCernLib.h"
8 #endif
10 #include <assert.h>
11 
12 
13 //_____________________________________________________________________________
14  StiPullEvent::StiPullEvent()
15  :mTrksG("StiPullTrk",100)
16  ,mTrksP("StiPullTrk",100)
17  ,mHitsG("StiPullHit",100)
18  ,mHitsP("StiPullHit",100)
19  ,mHitsR("StiPullHit",100)
20  {
21  mHitsG.SetOwner(0); mHitsP.SetOwner(0); mHitsR.SetOwner(0);
22  Clear();
23  };
24 //_____________________________________________________________________________
25 void StiPullTrk::Clear(const char*)
26 {
27  memset(mBeg,0,mEnd-mBeg+1);
28 }
29 //_____________________________________________________________________________
30 StiPullTrk::StiPullTrk()
31 {
32  Clear();
33 }
34 //_____________________________________________________________________________
35 void StiPullTrk::Print(const char* option) const
36 {
37  if (!option) option="";
38  printf("StiPullTrk::Print(%s)\n",option);
39 }
40 
41 
42 //_____________________________________________________________________________
43 void StiPullHit::Clear(const char*)
44 {
45  memset(mBeg,0,mEnd-mBeg+1);
46 }
47 //_____________________________________________________________________________
48 StiPullHit::StiPullHit()
49 {
50  Clear();
51 }
52 //_____________________________________________________________________________
53 void StiPullHit::Print(const char* option) const
54 {
55  if (!option) option="";
56  printf("StiPullHit::Print(%s)\n",option);
57  printf("mTrackNumber=%d mHardwarePosition=%u \n"
58  ,mTrackNumber,mHardwarePosition);
59  printf("mNormalRefAngle=%g mNormaYOffset=%g mZCenter=%g\n"
60  ,mNormalRefAngle,mNormalYOffset,mZCenter);
61 
62  printf("lXHit=%g \tlYHit %g(%g)\tlZHit %g(%g)\n"
63  ,lXHit
64  ,lYHit,lYHitErr
65  ,lZHit,lZHitErr);
66 
67  printf("lXFit=%g \tlYFit %g(%g)\tlZFit %g(%g)\n"
68  ,lXFit
69  ,lYFit,lYFitErr
70  ,lZFit,lZFitErr);
71 
72  printf("lYPul %g(%g)\tlZPul %g(%g)\n"
73  ,lYPul,lYPulErr
74  ,lZPul,lZPulErr);
75 
76 
77  printf("gRHit=%g \tgPHit %g(%g)\tgZHit %g(%g)\n"
78  ,gRHit
79  ,gPHit,gPHitErr
80  ,gZHit,gZHitErr);
81 
82  printf("gRFit=%g \tgPFit %g(%g)\tgZFit %g(%g)\n"
83  ,gRFit
84  ,gPFit,gPFitErr
85  ,gZFit,gZFitErr);
86 
87  printf("gPPul %g(%g)\tgZPul %g(%g)\n"
88  ,gPPul,gPPulErr
89  ,gZPul,gZPulErr);
90 
91 
92 }
93 //_____________________________________________________________________________
94 int StiPullHit::TestIt()
95 {
96  return 0;
97 }
98 //_____________________________________________________________________________
99 void StiPullEvent::Add(StiPullHit &hit,int gloPrim)
100 {
101  TClonesArray *hits = &mHitsG+gloPrim;
102  int iHit = hits->GetLast()+1;
103  StiPullHit *kHit = (StiPullHit*)hits->New(iHit);
104  *kHit = hit;
105  if (gloPrim) return;
106  if (!hit.mDetector) return;
107  int i = 4;
108  if (hit.mDetector==kTpcId) i=1;
109  if (hit.mDetector==kSvtId) i=2;
110  if (hit.mDetector==kSsdId) i=3;
111  if (hit.mDetector==kPxlId) i=4;
112  if (hit.mDetector==kIstId) i=5;
113  if (!i || i>3)return;
114  ++mNHits[i-1];
115 }
116 //_____________________________________________________________________________
117 void StiPullEvent::Add(StiPullTrk &trk,int gloPrim)
118 {
119  TClonesArray *trks = &mTrksG+gloPrim;
120  int iTrk = trks->GetLast()+1;
121  StiPullTrk *kTrk = (StiPullTrk*)trks->New(iTrk);
122  *kTrk = trk;
123  assert(trk.mTrackNumber);
124  mNTrks[gloPrim]++;
125 }
126 //_____________________________________________________________________________
127 
128 const int *StiPullEvent::GetNHits() const
129 {
130  return mNHits;
131 }
132 //_____________________________________________________________________________
133 void StiPullEvent::Clear(const char*)
134 {
135  mHitsG.Clear();mHitsP.Clear();mHitsR.Clear();
136  mTrksG.Clear();mTrksP.Clear();
137  memset(mVtx,0,sizeof(mVtx));
138  memset(mEtx,0,sizeof(mEtx));
139  mRun=0; mEvt=0;
140  memset(mNTrks,0,sizeof(mNTrks));
141  memset(mNHits,0,sizeof(mNHits));
142 
143 }
144 //_____________________________________________________________________________
145 void StiPullEvent::Finish()
146 {
147 static int nCall=0; nCall++;
148  int iTkG=0,iTkP=0,iHiG=0,iHiP=0,idP=0,idG=0;
149  StiPullTrk* trkG=0,*trkP =0;
150  StiPullHit* hiG=0,*hiP =0;
151  int nHiG = mHitsG.GetLast()+1;
152  int nHiP = mHitsP.GetLast()+1;
153  for (iTkG=0;iTkG<mNTrks[0];iTkG++) {// Loop over globs
154  trkG=(StiPullTrk*)mTrksG[iTkG]; idG = trkG->mTrackNumber;
155  idP=-1; trkP=0;
156  if (iTkP<mNTrks[1]) {
157  trkP=(StiPullTrk*)mTrksP[iTkP]; idP = trkP->mTrackNumber;
158  }
159  int vertex = 0;
160  if (idG==idP) { //It is a primary
161  vertex = trkP->mVertex;
162  int nHits=0;
163  for(;iHiP<nHiP; iHiP ++) { // Loop over prim hits
164  hiP = (StiPullHit*)mHitsP[iHiP]; if (idP!=hiP->mTrackNumber) break;
165  nHits++;
166  hiP->mTrackNumber=iTkG+1; hiP->mVertex=vertex;
167  }
168  assert(nHits==trkP->nAllHits || nHits-1==trkP->nAllHits);
169  trkP->mTrackNumber= iTkG+1; iTkP++;
170  }//end It is a primary
171 
172  int nHits=0;
173  for(;iHiG<nHiG; iHiG ++) { // Loop over glob hits
174  hiG = (StiPullHit*)mHitsG[iHiG]; if (idG!=hiG->mTrackNumber) break;
175  nHits++;
176  hiG->mTrackNumber=iTkG+1; hiG->mVertex=vertex;
177  }
178  assert(nHits==trkG->nAllHits);
179  trkG->mVertex = vertex;
180  trkG->mTrackNumber= iTkG+1;
181  }
182 }
183 
184 
185