1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
21 * \file DumpGlobalTrigger.C
22 * \brief Macro for dumping HLT global trigger decisions.
24 * This macro is used to dump to screen the HLT global trigger decisions encoded
25 * in AliHLTGlobalTriggerDecision objects found in the HLT raw data. The raw data
26 * should be packed in a ROOT or DATE file, or in DDL data files in raw*
27 * directories. An appropriate AliRawReader is created to read the data.
29 * The simplest way to run this macro with defaults is to run the following
30 * command from a terminal shell:
32 * > aliroot -b -q $ALICE_ROOT/HLT/trigger/macros/DumpGlobalTrigger.C
35 * \author Artur Szostak <artursz@iafrica.com>
38 #if !defined(__CINT__) || defined(__MAKECINT__)
39 #include "AliRawReader.h"
40 #include "AliHLTPluginBase.h"
41 #include "AliHLTOUT.h"
42 #include "AliHLTSystem.h"
43 #include "AliHLTComponent.h"
47 #include "Riostream.h"
51 * Dumps the AliHLTGlobalTriggerDecision objects found in HLT output data.
53 * \param dataSource This is the path to the raw data or the ROOT/DATE file
54 * contining the raw data. (default is the current directory).
55 * \param firstEvent The event number of the first event to process. (default = 0)
56 * \param lastEvent The event number of the last event to process. If this is
57 * less than firstEvent then it is set to maximum events available
58 * automatically. (default = -1)
59 * \param output Specifies the name of a ROOT output file. This file will be
60 * generated and the objects written to it. If the value is NULL then
61 * no output is written to file. (default = NULL)
62 * \param debug Specifies if full debug messages should be printed.
64 void DumpGlobalTrigger(
65 const char* dataSource = "./",
68 const char* output = NULL,
74 AliLog::SetModuleDebugLevel("HLT", AliLog::kMaxType);
75 AliHLTSystem* sys = AliHLTPluginBase::GetInstance();
76 sys->SetGlobalLoggingLevel(kHLTLogAll);
79 gSystem->Load("libHLTrec");
83 file = new TFile(output, "RECREATE");
86 cerr << "ERROR: Could not create file '" << output << "'." << endl;
91 // Setup the raw reader and HLTOUT handler.
92 AliRawReader* rawReader = AliRawReader::Create(dataSource);
93 if (rawReader == NULL)
95 cerr << "ERROR: Could not create raw reader for '" << dataSource << "'." << endl;
96 if (file != NULL) delete file;
99 if (! rawReader->IsRawReaderValid())
101 cerr << "ERROR: Raw reader is not valid for '" << dataSource << "'." << endl;
103 if (file != NULL) delete file;
106 AliHLTOUT* hltout = AliHLTOUT::New(rawReader);
109 cerr << "ERROR: Could not create an AliHLTOUT object for '" << dataSource << "'." << endl;
111 if (file != NULL) delete file;
115 // Make sure that the lastEvent is greater than firstEvent.
116 if (lastEvent < firstEvent) lastEvent = rawReader->GetNumberOfEvents();
117 if (lastEvent < firstEvent) lastEvent = firstEvent;
119 // Need to call NextEvent once here or we will start at the wrong event.
120 if (! rawReader->NextEvent())
122 cout << "No events found in '" << dataSource << "'." << endl;
123 AliHLTOUT::Delete(hltout);
125 if (file != NULL) delete file;
129 // Now step through the events.
130 for (int i = 0; i < firstEvent; i++) rawReader->NextEvent();
131 for (int i = firstEvent; i <= lastEvent; i++)
133 int result = hltout->Init();
136 cerr << "ERROR: could not initialise HLTOUT." << endl;
140 cout << "#################### Event " << i << " in " << dataSource
141 << " has event ID = " << hltout->EventId()
142 << " (0x" << hex << hltout->EventId() << dec << ")"
143 << " ####################" << endl;
145 for (result = hltout->SelectFirstDataBlock();
147 result = hltout->SelectNextDataBlock()
150 AliHLTComponentDataType dt;
151 AliHLTUInt32_t spec = 0;
152 hltout->GetDataBlockDescription(dt, spec);
153 TObject* obj = hltout->GetDataObject();
154 if (obj == NULL) continue;
155 if (obj->IsA()->GetBaseClass("AliHLTGlobalTriggerDecision") != NULL)
157 if (dt != kAliHLTDataTypeGlobalTrigger)
159 cerr << "WARNING: Found an AliHLTGlobalTriggerDecision object in a data block of type '"
160 << AliHLTComponent::DataType2Text(dt).c_str()
161 << "' but expected '"
162 << AliHLTComponent::DataType2Text(kAliHLTDataTypeGlobalTrigger).c_str()
168 Form("HLTGlobalDecision_event_0x%llX", hltout->EventId()),
174 hltout->ReleaseDataObject(obj);
177 result = hltout->Reset();
180 cerr << "ERROR: could not reset HLTOUT." << endl;
184 rawReader->NextEvent();
187 AliHLTOUT::Delete(hltout);
189 if (file != NULL) delete file;