]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Revert "Updated track-matcher component to deal with EMCAL" because it was plain...
authorslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Apr 2010 22:47:23 +0000 (22:47 +0000)
committerslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Apr 2010 22:47:23 +0000 (22:47 +0000)
This reverts commit 0838566de2e3e6bacf7c7b1b894570c349f3938d.

HLT/global/AliHLTGlobalTrackMatcher.cxx
HLT/global/AliHLTGlobalTrackMatcher.h
HLT/global/AliHLTGlobalTrackMatcherComponent.cxx

index c6c3b6567beb3f7f6501bf99346d9bcf66009b4d..1d1fdfb4fb418f68ae9c342c5404fe0e6cad29ab 100644 (file)
@@ -1,4 +1,4 @@
-//$Id  $
+//$Id$
 /**************************************************************************
  * This file is property of and copyright by the ALICE HLT Project        * 
  * ALICE Experiment at CERN, All rights reserved.                         *
@@ -22,6 +22,8 @@
 */
 
 #include "AliHLTGlobalTrackMatcher.h"
+//#include "AliESDCaloCluster.h"
+
 
 
 #if __GNUC__>= 3
@@ -32,18 +34,39 @@ ClassImp(AliHLTGlobalTrackMatcher)
 
 
 AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() :
-  fMaxZ(0),
-  fMaxX(0),
+  fPhosMaxZ(0),
+  fPhosMaxX(0),
+  fEmcalMaxZ(0),
+  fEmcalMaxX(0),
   fMatchDistance(0),
-  fRadius(0),
-  fYSign(kFALSE)
+  fPhosRadius(460),
+  fEmcalRadius(448)
 {
   //Default constructor
+  DoInit();
 }
 
+//_____________________________________________________________________________
 AliHLTGlobalTrackMatcher::~AliHLTGlobalTrackMatcher()
 {
   //Destructor
+
+}
+
+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;
+
+  fPhosMaxX = 355 + TMath::Sqrt(fMatchDistance) + 30;
+  fPhosMaxZ = 64.+ TMath::Sqrt(fMatchDistance) + 30;
+
+  fEmcalMaxZ = 350 + TMath::Sqrt(fMatchDistance) + 30;
+  fEmcalMaxX = 3000;
+
+
 }
 
 Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, TArrayI* matchedTracksArray, Bool_t bestMatch, Int_t nMatches){
@@ -61,11 +84,12 @@ Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, TArrayI* matchedTra
 }
 
 Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, Int_t* matchArray, bool bestMatch, Int_t nMatches ){
-  //See header file for documentation
+
+  //  HLTInfo("Adding track %d to cluster with %d previous matches", tId, nMatches);
   
   //BALLE TODO: remove hardcoded 9
-  if (nMatches > 9) {                                                   //BALLE this one tooo
-    HLTError("The number of matching tracks (%d) exceeds the array size of %d", nMatches, 9);
+  if (nMatches > 9) {                                                   //BALLE this on tooo
+    HLTDebug("The number of matching tracks (%d) exceeds the array size of %d", nMatches, 9);
     return 0;
   }
 
@@ -83,23 +107,23 @@ Int_t AliHLTGlobalTrackMatcher::AddTrackToCluster(Int_t tId, Int_t* matchArray,
 
 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
   Double_t trackPosition[3] = {0, 0, 0};
   if (! (track->GetXYZAt(dRadius, bz, trackPosition)) ) {
     return kFALSE;
   }
 
+  //  HLTInfo("Track coordinate at R = PHOS radius %f %f %f", trackPosition[0],trackPosition[1],trackPosition[2]);
+
+
   //Positive y for EMCAL, negative for PHOS
   if(ySign) {
-    if (trackPosition[1] < 0 ) {
+    if (trackPosition[1] < 0 ) 
       return kFALSE;
-    }
-    
   } else {
-    if (trackPosition[1] > 0 ) {
+    if (trackPosition[1] > 0 ) 
       return kFALSE;
-    }
   }
   
   
@@ -109,6 +133,7 @@ Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToDetector(AliExternalTrackParam *
   if (TMath::Abs(trackPosition[0]) > fMaxX )
     return kFALSE;
 
-
+  // HLTInfo("kTRUE");
+  
   return kTRUE;  
 }
index 53f1574b62174116d3ace0756d6eebd5eb00d709..11b62123da354c9db7d5755e204d028bda40ab03 100644 (file)
 #include "TObjArray.h"
 #include "TArrayI.h"
 
-class AliHLTGlobalTrackMatcher : public AliHLTLogging {
+class AliHLTGlobalTrackMatcher : public AliHLTLogging{
 
 public:
-
-  ///Constructor
   AliHLTGlobalTrackMatcher();
 
-  ///Destructor
+  /** destructor */
   virtual ~AliHLTGlobalTrackMatcher();
 
-  ///Main function, loops over tracks and calls appropriate functions to establish matches
+  //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 ); 
-
-
-  ///Set the maximum Z to be within distance of detector volume
-  void SetMaxZ(Float_t z) { fMaxZ = z; }
-  ///Set the maximum X to be within distance of detector volume
-  void SetMaxX(Float_t x) { fMaxX = x; }
-  ///Set whether the detector is in positive y direction
-  void SetYSign(Bool_t y) { fYSign = y; }
-  ///Set the max distance to be considered a match
-  void SetMatchDistance(Float_t d)  { fMatchDistance = d*d; }
-  ///Set the radius of detector volume
-  void SetRadius(Float_t r) { fRadius = r; }
-
-private:  
-
+  
+private:
+  
   void DoInit();
 
   //Loops over clusters and decides if track is a good match to any of these
@@ -62,12 +48,15 @@ private:
   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 fMaxZ;              // max Z track    (cm)
-  Float_t fMaxX;              // max X track    (cm)
+  Float_t fPhosMaxZ;              // max Z track    (cm)
+  Float_t fPhosMaxX;              // max X track    (cm)
+  Float_t fEmcalMaxZ;             // max Z track    (cm)
+  Float_t fEmcalMaxX;             // max X track    (cm)
+
+  Float_t fMatchDistance;        // Square of maximum distance where track is considered a match to cluster (cm^2)
 
-  Float_t fMatchDistance;     // Square of maximum distance where track is considered a match to cluster (cm^2)
-  Double_t fRadius;           // Radial position of detector volume
-  Bool_t fYSign;               // Positive or negative y
+  const Double_t fPhosRadius;          // Radial position of PHOS 
+  const Double_t fEmcalRadius;         // Radial position of EMCAL
 
   AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & );
   AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &);
@@ -76,49 +65,72 @@ private:
 };
 
 
-
 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 nClusters = clustersVector.size();
-
+  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  ( nClusters <= 0 )  {
+  } else if  ( (nEmcalClusters <= 0) && (nPhosClusters <= 0))  {
+    //HLTWarning("No calorimeter clusters in Event"); 
     return 0;
   }
 
-  Float_t bestMatch[nClusters];   
-  for(int ic = 0; ic < nClusters; ic++) {
-    bestMatch[ic] = 999999;
+  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, fMaxX, fYSign, fMaxZ, fRadius ) ) {
-      MatchTrackToClusters( track, clustersVector, nClusters, bestMatch, bz);
+
+    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++) {
+  
+  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
@@ -128,30 +140,43 @@ Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * tr
       continue;
     }
 
+
+    //    HLTInfo("Cluster global position %f %f %f", clusterPosition[0],clusterPosition[1],clusterPosition[2]);
+
+    
     //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;
     
+    //    HLTInfo("Track cluster residual %f, maxmatch %f", match, fMatchDistance);
+    
     if( match > fMatchDistance  )  {     
       continue;
     }
 
+
     if (match < bestMatch[ic]) {
       bestMatch[ic] = match;
       cluster->SetEmcCpvDistance(TMath::Sqrt(match));
       cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz));
     }
     
+    //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;
index 6375b4b44e93b9719fd3e72a11c72e75e9b5f2b8..ad50e90f53640cfc695aa36cf4d001561390b53c 100644 (file)
@@ -104,64 +104,40 @@ AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
   return new AliHLTGlobalTrackMatcherComponent;
 }
 
-Int_t AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv ) {
+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)){
-    HLTError("Component must be configured with detector as first parameter, either \"PHOS\" or \"EMCAL\"");
-    return -ENODEV;
-  } else {
-    TString allArgs = "";
-    
-    for ( int i = 0; i < argc; i++ ) {
-      if ( !allArgs.IsNull() ) allArgs += " ";
-      allArgs += argv[i];
-    }
-    
-    HLTInfo("Configuring with string \"%s\"", allArgs.Data());
+  if(argc > 0){
+    HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
   }
 
-  if(!strcmp("PHOS", argv[0])) {
-    fTrackMatcher = new AliHLTGlobalTrackMatcher();
-    fTrackMatcher->SetMaxX( 355. + 70. );
-    fTrackMatcher->SetMaxZ( 64. + 70. );
-    fTrackMatcher->SetYSign(kFALSE);
-    fTrackMatcher->SetRadius(460.);
-    fTrackMatcher->SetMatchDistance(40.*40);
-  } else if(!strcmp("EMCAL", argv[0])) {
-    fTrackMatcher = new AliHLTGlobalTrackMatcher();
-    fTrackMatcher->SetMaxX( 500. + 70. );
-    fTrackMatcher->SetMaxZ( 500. + 70. );
-    fTrackMatcher->SetYSign(kTRUE);
-    fTrackMatcher->SetRadius(470.);
-    fTrackMatcher->SetMatchDistance(40.*40);
-  } else {
-    HLTError("Component must be configured with detector as first parameter, either \"PHOS\" or \"EMCAL\"");
-    return -ENODEV;
-  }
-
-  if(!fTrackArray){
-    fTrackArray = new TObjArray();
-    fTrackArray->SetOwner(kFALSE);
-  }
-  
   if(!fClusterReader)
     fClusterReader = new AliHLTCaloClusterReader();
-  
+
   fBz = GetBz();
   if(fBz == -999999) {
     HLTError("Magnetic field not properly set, current value: %d", fBz);
-    return -ENODEV;
   }
 
-  return 0; 
-}
+  if(!fTrackMatcher)
+    fTrackMatcher = new AliHLTGlobalTrackMatcher();
 
+  fNEvents = 0;
+
+  if(!fTrackArray){
+    fTrackArray = new TObjArray();
+    fTrackArray->SetOwner(kFALSE);
+  }
+
+  return iResult; 
+}
   
-Int_t AliHLTGlobalTrackMatcherComponent::DoDeinit() {
+int AliHLTGlobalTrackMatcherComponent::DoDeinit() 
+{
   // see header file for class documentation
   Int_t iResult = 1;
   
@@ -174,66 +150,82 @@ Int_t AliHLTGlobalTrackMatcherComponent::DoDeinit() {
   fClusterReader = NULL;
   
 
+  fNEvents = 0;
+
   return iResult;
 }
 
-
-Int_t AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)  {
+int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) 
+{
   
   //See header file for documentation
-
   Int_t iResult = 0;
   
   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
     return 0;
 
-  fTrackArray->Clear();
-  vector<AliHLTGlobalBarrelTrack> tracks;
+
+  fNEvents++;
+
+  //Loop over TPC blocks
+  //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
+
+   fTrackArray->Clear();
+   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++) {
-               fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
-      }
-    } else {
-      HLTError("Converting tracks to vector failed");
-    }
+   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);
+       fTrackArray->AddLast(dynamic_cast<TObject*>(&(tracks.at(it))));
+              }
+     } else {
+             HLTWarning("Converting tracks to vector failed");
+     }
     
-    ///Push the TPC blocks on, without changes
-    PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
-  }
+     //     //Push the TPC block on, without any changes
+     PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+
+   }
 
   //Get the clusters
   AliHLTCaloClusterDataStruct * caloClusterStruct;
-  vector<AliHLTCaloClusterDataStruct*> clusterVec;
-
-  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
-    AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
-    fClusterReader->SetMemory(caloClusterHeader);
-
-    
-    if ( (caloClusterHeader->fNClusters) < 0) {
-      HLTError("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
-      continue;
-    } else {    
-      clusterVec.reserve(clusterVec.size()+(int) (caloClusterHeader->fNClusters)); 
-      while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
-       clusterVec.push_back(caloClusterStruct);  
-      }
-    }
-  }
-          
-  iResult = fTrackMatcher->Match(fTrackArray, clusterVec, fBz);
+  vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
   
-  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
-    PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
+     AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
+     fClusterReader->SetMemory(caloClusterHeader);
+     
+     if ( (caloClusterHeader->fNClusters) < 0) {
+       HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
+       return -1;
+     } else {    
+
+       //BALLE, TODO, make it able to do EMCAL as well!!!
+       phosClustersVector.resize((int) (caloClusterHeader->fNClusters)); 
+       Int_t nClusters = 0;
+       while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
+        //BALLE stil just phos
+        phosClustersVector[nClusters++] = caloClusterStruct;  
+       }
+       
+       iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, fBz);
+     }
+     
+     if(iResult <0) {
+       //HLTWarning("Error in track matcher");
+     }
+     PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
+     //PushBack(pBlock->fPtr, pBlock->fSize, kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny );
   }
 
-  fTrackArray->Clear();
-   
-  return iResult;
+
+   fTrackArray->Clear();
+   //BALLE TODO phos only !!!!
    
+   return iResult;
+
 }
 
 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)