]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
- changes to make the clusterisation work for EMCAL
[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
0bba8357 19//#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
792f66f1 20#include "AliHLTPHOSRcuHistogramProducer.h"
21#include "AliHLTPHOSRcuHistogramProducerComponent.h"
1b486665 22#include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
0bba8357 23#include "AliHLTPHOSSharedMemoryInterfacev2.h"
24//#include "AliHLTPHOSValidCellDataStruct.h"
25#include "AliHLTPHOSChannelDataHeaderStruct.h"
26#include "AliHLTPHOSChannelDataStruct.h"
9a2451f1 27//#include "AliHLTPHOSUtilities.h"
0bba8357 28
792f66f1 29
792f66f1 30AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
792f66f1 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**************************************************************************/
b444d727 38AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(),
39 fHistoWriteFrequency(100),
40 fRcuHistoProducerPtr(0),
41 fOutPtr(0),
42 fShmPtr(0)
792f66f1 43{
0bba8357 44 fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
14ff16ed 45 //Default constructor
792f66f1 46}
47
48
792f66f1 49AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
50{
1b486665 51 //Destructor
792f66f1 52}
53
54
792f66f1 55int
56AliHLTPHOSRcuHistogramProducerComponent::Deinit()
57{
1b486665 58 //See html documentation of base class
792f66f1 59 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
e304ea31 60 char* arg = new char[9];
61 sprintf(arg, "recreate");
62 fRcuHistoProducerPtr->WriteAllHistograms(arg);
792f66f1 63 return 0;
64}
65
66
792f66f1 67const char*
68AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
69{
1b486665 70 //See html documentation of base class
792f66f1 71 return "RcuHistogramProducer";
72}
73
74
75void
1b486665 76AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
792f66f1 77{
1b486665 78 //See html documentation of base class
79 const AliHLTComponentDataType* pType=fgkInputDataTypes;
792f66f1 80 while (pType->fID!=0)
81 {
82 list.push_back(*pType);
83 pType++;
84 }
85}
86
87
88AliHLTComponentDataType
89AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
90{
1b486665 91 //See html documentation of base class
d504c864 92 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
792f66f1 93}
94
95
96void
97AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
98{
1b486665 99 //See html documentation of base class
792f66f1 100 constBase = 30;
101 inputMultiplier = 1;
102}
103
104
c0b4e7eb 105
0bba8357 106int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, const AliHLTComponentBlockData* /*blocks*/,
b210e538 107 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/,
0bba8357 108 AliHLTUInt32_t& /*size*/, vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
792f66f1 109{
0bba8357 110 /*
b1a2799f 111
112 cout << " AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
113
114 //See html documentation of base class
b444d727 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
0bba8357 123 // AliHLTPHOSValidCellDataStruct *currentChannel =0;
124
125 AliHLTPHOSChannelDataStruct *currentChannel =0;
126
792f66f1 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;
0bba8357 132
792f66f1 133 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
134 AliHLTUInt8_t* outBPtr;
c0b4e7eb 135
792f66f1 136 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
137 {
b1a2799f 138 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
792f66f1 139 iter = blocks+ndx;
c0b4e7eb 140 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
141 {
b1a2799f 142 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
143 cout << "evtData.fSize =" << evtData.fStructSize << "evtData.fBlockCnt =" << evtData.fBlockCnt <<endl ;
144
c0b4e7eb 145 continue;
146 }
14ff16ed 147
0bba8357 148 cellDataPtr = (AliHLTPHOSChannelDataStruct*)( iter->fPtr);
14ff16ed 149 fShmPtr->SetMemory(cellDataPtr);
150 currentChannel = fShmPtr->NextChannel();
7ce40e5c 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
792f66f1 165 {
7ce40e5c 166
167 Logging(kHLTLogFatal, __FILE__ , IntToChar( __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
168 return -1;
792f66f1 169 }
170 }
14ff16ed 171
792f66f1 172 outBPtr = outputPtr;
173 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
174 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
792f66f1 175 fOutPtr->fModuleID = fModuleID;
176 fOutPtr->fRcuX = fRcuX;
177 fOutPtr->fRcuZ = fRcuZ;
178
27029341 179 for(int x=0; x < NXCOLUMNSRCU; x ++)
792f66f1 180 {
27029341 181 for(int z=0; z < NZROWSRCU; z ++)
792f66f1 182 {
27029341 183 for(int gain =0; gain < NGAINS; gain ++)
792f66f1 184 {
185 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
186 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
c0b4e7eb 187 fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
792f66f1 188 }
189 }
190 }
191
792f66f1 192 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
193 AliHLTComponentBlockData bd;
194 FillBlockData( bd );
195 bd.fOffset = offset;
196 bd.fSize = mysize;
d504c864 197 bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
792f66f1 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
1b486665 211 fPhosEventCount++;
c0b4e7eb 212
c0b4e7eb 213 if( (fPhosEventCount%fHistoWriteFrequency == 0) && ( fPhosEventCount != 0))
c0b4e7eb 214 {
e304ea31 215 char* arg = new char[9];
216 sprintf(arg, "recreate");
217 fRcuHistoProducerPtr->WriteAllHistograms(arg);
c0b4e7eb 218 }
792f66f1 219 return 0;
0bba8357 220
221 */
b210e538 222 return 0;
792f66f1 223}//end DoEvent
224
225
226int
b210e538 227AliHLTPHOSRcuHistogramProducerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
792f66f1 228{
1b486665 229 //See html documentation of base class
9a2451f1 230 // fPrintInfo = kFALSE;
792f66f1 231 int iResult=0;
232 TString argument="";
9a2451f1 233
234 // iResult = ScanArguments(argc, argv);
235
236 /*
1b486665 237 if(fIsSetEquippmentID == kFALSE)
792f66f1 238 {
1b486665 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;
792f66f1 242 }
9a2451f1 243 */
244
245
246 //fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
247
248
1b486665 249 return iResult;
792f66f1 250
792f66f1 251}
252
253
254AliHLTComponent*
255AliHLTPHOSRcuHistogramProducerComponent::Spawn()
256{
1b486665 257 //See html documentation of base class
792f66f1 258 return new AliHLTPHOSRcuHistogramProducerComponent;
259}
260
261
14ff16ed 262