]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TRD/AliHLTTRDClusterizerComponent.cxx
correcting compilation warnings (Theodor)
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDClusterizerComponent.cxx
index 293c33c487ca4a20de58773909f5f6c40868a228..da56abbe6666ef7502486a602bef2ef5435e01f2 100644 (file)
@@ -1,25 +1,26 @@
 // $Id$
 
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
- *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
- *          for The ALICE Off-line Project.                               *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors:                                                       *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
 
 /** @file   AliHLTTRDClusterizerComponent.cxx
-    @author Timm Steinbeck, Matthias Richter
+    @author 
     @date   
-    @brief  A TRDClusterizer processing component for the HLT. */
+    @brief  A TRDClusterizer processing component for the HLT. 
+*/
 
 // see header file for class documentation                                   //
 // or                                                                        //
@@ -62,10 +63,13 @@ using namespace std;
 #include <cerrno>
 #include <string>
 
+#include "AliTRDrawStream.h"
+#include "AliTRDrawFastStream.h"
+
 ClassImp(AliHLTTRDClusterizerComponent)
    
-AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent():
-  AliHLTProcessor(),
+AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent()
+: AliHLTProcessor(),
   fOutputPercentage(500),
   fOutputConst(0),
   fClusterizer(NULL),
@@ -78,8 +82,7 @@ AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent():
   fyPosMethod(1),
   fgeometryFileName(""),
   fProcessTracklets(kFALSE),
-  fOfflineMode(kFALSE),
-  fHLTstreamer(kFALSE)
+  fHLTstreamer(kTRUE)
 {
   // Default constructor
 
@@ -102,10 +105,10 @@ void AliHLTTRDClusterizerComponent::GetInputDataTypes( vector<AliHLTComponent_Da
 {
   // Get the list of input data
   list.clear(); // We do not have any requirements for our input data type(s).
-  list.push_back( (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD) );
+  list.push_back(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD);
 }
 
-AliHLTComponent_DataType AliHLTTRDClusterizerComponent::GetOutputDataType()
+AliHLTComponentDataType AliHLTTRDClusterizerComponent::GetOutputDataType()
 {
   // Get the output data type
   return kAliHLTMultipleDataType;
@@ -161,13 +164,19 @@ int AliHLTTRDClusterizerComponent::DoInit( int argc, const char** argv )
     return -1;
   }
 
+  if(iResult<0) return iResult;
+
   fMemReader = new AliRawReaderMemory;
   fClusterizer->SetReconstructor(fReconstructor);
   fClusterizer->SetUseLabels(kFALSE);
 
   if(fReconstructor->IsProcessingTracklets())
     fOutputConst = fClusterizer->GetTrMemBlockSize();
-  return 0;
+
+  AliTRDrawStream::SetSubtractBaseline(10);
+  AliTRDrawFastStream::SetSubtractBaseline(10);
+
+  return iResult;
 }
 
 int AliHLTTRDClusterizerComponent::DoDeinit()
@@ -240,7 +249,16 @@ int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtD
                   block.fSize);
        }
       
-      //      fMemReader->Reset();
+#ifndef NDEBUG
+      unsigned long constBase;
+      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);
+      }
+#endif
+
+      // fMemReader->Reset();
       fMemReader->SetMemory((UChar_t*) block.fPtr, block.fSize);
 
       AliHLTUInt32_t spec = block.fSpecification;
@@ -258,10 +276,10 @@ int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtD
       fMemReader->SetEquipmentID( id ); 
       
       fClusterizer->SetMemBlock(outputPtr+offset);
-      Bool_t iclustered = fClusterizer->Raw2ClustersChamber(fMemReader);
-      if (iclustered == kTRUE)
+      Bool_t bclustered = fClusterizer->Raw2ClustersChamber(fMemReader);
+      if(bclustered)
        {
-         HLTDebug( "Clustered successfully");
+         HLTDebug("Clustered successfully");
        }
       else
        {
@@ -269,9 +287,6 @@ int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtD
          return -1;
        }
 
-      // put the tree into output
-      //fcTree->Print();
-      
       AliHLTUInt32_t addedSize;
       if(fReconstructor->IsProcessingTracklets()){
        addedSize = fClusterizer->GetAddedTrSize();
@@ -291,19 +306,21 @@ int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtD
          FillBlockData( bd );
          bd.fOffset = offset;
          bd.fSize = addedSize;
-         //bd.fSpecification = spec;
-         bd.fSpecification = gkAliEventTypeData;
+         bd.fSpecification = block.fSpecification;
          bd.fDataType = AliHLTTRDDefinitions::fgkMCMtrackletDataType;
          outputBlocks.push_back( bd );
-         HLTDebug( "BD fPtr 0x%x, fOffset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), spec);
+         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(), spec);
        }
        offset = totalSize;
       }
 
       addedSize = fClusterizer->GetAddedClSize();
       if (addedSize > 0){
-       // Using low-level interface 
-       // with interface classes
+       
+       Int_t* nTimeBins = (Int_t*)(outputPtr+offset+fClusterizer->GetAddedClSize());
+       *nTimeBins = fClusterizer->GetNTimeBins();
+       addedSize += sizeof(*nTimeBins);
+
        totalSize += addedSize;
        if ( totalSize > size )
          {
@@ -311,22 +328,21 @@ int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtD
                     totalSize, size );
            return EMSGSIZE;
          }
-               
+
        // Fill block 
        AliHLTComponentBlockData bd;
        FillBlockData( bd );
        bd.fOffset = offset;
        bd.fSize = addedSize;
-       //bd.fSpecification = spec;
-       bd.fSpecification = gkAliEventTypeData;
+       bd.fSpecification = block.fSpecification;
        bd.fDataType = AliHLTTRDDefinitions::fgkClusterDataType;
        outputBlocks.push_back( bd );
-       HLTDebug( "BD fPtr 0x%x, fOffset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), spec);
+       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(), spec);
        offset = totalSize;
-             
       }
-      else 
+      else{
        HLTDebug("Array of clusters is empty!");
+      }
     }
   fReconstructor->SetClusters(0x0);
 
@@ -363,13 +379,7 @@ int AliHLTTRDClusterizerComponent::Configure(const char* arguments){
       argument=((TObjString*)pTokens->At(i))->GetString();
       if (argument.IsNull()) continue;
       
-      if (argument.CompareTo("-OFFLINE")==0) {
-       fOfflineMode = kTRUE;
-       HLTFatal("You have selected OFFLINE mode!");
-       HLTFatal("This program shall NOT run on the HLT cluster like this!");
-       continue;
-      }
-      else if (argument.CompareTo("output_percentage")==0) {
+      if (argument.CompareTo("output_percentage")==0) {
        if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
        HLTInfo("Setting output percentage to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
        fOutputPercentage=((TObjString*)pTokens->At(i))->GetString().Atoi();
@@ -381,46 +391,51 @@ int AliHLTTRDClusterizerComponent::Configure(const char* arguments){
        fgeometryFileName=((TObjString*)pTokens->At(i))->GetString();
        continue;
       } 
-      if (argument.CompareTo("-lowflux")==0) {
+      else if (argument.CompareTo("-lowflux")==0) {
        fRecoParamType = 0;
        HLTInfo("Low flux reconstruction selected");
        continue;
       }
-      if (argument.CompareTo("-highflux")==0) {
+      else if (argument.CompareTo("-highflux")==0) {
        fRecoParamType = 1;
        HLTInfo("High flux reconstruction selected");
        continue;
       }
-      if (argument.CompareTo("-cosmics")==0) {
+      else if (argument.CompareTo("-cosmics")==0) {
        fRecoParamType = 2;
        HLTInfo("Cosmics reconstruction selected");
        continue;
       }
-      if (argument.CompareTo("-simulation")==0) {
+      else if (argument.CompareTo("-simulation")==0) {
        fRecoDataType = 0;
        HLTInfo("Awaiting simulated data");
        continue;
       }
-      if (argument.CompareTo("-experiment")==0) {
+      else if (argument.CompareTo("-experiment")==0) {
        fRecoDataType = 1;
        HLTInfo("Awaiting real data");
        continue;
       }
-      if (argument.CompareTo("-processTracklets")==0) {
+      else if (argument.CompareTo("-processTracklets")==0) {
        fProcessTracklets = kTRUE;
-       HLTInfo("Processing L1 Tracklets");
+       HLTInfo("Writing L1 tracklets to output");
        continue;
       }
-      if (argument.CompareTo("-noZS")==0) {
+      else if (argument.CompareTo("-noZS")==0) {
        fOutputPercentage = 100;
        HLTInfo("Awaiting non zero surpressed data");
        continue;
       }
-      if (argument.CompareTo("-faststreamer")==0) {
+      else if (argument.CompareTo("-faststreamer")==0) {
        fHLTstreamer = kTRUE;
        HLTInfo("Useing fast raw streamer");
        continue;
       }
+      else if (argument.CompareTo("-nofaststreamer")==0) {
+       fHLTstreamer = kFALSE;
+       HLTInfo("Don't use fast raw streamer");
+       continue;
+      }
       else if (argument.CompareTo("-rawver")==0) {
        if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
        HLTInfo("Raw data version is: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
@@ -448,7 +463,7 @@ int AliHLTTRDClusterizerComponent::Configure(const char* arguments){
          break;
        }
        continue;
-      } 
+      }
       
       else {
        HLTError("unknown argument: %s", argument.Data());
@@ -463,7 +478,6 @@ int AliHLTTRDClusterizerComponent::Configure(const char* arguments){
     iResult=-EINVAL;
   }
   if(iResult>=0){
-    if(fOfflineMode)SetOfflineParams();
     iResult=SetParams();
   }
   return iResult;
@@ -473,7 +487,7 @@ int AliHLTTRDClusterizerComponent::SetParams()
 {
   Int_t iResult=0;
   if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
-    HLTError("DefaultStorage is not Set in CDBManager");
+    HLTError("DefaultStorage is not set in CDBManager");
     return -EINVAL;
   }
   if(AliCDBManager::Instance()->GetRun()<0){
@@ -491,7 +505,7 @@ int AliHLTTRDClusterizerComponent::SetParams()
       AliGeomManager::LoadGeometry(fgeometryFileName.Data());
     }
     if(!AliGeomManager::GetGeometry()){
-      HLTError("Cannot load geometry");
+      HLTError("Could not load geometry");
       return -EINVAL;
     }
   }
@@ -538,8 +552,8 @@ int AliHLTTRDClusterizerComponent::SetParams()
       return -EINVAL;
     }
 
+  fRecoParam->SetStreamLevel(AliTRDrecoParam::kClusterizer, 0);
   fReconstructor->SetRecoParam(fRecoParam);
-  fReconstructor->SetStreamLevel(0, AliTRDReconstructor::kClusterizer);
 
   HLTDebug("Reconstructor options are: %s",recoOptions.Data());
   fReconstructor->SetOption(recoOptions.Data());
@@ -578,24 +592,6 @@ int AliHLTTRDClusterizerComponent::SetParams()
   return iResult;
 }
 
-void AliHLTTRDClusterizerComponent::SetOfflineParams(){
-  HLTFatal("You have entered the OFFLINE configuration!");
-  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");
-  }else{
-    HLTError("DefaultStorage was already set!");
-  }
-  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);
-  }else{
-    HLTError("Run Number was already set!");
-  }
-}
-
 int AliHLTTRDClusterizerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
 {
   // see header file for class documentation