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, const char* digitFile)
40 AliHLTOUTHomerCollection(event, pEsdManager),
41 fDigitFileName(digitFile),
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 AliHLTOUTDigitReader::~AliHLTOUTDigitReader()
60 // see header file for class documentation
70 Bool_t AliHLTOUTDigitReader::ReadNextData(UChar_t*& data)
72 // see header file for class documentation
73 if (!fppDigitArrays && (!ReadArrays() || !fppDigitArrays))
76 if (fCurrent>=fNofDDLs)
79 while (++fCurrent<fNofDDLs) {
80 if (fMinDDL>-1 && fMinDDL>fpEquipments[fCurrent]) continue;
81 if (fMaxDDL>-1 && fMaxDDL<fpEquipments[fCurrent]) continue;
82 if (fppDigitArrays[fCurrent]->GetSize()>(int)sizeof(AliRawDataHeader)) {
83 data=reinterpret_cast<UChar_t*>(fppDigitArrays[fCurrent]->GetArray());
84 data+=sizeof(AliRawDataHeader);
91 int AliHLTOUTDigitReader::Reset()
93 // see header file for class documentation
98 int AliHLTOUTDigitReader::GetDataSize()
100 // see header file for class documentation
101 if (fCurrent>=0 && fCurrent<fNofDDLs && fppDigitArrays) {
102 return fppDigitArrays[fCurrent]->GetSize()-sizeof(AliRawDataHeader);
107 const AliRawDataHeader* AliHLTOUTDigitReader::GetDataHeader()
109 // see header file for class documentation
110 if (fCurrent>=0 && fCurrent<fNofDDLs && fppDigitArrays) {
111 return reinterpret_cast<AliRawDataHeader*>(fppDigitArrays[fCurrent]->GetArray());
116 void AliHLTOUTDigitReader::SelectEquipment(int /*equipmentType*/, int minEquipmentId, int maxEquipmentId)
118 // see header file for class documentation
119 fMinDDL=minEquipmentId;
120 fMaxDDL=maxEquipmentId;
123 int AliHLTOUTDigitReader::GetEquipmentId()
125 // see header file for class documentation
126 if (fCurrent>=0 && fCurrent<fNofDDLs && fpEquipments) {
127 return fpEquipments[fCurrent];
132 bool AliHLTOUTDigitReader::ReadArrays()
134 // see header file for class documentation
137 if (GetCurrentEventNo()<0) {
138 HLTWarning("no event selected, no data available");
143 fpDigitFile=new TFile(fDigitFileName);
145 if (!fpDigitFile) return false;
146 if (fpDigitFile->IsZombie()) return false;
148 fpDigitFile->GetObject("rawhltout", fpDigitTree);
153 vector<int> equipments;
155 TIter iter(fpDigitTree->GetListOfBranches());
156 while (TBranch* br=(TBranch *)iter.Next()) {
158 TString bname=br->GetName();
159 if (bname.BeginsWith("HLT_") && bname.EndsWith(".ddl")) {
160 bname.ReplaceAll("HLT_", "");
161 bname.ReplaceAll(".ddl", "");
162 if (bname.IsDigit()) {
163 int equipment=bname.Atoi();
164 int index=equipment-AliDAQ::DdlIDOffset("HLT");
165 if (index>=0 && strcmp(br->GetName(), AliDAQ::DdlFileName("HLT", index))==0) {
166 equipments.push_back(equipment);
168 HLTWarning("equipment mismatch: skipping id %d (out of range of HLT equipments)", equipment);
173 HLTDebug("found %d HLT branche(s) out of %d", equipments.size(), iTotal);
175 if (equipments.size()>0) {
176 fNofDDLs=equipments.size();
177 fpEquipments=new int[fNofDDLs];
178 fppDigitArrays=new TArrayC*[fNofDDLs];
179 if (fpEquipments && fppDigitArrays) {
180 memcpy(fpEquipments, &equipments[0], fNofDDLs*sizeof(int));
182 for (i=0; i<fNofDDLs; i++) {
183 fppDigitArrays[i]=NULL;
184 fpDigitTree->SetBranchAddress(AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), &fppDigitArrays[i]);
186 fpDigitTree->GetEvent(GetCurrentEventNo());
187 for (i=0; i<fNofDDLs; i++) {
188 if (fppDigitArrays[i]) {
189 HLTDebug("branch %s: %d byte(s)", AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), fppDigitArrays[i]);
200 int AliHLTOUTDigitReader::CloseTree()
202 // see header file for class documentation
204 if (fppDigitArrays) delete[] fppDigitArrays;
206 if (fpEquipments) delete[] fpEquipments;
208 if (fpDigitTree) delete fpDigitTree;
216 void AliHLTOUTDigitReader::SetParam(TTree* /*pDigitTree*/, int event)
218 // see header file for class documentation
220 // TODO: here we have the implemented to correct loading of
221 // the digit file from the run loader. At time of writing
222 // (Jun 2008) the AliLoader for the HLT is missing in the AliRoot