]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TRD/AliHLTTRDTrackerComponent.cxx
clean-up and removal of TPC legacy code
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDTrackerComponent.cxx
index 8991571c9cc1ed918e9bf230e1bcd33254018196..e0023535c3754fc3939d12f3b441af8d75189c2e 100644 (file)
@@ -26,20 +26,20 @@ using namespace std;
 #endif
 
 #include "TFile.h"
+#include "TChain.h"
 
 #include "AliHLTTRDTrackerComponent.h"
 #include "AliHLTTRDDefinitions.h"
 #include "AliCDBManager.h"
 
-#include "AliTRDclusterizerV1HLT.h"
 #include "AliTRDReconstructor.h"
 #include "AliESDEvent.h"
-#include "AliTRDtrackerHLT.h"
+//#include "AliTRDtrackerHLT.h"
+#include "AliTRDtracker.h"
 #include "AliTRDCalibraFillHisto.h"
 #include "AliMagFMaps.h"
 #include "AliTRDcluster.h"
-#include "TObjArray.h"
-
+#include "AliESDfriend.h"
 #include <cstdlib>
 #include <cerrno>
 #include <string>
@@ -50,10 +50,17 @@ AliHLTTRDTrackerComponent gAliHLTTRDTrackerComponent;
 ClassImp(AliHLTTRDTrackerComponent);
     
 AliHLTTRDTrackerComponent::AliHLTTRDTrackerComponent()
+  : AliHLTProcessor()
+  , fOutputPercentage(100) // By default we copy to the output exactly what we got as input  
+  , fStrorageDBpath("local://$ALICE_ROOT")
+  , fCDB(NULL)
+  , fField(NULL)
+  , fGeometryFileName("")
+  , fGeometryFile(NULL)
+  , fGeoManager(NULL)
+  , fTracker(NULL)
 {
-  fOutputPercentage = 100; // By default we copy to the output exactly what we got as input
-
-  fStrorageDBpath = "local://$ALICE_ROOT";
+  // Default constructor
   fCDB = AliCDBManager::Instance();
   //fCDB->SetDefaultStorage(fStrorageDBpath.c_str());
   fCDB->SetRun(0);
@@ -64,26 +71,31 @@ AliHLTTRDTrackerComponent::AliHLTTRDTrackerComponent()
 
 AliHLTTRDTrackerComponent::~AliHLTTRDTrackerComponent()
 {
+  // Destructor
 }
 
 const char* AliHLTTRDTrackerComponent::GetComponentID()
 {
+  // Return the component ID const char *
   return "TRDTracker"; // The ID of this component
 }
 
 void AliHLTTRDTrackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
 {
+  // Get the list of input data  
   list.clear(); // We do not have any requirements for our input data type(s).
   list.push_back( AliHLTTRDDefinitions::fgkClusterDataType );
 }
 
 AliHLTComponent_DataType AliHLTTRDTrackerComponent::GetOutputDataType()
 {
+  // Get the output data type
   return AliHLTTRDDefinitions::fgkClusterDataType;
 }
 
 void AliHLTTRDTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
 {
+  // Get the output data size
   constBase = 0;
   inputMultiplier = ((double)fOutputPercentage)/100.0;
 }
@@ -91,6 +103,7 @@ void AliHLTTRDTrackerComponent::GetOutputDataSize( unsigned long& constBase, dou
 // Spawn function, return new instance of this class
 AliHLTComponent* AliHLTTRDTrackerComponent::Spawn()
 {
+  // Spawn function, return new instance of this class
   return new AliHLTTRDTrackerComponent;
 };
 
@@ -154,8 +167,6 @@ int AliHLTTRDTrackerComponent::DoInit( int argc, const char** argv )
       return EINVAL;
     }
 
-  fClusterizer = new AliTRDclusterizerV1HLT("TRCclusterizer", "TRCclusterizer");
-
   //init alifield map - temporarly fixed - should come from a DB
   fField = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1);
   if (fField)
@@ -167,7 +178,9 @@ int AliHLTTRDTrackerComponent::DoInit( int argc, const char** argv )
   if (fGeometryFile)
     {
       fGeoManager = (TGeoManager *)fGeometryFile->Get("Geometry");
-      fTracker = new AliTRDtrackerHLT(fGeometryFile);
+      //fTracker = new AliTRDtrackerHLT(fGeometryFile);
+      fTracker = new AliTRDtracker(fGeometryFile);
+      //fTracker = new AliTRDtracker(fGeometryFile);
     }
   else
     {
@@ -192,10 +205,10 @@ int AliHLTTRDTrackerComponent::DoInit( int argc, const char** argv )
 
 int AliHLTTRDTrackerComponent::DoDeinit()
 {
-  delete fClusterizer;
-  fClusterizer = 0;
+  // Deinitialization of the component
 
   delete fField;
+  fField = 0;
 
   delete fTracker;
   fTracker = 0;
@@ -204,13 +217,17 @@ int AliHLTTRDTrackerComponent::DoDeinit()
     {
       fGeometryFile->Close();
       delete fGeometryFile;
+      fGeometryFile = 0;
     }
 
   AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
   if (calibra)
     {
+      // should not write in here!
       calibra->Write2d();
+      Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "before destroy");
       calibra->Destroy();
+      Logging( kHLTLogInfo, "HLT::TRDTracker::DoDeinit", "CALIBRA", "after destroy");
     }
 
   return 0;
@@ -219,11 +236,20 @@ int AliHLTTRDTrackerComponent::DoDeinit()
 int AliHLTTRDTrackerComponent::DoEvent( const AliHLTComponentEventData & evtData,
                                        AliHLTComponentTriggerData & trigData )
 {
+  // Process an event
+  
   Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
   Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "BLOCKS", "NofBlocks %lu", evtData.fBlockCnt );
 
   AliHLTUInt32_t fDblock_Specification = 0;
 
+  //implement a usage of the following
+//   AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
+//   AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
+//   void *triggerData = trigData.fData;
+  Logging( kHLTLogDebug, "HLT::TRDTracker::DoEvent", "Trigger data received", 
+          "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
+
   AliHLTComponentBlockData *dblock = (AliHLTComponentBlockData *)GetFirstInputBlock( AliHLTTRDDefinitions::fgkClusterDataType );
   if (dblock != 0)
     {
@@ -236,62 +262,91 @@ int AliHLTTRDTrackerComponent::DoEvent( const AliHLTComponentEventData & evtData
     }
 
   int ibForce = 0;
-  TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TObjArray", ibForce);
+  TObject *tobjin = (TObject *)GetFirstInputObject( AliHLTTRDDefinitions::fgkClusterDataType, "TTree", ibForce);
   Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x", tobjin);
 
-//   int iTotalClusterCounter = 0;
+  TTree *clusterTree = (TTree*)tobjin;
+  if (!clusterTree)
+    {
+      Logging( kHLTLogWarning, "HLT::TRDTracker::DoEvent", "DATAIN", "First Input Block not a tree! 0x%x", tobjin);
+      return -1;
+    }
+
+  Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "1stBLOCK", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
+
   while (tobjin != 0)
     {
-      TObjArray *clusters = (TObjArray *)tobjin;
-      if (clusters != 0)
+      if (clusterTree)
        {
-         //put back to the clusterizers tree
-         Int_t iSuggestedDet = -1; // take the det number from the first cluster
-         Bool_t kInsert = kFALSE;
-         if (clusters->GetEntries() > 0)
-           {
-             AliTRDcluster *cl = (AliTRDcluster*)clusters->At(0);
-             iSuggestedDet = cl->GetDetector();
-             kInsert = fClusterizer->InsertClusters(clusters, iSuggestedDet);      
-             Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "TOTREE", "Result = %d", kInsert);        
-           }
-           
-         Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Pointer = 0x%x", clusters);      
-//       //dump the clusters to the log files
-//       for (Int_t ic = 0; ic < clusters->GetEntries(); ic++)
-//         {
-//           AliTRDcluster *cl = (AliTRDcluster*)clusters->At(ic);
-//           Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "CLUSTER", "%d : %d : Q = %1.2f", 
-//                    iTotalClusterCounter, ic, cl->GetQ());         
-//           iTotalClusterCounter++;
-//         }
-         
-         //Pass the data further...
-         //PushBack(clusters, AliHLTTRDDefinitions::fgkClusterDataType, fDblock_Specification);
+         Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Pointer = 0x%x Name = %s", clusterTree, clusterTree->GetName());
+         Int_t iNentries = clusterTree->GetEntries();
+         Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "COUNT", "N of tree entries = %d", iNentries);
+         fTracker->LoadClusters(clusterTree);
        }
       else
        {
-         Logging( kHLTLogError, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Pointer = 0x%x", clusters);     
+         Logging( kHLTLogError, "HLT::TRDTracker::DoEvent", "CLUSTERS", "Tree Pointer = 0x%x", clusterTree);
        }
 
       tobjin = (TObject *)GetNextInputObject( ibForce );
       Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "nextBLOCK", "Pointer = 0x%x", tobjin);
-
+      clusterTree = (TTree*)tobjin;
     }
 
-  Int_t iNclusters = fClusterizer->GetNclusters();
-  Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "COUNT", "N of Clusters = %d", iNclusters);
-  fTracker->LoadClusters(fClusterizer->GetClusterTree());
-
   AliTRDReconstructor::SetSeedingOn(kTRUE);
 
+  fTracker->SetAddTRDseeds();
+
+  AliESDfriend *esdFriend = new AliESDfriend();
+
   AliESDEvent *esd = new AliESDEvent();
   esd->CreateStdContent();
-  //fTracker->MakeSeedsMI(3, 5, esd);
   fTracker->PropagateBack(esd);
+  fTracker->RefitInward(esd);
+  fTracker->Clusters2Tracks(esd);
 
+  esd->GetESDfriend(esdFriend);
   //here transport the esd tracks further
+
+  Int_t nTracks = esd->GetNumberOfTracks();
+  Int_t nTRDTracks = esd->GetNumberOfTrdTracks();
+  Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Number of tracks %d Number of TRD tracks %d", nTracks, nTRDTracks);
+
+//   AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
+//   calibra->Init2Dhistostrack();
+
+  for (Int_t it = 0; it < nTracks; it++)
+    {
+      AliESDtrack* track = esd->GetTrack(it);
+
+//       Int_t nCalibObjects = 0;
+//       Int_t idx = 0;
+//       while (track->GetCalibObject(idx) != 0)
+//     {
+//       nCalibObjects++;
+//       idx++;
+//     }
+//       Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Track 0x%x NcalibObjects %d", track, nCalibObjects);
+
+      Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "Track %d 0x%x Pt %1.2f", it, track, track->Pt());
+      PushBack(track, AliHLTTRDDefinitions::fgkTRDSATracksDataType, ++fDblock_Specification);
+//       if (calibra->GetMItracking())
+//     {
+//       calibra->UpdateHistograms(track);
+//     }
+    }
+
+  //PushBack(esd, AliHLTTRDDefinitions::fgkTRDSAEsdDataType, fDblock_Specification);
+  //PushBack(esdFriend, AliHLTTRDDefinitions::fgkTRDSAEsdDataType, fDblock_Specification);
+
   //no receiver defined yet(!)
+  //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "now deleting");
   delete esd;
+  delete esdFriend;
+
+  //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete esd");
+  delete clusterTree;
+
+  //Logging( kHLTLogInfo, "HLT::TRDTracker::DoEvent", "DONE", "after delete clusterTree");
   return 0;
 }