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: Federico Ronchetti *
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 AliHLTEMCALAgent.cxx
19 @author Federico Ronchetti
21 @brief Agent of the libAliHLTEMCAL library
24 #include "AliHLTEMCALAgent.h"
25 #include "AliHLTConfiguration.h"
26 #include "AliHLTEMCALDefinitions.h"
27 #include "AliHLTOUT.h"
28 #include "AliHLTOUTHandlerChain.h"
29 #include "AliHLTErrorGuard.h"
30 #include "AliRunLoader.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
35 // #include "AliHLTEMCALConstant.h"
36 #include "AliHLTEMCALConstants.h"
37 #include "AliHLTEMCALMapper.h"
39 /** global instance for agent registration */
40 AliHLTEMCALAgent gAliHLTEMCALAgent;
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"
56 #include "AliHLTEMCALRawAnalyzerLMSComponent.h"
57 #include "AliHLTEMCALRawAnalyzerFastFitComponent.h"
58 #include "AliHLTEMCALRawAnalyzerNNComponent.h"
59 #include "AliHLTEMCALClusterizerComponentNbyN.h"
61 /** ROOT macro for the implementation of ROOT specific class methods */
62 ClassImp(AliHLTEMCALAgent)
64 AliHLTEMCALAgent::AliHLTEMCALAgent() : AliHLTModuleAgent("EMCAL")
65 , fRawDataHandler(NULL)
68 // see header file for class documentation
70 // refer to README to build package
72 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
75 AliHLTEMCALAgent::~AliHLTEMCALAgent()
77 // see header file for class documentation
80 int AliHLTEMCALAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
81 AliRawReader* /*rawReader*/,
82 AliRunLoader* /*runloader*/) const
84 // see header file for class documentation
87 // const char* cdbEntry="EMCAL/Calib/Parameters";
88 //AliCDBManager* pMan=AliCDBManager::Instance();
89 //AliEMCALParam* pEMCALParam=NULL;
93 // AliCDBEntry *pEntry = pMan->Get(cdbEntry);
95 // pEntry->GetObject() &&
96 // (pEMCALParam=dynamic_cast<AliEMCALParam*>(pEntry->GetObject())))
100 // HLTWarning("can not load AliEMCALParam from CDB entry %s", cdbEntry);
110 Int_t rcusPerModule = 2;
111 Int_t ddlOffset = 4608;
114 TString sinkClusterInput;
117 for (int module = moduleStart; module <= moduleEnd; module++)
121 for(int rcu = rcuStart; rcu < rcuEnd; rcu++)
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));
128 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
132 ra.Form("EMCAL-RA_%02d_%d", module, rcu);
133 handler->CreateConfiguration(ra.Data(), "EmcalRawCrude", publisher.Data(), arg.Data());
135 // digit maker components
136 dm.Form("EMCAL-DM_%02d_%d", module, rcu);
138 arg.Form("-sethighgainfactor 0.0153 -setlowgainfactor 0.2448 -setdigitthresholds 0.005 0.002");
139 handler->CreateConfiguration(dm.Data(), "EmcalDigitMaker", ra.Data(), arg.Data());
141 if(clInput.Length() > 0) clInput += " ";
147 cl.Form("EMCAL-CF_%02d", module);
149 arg.Form("-digitthreshold 0.005 -recpointthreshold 0.1 -modulemode");
150 handler->CreateConfiguration(cl.Data(), "EmcalClusterizer", clInput.Data(), arg.Data());
152 //ca.Form("EMCAL-CA_%02d", module);
154 //handler->CreateConfiguration(ca.Data(), "CaloClusterAnalyser", cl.Data(), arg.Data());
156 if(emInput.Length() > 0) emInput += " ";
163 // tracker finder components
166 // em.Form("EMCAL-EM");
168 //handler->CreateConfiguration(em.Data(), "EmcalEsdEntriesMaker", emInput.Data(), " ");
175 const char* AliHLTEMCALAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
176 AliRunLoader* runloader) const
178 // see header file for class documentation
180 // reconstruction chains for AliRoot simulation
181 // Note: run loader is only available while running embedded into
182 // AliRoot simulation
184 // if (runloader->GetLoader("EMCALLoader") != NULL)
185 // return "EMCAL-EM";
190 const char* AliHLTEMCALAgent::GetRequiredComponentLibraries() const
192 // see header file for class documentation
196 int AliHLTEMCALAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
198 // see header file for class documentation
199 if (!pHandler) return -EINVAL;
201 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerCrudeComponent);
202 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerLMSComponent);
203 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerPeakFinderComponent);
204 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerFastFitComponent);
205 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerNNComponent);
206 pHandler->AddComponent(new AliHLTEMCALDigitMakerComponent);
207 pHandler->AddComponent(new AliHLTEMCALClusterizerComponent);
208 pHandler->AddComponent(new AliHLTEMCALClusterizerComponentNbyN);
209 //pHandler->AddComponent(new AliHLTCaloClusterAnalyserComponent);
210 //pHandler->AddComponent(new AliHLTEMCALESDEntriesMakerComponent);
216 int AliHLTEMCALAgent::GetHandlerDescription(AliHLTComponentDataType dt,
218 AliHLTOUTHandlerDesc& desc) const
220 // see header file for class documentation
222 // raw data blocks to be fed into offline reconstruction
223 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
225 AliHLTEMCALMapper* pMapper=GetMapper(spec);
227 if(pMapper && pMapper->GetDDLFromSpec(spec) >= 0)
229 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
232 else if (pMapper==NULL)
234 ALIHLTERRORGUARD(5, "failed to create EMCAL mapper");
239 HLTWarning("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
246 AliHLTOUTHandler* AliHLTEMCALAgent::GetOutputHandler(AliHLTComponentDataType dt,
247 AliHLTUInt32_t /*spec*/)
249 // see header file for class documentation
251 // raw data blocks to be fed into offline reconstruction
252 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
254 if (!fRawDataHandler)
256 fRawDataHandler = new AliHLTEMCALAgent::AliHLTEMCALRawDataHandler(this);
258 return fRawDataHandler;
264 int AliHLTEMCALAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
266 // see header file for class documentation
267 if (pInstance==NULL) return -EINVAL;
269 if (pInstance==fRawDataHandler) {
270 delete fRawDataHandler;
271 fRawDataHandler=NULL;
276 AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::AliHLTEMCALRawDataHandler(AliHLTEMCALAgent* pAgent)
279 // see header file for class documentation
282 AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::~AliHLTEMCALRawDataHandler()
284 // see header file for class documentation
287 int AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::ProcessData(AliHLTOUT* pData)
289 // see header file for class documentation
290 if (!pData) return -EINVAL;
292 AliHLTComponentDataType dt = kAliHLTVoidDataType;
293 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
295 AliHLTEMCALMapper* pMapper=fpAgent?fpAgent->GetMapper(spec):NULL;
297 ALIHLTERRORGUARD(5, "%s", fpAgent?"can not retrieve EMCAL mapper from agent":"agent not available to retrieve EMCAL mapper");
301 int iResult = pData->GetDataBlockDescription(dt, spec);
305 if((ddl = pMapper->GetDDLFromSpec(spec)) >=0)
312 HLTError("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
318 AliHLTEMCALMapper* AliHLTEMCALAgent::GetMapper(AliHLTUInt32_t spec) const
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;
324 AliHLTEMCALMapper* mapper=new AliHLTEMCALMapper(spec);
325 if (!mapper) return NULL;
326 mapper->InitDDLSpecificationMapping();
327 const_cast<AliHLTEMCALAgent*>(this)->fMappers[spec]=mapper;