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"
32 #include "AliCDBManager.h"
33 #include "AliCDBEntry.h"
36 // #include "AliHLTEMCALConstant.h"
37 #include "AliHLTEMCALConstants.h"
38 #include "AliHLTEMCALMapper.h"
40 /** global instance for agent registration */
41 AliHLTEMCALAgent gAliHLTEMCALAgent;
44 //#include "AliHLTEMCALCalibrationComponent.h"
45 #include "AliHLTCaloClusterAnalyser.h"
46 #include "AliHLTEMCALClusterizerComponent.h"
47 #include "AliHLTEMCALDigitMakerComponent.h"
48 //#include "AliHLTEMCALESDEntriesMakerComponent.h"
49 //#include "AliHLTEMCALHistogramProducerComponent.h"
50 //#include "AliHLTEMCALModuleCalibrationProcessorComponent.h"
51 //#include "AliHLTEMCALMonitorTriggerComponent.h"
52 #include "AliHLTEMCALRawAnalyzerComponent.h"
53 #include "AliHLTEMCALRawAnalyzerCrudeComponent.h"
54 #include "AliHLTEMCALRawAnalyzerPeakFinderComponent.h"
55 //#include "AliHLTEMCALRcuCalibrationProcessorComponent.h"
56 //#include "AliHLTEMCALRcuDAComponent.h"
57 #include "AliHLTEMCALRawAnalyzerLMSComponent.h"
58 #include "AliHLTEMCALRawAnalyzerFastFitComponent.h"
59 #include "AliHLTEMCALRawAnalyzerNNComponent.h"
60 #include "AliHLTEMCALClusterizerComponentNbyN.h"
62 /** ROOT macro for the implementation of ROOT specific class methods */
63 ClassImp(AliHLTEMCALAgent)
65 AliHLTEMCALAgent::AliHLTEMCALAgent() : AliHLTModuleAgent("EMCAL")
66 , fRawDataHandler(NULL)
69 // see header file for class documentation
71 // refer to README to build package
73 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
76 AliHLTEMCALAgent::~AliHLTEMCALAgent()
78 // see header file for class documentation
81 UInt_t AliHLTEMCALAgent::GetDetectorMask() const
83 return AliDAQ::kEMCAL;
86 int AliHLTEMCALAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
87 AliRawReader* /*rawReader*/,
88 AliRunLoader* /*runloader*/) const
90 // see header file for class documentation
93 // const char* cdbEntry="EMCAL/Calib/Parameters";
94 //AliCDBManager* pMan=AliCDBManager::Instance();
95 //AliEMCALParam* pEMCALParam=NULL;
99 // AliCDBEntry *pEntry = pMan->Get(cdbEntry);
101 // pEntry->GetObject() &&
102 // (pEMCALParam=dynamic_cast<AliEMCALParam*>(pEntry->GetObject())))
106 // HLTWarning("can not load AliEMCALParam from CDB entry %s", cdbEntry);
116 Int_t rcusPerModule = 2;
117 Int_t ddlOffset = 4608;
120 TString sinkClusterInput;
123 for (int module = moduleStart; module <= moduleEnd; module++)
127 for(int rcu = rcuStart; rcu < rcuEnd; rcu++)
129 TString arg, publisher, ra, dm;
130 // raw data publisher components
131 publisher.Form("EMCAL-RP_%02d_%d", module, rcu);
132 arg.Form("-verbose -minid %d -datatype 'DDL_RAW ' 'EMCA' -dataspec 0x%x ", ddlOffset + module*(rcusPerModule) + rcu, 0x1 << (module*rcusPerModule + rcu));
134 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
138 ra.Form("EMCAL-RA_%02d_%d", module, rcu);
139 handler->CreateConfiguration(ra.Data(), "EmcalRawCrude", publisher.Data(), arg.Data());
141 // digit maker components
142 dm.Form("EMCAL-DM_%02d_%d", module, rcu);
144 arg.Form("-sethighgainfactor 0.0153 -setlowgainfactor 0.2448 -setdigitthresholds 0.005 0.002");
145 handler->CreateConfiguration(dm.Data(), "EmcalDigitMaker", ra.Data(), arg.Data());
147 if(clInput.Length() > 0) clInput += " ";
153 cl.Form("EMCAL-CF_%02d", module);
155 arg.Form("-digitthreshold 0.005 -recpointthreshold 0.1 -modulemode");
156 handler->CreateConfiguration(cl.Data(), "EmcalClusterizer", clInput.Data(), arg.Data());
158 //ca.Form("EMCAL-CA_%02d", module);
160 //handler->CreateConfiguration(ca.Data(), "CaloClusterAnalyser", cl.Data(), arg.Data());
162 if(emInput.Length() > 0) emInput += " ";
169 // tracker finder components
172 // em.Form("EMCAL-EM");
174 //handler->CreateConfiguration(em.Data(), "EmcalEsdEntriesMaker", emInput.Data(), " ");
181 const char* AliHLTEMCALAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
182 AliRunLoader* runloader) const
184 // see header file for class documentation
186 // reconstruction chains for AliRoot simulation
187 // Note: run loader is only available while running embedded into
188 // AliRoot simulation
190 // if (runloader->GetLoader("EMCALLoader") != NULL)
191 // return "EMCAL-EM";
196 const char* AliHLTEMCALAgent::GetRequiredComponentLibraries() const
198 // see header file for class documentation
202 int AliHLTEMCALAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
204 // see header file for class documentation
205 if (!pHandler) return -EINVAL;
207 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerCrudeComponent);
208 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerLMSComponent);
209 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerPeakFinderComponent);
210 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerFastFitComponent);
211 pHandler->AddComponent(new AliHLTEMCALRawAnalyzerNNComponent);
212 pHandler->AddComponent(new AliHLTEMCALDigitMakerComponent);
213 pHandler->AddComponent(new AliHLTEMCALClusterizerComponent);
214 pHandler->AddComponent(new AliHLTEMCALClusterizerComponentNbyN);
215 //pHandler->AddComponent(new AliHLTCaloClusterAnalyserComponent);
216 //pHandler->AddComponent(new AliHLTEMCALESDEntriesMakerComponent);
222 int AliHLTEMCALAgent::GetHandlerDescription(AliHLTComponentDataType dt,
224 AliHLTOUTHandlerDesc& desc) const
226 // see header file for class documentation
228 // raw data blocks to be fed into offline reconstruction
229 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
231 AliHLTEMCALMapper* pMapper=GetMapper(spec);
233 if(pMapper && pMapper->GetDDLFromSpec(spec) >= 0)
235 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
238 else if (pMapper==NULL)
240 ALIHLTERRORGUARD(5, "failed to create EMCAL mapper");
245 HLTWarning("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
252 AliHLTOUTHandler* AliHLTEMCALAgent::GetOutputHandler(AliHLTComponentDataType dt,
253 AliHLTUInt32_t /*spec*/)
255 // see header file for class documentation
257 // raw data blocks to be fed into offline reconstruction
258 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL))
260 if (!fRawDataHandler)
262 fRawDataHandler = new AliHLTEMCALAgent::AliHLTEMCALRawDataHandler(this);
264 return fRawDataHandler;
270 int AliHLTEMCALAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
272 // see header file for class documentation
273 if (pInstance==NULL) return -EINVAL;
275 if (pInstance==fRawDataHandler) {
276 delete fRawDataHandler;
277 fRawDataHandler=NULL;
282 AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::AliHLTEMCALRawDataHandler(AliHLTEMCALAgent* pAgent)
285 // see header file for class documentation
288 AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::~AliHLTEMCALRawDataHandler()
290 // see header file for class documentation
293 int AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::ProcessData(AliHLTOUT* pData)
295 // see header file for class documentation
296 if (!pData) return -EINVAL;
298 AliHLTComponentDataType dt = kAliHLTVoidDataType;
299 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
301 AliHLTEMCALMapper* pMapper=fpAgent?fpAgent->GetMapper(spec):NULL;
303 ALIHLTERRORGUARD(5, "%s", fpAgent?"can not retrieve EMCAL mapper from agent":"agent not available to retrieve EMCAL mapper");
307 int iResult = pData->GetDataBlockDescription(dt, spec);
311 if((ddl = pMapper->GetDDLFromSpec(spec)) >=0)
318 HLTError("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
324 AliHLTEMCALMapper* AliHLTEMCALAgent::GetMapper(AliHLTUInt32_t spec) const
326 // get the mapper instance for a specification
327 std::map<AliHLTUInt32_t, AliHLTEMCALMapper*>::const_iterator element=fMappers.find(spec);
328 if (element!=fMappers.end()) return element->second;
330 AliHLTEMCALMapper* mapper=new AliHLTEMCALMapper(spec);
331 if (!mapper) return NULL;
332 mapper->InitDDLSpecificationMapping();
333 const_cast<AliHLTEMCALAgent*>(this)->fMappers[spec]=mapper;