]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSModuleCalibrationProcessorComponent.cxx
- fixes due to new PHOS mapping
[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   //AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
124   
125   AliHLTComponentEventData dummyEvtData;
126   AliHLTComponentTriggerData dummyTrgData;
127
128   ShipDataToFXS(dummyEvtData, dummyTrgData); 
129
130   //See header file for documentation
131   if(fShmPtr)
132     {
133       delete fShmPtr;
134       fShmPtr = 0;
135     }
136   if(fPHOSDAPtr)
137     {
138       delete fPHOSDAPtr;
139       fPHOSDAPtr = 0;
140     }
141   return 0;
142 }
143
144 Int_t AliHLTPHOSModuleCalibrationProcessorComponent::ProcessCalibration(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
145 {
146   
147   //  fCnt ++;
148
149   fCnt ++;
150
151   //See header file for documentation
152   const  AliHLTComponentEventData eDta  = evtData;
153   AliHLTComponentTriggerData  tDta =  trigData;
154
155
156   AliHLTPHOSValidCellDataStruct *currentChannel =0;
157
158   UInt_t specification = 0;
159   const AliHLTComponentBlockData* iter = 0;
160   iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
161   AliHLTPHOSRcuCellEnergyDataStruct* cellDataPtr = 0;
162   Int_t xOffset = 0;
163   Int_t zOffset = 0;
164   Int_t module = -1;
165
166   Float_t energyArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
167   Float_t timeArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
168
169   while(iter != 0)
170     {
171
172       specification = specification|iter->fSpecification;
173
174       cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
175
176       // Only necessary until the specification gives the module number
177       module = cellDataPtr->fModuleID;
178       if(!fPHOSDAPtr)
179         {
180           //      fPHOSDAPtr = new AliPHOSDA1(module,0);
181           fPHOSDAPtr = new AliPHOSRcuDA1(module,0);
182         }
183       
184       xOffset = cellDataPtr->fRcuX*NXCOLUMNSRCU;
185       zOffset = cellDataPtr->fRcuZ*NZROWSRCU;
186       
187       fShmPtr->SetMemory(cellDataPtr);
188       currentChannel = fShmPtr->NextChannel();
189       
190       while(currentChannel != 0)
191         {
192           Int_t tmpZ =  currentChannel->fZ;
193           Int_t tmpX =  currentChannel->fX;
194           Int_t tmpGain =  currentChannel->fGain;
195           
196           energyArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fEnergy;
197           timeArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fTime;
198         }
199 //       for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
200 //      {
201 //        for(Int_t z = 0; z < NZROWSRCU; z++)
202 //          {
203 //            for(Int_t gain = 0; gain < NGAINS; gain++)
204 //              {
205 //                energyArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fEnergy;
206 //                timeArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fTime;
207 //              }
208 //          }
209 //      }
210       iter = GetNextInputBlock(); 
211     }
212   
213   if(fPHOSDAPtr)
214     {
215       // fPHOSDAPtr->FillHistograms(energyArray, timeArray);
216     }
217
218   ResetArrays(energyArray, timeArray);
219
220   //PushBack((TObject*) fCalibDataPtr,  AliHLTPHOSDefinitions::fgkEmcCalibDataType, specification);
221  
222   return 0; 
223 }
224
225   
226 Int_t 
227 AliHLTPHOSModuleCalibrationProcessorComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) 
228 {
229
230
231  
232   //://:ShipDataToFXS(
233
234   // see header file for class documentation
235  
236   // ** PushBack data to FXS ...
237   Char_t filename[200];
238
239   for(int i=0; i < 200; i++)
240     {
241       filename[i] = 0;
242     }
243  
244   fPHOSDAPtr->GetModule();
245
246   sprintf(filename, "PHOS_Module%d_Calib_HLT.root",  fPHOSDAPtr->GetModule() );
247
248   for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
249     {
250       for(Int_t z = 0; z < NZROWSRCU; z++)
251         {
252           PushToFXS( (TObject*) fPHOSDAPtr->GetHgLgRatioHistogram(x, z), "PHOS", filename);
253           for(Int_t gain = 0; gain < NGAINS; gain++)
254             {
255               PushToFXS( (TObject*) fPHOSDAPtr->GetTimeEnergyHistogram(x, z, gain), "PHOS", filename);
256             }
257         }
258     }
259   return 0;
260 }  
261
262 void
263 AliHLTPHOSModuleCalibrationProcessorComponent::ResetArrays(Float_t e[NXCOLUMNSMOD][NZROWSMOD][NGAINS], Float_t t[NXCOLUMNSMOD][NZROWSMOD][NGAINS])
264 {
265   for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
266     {
267       for(Int_t z = 0; z < NZROWSRCU; z++)
268         {
269           for(Int_t gain = 0; gain < NGAINS; gain++)
270             {
271               e[x][z][gain] = 0;
272               t[x][z][gain] = 0;
273             }
274         }
275     }
276 }