1 // $Id: AliHLTCompPreprocessor.cxx 23039 2007-12-13 20:53:02Z richterm $
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> *
9 //* for The ALICE HLT Project. *
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 //**************************************************************************
21 * @file AliHLTCompPreprocessor.cxx
22 * @author Jenny Wagner, Matthias Richter
23 * @brief Implementation of the HLT preprocessor for the AliHLTComp library
26 #include "AliHLTCompPreprocessor.h"
27 #include "AliCDBMetaData.h"
28 #include "AliPreprocessor.h"
29 #include "TObjString.h"
34 // necessary for huffman table to get information about the origin
35 #include "AliHLTCOMPHuffmanData.h"
37 ClassImp(AliHLTCompPreprocessor)
39 AliHLTCompPreprocessor::AliHLTCompPreprocessor() :
43 // see header file for class documentation
45 // refer to README to build package
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50 const char* AliHLTCompPreprocessor::fgkHuffmanFileId = "HuffmanData";
52 AliHLTCompPreprocessor::~AliHLTCompPreprocessor()
54 // see header file for function documentation
57 void AliHLTCompPreprocessor::Initialize(Int_t /*run*/, UInt_t /*startTime*/,
60 // see header file for function documentation
61 fTPCactive = AliHLTModulePreprocessor::GetDetectorStatus(AliHLTModulePreprocessor::DetectorBitMask("TPC"));
62 fPHOSactive = AliHLTModulePreprocessor::GetDetectorStatus(AliHLTModulePreprocessor::DetectorBitMask("PHOS"));
67 UInt_t AliHLTCompPreprocessor::Process(TMap* /*dcsAliasMap*/)
69 // see header file for function documentation
72 // error if preprocessor states that TPC or PHOS were active but both are inactive here!
73 if( !(fTPCactive || fPHOSactive) )
75 Log("Neither TPC nor PHOS active in current run!");
79 // else there must be Huffman tables:
80 if (GetHuffmanTables() != 0) {
81 // unable to fetch Huffman tables
88 UInt_t AliHLTCompPreprocessor::GetHuffmanTables()
90 // see header file for function documentation
94 // get all huffman tables stored at FXS
95 TList* HuffmanList = GetFileSources(AliPreprocessor::kHLT, fgkHuffmanFileId);
96 // -> list of all DDL numbers that own a huffman table
98 // if there is no Huffman code table for a calib run, return error!
99 // else produce containers for each detector to be stored in the OCDB
102 Log("No Huffman code tables for HLT");
106 TList* TPCHuffmanList;
107 TList* PHOSHuffmanList;
111 TPCHuffmanList = new TList();
116 PHOSHuffmanList = new TList();
120 // loop over all DDL numbers and put huffman tables into special containers
121 // (one for each detector)
122 for(Int_t ii=0; ii < HuffmanList->GetEntries(); ii++)
125 TObjString *objstr = (TObjString*) HuffmanList->At(ii);
127 if(objstr == 0) // should not happen?!
130 sprintf(logging, "Error in Huffmanlist, no DDL at position %d", ii);
135 TString fileName = GetFile(AliPreprocessor::kHLT, "HuffmanData", objstr->GetName());
137 if (!(fileName.Length() > 0)) // error if local path/filename is not defined
139 Log("Local file for current Huffman table is not properly defined.");
143 TFile* currenthuffmanfile = new TFile(fileName, "READ");
145 // if current huffman table file does not contain a table, return an error
146 if ( currenthuffmanfile->Get("fHuffmanData") == NULL)
149 sprintf(logging,"Local file %s does not contain a Huffman code table.", fileName.Data());
151 //retVal = 1; // retVal must be zero to give other functions a chance to read their data
155 TObject* huffmandata = (TObject*) currenthuffmanfile->Get("fHuffmanData");
156 // class object not needed since container uses TObjects!
157 //AliHLTCOMPHuffmanData* currenthuffmandata = (AliHLTCOMPHuffmanData*) huffmandata;
159 // specifications necessary for sorting process
160 TString detectororigin = "";//currenthuffmandata->GetOrigin();
161 Int_t tablespec = 0;//currenthuffmandata->GetDataSpec();
164 // plug them into a container:
165 if(detectororigin == "PHOS") // belongs to PHOS table (one one!)
169 Log("PHOS Huffman code table retrieved although PHOS detector was not active!");
173 PHOSHuffmanList->AddFirst(huffmandata);
175 if(PHOSHuffmanList->GetEntries() > 1)
177 Log("More than one table available for PHOS.");
178 // return: warning but go on...
183 if(detectororigin == "TPC ") // belongs to TPC tables (six)
188 Log("TPC Huffman code table retrieved although TPC detector was not active!");
194 TPCHuffmanList->Add(huffmandata);
196 if(TPCHuffmanList->GetEntries() > 6)
198 Log("More than six tables available for TPC.");
199 // return warning but go on...
205 sprintf(logging, "Read data specification %d from Huffman table too large to belong to TPC.", tablespec);
207 // retVal = 1; // retVal must be zero to give other functions a chance to read their data
214 sprintf(logging, "Specified detector pattern %s does not define a valid detector.", detectororigin.Data());
216 retVal = 1; // retVal must be zero to give other functions a chance to read their data
222 } // end loop over all DDLs
225 // after loop all containers are filled and can be stored in OCDB
226 AliCDBMetaData meta("Jenny Wagner");
230 if (!(Store("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta, 0, kTRUE)))
233 Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to OCDB failed.");
235 if (!(StoreReferenceData("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta)))
237 Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to reference storage failed.");
246 if (!(Store("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta, 0, kTRUE)))
249 Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to OCDB failed.");
251 if (!(StoreReferenceData("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta)))
253 Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to reference storage failed.");