]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSHistogramProducerComponent.cxx
New on per RCU data containers
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSHistogramProducerComponent.cxx
CommitLineData
753a19c1 1/**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
955f6ca8 4 * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE *
5 * offline/HLT Project. Contributors are mentioned in the code where *
6 * appropriate. *
753a19c1 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 "AliHLTPHOSHistogramProducerComponent.h"
18#include <iostream>
19#include "stdio.h"
20#include "AliRawReaderMemory.h"
21#include "AliCaloRawStream.h"
22#include <cstdlib>
23#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
24#include "AliHLTPHOSModuleCellAccumulatedEnergyDataStruct.h"
25
26
2f166df5 27
753a19c1 28const AliHLTComponentDataType AliHLTPHOSHistogramProducerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
29const AliHLTComponentDataType AliHLTPHOSHistogramProducerComponent::outputDataType=kAliHLTVoidDataType;
30
31
32AliHLTPHOSHistogramProducerComponent gAliHLTPHOSHistogramProducerComponent;
33
955f6ca8 34/*************************************************************************
35* Class AliHLTPHOSHistogramProducerComponent accumulating histograms *
36* with amplitudes per PHOS channel *
37* It is intended to run at the HLT farm *
38* and it fills the histograms with amplitudes per channel. *
39* Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
40**************************************************************************/
2f166df5 41AliHLTPHOSHistogramProducerComponent:: AliHLTPHOSHistogramProducerComponent():AliHLTProcessor(), fEventCount(0), fEquippmentID(0)
753a19c1 42{
43 Reset();
44}
45
46
47AliHLTPHOSHistogramProducerComponent::~ AliHLTPHOSHistogramProducerComponent()
48{
49
50}
51
52
2f166df5 53AliHLTPHOSHistogramProducerComponent::AliHLTPHOSHistogramProducerComponent(const AliHLTPHOSHistogramProducerComponent & ) : AliHLTProcessor(), fEventCount(0), fEquippmentID(0)
753a19c1 54{
55
56}
57
58
59int
60AliHLTPHOSHistogramProducerComponent::Deinit()
61{
62 return 0;
63}
64
65
66int
67AliHLTPHOSHistogramProducerComponent::DoDeinit()
68{
69 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSHistogramProducer DoDeinit");
70 return 0;
753a19c1 71}
72
73
74const char*
75AliHLTPHOSHistogramProducerComponent::GetComponentID()
76{
77 return "HistogramProducer";
78}
79
80
81void
82 AliHLTPHOSHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
83{
84 const AliHLTComponentDataType* pType=inputDataTypes;
85 while (pType->fID!=0)
86 {
87 list.push_back(*pType);
88 pType++;
89 }
90}
91
92
93AliHLTComponentDataType
94AliHLTPHOSHistogramProducerComponent::GetOutputDataType()
95{
96 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
97}
98
99
100void
101AliHLTPHOSHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
102{
103 constBase = 30;
104 inputMultiplier = 1;
105}
106
107
108int AliHLTPHOSHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
109 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
110 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
111{
112 unsigned long ndx;
113 UInt_t offset = 0;
114 UInt_t mysize = 0;
115 UInt_t tSize = 0;
116
117 const AliHLTComponentBlockData* iter = NULL;
118 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
119 AliHLTUInt8_t* outBPtr;
120 outBPtr = outputPtr;
753a19c1 121 fOutPtr = (AliHLTPHOSModuleCellAccumulatedEnergyDataStruct*)outBPtr;
753a19c1 122
753a19c1 123 int tmpCnt;
753a19c1 124 AliHLTUInt8_t tmpModuleID;
125 AliHLTUInt8_t tmpRcuX;
126 AliHLTUInt8_t tmpRcuZ;
127
128 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129 {
130 iter = blocks+ndx;
131 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
132 tmpCnt = cellDataPtr->fCnt;
133
134 tmpModuleID = cellDataPtr->fModuleID;
753a19c1 135 tmpRcuX = cellDataPtr->fRcuX ;
136 tmpRcuZ = cellDataPtr->fRcuZ;
137
753a19c1 138 fOutPtr->fModuleID = tmpModuleID;
05be0766 139
753a19c1 140 int tmpGain;
141 int tmpZ;
142 int tmpX;
753a19c1 143
955f6ca8 144 // for(int i= 0; i< tmpCnt; i ++)
145 for(int i= 0; i <= tmpCnt; i ++)
753a19c1 146 {
147 tmpZ = cellDataPtr->fValidData[i].fZ + N_ZROWS_RCU*tmpRcuZ;
148 tmpX = cellDataPtr->fValidData[i].fX + N_XCOLUMNS_RCU*tmpRcuX;
149
150 if(cellDataPtr->fValidData[i].fGain == HIGH_GAIN)
151 {
152 fAccumulatedValues[tmpZ][tmpX][HIGH_GAIN] += cellDataPtr->fValidData[i].fEnergy;
153 fHits[tmpZ][tmpX][HIGH_GAIN] ++;
154 }
155 else if(cellDataPtr->fValidData[i].fGain == LOW_GAIN)
156 {
157 fAccumulatedValues[tmpZ][tmpX][LOW_GAIN] += cellDataPtr->fValidData[i].fEnergy;
158 fHits[tmpZ][tmpX][LOW_GAIN] ++;
159
160 }
161 }
162 }
163
164
165 for(int z=0; z < N_ZROWS_MOD; z ++ )
166 {
167 for(int x = 0; x < N_XCOLUMNS_MOD; x ++)
168 {
169 for(int gain =0; gain < N_GAINS; gain ++)
170 {
171 fOutPtr->fAccumulatedEnergies[z][x][gain] = fAccumulatedValues[z][x][gain];
172 fOutPtr->fHits[z][x][gain] = fHits[z][x][gain];
173 }
174 }
175 }
176
177
178 //pushing data to shared output memory
179 mysize += sizeof(AliHLTPHOSModuleCellAccumulatedEnergyDataStruct);
180 AliHLTComponentBlockData bd;
181 FillBlockData( bd );
182 bd.fOffset = offset;
183 bd.fSize = mysize;
184 bd.fDataType = AliHLTPHOSDefinitions::gkCellAccumulatedEnergyDataType;
185 bd.fSpecification = 0xFFFFFFFF;
186 outputBlocks.push_back( bd );
187 tSize += mysize;
188 outBPtr += mysize;
189
190 if( tSize > size )
191 {
192 Logging( kHLTLogFatal, "HLT::AliHLTHistogramProducerComponent::DoEvent", "Too much data",
193 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
194 , tSize, size );
195 return EMSGSIZE;
196 }
197
753a19c1 198 fEventCount++;
199 return 0;
200}//end DoEvent
201
202
203int
204AliHLTPHOSHistogramProducerComponent::DoInit( int argc, const char** argv )
205{
206 Reset();
207 if (argc==0 && argv==NULL) {
208 // this is currently just to get rid of the warning "unused parameter"
209 }
210 return 0;
211}
212
213
214void
215AliHLTPHOSHistogramProducerComponent::DumpData(int gain)
216{
217
218 if(gain < 0 || gain > N_GAINS)
219 {
220 cout <<"AliHLTPHOSHistogramProducerComponent::DumpDat: Error, gain must be between " << 0 << "and" << N_GAINS << endl;
221 }
222
223 for(int mod = 0; mod < N_MODULES; mod ++)
224 {
225 if(gain == HIGH_GAIN)
226 {
227 cout << endl <<" *********** MODULE" << mod << "****HIGH_GAIN" <<"************" << endl;
228 }
229 else if(gain == LOW_GAIN)
230 {
231 cout << endl <<" *********** MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
232 }
233
234 for(int row = 0; row < N_ROWS_MOD; row ++)
235 {
236 for(int col = 0; col < N_COLUMNS_MOD; col ++)
237 {
238 if(fAccumulatedValues[row][col][0] != 0)
239 {
240 cout << fAccumulatedValues[row][col][0] << "\t";
241 }
242 }
243 }
244 }
245}
246
247
248
249void
250AliHLTPHOSHistogramProducerComponent::Reset()
251{
252 for(int mod = 0; mod < N_MODULES; mod ++)
253 {
254 for(int row = 0; row < N_ROWS_MOD; row ++)
255 {
256 for(int col = 0; col < N_COLUMNS_MOD; col ++)
257 {
258 for(int gain = 0; gain < N_GAINS; gain ++ )
259 {
260 fAccumulatedValues[row][col][gain] = 0;
261 fHits[row][col][gain] = 0;
262 }
263 }
264 }
265 }
266
267 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
268 {
269 fTmpChannelData[i] = 0;
270 }
271} // end Reset
272
273void
274AliHLTPHOSHistogramProducerComponent::ResetDataPtr()
275{
276 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
277 {
278 fTmpChannelData[i] = 0;
279 }
280}
281
282
283void
284AliHLTPHOSHistogramProducerComponent::SetEquippmentId(int id)
285{
286 fEquippmentID = id;
287}
288
289int
290AliHLTPHOSHistogramProducerComponent::GetEquippmentId()
291{
292 return fEquippmentID;
293}
294
295
296AliHLTComponent*
297AliHLTPHOSHistogramProducerComponent::Spawn()
298{
753a19c1 299 return new AliHLTPHOSHistogramProducerComponent;
300}
301
302