// $Id$ //************************************************************************** //* This file is property of and copyright by the ALICE HLT Project * //* ALICE Experiment at CERN, All rights reserved. * //* * //* Primary Authors: Matthias Richter * //* 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 AliHLTOUTDigitReader.cxx @author Matthias Richter @date @brief HLTOUT data wrapper for simulated AliRoot HLT digit data. */ #include "AliHLTOUTDigitReader.h" #include "AliRawDataHeader.h" #include "AliDAQ.h" #include "TTree.h" #include "TFile.h" #include "TArrayC.h" #include "TBranch.h" #include "TString.h" #include /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTOUTDigitReader) AliHLTOUTDigitReader::AliHLTOUTDigitReader(int event, AliHLTEsdManager* pEsdManager) : AliHLTOUTHomerCollection(event, pEsdManager), fpDigitFile(NULL), fpDigitTree(NULL), fMinDDL(-1), fMaxDDL(-1), fppDigitArrays(NULL), fpEquipments(NULL), fNofDDLs(0), fCurrent(-1) { // see header file for class documentation // or // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } AliHLTOUTDigitReader::~AliHLTOUTDigitReader() { // see header file for class documentation CloseTree(); if (fpDigitFile) { fpDigitFile->Close(); delete fpDigitFile; fpDigitFile=NULL; } } Bool_t AliHLTOUTDigitReader::ReadNextData(UChar_t*& data) { // see header file for class documentation if (!fppDigitArrays && (!ReadArrays() || !fppDigitArrays)) return kFALSE; if (fCurrent>=fNofDDLs) return kFALSE; while (++fCurrent-1 && fMinDDL>fpEquipments[fCurrent]) continue; if (fMaxDDL>-1 && fMaxDDLGetSize()>(int)sizeof(AliRawDataHeader)) { data=reinterpret_cast(fppDigitArrays[fCurrent]->GetArray()); data+=sizeof(AliRawDataHeader); return kTRUE; } } return kFALSE; } int AliHLTOUTDigitReader::Reset() { // see header file for class documentation fCurrent=-1; return 0; } int AliHLTOUTDigitReader::GetDataSize() { // see header file for class documentation if (fCurrent>=0 && fCurrentGetSize()-sizeof(AliRawDataHeader); } return 0; } const AliRawDataHeader* AliHLTOUTDigitReader::GetDataHeader() { // see header file for class documentation if (fCurrent>=0 && fCurrent(fppDigitArrays[fCurrent]->GetArray()); } return NULL; } void AliHLTOUTDigitReader::SelectEquipment(int /*equipmentType*/, int minEquipmentId, int maxEquipmentId) { // see header file for class documentation fMinDDL=minEquipmentId; fMaxDDL=maxEquipmentId; } int AliHLTOUTDigitReader::GetEquipmentId() { // see header file for class documentation if (fCurrent>=0 && fCurrentIsZombie()) return false; fpDigitFile->GetObject("rawhltout", fpDigitTree); if (!fpDigitTree) { return false; } vector equipments; int iTotal=0; TIter iter(fpDigitTree->GetListOfBranches()); while (TBranch* br=(TBranch *)iter.Next()) { iTotal++; TString bname=br->GetName(); if (bname.BeginsWith("HLT_") && bname.EndsWith(".ddl")) { bname.ReplaceAll("HLT_", ""); bname.ReplaceAll(".ddl", ""); if (bname.IsDigit()) { int equipment=bname.Atoi(); int index=equipment-AliDAQ::DdlIDOffset("HLT"); if (index>=0 && strcmp(br->GetName(), AliDAQ::DdlFileName("HLT", index))==0) { equipments.push_back(equipment); } else { HLTWarning("equipment mismatch: skipping id %d (out of range of HLT equipments)", equipment); } } } } HLTDebug("found %d HLT branche(s) out of %d", equipments.size(), iTotal); if (equipments.size()>0) { fNofDDLs=equipments.size(); fpEquipments=new int[fNofDDLs]; fppDigitArrays=new TArrayC*[fNofDDLs]; if (fpEquipments && fppDigitArrays) { memcpy(fpEquipments, &equipments[0], fNofDDLs*sizeof(int)); int i=0; for (i=0; iSetBranchAddress(AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), &fppDigitArrays[i]); } fpDigitTree->GetEvent(GetCurrentEventNo()); for (i=0; i