]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
- fixing warnings
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuHistogramProducerComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
5  *                                                                        *
6  * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE           *
7  * offline/HLT Project. Contributors are mentioned in the code where      *
8  * appropriate.                                                           *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 //#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
20 #include "AliHLTPHOSRcuHistogramProducer.h"
21 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
22 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
23 #include "AliHLTPHOSSharedMemoryInterfacev2.h"
24 #include "AliHLTPHOSChannelDataHeaderStruct.h"
25 #include "AliHLTPHOSChannelDataStruct.h"
26
27
28 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
29 /*************************************************************************
30 * Class AliHLTPHOSRcuHistogramProducerComponent accumulating histograms  *
31 * with amplitudes per PHOS channel                                       *
32 * It is intended to run at the HLT farm                                  *
33 * and it fills the histograms with amplitudes per channel.               * 
34 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C   *
35 **************************************************************************/
36 AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(), 
37                                                                                       fHistoWriteFrequency(100), 
38                                                                                       fRcuHistoProducerPtr(0), 
39                                                                                       fOutPtr(0),
40                                                                                       fShmPtr(0)
41 {
42   fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
43  //Default constructor
44
45
46
47 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
48 {
49   //Destructor
50 }
51
52
53 int 
54 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
55 {
56   //See html documentation of base class
57   cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
58   char* arg = new char[9];
59   sprintf(arg, "recreate");
60   fRcuHistoProducerPtr->WriteAllHistograms(arg);
61   return 0;
62 }
63
64
65 const char* 
66 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
67 {
68   //See html documentation of base class
69   return "RcuHistogramProducer";
70 }
71
72
73 void
74 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
75 {
76   //See html documentation of base class
77   const AliHLTComponentDataType* pType=fgkInputDataTypes;
78   while (pType->fID!=0) 
79     {
80       list.push_back(*pType);
81       pType++;
82     }
83 }
84
85
86 AliHLTComponentDataType 
87 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
88 {
89   //See html documentation of base class  
90   return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
91 }
92
93
94 void
95 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
96 {
97   //See html documentation of base class
98   constBase = 30;
99   inputMultiplier = 1;
100 }
101
102
103
104 int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, const AliHLTComponentBlockData* /*blocks*/, 
105                                                        AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, 
106                                                        AliHLTUInt32_t& /*size*/, vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
107 {
108   /*
109   
110   cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
111
112  //See html documentation of base class
113  
114   // trigData++;
115   // trigData--; //shutting up the compiler, we dont use trigData now but will do in near future
116
117   AliHLTComponentTriggerData &trDta = trigData;  
118   trDta.fDataSize++;
119   trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
120
121   // AliHLTPHOSValidCellDataStruct *currentChannel =0;
122  
123   AliHLTPHOSChannelDataStruct  *currentChannel =0;
124    
125   unsigned long ndx       = 0;
126   UInt_t offset           = 0; 
127   UInt_t mysize           = 0;
128   UInt_t tSize            = 0;
129   const AliHLTComponentBlockData* iter = NULL;   
130
131   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
132   AliHLTUInt8_t* outBPtr;
133
134   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
135     {
136       cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
137       iter = blocks+ndx;
138       if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
139         {
140           cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
141           cout << "evtData.fSize ="  << evtData.fStructSize  <<  "evtData.fBlockCnt =" << evtData.fBlockCnt   <<endl ;
142
143           continue;
144         }
145       
146       cellDataPtr = (AliHLTPHOSChannelDataStruct*)( iter->fPtr);
147       fShmPtr->SetMemory(cellDataPtr);
148       currentChannel = fShmPtr->NextChannel();
149       
150       Int_t* tmpDataPtr = 0;
151       Int_t nSamples = 0;
152       if(cellDataPtr->fHasRawData == true)
153         {
154           while(currentChannel != 0)
155             {
156               tmpDataPtr = fShmPtr->GetRawData(nSamples);
157               fRcuHistoProducerPtr->FillEnergy(currentChannel->fX, currentChannel->fZ, currentChannel->fGain, currentChannel->fEnergy);
158               fRcuHistoProducerPtr->FillLiveChannels(tmpDataPtr, nSamples, currentChannel->fX, currentChannel->fZ,currentChannel->fGain);
159               currentChannel = fShmPtr->NextChannel();
160             }
161         }
162       else
163         {
164           
165           Logging(kHLTLogFatal, __FILE__ , IntToChar(  __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
166           return -1;
167         }
168     }
169
170   outBPtr = outputPtr;
171   fOutPtr =  (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
172   const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct  &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
173   fOutPtr->fModuleID = fModuleID;
174   fOutPtr->fRcuX     = fRcuX;
175   fOutPtr->fRcuZ     = fRcuZ;
176
177   for(int x=0; x < NXCOLUMNSRCU; x ++)
178     {
179       for(int z=0; z < NZROWSRCU; z ++)
180         {
181           for(int gain =0;  gain < NGAINS; gain ++)
182             {
183               fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
184               fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
185               fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
186             }
187         }
188     }
189
190   mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
191   AliHLTComponentBlockData bd;
192   FillBlockData( bd );
193   bd.fOffset = offset;
194   bd.fSize = mysize;
195   bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
196   bd.fSpecification = 0xFFFFFFFF;
197   outputBlocks.push_back( bd );
198   tSize += mysize;
199   outBPtr += mysize;
200
201   if( tSize > size )
202     {
203       Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
204                "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
205                , tSize, size );
206       return EMSGSIZE;
207     }
208
209   fPhosEventCount++; 
210
211   if( (fPhosEventCount%fHistoWriteFrequency == 0) &&  ( fPhosEventCount != 0))
212     {
213       char* arg = new char[9];
214       sprintf(arg, "recreate");
215       fRcuHistoProducerPtr->WriteAllHistograms(arg);
216     }
217   return 0;
218
219   */
220   return 0;
221 }//end DoEvent
222
223
224 int
225 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
226 {
227   //See html documentation of base class
228   //  fPrintInfo = kFALSE;
229   int iResult=0;
230   TString argument="";
231  
232   // iResult = ScanArguments(argc, argv);
233
234   /*
235   if(fIsSetEquippmentID == kFALSE)
236     {
237       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
238                "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
239       iResult = -2; 
240     }
241   */
242
243   
244   //fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
245  
246
247   return iResult; 
248   
249 }
250
251
252 AliHLTComponent*
253 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
254 {
255   //See html documentation of base class
256   return new AliHLTPHOSRcuHistogramProducerComponent;
257 }
258
259
260