]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSModuleCalibrationProcessorComponent.cxx
remove defnition of cluster correction
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSModuleCalibrationProcessorComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * All rights reserved.                                                   *
6  *                                                                        *
7  * Primary Authors: Oystein Djuvsland                                     *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          * 
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18
19 #include "AliPHOSRcuDA1.h"
20 #include "AliHLTPHOSSharedMemoryInterface.h"
21 #include "AliHLTPHOSModuleCalibrationProcessorComponent.h"
22 #include "AliHLTPHOSDefinitions.h"
23 #include "AliHLTPHOSConstants.h"
24 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
25
26 //#include <iostream>
27
28 /** @file   AliHLTPHOSModuleCalibrationProcessorComponent.cxx
29     @author Oystein Djuvsland
30     @date   
31     @brief  A module calibration component for PHOS HLT, using the PHOS DA's
32 */
33
34 // see header file for class documentation
35 // or
36 // refer to README to build package
37 // or
38 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
39
40 using namespace PhosHLTConst;
41
42 AliHLTPHOSModuleCalibrationProcessorComponent gAliHLTPHOSModuleCalibrationProcessorComponent;
43
44 AliHLTPHOSModuleCalibrationProcessorComponent::AliHLTPHOSModuleCalibrationProcessorComponent() :
45   AliHLTCalibrationProcessor(),
46   fCnt(0),
47   fPHOSDAPtr(0),
48   fShmPtr(0) 
49 {
50   //See header file for documentation
51 }
52
53
54 AliHLTPHOSModuleCalibrationProcessorComponent::~AliHLTPHOSModuleCalibrationProcessorComponent() 
55 {
56   //See header file for documentation
57   if(fShmPtr)
58     {
59       delete fShmPtr;
60       fShmPtr = 0;
61     }
62   if(fPHOSDAPtr)
63     {
64       delete fPHOSDAPtr;
65       fPHOSDAPtr = 0;
66     }
67 }
68
69 void AliHLTPHOSModuleCalibrationProcessorComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
70 {
71   //See header file for documentation
72   list.clear();
73   list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
74 }
75
76
77 AliHLTComponentDataType AliHLTPHOSModuleCalibrationProcessorComponent::GetOutputDataType()
78 {
79   //See header file for documentation
80   return AliHLTPHOSDefinitions::fgkEmcCalibDataType;
81 }
82                                      
83 void AliHLTPHOSModuleCalibrationProcessorComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
84 {
85   //See header file for documentation
86   constBase = 0;
87   inputMultiplier = 2;
88 }
89
90 AliHLTComponent* 
91 AliHLTPHOSModuleCalibrationProcessorComponent::Spawn()
92 {
93   //See header file for documentation
94   return new AliHLTPHOSModuleCalibrationProcessorComponent();
95 }
96
97 const char* 
98 AliHLTPHOSModuleCalibrationProcessorComponent::GetComponentID()
99 {
100   //See header file for documentation
101   return "PhosModuleCalibrationProcessor";  
102 }
103
104 Int_t 
105 AliHLTPHOSModuleCalibrationProcessorComponent::ScanArgument( Int_t /*argc*/, const char** /*argv*/)
106 {
107   //See header file for documentation
108   return 0;
109 }
110
111 Int_t AliHLTPHOSModuleCalibrationProcessorComponent::InitCalibration()
112 {  
113   //See header file for documentation
114   fShmPtr = new AliHLTPHOSSharedMemoryInterface();
115   return 0;
116 }
117
118
119 Int_t AliHLTPHOSModuleCalibrationProcessorComponent::DeinitCalibration()
120 {
121    //See header file for documentation
122
123   cout << "Int_t AliHLTPHOSModuleCalibrationProcessorComponent::DeinitCalibration()"  << endl;
124   //AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
125   
126   AliHLTComponentEventData dummyEvtData;
127   AliHLTComponentTriggerData dummyTrgData;
128
129   ShipDataToFXS(dummyEvtData, dummyTrgData); 
130
131   //See header file for documentation
132   if(fShmPtr)
133     {
134       delete fShmPtr;
135       fShmPtr = 0;
136     }
137   if(fPHOSDAPtr)
138     {
139       delete fPHOSDAPtr;
140       fPHOSDAPtr = 0;
141     }
142   return 0;
143 }
144
145 Int_t AliHLTPHOSModuleCalibrationProcessorComponent::ProcessCalibration(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
146 {
147   
148   //  fCnt ++;
149
150   fCnt ++;
151
152   //See header file for documentation
153   const  AliHLTComponentEventData eDta  = evtData;
154   AliHLTComponentTriggerData  tDta =  trigData;
155
156
157   AliHLTPHOSValidCellDataStruct *currentChannel =0;
158
159   UInt_t specification = 0;
160   const AliHLTComponentBlockData* iter = 0;
161   iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
162   AliHLTPHOSRcuCellEnergyDataStruct* cellDataPtr = 0;
163   Int_t xOffset = 0;
164   Int_t zOffset = 0;
165   Int_t module = -1;
166
167   Float_t energyArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
168   Float_t timeArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
169
170   while(iter != 0)
171     {
172
173       specification = specification|iter->fSpecification;
174
175       cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
176
177       // Only necessary until the specification gives the module number
178       module = cellDataPtr->fModuleID;
179       if(!fPHOSDAPtr)
180         {
181           //      fPHOSDAPtr = new AliPHOSDA1(module,0);
182           fPHOSDAPtr = new AliPHOSRcuDA1(module,0);
183         }
184       
185       xOffset = cellDataPtr->fRcuX*NXCOLUMNSRCU;
186       zOffset = cellDataPtr->fRcuZ*NZROWSRCU;
187       
188       fShmPtr->SetMemory(cellDataPtr);
189       currentChannel = fShmPtr->NextChannel();
190       
191       while(currentChannel != 0)
192         {
193           Int_t tmpZ =  currentChannel->fZ;
194           Int_t tmpX =  currentChannel->fX;
195           Int_t tmpGain =  currentChannel->fGain;
196           
197           energyArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fEnergy;
198           timeArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fTime;
199         }
200 //       for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
201 //      {
202 //        for(Int_t z = 0; z < NZROWSRCU; z++)
203 //          {
204 //            for(Int_t gain = 0; gain < NGAINS; gain++)
205 //              {
206 //                energyArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fEnergy;
207 //                timeArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fTime;
208 //              }
209 //          }
210 //      }
211       iter = GetNextInputBlock(); 
212     }
213   
214   if(fPHOSDAPtr)
215     {
216       // fPHOSDAPtr->FillHistograms(energyArray, timeArray);
217     }
218
219   ResetArrays(energyArray, timeArray);
220
221   //PushBack((TObject*) fCalibDataPtr,  AliHLTPHOSDefinitions::fgkEmcCalibDataType, specification);
222  
223   return 0; 
224 }
225
226   
227 Int_t 
228 AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
229
230   cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP0" << endl;
231  
232   //://:ShipDataToFXS(
233
234   // see header file for class documentation
235  
236   // ** PushBack data to FXS ...
237   cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP0.1" << endl;
238   Char_t filename[200];
239
240   for(int i=0; i < 200; i++)
241     {
242       filename[i] = 0;
243     }
244
245   cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP0.2" << endl;
246  
247   fPHOSDAPtr->GetModule();
248
249   sprintf(filename, "PHOS_Module%d_Calib_HLT.root",  fPHOSDAPtr->GetModule() );
250   cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP0.3" << endl;
251   cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP1" << endl;
252
253   for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
254     {
255       for(Int_t z = 0; z < NZROWSRCU; z++)
256         {
257           cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP2" << endl;
258           PushToFXS( (TObject*) fPHOSDAPtr->GetHgLgRatioHistogram(x, z), "PHOS", filename);
259           for(Int_t gain = 0; gain < NGAINS; gain++)
260             {
261               cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP3" << endl; 
262               PushToFXS( (TObject*) fPHOSDAPtr->GetTimeEnergyHistogram(x, z, gain), "PHOS", filename);
263               cout << "AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS TP4" << endl;
264             }
265         }
266     }
267   return 0;
268 }  
269
270 void
271 AliHLTPHOSModuleCalibrationProcessorComponent::ResetArrays(Float_t e[NXCOLUMNSMOD][NZROWSMOD][NGAINS], Float_t t[NXCOLUMNSMOD][NZROWSMOD][NGAINS])
272 {
273   for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
274     {
275       for(Int_t z = 0; z < NZROWSRCU; z++)
276         {
277           for(Int_t gain = 0; gain < NGAINS; gain++)
278             {
279               e[x][z][gain] = 0;
280               t[x][z][gain] = 0;
281             }
282         }
283     }
284 }