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