From f3ab48480e40fe77ac13c3d32b3f0e2c5f7e730f Mon Sep 17 00:00:00 2001 From: phille Date: Mon, 15 Oct 2007 16:02:28 +0000 Subject: [PATCH] Classes for online creation of root trees --- HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx | 79 +++++++ HLT/PHOS/AliHLTPHOSRcuTreeMaker.h | 54 +++++ HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx | 227 +++++++++++++++++++ HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h | 72 ++++++ HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h | 28 +++ HLT/PHOS/AliHLTPHOSRecPointDataStruct.h | 38 ++-- HLT/PHOS/AliHLTPHOSTreeMaker.cxx | 79 +++++++ HLT/PHOS/AliHLTPHOSTreeMaker.h | 54 +++++ HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx | 217 ++++++++++++++++++ HLT/PHOS/AliHLTPHOSTreeMakerComponent.h | 72 ++++++ 10 files changed, 898 insertions(+), 22 deletions(-) create mode 100644 HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx create mode 100644 HLT/PHOS/AliHLTPHOSRcuTreeMaker.h create mode 100644 HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx create mode 100644 HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h create mode 100644 HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h create mode 100644 HLT/PHOS/AliHLTPHOSTreeMaker.cxx create mode 100644 HLT/PHOS/AliHLTPHOSTreeMaker.h create mode 100644 HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx create mode 100644 HLT/PHOS/AliHLTPHOSTreeMakerComponent.h diff --git a/HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx b/HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx new file mode 100644 index 00000000000..82b5d9f5ac8 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSRcuTreeMaker.cxx @@ -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 index 00000000000..0e663bc41f1 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSRcuTreeMaker.h @@ -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 index 00000000000..0cf36f53b72 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.cxx @@ -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 +#include "TFile.h" +#include +#include + +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& 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& 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 ( 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 index 00000000000..fef64c2c9d0 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSRcuTreeMakerComponent.h @@ -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& 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&); + + 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 index 00000000000..69d567c55ec --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSRecPointContainerStruct.h @@ -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 diff --git a/HLT/PHOS/AliHLTPHOSRecPointDataStruct.h b/HLT/PHOS/AliHLTPHOSRecPointDataStruct.h index 7cbe32d3a67..0ed6131b820 100644 --- a/HLT/PHOS/AliHLTPHOSRecPointDataStruct.h +++ b/HLT/PHOS/AliHLTPHOSRecPointDataStruct.h @@ -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 * + * 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 index 00000000000..3e9affdc3f6 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSTreeMaker.cxx @@ -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 index 00000000000..4ed127ab9a9 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSTreeMaker.h @@ -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 index 00000000000..7be3fea00de --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSTreeMakerComponent.cxx @@ -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 +#include "TFile.h" +#include +#include + +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& 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& 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 ( 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 index 00000000000..2cde29c0592 --- /dev/null +++ b/HLT/PHOS/AliHLTPHOSTreeMakerComponent.h @@ -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& 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&); + + 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 + -- 2.31.1