1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /** @file AliHLTEMCALClusterizerComponent.cxx
19 @author Mateusz Ploskon
21 @brief EMCAL clusterizer component for HLT. */
27 #include "AliHLTEMCALClusterizerComponent.h"
28 #include "AliHLTEMCALDefinitions.h"
31 #include "TObjString.h"
32 #include "TObjArray.h"
33 #include "AliCDBEntry.h"
34 #include "AliCDBManager.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTEMCALClusterizerComponent)
39 AliHLTEMCALClusterizerComponent::AliHLTEMCALClusterizerComponent()
41 , fOutputPercentage(100)
42 , fStorageDBpath("local://$ALICE_ROOT")
46 , fGeometryFileName("")
50 // see header file for class documentation
52 // refer to README to build package
54 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 AliHLTEMCALClusterizerComponent::AliHLTEMCALClusterizerComponent(const AliHLTEMCALClusterizerComponent &/*c*/)
59 , fOutputPercentage(100)
60 , fStorageDBpath("local://$ALICE_ROOT")
64 , fGeometryFileName("")
68 // may not use the copy contructor
69 HLTError("May not use.");
72 AliHLTEMCALClusterizerComponent& AliHLTEMCALClusterizerComponent::operator=(const AliHLTEMCALClusterizerComponent&)
74 // may not use the copy contructor
75 HLTError("May not use.");
79 AliHLTEMCALClusterizerComponent::~AliHLTEMCALClusterizerComponent()
81 // see header file for class documentation
84 AliHLTComponentDataType AliHLTEMCALClusterizerComponent::GetOutputDataType()
86 return AliHLTEMCALDefinitions::fgkClusterDataType;
89 int AliHLTEMCALClusterizerComponent::DoInit( int argc, const char** argv )
91 // see header file for class documentation
93 HLTInfo("parsing %d arguments", argc);
96 TString configuration="";
98 bool bHaveMandatory1=false;
99 bool bHaveMandatory2=false;
103 for (int i=0; i<argc && iResult>=0; i++) {
105 if (argument.IsNull()) continue;
108 if (argument.CompareTo("-cdb")==0) {
110 if ((bMissingParam=(++i>=argc))) break;
111 HLTInfo("got \'-cdb\' argument: %s", argv[i]);
112 fStorageDBpath = argv[i];
113 HLTInfo("CDB path is: %s", fStorageDBpath.c_str());
115 } else if (argument.CompareTo("-geometry")==0) {
117 HLTInfo("got \'-geometry\' argument");
118 fGeometryFileName = argv[i];
119 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
121 } else if (argument.CompareTo("-output_percentage")==0) {
122 if ((bMissingParam=(++i>=argc))) break;
123 HLTInfo("got \'-output_percentage\' argument: %s", argv[i]);
124 fOutputPercentage = strtoul(argv[i], &cpErr, 0);
127 HLTError("Unable to convert ouput_percentage to a number %s", argv[i]);
132 // } else if (argument.CompareTo("-optional2")==0) {
133 // HLTInfo("got \'-optional2\' argument");
136 // the remaining arguments are treated as configuration
137 if (!configuration.IsNull()) configuration+=" ";
138 configuration+=argument;
142 HLTError("missing parameter for argument %s", argument.Data());
146 if (iResult>=0 && !bHaveMandatory1) {
147 HLTError("mandatory argument \'-cdb\' missing");
150 if (iResult>=0 && !bHaveMandatory2) {
151 HLTError("mandatory argument \'-geometry\' missing");
154 if (iResult>=0 && !configuration.IsNull()) {
155 iResult=Configure(configuration.Data());
157 iResult=Reconfigure(NULL, NULL);
163 int AliHLTEMCALClusterizerComponent::DoDeinit()
165 // see header file for class documentation
166 HLTInfo("processing cleanup");
170 int AliHLTEMCALClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
171 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
172 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
173 // see header file for class documentation
174 HLTInfo("processing data");
175 if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
176 outputPtr==0 && size==0)
178 outputBlocks.clear();
179 // this is just to get rid of the warning "unused parameter"
184 int AliHLTEMCALClusterizerComponent::Configure(const char* arguments)
186 // see header file for class documentation
188 if (!arguments) return iResult;
189 HLTInfo("parsing configuration string \'%s\'", arguments);
191 TString allArgs=arguments;
195 TObjArray* pTokens=allArgs.Tokenize(" ");
197 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
198 argument=((TObjString*)pTokens->At(i))->GetString();
199 if (argument.IsNull()) continue;
202 if (argument.CompareTo("-config1")==0) {
203 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
204 HLTInfo("got \'-config1\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
207 } else if (argument.CompareTo("-config2")==0) {
208 HLTInfo("got \'-config2\'");
210 HLTError("unknown argument %s", argument.Data());
218 HLTError("missing parameter for argument %s", argument.Data());
224 int AliHLTEMCALClusterizerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
226 // see header file for class documentation
228 const char* path="HLT/ConfigSample/EMCALClusterizerComponent";
229 const char* defaultNotify="";
232 defaultNotify=" (default)";
235 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
236 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
238 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
240 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
241 iResult=Configure(pString->GetString().Data());
243 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
246 HLTError("can not fetch object \"%s\" from CDB", path);
252 int AliHLTEMCALClusterizerComponent::ReadPreprocessorValues(const char* modules)
254 // see header file for class documentation
256 TString detectors(modules!=NULL?modules:"");
257 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());