]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSAgent.cxx
- changes to make the clusterisation work for EMCAL
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSAgent.cxx
1
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Oystein Djuvsland                                     *
7 //*                                                                        *
8 //* Permission to use, copy, modify and distribute this software and its   *
9 //* documentation strictly for non-commercial purposes is hereby granted   *
10 //* without fee, provided that the above copyright notice appears in all   *
11 //* copies and that both the copyright notice and this permission notice   *
12 //* appear in the supporting documentation. The authors make no claims     *
13 //* about the suitability of this software for any purpose. It is          *
14 //* provided "as is" without express or implied warranty.                  *
15 //**************************************************************************
16
17 /** @file   AliHLTPHOSAgent.cxx
18     @author Oystein Djuvsland
19     @date   
20     @brief  Agent of the libAliHLTPHOS library
21 */
22
23 #include "AliHLTPHOSAgent.h"
24 #include "AliHLTConfiguration.h"
25 #include "AliHLTPHOSDefinitions.h"
26 #include "AliHLTOUT.h"
27 #include "AliHLTOUTHandlerChain.h"
28 #include "AliRunLoader.h"
29 #include "AliCDBManager.h"
30 #include "AliCDBEntry.h"
31 #include "AliHLTPHOSConstant.h"
32 #include "AliHLTPHOSMapper.h"
33
34 /** global instance for agent registration */
35 AliHLTPHOSAgent gAliHLTPHOSAgent;
36
37 // component headers
38 #include "AliHLTPHOSCalibrationComponent.h"
39 #include "AliHLTPHOSClusterAnalyserComponent.h"
40 #include "AliHLTPHOSClusterizerComponent.h"
41 #include "AliHLTPHOSDigitMakerComponent.h"
42 #include "AliHLTPHOSESDEntriesMakerComponent.h"
43 #include "AliHLTPHOSHistogramProducerComponent.h"
44 #include "AliHLTPHOSModuleCalibrationProcessorComponent.h"
45 #include "AliHLTPHOSMonitorTriggerComponent.h"
46 #include "AliHLTPHOSRawAnalyzerComponent.h"
47 #include "AliHLTPHOSRawAnalyzerCrudeComponentv2.h"
48 #include "AliHLTPHOSRawAnalyzerPeakFinderComponent.h"
49 #include "AliHLTPHOSRcuCalibrationProcessorComponent.h"
50 #include "AliHLTPHOSRcuDAComponent.h"
51
52 /** ROOT macro for the implementation of ROOT specific class methods */
53 ClassImp(AliHLTPHOSAgent)
54
55 AliHLTPHOSAgent::AliHLTPHOSAgent()
56   :
57   AliHLTModuleAgent("PHOS"),
58   fRawDataHandler(NULL)
59 {
60   // see header file for class documentation
61   // or
62   // refer to README to build package
63   // or
64   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65 }
66
67 AliHLTPHOSAgent::~AliHLTPHOSAgent()
68 {
69   // see header file for class documentation
70 }
71
72 int AliHLTPHOSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
73                                           AliRawReader* /*rawReader*/,
74                                          AliRunLoader* /*runloader*/) const
75 {
76   // see header file for class documentation
77   if (handler) 
78     {
79       //      const char* cdbEntry="PHOS/Calib/Parameters";
80       //      AliCDBManager* pMan=AliCDBManager::Instance();
81 //       AliPHOSParam* pPHOSParam=NULL;
82 //       if (pMan) 
83 //      {
84 //        AliCDBEntry *pEntry = pMan->Get(cdbEntry);
85 //        if (pEntry && 
86 //            pEntry->GetObject() &&
87 //            (pPHOSParam=dynamic_cast<AliPHOSParam*>(pEntry->GetObject()))) 
88 //          {
89 //          } else 
90 //          {
91 //            HLTWarning("can not load AliPHOSParam from CDB entry %s", cdbEntry);
92 //          }
93 //      }
94
95
96       int moduleStart = 0;
97       int moduleEnd = PhosHLTConst::NMODULES - 1;
98       int rcuStart = 0;
99       int rcuEnd = PhosHLTConst::NRCUSPERMODULE - 1;
100     
101       TString mergerInput;
102       TString sinkClusterInput;
103       TString emInput;
104       for (int module = moduleStart; module < moduleEnd; module++) 
105         {
106           TString clInput;
107
108           for(int rcu = rcuStart; rcu < rcuEnd; rcu++) 
109             {
110               TString arg, publisher, ra, dm;
111               // raw data publisher components
112               publisher.Form("PHOS-RP_%02d_%d", module, rcu);
113         
114               arg.Form("-datatype 'DDL_RAW ' 'PHOS'  -dataspec 0x ", 0x1 << (module*PhosHLTConst::NRCUSPERMODULE + rcu));
115               handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
116
117               // Raw analyzer
118               arg = "";
119               ra.Form("PHOS-RA_%02d_%d", module, rcu);
120               handler->CreateConfiguration(ra.Data(), "PhosRawCrudev2", publisher.Data(), arg.Data());
121
122               // digit maker components
123               dm.Form("PHOS-DM_%02d_%d", module, rcu);
124               arg="";
125               arg.Form("-sethighgainfactor 0.005 -setlowgainfactor 0.08 -setdigitthresholds 0.005 0.002");
126               handler->CreateConfiguration(dm.Data(), "PhosDigitMaker", ra.Data(), arg.Data());
127
128               if(clInput.Length() > 0) clInput += " ";
129               clInput+=dm;
130             }
131           TString arg, cl, ca;
132
133           cl.Form("PHOS-CF_%02d", module);
134           arg = "";
135           arg.Form("-digitthreshold 0.005 -recpointthreshold 0.1 -modulemode");
136           handler->CreateConfiguration(cl.Data(), "PhosClusterizer", clInput.Data(), arg.Data());
137         
138           ca.Form("PHOS-CA_%02d", module);
139           arg = " ";
140           handler->CreateConfiguration(ca.Data(), "PhosClusterAnalyser", cl.Data(), arg.Data());
141
142           if(emInput.Length() > 0) emInput += " ";
143           emInput += ca;
144         }
145       
146       TString arg, em;
147   
148       // tracker finder components
149       em.Form("PHOS-EM");
150       arg = " ";
151       handler->CreateConfiguration(em.Data(), "PhosEsdEntriesMaker", emInput.Data(), " ");
152     }
153   return 0;
154 }
155
156 const char* AliHLTPHOSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
157                                                     AliRunLoader* runloader) const
158 {
159   // see header file for class documentation
160   if (runloader) {
161     // reconstruction chains for AliRoot simulation
162     // Note: run loader is only available while running embedded into
163     // AliRoot simulation
164     if (runloader->GetLoader("PHOSLoader") != NULL)
165       return "PHOS-EM";
166   }
167   return NULL;
168 }
169
170 const char* AliHLTPHOSAgent::GetRequiredComponentLibraries() const
171 {
172   // see header file for class documentation
173   return NULL;
174 }
175
176 int AliHLTPHOSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
177 {
178   // see header file for class documentation
179   if (!pHandler) return -EINVAL;
180   pHandler->AddComponent(new AliHLTPHOSRawAnalyzerCrudeComponentv2);
181   pHandler->AddComponent(new AliHLTPHOSDigitMakerComponent);
182   pHandler->AddComponent(new AliHLTPHOSClusterizerComponent);
183   pHandler->AddComponent(new AliHLTPHOSClusterAnalyserComponent);                        
184   pHandler->AddComponent(new AliHLTPHOSESDEntriesMakerComponent);
185
186   return 0;
187 }
188
189 int AliHLTPHOSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
190                                           AliHLTUInt32_t spec,
191                                           AliHLTOUTHandlerDesc& desc) const
192 {
193   // see header file for class documentation
194
195   AliHLTPHOSMapper mapper;
196   mapper.InitDDLSpecificationMapping();
197   
198   // raw data blocks to be fed into offline reconstruction
199   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginPHOS)) 
200     {
201       if(mapper.GetDDLFromSpec(spec) >= 0)
202         {
203           desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
204           return 1;
205         } 
206       else 
207         {
208           HLTWarning("Handler can not process data inconsistent with a single PHOS DDL from specification % d", spec);
209           return 0;
210         }
211     }
212   return 0;
213 }
214
215 AliHLTOUTHandler* AliHLTPHOSAgent::GetOutputHandler(AliHLTComponentDataType dt,
216                                                    AliHLTUInt32_t /*spec*/)
217 {
218   // see header file for class documentation
219
220   // raw data blocks to be fed into offline reconstruction
221   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginPHOS)) 
222     {
223       if (!fRawDataHandler) 
224         {
225           fRawDataHandler = new AliHLTPHOSAgent::AliHLTPHOSRawDataHandler;
226         }
227       return fRawDataHandler;
228     }
229
230   return NULL;
231 }
232
233 int AliHLTPHOSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
234 {
235   // see header file for class documentation
236   if (pInstance==NULL) return -EINVAL;
237
238   if (pInstance==fRawDataHandler) {
239     delete fRawDataHandler;
240     fRawDataHandler=NULL;
241   }
242   return 0;
243 }
244
245 AliHLTPHOSAgent::AliHLTPHOSRawDataHandler::AliHLTPHOSRawDataHandler()
246 {
247   // see header file for class documentation
248 }
249
250 AliHLTPHOSAgent::AliHLTPHOSRawDataHandler::~AliHLTPHOSRawDataHandler()
251 {
252   // see header file for class documentation
253 }
254
255 int AliHLTPHOSAgent::AliHLTPHOSRawDataHandler::ProcessData(AliHLTOUT* pData)
256 {
257   // see header file for class documentation
258   if (!pData) return -EINVAL;
259
260   AliHLTPHOSMapper mapper;
261   mapper.InitDDLSpecificationMapping();
262
263   AliHLTComponentDataType dt = kAliHLTVoidDataType;
264   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
265   int iResult = pData->GetDataBlockDescription(dt, spec);
266   if (iResult>=0) 
267     {
268       int ddl = -1;
269       if((ddl = mapper.GetDDLFromSpec(spec)) >=0)
270         {
271           iResult = ddl;
272         }
273     } 
274   else 
275     {
276       HLTError("Handler can not process data inconsistent with a single PHOS DDL from specification % d", spec);
277       iResult=-EBADMSG;
278     }
279   return iResult;
280 }