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