3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTOUTDigitReader.cxx
20 @author Matthias Richter
22 @brief HLTOUT data wrapper for simulated AliRoot HLT digit data.
25 #include "AliHLTOUTDigitReader.h"
26 #include "AliRawDataHeader.h"
35 /** ROOT macro for the implementation of ROOT specific class methods */
36 ClassImp(AliHLTOUTDigitReader)
38 AliHLTOUTDigitReader::AliHLTOUTDigitReader(int event, AliHLTEsdManager* pEsdManager)
40 AliHLTOUTHomerCollection(event, pEsdManager),
50 // see header file for class documentation
52 // refer to README to build package
54 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 AliHLTOUTDigitReader::~AliHLTOUTDigitReader()
59 // see header file for class documentation
69 Bool_t AliHLTOUTDigitReader::ReadNextData(UChar_t*& data)
71 // see header file for class documentation
72 if (!fppDigitArrays && (!ReadArrays() || !fppDigitArrays))
75 if (fCurrent>=fNofDDLs)
78 while (++fCurrent<fNofDDLs) {
79 if (fMinDDL>-1 && fMinDDL>fpEquipments[fCurrent]) continue;
80 if (fMaxDDL>-1 && fMaxDDL<fpEquipments[fCurrent]) continue;
81 if (fppDigitArrays[fCurrent]->GetSize()>(int)sizeof(AliRawDataHeader)) {
82 data=reinterpret_cast<UChar_t*>(fppDigitArrays[fCurrent]->GetArray());
83 data+=sizeof(AliRawDataHeader);
90 int AliHLTOUTDigitReader::Reset()
92 // see header file for class documentation
97 int AliHLTOUTDigitReader::GetDataSize()
99 // see header file for class documentation
100 if (fCurrent>=0 && fCurrent<fNofDDLs && fppDigitArrays) {
101 return fppDigitArrays[fCurrent]->GetSize()-sizeof(AliRawDataHeader);
106 const AliRawDataHeader* AliHLTOUTDigitReader::GetDataHeader()
108 // see header file for class documentation
109 if (fCurrent>=0 && fCurrent<fNofDDLs && fppDigitArrays) {
110 return reinterpret_cast<AliRawDataHeader*>(fppDigitArrays[fCurrent]->GetArray());
115 void AliHLTOUTDigitReader::SelectEquipment(int /*equipmentType*/, int minEquipmentId, int maxEquipmentId)
117 // see header file for class documentation
118 fMinDDL=minEquipmentId;
119 fMaxDDL=maxEquipmentId;
122 int AliHLTOUTDigitReader::GetEquipmentId()
124 // see header file for class documentation
125 if (fCurrent>=0 && fCurrent<fNofDDLs && fpEquipments) {
126 return fpEquipments[fCurrent];
131 bool AliHLTOUTDigitReader::ReadArrays()
133 // see header file for class documentation
136 if (GetCurrentEventNo()<0) {
137 HLTWarning("no event selected, no data available");
142 fpDigitFile=new TFile("HLT.Digits.root");
144 if (!fpDigitFile) return false;
145 if (fpDigitFile->IsZombie()) return false;
147 fpDigitFile->GetObject("rawhltout", fpDigitTree);
152 vector<int> equipments;
154 TIter iter(fpDigitTree->GetListOfBranches());
155 while (TBranch* br=(TBranch *)iter.Next()) {
157 TString bname=br->GetName();
158 if (bname.BeginsWith("HLT_") && bname.EndsWith(".ddl")) {
159 bname.ReplaceAll("HLT_", "");
160 bname.ReplaceAll(".ddl", "");
161 if (bname.IsDigit()) {
162 int equipment=bname.Atoi();
163 int index=equipment-AliDAQ::DdlIDOffset("HLT");
164 if (index>=0 && strcmp(br->GetName(), AliDAQ::DdlFileName("HLT", index))==0) {
165 equipments.push_back(equipment);
167 HLTWarning("equipment mismatch: skipping id %d (out of range of HLT equipments)", equipment);
172 HLTDebug("found %d HLT branche(s) out of %d", equipments.size(), iTotal);
174 if (equipments.size()>0) {
175 fNofDDLs=equipments.size();
176 fpEquipments=new int[fNofDDLs];
177 fppDigitArrays=new TArrayC*[fNofDDLs];
178 if (fpEquipments && fppDigitArrays) {
179 memcpy(fpEquipments, &equipments[0], fNofDDLs*sizeof(int));
181 for (i=0; i<fNofDDLs; i++) {
182 fppDigitArrays[i]=NULL;
183 fpDigitTree->SetBranchAddress(AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), &fppDigitArrays[i]);
185 fpDigitTree->GetEvent(GetCurrentEventNo());
186 for (i=0; i<fNofDDLs; i++) {
187 if (fppDigitArrays[i]) {
188 HLTDebug("branch %s: %d byte(s)", AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), fppDigitArrays[i]);
199 int AliHLTOUTDigitReader::CloseTree()
201 // see header file for class documentation
203 if (fppDigitArrays) delete[] fppDigitArrays;
205 if (fpEquipments) delete[] fpEquipments;
207 if (fpDigitTree) delete fpDigitTree;