]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Classes for online creation of root trees
authorphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 16:02:28 +0000 (16:02 +0000)
committerphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 16:02:28 +0000 (16:02 +0000)
HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSRcuTreeMaker.h [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSRecPointDataStruct.h
HLT/PHOS/AliHLTPHOSTreeMaker.cxx [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSTreeMaker.h [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSTreeMakerComponent.h [new file with mode: 0644]

diff --git a/HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx b/HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx
new file mode 100644 (file)
index 0000000..82b5d9f
--- /dev/null
@@ -0,0 +1,79 @@
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#include "AliHLTPHOSRcuTreeMaker.h"
+#include "AliHLTPHOSBase.h"
+#include "AliHLTPHOSRcuDigitContainerDataStruct.h"
+#include "AliHLTPHOSDigitDataStruct.h"
+#include "AliHLTPHOSDigit.h"
+#include "TClonesArray.h"
+#include "TTree.h"
+
+ClassImp(AliHLTPHOSRcuTreeMaker);
+
+AliHLTPHOSRcuTreeMaker::AliHLTPHOSRcuTreeMaker() :
+  AliHLTPHOSBase(),
+  fDigitArrayPtr(0),
+  fDigitTreePtr(0)
+{
+
+  fDigitArrayPtr = new TClonesArray("AliHLTPHOSRcuDigit", 300); //!!!!!!!!!!!!!!!!
+  fDigitTreePtr = new TTree("digitTree", "Digits Tree");
+
+  fDigitTreePtr->Branch("Digit", &fDigitArrayPtr);
+
+}
+
+AliHLTPHOSRcuTreeMaker::~AliHLTPHOSRcuTreeMaker()
+{
+}
+
+Int_t
+AliHLTPHOSRcuTreeMaker::MakeDigitArray(AliHLTPHOSRcuDigitContainerDataStruct *digitContainer, Int_t nDigits)
+{
+  AliHLTPHOSDigit *digit = 0;
+  AliHLTPHOSDigitDataStruct *digitStruct = 0;
+
+  for(Int_t i = 0; i < digitContainer->fNDigits; i++)
+    {
+      digitStruct = &(digitContainer->fDigitDataStruct[i]);
+      digit = (AliHLTPHOSDigit*)fDigitArrayPtr->New(i + nDigits);
+      digit->SetX(digitStruct->fX);
+      digit->SetZ(digitStruct->fZ);
+      digit->SetAmplitude(digitStruct->fAmplitude);
+      digit->SetTime(digitStruct->fTime);
+      digit->SetGain(digitStruct->fGain);
+      digit->SetRawData(digitStruct->fData);
+      digit->SetCrazyness(digitStruct->fCrazyness);
+      digit->SetBaseline(digitStruct->fBaseline);
+    }
+  return digitContainer->fNDigits;
+}
+
+void
+AliHLTPHOSRcuTreeMaker::FillDigitTree()
+{
+  fDigitTreePtr->Fill();
+  fDigitArrayPtr->Clear();
+}
+void 
+AliHLTPHOSRcuTreeMaker::SetDigitTree(TTree *tree) 
+{ 
+  fDigitTreePtr = tree; 
+  fDigitTreePtr->Branch("Digit", &fDigitArrayPtr);
+}
diff --git a/HLT/PHOS/AliHLTPHOSRcuTreeMaker.h b/HLT/PHOS/AliHLTPHOSRcuTreeMaker.h
new file mode 100644 (file)
index 0000000..0e663bc
--- /dev/null
@@ -0,0 +1,54 @@
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#ifndef ALIHLTPHOSRCUTREEMAKER_H
+#define ALIHLTPHOSRCUTREEMAKER_H
+
+#include "AliHLTPHOSBase.h"
+#include "TTree.h"
+class AliHLTPHOSRcuDigitContainerDataStruct;
+
+class TClonesArray;
+//class TTree;
+
+class AliHLTPHOSRcuTreeMaker : public AliHLTPHOSBase
+{
+public:
+
+  AliHLTPHOSRcuTreeMaker();
+  ~AliHLTPHOSRcuTreeMaker();
+
+  Int_t MakeDigitArray(AliHLTPHOSRcuDigitContainerDataStruct* digitContainer, Int_t nDigits);
+
+  void FillDigitTree();
+  
+  void ResetDigitTree() { fDigitTreePtr->Reset(); }
+  
+  void SetDigitTree(TTree* tree);
+  
+  TTree* GetDigitTree() { return fDigitTreePtr; }
+  
+private:
+  TClonesArray *fDigitArrayPtr;
+  TTree* fDigitTreePtr;
+  ClassDef(AliHLTPHOSRcuTreeMaker, 1);
+
+};
+
+
+#endif
diff --git a/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx b/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx
new file mode 100644 (file)
index 0000000..0cf36f5
--- /dev/null
@@ -0,0 +1,227 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#include "AliHLTPHOSRcuTreeMakerComponent.h"
+#include "AliHLTPHOSRcuTreeMaker.h"
+#include "AliHLTPHOSRcuProcessor.h"
+#include "AliHLTPHOSDigitDataStruct.h"
+#include "TTree.h"
+#include "TClonesArray.h"
+#include "TObject.h"
+#include <fstream>
+#include "TFile.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+
+const AliHLTComponentDataType AliHLTPHOSRcuTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
+
+AliHLTPHOSRcuTreeMakerComponent gAliHLTPHOSRcuTreeMakerComponent;
+
+AliHLTPHOSRcuTreeMakerComponent::AliHLTPHOSRcuTreeMakerComponent() :
+  AliHLTPHOSRcuProcessor(),
+  fDigitTreePtr(0),
+  fEventCount(0),
+  fWriteInterval(1000)
+{
+}
+
+AliHLTPHOSRcuTreeMakerComponent::~AliHLTPHOSRcuTreeMakerComponent()
+{
+}
+
+int 
+AliHLTPHOSRcuTreeMakerComponent::Deinit()
+{
+
+  //  cout << "Printing file...";
+
+  /*
+  char filename [50];
+  sprintf(filename, "%s/run%d_digitTree_rcuX_%d_rcuZ_%d_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
+  TFile *outfile = new TFile(filename,"recreate");
+  fDigitTreePtr->Write();
+  delete outfile;
+  outfile = 0;
+  cout << "Done!\n";
+  */
+  
+  Write();
+
+
+  if(fDigitTreePtr) 
+    {
+      delete fDigitTreePtr;
+      fDigitTreePtr = 0;
+    }
+  return 0;
+}
+
+
+
+const char*
+AliHLTPHOSRcuTreeMakerComponent::GetComponentID()
+{
+  return "PhosRcuTreeMaker";
+}
+
+void
+AliHLTPHOSRcuTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
+{ 
+ //Get datatypes for input
+  const AliHLTComponentDataType* pType=fgkInputDataTypes;
+  while (pType->fID!=0) {
+    list.push_back(*pType); 
+    pType++;
+  }
+}
+
+AliHLTComponentDataType 
+AliHLTPHOSRcuTreeMakerComponent::GetOutputDataType()
+{
+  return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
+}
+
+void 
+AliHLTPHOSRcuTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+  constBase = 30;
+  inputMultiplier = 1;
+}
+
+int 
+AliHLTPHOSRcuTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
+                                       AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
+                                       std::vector<AliHLTComponentBlockData>& outputBlocks)
+
+{
+  //Do event
+
+  Bool_t digitEvent;
+  Int_t nDigits = 0;
+  Int_t totalDigits = 0;
+
+  const AliHLTComponentBlockData* iter = 0;
+  unsigned long ndx;
+
+  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+    {
+      iter = blocks + ndx;
+
+      if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
+
+        {
+          digitEvent == true;
+          nDigits  = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSRcuDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
+          totalDigits += nDigits;
+         //cout << totalDigits << endl;
+          continue;
+        }
+      if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
+        {
+          //
+        }
+    }
+  fEventCount++;
+  fTreeMakerPtr->FillDigitTree();
+  
+  if(fEventCount%fWriteInterval == 0)
+    {
+      Write();
+      ResetTrees();
+    }
+
+return 0;
+
+}
+
+int
+AliHLTPHOSRcuTreeMakerComponent::DoInit ( int argc, const char** argv )
+{
+
+  fTreeMakerPtr = new AliHLTPHOSRcuTreeMaker();
+  fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
+  fDirectory = new char[50];
+
+  for ( int i = 0; i < argc; i++ )
+    {
+      if ( !strcmp ( "-path", argv[i] ) )
+        {
+          strcpy ( fDirectory, argv[i+1] );
+        }
+      if ( !strcmp ( "-writeinterval", argv[i] ) )
+       {
+         fWriteInterval = atoi(argv[i+1]);
+       }
+    }
+
+  fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
+    
+  fstream runNbFile;
+  Int_t newRunNb;
+  runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
+  runNbFile >> fRunNb;
+  runNbFile.close();
+  /*  newRunNb = fRunNb + 1;
+  runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
+  runNbFile << newRunNb;
+  runNbFile.close();*/
+  
+  cout << endl << "Run number is: " << fRunNb  << "  -- Check that this is correct!!!\n";
+
+  return 0;
+  
+}
+
+
+AliHLTComponent*
+AliHLTPHOSRcuTreeMakerComponent::Spawn()
+{
+  return new AliHLTPHOSRcuTreeMakerComponent();
+}
+
+void
+AliHLTPHOSRcuTreeMakerComponent::Write()
+{
+  cout << "Writing file...";
+
+  char filename [256];
+  sprintf(filename, "%s/run%d_%d_digitTree_mod%d_rcuX%d_rcuZ%d_.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1), fModuleID, fRcuX, fRcuZ);
+  TFile *outfile = new TFile(filename,"recreate");
+  fDigitTreePtr->Write();
+  delete outfile;
+  outfile = 0;
+  cout << "Done!\n";
+
+}
+
+void
+AliHLTPHOSRcuTreeMakerComponent::ResetTrees()
+{
+  delete fDigitTreePtr;
+  fDigitTreePtr = new TTree("digitTree", "Digits tree");
+  fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
+}
+  
+  
+  
+  
+  
+  
+  
+
+
+
diff --git a/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h b/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h
new file mode 100644 (file)
index 0000000..fef64c2
--- /dev/null
@@ -0,0 +1,72 @@
+
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+
+#ifndef ALIHLTPHOSRCUTREEMAKERCOMPONENT_H
+#define ALIHLTPHOSRCUTREEMAKERCOMPONENT_H
+
+# include "AliHLTPHOSRcuProcessor.h"
+
+class AliHLTPHOSRcuTreeMaker;
+class TTree;
+
+class AliHLTPHOSRcuTreeMakerComponent : public AliHLTPHOSRcuProcessor
+{
+ public:
+  
+  AliHLTPHOSRcuTreeMakerComponent();
+  ~AliHLTPHOSRcuTreeMakerComponent();
+    
+  const char* GetComponentID();
+  
+  void  GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+  
+  AliHLTComponentDataType GetOutputDataType();
+  
+  void GetOutputDataSize(unsigned long& constBase, double& inputmultiplier);
+/*
+  int DoEvent(const AliHLTComponentEventData&,
+             AliHLTComponentTriggerData&);
+  */
+  
+  int DoEvent(const AliHLTComponentEventData&, const AliHLTComponentBlockData*,
+             AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&,
+       std::vector<AliHLTComponentBlockData>&);
+  
+  AliHLTComponent* Spawn();
+
+  void Write(); 
+  void ResetTrees();
+   
+ protected:
+  int DoInit(int argc, const char** argv);
+
+  virtual int Deinit(); ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
+  
+ private:  
+  AliHLTPHOSRcuTreeMaker *fTreeMakerPtr;
+  TTree *fDigitTreePtr;
+  UInt_t fEventCount;
+  UInt_t fWriteInterval;
+  UInt_t fRunNb;
+  char *fDirectory;
+  static const AliHLTComponentDataType fgkInputDataTypes[];     //HLT input data type
+  
+};
+#endif
+  
diff --git a/HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h b/HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h
new file mode 100644 (file)
index 0000000..69d567c
--- /dev/null
@@ -0,0 +1,28 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                                      *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+#ifndef ALIHLTPHOSRECPOINTCOINTAINERSTRUCT_H
+#define ALIHLTPHOSRECPOINTCOINTAINERSTRUCT_H
+
+#include "AliHLTPHOSRecPointDataStruct.h"
+
+struct AliHLTPHOSRecPointContainerStruct
+{
+  UInt_t fPHOSModule;
+  UInt_t fNRecPoints; 
+  AliHLTPHOSRecPointDataStruct fRecPointArray[1000];
+};
+
+#endif
index 7cbe32d3a67307e0c2e5b2869614ea2d8a227272..0ed6131b8202bc75ef92a10c99358b33d0bffbdf 100644 (file)
@@ -1,48 +1,42 @@
-#ifndef ALIHLTPHOSRECPOINTDATASTRUCT_H
-#define ALIHLTPHOSRECPOINTDATASTRUCT_H
 
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
  *                                                                        *
- * Authors: Ã˜ystein Djuvsland <oysteind@ift.uib.no>                       *
+ * Primary Authors: Oystein Djuvsland                                                      *
  *                                                                        *
  * 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          *
+ * about the suitability of this software for any purpose. It is          * 
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+#ifndef ALIHLTPHOSRECPOINTDATASTRUCT_H
+#define ALIHLTPHOSRECPOINTDATASTRUCT_H
+
+//struct AliHLTPHOSDigitDataStruct;
+#include "AliHLTPHOSDigitDataStruct.h"
+//#include "AliHLTTypes.h"
+
 struct AliHLTPHOSRecPointDataStruct
 {
-  AliHLTUInt8_t fPHOSModule;
-  AliHLTUInt8_t fMultiplicity;
-  AliHLTUInt8_t fCoordinatesPtr[2]; 
+
+  //AliHLTUInt8_t fMultiplicity; 
+  UInt_t fMultiplicity;
   Float_t fX;
   Float_t fZ;
+  Float_t fAmp;
   Float_t fM2x;
   Float_t fM2z;
   Float_t fM3x;
   Float_t fM4z;
   Float_t fPhixe;
   Float_t fDistanceToBadChannel;
-  Float_t* fEnergiesListPtr;
-
-  void New()
-  {
-    fEnergiesListPtr = new Float_t[fMultiplicity];
-  }
+  AliHLTPHOSDigitDataStruct fDigitsList[64];
 
-  void Del()
-  {
-    if(fEnergiesListPtr)
-      {
-       delete [] fEnergiesListPtr;
-       fEnergiesListPtr = 0;
-      }
-  }
 };
 
 #endif
diff --git a/HLT/PHOS/AliHLTPHOSTreeMaker.cxx b/HLT/PHOS/AliHLTPHOSTreeMaker.cxx
new file mode 100644 (file)
index 0000000..3e9affd
--- /dev/null
@@ -0,0 +1,79 @@
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#include "AliHLTPHOSTreeMaker.h"
+#include "AliHLTPHOSBase.h"
+#include "AliHLTPHOSDigitContainerDataStruct.h"
+#include "AliHLTPHOSDigitDataStruct.h"
+#include "AliHLTPHOSDigit.h"
+#include "TClonesArray.h"
+#include "TTree.h"
+
+ClassImp(AliHLTPHOSTreeMaker);
+
+AliHLTPHOSTreeMaker::AliHLTPHOSTreeMaker() :
+  AliHLTPHOSBase(),
+  fDigitArrayPtr(0),
+  fDigitTreePtr(0)
+{
+
+  fDigitArrayPtr = new TClonesArray("AliHLTPHOSDigit", 300); //!!!!!!!!!!!!!!!!
+  fDigitTreePtr = new TTree("digitTree", "Digits Tree");
+
+  fDigitTreePtr->Branch("Digit", &fDigitArrayPtr);
+
+}
+
+AliHLTPHOSTreeMaker::~AliHLTPHOSTreeMaker()
+{
+}
+
+Int_t
+AliHLTPHOSTreeMaker::MakeDigitArray(AliHLTPHOSDigitContainerDataStruct *digitContainer, Int_t nDigits)
+{
+  AliHLTPHOSDigit *digit = 0;
+  AliHLTPHOSDigitDataStruct *digitStruct = 0;
+
+  for(Int_t i = 0; i < digitContainer->fNDigits; i++)
+    {
+      digitStruct = &(digitContainer->fDigitDataStruct[i]);
+      digit = (AliHLTPHOSDigit*)fDigitArrayPtr->New(i + nDigits);
+      digit->SetX(digitStruct->fX);
+      digit->SetZ(digitStruct->fZ);
+      digit->SetAmplitude(digitStruct->fAmplitude);
+      digit->SetTime(digitStruct->fTime);
+      digit->SetGain(digitStruct->fGain);
+      digit->SetRawData(digitStruct->fData);
+      digit->SetCrazyness(digitStruct->fCrazyness);
+      digit->SetBaseline(digitStruct->fBaseline);
+    }
+  return digitContainer->fNDigits;
+}
+
+void
+AliHLTPHOSTreeMaker::FillDigitTree()
+{
+  fDigitTreePtr->Fill();
+  fDigitArrayPtr->Clear();
+}
+void 
+AliHLTPHOSTreeMaker::SetDigitTree(TTree *tree) 
+{ 
+  fDigitTreePtr = tree; 
+  fDigitTreePtr->Branch("Digit", &fDigitArrayPtr);
+}
diff --git a/HLT/PHOS/AliHLTPHOSTreeMaker.h b/HLT/PHOS/AliHLTPHOSTreeMaker.h
new file mode 100644 (file)
index 0000000..4ed127a
--- /dev/null
@@ -0,0 +1,54 @@
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#ifndef ALIHLTPHOSTREEMAKER_H
+#define ALIHLTPHOSTREEMAKER_H
+
+#include "AliHLTPHOSBase.h"
+#include "TTree.h"
+class AliHLTPHOSDigitContainerDataStruct;
+
+class TClonesArray;
+//class TTree;
+
+class AliHLTPHOSTreeMaker : public AliHLTPHOSBase
+{
+public:
+
+  AliHLTPHOSTreeMaker();
+  ~AliHLTPHOSTreeMaker();
+
+  Int_t MakeDigitArray(AliHLTPHOSDigitContainerDataStruct* digitContainer, Int_t nDigits);
+
+  void FillDigitTree();
+  
+  void ResetDigitTree() { fDigitTreePtr->Reset(); }
+  
+  void SetDigitTree(TTree* tree);
+  
+  TTree* GetDigitTree() { return fDigitTreePtr; }
+  
+private:
+  TClonesArray *fDigitArrayPtr;
+  TTree* fDigitTreePtr;
+  ClassDef(AliHLTPHOSTreeMaker, 1);
+
+};
+
+
+#endif
diff --git a/HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx b/HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx
new file mode 100644 (file)
index 0000000..7be3fea
--- /dev/null
@@ -0,0 +1,217 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+#include "AliHLTPHOSTreeMakerComponent.h"
+#include "AliHLTPHOSTreeMaker.h"
+#include "AliHLTPHOSProcessor.h"
+#include "AliHLTPHOSDigitDataStruct.h"
+#include "TTree.h"
+#include "TClonesArray.h"
+#include "TObject.h"
+#include <fstream>
+#include "TFile.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+
+const AliHLTComponentDataType AliHLTPHOSTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
+
+AliHLTPHOSTreeMakerComponent gAliHLTPHOSTreeMakerComponent;
+
+AliHLTPHOSTreeMakerComponent::AliHLTPHOSTreeMakerComponent() :
+  AliHLTPHOSProcessor(),
+  fDigitTreePtr(0),
+  fEventCount(0),
+  fWriteInterval(1000)
+{
+}
+
+AliHLTPHOSTreeMakerComponent::~AliHLTPHOSTreeMakerComponent()
+{
+}
+
+int 
+AliHLTPHOSTreeMakerComponent::Deinit()
+{
+  cout << "Printing file...";
+  char filename [50];
+  sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
+  TFile *outfile = new TFile(filename,"recreate");
+  fDigitTreePtr->Write();
+  delete outfile;
+  outfile = 0;
+  cout << "Done!\n";
+  if(fDigitTreePtr) 
+    {
+      delete fDigitTreePtr;
+      fDigitTreePtr = 0;
+    }
+  return 0;
+}
+
+
+
+const char*
+AliHLTPHOSTreeMakerComponent::GetComponentID()
+{
+  return "PhosTreeMaker";
+}
+
+void
+AliHLTPHOSTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
+{ 
+ //Get datatypes for input
+  const AliHLTComponentDataType* pType=fgkInputDataTypes;
+  while (pType->fID!=0) {
+    list.push_back(*pType); 
+    pType++;
+  }
+}
+
+AliHLTComponentDataType 
+AliHLTPHOSTreeMakerComponent::GetOutputDataType()
+{
+  return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
+}
+
+void 
+AliHLTPHOSTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+  constBase = 30;
+  inputMultiplier = 1;
+}
+
+int 
+AliHLTPHOSTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
+                                       AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
+                                       std::vector<AliHLTComponentBlockData>& outputBlocks)
+
+{
+  //Do event
+
+  Bool_t digitEvent;
+  Int_t nDigits = 0;
+  Int_t totalDigits = 0;
+
+  const AliHLTComponentBlockData* iter = 0;
+  unsigned long ndx;
+
+  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+    {
+      iter = blocks + ndx;
+
+      if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
+
+        {
+          digitEvent == true;
+          nDigits  = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
+          totalDigits += nDigits;
+         //cout << totalDigits << endl;
+          continue;
+        }
+      if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
+        {
+          //
+        }
+    }
+  fEventCount++;
+  fTreeMakerPtr->FillDigitTree();
+  
+  if(fEventCount%fWriteInterval == 0)
+    {
+      Write();
+      ResetTrees();
+    }
+
+return 0;
+
+}
+
+int
+AliHLTPHOSTreeMakerComponent::DoInit ( int argc, const char** argv )
+{
+
+  fTreeMakerPtr = new AliHLTPHOSTreeMaker();
+  fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
+  fDirectory = new char[50];
+
+  for ( int i = 0; i < argc; i++ )
+    {
+      if ( !strcmp ( "-path", argv[i] ) )
+        {
+          strcpy ( fDirectory, argv[i+1] );
+        }
+      if ( !strcmp ( "-writeinterval", argv[i] ) )
+       {
+         fWriteInterval = atoi(argv[i+1]);
+       }
+    }
+
+  fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
+    
+  fstream runNbFile;
+  Int_t newRunNb;
+  runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
+  runNbFile >> fRunNb;
+  runNbFile.close();
+  /*  newRunNb = fRunNb + 1;
+  runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
+  runNbFile << newRunNb;
+  runNbFile.close();*/
+  
+  cout << endl << "Run number is: " << fRunNb  << "  -- Check that this is correct!!!\n";
+
+  return 0;
+  
+}
+
+
+AliHLTComponent*
+AliHLTPHOSTreeMakerComponent::Spawn()
+{
+  return new AliHLTPHOSTreeMakerComponent();
+}
+
+void
+AliHLTPHOSTreeMakerComponent::Write()
+{
+  cout << "Writing file...";
+  char filename [50];
+  sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1));
+  TFile *outfile = new TFile(filename,"recreate");
+  fDigitTreePtr->Write();
+  delete outfile;
+  outfile = 0;
+  cout << "Done!\n";
+}
+
+void
+AliHLTPHOSTreeMakerComponent::ResetTrees()
+{
+  delete fDigitTreePtr;
+  fDigitTreePtr = new TTree("digitTree", "Digits tree");
+  fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
+}
+  
+  
+  
+  
+  
+  
+  
+
+
+
diff --git a/HLT/PHOS/AliHLTPHOSTreeMakerComponent.h b/HLT/PHOS/AliHLTPHOSTreeMakerComponent.h
new file mode 100644 (file)
index 0000000..2cde29c
--- /dev/null
@@ -0,0 +1,72 @@
+
+ /**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+
+
+#ifndef ALIHLTPHOSTREEMAKERCOMPONENT_H
+#define ALIHLTPHOSTREEMAKERCOMPONENT_H
+
+# include "AliHLTPHOSProcessor.h"
+
+class AliHLTPHOSTreeMaker;
+class TTree;
+
+class AliHLTPHOSTreeMakerComponent : public AliHLTPHOSProcessor
+{
+ public:
+  
+  AliHLTPHOSTreeMakerComponent();
+  ~AliHLTPHOSTreeMakerComponent();
+    
+  const char* GetComponentID();
+  
+  void  GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
+  
+  AliHLTComponentDataType GetOutputDataType();
+  
+  void GetOutputDataSize(unsigned long& constBase, double& inputmultiplier);
+/*
+  int DoEvent(const AliHLTComponentEventData&,
+             AliHLTComponentTriggerData&);
+  */
+  
+  int DoEvent(const AliHLTComponentEventData&, const AliHLTComponentBlockData*,
+             AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&,
+       std::vector<AliHLTComponentBlockData>&);
+  
+  AliHLTComponent* Spawn();
+
+  void Write(); 
+  void ResetTrees();
+   
+ protected:
+  int DoInit(int argc, const char** argv);
+
+  virtual int Deinit(); ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
+  
+ private:  
+  AliHLTPHOSTreeMaker *fTreeMakerPtr;
+  TTree *fDigitTreePtr;
+  UInt_t fEventCount;
+  UInt_t fWriteInterval;
+  UInt_t fRunNb;
+  char *fDirectory;
+  static const AliHLTComponentDataType fgkInputDataTypes[];     //HLT input data type
+  
+};
+#endif
+