// $Id$ //************************************************************************** //* This file is property of and copyright by the * //* ALICE Experiment at CERN, All rights reserved. * //* * //* Primary Authors: Matthias Richter * //* * //* 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, const char* digitFile) : AliHLTOUTHomerCollection(event, pEsdManager), fDigitFileName(digitFile), fpDigitFile(NULL), fpDigitTree(NULL), fMinDDL(-1), fMaxDDL(-1), fppDigitArrays(NULL), fpEquipments(NULL), fNofDDLs(0), fCurrentLink(-1) { // constructor // // HLTOUT data wrapper for simulated AliRoot HLT digit data // // see header file for class documentation } AliHLTOUTDigitReader::~AliHLTOUTDigitReader() { // destructor CloseTree(); if (fpDigitFile) { fpDigitFile->Close(); delete fpDigitFile; fpDigitFile=NULL; } } Bool_t AliHLTOUTDigitReader::ReadNextData(UChar_t*& data) { // overloaded from AliHLTOUTHomerCollection: switch to next DDL if (!fppDigitArrays && (!ReadArrays() || !fppDigitArrays)) return kFALSE; if (fCurrentLink>=fNofDDLs) return kFALSE; while (++fCurrentLink-1 && fMinDDL>fpEquipments[fCurrentLink]) continue; if (fMaxDDL>-1 && fMaxDDLGetSize()>(int)sizeof(AliRawDataHeader)) { data=reinterpret_cast(fppDigitArrays[fCurrentLink]->GetArray()); data+=sizeof(AliRawDataHeader); return kTRUE; } } return kFALSE; } int AliHLTOUTDigitReader::Reset() { // overloaded from AliHLTOUTHomerCollection: reset DDL position fCurrentLink=-1; return 0; } int AliHLTOUTDigitReader::GetDataSize() { // overloaded from AliHLTOUTHomerCollection: get size of current DDL if (fCurrentLink>=0 && fCurrentLinkGetSize()-sizeof(AliRawDataHeader); } return 0; } const AliRawDataHeader* AliHLTOUTDigitReader::GetDataHeader() { // overloaded from AliHLTOUTHomerCollection: get data header of current DDL if (fCurrentLink>=0 && fCurrentLink(fppDigitArrays[fCurrentLink]->GetArray()); } return NULL; } void AliHLTOUTDigitReader::SelectEquipment(int /*equipmentType*/, int minEquipmentId, int maxEquipmentId) { // overloaded from AliHLTOUTHomerCollection: select equipment range fMinDDL=minEquipmentId; fMaxDDL=maxEquipmentId; } int AliHLTOUTDigitReader::GetEquipmentId() { // overloaded from AliHLTOUTHomerCollection: get id of current DDL if (fCurrentLink>=0 && fCurrentLinkIsZombie()) 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