]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRcuDAComponent.cxx
converted warning to debug msg
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuDAComponent.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 "AliHLTPHOSSharedMemoryInterfacev2.h"
21 #include "AliHLTPHOSRcuDAComponent.h"
22 #include "AliHLTPHOSDefinitions.h"
23
24 // #include "AliHLTPHOSConstant.h"
25 //#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
26 #include "TObjArray.h"
27 #include "AliHLTCaloUtilities.h"
28 #include "AliHLTReadoutList.h"
29
30 //#include <iostream>
31
32 /** @file   AliHLTPHOSRcuDAComponent.cxx
33     @author Oystein Djuvsland
34     @date   
35     @brief  A module calibration component for PHOS HLT, using the PHOS DA's
36 */
37
38 // see header file for class documentation
39 // or
40 // refer to README to build package
41 // or
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
43
44 using namespace PhosHLTConst;
45
46 AliHLTPHOSRcuDAComponent gAliHLTPHOSRcuDAComponent;
47
48 AliHLTPHOSRcuDAComponent::AliHLTPHOSRcuDAComponent() : 
49   //AliHLTPHOSRcuProperties(),
50   AliHLTCalibrationProcessor(),
51   fPhosEventCount(0),
52   fPHOSDAPtr(0),
53   fShmPtr(0) 
54   //    fTest(-2)
55 {
56   fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
57 }
58
59
60
61 AliHLTPHOSRcuDAComponent::~AliHLTPHOSRcuDAComponent() 
62 {
63   if(fShmPtr)
64     {
65       delete fShmPtr;
66       fShmPtr = 0;
67     }
68   if(fPHOSDAPtr)
69     {
70       delete fPHOSDAPtr;
71       fPHOSDAPtr = 0;
72     }
73 }
74
75
76 void AliHLTPHOSRcuDAComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
77 {
78   list.clear();
79   list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
80 }
81
82
83 AliHLTComponentDataType AliHLTPHOSRcuDAComponent::GetOutputDataType()
84 {
85   return AliHLTPHOSDefinitions::fgkEmcCalibDataType;
86 }
87   
88                                    
89 void AliHLTPHOSRcuDAComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
90 {
91   constBase = 0;
92   inputMultiplier = 2;
93 }
94
95
96 AliHLTComponent* 
97 AliHLTPHOSRcuDAComponent::Spawn()
98 {
99   return new AliHLTPHOSRcuDAComponent();
100 }
101
102 const char* 
103 AliHLTPHOSRcuDAComponent::GetComponentID()
104 {
105   return "PhosRcuDAProcessor";  
106 }
107
108
109 Int_t
110 AliHLTPHOSRcuDAComponent::ScanArgument( Int_t /*argc*/, const char** /*argv*/)
111 {
112   //CRAP PTH
113   //  AliHLTPHOSUtilities::ScanArguments(argc, argv);
114  
115
116  return 0;
117 }
118
119
120 Int_t AliHLTPHOSRcuDAComponent::InitCalibration()
121 {  
122   return 0;
123 }
124
125
126 Int_t AliHLTPHOSRcuDAComponent::DeinitCalibration()
127 {
128   AliHLTComponentEventData dummyEvtData;
129   AliHLTComponentTriggerData dummyTrgData;
130   ShipDataToFXS(dummyEvtData, dummyTrgData); 
131
132
133   if(fShmPtr)
134     {
135       delete fShmPtr;
136       fShmPtr = 0;
137     }
138   if(fPHOSDAPtr)
139     {
140       delete fPHOSDAPtr;
141       fPHOSDAPtr = 0;
142     }
143   return 0;
144 }
145
146
147
148 Int_t AliHLTPHOSRcuDAComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
149 {
150   /*
151   fPhosEventCount ++;
152   const  AliHLTComponentEventData eDta  = evtData;
153   AliHLTComponentTriggerData  tDta =  trigData;
154
155   UInt_t specification = 0;
156   const AliHLTComponentBlockData* iter = 0;
157   iter = GetFirstInputBlock( AliHLTPHOSDefinitions::fgkCellEnergyDataType | kAliHLTDataOriginPHOS);
158
159   AliHLTPHOSRcuCellEnergyDataStruct* cellDataPtr = 0;
160   AliHLTPHOSValidCellDataStruct *currentChannel =0;
161   Int_t xOffset = 0;
162   Int_t zOffset = 0;
163   Int_t module = -1;
164
165   Float_t energyArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
166   Float_t timeArray[NXCOLUMNSMOD][NZROWSMOD][NGAINS];
167   ResetArrays(energyArray, timeArray);
168
169   while(iter != 0)
170     {
171       specification = specification|iter->fSpecification;
172       cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
173       module = cellDataPtr->fModuleID;
174       xOffset = cellDataPtr->fRcuX*NXCOLUMNSRCU;
175       zOffset = cellDataPtr->fRcuZ*NZROWSRCU;
176
177       while(currentChannel != 0)
178         {
179           Int_t tmpZ =  currentChannel->fZ;
180           Int_t tmpX =  currentChannel->fX;
181           Int_t tmpGain =  currentChannel->fGain;
182           
183           energyArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fEnergy;
184           timeArray[tmpX+xOffset][tmpZ+zOffset][tmpGain] = currentChannel->fTime;
185         }
186
187 //       for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
188 //      {
189 //        for(Int_t z = 0; z < NZROWSRCU; z++)
190 //          {
191 //            for(Int_t gain = 0; gain < NGAINS; gain++)
192 //              {
193 //                energyArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fEnergy;
194 //                timeArray[x+xOffset][z+zOffset][gain] = cellDataPtr->fValidData[x][z][gain].fTime;
195 //              }
196 //          }
197 //      }
198       iter = GetNextInputBlock(); 
199     }
200   
201   fPHOSDAPtr->FillHistograms(energyArray, timeArray);
202
203   ResetArrays(energyArray, timeArray);
204   */
205   return 0; 
206 }
207
208   
209 Int_t 
210 AliHLTPHOSRcuDAComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) 
211 {
212   Char_t filename[200];
213
214   for(int i=0; i < 200; i++)
215     {
216       filename[i] = 0;
217     }
218   const TObjArray *calibPtr = fPHOSDAPtr->GetHistoContainer();
219   sprintf(filename, "/home/perthi/hlt/rundir/test/outdata/%s.root", fPHOSDAPtr->GetName() );
220   TFile *outFile =  new TFile(filename, "recreate");
221   calibPtr->Write(); 
222   outFile->Close();
223   static AliHLTReadoutList rdList(AliHLTReadoutList::kPHOS);
224   PushToFXS( (TObject*)fPHOSDAPtr->GetHistoContainer(), "PHOS",  filename, rdList.Buffer());
225   cout << "Finnished pushing data to HLT FXS" << endl;
226   return 0;
227 }  
228
229
230
231 /*
232 void
233 AliHLTPHOSRcuDAComponent::ResetArrays(Float_t e[NXCOLUMNSMOD][NZROWSMOD][NGAINS], Float_t t[NXCOLUMNSMOD][NZROWSMOD][NGAINS])
234 {
235   for(Int_t x = 0; x < NXCOLUMNSRCU; x++)
236     {
237       for(Int_t z = 0; z < NZROWSRCU; z++)
238         {
239           for(Int_t gain = 0; gain < NGAINS; gain++)
240             {
241               e[x][z][gain] = 0;
242               t[x][z][gain] = 0;
243             }
244         }
245     }
246 }
247 */