]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
26530aeef8b1e5b306f423c552ce169c4949a3c7
[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 #include <cstdlib>
24 //#include "TH2.h"
25
26 //#include "AliHLTTPCDefinitions.h"
27
28 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
29 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType;
30
31
32 //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent;
33 //ClassImp(AliHLTPHOSRawAnalyzerComponent) 
34 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(),  eventCount(0), fPHOSRawStream(), fRawMemoryReader(0)
35 {
36   //  fRawMemoryReader = NULL;
37
38
39 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
40 {
41   if(fRawMemoryReader != 0)
42     {
43       delete fRawMemoryReader;
44     }
45     if(fPHOSRawStream != 0)
46     {
47       delete fPHOSRawStream;
48     }
49
50 }
51
52
53
54 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),  eventCount(0), fPHOSRawStream(),fRawMemoryReader(0)
55 {
56   //  fRawMemoryReader = NULL;
57 }
58
59
60 int 
61 AliHLTPHOSRawAnalyzerComponent::Deinit()
62 {
63   return 0;
64 }
65
66 int 
67 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
68 {
69   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
70
71   if(fRawMemoryReader !=0)
72     {
73       delete fRawMemoryReader;
74     }
75     
76   if(fPHOSRawStream != 0)
77     {
78       delete fPHOSRawStream;
79     }
80   return 0;
81
82 }
83
84 const char* 
85 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
86 {
87   return "AliPhosTestRaw";
88 }
89
90 void
91 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
92 {
93   const AliHLTComponentDataType* pType=inputDataTypes;
94   while (pType->fID!=0) {
95     list.push_back(*pType);
96     pType++;
97   }
98 }
99
100 AliHLTComponentDataType 
101 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
102 {
103   return outputDataType;
104 }
105
106 void
107 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
108
109 {
110   constBase = 0;inputMultiplier = 0;
111 }
112
113
114 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
115                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
116                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
117 {
118   Int_t tmpMod  = 0;
119   Int_t tmpRow  = 0;
120   Int_t tmpCol  = 0;
121   Int_t tmpGain = 0;
122   Int_t processedChannels = 0;
123   //  Int_t tmpMax  = 0;
124   const AliHLTComponentBlockData* iter = NULL; 
125   unsigned long ndx;
126   Reset();
127
128   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129     {
130       iter = blocks+ndx;
131       if (eventCount == 0)
132         {
133           continue;
134         }
135  
136       if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
137         {
138           cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
139           continue;
140         }
141      fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
142      fRawMemoryReader->DumpData();
143      fRawMemoryReader->RewindEvents();
144
145      analyzerPtr->SetData(fTmpChannelData);
146  
147       while(fPHOSRawStream->Next())
148         {
149           if (fPHOSRawStream->IsNewHWAddress())
150             {
151               if(processedChannels > 0)
152                 {
153                   analyzerPtr->SetData(fTmpChannelData);
154                   analyzerPtr->Evaluate(0, 1008);
155                   fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
156                   ResetDataPtr(); 
157                 }
158
159               tmpMod  =  fPHOSRawStream->GetModule();
160               tmpRow  =  fPHOSRawStream->GetRow();
161               tmpCol  =  fPHOSRawStream->GetColumn();
162               tmpGain =  fPHOSRawStream->IsLowGain(); 
163               processedChannels ++;
164             }
165
166           fTmpChannelData[fPHOSRawStream->GetTime()] =  fPHOSRawStream->GetSignal();
167         }
168     }
169   DumpData();
170   fEventCount++; 
171   return 0;
172 }//end DoEvent
173
174
175
176 int
177 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
178 {
179   cout << "DOINIT argc =" << argc << endl;
180   cout << "DOINIT argv[0] =" << argv[0] << endl;
181   cout << "DOINIT argv[1] =" << argv[1] << endl;
182   cout << "DOINIT argv[2] =" << argv[2] << endl;
183   cout << "DOINIT argv[3] =" << argv[3] << endl;
184   cout << "DOINIT argv[4] =" << argv[4] << endl;
185   cout << "DOINIT argv[5] =" << argv[5] << endl;
186   cout << "DOINIT argv[6] =" << argv[6] << endl;
187  
188   int equippmentId = atoi(argv[6]);
189   cout << "The equipment ID was set to " <<equippmentId << endl;
190   
191  //fRawMemoryReader->SetEquipmentID(1806); 
192
193   Reset();
194   cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new  AliRawReaderMemory()" << endl; 
195   legoPlotPtr   = new TH2S("Lego plot 1","Phi0 20Gev, High gain", 56*5, 0, 56*5, 64, 0, 64);
196   fRawMemoryReader = new AliRawReaderMemory();
197   fPHOSRawStream = new  AliCaloRawStream(fRawMemoryReader,"PHOS");
198   fRawMemoryReader->SetEquipmentID(equippmentId); 
199
200   cout <<"AliHLTPHOSRawAnalyzerComponent::DoIni  DONE!" << endl;
201   if (argc==0 && argv==NULL) {
202     // this is currently just to get rid of the warning "unused parameter"
203   }
204   return 0;
205 }
206
207 void
208 AliHLTPHOSRawAnalyzerComponent::DumpData()
209 {
210   for(int mod = 0; mod <5; mod ++)
211     {
212       printf("\n ***********  MODULE %d ************\n", mod);
213       for(int row = 0; row < 64; row ++)
214         {
215           for(int col = 0; col < 56; col ++)
216             {
217               if( fMaxValues[mod][row][col][0] != 0)
218                 { 
219                   cout << fMaxValues[mod][row][col][0] << "\t";
220                 }
221             }
222         } 
223     }
224 }
225
226
227 void
228 AliHLTPHOSRawAnalyzerComponent::Reset()
229 {
230   for(int mod = 0; mod <5; mod ++)
231     {
232       for(int row = 0; row < 64; row ++)
233         {
234           for(int col = 0; col < 56; col ++)
235             {
236               for(int gain = 0; gain <2; gain ++ )
237                 {
238                   fMaxValues[mod][row][col][gain] = 0;
239                 }
240             }
241         }
242     }
243
244   for(int i = 0 ; i< 1008; i++)
245     {
246       fTmpChannelData[i] = 0;
247     }
248 } // end Reset
249
250 void
251 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
252 {
253   for(int i = 0 ; i< 1008; i++)
254     {
255       fTmpChannelData[i] = 0;
256     }
257 }