FairRoot/PandaRoot
RiemannTrackFinderTest.C
Go to the documentation of this file.
1 {
2 
3 #include "TVector3.h"
4 #include "TRandom.h"
5 
6  TStopwatch timer;
7  timer.Start();
8 
9  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
10  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
11 
12  gSystem->Load("libriemann");
13 
14  double r1 = -2;
15  TVector3 offset1(2,0,0);
16  int nHits1 = 4;
17  double dPhi1 = TMath::Pi()/36; // 10 degree
18 
19  double r2 = 2;
20  TVector3 offset2(-2,0,0);
21  int nHits2 = 4;
22  double dPhi2 = -TMath::Pi()/36; // 10 degree
23 
24  CbmHit* hits[nHits1+nHits2];
25  TRandom1 rand;
26 
27  for (int i = 0; i < nHits1; i++){
28  TVector3 dpos (0.001,0.001,0.001);
29  TVector3 pos (r1*TMath::Cos(dPhi1*i)+rand.Gaus(0,dpos[0]), r1*TMath::Sin(dPhi1*i)+rand.Gaus(0,dpos[1]), i+1 + rand.Gaus(0,dpos[2]));
30 
31  pos += offset1;
32  PndSdsHit* detHit = new PndSdsHit(0,"",pos,dpos,i,0,0);
33  std::cout << i << ": " << detHit->GetX() << " " << detHit->GetY() << " " << detHit->GetZ() << std::endl;
34 
35  hits[i] = detHit;
36  }
37 
38  for (int j = 0; j < nHits2; j++){
39  TVector3 dpos (0.001,0.001,0.001);
40  TVector3 pos (r2*TMath::Cos(dPhi2*j)+rand.Gaus(0,dpos[0]), r2*TMath::Sin(dPhi2*j)+rand.Gaus(0,dpos[1]), j+1 + rand.Gaus(0,dpos[2]));
41 
42  pos += offset2;
43  PndSdsHit* detHit = new PndSdsHit(0,"",pos,dpos,j,0,0);
44  std::cout << nHits1 + j << ": " << detHit->GetX() << " " << detHit->GetY() << " " << detHit->GetZ() << std::endl;
45 
46  hits[nHits1 + j] = detHit;
47  }
48 
50  for (int k = 0; k < (nHits1 + nHits2); k++){
51  findTracks.AddHit(hits[k]);
52  }
53  findTracks.FindTracks(0.01);
54  std::cout << "Found Tracks: " << findTracks.NTracks() << std::endl;
55 /*
56  TVectorT<double> dVec = track.orig();
57  double x = dVec[0];
58  double y = dVec[1];
59  std::cout << "Riemann Fit r: " << track.r() << " offset: " << x << " " << y << std::endl;
60  PndRiemannTrack track2;
61  track2.init(x,y,track.r(),1,1);
62  */
63 
64  timer.Stop();
65  Double_t rtime = timer.RealTime();
66  Double_t ctime = timer.CpuTime();
67  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
68 
69 
70 }
TVector3 pos
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
PndRiemannTrackFinder findTracks
Int_t i
Definition: run_full.C:25
void FindTracks()
Main function to start the riemann track finding.
int nHits2
static T Sin(const T &x)
Definition: PndCAMath.h:42
double r1
TVector3 offset1(2, 0, 0)
static T Cos(const T &x)
Definition: PndCAMath.h:43
int nHits1
void AddHit(FairHit *hit)
Double_t
TRandom1 rand
double dPhi1
TStopwatch timer
Definition: hit_dirc.C:51
CbmHit * hits[nHits1+nHits2]
Double_t ctime
Definition: hit_dirc.C:114
Double_t rtime
Definition: hit_dirc.C:113
TVector3 offset2(-2, 0, 0)
Double_t Pi
double dPhi2
double r2