]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
implemented alternative (faster) track extrapolation for EMCAL track matcher
authorfronchet <fronchet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Sep 2011 08:39:02 +0000 (08:39 +0000)
committerfronchet <fronchet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Sep 2011 08:39:02 +0000 (08:39 +0000)
HLT/global/AliHLTGlobalTrackMatcher.cxx
HLT/global/AliHLTGlobalTrackMatcher.h
HLT/global/AliHLTGlobalTrackMatcherComponent.cxx
HLT/global/AliHLTGlobalTrackMatcherComponent.h

index 8896f5280942fc8eda4ed9dd5e583b27bbd699e9..87ea4a9298dd8aa360b7838a8eb53c6b2daa96b1 100644 (file)
@@ -39,7 +39,9 @@ AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() :
   fMatchDistance(0),
   fMatchDistanceEMCal(0),
   fPhosRadius(460),
-  fEmcalRadius(448)
+  fEmcalRadius(448),
+  fStep(100.),
+  fMass(0.139)
 {
   //Default constructor
   DoInit();
@@ -58,7 +60,7 @@ void AliHLTGlobalTrackMatcher::DoInit( ) {
 
 
   fMatchDistance = 40*40;
-  fMatchDistanceEMCal = 0.1; // EMCal deltaR(EtaxPhi) cut. It must be refined inside AliESD analysis. 
+  fMatchDistanceEMCal = 0.1; // EMCal EtaxPhi cut 
 
   fPhosMaxX = 355 + TMath::Sqrt(fMatchDistance) + 30;
   fPhosMaxZ = 64.+ TMath::Sqrt(fMatchDistance) + 30;
@@ -66,6 +68,8 @@ void AliHLTGlobalTrackMatcher::DoInit( ) {
   fEmcalMaxZ = 350 + TMath::Sqrt(fMatchDistance) + 30;
   fEmcalMaxX = 3000;
 
+  fStep=100.;// Step for EMCAL extrapolation
+  fMass=0.139;// Mass for EMCAL extrapolation hipothesis
 
 }
 
@@ -105,36 +109,28 @@ 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 ) 
-      return kFALSE;
+    //EMCAL
+    if (track->Pt()<1.)        return kFALSE;
+    if (track->Eta()>.8||track->Eta()<-.8)     return kFALSE;
+    if (track->Phi()>4.||track->Phi()<1.)      return kFALSE;   
   } else {
+    //PHOS
+      //Get track instersection with cylinder defined by detector radius
+    Double_t trackPosition[3] = {0, 0, 0};
+    if (! (track->GetXYZAt(dRadius, bz, trackPosition)) ) {
+      return kFALSE;
+    }
     if (trackPosition[1] > 0 ) 
       return kFALSE;
+    if ( (TMath::Abs(trackPosition[2]) > fMaxZ) ) 
+      return kFALSE;
+    if (TMath::Abs(trackPosition[0]) > fMaxX )
+      return kFALSE;
   }
-  
-  
-  if ( (TMath::Abs(trackPosition[2]) > fMaxZ) ) 
-    return kFALSE;
-  
-  if (TMath::Abs(trackPosition[0]) > fMaxX )
-    return kFALSE;
-
-  // HLTInfo("kTRUE");
-  
   return kTRUE;  
 }
index fab831a08ffeeac27447ea2af68fc7cd8549f28c..a822a75e8f1ffca3127b7c5a894cbdd99b616a6e 100644 (file)
@@ -33,7 +33,7 @@ public:
 
   //Main function, loops over tracks and calls appropriate functions to establish matches
   template <class T>
-  Int_t Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, vector<T*>  &emcalClustersVector,  Double_t bz ); 
+  Int_t Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, vector<T*>  &emcalClustersVector,  Double_t bz, Int_t Method ); 
 
 private:
   
@@ -45,7 +45,7 @@ private:
   Int_t MatchTrackToClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz); 
 
   template <class T>
-  Int_t MatchTrackToEMCalClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz); // EMCal Track-Matching from recoUtils::ExtrapolateTracktoCluster
+  Int_t MatchTrackToEMCalClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz, Int_t Method); // EMCal Track-Matching from recoUtils::ExtrapolateTracktoCluster
 
   //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);
@@ -66,6 +66,9 @@ private:
   const Double_t fPhosRadius;          // Radial position of PHOS 
   const Double_t fEmcalRadius;         // Radial position of EMCAL
 
+  Float_t fStep; // Step for EMCal Extrapolation Calculation
+  Float_t fMass; // Mass for EMCal Extrapolation hipothesis
+
   AliHLTGlobalTrackMatcher(const AliHLTGlobalTrackMatcher & );
   AliHLTGlobalTrackMatcher & operator = (const AliHLTGlobalTrackMatcher &);
 
@@ -74,7 +77,8 @@ private:
 
 
 template <class T>
-Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, vector<T*> &emcalClustersVector,  Double_t bz ) {
+Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, vector<T*> &emcalClustersVector,  Double_t bz, Int_t Method ) {
+  //Method for extrapolation EMcal
   //See above for documentation
 
   Int_t nTracks = trackArray->GetEntriesFast();
@@ -106,15 +110,16 @@ Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phos
   for (int it = 0; it < nTracks; it++ ) {
     AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
 
-    if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
-
+    if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
+        if(Method!=1&&Method!=2){
+         HLTError("\n Method %d is not valid",Method);
+         return 0; // No method defined
+         }
+       MatchTrackToEMCalClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz,Method); //With Method
+       
+    } else if  ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
       MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz);
-
-    } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
-
-       MatchTrackToEMCalClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz);
     } 
-
   }   
     
   return 0;
@@ -122,58 +127,47 @@ Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phos
 
 //MARCEL 
 template <class T>
-Int_t AliHLTGlobalTrackMatcher::MatchTrackToEMCalClusters( AliExternalTrackParam * track,  vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t  /*bz */) {
-  
+Int_t AliHLTGlobalTrackMatcher::MatchTrackToEMCalClusters( AliExternalTrackParam * track,  vector<T*> &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz, Int_t Method ) {
+
   //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);
-
-/* Comment:July 2011
-   The lines below correspond to the method for Track-matching from RecoUtils:ExtrapolatetoCluster()
-   In principle, the method ExtrapolateToCluster should be called directly from RecoUtils. The problems is that this method requires AliVCluster
-   which would have to be created inside the GlobalMatcher, since the information that this class obtains from the Cluster comes from the
-   data struct. In order to avoid the whole creation of a AliVCluster object, the code from RecoUtils
+    T * cluster = clustersVector.at(ic);
+    if(cluster->E()<1.)continue;  
+/* The lines below correspond to the method for Track-matching from RecoUtils:ExtrapolatetoCluster
+   In principle, the method ExtrapolateToCluster should be called directly from RecoUtils. The problems is that This method requires AliVCluster
+   which would have to be created inside the GlobalMatcher, since the information this class obtains from the Cluster comes from the
+   data struct with the cluster information. In order to avoid the whole creation of a AliVCluster object, the code from RecoUtils
    was brought here in the same way it is written there.
 */ 
-    if(cluster->E()<1.)continue;  
-    if(track->Pt()<1.)continue;
-
-    // This is a rough cut in acceptance, since it is pointless to try matching with tracks far from the EMCal
-    if(track->Eta()<-.9)continue;
-    if(track->Eta()>.9)continue;
-    if(track->Phi()>4.)continue; 
-    if(track->Phi()<.9)continue;
-    
     cluster->GetPosition(clusterPosition);
-    TVector3 VClsPos(clusterPosition[0], clusterPosition[1], clusterPosition[2]); //MARCEL  
+    TVector3 vec(clusterPosition[0],clusterPosition[1],clusterPosition[2]);
+    if(clusterPosition[1]<0.)  continue;  
+    if(TMath::Abs(track->Eta()-vec.Eta())>0.3) continue; 
+    
     AliExternalTrackParam *trkParam = new AliExternalTrackParam(*track);//Retrieve the starting point every time before the extrapolation
     Double_t trkPos[3];
-    TVector3 vec(clusterPosition[0],clusterPosition[1],clusterPosition[2]);
     Double_t alpha =  ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
     vec.RotateZ(-alpha); //Rotate the cluster to the local extrapolation coordinate system
     trkParam->Rotate(alpha); //Rotate the track to the same local extrapolation system
-    Float_t fMass=0.139;
-    Float_t fStep=100.;
-    if(!AliTrackerBase::PropagateTrackToBxByBz(trkParam, vec.X(), fMass, fStep,kFALSE, 0.8, -1)) return kFALSE; 
+    if(1==Method&&!trkParam->GetXYZAt(vec.X(), bz, trkPos))            continue; // Simpler extrapolation  
+    if(2==Method){
+      if(!AliTrackerBase::PropagateTrackToBxByBz(trkParam, vec.X(), fMass, fStep,kFALSE, 0.8, -1))     continue;  
+      trkParam->GetXYZ(trkPos); //Get the extrapolated global position
+      }
 
-    trkParam->GetXYZ(trkPos); //Get the extrapolated global position
     TVector3 clsPosVec(clusterPosition[0],clusterPosition[1],clusterPosition[2]);
     TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
-    Float_t clsPhi = (Float_t)clsPosVec.Phi();
-    if(clsPhi<0) clsPhi+=2*TMath::Pi();
-    Float_t trkPhi = (Float_t)trkPosVec.Phi();
-    if(trkPhi<0) trkPhi+=2*TMath::Pi();
-    Double_t tmpPhi = clsPhi-trkPhi;  // track cluster matching
-    Double_t tmpEta = clsPosVec.Eta()-trkPosVec.Eta();  // track cluster matching
-    Double_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);//MARCEL
-    Double_t match = tmpR;
 
+    // track cluster matching
+    Double_t tmpPhi = clsPosVec.DeltaPhi(trkPosVec); // tmpPhi is between -pi and pi
+    Double_t tmpEta = clsPosVec.Eta()-trkPosVec.Eta();  // track cluster matching
+    Double_t match=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);//MARCEL
     if( match > fMatchDistanceEMCal )continue;
     
     if (match < bestMatch[ic]) {
@@ -190,8 +184,6 @@ Int_t AliHLTGlobalTrackMatcher::MatchTrackToEMCalClusters( AliExternalTrackParam
   
   return iResult;
 }
-//end of MARCEL TEST
-
 
 template <class T>
 Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
index 2f6d073b407b78d92de62021268523b387e8767d..45888f5bb4c694e219bea0fcb7d723be85487bbd 100644 (file)
@@ -35,6 +35,9 @@ using namespace std;
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 #include "TGeoManager.h"
+#include "TRefArray.h"
+#include "TString.h"
+#include "TMap.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
@@ -42,6 +45,8 @@ AliHLTGlobalTrackMatcherComponent gAliHLTGlobalTrackMatcherComponent;
 ClassImp(AliHLTGlobalTrackMatcherComponent);
 
 AliHLTGlobalTrackMatcherComponent::AliHLTGlobalTrackMatcherComponent() :
+  fOCDBEntry("HLT/ConfigHLT/GlobalTrackMatcher"), //TODO
+  fMethod(1), //Method 1(PbPb) 2(pp)
   fTrackMatcher(NULL),
   fNEvents(0),
   fBz(-9999999),
@@ -108,10 +113,20 @@ AliHLTComponent* AliHLTGlobalTrackMatcherComponent::Spawn()
 
 int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv ) 
 {
+  Int_t iResult=ConfigureFromCDBTObjString(fOCDBEntry); //MARCEL
+    // configure from the command line parameters if specified
+  if (iResult>=0 && argc>0) {
+    iResult=ConfigureFromArgumentString(argc, argv);
+    HLTImportant("Extrapolation Method from argument string:  %d", fMethod);   
+  } else if ( iResult >=0 ) {
+    HLTImportant("Extrapolation Method from OCDB database entry:  %d", fMethod);   
+  } 
+  
+  
   //BALLE TODO, use command line values to initialise matching vaules
  // init
-  Int_t iResult = argc;
+//   Int_t iResult = argc;
+//   iResult = argc;
   
   if(argc > 0){
     HLTWarning("Ignoring all configuration args, starting with: argv %s", argv[0]);
@@ -134,7 +149,7 @@ int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
     fTrackArray = new TObjArray();
     fTrackArray->SetOwner(kFALSE);
   }
-  
+
   //*** GeoManager ***
    AliCDBPath path("GRP","Geometry","Data");
    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
@@ -147,7 +162,7 @@ int AliHLTGlobalTrackMatcherComponent::DoInit( int argc, const char** argv )
       HLTError("can not fetch object \"%s\" from CDB",path.GetPath().Data());
    }
    // ****
-  
+
 
   return iResult; 
 }
@@ -179,13 +194,16 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /
   
   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
     return 0;
-
+  
+  if(!IsDataEvent()){//marcel test
+    return 0;//marcel test
+  }//marcel test
 
   fNEvents++;
 
   //Loop over TPC blocks
   //BALLE TODO check that the tracks in the TObjArray are fine over several blocks
-
+  
    fTrackArray->Clear();
    vector<AliHLTGlobalBarrelTrack> tracks;
    
@@ -204,7 +222,7 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /
      //PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
 
    }
-
+    
    AliHLTCaloClusterDataStruct * caloClusterStruct;
    //Get the PHOS Clusters
    vector<AliHLTCaloClusterDataStruct*> phosClustersVector;
@@ -222,13 +240,13 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /
        }
      }
    }
-   
 
-   //Get the EMCAL Clusters
+    //Get the EMCAL Clusters
    vector<AliHLTCaloClusterDataStruct*> emcalClustersVector;
    for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL); pBlock!=NULL; pBlock=GetNextInputBlock()) {
      AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
      fClusterReader->SetMemory(caloClusterHeader);
+//           HLTInfo("\n EMCAL: estou aqui");//marcel
      if ( (caloClusterHeader->fNClusters) < 0) {
        HLTWarning("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (caloClusterHeader->fNClusters));
        continue;
@@ -239,19 +257,38 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /
        }
      }
    }
-   
-   iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz);
+
+      iResult = fTrackMatcher->Match(fTrackArray, phosClustersVector, emcalClustersVector, fBz,fMethod); //With Method String
+
 
    //Push the blocks on
    for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) {
      PushBack(pBlock->fPtr, pBlock->fSize, pBlock->fDataType, pBlock->fSpecification);
-   }
-
-   fTrackArray->Clear();
+    }
    
+   fTrackArray->Clear();
+
    return iResult;
 }
 
+int AliHLTGlobalTrackMatcherComponent::ScanConfigurationArgument(int argc, const char** argv) {
+  // see header file for class documentation
+  if (argc<=0) return 0;
+  int i=0;
+  TString argument=argv[i];
+
+  // -maxpt
+  if (argument.CompareTo("-method")==0) {
+    if (++i>=argc) return -EPROTO;
+    argument=argv[i];
+    fMethod=argument.Atof(); // 
+    return 2;
+  }    
+
+// unknown argument
+  return -EINVAL;
+}
+
 // int AliHLTGlobalTrackMatcherComponent::Configure(const char* arguments)
 // {
 //   Int_t iResult = 1;
@@ -263,3 +300,22 @@ int AliHLTGlobalTrackMatcherComponent::DoEvent(const AliHLTComponentEventData& /
 //   Int_t iResult = 1;
 //   return iResult;
 // }
+
+int AliHLTGlobalTrackMatcherComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
+  // configure from the specified antry or the default one
+  const char* entry=cdbEntry;
+  if (!entry || entry[0]==0) entry=fOCDBEntry;
+
+  return ConfigureFromCDBTObjString(entry);
+}
+
+void AliHLTGlobalTrackMatcherComponent::GetOCDBObjectDescription( TMap* const targetMap) {
+  
+  // Get a list of OCDB object description.
+  if (!targetMap) return;
+  targetMap->Add(new TObjString(fOCDBEntry),
+                new TObjString(Form("Track-Matcher Method OCDB object") ) 
+                );
+}
+
+
index 3f81438b4f4d7f7934280ce703e688c747ce5ce0..3a51b0412a714fb5346c9d4fc9a2f07f76191a7a 100644 (file)
@@ -11,7 +11,7 @@
 
 #ifndef ALIHLTGLOBALTRACKMATCHERCOMPONENT_H
 #define ALIHLTGLOBALTRACKMATCHERCOMPONENT_H
-
+#include "AliHLTComponentBenchmark.h"
 
 class AliHLTProcessor;
 class AliHLTGlobalTrackMatcher;
@@ -43,6 +43,9 @@ public:
   /** interface function, see AliHLTComponent for description */
   AliHLTComponent* Spawn();
 
+    ///Inherited from AliHLTComponent: Get list of OCDB objects
+  void GetOCDBObjectDescription( TMap* const targetMap); //Methods
+  
 protected:
 
   // Protected functions to implement AliHLTComponent's interface.
@@ -54,12 +57,27 @@ protected:
   /** interface function, see AliHLTComponent for description */
   int DoDeinit();
   /** interface function, see AliHLTComponent for description */
+  
+  //FOR METHOD extrapolation:
+    /// inherited from AliHLTComponent: handle re-configuration event
+  int Reconfigure(const char* cdbEntry, const char* chainId);
+
+  /// inherited from AliHLTComponent, scan one argument and
+  /// its parameters
+  int ScanConfigurationArgument(int argc, const char** argv);
+  //FOR METHOD
+  
+    /// the default configuration entry for this component
+  const char* fOCDBEntry; // Method for TrackMatcher
+  
   int DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& trigData );
 
   //int Reconfigure(const char* cdbEntry, const char* chainId);
 
   using AliHLTProcessor::DoEvent;
   
+  Int_t fMethod; //TString for method choice for extrapolation
+  
 private:
   /** copy constructor prohibited */
   AliHLTGlobalTrackMatcherComponent(const AliHLTGlobalTrackMatcherComponent&);
@@ -82,7 +100,7 @@ private:
   AliHLTCaloClusterReader * fClusterReader;   //Instance of helper class to read calorimeter structs
 
   TObjArray * fTrackArray;
-  
+
   ClassDef(AliHLTGlobalTrackMatcherComponent, 0);
 
 };