]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
- fixing compilation warnings
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterAnalyserComponent.cxx
CommitLineData
1b41ab20 1// $Id$
2
fa0a9bec 3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
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#include "AliHLTPHOSClusterAnalyserComponent.h"
18#include "AliHLTPHOSClusterAnalyser.h"
87434909 19#include "AliHLTPHOSRecPointHeaderStruct.h"
933eb3ed 20#include "AliHLTPHOSDigitDataStruct.h"
7fc04b67 21#include "AliHLTCaloClusterDataStruct.h"
46d8500c 22#include "AliPHOSGeoUtils.h"
32f4f8c9 23#include "TGeoManager.h"
24#include "AliCDBEntry.h"
25#include "AliCDBManager.h"
26#include "AliCDBPath.h"
27
fa0a9bec 28
29/** @file AliHLTPHOSClusterAnalyserComponent.cxx
30 @author Oystein Djuvsland
31 @date
32 @brief A cluster analyser component for PHOS HLT
33*/
34
35// see header file for class documentation
36// or
37// refer to README to build package
38// or
39// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40
41#if __GNUC__>= 3
42using namespace std;
43#endif
44
32f4f8c9 45TGeoManager* gGeoManager = NULL;
fa0a9bec 46
47AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
48
49
b444d727 50AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(),
51 fClusterAnalyserPtr(0),
52 fDoDeconvolution(0),
32f4f8c9 53 fDoCalculateMoments(0),
54 fPHOSGeometry(0)
fa0a9bec 55{
56 //See headerfile for documentation
32f4f8c9 57
fa0a9bec 58}
59
60AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
61{
62 //See headerfile for documentation
63
64 if (fClusterAnalyserPtr)
65 {
66 delete fClusterAnalyserPtr;
67 fClusterAnalyserPtr = 0;
68 }
69}
70
71int
72AliHLTPHOSClusterAnalyserComponent::Deinit()
73{
74 //See headerfile for documentation
75
76 if (fClusterAnalyserPtr)
77 {
78 delete fClusterAnalyserPtr;
79 fClusterAnalyserPtr = 0;
80 }
81 return 0;
82}
83
84const Char_t*
85AliHLTPHOSClusterAnalyserComponent::GetComponentID()
86{
87 //See headerfile for documentation
88
89 return "PhosClusterAnalyser";
90}
91
92void
93AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
94{
95 //See headerfile for documentation
94594220 96 list.clear();
e304ea31 97 list.push_back(AliHLTPHOSDefinitions::fgkRecPointDataType);
fa0a9bec 98}
99
100AliHLTComponentDataType
101AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
102{
103 //See headerfile for documentation
104
947064ec 105 return kAliHLTDataTypeCaloCluster;
fa0a9bec 106}
107
108void
109AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
110
111{
112 //See headerfile for documentation
113
7fc04b67 114 constBase = sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t);
e304ea31 115 inputMultiplier = 1.2;
fa0a9bec 116}
117
118AliHLTComponent*
119AliHLTPHOSClusterAnalyserComponent::Spawn()
120{
121 //See headerfile for documentation
122
123 return new AliHLTPHOSClusterAnalyserComponent();
124}
125
126int
127AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
128 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
129 std::vector<AliHLTComponentBlockData>& outputBlocks)
130{
131 //See headerfile for documentation
132
e304ea31 133 //UInt_t tSize = 0;
fa0a9bec 134 UInt_t offset = 0;
135 UInt_t mysize = 0;
25b7f84c 136 Int_t nClusters = 0;
fa0a9bec 137
138 AliHLTUInt8_t* outBPtr;
139 outBPtr = outputPtr;
140 const AliHLTComponentBlockData* iter = 0;
141 unsigned long ndx;
142
143 UInt_t specification = 0;
144
b210e538 145 // AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
e304ea31 146
7fc04b67 147 fClusterAnalyserPtr->SetCaloClusterDataPtr(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr + sizeof(AliHLTCaloClusterHeaderStruct)));
fa0a9bec 148 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
149 {
25b7f84c 150 iter = blocks+ndx;
e304ea31 151 if (iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType)
fa0a9bec 152 {
e304ea31 153 continue;
fa0a9bec 154 }
155 specification = specification|iter->fSpecification;
933eb3ed 156 AliHLTPHOSDigitHeaderStruct *digitHeader = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(iter->fPtr);
933eb3ed 157 fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(reinterpret_cast<Long_t>(iter->fPtr) + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeader->fNDigits*sizeof(AliHLTPHOSDigitDataStruct)), digitHeader);
fa0a9bec 158 if(fDoDeconvolution)
159 {
160 fClusterAnalyserPtr->DeconvoluteClusters();
161 }
162 fClusterAnalyserPtr->CalculateCenterOfGravity();
163 if(fDoCalculateMoments)
164 {
165 fClusterAnalyserPtr->CalculateRecPointMoments();
166 }
e304ea31 167 nClusters = fClusterAnalyserPtr->CreateClusters(size, mysize);
fa0a9bec 168 }
e304ea31 169
170 if(nClusters == -1)
171 {
172 HLTError("Running out of buffer, exiting for safety.");
173 return -ENOBUFS;
174 }
87434909 175 for(int i = 0; i < nClusters; i++)
176 {
177
178 }
179
947064ec 180 HLTDebug("Number of clusters: %d", nClusters);
181 // caloClusterHeaderPtr->fNClusters = nClusters;
182 reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr)->fNClusters = nClusters;
7fc04b67 183 mysize += sizeof(AliHLTCaloClusterHeaderStruct);
25b7f84c 184
fa0a9bec 185 AliHLTComponentBlockData bd;
186 FillBlockData( bd );
187 bd.fOffset = offset;
188 bd.fSize = mysize;
947064ec 189 bd.fDataType = kAliHLTDataTypeCaloCluster;
fa0a9bec 190 bd.fSpecification = specification;
191 outputBlocks.push_back( bd );
25b7f84c 192
e304ea31 193 if ( mysize > size )
fa0a9bec 194 {
e304ea31 195 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", mysize, size );
fa0a9bec 196 return EMSGSIZE;
197 }
25b7f84c 198
199 fPhosEventCount++;
9bf87c6f 200
201 size = mysize;
fa0a9bec 202 return 0;
203
204}
205
32f4f8c9 206int
46d8500c 207AliHLTPHOSClusterAnalyserComponent::Reconfigure(const char *cdbEntry, const char */*chainId*/)
32f4f8c9 208{
209 // see header file for class documentation
210
211 // configure from the specified entry or the default
dd74da33 212
46d8500c 213 ConfigureFromCDBTObjString(cdbEntry);
dd74da33 214
215 return 0;
216}
217
dd74da33 218
219int
220AliHLTPHOSClusterAnalyserComponent::ScanConfigurationArgument(int argc, const char **argv)
221{
222 //See header file for documentation
223
224 if(argc <= 0) return 0;
225
226 int i=0;
227
228 TString argument=argv[i];
229
230 if (argument.CompareTo("-dodeconvolution") == 0)
231 {
232 fDoDeconvolution = true;
233 return 1;
234 }
235 if (argument.CompareTo("-doclusterfit") == 0)
236 {
237 fClusterAnalyserPtr->SetDoClusterFit();
238 fDoCalculateMoments = true;
239 return 1;
240 }
241 if (argument.CompareTo("-haveCPV") == 0)
242 {
243 fClusterAnalyserPtr->SetHaveCPVInfo();
244 return 1;
245 }
246 if (argument.CompareTo("-doPID") == 0)
247 {
248 fClusterAnalyserPtr->SetDoPID();
249 return 1;
250 }
251 if (argument.CompareTo("-havedistbadchannel") == 0)
252 {
253 fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
254 return 1;
255 }
256
257 return 0;
258}
259
260int
261AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
262{
263
264 //See headerfile for documentation
265
341aab10 266 HLTError("Doing init...");
267
dd74da33 268 fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
269
c375e15d 270 // const char *path = "HLT/ConfigPHOS/ClusterAnalyserComponent";
dd74da33 271
272 GetGeometryFromCDB();
273
341aab10 274 // ConfigureFromCDBTObjString(path);
dd74da33 275
276 for (int i = 0; i < argc; i++)
277 {
46d8500c 278 ScanConfigurationArgument(i, argv);
dd74da33 279 }
280
281 return 0;
282}
283
284int
285AliHLTPHOSClusterAnalyserComponent::GetGeometryFromCDB()
286{
341aab10 287 HLTError("Getting geometry...");
288
289 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
dd74da33 290
291 AliCDBPath path("GRP","Geometry","Data");
46d8500c 292 if(path.GetPath())
32f4f8c9 293 {
f1bfc65f 294 // HLTInfo("configure from entry %s", path.GetPath());
32f4f8c9 295 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
296 if (pEntry)
297 {
298 if(!fPHOSGeometry)
299 {
300 delete fPHOSGeometry;
301 fPHOSGeometry = 0;
302 }
303
304 gGeoManager = (TGeoManager*) pEntry->GetObject();
341aab10 305 HLTError("gGeoManager = 0x%x", gGeoManager);
306 if(gGeoManager)
307 {
308 fPHOSGeometry = new AliPHOSGeoUtils("PHOS", "noCPV");
309 fClusterAnalyserPtr->SetGeometry(fPHOSGeometry);
310 }
32f4f8c9 311
312 }
313 else
314 {
f1bfc65f 315 // HLTError("can not fetch object \"%s\" from OCDB", path);
fa0a9bec 316 }
fa0a9bec 317 }
6aca9e6e 318 return 0;
fa0a9bec 319}