]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
- increased output buffer size
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterAnalyserComponent.cxx
index 02f35fe4cb8d204f56ccf1681b6bc7f7ce366ace..4f6b190baa277f7924b27ad50e5ee8eb639a48df 100644 (file)
@@ -1,3 +1,5 @@
+// $Id$
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 
 #include "AliHLTPHOSClusterAnalyserComponent.h"
 #include "AliHLTPHOSClusterAnalyser.h"
-#include "AliHLTPHOSRecPointContainerStruct.h"
-#include "AliHLTPHOSCaloClusterContainerStruct.h"
+#include "AliHLTPHOSRecPointHeaderStruct.h"
+#include "AliHLTPHOSDigitDataStruct.h"
+#include "AliHLTCaloClusterDataStruct.h"
+#include "AliPHOSGeoUtils.h"
+#include "TGeoManager.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliCDBPath.h"
+
 
 /** @file   AliHLTPHOSClusterAnalyserComponent.cxx
     @author Oystein Djuvsland
 using namespace std;
 #endif
 
-const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]=
-  {
-    kAliHLTVoidDataType,{0,"",""}
-  };
+TGeoManager* gGeoManager = NULL;
 
 AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
 
@@ -44,9 +50,11 @@ AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
 AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(), 
                                                                          fClusterAnalyserPtr(0),
                                                                          fDoDeconvolution(0),
-                                                                         fDoCalculateMoments(0)
+                                                                         fDoCalculateMoments(0),
+                                                                         fPHOSGeometry(0)
 {
   //See headerfile for documentation
+   
 }
 
 AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
@@ -86,13 +94,7 @@ AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDat
 {
   //See headerfile for documentation
   list.clear();
-  list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
-//   const AliHLTComponentDataType* pType=fgkInputDataTypes;
-//   while (pType->fID!=0)
-//     {
-//       list.push_back(*pType);
-//       pType++;
-//     }
+  list.push_back(AliHLTPHOSDefinitions::fgkRecPointDataType);
 }
 
 AliHLTComponentDataType
@@ -100,7 +102,7 @@ AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
 {
   //See headerfile for documentation
 
-  return AliHLTPHOSDefinitions::fgkClusterDataType;
+  return kAliHLTDataTypeCaloCluster;
 }
 
 void
@@ -109,8 +111,8 @@ AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase,
 {
   //See headerfile for documentation
 
-  constBase = 0;
-  inputMultiplier = 1;
+  constBase = sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t);
+  inputMultiplier = 1.2;
 }
 
 AliHLTComponent*
@@ -128,7 +130,7 @@ AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtD
 {
   //See headerfile for documentation
 
-  UInt_t tSize            = 0;
+  //UInt_t tSize            = 0;
   UInt_t offset           = 0;
   UInt_t mysize           = 0;
   Int_t nClusters         = 0;
@@ -140,18 +142,19 @@ AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtD
 
   UInt_t specification = 0;
 
-  AliHLTPHOSRecPointContainerStruct* recPointContainerPtr = 0;
-  fClusterAnalyserPtr->SetCaloClusterContainer((AliHLTPHOSCaloClusterContainerStruct*)outBPtr);
+  //  AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
+
+  fClusterAnalyserPtr->SetCaloClusterDataPtr(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr + sizeof(AliHLTCaloClusterHeaderStruct)));
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx; 
-      if (iter->fDataType != AliHLTPHOSDefinitions::fgkClusterDataType)
+      if (iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType)
         {
-          continue;
+         continue;
         }
       specification = specification|iter->fSpecification;
-      recPointContainerPtr = reinterpret_cast<AliHLTPHOSRecPointContainerStruct*>(iter->fPtr);
-      fClusterAnalyserPtr->SetRecPointContainer(recPointContainerPtr);
+      AliHLTPHOSDigitHeaderStruct *digitHeader = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(iter->fPtr);
+      fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(reinterpret_cast<Long_t>(iter->fPtr) + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeader->fNDigits*sizeof(AliHLTPHOSDigitDataStruct)), digitHeader);
       if(fDoDeconvolution)
        {
          fClusterAnalyserPtr->DeconvoluteClusters();
@@ -161,41 +164,97 @@ AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtD
        {
          fClusterAnalyserPtr->CalculateRecPointMoments();
        }
-      nClusters = fClusterAnalyserPtr->CreateClusters();
+      nClusters = fClusterAnalyserPtr->CreateClusters(size, mysize);
+    }
+  
+  if(nClusters == -1)
+    {
+      HLTError("Running out of buffer, exiting for safety.");
+      return -ENOBUFS;
     }
+  for(int i = 0; i < nClusters; i++)
+    {
 
-  mysize = 0; 
-  offset = tSize;
-  mysize += sizeof(AliHLTPHOSCaloClusterContainerStruct);
+    }
+
+  HLTDebug("Number of clusters: %d", nClusters);
+  //  caloClusterHeaderPtr->fNClusters = nClusters;
+  reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr)->fNClusters = nClusters;
+  mysize += sizeof(AliHLTCaloClusterHeaderStruct); 
   
   AliHLTComponentBlockData bd;
   FillBlockData( bd );
   bd.fOffset = offset;
   bd.fSize = mysize;
-  bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType;
+  bd.fDataType = kAliHLTDataTypeCaloCluster;
   bd.fSpecification = specification;
   outputBlocks.push_back( bd );
-
-  tSize += mysize;
-  outBPtr += mysize;
  
-  if ( tSize > size )
+  if ( mysize > size )
     {
-      Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
+      Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", mysize, size );
       return EMSGSIZE;
     }
 
   fPhosEventCount++; 
-  if(fPrintInfoModule == kTRUE)
-    {
-      if(fPhosEventCount%fPrintInfoFrequncyModule == 0)
-       {
-         Logging( kHLTLogInfo, __FILE__ , "Clusters analyzed",  "Has analyzed  %lu  for this event",  nClusters);
-       }  
-    }
+
+  size = mysize;  
+  return 0;
+
+}
+
+int 
+AliHLTPHOSClusterAnalyserComponent::Reconfigure(const char *cdbEntry, const char */*chainId*/)
+{
+  // see header file for class documentation
+
+  // configure from the specified entry or the default
+
+  ConfigureFromCDBTObjString(cdbEntry);
   
   return 0;
+} 
+
+
+int 
+AliHLTPHOSClusterAnalyserComponent::ScanConfigurationArgument(int argc, const char **argv)
+{
+  //See header file for documentation
+
+  if(argc <= 0) return 0;
+
+  int i=0;
+
+  TString argument=argv[i];
+
+  if (argument.CompareTo("-dodeconvolution") == 0)
+    {
+      fDoDeconvolution = true;
+      return 1;
+    }
+  if (argument.CompareTo("-doclusterfit") == 0)
+    {
+      fClusterAnalyserPtr->SetDoClusterFit();
+      fDoCalculateMoments = true;
+      return 1;
+    }
+  if (argument.CompareTo("-haveCPV") == 0)
+    {
+      fClusterAnalyserPtr->SetHaveCPVInfo();
+      return 1;
+    }
+  if (argument.CompareTo("-doPID") == 0)
+    {
+      fClusterAnalyserPtr->SetDoPID();
+      return 1;
+    }
+  if (argument.CompareTo("-havedistbadchannel") == 0)
+    {
+      fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
+      return 1;
+    }
 
+  return 0;
 }
 
 int
@@ -204,33 +263,57 @@ AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
 
   //See headerfile for documentation
   
+  HLTError("Doing init...");
+
   fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
-  ScanArgumentsModule(argc, argv);
+
+  //  const char *path = "HLT/ConfigPHOS/ClusterAnalyserComponent";
+
+  GetGeometryFromCDB();
+
+  //  ConfigureFromCDBTObjString(path);
+
   for (int i = 0; i < argc; i++)
     {
-      if(!strcmp("-dodeconvolution", argv[i]))
-       {
-         fDoDeconvolution = true;
-       }
-      if(!strcmp("-doclusterfit", argv[i]))
-       {
-         fClusterAnalyserPtr->SetDoClusterFit();
-         fDoCalculateMoments = true;
-       }
-      if(!strcmp("-haveCPV", argv[i]))
+      ScanConfigurationArgument(i, argv);
+    }
+
+  return 0;
+}
+
+int 
+AliHLTPHOSClusterAnalyserComponent::GetGeometryFromCDB()
+{
+  HLTError("Getting geometry...");
+
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+
+  AliCDBPath path("GRP","Geometry","Data");
+  if(path.GetPath())
+    {
+      //      HLTInfo("configure from entry %s", path.GetPath());
+      AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+      if (pEntry) 
        {
-         fClusterAnalyserPtr->SetHaveCPVInfo();
+         if(!fPHOSGeometry) 
+           {
+             delete fPHOSGeometry;
+             fPHOSGeometry = 0;
+           }
+
+         gGeoManager = (TGeoManager*) pEntry->GetObject();
+         HLTError("gGeoManager = 0x%x", gGeoManager);
+         if(gGeoManager)
+           {
+             fPHOSGeometry = new AliPHOSGeoUtils("PHOS", "noCPV");
+             fClusterAnalyserPtr->SetGeometry(fPHOSGeometry);
+           }
+
        }
-      if(!strcmp("-doPID", argv[i]))
+      else
        {
-         fClusterAnalyserPtr->SetDoPID();
-       } 
-      if(!strcmp("-havedistbadchannel", argv[i]))
-       {
-         fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
+         //      HLTError("can not fetch object \"%s\" from OCDB", path);
        }
-
     }
-
   return 0;
 }