code cleanup of the HLT TRD tracker, integration of the offline mode
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Dec 2009 13:37:00 +0000 (13:37 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Dec 2009 13:37:00 +0000 (13:37 +0000)
fixing bug in calibration: dQdl was wrong for tracks crossing 2 pad
rows. Solved by saving the original position of each cluster in the
tracklet's array. (Theodor)

HLT/TRD/AliHLTTRDOfflineTrackerV1Component.cxx
HLT/TRD/AliHLTTRDOfflineTrackerV1Component.h
HLT/TRD/AliHLTTRDTrackerV1Component.cxx
HLT/TRD/AliHLTTRDTrackerV1Component.h

index d850856151ae1f643d252bcb6437a6b6246e504a..0a14d9761d4bbb5d6816da4c7ccec57b939fcbe4 100644 (file)
 */
 
 #include "AliHLTTRDOfflineTrackerV1Component.h"
-#include "AliCDBManager.h"
-#include "AliTRDrecoParam.h"
 #include "AliHLTTRDDefinitions.h"
+#include "AliHLTTRDUtils.h"
+#include "AliTRDrecoParam.h"
+#include "AliTRDtrackerV1.h"
+#include "AliTRDReconstructor.h"
+#include "AliCDBManager.h"
+#include "AliESDEvent.h"
+#include "TClonesArray.h"
+#include "TObjString.h"
+
+#include "AliTRDtrackV1.h"
+#include "AliTRDseedV1.h"
+#include "AliTRDcluster.h"
 
 ClassImp(AliHLTTRDOfflineTrackerV1Component)
     
@@ -33,7 +43,6 @@ AliHLTTRDOfflineTrackerV1Component::AliHLTTRDOfflineTrackerV1Component()
   :AliHLTTRDTrackerV1Component()
 {
   // Default constructor
-  fOffline=kTRUE;
 }
 
 AliHLTTRDOfflineTrackerV1Component::~AliHLTTRDOfflineTrackerV1Component()
@@ -42,6 +51,20 @@ AliHLTTRDOfflineTrackerV1Component::~AliHLTTRDOfflineTrackerV1Component()
   // Work is Done in DoDeInit()
 }
 
+void AliHLTTRDOfflineTrackerV1Component::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+{
+  // Get the list of input data
+  list.clear();
+  AliHLTTRDTrackerV1Component::GetInputDataTypes(list);
+  list.push_back(AliHLTTRDDefinitions::fgkHiLvlClusterDataType);
+}
+
+AliHLTComponentDataType AliHLTTRDOfflineTrackerV1Component::GetOutputDataType()
+{
+  // Get the output data type
+  return kAliHLTMultipleDataType;
+}
+
 int AliHLTTRDOfflineTrackerV1Component::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
 {
   // Get the output data types
@@ -53,8 +76,8 @@ int AliHLTTRDOfflineTrackerV1Component::GetOutputDataTypes(AliHLTComponentDataTy
 void AliHLTTRDOfflineTrackerV1Component::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
 {
   // Get the output data size
-  constBase = 1000000;
-  inputMultiplier = 4*((double)fOutputPercentage);
+  AliHLTTRDTrackerV1Component::GetOutputDataSize(constBase, inputMultiplier);
+  constBase += 500;
 }
 
 AliHLTComponent* AliHLTTRDOfflineTrackerV1Component::Spawn()
@@ -66,9 +89,8 @@ AliHLTComponent* AliHLTTRDOfflineTrackerV1Component::Spawn()
 int AliHLTTRDOfflineTrackerV1Component::DoInit( int argc, const char** argv )
 {
   int iResult = 0;
-  SetOfflineParams();
   iResult=AliHLTTRDTrackerV1Component::DoInit(argc, argv);
-  fRecoParam->SetStreamLevel(AliTRDrecoParam::kTracker, 1); //in order to have the friends written
+  fRecoParam->SetStreamLevel(AliTRDrecoParam::kTracker, 1); // in order to have the friends written
   return iResult;
 }
 
@@ -78,29 +100,47 @@ const char* AliHLTTRDOfflineTrackerV1Component::GetComponentID()
   return "TRDOfflineTrackerV1"; // The ID of this component
 }
 
-void AliHLTTRDOfflineTrackerV1Component::SetOfflineParams(){
-  if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
-    HLTFatal("You are resetting the Default Storage of the CDBManager!");
-    HLTFatal("Let's hope that this program is NOT running on the HLT cluster!");
-    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  }
-  if(AliCDBManager::Instance()->GetRun()<0){
-    HLTFatal("You are resetting the CDB run number to 0!");
-    HLTFatal("Let's hope that this program is NOT running on the HLT cluster!");
-    AliCDBManager::Instance()->SetRun(0);
-  }
-}
-
-int AliHLTTRDOfflineTrackerV1Component::DoDeinit()
-{
-  return AliHLTTRDTrackerV1Component::DoDeinit();
-}
-
 int AliHLTTRDOfflineTrackerV1Component::DoEvent(const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
                                                  AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
                                                  AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
 {
   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
     return 0;
-  return AliHLTTRDTrackerV1Component::DoEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks );
+  
+  if(!GetFirstInputBlock(AliHLTTRDDefinitions::fgkHiLvlClusterDataType))
+    return AliHLTTRDTrackerV1Component::DoEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks );
+
+  for(const TObject *iter = GetFirstInputObject(AliHLTTRDDefinitions::fgkHiLvlClusterDataType); iter; iter = GetNextInputObject()) 
+    {
+      TClonesArray* clusterArray = dynamic_cast<TClonesArray*>(const_cast<TObject*>(iter));
+      if(!clusterArray)continue;
+      TObjString* strg = dynamic_cast<TObjString*>(const_cast<TObject*>(GetNextInputObject()));
+      if(!strg)continue;
+      
+      fNtimeBins = strg->String().Atoi();
+      fESD->Reset();
+      AliTRDtrackerV1::SetNTimeBins(fNtimeBins);
+      HLTDebug("TClonesArray of clusters: nbEntries = %i", clusterArray->GetEntriesFast());
+      fTracker->LoadClusters(clusterArray);
+      fTracker->Clusters2Tracks(fESD);
+      Int_t nTracks = fESD->GetNumberOfTracks();
+      HLTInfo("Number of tracks  == %d ==", nTracks);  
+      TClonesArray* trdTracks = fTracker->GetListOfTracks();
+
+      if(fEmulateHLTTracks && trdTracks){
+       trdTracks = new TClonesArray(*trdTracks);
+       AliHLTTRDUtils::EmulateHLTTracks(trdTracks);
+      }
+
+      PushBack(trdTracks, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0);
+      PushBack(strg, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0);
+      fTracker->UnloadClusters();
+      AliTRDReconstructor::SetClusters(0x0);
+
+      if(fEmulateHLTTracks && trdTracks){
+       trdTracks->Delete();
+       delete trdTracks;
+      }
+    }
+  return 0;
 }
index 848ef69351fbfcf934c61a5e513558c15913fe0d..bbd145737625c25bea869fd6ed1fcc0d5b285611 100644 (file)
@@ -21,18 +21,18 @@ public:
   virtual ~AliHLTTRDOfflineTrackerV1Component();
 
   const char* GetComponentID();
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+  AliHLTComponentDataType GetOutputDataType();
   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
   virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
   AliHLTComponent* Spawn();
 
   int DoInit( int argc, const char** argv );
-  int DoDeinit();
   int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
               AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
               AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
 
 protected:
-  void SetOfflineParams();
 
   ClassDef(AliHLTTRDOfflineTrackerV1Component, 1)
 
index 444e17b85c43df7c6f16a15389cf1be808053249..8d82d461250217316fa414c3808d1360b6f574ad 100644 (file)
@@ -28,7 +28,6 @@ using namespace std;
 
 #include "AliHLTTRDTrackerV1Component.h"
 #include "AliHLTTRDDefinitions.h"
-#include "AliHLTTRDCluster.h"
 #include "AliHLTTRDTrack.h"
 #include "AliHLTTRDUtils.h"
 
@@ -51,13 +50,6 @@ using namespace std;
 #include <cerrno>
 #include <string>
 
-#ifdef HAVE_VALGRIND_CALLGRIND_H
-#include <valgrind/callgrind.h>
-#else
-#define CALLGRIND_START_INSTRUMENTATION do { } while (0)
-#define CALLGRIND_STOP_INSTRUMENTATION do { } while (0)
-#endif
-
 ClassImp(AliHLTTRDTrackerV1Component)
     
 AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component():
@@ -70,13 +62,13 @@ AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component():
   fClusterArray(NULL),
   fRecoParamType(-1),
   fNtimeBins(-1),
-  fMagneticField(-1),
   fPIDmethod(1),
   fgeometryFileName(""),
-  fieldStrength(-101),
-  fSlowTracking(kFALSE),
+  fHLTflag(kTRUE),
   fOutputV1Tracks(kTRUE),
-  fOffline(kFALSE)
+  fHighLevelOutput(kFALSE),
+  fEmulateHLTTracks(kFALSE),
+  fImproveTracklets(kTRUE)
 {
   // Default constructor
 
@@ -110,7 +102,6 @@ int AliHLTTRDTrackerV1Component::GetOutputDataTypes(AliHLTComponentDataTypeList&
 {
   // Get the output data types
   tgtList.clear();
-  //tgtList.push_back(AliHLTTRDDefinitions::fgkTimeBinPropagationDataType);
   tgtList.push_back(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD);
   tgtList.push_back(AliHLTTRDDefinitions::fgkTracksDataType);
   return tgtList.size();
@@ -200,9 +191,6 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
 {
   // Process an event
 
-  if (evtData.fEventID == 1)
-    CALLGRIND_START_INSTRUMENTATION;
-
   HLTDebug("NofBlocks %i", evtData.fBlockCnt );
   
   fESD->Reset();
@@ -210,19 +198,13 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
 
   AliHLTUInt32_t totalSize = 0, offset = 0;
 
-  vector<AliHLTComponent_DataType> expectedDataTypes;
-  GetInputDataTypes(expectedDataTypes);
+  AliHLTComponentDataType expectedDataType = AliHLTTRDDefinitions::fgkClusterDataType;
   for ( unsigned long iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ ) 
     {
       const AliHLTComponentBlockData &block = blocks[iBlock];
       AliHLTComponentDataType inputDataType = block.fDataType;
-      Bool_t correctDataType = kFALSE;
 
-      for(UInt_t i = 0; i < expectedDataTypes.size(); i++){
-       if( expectedDataTypes.at(i) == inputDataType)
-         correctDataType = kTRUE;
-      }
-      if (!correctDataType)
+      if(inputDataType != expectedDataType)
        {
          HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - Skipping",
                    iBlock, evtData.fBlockCnt-1,
@@ -262,7 +244,30 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
       TClonesArray* trdTracks;
       trdTracks = fTracker->GetListOfTracks();
       
-      if(!fOffline && nTracks>0){
+      if(fHighLevelOutput){
+       if(fEmulateHLTTracks && trdTracks){
+         // TClonesArray* oldArr = trdTracks;
+         trdTracks = new TClonesArray(*trdTracks);
+         AliHLTTRDUtils::EmulateHLTTracks(trdTracks);
+         // if(oldArr->At(0)){
+         //   HLTInfo("Old Track:");
+         //   ((AliTRDtrackV1*)oldArr->At(0))->Print("a");
+         //   HLTInfo("\nNew Track:");
+         //   ((AliTRDtrackV1*)trdTracks->At(0))->Print("a");
+         // }
+       }
+
+       TObjString strg;
+       strg.String() += fNtimeBins;
+       PushBack(trdTracks, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0);
+       PushBack(&strg, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0);
+
+       if(fEmulateHLTTracks && trdTracks){
+         trdTracks->Delete();
+         delete trdTracks;
+       }
+      }
+      else if(nTracks>0){
        HLTDebug("We have an output ESDEvent: 0x%x with %i tracks", fESD, nTracks);
        AliHLTUInt32_t addedSize = AliHLTTRDUtils::AddESDToOutput(fESD, outputPtr+offset);
        totalSize += addedSize;
@@ -297,12 +302,6 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
          offset = totalSize;
        }
       }
-      if(fOffline){
-       if(trdTracks)
-         PushBack(trdTracks, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0); 
-       else
-         PushBack(new TObject, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, 0);
-      }
 
       HLTDebug("totalSize: %i", totalSize);
       
@@ -350,11 +349,6 @@ int AliHLTTRDTrackerV1Component::Configure(const char* arguments){
        HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
        continue;
       } 
-      else if (argument.CompareTo("-NTimeBins")==0) {
-       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
-       HLTInfo("Option depreceated");
-       continue;
-      } 
       else if (argument.CompareTo("-geometry")==0) {
        if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
        HLTInfo("Setting geometry to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
@@ -376,19 +370,22 @@ int AliHLTTRDTrackerV1Component::Configure(const char* arguments){
        HLTInfo("Cosmics reconstruction selected");
        continue;
       }
-      else if (argument.CompareTo("-magnetic_field_ON")==0) {
-       fMagneticField = 1;
-       HLTInfo("Reconstructon with magnetic field");
-       continue;
-      }
-      else if (argument.CompareTo("-magnetic_field_OFF")==0) {
-       fMagneticField = 0;
-       HLTInfo("Reconstructon without magnetic field");
-       continue;
-      }
-      else if (argument.CompareTo("-slowTracking")==0) {
-       fSlowTracking = kTRUE;
-       HLTInfo("Using slow tracking");
+      else if (argument.CompareTo("-HLTflag")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
+       if (toCompareTo.CompareTo("yes")==0){
+         HLTInfo("Setting HLTflag to: %s", toCompareTo.Data());
+         fHLTflag=kTRUE;
+       }
+       else if (toCompareTo.CompareTo("no")==0){
+         HLTInfo("Setting HLTflag to: %s", toCompareTo.Data());
+         fHLTflag=kFALSE;
+       }
+       else {
+         HLTError("unknown argument for HLTflag: %s", toCompareTo.Data());
+         iResult=-EINVAL;
+         break;
+       }
        continue;
       }
       else if (argument.CompareTo("-outputV1Tracks")==0) {
@@ -408,7 +405,43 @@ int AliHLTTRDTrackerV1Component::Configure(const char* arguments){
          break;
        }
        continue;
-      } 
+      }
+      else if (argument.CompareTo("-highLevelOutput")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
+       if (toCompareTo.CompareTo("yes")==0){
+         HLTWarning("Setting highLevelOutput to: %s", toCompareTo.Data());
+         fHighLevelOutput=kTRUE;
+       }
+       else if (toCompareTo.CompareTo("no")==0){
+         HLTInfo("Setting highLevelOutput to: %s", toCompareTo.Data());
+         fHighLevelOutput=kFALSE;
+       }
+       else {
+         HLTError("unknown argument for highLevelOutput: %s", toCompareTo.Data());
+         iResult=-EINVAL;
+         break;
+       }
+       continue;
+      }
+      else if (argument.CompareTo("-emulateHLTTracks")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
+       if (toCompareTo.CompareTo("yes")==0){
+         HLTWarning("Setting emulateHLTTracks to: %s", toCompareTo.Data());
+         fEmulateHLTTracks=kTRUE;
+       }
+       else if (toCompareTo.CompareTo("no")==0){
+         HLTInfo("Setting emulateHLTTracks to: %s", toCompareTo.Data());
+         fEmulateHLTTracks=kFALSE;
+       }
+       else {
+         HLTError("unknown argument for emulateHLTTracks: %s", toCompareTo.Data());
+         iResult=-EINVAL;
+         break;
+       }
+       continue;
+      }
       else if (argument.CompareTo("-PIDmethod")==0) {
        if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
        TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
@@ -482,25 +515,25 @@ int AliHLTTRDTrackerV1Component::SetParams()
     HLTInfo("Geometry Already Loaded!");
   }
   
-  if (fRecoParamType == 0)
-    {
+  if(fReconstructor->GetRecoParam()){
+    fRecoParam = new AliTRDrecoParam(*fReconstructor->GetRecoParam());
+    HLTInfo("RecoParam already set!");
+  }else{
+    if(fRecoParamType == 0){
       HLTDebug("Low flux params init.");
       fRecoParam = AliTRDrecoParam::GetLowFluxParam();
     }
-
-  if (fRecoParamType == 1)
-    {
+    if(fRecoParamType == 1){
       HLTDebug("High flux params init.");
       fRecoParam = AliTRDrecoParam::GetHighFluxParam();
     }
-  
-  if (fRecoParamType == 2)
-    {
+    if(fRecoParamType == 2){
       HLTDebug("Cosmic Test params init.");
       fRecoParam = AliTRDrecoParam::GetCosmicTestParam();
     }
+  }
 
-  if (fRecoParam == 0)
+  if(!fRecoParam)
     {
       HLTError("No reco params initialized. Sniffing big trouble!");
       return -EINVAL;
@@ -519,12 +552,14 @@ int AliHLTTRDTrackerV1Component::SetParams()
   case 2: AliTRDRecoParamSetPIDNeuralNetwork(kFALSE); break;
   }
 
+  fRecoParam->SetImproveTracklets(fImproveTracklets);
+
   fRecoParam->SetStreamLevel(AliTRDrecoParam::kTracker, 0);
   fReconstructor->SetRecoParam(fRecoParam);
 
   TString recoOptions="sa,!cw";
   
-  if(!fSlowTracking)
+  if(fHLTflag)
     recoOptions += ",hlt";
 
   HLTDebug("Reconstructor options are: %s",recoOptions.Data());
index cdbeb4982cc2a198289290ff28fd1af08863cb60..91e49b0f9402764e8bb44670b3f16fe4fcf6392e 100644 (file)
@@ -86,13 +86,13 @@ protected:
 
   Int_t fRecoParamType;       // default will be the low flux
   Int_t fNtimeBins;           // number of time bins for the tracker to use
-  Int_t fMagneticField;       // magnetic field: 0==OFF and 1==ON
   Int_t fPIDmethod;           // 0=LikelyHood(LH) 1=NeuronalNetwork(NN) 2=TruncatedMean(TM)
   TString fgeometryFileName;
-  Double_t fieldStrength;
-  Bool_t fSlowTracking;
-  Bool_t fOutputV1Tracks;
-  Bool_t fOffline;            // mode to compare HLT data with offline
+  Bool_t fHLTflag;            // use HLT flag in reconstructor
+  Bool_t fOutputV1Tracks;     // output TRD tracks, needed for calibration and ESDfriends
+  Bool_t fHighLevelOutput;    // do we what to have high level output (only for debuging)
+  Bool_t fEmulateHLTTracks;   // for debugging data containers
+  Bool_t fImproveTracklets;   // improve tracklets?
 
   ClassDef(AliHLTTRDTrackerV1Component, 4)