]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSModuleMergerComponent.cxx
Cosmetic changes
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSModuleMergerComponent.cxx
1 /**************************************************************************
2  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
3  *                                                                        *
4  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 #include "AliHLTPHOSModuleMergerComponent.h"
17 #include <iostream>
18 #include "stdio.h"
19 #include "AliRawReaderMemory.h"
20 #include "AliCaloRawStream.h"
21 #include <cstdlib>
22 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
23
24
25 const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
26 const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::outputDataType=kAliHLTVoidDataType;
27
28
29 AliHLTPHOSModuleMergerComponent gAliHLTPHOSModuleMergerComponent;
30 AliHLTPHOSModuleMergerComponent:: AliHLTPHOSModuleMergerComponent():AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
31 {
32
33
34
35
36 AliHLTPHOSModuleMergerComponent::~ AliHLTPHOSModuleMergerComponent()
37 {
38
39 }
40
41
42 AliHLTPHOSModuleMergerComponent::AliHLTPHOSModuleMergerComponent(const  AliHLTPHOSModuleMergerComponent & ) : AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
43 {
44
45 }
46
47
48 int 
49 AliHLTPHOSModuleMergerComponent::Deinit()
50 {
51   return 0;
52 }
53
54
55 int 
56 AliHLTPHOSModuleMergerComponent::DoDeinit()
57 {
58   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSModuleMerger DoDeinit");
59   return 0;
60
61 }
62
63
64 const char* 
65 AliHLTPHOSModuleMergerComponent::GetComponentID()
66 {
67   return "ModuleMerger";
68 }
69
70
71 void
72  AliHLTPHOSModuleMergerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
73 {
74   const AliHLTComponentDataType* pType=inputDataTypes;
75   while (pType->fID!=0) 
76     {
77       list.push_back(*pType);
78       pType++;
79     }
80 }
81
82
83 AliHLTComponentDataType 
84 AliHLTPHOSModuleMergerComponent::GetOutputDataType()
85 {
86   return AliHLTPHOSDefinitions::gkCellEnergyDataType;
87 }
88
89
90 void
91 AliHLTPHOSModuleMergerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
92 {
93   constBase = 30;
94   inputMultiplier = 1;
95 }
96
97
98 int  AliHLTPHOSModuleMergerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
99                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
100                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
101 {
102   
103   unsigned long ndx;
104   const AliHLTComponentBlockData* iter = NULL;   
105   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
106
107   Reset();
108
109   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
110     {
111       int tmpModuleID = 0;
112       int tmpRcuX = 0;
113       int tmpRcuZ = 0;
114       int tmpCnt =  cellDataPtr->fCnt;
115       iter = blocks+ndx;
116       AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
117       tmpModuleID = cellDataPtr->fModuleID;
118       tmpRcuX     = cellDataPtr->fRcuX ;
119       tmpRcuZ     = cellDataPtr->fRcuZ;
120
121       for(int i= 0; i< tmpCnt; tmpCnt ++)
122         {
123           if(cellDataPtr->fValidData[i].fGain == HIGH_GAIN)
124             {
125               fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ZROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX + N_XCOLUMNS_RCU*tmpRcuX][HIGH_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
126             }
127           else if(cellDataPtr->fValidData[i].fGain == LOW_GAIN)
128             {
129               fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX +N_COLUMNS_RCU*tmpRcuX][LOW_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
130             }
131         }
132       
133     }
134
135   DumpData(1);
136   fEventCount++; 
137   return 0;
138   
139 }//end DoEvent
140
141
142 int
143 AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
144 {
145   Reset();
146
147   if (argc==0 && argv==NULL) {
148     // this is currently just to get rid of the warning "unused parameter"
149   }
150   return 0;
151 }
152
153
154 void
155 AliHLTPHOSModuleMergerComponent::DumpData(int gain)
156 {
157
158   if(gain < 0 || gain >  N_GAINS)
159     {
160       cout <<"AliHLTPHOSModuleMergerComponent::DumpDat: Error, gain must be between " << 0 << "and" << N_GAINS << endl;
161     }
162   
163   for(int mod = 0; mod < N_MODULES; mod ++)
164     {
165       if(gain == HIGH_GAIN)
166         {
167           cout << endl <<" ***********  MODULE" << mod << "****HIGH_GAIN" <<"************" << endl;
168         }
169       else if(gain == LOW_GAIN)
170         {
171           cout << endl <<" ***********  MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
172         }
173       
174       for(int row = 0; row < N_ROWS_MOD; row ++)
175         {
176           for(int col = 0; col < N_COLUMNS_MOD; col ++)
177             {
178                       if( fMaxValues[mod][row][col][0] != 0)
179                 { 
180                                   cout << fMaxValues[mod][row][col][0] << "\t";
181                 }
182             }
183         } 
184     }
185 }
186
187
188
189 void
190 AliHLTPHOSModuleMergerComponent::Reset()
191 {
192   for(int mod = 0; mod < N_MODULES; mod ++)
193     {
194       for(int row = 0; row <  N_ROWS_MOD; row ++)
195         {
196           for(int col = 0; col < N_COLUMNS_MOD; col ++)
197             {
198               for(int gain = 0; gain < N_GAINS; gain ++ )
199                 { 
200
201                   fMaxValues[mod][row][col][gain] = 0;
202                 }
203             }
204         }
205     }
206
207   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
208     {
209       fTmpChannelData[i] = 0;
210     }
211 } // end Reset
212
213 void
214 AliHLTPHOSModuleMergerComponent::ResetDataPtr()
215 {
216   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
217     {
218       fTmpChannelData[i] = 0;
219     }
220 }
221
222
223 void 
224 AliHLTPHOSModuleMergerComponent::SetEquippmentId(int id)
225 {
226   fEquippmentID = id;
227 }
228
229 int 
230 AliHLTPHOSModuleMergerComponent::GetEquippmentId()
231 {
232   return  fEquippmentID;
233 }
234
235
236 AliHLTComponent*
237 AliHLTPHOSModuleMergerComponent::Spawn()
238 {
239   return new AliHLTPHOSModuleMergerComponent;
240 }
241
242