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");
142 // 2011-06-06 in order to support AliHLTReconstructor option 'ignore-hltout' for
143 // digits, the file name can be set to NULL, nothing done in that case
144 if (!fDigitFileName) return false;
147 fpDigitFile=new TFile(fDigitFileName);
149 if (!fpDigitFile) return false;
150 if (fpDigitFile->IsZombie()) return false;
152 fpDigitFile->GetObject("rawhltout", fpDigitTree);
157 vector<int> equipments;
159 TIter iter(fpDigitTree->GetListOfBranches());
160 while (TBranch* br=(TBranch *)iter.Next()) {
162 TString bname=br->GetName();
163 if (bname.BeginsWith("HLT_") && bname.EndsWith(".ddl")) {
164 bname.ReplaceAll("HLT_", "");
165 bname.ReplaceAll(".ddl", "");
166 if (bname.IsDigit()) {
167 int equipment=bname.Atoi();
168 int index=equipment-AliDAQ::DdlIDOffset("HLT");
169 if (index>=0 && strcmp(br->GetName(), AliDAQ::DdlFileName("HLT", index))==0) {
170 equipments.push_back(equipment);
172 HLTWarning("equipment mismatch: skipping id %d (out of range of HLT equipments)", equipment);
177 HLTDebug("found %d HLT branche(s) out of %d", equipments.size(), iTotal);
179 if (equipments.size()>0) {
180 fNofDDLs=equipments.size();
181 fpEquipments=new int[fNofDDLs];
182 fppDigitArrays=new TArrayC*[fNofDDLs];
183 if (fpEquipments && fppDigitArrays) {
184 memcpy(fpEquipments, &equipments[0], fNofDDLs*sizeof(int));
186 for (i=0; i<fNofDDLs; i++) {
187 fppDigitArrays[i]=NULL;
188 fpDigitTree->SetBranchAddress(AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), &fppDigitArrays[i]);
190 fpDigitTree->GetEvent(GetCurrentEventNo());
191 for (i=0; i<fNofDDLs; i++) {
192 if (fppDigitArrays[i]) {
193 HLTDebug("branch %s: %d byte(s)", AliDAQ::DdlFileName("HLT", fpEquipments[i]-AliDAQ::DdlIDOffset("HLT")), fppDigitArrays[i]);
204 int AliHLTOUTDigitReader::CloseTree()
206 // see header file for class documentation
208 if (fppDigitArrays) delete[] fppDigitArrays;
210 if (fpEquipments) delete[] fpEquipments;
212 if (fpDigitTree) delete fpDigitTree;
220 void AliHLTOUTDigitReader::SetParam(TTree* /*pDigitTree*/, int event)
222 // see header file for class documentation
224 // TODO: here we have the implemented to correct loading of
225 // the digit file from the run loader. At time of writing
226 // (Jun 2008) the AliLoader for the HLT is missing in the AliRoot
231 void AliHLTOUTDigitReader::SetParam(const char* filename, int event)
233 // see header file for class documentation
235 if (filename && filename[0]!=0) {
236 fDigitFileName=filename;
238 HLTWarning("no valid digit file provided, using default file %s", fDigitFileName.Data());