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