]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSModuleMergerComponent.cxx
731ce66423436b3b1c7746802f0e77f547a21c54
[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 <cstdio>
23 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
24
25
26 const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
27 const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::fgkOutputDataType=kAliHLTVoidDataType;
28
29
30 AliHLTPHOSModuleMergerComponent gAliHLTPHOSModuleMergerComponent;
31 AliHLTPHOSModuleMergerComponent:: AliHLTPHOSModuleMergerComponent():AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
32 {
33
34
35
36
37 AliHLTPHOSModuleMergerComponent::~ AliHLTPHOSModuleMergerComponent()
38 {
39
40 }
41
42
43 AliHLTPHOSModuleMergerComponent::AliHLTPHOSModuleMergerComponent(const  AliHLTPHOSModuleMergerComponent & ) : AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
44 {
45
46 }
47
48
49 int 
50 AliHLTPHOSModuleMergerComponent::Deinit()
51 {
52   return 0;
53 }
54
55
56 int 
57 AliHLTPHOSModuleMergerComponent::DoDeinit()
58 {
59   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSModuleMerger DoDeinit");
60   return 0;
61
62 }
63
64
65 const char* 
66 AliHLTPHOSModuleMergerComponent::GetComponentID()
67 {
68   return "ModuleMerger";
69 }
70
71
72 void
73  AliHLTPHOSModuleMergerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
74 {
75   ///
76   const AliHLTComponentDataType* pType=fgkInputDataTypes;
77   while (pType->fID!=0) 
78     {
79       list.push_back(*pType);
80       pType++;
81     }
82 }
83
84
85 AliHLTComponentDataType 
86 AliHLTPHOSModuleMergerComponent::GetOutputDataType()
87 {
88   ///
89   return AliHLTPHOSDefinitions::gkCellEnergyDataType;
90 }
91
92
93 void
94 AliHLTPHOSModuleMergerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
95 {
96   ///
97   constBase = 30;
98   inputMultiplier = 1;
99 }
100
101
102 int  AliHLTPHOSModuleMergerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
103                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
104                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
105 {
106   //Merging of data from 4 RCUS to one module
107   
108   unsigned long ndx;
109   const AliHLTComponentBlockData* iter = NULL;   
110   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
111
112   Reset();
113
114   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
115     {
116       int tmpModuleID = 0;
117       int tmpRcuX = 0;
118       int tmpRcuZ = 0;
119       int tmpCnt =  cellDataPtr->fCnt;
120       iter = blocks+ndx;
121       AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
122       tmpModuleID = cellDataPtr->fModuleID;
123       tmpRcuX     = cellDataPtr->fRcuX ;
124       tmpRcuZ     = cellDataPtr->fRcuZ;
125
126       for(int i= 0; i< tmpCnt; tmpCnt ++)
127         {
128           if(cellDataPtr->fValidData[i].fGain == HIGH_GAIN)
129             {
130               fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ZROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX + N_XCOLUMNS_RCU*tmpRcuX][HIGH_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
131             }
132           else if(cellDataPtr->fValidData[i].fGain == LOW_GAIN)
133             {
134               fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX +N_COLUMNS_RCU*tmpRcuX][LOW_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
135             }
136         }
137       
138     }
139
140   DumpData(1);
141   fEventCount++; 
142   return 0;
143   
144 }//end DoEvent
145
146
147 int
148 AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
149 {
150   //See base classs for documenation
151   Reset();
152
153   if (argc==0 && argv==NULL) {
154     // this is currently just to get rid of the warning "unused parameter"
155   }
156   return 0;
157 }
158
159
160 void
161 AliHLTPHOSModuleMergerComponent::DumpData(int gain)
162 {
163   if(gain < 0 || gain >  N_GAINS)
164     {
165       cout <<"AliHLTPHOSModuleMergerComponent::DumpDat: Error, gain must be between " << 0 << "and" << N_GAINS << endl;
166     }
167   
168   for(int mod = 0; mod < N_MODULES; mod ++)
169     {
170       if(gain == HIGH_GAIN)
171         {
172           cout << endl <<" ***********  MODULE" << mod << "****HIGH_GAIN" <<"************" << endl;
173         }
174       else if(gain == LOW_GAIN)
175         {
176           cout << endl <<" ***********  MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
177         }
178       
179       for(int row = 0; row < N_ROWS_MOD; row ++)
180         {
181           for(int col = 0; col < N_COLUMNS_MOD; col ++)
182             {
183                       if( fMaxValues[mod][row][col][0] != 0)
184                 { 
185                                   cout << fMaxValues[mod][row][col][0] << "\t";
186                 }
187             }
188         } 
189     }
190 }
191
192
193
194 void
195 AliHLTPHOSModuleMergerComponent::Reset()
196 {
197   for(int mod = 0; mod < N_MODULES; mod ++)
198     {
199       for(int row = 0; row <  N_ROWS_MOD; row ++)
200         {
201           for(int col = 0; col < N_COLUMNS_MOD; col ++)
202             {
203               for(int gain = 0; gain < N_GAINS; gain ++ )
204                 { 
205
206                   fMaxValues[mod][row][col][gain] = 0;
207                 }
208             }
209         }
210     }
211
212   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
213     {
214       fTmpChannelData[i] = 0;
215     }
216 } // end Reset
217
218 void
219 AliHLTPHOSModuleMergerComponent::ResetDataPtr()
220 {
221   for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
222     {
223       fTmpChannelData[i] = 0;
224     }
225 }
226
227
228 void 
229 AliHLTPHOSModuleMergerComponent::SetEquippmentId(int id)
230 {
231   fEquippmentID = id;
232 }
233
234 int 
235 AliHLTPHOSModuleMergerComponent::GetEquippmentId()
236 {
237   return  fEquippmentID;
238 }
239
240
241 AliHLTComponent*
242 AliHLTPHOSModuleMergerComponent::Spawn()
243 {
244   return new AliHLTPHOSModuleMergerComponent;
245 }
246
247