]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Merge branch 'trackMatcher'
authorslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Feb 2010 17:12:56 +0000 (17:12 +0000)
committerslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Feb 2010 17:12:56 +0000 (17:12 +0000)
* trackMatcher:
  -Tested and cleaned up
  -Added track matcher component
  Added AliHLTGlobalTrackMatcherComponent

Conflicts:
BASE/util/AliHLTCaloClusterDataStruct.h
BASE/util/AliHLTESDCaloClusterMaker.cxx
CALO/AliHLTCaloClusterAnalyser.cxx
PHOS/AliHLTPHOSGeometry.cxx

12 files changed:
HLT/BASE/util/AliHLTCaloClusterDataStruct.h
HLT/BASE/util/AliHLTESDCaloClusterMaker.cxx
HLT/BASE/util/AliHLTGlobalBarrelTrack.h
HLT/CALO/AliHLTCaloClusterAnalyser.cxx
HLT/CALO/AliHLTCaloClusterizer.cxx
HLT/global/AliHLTGlobalEsdConverterComponent.cxx
HLT/global/AliHLTGlobalTrackMatcher.cxx
HLT/global/AliHLTGlobalTrackMatcher.h
HLT/global/AliHLTGlobalTrackMatcherComponent.cxx [new file with mode: 0644]
HLT/global/AliHLTGlobalTrackMatcherComponent.h [new file with mode: 0644]
HLT/global/physics/AliHLTCaloHistoComponent.cxx
HLT/libAliHLTGlobal.pkg

index ce3c5014dac12bf6abc125f6e270a753244a0271..83a74f30e3e4e74008f65ca27360adc72511e96b 100644 (file)
@@ -214,13 +214,23 @@ struct AliHLTCaloClusterDataStruct
    /** Get the best match */
    Int_t GetTrackMatched() const   
   {
-     if( fTracksMatched >0)  return  fTracksMatched[0]; 
+    if( fTracksMatched[0] >0)  return  fTracksMatched[0]; 
     else return -1;
   } //Most likely the track associated to the cluster
 
 /** Get the number of tracks matched */
-  Int_t GetNTracksMatched() const { return fNTracksMatched; }
-  
+  Int_t GetNTracksMatched() const 
+  { 
+    for(int i = 0; i < 10; i++) 
+      {
+        if (fTracksMatched[i] < 0)
+         {
+           return i;
+         }
+    }
+    return 10;
+  }
+
   /** Number of cells in the cluster */
   UInt_t fNCells;                                //COMMENT
 
@@ -276,11 +286,11 @@ struct AliHLTCaloClusterDataStruct
   Float_t fDistanceToBadChannel;              //COMMENT
 
   /** Number of matched tracks */
-  Int_t fNTracksMatched; //COMMENT
+  Int_t fNTracksMatched; //COMMENT Obsolete?
 
   /** the matced tracks */
   Int_t fTracksMatched[10];           //COMMENT TODO: remove hardcoded 10
-  
+
   /** The absolute IDs of the cells*/
   UShort_t fCellsAbsId;                      //COMMENT
 
@@ -288,7 +298,6 @@ struct AliHLTCaloClusterDataStruct
   Float_t fCellsAmpFraction;              //COMMENT
   
   
-  
 };
 
 
index 283d5e2eebb741a949d74210395e2b4dc595be5c..f07be0f516cd7223dd507f83c731183db070c8a9 100644 (file)
@@ -81,8 +81,8 @@ AliHLTESDCaloClusterMaker::FillESD(AliESDEvent *esdPtr, const AliHLTCaloClusterH
       esdCluster.SetEmcCpvDistance(caloClusterStructPtr->fEmcCpvDistance);
       esdCluster.SetDistanceToBadChannel(caloClusterStructPtr->fDistToBadChannel);
       esdCluster.SetNCells(caloClusterStructPtr->fNCells);
-      //esdCluster.SetNCells(2);
-      
+      TArrayI tracksMatched(caloClusterStructPtr->GetNTracksMatched(), caloClusterStructPtr->fTracksMatched);
+      esdCluster.AddTracksMatched(tracksMatched);
       UShort_t *idArrayPtr = new UShort_t[caloClusterStructPtr->fNCells];
       Double32_t *ampFracArrayPtr = new Double32_t[caloClusterStructPtr->fNCells];
       for(UInt_t index = 0; index < caloClusterStructPtr->fNCells; index++)
index 23d69aa973b7040203597b59a230ec9740ef923f..f9ef1e2c4affbc9b5989af2d940a14c36c3b57d1 100644 (file)
@@ -51,6 +51,8 @@ class AliHLTGlobalBarrelTrack : public AliKalmanTrack
   Double_t GetLastPointY() const {return fLastY;}
   /// return Track ID
   Int_t TrackID() const {return fTrackID;}
+  /// return Track ID, inherited for AliExternalTrackParam
+  Int_t GetID() const {return fTrackID;}
 
   /// Get the number of associated points
   UInt_t GetNumberOfPoints() const;
index 81a5ea04dbeef38a6caab1247023da0d04eba97c..a2ac118da908901ab1ba22d99b9e5435d9f2cd13 100644 (file)
@@ -219,6 +219,9 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
       caloClusterPtr->fClusterType = fClusterType;
 //      Int_t tmpSize = 0;//totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
 
+      //TODO remove hardcoded 10; 
+      memset(caloClusterPtr->fTracksMatched, 0xff, sizeof(Int_t)*10);
+
       Int_t tmpSize = totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
 
       if((availableSize - totSize)  < tmpSize)
index e21c56114890f7b1c1e65cef023ecaed74cd936d..a3c04cfbd87df146ff394ec4e235058e3a947d1b 100644 (file)
@@ -58,8 +58,11 @@ AliHLTCaloClusterizer::AliHLTCaloClusterizer(TString det):
   fNDigits(0)\r
 {\r
   //See header file for documentation\r
-  fEmcClusteringThreshold = 0.2;\r
-  fEmcMinEnergyThreshold = 0.03;\r
+  //fEmcClusteringThreshold = 0.2;\r
+  //fEmcMinEnergyThreshold = 0.03;\r
+\r
+  fEmcClusteringThreshold = 0.1;\r
+  fEmcMinEnergyThreshold = 0.01;\r
   fEmcTimeGate = 1.e-6 ;\r
   \r
   fMaxDigitIndexDiff = 2*fCaloConstants->GetNZROWSMOD();\r
@@ -343,4 +346,4 @@ Int_t AliHLTCaloClusterizer::CheckDigits(AliHLTCaloRecPointDataStruct** recArray
   }\r
    return 0;\r
      \r
-}
\ No newline at end of file
+}\r
index a03e5fc65eecb5901c053b19b8d8d613212cdf67..c859409e1e4bc85c1158859454509d48e6dc4e9b 100644 (file)
@@ -476,13 +476,13 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
 
       HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification);
 
-      AliHLTCaloClusterReader reader;
-      reader.SetMemory(caloClusterHeaderPtr);
+      //AliHLTCaloClusterReader reader;
+      //reader.SetMemory(caloClusterHeaderPtr);
 
       AliHLTESDCaloClusterMaker clusterMaker;
 
       int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr);
-
+     
       HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters);
       iAddedDataBlocks++;
     }
index e27368bba61c95767d367627c537f4d6dcb46af6..e133f9c02bd54be8eaa1b0d97cc21f68441cb340 100644 (file)
@@ -1,10 +1,9 @@
 //$Id$
-
 /**************************************************************************
  * This file is property of and copyright by the ALICE HLT Project        * 
  * ALICE Experiment at CERN, All rights reserved.                         *
  *                                                                        *
- * Primary Authors: Svein Lindal     (slindal@fys.uio.no)                 *
+ * Primary Authors: Svein Lindal (slindal@fys.uio.no)                 *
  *                  for The ALICE HLT Project.                            *
  *                                                                        *
  * Permission to use, copy, modify and distribute this software and its   *
@@ -23,7 +22,9 @@
 */
 
 #include "AliHLTGlobalTrackMatcher.h"
-#include "AliESDCaloCluster.h"
+//#include "AliESDCaloCluster.h"
+
+
 
 #if __GNUC__>= 3
 using namespace std;
@@ -37,14 +38,11 @@ AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() :
   fPhosMaxX(0),
   fEmcalMaxZ(0),
   fEmcalMaxX(0),
-  fPhosRadius(460),
-  fEmcalRadius(448),
   fMatchDistance(0),
-  fPhosClustersArray(NULL), 
-  fEmcalClustersArray(NULL)
+  fPhosRadius(460),
+  fEmcalRadius(448)
 {
   //Default constructor
-
   DoInit();
 }
 
@@ -56,6 +54,8 @@ AliHLTGlobalTrackMatcher::~AliHLTGlobalTrackMatcher()
 }
 
 void AliHLTGlobalTrackMatcher::DoInit( ) {
+  //See header file for documentation
+  //BALLE TODO: Change hardcoded values to something that is initialised through command line or something!!!
 
   fMatchDistance = 40*40;
 
@@ -65,117 +65,56 @@ void AliHLTGlobalTrackMatcher::DoInit( ) {
   fEmcalMaxZ = 350 + TMath::Sqrt(fMatchDistance) + 30;
   fEmcalMaxX = 3000;
 
-  fPhosClustersArray = new TRefArray();
-  fEmcalClustersArray = new TRefArray();
 
 }
 
-Bool_t AliHLTGlobalTrackMatcher::Match( AliESDEvent* event ){
+Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, TArrayI* matchedTracksArray, Bool_t bestMatch, Int_t nMatches){
+  //See header file for documentation
+    
+  matchedTracksArray->Set(matchedTracksArray->GetSize() + 1);
+  if ( bestMatch )  {
+    matchedTracksArray->AddAt(matchedTracksArray->At(0), matchedTracksArray->GetSize() - 1);
+    matchedTracksArray->AddAt(tId, 0);
+  } else {
+    matchedTracksArray->AddAt(tId, matchedTracksArray->GetSize() - 1);
+  }
 
-  Int_t nTracks = event->GetNumberOfTracks();
+  return nMatches;
+}
 
-  //Fill arrays with clusters
-  Int_t nPhosClusters = event->GetPHOSClusters(fPhosClustersArray);
-  Int_t nEmcalClusters = event->GetEMCALClusters(fEmcalClustersArray);
+Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, Int_t* matchArray, bool bestMatch, Int_t nMatches ){
 
-  if ( ( nTracks <= 0 ) || ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) ) {
-    //printf(Form("No tracks or clusters in event"));
-    return 0;
-  }
+  HLTInfo("Adding track %d to cluster with %d previous matches", tId, nMatches);
   
-
-  Float_t bestMatchPhos[nPhosClusters];   
-  for(int ic = 0; ic < nPhosClusters; ic++) {
-    bestMatchPhos[ic] = 999999;
+  //BALLE TODO: remove hardcoded 9
+  if (nMatches > 9) {                                                   //BALLE this on tooo
+    HLTError("The number of matching tracks (%d) exceeds the array size of %d", nMatches, 9);
+    return 0;
   }
 
-  Float_t bestMatchEmcal[nEmcalClusters];    
-  for(int ic = 0; ic < nEmcalClusters; ic++) {
-    bestMatchEmcal[ic] = 999999;
+  if(bestMatch) {
+    cout <<"bestmatch"<<endl;
+    matchArray[nMatches] = matchArray[0];
+    matchArray[0] = tId;
+  } else  {
+    matchArray[nMatches] = tId;
   }
-
-
-  Double_t trackPosition[3];
   
-  //Loop over tracks
-  for (int it = 0; it < nTracks; it++ ) {
+  return nMatches;
 
-    AliESDtrack * track = event->GetTrack(it);
+};
 
-    Double_t bz = event->GetMagneticField();
-    
-    //Does track pass close to either calorimeter volume
-    if ( IsTrackCloseToDetector(track, bz, trackPosition, fPhosMaxX, kFALSE, fPhosMaxZ ) ) {
-      MatchTrackToClusters( track, fPhosClustersArray, nPhosClusters, bestMatchPhos, bz);
-    
-    } else if ( IsTrackCloseToDetector(track, bz, trackPosition, fEmcalMaxX, kTRUE, fEmcalMaxZ ) ) {
-      MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz);
-    } 
-  } // track loop 
-
-
-  return 0;
-} 
-
-
-
-void AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliESDtrack * track, TRefArray * clustersArray, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
-    
-  //loop over clusters to find matches with track
-  Float_t clusterPosition[3];
-  Double_t trackPosition[3];
-  for(int ic = 0; ic < nClusters; ic++) {
-       
-    AliESDCaloCluster * cluster = static_cast<AliESDCaloCluster*>(clustersArray->At(ic));
-      
-    //Get Cluster Global Coordinates
-    cluster->GetPosition(clusterPosition);
-
-    //Get track postion at radius of cluster
-    Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]);      
-    if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
-      cout << "XXXXXXXXXXXXX  BALLE Track reached detector but not cluster, needs to be handled no? !!!!!!" << endl;
-    }
-      
-    Float_t match = 0;
-    Float_t dxyz = 0;
-    for(int i = 0; i < 3; i++) {
-      dxyz = trackPosition[i] - clusterPosition[i];
-      match += dxyz*dxyz;
-    }
-      
-      
-    if( match > fMatchDistance  )  {     
-          continue;
-    }
-
-
-    //Track is close to cluster, add to cluster's array of matching tracks
-    TArrayI *matchedTracksArray = cluster->GetTracksMatched();
-    matchedTracksArray->Set(matchedTracksArray->GetSize() + 1);
-    if ( match  < bestMatch[ic] )  {
-      bestMatch[ic] = match;
-      matchedTracksArray->AddAt(matchedTracksArray->At(0), matchedTracksArray->GetSize() - 1);
-      matchedTracksArray->AddAt(track->GetID(), 0);
-    } else {
-      matchedTracksArray->AddAt(track->GetID(), matchedTracksArray->GetSize() - 1);
-    }
-  } //cluster loop
-}
-
-
-Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToDetector(AliESDtrack * track, Double_t bz, Double_t * trackPosition, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ) {
 
+Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToDetector(AliExternalTrackParam * track, Double_t bz, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ, Double_t dRadius) {
   //See header file for documentation
   
-  
   //Get track instersection with cylinder defined by detector radius
-  if (! (track->GetXYZAt(fPhosRadius, bz, trackPosition)) ) 
+  Double_t trackPosition[3];
+  if (! (track->GetXYZAt(dRadius, bz, trackPosition)) ) {
     return kFALSE;
-  
- //Positive y for EMCAL, negative for PHOS
+  }
+
+  //Positive y for EMCAL, negative for PHOS
   if(ySign) {
     if (trackPosition[1] < 0 ) 
       return kFALSE;
@@ -191,37 +130,5 @@ Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToDetector(AliESDtrack * track, Dou
   if (TMath::Abs(trackPosition[0]) > fMaxX )
     return kFALSE;
   
-  
-  
   return kTRUE;  
 }
-
-
-// Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToEmcal(AliESDtrack * track, Double_t bz, Double_t * trackPosition) {
-  
-//   //Get track instersection with cylinder defined by detector radius
-//   if (! (track->GetXYZAt(fEmcalRadius, bz, trackPosition)) ) 
-//     return kFALSE;
-    
-
-//   //See header file for documentation
-
-
-
-//   return kTRUE;
-
-//   if (trackPosition[1] < 0 ) 
-//     return kFALSE;
-  
-
-//   if ( TMath::Abs(trackPosition[2]) > fEmcalMaxZ ) 
-//     return kFALSE;
-  
-//   if ( TMath::Abs(trackPosition[0]) > fEmcalMaxX )
-//     return kFALSE;
-  
-  
-//   //
-//   return kTRUE;
-// }
-
index aaa759a06d5dcab836c7c3ae1c0d254e2d2f57ab..08fdaf4e91c39b60a79642a3c8ee7ef228a38d10 100644 (file)
 
 #include "AliHLTLogging.h"
 #include "AliESDtrack.h"
-#include "TRefArray.h"
-#include "AliESDEvent.h"
+#include "TObjArray.h"
+#include "TArrayI.h"
 
-class AliHLTGlobalTrackMatcher {
+class AliHLTGlobalTrackMatcher : public AliHLTLogging{
 
 public:
   AliHLTGlobalTrackMatcher();
@@ -28,40 +28,151 @@ public:
   /** destructor */
   virtual ~AliHLTGlobalTrackMatcher();
 
-
-  // Main function, loops over tracks, clusters
-  // Finds best match for cluster
-  Bool_t Match( AliESDEvent* event );
-
-
+  //Main function, loops over tracks and calls appropriate functions to establish matches
+  template <class T>
+  Int_t Match( TObjArray * trackArray, vector<T*>  &clustersVector, Double_t bz ); 
+  
 private:
-
+  
   void DoInit();
 
-  //Projects track to detector volume and decides if it passes in the vinity or not
-  Bool_t IsTrackCloseToDetector(AliESDtrack * track, Double_t bz, Double_t * trackPosition, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ);
+  //Loops over clusters and decides if track is a good match to any of these
+  template <class T>
+  Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz); 
 
-  //Fills fClustersArray with refs to the clusters, returns number of clusters
-  void MatchTrackToClusters( AliESDtrack * track, TRefArray * clustersArray, Int_t nClusters, Float_t * bestMatch, Double_t bz );
-    
-  // Geometrical paramaters of detector volume
+  //Add track Id to cluster's list of matching tracks
+  Int_t AddTrackToCluster(Int_t tId, Int_t* clustersArray, Bool_t bestMatch, Int_t nMatches);
+  Int_t AddTrackToCluster(Int_t tId, TArrayI* clustersArray, Bool_t bestMatch, Int_t nMatches);
+
+  //Projects track to detector volume and decides if it's anywhere near calorimeter volume
+  Bool_t IsTrackCloseToDetector(AliExternalTrackParam * track, Double_t bz, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ, Double_t dRadius);
+
+  // Geometrical cut off values used to decide whether track is anywhere near calorimeter volumes
   Float_t fPhosMaxZ;              // max Z track    (cm)
   Float_t fPhosMaxX;              // max X track    (cm)
-  Float_t fEmcalMaxZ;
-  Float_t fEmcalMaxX;
+  Float_t fEmcalMaxZ;             // max Z track    (cm)
+  Float_t fEmcalMaxX;             // max X track    (cm)
 
-  Float_t fMatchDistance;
+  Float_t fMatchDistance;        // Square of maximum distance where track is considered a match to cluster (cm^2)
 
-  const Double_t fPhosRadius;
-  const Double_t fEmcalRadius;         // Radial position of detector volume
-  //TRefArrays that will be filled with referenced to the PHOS and EMCAL Clusters
-  TRefArray * fPhosClustersArray;
-  TRefArray * fEmcalClustersArray;
+  const Double_t fPhosRadius;          // Radial position of PHOS 
+  const Double_t fEmcalRadius;         // Radial position of EMCAL
 
   AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & );
   AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &);
 
-  ClassDef(AliHLTGlobalTrackMatcher,1) //Merging base class
+  ClassDef(AliHLTGlobalTrackMatcher,1) 
 };
 
+
+template <class T>
+Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &clustersVector, Double_t bz ) {
+  //See above for documentation
+
+  Int_t nTracks = trackArray->GetEntriesFast();
+  Int_t nPhosClusters = clustersVector.size();
+  //TODO emcal not yet implemented
+  Int_t nEmcalClusters = 0; //BALLE event->GetEMCALClusters(fEmcalClustersArray);
+  
+  if ( nTracks <= 0 ) {
+    HLTWarning("No tracks in event");
+    return 0;
+  } else if  ( (nEmcalClusters <= 0) && (nPhosClusters <= 0))  {
+    HLTWarning("No calorimeter clusters in Event"); 
+    return 0;
+  }
+
+  Float_t bestMatchPhos[nPhosClusters];   
+  for(int ic = 0; ic < nPhosClusters; ic++) {
+    bestMatchPhos[ic] = 999999;
+  }
+    
+  //BALLE TODO EMCAL implement
+  // Float_t bestMatchEmcal[nEmcalClusters];    
+  //   for(int ic = 0; ic < nEmcalClusters; ic++) {
+  //     bestMatchEmcal[ic] = 999999;
+  //   }
+    
+    
+  //Loop over tracks
+  for (int it = 0; it < nTracks; it++ ) {
+    AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
+
+    if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
+      MatchTrackToClusters( track, clustersVector, nPhosClusters, bestMatchPhos, bz);
+      
+      //BALLE TODO EMCAL !!!!
+      //     } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
+      //       MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz);
+    } 
+    
+
+  } // track loop 
+  
+    
+  return 0;
+} 
+
+
+
+template <class T>
+Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
+  
+  //See header file for documentation
+  Int_t iResult = 0;
+  Float_t clusterPosition[3];
+  Double_t trackPosition[3];
+  
+  for(int ic = 0; ic < nClusters; ic++) {
+    
+    T * cluster = clustersVector.at(ic);
+    
+    //Get cluster global coordinates
+    cluster->GetPosition(clusterPosition);
+   
+    //Get track postion at radius of cluster
+    Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]);      
+    if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
+      HLTWarning("Track reached detector but not cluster!!!!!!");
+      continue;
+    }
+    
+    //Calculate track - cluster residual
+  
+
+    //Get residual in z= 0 plane (squared)
+    Double_t dxy = 0;
+    for(int i = 0; i < 2; i++) {
+      Double_t dd = trackPosition[i] - clusterPosition[i];
+      dxy += dd*dd;
+    }
+
+    //Get z residual (squared)
+    Double_t dd = trackPosition[2] - clusterPosition[2];
+    Double_t dz = dd*dd;
+  
+    Double_t match = dz + dxy;
+        
+    if( match > fMatchDistance  )  {     
+      continue;
+    }
+
+    if (match < bestMatch[ic]) {
+      bestMatch[ic] = match;
+      cluster->SetEmcCpvDistance(TMath::Sqrt(match));
+      //cluster->SEt
+    }
+    
+    //Add track to cluster's array of matching tracks
+    Int_t nTracksMatched = cluster->GetNTracksMatched();
+    iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched);
+    HLTInfo("Added track %d to cluster %d, it now has %d matching tracks", track->GetID(), cluster->GetID(), cluster->GetNTracksMatched());
+  }
+  
+  return iResult;
+}
+
 #endif
diff --git a/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx b/HLT/global/AliHLTGlobalTrackMatcherComponent.cxx
new file mode 100644 (file)
index 0000000..3c94039
--- /dev/null
@@ -0,0 +1,227 @@
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Svein Lindal <svein.lindal@gmail.com>                 *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
+
+/** @file   AliHLTGlobalTrackMatcherComponent.cxx
+    @author Svein Lindal
+    @brief  Component to match TPC tracks to Calo Clusters
+*/
+
+#if __GNUC__>= 3
+using namespace std;
+#endif
+
+#include "AliHLTProcessor.h"
+#include "AliHLTGlobalTrackMatcherComponent.h"
+#include "AliHLTGlobalTrackMatcher.h"
+#include "TObjArray.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliHLTGlobalBarrelTrack.h"
+#include "AliHLTCaloClusterDataStruct.h"
+#include "AliHLTCaloClusterReader.h"
+
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
+
+ClassImp(AliHLTGlobalTrackMatcherComponent);
+
+AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
+  fTrackMatcher(NULL),
+  fNEvents(0),
+  fBz(-9999999),
+  fClusterReader(NULL)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+}
+
+AliHLTGlobalTrackMatcherComponent::~AliHLTGlobalTrackMatcherComponent()
+{
+  // see header file for class documentation
+  if(fTrackMatcher)
+    delete fTrackMatcher;
+  fTrackMatcher = NULL;
+
+  if(fClusterReader)
+    delete fClusterReader;
+  fClusterReader = NULL;
+
+}
+
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+const char* AliHLTGlobalTrackMatcherComponent::GetComponentID()
+{
+  // see header file for class documentation
+  return "TrackMatcher";
+}
+
+void AliHLTGlobalTrackMatcherComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
+{
+  // see header file for class documentation
+  list.clear();
+  list.push_back( kAliHLTDataTypeTrack );
+  list.push_back( kAliHLTDataTypeCaloCluster );
+}
+
+AliHLTComponentDataType AliHLTGlobalTrackMatcherComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny;
+}
+
+void AliHLTGlobalTrackMatcherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // see header file for class documentation
+  // XXX TODO: Find more realistic values.
+  constBase = 80000;
+  inputMultiplier = 0;
+}
+
+AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
+{
+  // see header file for class documentation
+  return new AliHLTGlobalTrackMatcherComponent;
+}
+
+int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv ) 
+{
+  //BALLE TODO, use command line values to initialise matching vaules
+ // init
+  Int_t iResult = argc;
+  
+  if(argc > 0){
+    HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
+  }
+
+  fClusterReader = new AliHLTCaloClusterReader();
+
+  fBz = GetBz();
+  if(fBz == -999999) {
+    HLTError("Magnetic field not properly set, current value: %d", fBz);
+  }
+
+  fTrackMatcher = new AliHLTGlobalTrackMatcher();
+
+  fNEvents = 0;
+
+  return iResult; 
+}
+  
+int AliHLTGlobalTrackMatcherComponent::DoDeinit() 
+{
+  // see header file for class documentation
+  Int_t iResult = 1;
+  
+  if(fTrackMatcher)
+    delete fTrackMatcher;
+  fTrackMatcher = NULL;
+  
+  if(fClusterReader)
+    delete fClusterReader;
+  fClusterReader = NULL;
+  
+
+  fNEvents = 0;
+
+  return iResult;
+}
+
+int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) 
+{
+  
+  //See header file for documentation
+  Int_t iResult = 0;
+  
+  if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
+    return 0;
+
+
+  fNEvents++;
+  
+  //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
+  TObjArray * trackArray = new TObjArray();
+  trackArray->SetOwner(kFALSE);
+  vector<AliHLTGlobalBarrelTrack> tracks;
+  
+  for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+    
+    if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
+
+      for(UInt_t it = 0; it < tracks.size(); it++) {
+       AliHLTGlobalBarrelTrack track = tracks.at(it);
+       HLTInfo("track ID %d", track.TrackID());
+       trackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
+      }
+    } else {
+      HLTWarning("Converting tracks to vector failed");
+    }
+    
+    //Push the TPC block on, without any changes
+    PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+
+  }
+
+  //Vector to contain the phos clusters
+  vector<AliHLTCaloClusterDataStruct *> phosClustersVector;
+  AliHLTCaloClusterDataStruct * caloClusterStructPtr;
+  
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+    AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
+    fClusterReader->SetMemory(caloClusterHeaderPtr);
+    
+    //BALLE, TODO, make it able to do EMCAL as well!!!
+    phosClustersVector.resize((Int_t) (caloClusterHeaderPtr->fNClusters));
+    
+    Int_t nClusters = 0;
+    while((caloClusterStructPtr = fClusterReader->NextCluster()) != 0) {
+      //BALLE stil just phos
+      phosClustersVector[nClusters++] = caloClusterStructPtr;  
+    }
+    
+    iResult = fTrackMatcher->Match(trackArray, phosClustersVector, fBz);
+    if(iResult <0) {
+      HLTWarning("Error in track matcher");
+    }
+
+    PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+  }
+
+  //BALLE TODO phos only !!!!
+  
+  delete trackArray;
+  return iResult;
+
+}
+
+// int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
+// {
+//   Int_t iResult = 1;
+//   return iResult;
+// }
+
+// int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+// {
+//   Int_t iResult = 1;
+//   return iResult;
+// }
diff --git a/HLT/global/AliHLTGlobalTrackMatcherComponent.h b/HLT/global/AliHLTGlobalTrackMatcherComponent.h
new file mode 100644 (file)
index 0000000..07e462d
--- /dev/null
@@ -0,0 +1,88 @@
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
+
+/** @file   AliHLTGlobalTrackMatcherComponent.h
+    @author Sergey Gorbunov
+    @brief  Component for monitor V0 physics
+*/
+
+
+
+#ifndef ALIHLTGLOBALTRACKMATCHERCOMPONENT_H
+#define ALIHLTGLOBALTRACKMATCHERCOMPONENT_H
+
+
+class AliHLTProcessor;
+class AliHLTGlobalTrackMatcher;
+class AliHLTCaloClusterReader;
+
+/**
+ * @class AliHLTTPCV0HistoComponent
+ * Component for monitor V0 physics 
+ */
+class AliHLTGlobalTrackMatcherComponent : public AliHLTProcessor
+{
+public:
+  /** default constructor */
+  AliHLTGlobalTrackMatcherComponent();
+  /** destructor */
+  virtual ~AliHLTGlobalTrackMatcherComponent();
+
+  // Public functions to implement AliHLTComponent's interface.
+  // These functions are required for the registration process
+
+  /** interface function, see AliHLTComponent for description */
+  const char* GetComponentID();
+  /** interface function, see AliHLTComponent for description */
+  void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+  /** interface function, see AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+  /** interface function, see AliHLTComponent for description */
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+  /** interface function, see AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+protected:
+
+  // Protected functions to implement AliHLTComponent's interface.
+  // These functions provide initialization as well as the actual processing
+  // capabilities of the component. 
+
+  /** interface function, see AliHLTComponent for description */
+  int DoInit( int argc, const char** argv );
+  /** interface function, see AliHLTComponent for description */
+  int DoDeinit();
+  /** interface function, see AliHLTComponent for description */
+  int DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& trigData );
+
+  //int Reconfigure(const char* cdbEntry, const char* chainId);
+
+  using AliHLTProcessor::DoEvent;
+  
+private:
+  /** copy constructor prohibited */
+  AliHLTGlobalTrackMatcherComponent(const AliHLTGlobalTrackMatcherComponent&);
+  /** assignment operator prohibited */
+  AliHLTGlobalTrackMatcherComponent& operator=(const AliHLTGlobalTrackMatcherComponent&);
+  /**
+   * Configure the component.
+   * Parse a string for the configuration arguments and set the component
+   * properties.
+   */ 
+  //  int Configure(const char* arguments);
+  
+
+  AliHLTGlobalTrackMatcher * fTrackMatcher;   //Instance of the track matcher class
+
+  Int_t fNEvents;    //Number of events processed
+
+  Double_t fBz;   //Magnetic field of event
+
+  AliHLTCaloClusterReader * fClusterReader;   //Instance of helper class to read calorimeter structs
+
+  
+  ClassDef(AliHLTGlobalTrackMatcherComponent, 0);
+
+};
+#endif
index 482f6ac4bce465f35d3672aee2f46f91f74d3dcf..8dad6a78699622f5bbcb9b9e6278376c282dc0be 100644 (file)
@@ -209,16 +209,19 @@ AliHLTCaloHistoComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& lis
   //see header file for documentation
   list.clear();
   list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
+  list.push_back( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL );
+  list.push_back(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS );
+
   //   list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
-//   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
-//   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
+  //   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
+  //   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
 
 }
 
 AliHLTComponentDataType AliHLTCaloHistoComponent::GetOutputDataType()
 {
   //see header file for documentation
-  return (kAliHLTDataTypeHistogram  | kAliHLTDataOriginOut);
+  return kAliHLTDataTypeHistogram  | kAliHLTDataOriginAny ;
 }
 
 
@@ -245,14 +248,13 @@ Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtDat
 //     fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
 //   }
 
-
   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
     AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
     event->GetStdContent();
     
     //EMCAL
     if(fDoEmcal){
+      
       Int_t nec = event->GetEMCALClusters(fEmcalClustersArray);
       
       if(fDoMatchedTracks)
@@ -260,16 +262,16 @@ Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtDat
       
       if(fDoInvariantMass)
        fEmcalInvariantMassHistProducer->FillHistograms(nec, fEmcalClustersArray);
-    
+      
       if(fDoClusterEnergy)
        fEmcalClusterEnergyHistProducer->FillHistograms(nec, fEmcalClustersArray);
-   
+      
       if(fDoCellEnergy)
        fEmcalCellEnergyHistProducer->FillHistograms(nec, fEmcalClustersArray);;
-   
+      
     }
-
-
+    
+    
     //PHOS
     if(fDoPhos){
       
@@ -280,17 +282,17 @@ Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtDat
       
       if(fDoInvariantMass)
        fPhosInvariantMassHistProducer->FillHistograms(npc, fPhosClustersArray);
-
+      
       if(fDoClusterEnergy)
        fPhosClusterEnergyHistProducer->FillHistograms(npc, fPhosClustersArray);
-
+      
       if(fDoCellEnergy)
        fPhosCellEnergyHistProducer->FillHistograms(npc, fPhosClustersArray);
-   
-    }
       
+    }
+    
   }
-
+  
   
   //Push histos
   
@@ -302,10 +304,10 @@ Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtDat
     
     if(fDoMatchedTracks)
       PushBack(fPhosMatchedTracksHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
-
+    
     if(fDoClusterEnergy) 
       PushBack(fPhosClusterEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
-
+    
     if(fDoCellEnergy)
       PushBack(fPhosCellEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
     
index 2a9039693ea8f0eb1d02162e382748c3298950c6..c6f044e17c88199821ac5461d303399c6859ec8b 100644 (file)
@@ -7,6 +7,7 @@ CLASS_HDRS:=    AliHLTGlobalEsdConverterComponent.h \
                AliHLTGlobalAgent.h \
                AliHLTGlobalVertexerComponent.h \
                AliHLTGlobalTrackMatcher.h \
+               AliHLTGlobalTrackMatcherComponent.h \
                AliHLTGlobalVertexerHistoComponent.h \
                AliHLTGlobalHistoCollector.h \
                physics/AliHLTV0HistoComponent.h \
@@ -16,10 +17,8 @@ CLASS_HDRS:= AliHLTGlobalEsdConverterComponent.h \
                physics/AliHLTCaloHistoClusterEnergy.h \
                physics/AliHLTCaloHistoCellEnergy.h 
 
-#              physics/AliHLTPHOSHistogramProducerComponent.h \
-#physics/AliHLTPHOSHistogramProducerComponent.h 
 
-#              
+#
 MODULE_SRCS=   $(CLASS_HDRS:.h=.cxx)
 
 MODULE_HDRS:=  $(CLASS_HDRS)