]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSClusterAnalyserComponent.cxx
613528aa9d7d318bea6a34f7353197961a6e0602
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterAnalyserComponent.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Oystein Djuvsland <oysteind@ift.uib.no>                       *
5  *                                                                        *
6  * Permission to use, copy, modify and distribute this software and its   *
7  * documentation strictly for non-commercial purposes is hereby granted   *
8  * without fee, provided that the above copyright notice appears in all   *
9  * copies and that both the copyright notice and this permission notice   *
10  * appear in the supporting documentation. The authors make no claims     *
11  * about the suitability of this software for any purpose. It is          *
12  * provided "as is" without express or implied warranty.                  *
13  **************************************************************************/
14
15 #include "AliHLTPHOSClusterAnalyserComponent.h"
16 #include "AliHLTPHOSClusterAnalyser.h"
17 #include "AliHLTPHOSRecPointContainerStruct.h"
18 #include "AliHLTPHOSCaloClusterContainerStruct.h"
19
20 /** @file   AliHLTPHOSClusterAnalyserComponent.cxx
21     @author Oystein Djuvsland
22     @date   
23     @brief  A cluster analyser component for PHOS HLT
24 */
25
26 // see header file for class documentation
27 // or
28 // refer to README to build package
29 // or
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31
32 #if __GNUC__>= 3
33 using namespace std;
34 #endif
35
36 const AliHLTComponentDataType AliHLTPHOSClusterAnalyserComponent::fgkInputDataTypes[]=
37   {
38     kAliHLTVoidDataType,{0,"",""}
39   };
40
41 AliHLTPHOSClusterAnalyserComponent gAliHLTPHOSClusterAnalyserComponent;
42
43
44 AliHLTPHOSClusterAnalyserComponent::AliHLTPHOSClusterAnalyserComponent(): 
45 AliHLTPHOSProcessor(), 
46 fClusterAnalyserPtr(0)
47 {
48   //See headerfile for documentation
49 }
50
51 AliHLTPHOSClusterAnalyserComponent::~AliHLTPHOSClusterAnalyserComponent()
52 {
53   //See headerfile for documentation
54
55   if (fClusterAnalyserPtr)
56     {
57       delete fClusterAnalyserPtr;
58       fClusterAnalyserPtr = 0;
59     }
60 }
61
62 int
63 AliHLTPHOSClusterAnalyserComponent::Deinit()
64 {
65   //See headerfile for documentation
66
67   if (fClusterAnalyserPtr)
68     {
69       delete fClusterAnalyserPtr;
70       fClusterAnalyserPtr = 0;
71     }
72   return 0;
73 }
74
75 const Char_t*
76 AliHLTPHOSClusterAnalyserComponent::GetComponentID()
77 {
78   //See headerfile for documentation
79
80   return "PhosClusterAnalyser";
81 }
82
83 void
84 AliHLTPHOSClusterAnalyserComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
85 {
86   //See headerfile for documentation
87
88   const AliHLTComponentDataType* pType=fgkInputDataTypes;
89   while (pType->fID!=0)
90     {
91       list.push_back(*pType);
92       pType++;
93     }
94 }
95
96 AliHLTComponentDataType
97 AliHLTPHOSClusterAnalyserComponent::GetOutputDataType()
98 {
99   //See headerfile for documentation
100
101   return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
102 }
103
104 void
105 AliHLTPHOSClusterAnalyserComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
106
107 {
108   //See headerfile for documentation
109
110   constBase = 0;
111   inputMultiplier = 1;
112 }
113
114 AliHLTComponent*
115 AliHLTPHOSClusterAnalyserComponent::Spawn()
116 {
117   //See headerfile for documentation
118
119   return new AliHLTPHOSClusterAnalyserComponent();
120 }
121
122 int
123 AliHLTPHOSClusterAnalyserComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
124                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
125                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
126 {
127   //See headerfile for documentation
128
129   UInt_t tSize            = 0;
130   UInt_t offset           = 0;
131   UInt_t mysize           = 0;
132   Int_t nRecPoints        = 0;
133   Int_t nDigits           = 0;
134   Int_t j =0;
135
136   AliHLTUInt8_t* outBPtr;
137   outBPtr = outputPtr;
138   const AliHLTComponentBlockData* iter = 0;
139   unsigned long ndx;
140
141   UInt_t specification = 0;
142
143   AliHLTPHOSRecPointContainerStruct* recPointContainerPtr = 0;
144   fClusterAnalyserPtr->SetCaloClusterContainer((AliHLTPHOSCaloClusterContainerStruct*)outBPtr);
145   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
146     {
147       iter = blocks+ndx;
148       if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTRecPointDataType)
149         {
150           continue;
151         }
152       specification = specification|iter->fSpecification;
153       recPointContainerPtr = reinterpret_cast<AliHLTPHOSRecPointContainerStruct*>(iter->fPtr);
154       fClusterAnalyserPtr->SetRecPointContainer(recPointContainerPtr);
155       if(fDoDeconvolution)
156         {
157           fClusterAnalyserPtr->DeconvoluteClusters();
158         }
159       fClusterAnalyserPtr->CalculateCenterOfGravity();
160       if(fDoCalculateMoments)
161         {
162           fClusterAnalyserPtr->CalculateRecPointMoments();
163         }
164       fClusterAnalyserPtr->CreateClusters();
165       
166     }
167
168   mysize = 0;
169   offset = tSize;
170
171   mysize += sizeof(AliHLTPHOSCaloClusterContainerStruct);
172   //cout << "Size of calo cluster container: " << mysize << endl;
173   AliHLTComponentBlockData bd;
174   FillBlockData( bd );
175   bd.fOffset = offset;
176   bd.fSize = mysize;
177   bd.fDataType = AliHLTPHOSDefinitions::fgkCaloClusterDataType;
178   bd.fSpecification = specification;
179   outputBlocks.push_back( bd );
180
181   tSize += mysize;
182   outBPtr += mysize;
183
184   if ( tSize > size )
185     {
186       Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterAnalyserComponent::DoEvent", "Too much data",
187                "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
188                , tSize, size );
189       return EMSGSIZE;
190     }
191   
192   return 0;
193
194 }
195
196 int
197 AliHLTPHOSClusterAnalyserComponent::DoInit(int argc, const char** argv )
198 {
199   //See headerfile for documentation
200   
201   fClusterAnalyserPtr = new AliHLTPHOSClusterAnalyser();
202   for (int i = 0; i < argc; i++)
203     {
204       if(!strcmp("-dodeconvolution", argv[i]))
205         {
206           fDoDeconvolution = true;
207         }
208       if(!strcmp("-doclusterfit", argv[i]))
209         {
210           fClusterAnalyserPtr->SetDoClusterFit();
211           fDoCalculateMoments = true;
212         }
213       if(!strcmp("-haveCPV", argv[i]))
214         {
215           fClusterAnalyserPtr->SetHaveCPVInfo();
216         }
217       if(!strcmp("-doPID", argv[i]))
218         {
219           fClusterAnalyserPtr->SetDoPID();
220         } 
221       if(!strcmp("-havedistbadchannel", argv[i]))
222         {
223           fClusterAnalyserPtr->SetHaveDistanceToBadChannel();
224         }
225
226     }
227
228   return 0;
229 }