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 "TObjString.h"
33 // necessary for huffman table to get information about the origin
34 #include "AliHLTCOMPHuffmanData.h"
36 ClassImp(AliHLTCompPreprocessor)
38 AliHLTCompPreprocessor::AliHLTCompPreprocessor() :
42 // see header file for class documentation
44 // refer to README to build package
46 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 const char* AliHLTCompPreprocessor::fgkHuffmanFileId = "HuffmanData";
51 AliHLTCompPreprocessor::~AliHLTCompPreprocessor()
53 // see header file for function documentation
56 void AliHLTCompPreprocessor::Initialize(Int_t /*run*/, UInt_t /*startTime*/,
59 // see header file for function documentation
60 fTPCactive = AliHLTModulePreprocessor::GetDetectorStatus(AliHLTModulePreprocessor::DetectorBitMask("TPC"));
61 fPHOSactive = AliHLTModulePreprocessor::GetDetectorStatus(AliHLTModulePreprocessor::DetectorBitMask("PHOS"));
66 UInt_t AliHLTCompPreprocessor::Process(TMap* /*dcsAliasMap*/)
68 // see header file for function documentation
71 // error if preprocessor states that TPC or PHOS were active but both are inactive here!
72 if( !(fTPCactive || fPHOSactive) )
74 Log("Neither TPC nor PHOS active in current run!");
78 // else there must be Huffman tables:
79 if (GetHuffmanTables() != 0) {
80 // unable to fetch Huffman tables
87 UInt_t AliHLTCompPreprocessor::GetHuffmanTables()
89 // see header file for function documentation
93 // get all huffman tables stored at FXS
94 //TList* HuffmanList = GetFileSources(AliPreprocessor::kHLT, fgkHuffmanFileId);
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;
109 TPCHuffmanList = new TList();
113 delete TPCHuffmanList;
116 PHOSHuffmanList = new TList();
120 delete PHOSHuffmanList;
123 // loop over all DDL numbers and put huffman tables into special containers
124 // (one for each detector)
125 for(Int_t ii=0; ii < HuffmanList->GetEntries(); ii++)
128 TObjString *objstr = (TObjString*) HuffmanList->At(ii);
130 if(objstr == 0) // should not happen?!
133 sprintf(logging, "Error in Huffmanlist, no DDL at position %d", ii);
138 TString fileName = GetFile(AliPreprocessor::kHLT, "HuffmanData", objstr->GetName());
140 if (!(fileName.Length() > 0)) // error if local path/filename is not defined
142 Log("Local file for current Huffman table is not properly defined.");
146 TFile* currenthuffmanfile = new TFile(fileName, "READ");
148 // if current huffman table file does not contain a table, return an error
149 if ( currenthuffmanfile->Get("HuffmanData") == NULL)
152 sprintf(logging,"Local file %s does not contain a Huffman code table.", fileName.Data());
154 //retVal = 1; // retVal must be zero to give other functions a chance to read their data
158 TObject* huffmandata = (TObject*) currenthuffmanfile->Get("HuffmanData");
159 // class object not needed since container uses TObjects!
160 AliHLTCOMPHuffmanData* currenthuffmandata = (AliHLTCOMPHuffmanData*) currenthuffmanfile->Get("HuffmanData");
162 // specifications necessary for sorting process
163 TString detectororigin = currenthuffmandata->GetOrigin();
164 Int_t tablespec = currenthuffmandata->GetDataSpec();
167 // plug them into a container:
168 if(detectororigin == "PHOS") // belongs to PHOS table (one one!)
172 Log("PHOS Huffman code table retrieved although PHOS detector was not active!");
176 PHOSHuffmanList->AddFirst(huffmandata);
178 if(PHOSHuffmanList->GetEntries() > 1)
180 Log("More than one table available for PHOS.");
181 // return: warning but go on...
186 if(detectororigin == "TPC ") // belongs to TPC tables (six)
191 Log("TPC Huffman code table retrieved although TPC detector was not active!");
197 TPCHuffmanList->Add(huffmandata);
199 if(TPCHuffmanList->GetEntries() > 6)
201 Log("More than six tables available for TPC.");
202 // return warning but go on...
208 sprintf(logging, "Read data specification %d from Huffman table too large to belong to TPC.", tablespec);
210 // retVal = 1; // retVal must be zero to give other functions a chance to read their data
217 sprintf(logging, "Specified detector pattern %s does not define a valid detector.", detectororigin.Data());
219 retVal = 1; // retVal must be zero to give other functions a chance to read their data
225 } // end loop over all DDLs
228 // after loop all containers are filled and can be stored in OCDB
229 AliCDBMetaData meta("Jenny Wagner");
233 if (!(Store("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta, 0, kTRUE)))
236 Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to OCDB failed.");
238 if (!(StoreReferenceData("CalibTPC", "HuffmanCodeTables", (TObject*) TPCHuffmanList, &meta)))
240 Log("Storing of TPCHuffmanList (Huffman code tables for TPC) to reference storage failed.");
249 if (!(Store("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta, 0, kTRUE)))
252 Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to OCDB failed.");
254 if (!(StoreReferenceData("CalibPHOS", "HuffmanCodeTables", (TObject*) PHOSHuffmanList, &meta)))
256 Log("Storing of PHOSHuffmanList (Huffman code table for PHOS) to reference storage failed.");