]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
Effective C++
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuHistogramProducerComponent.cxx
CommitLineData
792f66f1 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
792f66f1 17#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
792f66f1 18#include "AliHLTPHOSRcuHistogramProducer.h"
19#include "AliHLTPHOSRcuHistogramProducerComponent.h"
1b486665 20#include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
14ff16ed 21#include "AliHLTPHOSSharedMemoryInterface.h"
22#include "AliHLTPHOSValidCellDataStruct.h"
792f66f1 23
792f66f1 24AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
792f66f1 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**************************************************************************/
b444d727 32AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(),
33 fHistoWriteFrequency(100),
34 fRcuHistoProducerPtr(0),
35 fOutPtr(0),
36 fShmPtr(0)
792f66f1 37{
14ff16ed 38 fShmPtr = new AliHLTPHOSSharedMemoryInterface();
39 //Default constructor
792f66f1 40}
41
42
792f66f1 43AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
44{
1b486665 45 //Destructor
792f66f1 46}
47
48
792f66f1 49int
50AliHLTPHOSRcuHistogramProducerComponent::Deinit()
51{
1b486665 52 //See html documentation of base class
792f66f1 53 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
c0b4e7eb 54 fRcuHistoProducerPtr->WriteAllHistograms("recreate");
792f66f1 55 return 0;
56}
57
58
792f66f1 59const char*
60AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
61{
1b486665 62 //See html documentation of base class
792f66f1 63 return "RcuHistogramProducer";
64}
65
66
67void
1b486665 68AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
792f66f1 69{
1b486665 70 //See html documentation of base class
71 const AliHLTComponentDataType* pType=fgkInputDataTypes;
792f66f1 72 while (pType->fID!=0)
73 {
74 list.push_back(*pType);
75 pType++;
76 }
77}
78
79
80AliHLTComponentDataType
81AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
82{
1b486665 83 //See html documentation of base class
d504c864 84 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
792f66f1 85}
86
87
88void
89AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
90{
1b486665 91 //See html documentation of base class
792f66f1 92 constBase = 30;
93 inputMultiplier = 1;
94}
95
96
c0b4e7eb 97
792f66f1 98int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
14ff16ed 99 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
792f66f1 100 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
101{
1b486665 102 //See html documentation of base class
b444d727 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
14ff16ed 111 AliHLTPHOSValidCellDataStruct *currentChannel =0;
792f66f1 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;
c0b4e7eb 119
792f66f1 120 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
121 {
122 iter = blocks+ndx;
c0b4e7eb 123 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
124 {
c0b4e7eb 125 continue;
126 }
14ff16ed 127
128 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
129 fShmPtr->SetMemory(cellDataPtr);
130 currentChannel = fShmPtr->NextChannel();
c0b4e7eb 131
14ff16ed 132 while(currentChannel != 0)
792f66f1 133 {
14ff16ed 134 fRcuHistoProducerPtr->FillEnergy(currentChannel->fX, currentChannel->fZ, currentChannel->fGain, currentChannel->fEnergy);
135 fRcuHistoProducerPtr->FillLiveChannels(currentChannel->fData, fNTotalSamples, currentChannel->fX, currentChannel->fZ,currentChannel->fGain);
136 currentChannel = fShmPtr->NextChannel();
792f66f1 137 }
138 }
14ff16ed 139
792f66f1 140 outBPtr = outputPtr;
141 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
142 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
792f66f1 143 fOutPtr->fModuleID = fModuleID;
144 fOutPtr->fRcuX = fRcuX;
145 fOutPtr->fRcuZ = fRcuZ;
146
b444d727 147 for(int x=0; x < N_XCOLUMNS_RCU; x ++)
792f66f1 148 {
b444d727 149 for(int z=0; z < N_ZROWS_RCU; z ++)
792f66f1 150 {
b444d727 151 for(int gain =0; gain < N_GAINS; gain ++)
792f66f1 152 {
153 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
154 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
c0b4e7eb 155 fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
792f66f1 156 }
157 }
158 }
159
792f66f1 160 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
161 AliHLTComponentBlockData bd;
162 FillBlockData( bd );
163 bd.fOffset = offset;
164 bd.fSize = mysize;
d504c864 165 bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
792f66f1 166 bd.fSpecification = 0xFFFFFFFF;
167 outputBlocks.push_back( bd );
168 tSize += mysize;
169 outBPtr += mysize;
170
171 if( tSize > size )
172 {
173 Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
174 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
175 , tSize, size );
176 return EMSGSIZE;
177 }
178
1b486665 179 fPhosEventCount++;
c0b4e7eb 180
c0b4e7eb 181 if( (fPhosEventCount%fHistoWriteFrequency == 0) && ( fPhosEventCount != 0))
c0b4e7eb 182 {
c0b4e7eb 183 fRcuHistoProducerPtr->WriteAllHistograms("recreate");
184 }
792f66f1 185 return 0;
186}//end DoEvent
187
188
189int
190AliHLTPHOSRcuHistogramProducerComponent::DoInit( int argc, const char** argv )
191{
1b486665 192 //See html documentation of base class
193 fPrintInfo = kFALSE;
792f66f1 194 int iResult=0;
195 TString argument="";
1b486665 196 iResult = ScanArguments(argc, argv);
1b486665 197 if(fIsSetEquippmentID == kFALSE)
792f66f1 198 {
1b486665 199 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
200 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
201 iResult = -2;
792f66f1 202 }
1b486665 203 fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
1b486665 204 return iResult;
792f66f1 205
792f66f1 206}
207
208
209AliHLTComponent*
210AliHLTPHOSRcuHistogramProducerComponent::Spawn()
211{
1b486665 212 //See html documentation of base class
792f66f1 213 return new AliHLTPHOSRcuHistogramProducerComponent;
214}
215
216
14ff16ed 217