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: Artur Szostak <artursz@iafrica.com> *
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 testAliHLTEventDDLBackwardCompatibility.C
20 /// @author Artur Szostak <artursz@iafrica.com>
21 /// @date 25 June 2010
22 /// @brief Test program for backward compatibility of the AliHLTEventDDL structure.
25 #if defined(__CINT__) && (! defined(__MAKECINT__))
26 #error This macro must be compiled. Try running as testAliHLTEventDDLBackwardCompatibility.C++.
29 #if !defined(__CINT__) || defined(__MAKECINT__)
30 #include "AliHLTDataTypes.h"
31 #include "AliHLTReadoutList.h"
32 #include "AliHLTDAQ.h"
37 #include "Riostream.h"
43 * Tests to see if the AliHLTReadoutList class handles both AliHLTEventDDLV0
44 * and AliHLTEventDDLV1 correctly.
46 bool CheckReadoutListConvertedCorrectly()
48 // Initialise the different versions of the structures so that every detector
49 // has only its first DDL set.
52 AliHLTEventDDL eventddlV0;
53 AliHLTEventDDLV0 bitsV0;
55 bitsV0.fCount = gkAliHLTDDLListSizeV0;
56 if (gkAliHLTDDLListSizeV0 != 30)
58 cerr << "ERROR: gkAliHLTDDLListSizeV0 has a value of " << gkAliHLTDDLListSizeV0
59 << " but expected a value of 30." << endl;
62 bitsV0.fList[0] = 0x00000001; // kITSSPD
63 bitsV0.fList[1] = 0x00000001; // kITSSDD
64 bitsV0.fList[2] = 0x00000001; // kITSSSD
65 bitsV0.fList[3] = 0x00000001; // kTPC
66 bitsV0.fList[4] = 0x00000000; // kTPC
67 bitsV0.fList[5] = 0x00000000; // kTPC
68 bitsV0.fList[6] = 0x00000000; // kTPC
69 bitsV0.fList[7] = 0x00000000; // kTPC
70 bitsV0.fList[8] = 0x00000000; // kTPC
71 bitsV0.fList[9] = 0x00000000; // kTPC
72 bitsV0.fList[10] = 0x00000000; // kTPC
73 bitsV0.fList[11] = 0x00000001; // kTRD
74 bitsV0.fList[12] = 0x00000001; // kTOF
75 bitsV0.fList[13] = 0x00000000; // kTOF
76 bitsV0.fList[14] = 0x00000000; // kTOF
77 bitsV0.fList[15] = 0x00000001; // kHMPID
78 bitsV0.fList[16] = 0x00000001; // kPHOS
79 bitsV0.fList[17] = 0x00000001; // kCPV
80 bitsV0.fList[18] = 0x00000001; // kPMD
81 bitsV0.fList[19] = 0x00000001; // kMUONTRK
82 bitsV0.fList[20] = 0x00000001; // kMUONTRG
83 bitsV0.fList[21] = 0x00000001; // kFMD
84 bitsV0.fList[22] = 0x00000001; // kT0
85 bitsV0.fList[23] = 0x00000001; // kV0
86 bitsV0.fList[24] = 0x00000001; // kZDC
87 bitsV0.fList[25] = 0x00000001; // kACORDE
88 bitsV0.fList[26] = 0x00000001; // kTRG
89 bitsV0.fList[27] = 0x00000001; // kEMCAL
90 bitsV0.fList[28] = 0x00000001; // kDAQTEST
91 bitsV0.fList[29] = 0x00000001; // kHLT
95 AliHLTEventDDL eventddlV1;
96 AliHLTEventDDLV1 bitsV1;
98 bitsV1.fCount = gkAliHLTDDLListSizeV1;
99 if (gkAliHLTDDLListSizeV1 != 31)
101 cerr << "ERROR: gkAliHLTDDLListSizeV1 has a value of " << gkAliHLTDDLListSizeV1
102 << " but expected a value of 31." << endl;
105 bitsV1.fList[0] = 0x00000001; // kITSSPD
106 bitsV1.fList[1] = 0x00000001; // kITSSDD
107 bitsV1.fList[2] = 0x00000001; // kITSSSD
108 bitsV1.fList[3] = 0x00000001; // kTPC
109 bitsV1.fList[4] = 0x00000000; // kTPC
110 bitsV1.fList[5] = 0x00000000; // kTPC
111 bitsV1.fList[6] = 0x00000000; // kTPC
112 bitsV1.fList[7] = 0x00000000; // kTPC
113 bitsV1.fList[8] = 0x00000000; // kTPC
114 bitsV1.fList[9] = 0x00000000; // kTPC
115 bitsV1.fList[10] = 0x00000000; // kTPC
116 bitsV1.fList[11] = 0x00000001; // kTRD
117 bitsV1.fList[12] = 0x00000001; // kTOF
118 bitsV1.fList[13] = 0x00000000; // kTOF
119 bitsV1.fList[14] = 0x00000000; // kTOF
120 bitsV1.fList[15] = 0x00000001; // kHMPID
121 bitsV1.fList[16] = 0x00000001; // kPHOS
122 bitsV1.fList[17] = 0x00000001; // kCPV
123 bitsV1.fList[18] = 0x00000001; // kPMD
124 bitsV1.fList[19] = 0x00000001; // kMUONTRK
125 bitsV1.fList[20] = 0x00000001; // kMUONTRG
126 bitsV1.fList[21] = 0x00000001; // kFMD
127 bitsV1.fList[22] = 0x00000001; // kT0
128 bitsV1.fList[23] = 0x00000001; // kV0
129 bitsV1.fList[24] = 0x00000001; // kZDC
130 bitsV1.fList[25] = 0x00000001; // kACORDE
131 bitsV1.fList[26] = 0x00000001; // kTRG
132 bitsV1.fList[27] = 0x00000001; // kEMCAL
133 bitsV1.fList[28] = 0x00000000; // kEMCAL
134 bitsV1.fList[29] = 0x00000001; // kDAQTEST
135 bitsV1.fList[30] = 0x00000001; // kHLT
137 AliHLTReadoutList rlV0(eventddlV0);
138 AliHLTReadoutList rlV1(eventddlV1);
140 // Check that for both readout list versions only the first DDLs are
141 // enabled as expected.
142 for (Int_t i = 0; i < AliHLTDAQ::NumberOfDetectors(); ++i)
143 for (Int_t j = 0; j < AliHLTDAQ::NumberOfDdls(i); ++j)
145 Int_t ddlid = AliHLTDAQ::DdlIDOffset(i) | (j & 0xFF);
148 if (rlV0.IsDDLDisabled(ddlid))
150 cerr << "ERROR: The first DDL for detector " << AliHLTDAQ::DetectorName(i)
151 << " was not enabled for readout list initialised from AliHLTEventDDLV0."
155 if (rlV1.IsDDLDisabled(ddlid))
157 cerr << "ERROR: The first DDL for detector " << AliHLTDAQ::DetectorName(i)
158 << " was not enabled for readout list initialised from AliHLTEventDDLV1."
165 if (rlV0.IsDDLEnabled(ddlid))
167 cerr << "ERROR: DDL " << ddlid << " for detector " << AliHLTDAQ::DetectorName(i)
168 << " was marked enabled for readout list initialised from AliHLTEventDDLV0."
172 if (rlV1.IsDDLEnabled(ddlid))
174 cerr << "ERROR: DDL " << ddlid << " for detector " << AliHLTDAQ::DetectorName(i)
175 << " was marked enabled for readout list initialised from AliHLTEventDDLV1."
182 // Check that the internal buffers are identical.
183 if (rlV0.BufferSize() != rlV1.BufferSize())
185 cerr << "ERROR: Buffer sizes for readout lists are different: rlV0.BufferSize() = "
186 << rlV0.BufferSize() << ", rlV1.BufferSize() = " << rlV1.BufferSize() << endl;
189 if (memcmp(rlV0.Buffer(), rlV1.Buffer(), rlV0.BufferSize()) != 0)
191 cerr << "ERROR: Buffers for the two readout list versions are different." << endl;
199 * Tests to see if reading old AliHLTReadoutList versions from root files works.
200 * \param filename The name of the file generated by GenerateReadoutListFile.C,
201 * which contains the readout list objects to test.
203 bool CheckReadingOldFormat(const char* filename = "oldAliHLTReadoutListFormat.root")
205 TFile file(filename, "READ");
207 // Load the readout list objects.
208 AliHLTReadoutList* rl[5] = {NULL, NULL, NULL, NULL, NULL};
209 for (int i = 0; i < 5; ++i)
212 sprintf(name, "readoutlist%d", i+1);
213 rl[i] = dynamic_cast<AliHLTReadoutList*>(file.Get(name));
216 cerr << "ERROR: Could not get object '" << name
217 << "' from file '" << filename << "'." << endl;
222 // Now load the tree and see that the objects are the same as the readout
223 // list objects stored directly to the TFile.
224 const char* treename = "rltree";
225 TTree* tree = dynamic_cast<TTree*>(file.Get(treename));
228 cerr << "ERROR: Could not get TTree '" << treename
229 << "' from file '" << filename << "'." << endl;
232 AliHLTReadoutList* r = new AliHLTReadoutList;
233 tree->SetBranchAddress("readoutlist", &r);
234 for (int i = 0; i < 5; ++i)
237 if (r->BufferSize() != rl[i]->BufferSize())
239 cerr << "ERROR: readoutlist" << i+1
240 << " and the one from the TTree have different sizes."
244 if (memcmp(r->Buffer(), rl[i]->Buffer(), r->BufferSize()) != 0)
246 cerr << "ERROR: readoutlist" << i+1
247 << " and the one from the TTree are different."
253 // Now check each readout list individually.
254 typedef AliHLTReadoutList RL;
255 Int_t alwaysoff = RL::kITSSPD
273 // We will need to try and set the missing EMCAL DDL bits.
274 // Otherwise the DetectorEnabled and DetectorDisabled methods will not
275 // give the expected answers.
276 for (int i = 24; i < AliHLTDAQ::NumberOfDdls("EMCAL"); ++i)
278 for (int j = 1; j <= 3; ++j)
280 Int_t ddlid = AliHLTDAQ::DdlIDOffset("EMCAL") | (i & 0xFF);
281 rl[j]->EnableDDLBit(ddlid);
286 if (not (rl[rlnum]->DetectorEnabled(RL::kTRG) and
287 rl[rlnum]->DetectorDisabled(alwaysoff | RL::kEMCAL | RL::kDAQTEST | RL::kHLT)
291 cerr << "ERROR: readoutlist" << rlnum+1 << " does not have the correct bits set." << endl;
296 if (not (rl[rlnum]->DetectorEnabled(RL::kTRG | RL::kEMCAL) and
297 rl[rlnum]->DetectorDisabled(alwaysoff | RL::kDAQTEST | RL::kHLT)
300 cerr << "ERROR: readoutlist" << rlnum+1 << " does not have the correct bits set." << endl;
305 if (not (rl[rlnum]->DetectorEnabled(RL::kTRG | RL::kEMCAL | RL::kDAQTEST) and
306 rl[rlnum]->DetectorDisabled(alwaysoff | RL::kHLT)
309 cerr << "ERROR: readoutlist" << rlnum+1 << " does not have the correct bits set." << endl;
314 if (not (rl[rlnum]->DetectorEnabled(RL::kTRG | RL::kEMCAL | RL::kDAQTEST | RL::kHLT) and
315 rl[rlnum]->DetectorDisabled(alwaysoff)
318 cerr << "ERROR: readoutlist" << rlnum+1 << " does not have the correct bits set." << endl;
323 if (not (rl[rlnum]->DetectorEnabled(RL::kTRG | RL::kDAQTEST | RL::kHLT) and
324 rl[rlnum]->DetectorDisabled(alwaysoff | RL::kEMCAL)
327 cerr << "ERROR: readoutlist" << rlnum+1 << " does not have the correct bits set." << endl;
336 * Runs the unit tests for backward compatibility of AliHLTEventDDL succeeded.
337 * \returns true if the tests were passed and false otherwise.
339 bool testAliHLTEventDDLBackwardCompatibility()
341 if (not CheckReadoutListConvertedCorrectly()) return false;
342 if (not CheckReadingOldFormat()) return false;
348 int main(int /*argc*/, const char** /*argv*/)
350 bool resultOk = testAliHLTEventDDLBackwardCompatibility();
351 if (not resultOk) return 1;
355 #endif // __MAKECINT__