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