]>
Commit | Line | Data |
---|---|---|
12ec5482 | 1 | // $Id: AliHLTCompPreprocessor.cxx 23039 2007-12-13 20:53:02Z richterm $ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* Jenny Wagner * | |
9 | //* for The ALICE HLT Project. * | |
10 | //* * | |
11 | //* Permission to use, copy, modify and distribute this software and its * | |
12 | //* documentation strictly for non-commercial purposes is hereby granted * | |
13 | //* without fee, provided that the above copyright notice appears in all * | |
14 | //* copies and that both the copyright notice and this permission notice * | |
15 | //* appear in the supporting documentation. The authors make no claims * | |
16 | //* about the suitability of this software for any purpose. It is * | |
17 | //* provided "as is" without express or implied warranty. * | |
18 | //************************************************************************** | |
19 | ||
20 | /** | |
21 | * @file AliHLTCompPreprocessor.cxx | |
22 | * @author Jenny Wagner, Matthias Richter | |
23 | * @brief Implementation of the HLT preprocessor for the AliHLTComp library | |
24 | */ | |
25 | ||
26 | #include "AliHLTCompPreprocessor.h" | |
27 | #include "AliCDBMetaData.h" | |
28 | #include "AliPreprocessor.h" | |
29 | #include "TObjString.h" | |
30 | #include "TString.h" | |
31 | #include "TList.h" | |
32 | #include "TFile.h" | |
33 | ||
34 | // necessary for huffman table to get information about the origin | |
35 | #include "AliHLTCOMPHuffmanData.h" | |
36 | ||
37 | ClassImp(AliHLTCompPreprocessor) | |
38 | ||
39 | AliHLTCompPreprocessor::AliHLTCompPreprocessor() | |
40 | { | |
41 | // see header file for class documentation | |
42 | // or | |
43 | // refer to README to build package | |
44 | // or | |
45 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
46 | } | |
47 | ||
48 | const char* AliHLTCompPreprocessor::fgkHuffmanFileId = "HuffmanData"; | |
49 | ||
50 | AliHLTCompPreprocessor::~AliHLTCompPreprocessor() | |
51 | { | |
52 | // see header file for function documentation | |
53 | } | |
54 | ||
55 | void AliHLTCompPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
56 | UInt_t endTime) | |
57 | { | |
58 | // see header file for function documentation | |
59 | } | |
60 | ||
61 | ||
62 | UInt_t AliHLTCompPreprocessor::Process(TMap* dcsAliasMap) | |
63 | { | |
64 | // see header file for function documentation | |
65 | UInt_t retVal = 0; | |
66 | ||
67 | if (GetHuffmanTables() != 0) { | |
68 | // unable to fetch Huffman tables | |
69 | retVal = 1; | |
70 | // but if set to 1, then also file from GetTempHisto won't be saved !!! | |
71 | } | |
72 | ||
73 | return retVal; | |
74 | } | |
75 | ||
76 | UInt_t AliHLTCompPreprocessor::GetHuffmanTables() | |
77 | { | |
78 | // see header file for function documentation | |
79 | ||
80 | UInt_t retVal = 0; | |
81 | ||
82 | // get all huffman tables stored at FXS | |
83 | TList* HuffmanList = GetFileSources(AliPreprocessor::kHLT, fgkHuffmanFileId); | |
84 | // -> list of all DDL numbers that own a huffman table | |
85 | ||
86 | // if no huffman tables are produced, return 0 (successful end --> test if TPC, PHOS are used in current run!) | |
87 | // --> still open to be implemented! | |
88 | // if there is an error getting the sources return 1 | |
89 | // else produce containers for each detector to be stored in the OCDB | |
90 | if (!HuffmanList) | |
91 | { | |
92 | Log("No Huffman code tables for HLT"); | |
93 | return 1; | |
94 | } | |
95 | ||
96 | TList* TPCHuffmanList = new TList(); | |
97 | TList* PHOSHuffmanList = new TList(); | |
98 | ||
99 | // loop over all DDL numbers and put huffman tables into special containers | |
100 | // (one for each detector) | |
101 | for(Int_t ii=0; ii < HuffmanList->GetEntries(); ii++) | |
102 | { | |
103 | // get huffman table | |
104 | TObjString *objstr = (TObjString*) HuffmanList->At(ii); | |
105 | ||
106 | if(objstr == 0) // should not happen?! | |
107 | { | |
108 | char logging[1000]; | |
109 | sprintf(logging, "Error in Huffmanlist, no DDL at position %d", ii); | |
110 | Log(logging); | |
111 | continue; | |
112 | } | |
113 | ||
114 | TString fileName = GetFile(AliPreprocessor::kHLT, "HuffmanData", objstr->GetName()); | |
115 | ||
116 | if (!(fileName.Length() > 0)) // error if local path/filename is not defined | |
117 | { | |
118 | Log("Local file for current Huffman table is not properly defined."); | |
119 | return 1; | |
120 | } | |
121 | ||
122 | TFile* currenthuffmanfile = new TFile(fileName, "READ"); | |
123 | ||
124 | // if current huffman table file does not contain a table, return an error | |
125 | if ( currenthuffmanfile->Get("fHuffmanData") == NULL) | |
126 | { | |
127 | char logging[1000]; | |
128 | sprintf(logging,"Local file %s does not contain a Huffman code table.", fileName.Data()); | |
129 | Log(logging); | |
130 | //retVal = 1; // retVal must be zero to give other functions a chance to read their data | |
131 | retVal = 0; | |
132 | } | |
133 | ||
134 | TObject* huffmandata = (TObject*) currenthuffmanfile->Get("fHuffmanData"); | |
135 | AliHLTCOMPHuffmanData* currenthuffmandata = (AliHLTCOMPHuffmanData*) huffmandata; | |
136 | ||
137 | // specifications necessary for sorting process | |
138 | TString detectororigin = "";//currenthuffmandata->GetOrigin(); | |
139 | Int_t tablespec = 0;//currenthuffmandata->GetDataSpec(); | |
140 | ||
141 | ||
142 | // plug them into a container: | |
143 | if(detectororigin == "PHOS") // belongs to PHOS table (one one!) | |
144 | { | |
145 | PHOSHuffmanList->AddFirst(huffmandata); | |
146 | ||
147 | if(PHOSHuffmanList->GetEntries() > 1) | |
148 | { | |
149 | Log("More than one table available for PHOS."); | |
150 | // return: warning but go on... | |
151 | } | |
152 | } | |
153 | else | |
154 | { | |
155 | if(detectororigin == "TPC ") // belongs to TPC tables (six) | |
156 | { | |
157 | if(tablespec < 6) | |
158 | { | |
159 | TPCHuffmanList->Add(huffmandata); | |
160 | ||
161 | if(TPCHuffmanList->GetEntries() > 6) | |
162 | { | |
163 | Log("More than six tables available for TPC."); | |
164 | // return warning but go on... | |
165 | } | |
166 | } | |
167 | else | |
168 | { | |
169 | char logging[1000]; | |
170 | sprintf(logging, "Read data specification %d from Huffman table too large to belong to TPC.", tablespec); | |
171 | Log(logging); | |
172 | // retVal = 1; // retVal must be zero to give other functions a chance to read their data | |
173 | retVal = 0; | |
174 | } | |
175 | } | |
176 | else // error! | |
177 | { | |
178 | char logging[1000]; | |
179 | sprintf(logging, "Specified detector pattern %s does not define a valid detector.", detectororigin.Data()); | |
180 | Log(logging); | |
181 | // retVal = 1; // retVal must be zero to give other functions a chance to read their data | |
182 | retVal = 0; | |
183 | } | |
184 | } | |
185 | ||
186 | ||
187 | } // end loop over all DDLs | |
188 | ||
189 | ||
190 | // after loop all containers are filled and can be stored in OCDB | |
191 | AliCDBMetaData meta("Jenny Wagner"); | |
192 | ||
193 | if (!(Store("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta, 0, kTRUE))) | |
194 | { | |
195 | ||
196 | Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to OCDB failed."); | |
197 | ||
198 | if (!(StoreReferenceData("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta))) | |
199 | { | |
200 | Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to reference storage failed."); | |
201 | ||
202 | retVal = 1; | |
203 | } | |
204 | } | |
205 | ||
206 | if (!(Store("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta, 0, kTRUE))) | |
207 | { | |
208 | ||
209 | Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to OCDB failed."); | |
210 | ||
211 | if (!(StoreReferenceData("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta))) | |
212 | { | |
213 | Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to reference storage failed."); | |
214 | ||
215 | retVal = 1; | |
216 | } | |
217 | } | |
218 | ||
219 | return retVal; | |
220 | } |