]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Started the implemetation of the online analysis
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerComponent.cxx
1
2 /**************************************************************************
3  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
4  *                                                                        *
5  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
6  * Contributors are mentioned in the code where appropriate.              *
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 "AliHLTPHOSRawAnalyzerComponent.h"
18 #include <iostream>
19 #include "stdio.h"
20
21 #include "AliRawReaderMemory.h"
22 #include "AliCaloRawStream.h"
23
24 //#include "AliHLTTPCDefinitions.h"
25
26 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
27 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType;
28
29
30 //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent;
31 //ClassImp(AliHLTPHOSRawAnalyzerComponent) 
32 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(),  eventCount(0), fPHOSRawStream(), fRawMemoryReader(0)
33 {
34   //  fRawMemoryReader = NULL;
35
36
37 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
38 {
39   if(fRawMemoryReader != 0)
40     {
41       delete fRawMemoryReader;
42     }
43     if(fPHOSRawStream != 0)
44     {
45       delete fPHOSRawStream;
46     }
47
48 }
49
50
51
52 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),  eventCount(0), fPHOSRawStream(),fRawMemoryReader(0)
53 {
54   //  fRawMemoryReader = NULL;
55 }
56
57
58 int 
59 AliHLTPHOSRawAnalyzerComponent::Deinit()
60 {
61   return 0;
62 }
63
64 int 
65 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
66 {
67   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
68
69   if(fRawMemoryReader !=0)
70     {
71       delete fRawMemoryReader;
72     }
73     
74   if(fPHOSRawStream != 0)
75     {
76       delete fPHOSRawStream;
77     }
78   return 0;
79
80 }
81
82 const char* 
83 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
84 {
85   return "AliPhosTestRaw";
86 }
87
88 void
89 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
90 {
91   const AliHLTComponentDataType* pType=inputDataTypes;
92   while (pType->fID!=0) {
93     list.push_back(*pType);
94     pType++;
95   }
96 }
97
98 AliHLTComponentDataType 
99 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
100 {
101   return outputDataType;
102 }
103
104 void
105 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
106
107 {
108   constBase = 0;inputMultiplier = 0;
109 }
110
111
112 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
113                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
114                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
115 {
116   //  int tmpCnt = 0;
117   cout << "processing Event" << endl;
118   const AliHLTComponentBlockData* iter = NULL; 
119   unsigned long ndx;
120     
121   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
122     {
123       cout <<"Inside for loop ndx =" << ndx << endl;
124       iter = blocks+ndx;
125       
126        if (eventCount == 0)
127         {
128           continue;
129         }
130  
131       
132       if ( iter->fDataType == AliHLTPHOSDefinitions::gkDDLPackedRawDataType ) cout << "data type is :gkDDLPackedRawDataType " <<endl;
133       if ( iter->fDataType == AliHLTPHOSDefinitions::gkPackedRawDataType ) cout << "data type is : gkPackedRawDataType" <<endl;
134       if ( iter->fDataType == AliHLTPHOSDefinitions::gkUnpackedRawDataType) cout << "data type is gkUnpackedRawDataType" <<endl;
135       if ( iter->fDataType == AliHLTPHOSDefinitions::gkClustersDataType) cout << "data type is ::gkClustersDataType" <<endl;
136       if ( iter->fDataType == AliHLTPHOSDefinitions::gkVertexDataType ) cout << "data type is ::gkVertexDataType " <<endl;
137       if ( iter->fDataType == AliHLTPHOSDefinitions::gkTrackSegmentsDataType) cout << "data type is :::gkTrackSegmentsDataType" <<endl;
138
139       if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
140         {
141           cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
142           continue;
143         }
144
145      cout <<"PHOSHLT DoEvent: processing event:"<< eventCount << endl;
146      cout <<"Struct size = " << evtData.fStructSize << endl;
147      cout <<"Event ID = " <<evtData.fEventID << endl;
148      cout <<"Block count = " <<evtData.fBlockCnt << endl;
149      cout <<"Block size = " << blocks->fSize << endl;
150      cout <<"printing out start od data block" << endl;
151      //     cout << "content of data pointer =" << tmpDtaPtr << endl;  
152
153      //     UChar_t *tmpDtaPtr  = (UChar_t *)blocks->fPtr;
154      UInt_t *tmpDtaPtr  = (UInt_t *)blocks->fPtr;
155
156     
157      for(unsigned int i = 0; i < 15; i++)
158        {
159          // getc();
160          //     sleep(10);
161          //    printf("\ntype return to continue; ");
162          //     getc(stdin);
163          //    printf("\nThanks; read in \n");
164          cout << "entry:" <<i <<" =  " << *tmpDtaPtr << endl;
165          tmpDtaPtr ++;
166          //      cout << "entry:" <<i <<" =  " << *blocks << endl;
167          //      blocks ++;
168        } 
169
170
171      fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
172      bool readValue = true;
173      
174  
175      cout << endl << "eventCount =" << eventCount << endl;
176     fRawMemoryReader->DumpData();
177
178      readValue = fPHOSRawStream->Next();
179      //    fPHOSRawStream->Next();  
180
181      while( readValue )
182        {
183          cout <<"reading value" << endl;
184          readValue = fPHOSRawStream->Next();
185        }
186      cout << "end of for lop" << endl;
187    }
188
189   eventCount++; 
190
191  return 0;
192 }
193
194
195
196 int
197 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
198 {
199   cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new  AliRawReaderMemory()" << endl; 
200   fRawMemoryReader = new AliRawReaderMemory();
201   fPHOSRawStream = new  AliCaloRawStream(fRawMemoryReader,"PHOS");
202   cout <<"AliHLTPHOSRawAnalyzerComponent::DoIni  DONE!" << endl;
203   if (argc==0 && argv==NULL) {
204     // this is currently just to get rid of the warning "unused parameter"
205   }
206   return 0;
207 }
208
209
210
211 /*
212 int 
213 AliHLTPHOSRawAnalyzerComponent::DoEvent(const AliHLTComponentEventData& evtDtaPtr, const AliHLTComponentBlockData* dtaPtr, AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&, std::vector<AliHLTComponentBlockData, std::allocator<AliHLTComponentBlockData> >&)
214 {
215   const Bool_t skipBadEvent=kFALSE;
216   const AliHLTComponentBlockData* iter = NULL;
217
218   fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( dtaPtr->fPtr ), dtaPtr->fSize );
219
220   //  fPHOSRawStream = new  AliCaloRawStream(fRawMemoryReader,"PHOS");
221
222   fRawMemoryReader->DumpData();
223
224   Logging(kHLTLogInfo, "HLT", "Sample", "PhosHLTRawAnalyzerComonent, DoEvent");
225
226   //  UChar_t *tmpDtaPtr  = (UChar_t *)dtaPtr->fPtr;
227   //  UInt32_t *tmpDtaPtr  = (UInt32_t *)dtaPtr->fPtr;
228   //  unsigned long *tmpDtaPtr  = (unsigned long *)dtaPtr->fPtr;
229
230   
231   cout <<"PHOSHLT DoEvent: processing event:"<< eventCount << endl;
232   cout <<"Struct size = " <<evtDtaPtr.fStructSize << endl;
233   cout <<"Event ID = " <<evtDtaPtr.fEventID << endl;
234   cout <<"Block count = " <<evtDtaPtr.fBlockCnt << endl;
235   cout <<"Block size = " << dtaPtr->fSize << endl;
236   cout <<"printing out start od data block" << endl;
237   cout << "content of data pointer =" << tmpDtaPtr << endl;
238   
239
240   // UChar_t *tmpDtaPtr  = (UChar_t *)blokcs->fPtr;
241
242   //  AliCaloRawStream in(fRawMemoryReader,"PHOS");
243   //  for(unsigned int i = 0; i < tmpSize; i++)
244   for(unsigned int i = 0; i < 15; i++)
245     {
246       // getc();
247       //     sleep(10);
248       //    printf("\ntype return to continue; ");
249       //     getc(stdin);
250       //    printf("\nThanks; read in \n");
251       //    cout << "entry:" <<i <<" =  " << *tmpDtaPtr << endl;
252       //   tmpDtaPtr ++;
253    }
254
255   
256   
257   cout << "Entering while loop" << endl;
258   while ( fPHOSRawStream->Next() ) 
259     { 
260       cout << "Inside while loop" << endl;
261       if (fPHOSRawStream->IsNewHWAddress()) cout << endl << " New HW address: " << endl;
262       cout << "time bin=" << fPHOSRawStream->GetTime() << " of "<< fPHOSRawStream->GetTimeLength()
263            << ", amp=" <<  fPHOSRawStream->GetSignal() <<" gain="<< fPHOSRawStream->IsLowGain()
264            << " HW address="<<fPHOSRawStream->GetHWAddress()
265            << " channel=("<<fPHOSRawStream->GetModule() <<","<<fPHOSRawStream->GetColumn()<<","<<fPHOSRawStream->GetRow()<<")"<< endl;
266       
267       
268       if (skipBadEvent && (fPHOSRawStream->GetTime() < 0 || fPHOSRawStream->GetTimeLength() <=0) ) {
269         cout << "Wrong time bin or time length. Skip this event" << endl;
270         break;
271       }
272     }
273   cout << "Finnsihed while loop" << endl << endl;
274
275   eventCount++;
276   return 0;
277 }
278 */