]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSModuleMergerComponent.cxx
Chnages was necessary in this class beacause the format
[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].fRow +  N_ROWS_RCU*tmpRcuX][ cellDataPtr->fValidData[i].fCol + N_COLUMNS_RCU*tmpRcuZ][HIGH_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
126               //   fMaxValues[0][0][0][0] = 0;
127             }
128           else if(cellDataPtr->fValidData[i].fGain == LOW_GAIN)
129             {
130                    fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fRow +  N_ROWS_RCU*tmpRcuX][ cellDataPtr->fValidData[i].fCol +N_COLUMNS_RCU*tmpRcuZ][LOW_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
131               //    fMaxValues[0][0][0][0]=0;
132             }
133         }
134       
135     }
136
137   DumpData(1);
138   fEventCount++; 
139   return 0;
140   
141 }//end DoEvent
142
143
144 int
145 AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
146 {
147   Reset();
148
149   if (argc==0 && argv==NULL) {
150     // this is currently just to get rid of the warning "unused parameter"
151   }
152   return 0;
153 }
154
155
156 void
157 AliHLTPHOSModuleMergerComponent::DumpData(int gain)
158 {
159
160   if(gain < 0 || gain >  N_GAINS)
161     {
162       cout <<"AliHLTPHOSModuleMergerComponent::DumpDat: Error, gain must be between " << 0 << "and" << N_GAINS << endl;
163     }
164   
165   for(int mod = 0; mod < N_MODULES; mod ++)
166     {
167       if(gain == HIGH_GAIN)
168         {
169           cout << endl <<" ***********  MODULE" << mod << "****HIGH_GAIN" <<"************" << endl;
170         }
171       else if(gain == LOW_GAIN)
172         {
173           cout << endl <<" ***********  MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
174         }
175       
176       for(int row = 0; row < N_ROWS_MOD; row ++)
177         {
178           for(int col = 0; col < N_COLUMNS_MOD; col ++)
179             {
180                       if( fMaxValues[mod][row][col][0] != 0)
181                 { 
182                                   cout << fMaxValues[mod][row][col][0] << "\t";
183                 }
184             }
185         } 
186     }
187 }
188
189
190
191 void
192 AliHLTPHOSModuleMergerComponent::Reset()
193 {
194   for(int mod = 0; mod < N_MODULES; mod ++)
195     {
196       for(int row = 0; row <  N_ROWS_MOD; row ++)
197         {
198           for(int col = 0; col < N_COLUMNS_MOD; col ++)
199             {
200               for(int gain = 0; gain < N_GAINS; gain ++ )
201                 { 
202
203                   fMaxValues[mod][row][col][gain] = 0;
204                 }
205             }
206         }
207     }
208
209   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
210     {
211       fTmpChannelData[i] = 0;
212     }
213 } // end Reset
214
215 void
216 AliHLTPHOSModuleMergerComponent::ResetDataPtr()
217 {
218   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
219     {
220       fTmpChannelData[i] = 0;
221     }
222 }
223
224
225 void 
226 AliHLTPHOSModuleMergerComponent::SetEquippmentId(int id)
227 {
228   fEquippmentID = id;
229 }
230
231 int 
232 AliHLTPHOSModuleMergerComponent::GetEquippmentId()
233 {
234   return  fEquippmentID;
235 }
236
237
238 AliHLTComponent*
239 AliHLTPHOSModuleMergerComponent::Spawn()
240 {
241   return new AliHLTPHOSModuleMergerComponent;
242 }
243
244