FairRoot/PandaRoot
RiemannTest.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 r = -2;
15  TVector3 offset(2,0,0);
16  int nHits = 4;
17  double dPhi = TMath::Pi()/36; // 10 degree
18 
19  CbmHit* hits[nHits];
20  TRandom1 rand;
21 
22  for (int i = 0; i < nHits; i++){
23  TVector3 dpos (0.001,0.001,0.001);
24  TVector3 pos (r*TMath::Cos(dPhi*i)+rand.Gaus(0,dpos[0]), r*TMath::Sin(dPhi*i)+rand.Gaus(0,dpos[1]), i+1 + rand.Gaus(0,dpos[2]));
25 
26  pos += offset;
27  PndSdsHit* detHit = new PndSdsHit(0,"",pos,dpos,i,0,0);
28  std::cout << i << ": " << detHit->GetX() << " " << detHit->GetY() << " " << detHit->GetZ() << std::endl;
29 
30  hits[i] = detHit;
31  }
32 
34  std::cout << "Hits: " << std::endl;
35 
36  for (int j = 0; j < nHits-1; j++){
37  std::cout << j << ": " << hits[j]->GetX() << " " << hits[j]->GetY() << " " << hits[j]->GetZ() << std::endl;
38  PndRiemannHit* rHit = new PndRiemannHit(hits[j]);
39  track.addHit(rHit);
40  std::cout << "rHit: " << rHit->x().X() << " " << rHit->x().Y() << " " << rHit->x().Z() << std::endl;
41  }
42  track.refit();
43  std::cout << "Distance: " << track.dist(new PndRiemannHit(hits[nHits-1])) << std::endl;
44 
45  TVectorT<double> dVec = track.orig();
46  double x = dVec[0];
47  double y = dVec[1];
48  std::cout << "Riemann Fit r: " << track.r() << " offset: " << x << " " << y << std::endl;
49  PndRiemannTrack track2;
50  track2.init(x,y,track.r(),1,1);
51 
52  TVectorT<double> vecN = track.n();
53  std::cout << "Backcalc fn: " << vecN[0] << " " << vecN[1] << " " << vecN[2] << " fc: " << track.c() << std::endl;
54 
55  timer.Stop();
56  Double_t rtime = timer.RealTime();
57  Double_t ctime = timer.CpuTime();
58  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
59 
60 
61 }
TVector3 pos
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TRandom1 rand
Definition: RiemannTest.C:20
double r
Definition: RiemannTest.C:14
void init(double x0, double y0, double R, double dip, double z0)
Int_t i
Definition: run_full.C:25
PndRiemannTrack track
Definition: RiemannTest.C:33
static T Sin(const T &x)
Definition: PndCAMath.h:42
double dist(PndRiemannHit *hit)
TVector3 offset(2, 0, 0)
static T Cos(const T &x)
Definition: PndCAMath.h:43
const TVectorD & n() const
int nHits
Definition: RiemannTest.C:16
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
void refit(bool withErrorCalc=true)
Double_t ctime
Definition: hit_dirc.C:114
double r() const
Double_t x
double c() const
TVectorD orig() const
const TVector3 & x() const
Definition: PndRiemannHit.h:71
void addHit(PndRiemannHit &hit)
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
Double_t y
Double_t rtime
Definition: hit_dirc.C:113
double dPhi
Definition: RiemannTest.C:17
Double_t Pi