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