]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALRawAnalyzerComponent.cxx
Refactoring: rempved the usage of AliHLTEMCALConstant
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawAnalyzerComponent.cxx
CommitLineData
88b2ce82 1/**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
5 * *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to perthi@fys.uio.no *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
88938cd8 19// Base class fro anlyzing EMCAL raww data
20// Further documentation found in base class
21// --------------
22// --------------
23// --------------
24// --------------
25
88b2ce82 26
4fad3687 27
88b2ce82 28#include "AliHLTEMCALRawAnalyzerComponent.h"
29#include "AliHLTEMCALMapper.h"
30#include "AliHLTEMCALDefinitions.h"
c375e15d 31#include "AliHLTCaloChannelDataHeaderStruct.h"
1637625c 32//#include "unistd.h"
88938cd8 33
4fad3687 34
35#include "TStopwatch.h"
36TStopwatch fgWatch; //CRAP PTH
88b2ce82 37
1637625c 38
39AliHLTEMCALRawAnalyzerComponent::AliHLTEMCALRawAnalyzerComponent() : AliHLTCaloRawAnalyzerComponentv3("EMCAL")
88b2ce82 40{
41
1637625c 42
88b2ce82 43}
44
45
46AliHLTEMCALRawAnalyzerComponent::~AliHLTEMCALRawAnalyzerComponent()
47{
48
49}
50
51
52
53void
54AliHLTEMCALRawAnalyzerComponent::GetInputDataTypes( vector <AliHLTComponentDataType>& list)
55{
56 list.clear();
57 list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType | kAliHLTDataOriginEMCAL );
58}
59
60
c375e15d 61
62AliHLTComponentDataType
63AliHLTEMCALRawAnalyzerComponent::GetOutputDataType()
64{
65 //comment
66 return AliHLTEMCALDefinitions::fgkChannelDataType;
67}
68
69
70void
71AliHLTEMCALRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
72{
73 //comment
74 constBase = sizeof(AliHLTCaloChannelDataHeaderStruct);
75 inputMultiplier = 0.5;
76}
77
78
79void
80AliHLTEMCALRawAnalyzerComponent::DoInit()
81{
88938cd8 82 // fgWatch.Start();
1637625c 83
c375e15d 84}
85
4fad3687 86/*
87struct AliHLTComponentDataType
88 {
89 AliHLTUInt32_t fStructSize; /// Size of this structure in bytes.
90 char fID[kAliHLTComponentDataTypefIDsize]; /// Data type identifier.
91 char fOrigin[kAliHLTComponentDataTypefOriginSize]; /// Subsystem or detector origin of the data.
92 };
93*/
94
88b2ce82 95bool
96AliHLTEMCALRawAnalyzerComponent::CheckInputDataType(const AliHLTComponentDataType &datatype)
97{
88938cd8 98 // Cheking if datatype is the correct one before processing
e28d82c3 99 // ////cout << __FILE__ << __LINE__ << " : fID = " << datatype.fID << " : fOrigin = " << datatype.fOrigin << endl;
100 // ////cout << __FILE__ << __LINE__ << "fgkDDLRawDataType->fID = " << AliHLTEMCALDefinitions::fgkDDLRawDataType.fID <<
4fad3687 101 // "fgkDDLRawDataType->fOrigin = " << AliHLTEMCALDefinitions::fgkDDLRawDataType.fOrigin << endl;
102
103
88b2ce82 104 if ( datatype == AliHLTEMCALDefinitions::fgkDDLRawDataType )
105 {
106 return true;
107 }
108 else
109 {
4fad3687 110 // return true;
88b2ce82 111 return false;
112 }
113}
114
115
88b2ce82 116void
4d6be4cd 117AliHLTEMCALRawAnalyzerComponent::InitMapping( const int specification )
88b2ce82 118{
88938cd8 119 //-------------
4d6be4cd 120 if ( fMapperPtr == 0 )
121 {
122 fMapperPtr = new AliHLTEMCALMapper( specification );
123 }
124
125 if(fMapperPtr->GetIsInitializedMapping() == false )
126 {
4fad3687 127 // HLTError("%d:%d, ERROR, mapping not initialized ", __FILE__, __LINE__ );
4d6be4cd 128 exit(-2);
129 }
88b2ce82 130}
c375e15d 131
1637625c 132
c375e15d 133int
134AliHLTEMCALRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& /*trigData*/,
135 AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
136{
137
4fad3687 138 static int evntcnt = 0;
139 static double wlast = -1;
140 static double wcurrent = 0;
1637625c 141 evntcnt ++;
142
4fad3687 143 if( evntcnt %1000 == 0 )
144 {
e28d82c3 145 ////cout << __FILE__ << __LINE__ << " : Processing event " << evntcnt << endl;
4fad3687 146 wlast = wcurrent;
147 wcurrent = fgWatch.RealTime();
e28d82c3 148 ////cout << wlast << ":" << wcurrent << endl;
149 ////cout << __FILE__ << __LINE__ << "The event rate is " << 1000/( wcurrent - wlast ) << " Hz" << endl;
4fad3687 150 fgWatch.Start(kFALSE);
151 // wlast = fgWatch.RealTime();
152 }
153
88938cd8 154 /*
1637625c 155 if( evntcnt %100 == 0 )
c375e15d 156 {
1637625c 157
e28d82c3 158 ////cout << __FILE__ << __LINE__ << " : Processing event " << evntcnt << endl;
1637625c 159 wlast = wcurrent;
1637625c 160 wcurrent = fgWatch.RealTime();
e28d82c3 161 ////cout << wlast << ":" << wcurrent << endl;
162 ////cout << __FILE__ << __LINE__ << "The event rate is " << 100/( wcurrent - wlast ) << " Hz" << endl;
1637625c 163 fgWatch.Start(kFALSE);
1637625c 164 // wlast = fgWatch.RealTime();
88938cd8 165 }
166 */
1637625c 167
c375e15d 168
c375e15d 169 Int_t blockSize = -1;
170 UInt_t totSize = 0;
171 const AliHLTComponentBlockData* iter = NULL;
172 unsigned long ndx;
173
174 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
175 {
e28d82c3 176 // //cout << __FILE__ << __LINE__ << "ndx =" << ndx << endl;
c375e15d 177 iter = blocks+ndx;
178 if( ! CheckInputDataType(iter->fDataType) )
179 {
e28d82c3 180 // //cout << __FILE__ << __LINE__ << " continue" << endl;
c375e15d 181 continue;
182 }
183 else
184 {
e28d82c3 185 // //cout << __FILE__ << __LINE__ << " else" << endl;
4fad3687 186
c375e15d 187 InitMapping( iter->fSpecification);
c375e15d 188 blockSize = DoIt(iter, outputPtr, size, totSize); // Processing the block
189
c375e15d 190 if(blockSize == -1) // If the processing returns -1 we are out of buffer and return an error msg.
191 {
e28d82c3 192 // //cout << __FILE__ << __LINE__ << " return -ENOBUFS " << endl;
c375e15d 193 return -ENOBUFS;
194 }
195
196 totSize += blockSize; //Keeping track of the used size
197 AliHLTComponentBlockData bdChannelData;
198 FillBlockData( bdChannelData );
199 bdChannelData.fOffset = 0; //FIXME
200 bdChannelData.fSize = blockSize;
201
202 // bdChannelData.fDataType = AliHLTPHOSDefinitions::fgkChannelDataType;
203 bdChannelData.fDataType = AliHLTEMCALDefinitions::fgkChannelDataType;
204
205 bdChannelData.fSpecification = iter->fSpecification;
206 outputBlocks.push_back(bdChannelData);
207 outputPtr += blockSize; //Updating position of the output buffer
208 }
209
210 fCaloEventCount++;
211 size = totSize; //telling the framework how much buffer space we have used.
212 }
213
214
215return 0;
216
217}//end DoEvent
218