]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TRD/AliHLTTRDTrackerV1Component.cxx
HLTqadm
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDTrackerV1Component.cxx
index ab333c3084dde47e4e5aa97306449cf007f4fc92..b1d3c5c6920d231e8839cedd87ab46b523c14bdb 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: AliHLTTRDTrackerV1Component.cxx 23618 2008-01-29 13:07:38Z hristov $
+// $Id$
 
 //**************************************************************************
 //* This file is property of and copyright by the ALICE HLT Project        * 
 //**************************************************************************
 
 /** @file   AliHLTTRDTrackerV1Component.cxx
-    @author 
+    @author Theodor Rascanu
     @date   
     @brief  A TRDTrackerV1 processing component for the HLT.
 */
 
-#if __GNUC__ >= 3
-using namespace std;
-#endif
-
 #include "AliHLTTRDTrackerV1Component.h"
 #include "AliHLTTRDDefinitions.h"
-#include "AliHLTTRDCluster.h"
 #include "AliHLTTRDTrack.h"
 #include "AliHLTTRDUtils.h"
+#include "AliHLTTRDCluster.h"
 
 #include "TFile.h"
 #include "TChain.h"
@@ -51,15 +47,23 @@ 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
+using namespace std;
 
 ClassImp(AliHLTTRDTrackerV1Component)
-    
+
+void AliHLTTRDTrackerV1Component::AliHLTTRDESDEvent::CreateStdContent()
+{
+  TClonesArray* tracksArray = new TClonesArray("AliESDtrack",0);
+  tracksArray->SetName(AliESDEvent::fgkESDListName[AliESDEvent::kTracks]);
+  AddObject(tracksArray);
+  GetStdContent();
+}
+
+void AliHLTTRDTrackerV1Component::AliHLTTRDESDEvent::Streamer(TBuffer &/*R__b*/)
+{
+  AliFatal("class is for internal us only and not for streaming");
+}
+
 AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component():
   AliHLTProcessor(),
   fOutputPercentage(100), // By default we copy to the output exactly what we got as input 
@@ -70,12 +74,13 @@ AliHLTTRDTrackerV1Component::AliHLTTRDTrackerV1Component():
   fClusterArray(NULL),
   fRecoParamType(-1),
   fNtimeBins(-1),
-  fMagneticField(-1),
   fPIDmethod(1),
   fgeometryFileName(""),
-  fieldStrength(-101),
-  fSlowTracking(kFALSE),
-  fOutputV1Tracks(kTRUE)
+  fHLTflag(kTRUE),
+  fOutputV1Tracks(kTRUE),
+  fHighLevelOutput(kFALSE),
+  fEmulateHLTTracks(kFALSE),
+  fImproveTracklets(kFALSE)
 {
   // Default constructor
 
@@ -109,9 +114,8 @@ 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::fgkTRDSATracksDataType);
+  tgtList.push_back(AliHLTTRDDefinitions::fgkTracksDataType);
   return tgtList.size();
 }
 
@@ -120,6 +124,7 @@ void AliHLTTRDTrackerV1Component::GetOutputDataSize( unsigned long& constBase, d
   // Get the output data size
   constBase = 0;
   inputMultiplier = fOutputV1Tracks ? 2*((double)fOutputPercentage)/100.0 : 0.5*((double)fOutputPercentage)/100.0;
+  if(sizeof(AliHLTTRDClustersArray::cluster_type) == sizeof(AliHLTTRDCluster)) inputMultiplier *= 28.0/8;
 }
 
 // Spawn function, return new instance of this class
@@ -136,10 +141,9 @@ int AliHLTTRDTrackerV1Component::DoInit( int argc, const char** argv )
 
   fReconstructor = new AliTRDReconstructor();
   HLTDebug("TRDReconstructor at 0x%x", fReconstructor);
-
-  fESD = new AliESDEvent;
+  fESD = new AliHLTTRDESDEvent();
   fESD->CreateStdContent();
-  
+
   TString configuration="";
   TString argument="";
   for (int i=0; i<argc && iResult>=0; i++) {
@@ -179,7 +183,7 @@ int AliHLTTRDTrackerV1Component::DoDeinit()
   
   // We need to set clusters in Reconstructor to null to prevent from 
   // double deleting, since we delete TClonesArray by ourself.
-  fReconstructor->SetClusters(0x0);
+  //fReconstructor->SetClusters(0x0);
   delete fReconstructor;
   fReconstructor = NULL;
   delete fESD;
@@ -199,29 +203,17 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
 {
   // Process an event
 
-  if (evtData.fEventID == 1)
-    CALLGRIND_START_INSTRUMENTATION;
-
   HLTDebug("NofBlocks %i", evtData.fBlockCnt );
   
-  fESD->Reset();
-  //fESD->SetMagneticField(GetBz());
-
   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,
@@ -242,9 +234,12 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
       double inputMultiplier;
       GetOutputDataSize(constBase,inputMultiplier);
       if(size<(constBase+block.fSize*inputMultiplier)){
-       HLTWarning("Memory Block given might be too small: %i < %i; Event %Lu", size, constBase+block.fSize*inputMultiplier, evtData.fEventID);
+       HLTWarning("Memory Block given might be too small: %i < %f; Event %Lu", size, constBase+block.fSize*inputMultiplier, evtData.fEventID);
       }
-#endif      
+#endif
+
+      fESD->Reset();
+      //fESD->SetMagneticField(GetBz());
 
       AliHLTTRDUtils::ReadClusters(fClusterArray, block.fPtr, block.fSize, &fNtimeBins);
       HLTDebug("Reading number of time bins from input block. Setting number of timebins to %d", fNtimeBins);
@@ -261,7 +256,35 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
       TClonesArray* trdTracks;
       trdTracks = fTracker->GetListOfTracks();
       
-      if(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;
+       if(trdTracks)
+         PushBack(trdTracks, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, block.fSpecification);
+       else{
+         TClonesArray temp("AliTRDtrackV1");
+         PushBack(&temp, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, block.fSpecification);
+       }
+       PushBack(&strg, AliHLTTRDDefinitions::fgkHiLvlTracksDataType, block.fSpecification);
+
+       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;
@@ -290,13 +313,13 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
          bd.fOffset = offset;
          bd.fSize = addedSize;
          bd.fSpecification = block.fSpecification;
-         bd.fDataType = AliHLTTRDDefinitions::fgkTRDSATracksDataType;
+         bd.fDataType = AliHLTTRDDefinitions::fgkTracksDataType;
          outputBlocks.push_back( bd );
          HLTDebug("BD ptr 0x%x, offset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), bd.fSpecification);
          offset = totalSize;
        }
       }
-      
+
       HLTDebug("totalSize: %i", totalSize);
       
 //       if ( totalSize > allocSize )
@@ -308,7 +331,7 @@ int AliHLTTRDTrackerV1Component::DoEvent( const AliHLTComponentEventData& evtDat
 
       //here we are deleting clusters (but not the TClonesArray itself)
       fTracker->UnloadClusters();
-      AliTRDReconstructor::SetClusters(0x0);
+      //AliTRDReconstructor::SetClusters(0x0);
       fClusterArray->Delete();
       
     }
@@ -343,11 +366,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());
@@ -369,19 +387,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) {
@@ -401,7 +422,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("-emulateHLToutput")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
+       if (toCompareTo.CompareTo("yes")==0){
+         HLTWarning("Setting emulateHLToutput to: %s", toCompareTo.Data());
+         fEmulateHLTTracks=kTRUE;
+       }
+       else if (toCompareTo.CompareTo("no")==0){
+         HLTInfo("Setting emulateHLToutput to: %s", toCompareTo.Data());
+         fEmulateHLTTracks=kFALSE;
+       }
+       else {
+         HLTError("unknown argument for emulateHLToutput: %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();
@@ -475,49 +532,60 @@ int AliHLTTRDTrackerV1Component::SetParams()
     HLTInfo("Geometry Already Loaded!");
   }
   
-  if (fRecoParamType == 0)
-    {
-      HLTDebug("Low flux params init.");
-      fRecoParam = AliTRDrecoParam::GetLowFluxParam();
+  if(fReconstructor->GetRecoParam()){
+    fRecoParam = new AliTRDrecoParam(*fReconstructor->GetRecoParam());
+    HLTInfo("RecoParam already set!");
+  }else{
+    if(fRecoParamType == 0){
+#ifndef HAVE_NOT_ALITRD_RECOPARAM_r41621
+      if(fHLTflag){
+       HLTInfo("Low flux HLT params init.");
+       fRecoParam = AliTRDrecoParam::GetLowFluxHLTParam();
+      }else
+#endif
+       {
+         HLTInfo("Low flux params init.");
+         fRecoParam = AliTRDrecoParam::GetLowFluxParam();
+       }
     }
-
-  if (fRecoParamType == 1)
-    {
-      HLTDebug("High flux params init.");
-      fRecoParam = AliTRDrecoParam::GetHighFluxParam();
+    if(fRecoParamType == 1){
+#ifndef HAVE_NOT_ALITRD_RECOPARAM_r41621
+      if(fHLTflag){
+       HLTInfo("High flux HLT params init.");
+       fRecoParam = AliTRDrecoParam::GetHighFluxHLTParam();
+      }else
+#endif
+       {
+         HLTInfo("High flux params init.");
+         fRecoParam = AliTRDrecoParam::GetHighFluxParam();
+       }
     }
-  
-  if (fRecoParamType == 2)
-    {
-      HLTDebug("Cosmic Test params init.");
+    if(fRecoParamType == 2){
+      HLTInfo("Cosmic Test params init.");
       fRecoParam = AliTRDrecoParam::GetCosmicTestParam();
     }
+  }
 
-  if (fRecoParam == 0)
+  if(!fRecoParam)
     {
       HLTError("No reco params initialized. Sniffing big trouble!");
       return -EINVAL;
     }
 
-  // backward compatibility to AliTRDrecoParam < r34995
-# ifndef HAVE_NOT_ALITRDRECOPARAM_r34995
-#   define AliTRDRecoParamSetPIDNeuralNetwork(b) fRecoParam->SetPIDNeuralNetwork(b)
-# else
-#   define AliTRDRecoParamSetPIDNeuralNetwork(b) fRecoParam->SetPIDNeuralNetwork()
-# endif
-
   switch(fPIDmethod){
-  case 0: AliTRDRecoParamSetPIDNeuralNetwork(kFALSE); break;
-  case 1: AliTRDRecoParamSetPIDNeuralNetwork(kTRUE); break;
-  case 2: AliTRDRecoParamSetPIDNeuralNetwork(kFALSE); break;
+  case 0: fRecoParam->SetPIDNeuralNetwork(kFALSE); break;
+  case 1: fRecoParam->SetPIDNeuralNetwork(kTRUE); break;
+  case 2: fRecoParam->SetPIDNeuralNetwork(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());
@@ -568,3 +636,23 @@ int AliHLTTRDTrackerV1Component::ReadPreprocessorValues(const char* modules)
   }  
   return iResult;
 }
+
+void AliHLTTRDTrackerV1Component::GetOCDBObjectDescription(TMap* const targetMap){
+  // Get a list of OCDB object description needed for the particular component
+  if (!targetMap) return;
+  targetMap->Add(new TObjString("HLT/ConfigTRD/TrackerV1Component"), new TObjString("component arguments"));
+  targetMap->Add(new TObjString("TRD/Calib/ChamberGainFactor"), new TObjString("gain factor of chambers"));
+  targetMap->Add(new TObjString("TRD/Calib/ChamberT0"), new TObjString("T0 of chambers"));
+  targetMap->Add(new TObjString("TRD/Calib/ChamberVdrift"), new TObjString("drift velocity of chambers"));
+  targetMap->Add(new TObjString("TRD/Calib/DetNoise"), new TObjString("noise of chambers"));
+  targetMap->Add(new TObjString("TRD/Calib/LocalGainFactor"), new TObjString("per pad gain factor"));
+  targetMap->Add(new TObjString("TRD/Calib/LocalT0"), new TObjString("per pad T0"));
+  targetMap->Add(new TObjString("TRD/Calib/LocalVdrift"), new TObjString("per pad drift velocity"));
+  targetMap->Add(new TObjString("TRD/Calib/PadNoise"), new TObjString("per pad noise"));
+  targetMap->Add(new TObjString("TRD/Calib/PadStatus"), new TObjString("pad status"));
+  targetMap->Add(new TObjString("TRD/Calib/PRFWidth"), new TObjString("pad response function"));
+  targetMap->Add(new TObjString("TRD/Calib/ChamberStatus"), new TObjString("status of chambers"));
+  targetMap->Add(new TObjString("TRD/Calib/PIDLQ"), new TObjString("likelyhood PID"));
+  targetMap->Add(new TObjString("TRD/Calib/PIDNN"), new TObjString("neuronal network PID"));
+  targetMap->Add(new TObjString("TRD/Calib/PIDThresholds"), new TObjString("threshold for PID"));
+}