FairRoot/PandaRoot
Public Member Functions | Protected Attributes | List of all members
RhoSimpleVertexSelector Class Referenceabstract

#include <RhoSimpleVertexSelector.h>

Inheritance diagram for RhoSimpleVertexSelector:
RhoVertexSelectorBase

Public Member Functions

 RhoSimpleVertexSelector (const char *name="SimpleVertexSelector", Double_t d=1.0, Double_t a=3.14159265358979323846, Double_t r1=0.0, Double_t r2=1.E8)
 
virtual ~RhoSimpleVertexSelector ()
 
virtual Bool_t Accept (RhoCandidate &a, RhoCandidate &b)
 
virtual Bool_t Accept (RhoCandidate *, RhoCandidate *)=0
 
virtual Bool_t Accept (RhoCandidate *, RhoCandidate *, RhoCandidate *)
 
virtual Bool_t Accept (RhoCandidate *, RhoCandidate *, RhoCandidate *, RhoCandidate *)
 
virtual Bool_t Accept (RhoCandidate *, RhoCandidate *, RhoCandidate *, RhoCandidate *, RhoCandidate *)
 
void SetDistanceOfClosestApproach (Double_t d)
 
void SetAngle (Double_t d)
 
void SetRadius (Double_t r1, Double_t r2=1.E8)
 
void SetPrimaryVertex (TVector3 x)
 
TVector3 GetVertex ()
 
Double_t GetDistanceOfClosestApproach ()
 
Double_t GetAngle ()
 
virtual void PrintOn (std::ostream &o=std::cout) const
 
const TVector3 & GetMomentumA () const
 
const TVector3 & GetMomentumB () const
 
TVector3 GetMomentum () const
 
Double_t GetRadius () const
 
void Combine (RhoCandList &in1, RhoCandList &in2, RhoCandList &out)
 

Protected Attributes

Double_t fDoca
 
Double_t fVtxip
 
Double_t fRmin
 
Double_t fRmax
 
Double_t fActualR
 
Double_t fActualVtxip
 
Double_t fActualDoca
 
TVector3 fVertex
 
TVector3 fPrimaryVertex
 
TVector3 fMomA
 
TVector3 fMomB
 

Detailed Description

Definition at line 25 of file RhoSimpleVertexSelector.h.

Constructor & Destructor Documentation

RhoSimpleVertexSelector::RhoSimpleVertexSelector ( const char *  name = "SimpleVertexSelector",
Double_t  d = 1.0,
Double_t  a = 3.14159265358979323846,
Double_t  r1 = 0.0,
Double_t  r2 = 1.E8 
)

Definition at line 33 of file RhoSimpleVertexSelector.cxx.

References a, d, RhoVertexSelectorBase::fDoca, RhoVertexSelectorBase::fRmax, RhoVertexSelectorBase::fRmin, RhoVertexSelectorBase::fVtxip, r1, and r2.

33  :
34  RhoVertexSelectorBase ( name ) //, fQC(0)
35 {
36  fDoca = d;
37  fVtxip = a;
38  fRmin = r1;
39  fRmax = r2;
40 }
TObjArray * d
RhoVertexSelectorBase(const char *name="RhoVertexSelectorBase")
double r1
Int_t a
Definition: anaLmdDigi.C:126
TString name
double r2
RhoSimpleVertexSelector::~RhoSimpleVertexSelector ( )
virtual

Definition at line 42 of file RhoSimpleVertexSelector.cxx.

42 {};// delete fQC; }

Member Function Documentation

Bool_t RhoSimpleVertexSelector::Accept ( RhoCandidate a,
RhoCandidate b 
)
virtual

Definition at line 44 of file RhoSimpleVertexSelector.cxx.

References best, RhoCandidate::Charge(), Double_t, RhoVertexSelectorBase::fActualDoca, RhoVertexSelectorBase::fActualR, RhoVertexSelectorBase::fActualVtxip, RhoVertexSelectorBase::fDoca, RhoVertexSelectorBase::fMomA, RhoVertexSelectorBase::fMomB, RhoVertexSelectorBase::fPrimaryVertex, RhoVertexSelectorBase::fRmax, RhoVertexSelectorBase::fRmin, RhoVertexSelectorBase::fVertex, RhoVertexSelectorBase::fVtxip, RhoCandidate::GetPosition(), p, RhoCandidate::P3(), pnt, r1, r2, sign(), sqrt(), x, and y.

45 {
46  if ( &a==0 || &b==0 ) { return kFALSE; }
47 
48  // Position vectors
49  TVector3 position1 = a.GetPosition();
50  TVector3 position2 = b.GetPosition();
51 
52  double pnt[3], Bf[3];
53  pnt[0]=0.5* ( position1.X() +position2.X() );
54  pnt[1]=0.5* ( position1.Y() +position2.Y() );
55  pnt[2]=0.5* ( position1.Z() +position2.Z() );
56  if(FairRun::Instance()->IsAna()){
57  FairRunAna::Instance()->GetField()->GetFieldValue ( pnt, Bf ); //[kGs]
58  } else{
59  FairRunSim::Instance()->GetField()->GetFieldValue ( pnt, Bf ); //[kGs]
60  }
61  Float_t bField = Bf[2]; // Retrieve the B-Field
62 
63  // Momentum vectors
64  TVector3 ap3 = a.P3();
65  Double_t pPerp1 = ap3.Perp();
66  TVector3 d1 = ap3;
67  d1.SetZ ( 0 );
68  d1*=1.0/pPerp1;
69 
70  TVector3 bp3 = b.P3();
71  Double_t pPerp2 = bp3.Perp();
72  TVector3 d2 = bp3;
73  d2.SetZ ( 0 );
74  d2*=1.0/pPerp2;
75 
76 
77  TVector3 dB ( 0,0,1.0 );
78  // Radius and center
79  Double_t rho1 = 100. * pPerp1/ ( 0.3*bField ); // Radius in cm //FIXME really?
80  TVector3 r1=d1.Cross ( dB );
81  r1 *= -a.Charge() *rho1;
82  TVector3 center1 = position1 - r1;
83  center1.SetZ ( 0 );
84 
85  Double_t rho2 = 100. * pPerp2/ ( 0.3*bField ); // Radius in cm //FIXME really?
86  TVector3 r2=d2.Cross ( dB );
87  r2 *= -b.Charge() *rho2;
88  TVector3 center2 = position2 - r2;
89  center2.SetZ ( 0 );
90 
91  // distance and angle of the axis between the two centers
92  TVector3 ab = center2 - center1;
93  Double_t dab = ab.Perp();
94  Double_t cosTheAB = ab.X() /dab;
95  Double_t sinTheAB = ab.Y() /dab;
96 
97 
98  // x value of intersect at reduced system
99  Double_t x = dab/2 + ( rho1*rho1 - rho2*rho2 ) / ( 2*dab );
100 
101  // y*y value of intersect at reduced system for helix A
102  Double_t y2 = ( rho1+x ) * ( rho1-x );
103 
104  // both circles do not intersect (only one solution)
105  Int_t nSolMax=1;
106  Double_t y=0;
107 
108  if ( y2 > 0 ) {
109  nSolMax=2;
110  y = sqrt ( y2 );
111  } else {
112  //if( fabs(dab-rho1-rho2) > fActualDoca);
113  //return kFALSE;
114  }
115 
116  // now we compute the solution(s)
117 
118  TVector3 newap3[2];
119  TVector3 newbp3[2];
120  TVector3 newapos[2];
121  TVector3 newbpos[2];
122  Int_t best=0;
123  fActualDoca=1.E8;
124  for ( Int_t ns=0; ns<nSolMax; ns++ ) { // loop on the solutions
125 
126  // radius vector of intersection point
127  Double_t sign = ns ? 1.0 : -1.0;
128  TVector3 rs1 ( cosTheAB*x - sinTheAB*y * sign, sinTheAB*x + cosTheAB*y * sign, 0 );
129  TVector3 rs2 ( rs1-ab );
130 
131  // are we moving forward or backward?
132  Double_t adir= ( rs1-r1 ).Dot ( ap3 ) >0 ? 1.0 : -1.0;
133  Double_t aangle=adir * r1.Angle ( rs1 );
134  // intersection point
135  Double_t newaz=position1.Z() + rho1*aangle/pPerp1 * ap3.Z();
136  newapos[ns].SetX ( center1.X() + rs1.X() );
137  newapos[ns].SetY ( center1.Y() + rs1.Y() );
138  newapos[ns].SetZ ( newaz );
139 
140  // adjust momentum
141  newap3[ns]=rs1.Cross ( dB );
142  newap3[ns]*=a.Charge() /rho1*pPerp1;
143  newap3[ns].SetZ ( ap3.Z() );
144 
145 
146  // same for b
147  Double_t bdir= ( rs2-r2 ).Dot ( bp3 ) >0 ? 1.0 : -1.0;
148  Double_t bangle=bdir * r2.Angle ( rs2 );
149  Double_t newbz=position2.Z() + rho2*bangle/pPerp2 * bp3.Z();
150  newbpos[ns].SetX ( center2.X() + rs2.X() ); // ==newapos[ns].X()
151  newbpos[ns].SetY ( center2.Y() + rs2.Y() ); // ==newapos[ns].Y()
152  newbpos[ns].SetZ ( newbz );
153  newbp3[ns]=rs2.Cross ( dB );
154  newbp3[ns]*=b.Charge() /rho2*pPerp2;
155  newbp3[ns].SetZ ( bp3.Z() );
156 
157  Double_t delta = ( newapos[ns]-newbpos[ns] ).Mag();
158 
159  // take the solution of minimal deltaZ
160  if ( delta < fActualDoca ) {
161  best=ns;
162  fActualDoca = delta;
163  }
164  }
165 
166  fVertex=0.5* ( newapos[best]+newbpos[best] );
167  fMomA=newap3[best];
168  fMomB=newbp3[best];
169 
170  // Now reconstruct original flight path and
171  // calculate the angle to vertex-ip
172 
173  TVector3 p=fMomA+fMomB;
174  TVector3 vtxip = fVertex-fPrimaryVertex;
175  fActualVtxip = vtxip.Angle ( p );
176  fActualR = vtxip.Mag();
177 
178  //if (fQC!=0) fQC->Accumulate((Float_t)fActualDoca,(Float_t)fActualVtxip);
179 
180  if ( fActualDoca < fDoca &&
181  fActualR >= fRmin && fActualR < fRmax &&
182  fActualVtxip < fVtxip ) {
183 
184  return kTRUE;
185 
186  } else {
187  fMomA=ap3;
188  fMomB=bp3;
190  return kFALSE;
191  }
192  return kFALSE; //get rid of warnings
193 }
Double_t p
Definition: anasim.C:58
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
TClonesArray * pnt
double r1
TVector3 GetPosition() const
Definition: RhoCandidate.h:185
Double_t
Double_t x
Double_t Charge() const
Definition: RhoCandidate.h:184
int sign(T val)
Definition: PndCADef.h:48
Double_t y
double r2
TVector3 P3() const
Definition: RhoCandidate.h:199
virtual Bool_t RhoVertexSelectorBase::Accept ( RhoCandidate ,
RhoCandidate  
)
pure virtualinherited
virtual Bool_t RhoVertexSelectorBase::Accept ( RhoCandidate ,
RhoCandidate ,
RhoCandidate  
)
inlinevirtualinherited

Definition at line 35 of file RhoVertexSelectorBase.h.

35  {
36  return kTRUE;
37  };
virtual Bool_t RhoVertexSelectorBase::Accept ( RhoCandidate ,
RhoCandidate ,
RhoCandidate ,
RhoCandidate  
)
inlinevirtualinherited

Definition at line 38 of file RhoVertexSelectorBase.h.

38  {
39  return kTRUE;
40  };
virtual Bool_t RhoVertexSelectorBase::Accept ( RhoCandidate ,
RhoCandidate ,
RhoCandidate ,
RhoCandidate ,
RhoCandidate  
)
inlinevirtualinherited

Definition at line 41 of file RhoVertexSelectorBase.h.

41  {
42  return kTRUE;
43  };
void RhoVertexSelectorBase::Combine ( RhoCandList in1,
RhoCandList in2,
RhoCandList out 
)
inherited

Definition at line 32 of file RhoVertexSelectorBase.cxx.

References RhoVertexSelectorBase::Accept(), Bool_t, c, RhoCandList::Cleanup(), Double_t, RhoCandidate::E(), RhoCandList::GetLength(), RhoVertexSelectorBase::GetMomentum(), RhoVertexSelectorBase::GetVertex(), RhoCandList::Put(), RhoCandidate::SetE(), RhoCandidate::SetMarker(), RhoCandidate::SetPosition(), and RhoCandidate::SetVect().

33 {
34  TLorentzVector vl;
35  Double_t charge;
36  Bool_t nearby = kTRUE;
37  //fEntries = 0;
38  //end of unlock
39  Int_t endpos1 = l1.GetLength();
40  Int_t endpos2 = l2.GetLength();
41  out.Cleanup();
42 
43  if ( &l1==&l2 ) {
44  //combination of a list with itself
45  for ( Int_t comb_i=0; comb_i<endpos1; ++comb_i ) {
46  for ( Int_t comb_k=comb_i+1; comb_k<endpos2; ++comb_k ) {
47  if ( !l1[comb_i]->Overlaps ( l2[comb_k] ) ) {
48  vl=l1[comb_i]->P4() +l2[comb_k]->P4();
49  charge=l1[comb_i]->Charge() +l2[comb_k]->Charge();
50  nearby = Accept ( l1[comb_i],l2[comb_k] );
51  if ( nearby ) {
52  //fill list with new candidate
53  RhoCandidate c ( vl,charge );
54  c.SetMarker ( l1[comb_i]->GetMarker ( 0 ) |l2[comb_k]->GetMarker ( 0 ),0 );
55  c.SetMarker ( l1[comb_i]->GetMarker ( 1 ) |l2[comb_k]->GetMarker ( 1 ),1 );
56  c.SetMarker ( l1[comb_i]->GetMarker ( 2 ) |l2[comb_k]->GetMarker ( 2 ),2 );
57  c.SetMarker ( l1[comb_i]->GetMarker ( 3 ) |l2[comb_k]->GetMarker ( 3 ),3 );
58  c.SetPosition ( GetVertex() );
59  c.SetVect ( GetMomentum() );
60  c.SetE ( c.E() );
61  out.Put ( &c );
62  }
63  }
64  }
65  }
66  } else {
67  //combination of 2 different lists
68  for ( Int_t comb_i=0; comb_i<endpos1; ++comb_i ) {
69  for ( Int_t comb_k=0; comb_k<endpos2; ++comb_k ) {
70  if ( !l1[comb_i]->Overlaps ( l2[comb_k] ) ) {
71  vl=l1[comb_i]->P4() +l2[comb_k]->P4();
72  charge=l1[comb_i]->Charge() +l2[comb_k]->Charge();
73  nearby = Accept ( l1[comb_i],l2[comb_k] );
74  if ( nearby ) {
75  //fill list with new candidate
76  RhoCandidate c ( vl,charge );
77  c.SetMarker ( l1[comb_i]->GetMarker ( 0 ) |l2[comb_k]->GetMarker ( 0 ),0 );
78  c.SetMarker ( l1[comb_i]->GetMarker ( 1 ) |l2[comb_k]->GetMarker ( 1 ),1 );
79  c.SetMarker ( l1[comb_i]->GetMarker ( 2 ) |l2[comb_k]->GetMarker ( 2 ),2 );
80  c.SetMarker ( l1[comb_i]->GetMarker ( 3 ) |l2[comb_k]->GetMarker ( 3 ),3 );
81  c.SetPosition ( GetVertex() );
82  c.SetVect ( GetMomentum() );
83  c.SetE ( c.E() );
84  out.Put ( &c );
85  }
86  }
87  }
88  }
89  }
90 }
void Cleanup()
Definition: RhoCandList.cxx:62
TVector3 GetMomentum() const
Double_t
virtual Bool_t Accept(RhoCandidate *, RhoCandidate *)=0
void Put(const RhoCandidate *, Int_t i=-1)
Definition: RhoCandList.cxx:77
Double_t RhoVertexSelectorBase::GetAngle ( )
inlineinherited

Definition at line 63 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fActualVtxip.

63  {
64  return fActualVtxip;
65  }
Double_t RhoVertexSelectorBase::GetDistanceOfClosestApproach ( )
inlineinherited

Definition at line 60 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fActualDoca.

60  {
61  return fActualDoca;
62  }
TVector3 RhoVertexSelectorBase::GetMomentum ( ) const
inlineinherited
const TVector3& RhoVertexSelectorBase::GetMomentumA ( ) const
inlineinherited

Definition at line 68 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fMomA.

68  {
69  return fMomA;
70  }
const TVector3& RhoVertexSelectorBase::GetMomentumB ( ) const
inlineinherited

Definition at line 71 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fMomB.

71  {
72  return fMomB;
73  }
Double_t RhoVertexSelectorBase::GetRadius ( ) const
inlineinherited

Definition at line 77 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fActualR.

77  {
78  return fActualR;
79  }
TVector3 RhoVertexSelectorBase::GetVertex ( )
inlineinherited

Definition at line 57 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fVertex.

Referenced by RhoVertexSelectorBase::Combine().

57  {
58  return fVertex;
59  }
void RhoVertexSelectorBase::PrintOn ( std::ostream o = std::cout) const
virtualinherited

Definition at line 92 of file RhoVertexSelectorBase.cxx.

References RhoVertexSelectorBase::fDoca, RhoVertexSelectorBase::fRmax, RhoVertexSelectorBase::fRmin, and RhoVertexSelectorBase::fVtxip.

Referenced by operator<<().

93 {
94  o << GetName() << " settings:" << endl;
95  o << "Distance of closest approach < " << fDoca << " cm" << endl;
96  o << "Angle vertex-IP->momentum < " << fVtxip << " rad" << endl;
97  o << "Radius of acceptance = " << fRmin << " ... " << fRmax << " cm" << endl;
98  o << endl;
99 }
void RhoVertexSelectorBase::SetAngle ( Double_t  d)
inlineinherited

Definition at line 47 of file RhoVertexSelectorBase.h.

References d, and RhoVertexSelectorBase::fVtxip.

47  {
48  fVtxip = d;
49  }
TObjArray * d
void RhoVertexSelectorBase::SetDistanceOfClosestApproach ( Double_t  d)
inlineinherited

Definition at line 44 of file RhoVertexSelectorBase.h.

References d, and RhoVertexSelectorBase::fDoca.

44  {
45  fDoca = d;
46  }
TObjArray * d
void RhoVertexSelectorBase::SetPrimaryVertex ( TVector3  x)
inlineinherited

Definition at line 54 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fPrimaryVertex, and x.

54  {
55  fPrimaryVertex = x;
56  }
Double_t x
void RhoVertexSelectorBase::SetRadius ( Double_t  r1,
Double_t  r2 = 1.E8 
)
inlineinherited

Definition at line 50 of file RhoVertexSelectorBase.h.

References RhoVertexSelectorBase::fRmax, RhoVertexSelectorBase::fRmin, r1, and r2.

50  {
51  fRmin = r1;
52  fRmax = r2;
53  }
double r1
double r2

Member Data Documentation

Double_t RhoVertexSelectorBase::fActualDoca
protectedinherited
Double_t RhoVertexSelectorBase::fActualR
protectedinherited

Definition at line 87 of file RhoVertexSelectorBase.h.

Referenced by Accept(), and RhoVertexSelectorBase::GetRadius().

Double_t RhoVertexSelectorBase::fActualVtxip
protectedinherited

Definition at line 88 of file RhoVertexSelectorBase.h.

Referenced by Accept(), and RhoVertexSelectorBase::GetAngle().

Double_t RhoVertexSelectorBase::fDoca
protectedinherited
TVector3 RhoVertexSelectorBase::fMomA
protectedinherited
TVector3 RhoVertexSelectorBase::fMomB
protectedinherited
TVector3 RhoVertexSelectorBase::fPrimaryVertex
protectedinherited

Definition at line 91 of file RhoVertexSelectorBase.h.

Referenced by Accept(), and RhoVertexSelectorBase::SetPrimaryVertex().

Double_t RhoVertexSelectorBase::fRmax
protectedinherited
Double_t RhoVertexSelectorBase::fRmin
protectedinherited
TVector3 RhoVertexSelectorBase::fVertex
protectedinherited

Definition at line 90 of file RhoVertexSelectorBase.h.

Referenced by Accept(), and RhoVertexSelectorBase::GetVertex().

Double_t RhoVertexSelectorBase::fVtxip
protectedinherited

The documentation for this class was generated from the following files: