]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
Coding conventions + reorganization of code due to new
[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 <iostream>
18 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
19 #include "AliHLTPHOSRcuHistogramProducer.h"
20 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
21 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
22
23
24 //const AliHLTComponentDataType  AliHLTPHOSRcuHistogramProducerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
25 //const AliHLTComponentDataType  AliHLTPHOSRcuHistogramProducerComponent::fgkOutputDataType=kAliHLTVoidDataType;
26
27 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
28
29
30
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():AliHLTPHOSProcessor(), fRcuHistoProducerPtr(0)
39 {
40   //Default constructor
41
42
43
44 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
45 {
46   //Destructor
47 }
48
49
50 AliHLTPHOSRcuHistogramProducerComponent::AliHLTPHOSRcuHistogramProducerComponent(const  AliHLTPHOSRcuHistogramProducerComponent & ) : AliHLTPHOSProcessor(), fRcuHistoProducerPtr(0)
51 {
52
53 }
54
55
56 int 
57 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
58 {
59   //See html documentation of base class
60   cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
61   fRcuHistoProducerPtr->WriteEnergyHistograms();
62   return 0;
63 }
64
65
66 const char* 
67 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
68 {
69   //See html documentation of base class
70   return "RcuHistogramProducer";
71 }
72
73
74 void
75 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
76 {
77   //See html documentation of base class
78   const AliHLTComponentDataType* pType=fgkInputDataTypes;
79   while (pType->fID!=0) 
80     {
81       list.push_back(*pType);
82       pType++;
83     }
84 }
85
86
87 AliHLTComponentDataType 
88 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
89 {
90   //See html documentation of base class  
91   return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
92 }
93
94
95 void
96 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
97 {
98   //See html documentation of base class
99   constBase = 30;
100   inputMultiplier = 1;
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   //See html documentation of base class
109   unsigned long ndx       = 0;
110   UInt_t offset           = 0; 
111   UInt_t mysize           = 0;
112   UInt_t tSize            = 0;
113   const AliHLTComponentBlockData* iter = NULL;   
114   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
115   AliHLTUInt8_t* outBPtr;
116   int tmpCnt;
117
118   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
119     {
120       iter = blocks+ndx;
121       cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
122       tmpCnt =  cellDataPtr->fCnt;
123
124       for(int i= 0; i <= tmpCnt; i ++)
125         {
126           fRcuHistoProducerPtr->FillEnergy(cellDataPtr->fValidData[i].fX,
127                                            cellDataPtr->fValidData[i].fZ, 
128                                            cellDataPtr->fValidData[i].fGain, 
129                                            cellDataPtr->fValidData[i].fEnergy);
130         }
131     }
132   
133   outBPtr = outputPtr;
134   fOutPtr =  (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
135   const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct  &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
136
137   fOutPtr->fModuleID = fModuleID;
138   fOutPtr->fRcuX     = fRcuX;
139   fOutPtr->fRcuZ     = fRcuZ;
140
141
142   for(int x=0; x < N_XCOLUMNS_RCU; x ++)
143     {
144       for(int z=0; z < N_XCOLUMNS_RCU; z ++)
145         {
146           for(int gain =0;  gain < N_GAINS; gain ++)
147             {
148               fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
149               fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
150             }
151         }
152     }
153
154
155   //pushing data to shared output memory
156   mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
157   AliHLTComponentBlockData bd;
158   FillBlockData( bd );
159   bd.fOffset = offset;
160   bd.fSize = mysize;
161   bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
162   bd.fSpecification = 0xFFFFFFFF;
163   outputBlocks.push_back( bd );
164   tSize += mysize;
165   outBPtr += mysize;
166
167   if( tSize > size )
168     {
169       Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
170                "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
171                , tSize, size );
172       return EMSGSIZE;
173     }
174
175   fPhosEventCount++; 
176   return 0;
177   
178 }//end DoEvent
179
180
181 int
182 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int argc, const char** argv )
183 {
184   //See html documentation of base class
185   fPrintInfo = kFALSE;
186   int iResult=0;
187   TString argument="";
188   iResult = ScanArguments(argc, argv);
189
190   if(fIsSetEquippmentID == kFALSE)
191     {
192       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
193                "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
194       iResult = -2; 
195     }
196   fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
197
198   return iResult; 
199   
200 }
201
202
203 AliHLTComponent*
204 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
205 {
206   //See html documentation of base class
207   return new AliHLTPHOSRcuHistogramProducerComponent;
208 }
209
210