]>
Commit | Line | Data |
---|---|---|
95c928d2 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
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 | **************************************************************************/ | |
16 | ||
17 | // $Id: $ | |
18 | ||
19 | /** | |
20 | * \ingroup macros | |
21 | * \file DumpGlobalTrigger.C | |
22 | * \brief Macro for dumping HLT global trigger decisions. | |
23 | * | |
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. | |
28 | * | |
29 | * The simplest way to run this macro with defaults is to run the following | |
30 | * command from a terminal shell: | |
31 | * \code | |
32 | * > aliroot -b -q $ALICE_ROOT/HLT/trigger/macros/DumpGlobalTrigger.C | |
33 | * \endcode | |
34 | * | |
35 | * \author Artur Szostak <artursz@iafrica.com> | |
36 | */ | |
37 | ||
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" | |
44 | #include "AliLog.h" | |
45 | #include "TSystem.h" | |
46 | #include "TFile.h" | |
47 | #include "Riostream.h" | |
48 | #endif | |
49 | ||
50 | /** | |
51 | * Dumps the AliHLTGlobalTriggerDecision objects found in HLT output data. | |
52 | * | |
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. | |
63 | */ | |
64 | void DumpGlobalTrigger( | |
65 | const char* dataSource = "./", | |
66 | Int_t firstEvent = 0, | |
67 | Int_t lastEvent = -1, | |
68 | const char* output = NULL, | |
69 | bool debug = false | |
70 | ) | |
71 | { | |
72 | if (debug) | |
73 | { | |
74 | AliLog::SetModuleDebugLevel("HLT", AliLog::kMaxType); | |
75 | AliHLTSystem* sys = AliHLTPluginBase::GetInstance(); | |
76 | sys->SetGlobalLoggingLevel(kHLTLogAll); | |
77 | } | |
78 | ||
4070f709 | 79 | gSystem->Load("libHLTrec"); |
95c928d2 | 80 | TFile* file = NULL; |
81 | if (output != NULL) | |
82 | { | |
83 | file = new TFile(output, "RECREATE"); | |
84 | if (file == NULL) | |
85 | { | |
86 | cerr << "ERROR: Could not create file '" << output << "'." << endl; | |
87 | return; | |
88 | } | |
89 | } | |
90 | ||
91 | // Setup the raw reader and HLTOUT handler. | |
92 | AliRawReader* rawReader = AliRawReader::Create(dataSource); | |
93 | if (rawReader == NULL) | |
94 | { | |
95 | cerr << "ERROR: Could not create raw reader for '" << dataSource << "'." << endl; | |
96 | if (file != NULL) delete file; | |
97 | return; | |
98 | } | |
99 | if (! rawReader->IsRawReaderValid()) | |
100 | { | |
101 | cerr << "ERROR: Raw reader is not valid for '" << dataSource << "'." << endl; | |
102 | delete rawReader; | |
103 | if (file != NULL) delete file; | |
104 | return; | |
105 | } | |
106 | AliHLTOUT* hltout = AliHLTOUT::New(rawReader); | |
107 | if (hltout == NULL) | |
108 | { | |
109 | cerr << "ERROR: Could not create an AliHLTOUT object for '" << dataSource << "'." << endl; | |
110 | delete rawReader; | |
111 | if (file != NULL) delete file; | |
112 | return; | |
113 | } | |
114 | ||
115 | // Make sure that the lastEvent is greater than firstEvent. | |
116 | if (lastEvent < firstEvent) lastEvent = rawReader->GetNumberOfEvents(); | |
117 | if (lastEvent < firstEvent) lastEvent = firstEvent; | |
118 | ||
119 | // Need to call NextEvent once here or we will start at the wrong event. | |
120 | if (! rawReader->NextEvent()) | |
121 | { | |
122 | cout << "No events found in '" << dataSource << "'." << endl; | |
123 | AliHLTOUT::Delete(hltout); | |
124 | delete rawReader; | |
125 | if (file != NULL) delete file; | |
126 | return; | |
127 | } | |
128 | ||
129 | // Now step through the events. | |
130 | for (int i = 0; i < firstEvent; i++) rawReader->NextEvent(); | |
131 | for (int i = firstEvent; i <= lastEvent; i++) | |
132 | { | |
133 | int result = hltout->Init(); | |
134 | if (result != 0) | |
135 | { | |
136 | cerr << "ERROR: could not initialise HLTOUT." << endl; | |
137 | hltout->Reset(); | |
138 | continue; | |
139 | } | |
140 | cout << "#################### Event " << i << " in " << dataSource | |
141 | << " has event ID = " << hltout->EventId() | |
142 | << " (0x" << hex << hltout->EventId() << dec << ")" | |
143 | << " ####################" << endl; | |
144 | ||
145 | for (result = hltout->SelectFirstDataBlock(); | |
146 | result >= 0; | |
147 | result = hltout->SelectNextDataBlock() | |
148 | ) | |
149 | { | |
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) | |
156 | { | |
157 | if (dt != kAliHLTDataTypeGlobalTrigger) | |
158 | { | |
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() | |
163 | << "'." << endl; | |
164 | } | |
165 | if (file != NULL) | |
166 | { | |
167 | obj->Write( | |
168 | Form("HLTGlobalDecision_event_0x%llX", hltout->EventId()), | |
169 | TObject::kOverwrite | |
170 | ); | |
171 | } | |
172 | obj->Print(); | |
173 | } | |
174 | hltout->ReleaseDataObject(obj); | |
175 | } | |
176 | ||
177 | result = hltout->Reset(); | |
178 | if (result != 0) | |
179 | { | |
180 | cerr << "ERROR: could not reset HLTOUT." << endl; | |
181 | hltout->Reset(); | |
182 | continue; | |
183 | } | |
184 | rawReader->NextEvent(); | |
185 | } | |
186 | ||
187 | AliHLTOUT::Delete(hltout); | |
188 | delete rawReader; | |
189 | if (file != NULL) delete file; | |
190 | } |