]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
- fixes due to new PHOS mapping
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterAnalyserComponent.cxx
1 // $Id$
2
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"
19 #include "AliHLTPHOSRecPointHeaderStruct.h"
20 #include "AliHLTPHOSCaloClusterDataStruct.h"
21 #include "AliHLTPHOSCaloClusterHeaderStruct.h"
22
23 /** @file   AliHLTPHOSClusterAnalyserComponent.cxx
24     @author Oystein Djuvsland
25     @date   
26     @brief  A cluster analyser component for PHOS HLT
27 */
28
29 // see header file for class documentation
30 // or
31 // refer to README to build package
32 // or
33 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
34
35 #if __GNUC__>= 3
36 using namespace std;
37 #endif
38
39 const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]=
40   {
41     kAliHLTVoidDataType,{0,"",""}
42   };
43
44 AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
45
46
47 AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): AliHLTPHOSProcessor(), 
48                                                                           fClusterAnalyserPtr(0),
49                                                                           fDoDeconvolution(0),
50                                                                           fDoCalculateMoments(0)
51 {
52   //See headerfile for documentation
53 }
54
55 AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
56 {
57   //See headerfile for documentation
58
59   if (fClusterAnalyserPtr)
60     {
61       delete fClusterAnalyserPtr;
62       fClusterAnalyserPtr = 0;
63     }
64 }
65
66 int
67 AliHLTPHOSClusterAnalyserComponent::Deinit()
68 {
69   //See headerfile for documentation
70
71   if (fClusterAnalyserPtr)
72     {
73       delete fClusterAnalyserPtr;
74       fClusterAnalyserPtr = 0;
75     }
76   return 0;
77 }
78
79 const Char_t*
80 AliHLTPHOSClusterAnalyserComponent::GetComponentID()
81 {
82   //See headerfile for documentation
83
84   return "PhosClusterAnalyser";
85 }
86
87 void
88 AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
89 {
90   //See headerfile for documentation
91   list.clear();
92   list.push_back(AliHLTPHOSDefinitions::fgkRecPointDataType);
93 }
94
95 AliHLTComponentDataType
96 AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
97 {
98   //See headerfile for documentation
99
100   return AliHLTPHOSDefinitions::fgkCaloClusterDataType;
101 }
102
103 void
104 AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
105
106 {
107   //See headerfile for documentation
108
109   constBase = sizeof(AliHLTPHOSCaloClusterHeaderStruct) + sizeof(AliHLTPHOSCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t);
110   inputMultiplier = 1.2;
111 }
112
113 AliHLTComponent*
114 AliHLTPHOSClusterAnalyserComponent::Spawn()
115 {
116   //See headerfile for documentation
117
118   return new AliHLTPHOSClusterAnalyserComponent();
119 }
120
121 int
122 AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
123                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
124                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
125 {
126   //See headerfile for documentation
127
128   //UInt_t tSize            = 0;
129   UInt_t offset           = 0;
130   UInt_t mysize           = 0;
131   Int_t nClusters         = 0;
132
133   AliHLTUInt8_t* outBPtr;
134   outBPtr = outputPtr;
135   const AliHLTComponentBlockData* iter = 0;
136   unsigned long ndx;
137
138   UInt_t specification = 0;
139
140   AliHLTPHOSCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTPHOSCaloClusterHeaderStruct*>(outBPtr);
141
142   fClusterAnalyserPtr->SetCaloClusterDataPtr(reinterpret_cast<AliHLTPHOSCaloClusterDataStruct*>(outBPtr + sizeof(AliHLTPHOSCaloClusterHeaderStruct)));
143   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
144     {
145       iter = blocks+ndx; 
146       if (iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType)
147         {
148           continue;
149         }
150       specification = specification|iter->fSpecification;
151       fClusterAnalyserPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr));
152       HLTDebug("Number of rec points: %d", (reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(iter->fPtr))->fNRecPoints);
153
154       if(fDoDeconvolution)
155         {
156           fClusterAnalyserPtr->DeconvoluteClusters();
157         }
158       fClusterAnalyserPtr->CalculateCenterOfGravity();
159       if(fDoCalculateMoments)
160         {
161           fClusterAnalyserPtr->CalculateRecPointMoments();
162         }
163       nClusters = fClusterAnalyserPtr->CreateClusters(size, mysize);
164     }
165   
166   if(nClusters == -1)
167     {
168       HLTError("Running out of buffer, exiting for safety.");
169       return -ENOBUFS;
170     }
171   for(int i = 0; i < nClusters; i++)
172     {
173
174     }
175
176   HLTDebug("Number of clusters: %d", nClusters); 
177   caloClusterHeaderPtr->fNClusters = nClusters;
178   mysize += sizeof(AliHLTPHOSCaloClusterHeaderStruct); 
179   
180   AliHLTComponentBlockData bd;
181   FillBlockData( bd );
182   bd.fOffset = offset;
183   bd.fSize = mysize;
184   bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType;
185   bd.fSpecification = specification;
186   outputBlocks.push_back( bd );
187  
188   if ( mysize > size )
189     {
190       Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data","Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", mysize, size );
191       return EMSGSIZE;
192     }
193
194   fPhosEventCount++; 
195
196   size = mysize;  
197   return 0;
198
199 }
200
201 int
202 AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
203 {
204
205   //See headerfile for documentation
206   
207   fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
208   ScanArgumentsModule(argc, argv);
209   for (int i = 0; i < argc; i++)
210     {
211       if(!strcmp("-dodeconvolution", argv[i]))
212         {
213           fDoDeconvolution = true;
214         }
215       if(!strcmp("-doclusterfit", argv[i]))
216         {
217           fClusterAnalyserPtr->SetDoClusterFit();
218           fDoCalculateMoments = true;
219         }
220       if(!strcmp("-haveCPV", argv[i]))
221         {
222           fClusterAnalyserPtr->SetHaveCPVInfo();
223         }
224       if(!strcmp("-doPID", argv[i]))
225         {
226           fClusterAnalyserPtr->SetDoPID();
227         } 
228       if(!strcmp("-havedistbadchannel", argv[i]))
229         {
230           fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
231         }
232
233     }
234
235   return 0;
236 }