forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
886 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
#include "AliITSUClusterLines.h" | ||
#include <TMath.h> | ||
|
||
ClassImp(AliITSUClusterLines); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// This class is used by the AliITSUVertexer to compute and store // | ||
// information about vertex candidates. // | ||
// The cluster is seeded starting from two lines, then it is // | ||
// possible to attach other lines. Whenever a new line is attached // | ||
// the weight and coefficient matrices are computed. // | ||
// Origin [email protected] Feb. 20 2014 // | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
//____________________________________________________________________________________________________________ | ||
AliITSUClusterLines::AliITSUClusterLines() : TObject(), | ||
fA(), | ||
fB(), | ||
fLabels(), | ||
fV() { | ||
// Default Constructor | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
AliITSUClusterLines::AliITSUClusterLines(UInt_t first, AliStrLine *line1, UInt_t second, AliStrLine *line2,Bool_t weight) : TObject(), | ||
fA(), | ||
fB(), | ||
fLabels(), | ||
fV() { | ||
// Standard constructor | ||
fLabels.push_back(first); | ||
fLabels.push_back(second); | ||
Double_t wmat1[9],wmat2[9],p1[3],p2[3],cd1[3],cd2[3],sq1[3]={1.,1.,1.},sq2[3]={1.,1.,1.}; | ||
line1->GetWMatrix(wmat1); | ||
line2->GetWMatrix(wmat2); | ||
for(Int_t i=0;i<9;++i) fW[i]=wmat1[i]+wmat2[i]; | ||
line1->GetP0(p1); | ||
line2->GetP0(p2); | ||
line1->GetCd(cd1); | ||
line2->GetCd(cd2); | ||
if(weight) { | ||
line1->GetSigma2P0(sq1); | ||
line2->GetSig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-cd2[0]*p2[1]+cd2[1]*p2[0])+cd2[2]*sq2[0]*(-cd2[2]*p2[1]+cd2[1]*p2[2]))/det2; | ||
fB[2]=(cd1[0]*sq1[1]*(-cd1[0]*p1[2]+cd1[2]*p1[0])+cd1[1]*sq1[0]*(-cd1[1]*p1[2]+cd1[2]*p1[1]))/det1; | ||
fB[2]+=(cd2[0]*sq2[1]*(-cd2[0]*p2[2]+cd2[2]*p2[0])+cd2[1]*sq2[0]*(-cd2[1]*p2[2]+cd2[2]*p2[1]))/det2; | ||
|
||
this->ComputeClusterCentroid(); | ||
|
||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
AliITSUClusterLines::~AliITSUClusterLines() { | ||
// Destructor | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
void AliITSUClusterLines::Add(UInt_t label, AliStrLine *line, Bool_t weight) { | ||
// Add a line to the cluster. It changes the weight matrix of the cluster and its parameters | ||
fLabels.push_back(label); | ||
Double_t wmat[9],p[3],cd[3],sq[3]={1.,1.,1.}; | ||
line->GetWMatrix(wmat); | ||
line->GetP0(p); | ||
line->GetCd(cd); | ||
|
||
for(Int_t i=0;i<9;++i) fW[i]+=wmat[i]; | ||
if(weight) line->GetSigma2P0(sq); | ||
|
||
Double_t det=cd[2]*cd[2]*sq[0]*sq[1]+cd[1]*cd[1]*sq[0]*sq[2]+cd[0]*cd[0]*sq[1]*sq[2]; | ||
fA[0]+=(cd[2]*cd[2]*sq[1]+cd[1]*cd[1]*sq[2])/det; | ||
fA[1]+=-cd[0]*cd[1]*sq[2]/det; | ||
fA[2]+=-cd[0]*cd[2]*sq[1]/det; | ||
fA[3]+=(cd[2]*cd[2]*sq[0]+cd[0]*cd[0]*sq[2])/det; | ||
fA[4]+=-cd[1]*cd[2]*sq[0]/det; | ||
fA[5]+=(cd[1]*cd[1]*sq[0]+cd[0]*cd[0]*sq[1])/det; | ||
|
||
fB[0]+=(cd[1]*sq[2]*(-cd[1]*p[0]+cd[0]*p[1])+cd[2]*sq[1]*(-cd[2]*p[0]+cd[0]*p[2]))/det; | ||
fB[1]+=(cd[0]*sq[2]*(-cd[0]*p[1]+cd[1]*p[0])+cd[2]*sq[0]*(-cd[2]*p[1]+cd[1]*p[2]))/det; | ||
fB[2]+=(cd[0]*sq[1]*(-cd[0]*p[2]+cd[2]*p[0])+cd[1]*sq[0]*(-cd[1]*p[2]+cd[2]*p[1]))/det; | ||
|
||
this->ComputeClusterCentroid(); | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
Int_t AliITSUClusterLines::Compare(const TObject* obj) const { | ||
// Comparison criteria between two clusters | ||
const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj; | ||
if(fLabels.size()<cl->GetSize()) return 1; | ||
if(fLabels.size()>cl->GetSize()) return -1; | ||
return 0; | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
void AliITSUClusterLines::ComputeClusterCentroid() { | ||
// Calculation of the centroid | ||
Double_t *a=fA; | ||
Double_t *b=fB; | ||
Double_t *v=fV; | ||
|
||
Double_t det=a[0]*(a[3]*a[5]-a[4]*a[4])-a[1]*(a[1]*a[5]-a[4]*a[2])+a[2]*(a[1]*a[4]-a[2]*a[3]); | ||
|
||
if(det==0) { | ||
cout << "Could not invert weight matrix" << endl; | ||
return; | ||
} | ||
v[0]=-(b[0]*(a[3]*a[5]-a[4]*a[4])-a[1]*(b[1]*a[5]-a[4]*b[2])+a[2]*(b[1]*a[4]-b[2]*a[3]))/det; | ||
v[1]=-(a[0]*(b[1]*a[5]-b[2]*a[4])-b[0]*(a[1]*a[5]-a[4]*a[2])+a[2]*(a[1]*b[2]-a[2]*b[1]))/det; | ||
v[2]=-(a[0]*(a[3]*b[2]-b[1]*a[4])-a[1]*(a[1]*b[2]-b[1]*a[2])+b[0]*(a[1]*a[4]-a[2]*a[3]))/det; | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
void AliITSUClusterLines::GetCovMatrix(Float_t cov[6]) { | ||
// Returns the covariance matrix (single precision) | ||
Double_t *w=fW; | ||
Double_t den=w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]); | ||
if(den==0) { | ||
cout << "Could not invert weight matrix" << endl; | ||
return; | ||
} | ||
cov[0]=(w[4]*w[8]-w[5]*w[7])/den; | ||
cov[1]=-(w[1]*w[8]-w[7]*w[2])/den; | ||
cov[2]=(w[1]*w[5]-w[4]*w[2])/den; | ||
cov[3]=(w[0]*w[8]-w[6]*w[2])/den; | ||
cov[4]=-(w[0]*w[5]-w[3]*w[2])/den; | ||
cov[5]=(w[0]*w[4]-w[1]*w[3])/den; | ||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
void AliITSUClusterLines::GetCovMatrix(Double_t cov[6]) { | ||
// Returns the covariance matrix (double precision) | ||
Double_t *w=fW; | ||
Double_t den=w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]); | ||
if(den==0) { | ||
cout << "Could not invert weight matrix" << endl; | ||
return; | ||
} | ||
cov[0]=(w[4]*w[8]-w[5]*w[7])/den; | ||
cov[1]=-(w[1]*w[8]-w[7]*w[2])/den; | ||
cov[2]=(w[1]*w[5]-w[4]*w[2])/den; | ||
cov[3]=(w[0]*w[8]-w[6]*w[2])/den; | ||
cov[4]=-(w[0]*w[5]-w[3]*w[2])/den; | ||
cov[5]=(w[0]*w[4]-w[1]*w[3])/den; | ||
|
||
} | ||
|
||
//____________________________________________________________________________________________________________ | ||
Bool_t AliITSUClusterLines::IsEqual(const TObject* obj) const { | ||
// Comparison criteria between two clusters | ||
const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj; | ||
if(fLabels.size()==cl->GetSize()) return kTRUE; | ||
return kFALSE; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef ALIITSUCLUSTERLINES_H | ||
#define ALIITSUCLUSTERLINES_H | ||
/* Copyright(c) 2009-2014, ALICE Experiment at CERN, All rights reserved. * | ||
* See cxx source for full Copyright notice */ | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// Class intended to gather and compute the parameters of vertex candidate // | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#include <TObject.h> | ||
#include <Riostream.h> | ||
#include "AliStrLine.h" | ||
|
||
|
||
class AliITSUClusterLines : public TObject { | ||
public: | ||
AliITSUClusterLines(); | ||
AliITSUClusterLines(UInt_t first, AliStrLine *firstL, UInt_t second, AliStrLine *secondL,Bool_t=kFALSE); | ||
virtual ~AliITSUClusterLines(); | ||
|
||
void Add(UInt_t label, AliStrLine *line, Bool_t weight=kFALSE); | ||
void ComputeClusterCentroid(); | ||
inline UInt_t GetSize() const { return fLabels.size(); } | ||
inline Int_t* GetLabels(UInt_t &n) {n=fLabels.size(); return &fLabels[0]; } | ||
inline void GetA(Float_t a[3]) { for(Int_t i=0; i<3; ++i) a[i]=fA[i]; } | ||
inline void GetA(Double_t a[3]) { for(Int_t i=0; i<3; ++i) a[i]=fA[i]; } | ||
inline void GetB(Float_t b[3]) { for(Int_t i=0; i<3; ++i) b[i]=fB[i]; } | ||
inline void GetB(Double_t b[3]) { for(Int_t i=0; i<3; ++i) b[i]=fB[i]; } | ||
void GetCovMatrix(Float_t cov[6]); | ||
void GetCovMatrix(Double_t cov[6]); | ||
inline void GetVertex(Float_t p[3]) { for(Int_t i=0; i<3; ++i) p[i]=fV[i]; } | ||
inline void GetVertex(Double_t p[3]) { for(Int_t i=0; i<3; ++i) p[i]=fV[i]; } | ||
inline void GetWeight(Float_t w[9]) { for(Int_t i=0; i<9; ++i) w[i]=fW[i]; } | ||
inline void GetWeight(Double_t w[9]) { for(Int_t i=0; i<9; ++i) w[i]=fW[i]; } | ||
// | ||
virtual Bool_t IsSortable() const {return kTRUE;} | ||
virtual Bool_t IsEqual(const TObject* obj) const; | ||
virtual Int_t Compare(const TObject* obj) const; | ||
|
||
protected: | ||
Double_t fA[6]; // AX=B | ||
Double_t fB[3]; // AX=B | ||
vector<Int_t> fLabels; // labels | ||
Double_t fV[3]; // vertex candidate | ||
Double_t fW[9]; // weight matrix | ||
ClassDef(AliITSUClusterLines,1); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.