]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALAgent.cxx
Increase pt hard bin entry counter
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALAgent.cxx
CommitLineData
2f0cecb4 1// $Id$
8db5dd01 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: Federico Ronchetti *
8//* *
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//**************************************************************************
17
18/** @file AliHLTEMCALAgent.cxx
19 @author Federico Ronchetti
20 @date
21 @brief Agent of the libAliHLTEMCAL library
22 */
23
24#include "AliHLTEMCALAgent.h"
25#include "AliHLTConfiguration.h"
26#include "AliHLTEMCALDefinitions.h"
27#include "AliHLTOUT.h"
28#include "AliHLTOUTHandlerChain.h"
6c0647cd 29#include "AliHLTErrorGuard.h"
8db5dd01 30#include "AliRunLoader.h"
31#include "AliCDBManager.h"
32#include "AliCDBEntry.h"
33
34
35// #include "AliHLTEMCALConstant.h"
36#include "AliHLTEMCALConstants.h"
37#include "AliHLTEMCALMapper.h"
38
39/** global instance for agent registration */
40AliHLTEMCALAgent gAliHLTEMCALAgent;
41
42// component headers
43//#include "AliHLTEMCALCalibrationComponent.h"
44#include "AliHLTCaloClusterAnalyser.h"
45#include "AliHLTEMCALClusterizerComponent.h"
46#include "AliHLTEMCALDigitMakerComponent.h"
47//#include "AliHLTEMCALESDEntriesMakerComponent.h"
48//#include "AliHLTEMCALHistogramProducerComponent.h"
49//#include "AliHLTEMCALModuleCalibrationProcessorComponent.h"
50//#include "AliHLTEMCALMonitorTriggerComponent.h"
51#include "AliHLTEMCALRawAnalyzerComponent.h"
52#include "AliHLTEMCALRawAnalyzerCrudeComponent.h"
53#include "AliHLTEMCALRawAnalyzerPeakFinderComponent.h"
54//#include "AliHLTEMCALRcuCalibrationProcessorComponent.h"
55//#include "AliHLTEMCALRcuDAComponent.h"
6c0647cd 56#include "AliHLTEMCALRawAnalyzerLMSComponent.h"
57#include "AliHLTEMCALRawAnalyzerFastFitComponent.h"
58#include "AliHLTEMCALRawAnalyzerNNComponent.h"
59#include "AliHLTEMCALClusterizerComponentNbyN.h"
8db5dd01 60
61/** ROOT macro for the implementation of ROOT specific class methods */
62ClassImp(AliHLTEMCALAgent)
63
6c0647cd 64AliHLTEMCALAgent::AliHLTEMCALAgent() : AliHLTModuleAgent("EMCAL")
65 , fRawDataHandler(NULL)
66 , fMappers()
8db5dd01 67{
68 // see header file for class documentation
69 // or
70 // refer to README to build package
71 // or
72 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73}
74
75AliHLTEMCALAgent::~AliHLTEMCALAgent()
76{
77 // see header file for class documentation
78}
79
80int AliHLTEMCALAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
81 AliRawReader* /*rawReader*/,
82 AliRunLoader* /*runloader*/) const
83{
84 // see header file for class documentation
85 if (handler)
86 {
87 // const char* cdbEntry="EMCAL/Calib/Parameters";
88 //AliCDBManager* pMan=AliCDBManager::Instance();
89 //AliEMCALParam* pEMCALParam=NULL;
90
91 // if (pMan)
92 // {
93 // AliCDBEntry *pEntry = pMan->Get(cdbEntry);
94 // if (pEntry &&
95 // pEntry->GetObject() &&
96 // (pEMCALParam=dynamic_cast<AliEMCALParam*>(pEntry->GetObject())))
97 // {
98 // } else
99 // {
100 // HLTWarning("can not load AliEMCALParam from CDB entry %s", cdbEntry);
101 // }
102 // }
103
104 int moduleStart = 0;
105 int moduleEnd = 9;
106
107 int rcuStart = 0;
108 int rcuEnd = 1;
109
110 Int_t rcusPerModule = 2;
111 Int_t ddlOffset = 4608;
112
113 TString mergerInput;
114 TString sinkClusterInput;
115 TString emInput;
116
1bfac818 117 for (int module = moduleStart; module <= moduleEnd; module++)
8db5dd01 118 {
119 TString clInput;
120
121 for(int rcu = rcuStart; rcu < rcuEnd; rcu++)
122 {
123 TString arg, publisher, ra, dm;
124 // raw data publisher components
125 publisher.Form("EMCAL-RP_%02d_%d", module, rcu);
126 arg.Form("-verbose -minid %d -datatype 'DDL_RAW ' 'EMCA' -dataspec 0x%x ", ddlOffset + module*(rcusPerModule) + rcu, 0x1 << (module*rcusPerModule + rcu));
127
128 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
129
130 // Raw analyzer
131 arg = "";
132 ra.Form("EMCAL-RA_%02d_%d", module, rcu);
133 handler->CreateConfiguration(ra.Data(), "EmcalRawCrude", publisher.Data(), arg.Data());
134
135 // digit maker components
136 dm.Form("EMCAL-DM_%02d_%d", module, rcu);
137 arg="";
138 arg.Form("-sethighgainfactor 0.0153 -setlowgainfactor 0.2448 -setdigitthresholds 0.005 0.002");
139 handler->CreateConfiguration(dm.Data(), "EmcalDigitMaker", ra.Data(), arg.Data());
140
141 if(clInput.Length() > 0) clInput += " ";
142 clInput+=dm;
143 }
144
145 TString arg, cl, ca;
146
147 cl.Form("EMCAL-CF_%02d", module);
148 arg = "";
149 arg.Form("-digitthreshold 0.005 -recpointthreshold 0.1 -modulemode");
150 handler->CreateConfiguration(cl.Data(), "EmcalClusterizer", clInput.Data(), arg.Data());
151
152 //ca.Form("EMCAL-CA_%02d", module);
153 //arg = " ";
154 //handler->CreateConfiguration(ca.Data(), "CaloClusterAnalyser", cl.Data(), arg.Data());
155
156 if(emInput.Length() > 0) emInput += " ";
157 emInput += ca;
158 }
159
160
161 TString arg, em;
162
163 // tracker finder components
164
165 // later
166 // em.Form("EMCAL-EM");
167 //arg = " ";
168 //handler->CreateConfiguration(em.Data(), "EmcalEsdEntriesMaker", emInput.Data(), " ");
169
170 }
171
172 return 0;
173}
174
175const char* AliHLTEMCALAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
176 AliRunLoader* runloader) const
177{
178 // see header file for class documentation
179 if (runloader) {
180 // reconstruction chains for AliRoot simulation
181 // Note: run loader is only available while running embedded into
182 // AliRoot simulation
183
caa5984b 184 // if (runloader->GetLoader("EMCALLoader") != NULL)
185 // return "EMCAL-EM";
8db5dd01 186 }
187 return NULL;
188}
189
190const char* AliHLTEMCALAgent::GetRequiredComponentLibraries() const
191{
192 // see header file for class documentation
193 return NULL;
194}
195
196int AliHLTEMCALAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
197{
198 // see header file for class documentation
199 if (!pHandler) return -EINVAL;
200
201 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerCrudeComponent);
6c0647cd 202 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerLMSComponent);
203 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerPeakFinderComponent);
204 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerFastFitComponent);
205 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerNNComponent);
8db5dd01 206 pHandler->AddComponent(new AliHLTEMCALDigitMakerComponent);
207 pHandler->AddComponent(new AliHLTEMCALClusterizerComponent);
6c0647cd 208 pHandler->AddComponent(new AliHLTEMCALClusterizerComponentNbyN);
8db5dd01 209 //pHandler->AddComponent(new AliHLTCaloClusterAnalyserComponent);
210 //pHandler->AddComponent(new AliHLTEMCALESDEntriesMakerComponent);
211
212 return 0;
213}
214
215
216int AliHLTEMCALAgent::GetHandlerDescription(AliHLTComponentDataType dt,
217 AliHLTUInt32_t spec,
218 AliHLTOUTHandlerDesc& desc) const
219{
220 // see header file for class documentation
2f0cecb4 221
8db5dd01 222 // raw data blocks to be fed into offline reconstruction
223 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
224 {
6c0647cd 225 AliHLTEMCALMapper* pMapper=GetMapper(spec);
226
227 if(pMapper && pMapper->GetDDLFromSpec(spec) >= 0)
8db5dd01 228 {
229 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
230 return 1;
231 }
6c0647cd 232 else if (pMapper==NULL)
233 {
234 ALIHLTERRORGUARD(5, "failed to create EMCAL mapper");
235 return 0;
236 }
8db5dd01 237 else
238 {
239 HLTWarning("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
240 return 0;
241 }
242 }
243 return 0;
244}
245
246AliHLTOUTHandler* AliHLTEMCALAgent::GetOutputHandler(AliHLTComponentDataType dt,
247 AliHLTUInt32_t /*spec*/)
248{
249 // see header file for class documentation
250
251 // raw data blocks to be fed into offline reconstruction
252 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
253 {
254 if (!fRawDataHandler)
255 {
6c0647cd 256 fRawDataHandler = new AliHLTEMCALAgent::AliHLTEMCALRawDataHandler(this);
8db5dd01 257 }
258 return fRawDataHandler;
259 }
260
261 return NULL;
262}
263
264int AliHLTEMCALAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
265{
266 // see header file for class documentation
267 if (pInstance==NULL) return -EINVAL;
268
269 if (pInstance==fRawDataHandler) {
270 delete fRawDataHandler;
271 fRawDataHandler=NULL;
272 }
273 return 0;
274}
275
6c0647cd 276AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::AliHLTEMCALRawDataHandler(AliHLTEMCALAgent* pAgent)
277 : fpAgent(pAgent)
8db5dd01 278{
279 // see header file for class documentation
280}
281
282AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::~AliHLTEMCALRawDataHandler()
283{
284 // see header file for class documentation
285}
286
287int AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::ProcessData(AliHLTOUT* pData)
288{
289 // see header file for class documentation
290 if (!pData) return -EINVAL;
291
292 AliHLTComponentDataType dt = kAliHLTVoidDataType;
293 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
294
6c0647cd 295 AliHLTEMCALMapper* pMapper=fpAgent?fpAgent->GetMapper(spec):NULL;
296 if (!pMapper) {
297 ALIHLTERRORGUARD(5, "%s", fpAgent?"can not retrieve EMCAL mapper from agent":"agent not available to retrieve EMCAL mapper");
298 return -ENODEV;
299 }
8db5dd01 300
301 int iResult = pData->GetDataBlockDescription(dt, spec);
302 if (iResult>=0)
303 {
304 int ddl = -1;
6c0647cd 305 if((ddl = pMapper->GetDDLFromSpec(spec)) >=0)
8db5dd01 306 {
307 iResult = ddl;
308 }
309 }
310 else
311 {
312 HLTError("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
313 iResult=-EBADMSG;
314 }
315 return iResult;
316}
6c0647cd 317
318AliHLTEMCALMapper* AliHLTEMCALAgent::GetMapper(AliHLTUInt32_t spec) const
319{
320 // get the mapper instance for a specification
321 std::map<AliHLTUInt32_t, AliHLTEMCALMapper*>::const_iterator element=fMappers.find(spec);
322 if (element!=fMappers.end()) return element->second;
323
324 AliHLTEMCALMapper* mapper=new AliHLTEMCALMapper(spec);
325 if (!mapper) return NULL;
326 mapper->InitDDLSpecificationMapping();
327 const_cast<AliHLTEMCALAgent*>(this)->fMappers[spec]=mapper;
328 return mapper;
329}