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