X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITStrackerANN.cxx;h=ab642147e4893ab22539faec12b2821aeb0c799f;hb=74999ed1b2c144c77513f2ac869b6522546298a7;hp=170a4d6b7f125ec31859244d59f393820d380cfe;hpb=cec46807e3ae3bb7f73e74a3b7c1fb32b4e44998;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITStrackerANN.cxx b/ITS/AliITStrackerANN.cxx index 170a4d6b7f1..ab642147e48 100644 --- a/ITS/AliITStrackerANN.cxx +++ b/ITS/AliITStrackerANN.cxx @@ -18,7 +18,6 @@ // Email : alberto.pulvirenti@ct.infn.it // --------------------------------------------------------------------------------- -#include #include #include #include @@ -26,22 +25,78 @@ #include #include #include +#if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,2) + #include +#endif #include "AliITSgeom.h" #include "AliITStrackSA.h" -#include "AliITSclusterV2.h" +#include "AliITSRecPoint.h" #include "AliITStrackV2.h" #include "AliITStrackerANN.h" -class iostream; -using namespace std; +const Double_t AliITStrackerANN::fgkPi = 3.141592653; // pi +const Double_t AliITStrackerANN::fgkHalfPi = 1.570796327; // pi / 2 +const Double_t AliITStrackerANN::fgkTwoPi = 6.283185307; // 2 * pi ClassImp(AliITStrackerANN) + +AliITStrackerANN::AliITStrackerANN() : AliITStrackerV2(), +fVertexX(0.0), +fVertexY(0.0), +fVertexZ(0.0), +fSectorNum(0), +fSectorWidth(0), +fPolarInterval(0), +fCurvNum(0), +fCurvCut(0), +fActMinimum(0), +fEdge1(0), +fEdge2(0), +fStabThreshold(0), +fTemperature(0), +fGain2CostRatio(0), +fExponent(0), +fNLayers(0), +fFirstModInLayer(0), +fIndexMap(0), +fFoundTracks(0), +fNodes(0), +fNeurons(0), +fMsgLevel(0), +fStructureOK(0), +fGeom(0){ + //Default constructor +} //__________________________________________________________________________________ AliITStrackerANN::AliITStrackerANN(const AliITSgeom *geom, Int_t msglev) -: AliITStrackerV2(geom), fMsgLevel(msglev) +: AliITStrackerV2(0), +fVertexX(0.0), +fVertexY(0.0), +fVertexZ(0.0), +fSectorNum(0), +fSectorWidth(0), +fPolarInterval(0), +fCurvNum(0), +fCurvCut(0), +fActMinimum(0), +fEdge1(0), +fEdge2(0), +fStabThreshold(0), +fTemperature(0), +fGain2CostRatio(0), +fExponent(0), +fNLayers(0), +fFirstModInLayer(0), +fIndexMap(0), +fFoundTracks(0), +fNodes(0), +fNeurons(0), +fMsgLevel(msglev), +fStructureOK(0), +fGeom(0) { /************************************************************************** @@ -52,7 +107,7 @@ AliITStrackerANN::AliITStrackerANN(const AliITSgeom *geom, Int_t msglev) 2) the flag for log-messages writing The AliITSgeometry is used along the class, - in order to translate the local AliITSclusterV2 coordinates + in order to translate the local AliITSRecPoint coordinates into the Global reference frame, which is necessary for the Neural Network algorithm to operate. In case of serialized use, the log messages should be excluded, @@ -131,6 +186,42 @@ AliITStrackerANN::AliITStrackerANN(const AliITSgeom *geom, Int_t msglev) fFoundTracks = 0; } + +AliITStrackerANN::AliITStrackerANN(const AliITStrackerANN &n) : AliITStrackerV2((AliITStrackerV2&)n), +fVertexX(n.fVertexX), +fVertexY(n.fVertexY), +fVertexZ(n.fVertexZ), +fSectorNum(n.fSectorNum), +fSectorWidth(n.fSectorWidth), +fPolarInterval(n.fPolarInterval), +fCurvNum(n.fCurvNum), +fCurvCut(n.fCurvCut), +fActMinimum(n.fActMinimum), +fEdge1(n.fEdge1), +fEdge2(n.fEdge2), +fStabThreshold(n.fStabThreshold), +fTemperature(n.fTemperature), +fGain2CostRatio(n.fGain2CostRatio), +fExponent(n.fExponent), +fNLayers(n.fNLayers), +fFirstModInLayer(n.fFirstModInLayer), +fIndexMap(n.fIndexMap), +fFoundTracks(n.fFoundTracks), +fNodes(n.fNodes), +fNeurons(n.fNeurons), +fMsgLevel(n.fMsgLevel), +fStructureOK(n.fStructureOK), +fGeom(n.fGeom){ + //Copy constructor +} + +AliITStrackerANN& AliITStrackerANN::operator=(const AliITStrackerANN& arg){ + //Assignment operator + this->~AliITStrackerANN(); + new(this) AliITStrackerANN(arg); + return *this; +} + //__________________________________________________________________________________ void AliITStrackerANN::SetCuts (Int_t ncurv, Double_t *curv, Double_t *theta2D, Double_t *theta3D, Double_t *helix) @@ -272,7 +363,7 @@ Bool_t AliITStrackerANN::GetGlobalXYZ Operations: essentially, determines the ITS module index from the - detector index of the AliITSclusterV2 object, and extracts + detector index of the AliITSRecPoint object, and extracts the roto-translation from the ITS geometry, to convert the local module coordinates into the global ones. @@ -290,7 +381,7 @@ Bool_t AliITStrackerANN::GetGlobalXYZ return kFALSE; } // checks if the referenced cluster exists and corresponds to the passed reference - AliITSclusterV2 *refCluster = (AliITSclusterV2*) GetCluster(refIndex); + AliITSRecPoint *refCluster = (AliITSRecPoint*) GetCluster(refIndex); if (!refCluster) { Error("GetGlobalXYZ", "Cluster not found for index %d", refIndex); return kFALSE; @@ -345,7 +436,7 @@ AliITStrackerANN::AliITSnode* AliITStrackerANN::AddNode(Int_t refIndex) neuron-creation phase. Arguments: - 1) reference index of the correlated AliITSclusterV2 object + 1) reference index of the correlated AliITSRecPoint object Operations: - allocates the new AliITSnode objects @@ -472,7 +563,7 @@ Int_t AliITStrackerANN::ArrangePoints(char *exportFile) If this file must not be created, simply pass a NULL argument Operations: - - for each AliITSclusterV2 in each AliITSlayer, a ne AliITSnode + - for each AliITSRecPoint in each AliITSlayer, a ne AliITSnode is created and stored in the correct location. Return values: @@ -840,7 +931,7 @@ void AliITStrackerANN::PrintMatches(Bool_t stop) TObjArray *sector = 0; Int_t ilayer, isector, itheta, nF; AliITSnode *node1 = 0, *node2 = 0; - //AliITSclusterV2 *cluster1 = 0, *cluster2 = 0; + //AliITSRecPoint *cluster1 = 0, *cluster2 = 0; for (ilayer = 0; ilayer < 6; ilayer++) { for (isector = 0; isector < fSectorNum; isector++) { @@ -1431,7 +1522,7 @@ Int_t AliITStrackerANN::SaveTracks(Int_t sector) } //if (!RiemannFit(fNLayers, node, param)) continue; // initialization of Kalman Filter Tracking - AliITSclusterV2 *cluster = (AliITSclusterV2*)GetCluster(node[0]->ClusterRef()); + AliITSRecPoint *cluster = (AliITSRecPoint*)GetCluster(node[0]->ClusterRef()); Int_t mod = cluster->GetDetectorIndex(); Int_t lay, lad, det; fGeom->GetModuleId(mod, lay, lad, det); @@ -1441,15 +1532,15 @@ Int_t AliITStrackerANN::SaveTracks(Int_t sector) y0, z0, param[4], param[7], param[3], 1); for (l = 0; l < fNLayers; l++) { - cluster = (AliITSclusterV2*)GetCluster(node[l]->ClusterRef()); + cluster = (AliITSRecPoint*)GetCluster(node[l]->ClusterRef()); if (cluster) trac->AddClusterV2(l, (node[l]->ClusterRef() & 0x0fffffff)>>0); } AliITStrackV2* ot = new AliITStrackV2(*trac); - ot->ResetCovariance(); + ot->ResetCovariance(10.); ot->ResetClusters(); if (RefitAt(49.,ot,trac)) { //fit from layer 1 to layer 6 AliITStrackV2 *otrack2 = new AliITStrackV2(*ot); - otrack2->ResetCovariance(); + otrack2->ResetCovariance(10.); otrack2->ResetClusters(); //fit from layer 6 to layer 1 if (RefitAt(3.7,otrack2,ot)) fFoundTracks->AddLast(otrack2); @@ -1595,7 +1686,7 @@ Int_t AliITStrackerANN::StoreTracks() //if (!RiemannFit(fNLayers, trackitem, param)) continue; if (!annTrack.RiemannFit()) continue; // initialization of Kalman Filter Tracking - AliITSclusterV2 *cluster = (AliITSclusterV2*)GetCluster(annTrack[0]->ClusterRef()); + AliITSRecPoint *cluster = (AliITSRecPoint*)GetCluster(annTrack[0]->ClusterRef()); Int_t mod = cluster->GetDetectorIndex(); Int_t lay, lad, det; fGeom->GetModuleId(mod, lay, lad, det); @@ -1606,15 +1697,15 @@ Int_t AliITStrackerANN::StoreTracks() annTrack.Curv(), 1); for (Int_t l = 0; l < fNLayers; l++) { if (!annTrack[l]) continue; - cluster = (AliITSclusterV2*)GetCluster(annTrack[l]->ClusterRef()); + cluster = (AliITSRecPoint*)GetCluster(annTrack[l]->ClusterRef()); if (cluster) trac->AddClusterV2(l, (annTrack[l]->ClusterRef() & 0x0fffffff)>>0); } AliITStrackV2* ot = new AliITStrackV2(*trac); - ot->ResetCovariance(); + ot->ResetCovariance(10.); ot->ResetClusters(); if (RefitAt(49.,ot,trac)) { //fit from layer 1 to layer 6 AliITStrackV2 *otrack2 = new AliITStrackV2(*ot); - otrack2->ResetCovariance(); + otrack2->ResetCovariance(10.); otrack2->ResetClusters(); //fit from layer 6 to layer 1 if (RefitAt(3.7,otrack2,ot)) fFoundTracks->AddLast(otrack2); @@ -1684,18 +1775,42 @@ Double_t AliITStrackerANN::Weight(AliITSneuron *nAB, AliITSneuron *nBC) ******************************************/ //__________________________________________________________________________________ -inline AliITStrackerANN::AliITSnode::AliITSnode() -: fUsed(kFALSE), fClusterRef(-1), - fMatches(NULL), fInnerOf(NULL), fOuterOf(NULL), - fNext(NULL), fPrev(NULL) +AliITStrackerANN::AliITSnode::AliITSnode(): +fX(0.0), +fY(0.0), +fZ(0.0), +fEX2(0.0), +fEY2(0.0), +fEZ2(0.0), +fUsed(kFALSE), +fClusterRef(-1), +fMatches(NULL), +fInnerOf(NULL), +fOuterOf(NULL), +fNext(NULL), +fPrev(NULL) { // Constructor for the embedded 'AliITSnode' class. // It initializes all pointer-like objects. - fX = fY = fZ = 0.0; - fEX2 = fEY2 = fEZ2 = 0.0; } +AliITStrackerANN::AliITSnode::AliITSnode(const AliITSnode &n) : TObject((TObject&)n), +fX(n.fX), +fY(n.fY), +fZ(n.fZ), +fEX2(n.fEX2), +fEY2(n.fEY2), +fEZ2(n.fEZ2), +fUsed(n.fUsed), +fClusterRef(n.fClusterRef), +fMatches(n.fMatches), +fInnerOf(n.fInnerOf), +fOuterOf(n.fOuterOf), +fNext(n.fNext), +fPrev(n.fPrev){ + //copy constructor +} //__________________________________________________________________________________ AliITStrackerANN::AliITSnode::~AliITSnode() { @@ -1723,7 +1838,7 @@ AliITStrackerANN::AliITSnode::~AliITSnode() } //__________________________________________________________________________________ -inline Double_t AliITStrackerANN::AliITSnode::GetPhi() const +Double_t AliITStrackerANN::AliITSnode::GetPhi() const { // Calculates the 'phi' (azimutal) angle, and returns it // in the range between 0 and 2Pi radians. @@ -1737,7 +1852,7 @@ inline Double_t AliITStrackerANN::AliITSnode::GetPhi() const } //__________________________________________________________________________________ -inline Double_t AliITStrackerANN::AliITSnode::GetError(Option_t *option) +Double_t AliITStrackerANN::AliITSnode::GetError(Option_t *option) { // Returns the error or the square error of // values related to the coordinates in different systems. @@ -1791,16 +1906,28 @@ inline Double_t AliITStrackerANN::AliITSnode::GetError(Option_t *option) //__________________________________________________________________________________ AliITStrackerANN::AliITSneuron::AliITSneuron -(AliITSnode *inner, AliITSnode *outer, Double_t minAct, Double_t maxAct) - : fUsed(0), fInner(inner), fOuter(outer) +(AliITSnode *inner, AliITSnode *outer, Double_t minAct, Double_t maxAct): +fUsed(0), +fActivation(0), +fInner(inner), +fOuter(outer), +fGain(0) { // Default neuron constructor fActivation = gRandom->Rndm() * (maxAct-minAct) + minAct; fGain = new TObjArray; } - + +AliITStrackerANN::AliITSneuron::AliITSneuron(const AliITSneuron &n) : TObject((TObject&)n), +fUsed(n.fUsed), +fActivation(n.fActivation), +fInner(n.fInner), +fOuter(n.fOuter), +fGain(n.fGain){ + //copy constructor +} //__________________________________________________________________________________ -inline Double_t AliITStrackerANN::AliITSneuron::Activate(Double_t temperature) +Double_t AliITStrackerANN::AliITSneuron::Activate(Double_t temperature) { // This computes the new activation of a neuron, and returns // its activation variation as a consequence of the updating. @@ -1896,18 +2023,20 @@ inline Double_t AliITStrackerANN::AliITSneuron::Activate(Double_t temperature) **********************************************/ //__________________________________________________________________________________ -AliITStrackerANN::AliITStrackANN::AliITStrackANN(Int_t dim) : fNPoints(dim) +AliITStrackerANN::AliITStrackANN::AliITStrackANN(Int_t dim) : +fNPoints(dim), +fXCenter(0.0), +fYCenter(0.0), +fRadius(0.0), +fCurv(0.0), +fDTrans(0.0), +fDLong(0.0), +fTanLambda(0.0), +fPhi(0.0), +fNode(0) { // Default constructor for the AliITStrackANN class - fXCenter = 0.0; - fYCenter = 0.0; - fRadius = 0.0; - fCurv = 0.0; - fDTrans = 0.0; - fDLong = 0.0; - fTanLambda = 0.0; - if (! dim) { fNode = 0; } @@ -1918,6 +2047,20 @@ AliITStrackerANN::AliITStrackANN::AliITStrackANN(Int_t dim) : fNPoints(dim) } } +AliITStrackerANN::AliITStrackANN::AliITStrackANN(const AliITStrackANN &n) : TObject((TObject&)n), +fNPoints(n.fNPoints), +fXCenter(n.fXCenter), +fYCenter(n.fYCenter), +fRadius(n.fRadius), +fCurv(n.fCurv), +fDTrans(n.fDTrans), +fDLong(n.fDLong), +fTanLambda(n.fTanLambda), +fPhi(n.fPhi), +fNode(n.fNode) +{ + //copy constructor +} //__________________________________________________________________________________ Int_t AliITStrackerANN::AliITStrackANN::CheckOccupation() const { @@ -2005,7 +2148,13 @@ Bool_t AliITStrackerANN::AliITStrackANN::RiemannFit() // Eigenvalue problem solving for V matrix Int_t ileast = 0; TVectorD eval(3), n(3); +#if ROOT_VERSION_CODE < ROOT_VERSION(4,0,2) TMatrixD evec = sampleCov.EigenVectors(eval); +#else + TMatrixDEigen ei(sampleCov); + TMatrixD evec = ei.GetEigenVectors(); + eval = ei.GetEigenValuesRe(); +#endif if (eval(1) < eval(ileast)) ileast = 1; if (eval(2) < eval(ileast)) ileast = 2; n(0) = evec(0, ileast); @@ -2068,7 +2217,7 @@ Bool_t AliITStrackerANN::AliITStrackANN::RiemannFit() //---- s[j] = (p->GetR2sq() - dt * dt) / (1. + curv * dt); if (s[j] < 0.) { - if (fabs(s[j]) < 1.E-6) s[j] = 0.; + if (TMath::Abs(s[j]) < 1.E-6) s[j] = 0.; else { Error("RiemannFit", "Square root argument error: %17.15g < 0", s[j]); return kFALSE;