]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALRawAnalyzerComponent.cxx
- fixing compilation warnings
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawAnalyzerComponent.cxx
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
19 // Base class fro anlyzing EMCAL raww data
20 // Further documentation found in base class
21 // --------------
22 // --------------
23 // --------------
24 // --------------
25
26
27 #include "AliHLTEMCALRawAnalyzerComponent.h"
28 #include "AliHLTEMCALMapper.h"
29 #include "AliHLTEMCALDefinitions.h"
30 #include "AliHLTCaloChannelDataHeaderStruct.h"
31 //#include "unistd.h"
32
33 //#include  "TStopwatch.h"
34 //TStopwatch  fgWatch; //CRAP PTH
35
36
37 AliHLTEMCALRawAnalyzerComponent::AliHLTEMCALRawAnalyzerComponent() : AliHLTCaloRawAnalyzerComponentv3("EMCAL")
38 {
39   
40   
41 }
42
43
44 AliHLTEMCALRawAnalyzerComponent::~AliHLTEMCALRawAnalyzerComponent()
45 {
46
47 }
48
49
50
51 void 
52 AliHLTEMCALRawAnalyzerComponent::GetInputDataTypes( vector <AliHLTComponentDataType>& list)
53 {
54   list.clear();
55   list.push_back( AliHLTEMCALDefinitions::fgkDDLRawDataType   | kAliHLTDataOriginEMCAL );
56 }
57
58
59
60 AliHLTComponentDataType
61 AliHLTEMCALRawAnalyzerComponent::GetOutputDataType()
62 {
63   //comment
64   return AliHLTEMCALDefinitions::fgkChannelDataType;
65 }
66
67
68 void
69 AliHLTEMCALRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
70 {
71   //comment
72   constBase = sizeof(AliHLTCaloChannelDataHeaderStruct);
73   inputMultiplier = 0.5;
74 }
75
76
77 void 
78 AliHLTEMCALRawAnalyzerComponent::DoInit() 
79 {
80   //  fgWatch.Start();
81  
82 }
83
84 bool 
85 AliHLTEMCALRawAnalyzerComponent::CheckInputDataType(const AliHLTComponentDataType &datatype)
86 {
87   // Cheking if datatype is the correct one before processing 
88   if ( datatype  == AliHLTEMCALDefinitions::fgkDDLRawDataType  )
89      {
90        return true;
91      }
92    else
93      {
94        return false;
95      }
96 }
97
98
99 void 
100 AliHLTEMCALRawAnalyzerComponent::InitMapping( const int specification )
101 {
102   //-------------
103   if ( fMapperPtr == 0 )
104     {
105       fMapperPtr =  new   AliHLTEMCALMapper( specification );
106     }
107
108   if(fMapperPtr->GetIsInitializedMapping() == false )
109     {
110       HLTError("%d:%d, ERROR, mapping not initialized ", __FILE__, __LINE__ );
111       exit(-2);
112     }
113 }
114
115
116 int 
117 AliHLTEMCALRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& /*trigData*/, 
118                                          AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
119 {
120   //-----------------------
121   static int evntcnt = 0;
122 //  static double wlast = -1;
123  // static double wcurrent = 0;
124
125   evntcnt  ++;
126   
127   /*
128   if( evntcnt %100 == 0  )
129     {
130       
131       cout << __FILE__ << __LINE__ << " : Processing event "  << evntcnt   << endl; 
132       wlast =  wcurrent;
133       wcurrent = fgWatch.RealTime();
134       cout << wlast << ":" << wcurrent << endl;
135       cout << __FILE__ << __LINE__ << "The event rate is " <<  100/( wcurrent  -  wlast ) << "  Hz" << endl; 
136       fgWatch.Start(kFALSE); 
137       //     wlast =  fgWatch.RealTime(); 
138     }
139   */
140   
141
142   Int_t blockSize          = -1;
143   UInt_t totSize           = 0;
144   const AliHLTComponentBlockData* iter = NULL; 
145   unsigned long ndx;
146
147   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
148     {
149       iter = blocks+ndx;
150       if(  ! CheckInputDataType(iter->fDataType) )
151         {
152           continue;
153         }
154       else
155         {
156           InitMapping( iter->fSpecification); 
157           blockSize = DoIt(iter, outputPtr, size, totSize); // Processing the block
158           
159           if(blockSize == -1) // If the processing returns -1 we are out of buffer and return an error msg.
160             {
161               return -ENOBUFS;
162             }
163           
164           totSize += blockSize; //Keeping track of the used size
165           AliHLTComponentBlockData bdChannelData;
166           FillBlockData( bdChannelData );
167           bdChannelData.fOffset = 0; //FIXME
168           bdChannelData.fSize = blockSize;
169           
170           //      bdChannelData.fDataType = AliHLTPHOSDefinitions::fgkChannelDataType;
171           bdChannelData.fDataType = AliHLTEMCALDefinitions::fgkChannelDataType;
172
173           bdChannelData.fSpecification = iter->fSpecification;
174           outputBlocks.push_back(bdChannelData);
175           outputPtr += blockSize; //Updating position of the output buffer
176         }
177
178       fCaloEventCount++; 
179       size = totSize; //telling the framework how much buffer space we have used.
180     }
181
182   
183 return 0;
184   
185 }//end DoEvent
186