3 /**************************************************************************
4 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE *
7 * offline/HLT Project. Contributors are mentioned in the code where *
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 **************************************************************************/
19 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
20 #include "AliHLTPHOSRcuHistogramProducer.h"
21 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
22 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
23 #include "AliHLTPHOSSharedMemoryInterface.h"
24 #include "AliHLTPHOSValidCellDataStruct.h"
26 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
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 **************************************************************************/
34 AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(),
35 fHistoWriteFrequency(100),
36 fRcuHistoProducerPtr(0),
40 fShmPtr = new AliHLTPHOSSharedMemoryInterface();
45 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
52 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
54 //See html documentation of base class
55 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
56 char* arg = new char[9];
57 sprintf(arg, "recreate");
58 fRcuHistoProducerPtr->WriteAllHistograms(arg);
64 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
66 //See html documentation of base class
67 return "RcuHistogramProducer";
72 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
74 //See html documentation of base class
75 const AliHLTComponentDataType* pType=fgkInputDataTypes;
78 list.push_back(*pType);
84 AliHLTComponentDataType
85 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
87 //See html documentation of base class
88 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
93 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
95 //See html documentation of base class
102 int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
103 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
104 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
107 cout << " AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
109 //See html documentation of base class
112 // trigData--; //shutting up the compiler, we dont use trigData now but will do in near future
114 AliHLTComponentTriggerData &trDta = trigData;
116 trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
118 AliHLTPHOSValidCellDataStruct *currentChannel =0;
119 unsigned long ndx = 0;
123 const AliHLTComponentBlockData* iter = NULL;
124 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
125 AliHLTUInt8_t* outBPtr;
127 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
131 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
133 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
134 cout << "evtData.fSize =" << evtData.fStructSize << "evtData.fBlockCnt =" << evtData.fBlockCnt <<endl ;
139 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
140 fShmPtr->SetMemory(cellDataPtr);
141 currentChannel = fShmPtr->NextChannel();
143 Int_t* tmpDataPtr = 0;
145 if(cellDataPtr->fHasRawData == true)
147 while(currentChannel != 0)
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();
158 Logging(kHLTLogFatal, __FILE__ , IntToChar( __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
164 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
165 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
166 fOutPtr->fModuleID = fModuleID;
167 fOutPtr->fRcuX = fRcuX;
168 fOutPtr->fRcuZ = fRcuZ;
170 for(int x=0; x < NXCOLUMNSRCU; x ++)
172 for(int z=0; z < NZROWSRCU; z ++)
174 for(int gain =0; gain < NGAINS; gain ++)
176 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
177 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
178 fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
183 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
184 AliHLTComponentBlockData bd;
188 bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
189 bd.fSpecification = 0xFFFFFFFF;
190 outputBlocks.push_back( bd );
196 Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
197 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
204 if( (fPhosEventCount%fHistoWriteFrequency == 0) && ( fPhosEventCount != 0))
206 char* arg = new char[9];
207 sprintf(arg, "recreate");
208 fRcuHistoProducerPtr->WriteAllHistograms(arg);
215 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int argc, const char** argv )
217 //See html documentation of base class
221 iResult = ScanArguments(argc, argv);
222 if(fIsSetEquippmentID == kFALSE)
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>");
228 fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
235 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
237 //See html documentation of base class
238 return new AliHLTPHOSRcuHistogramProducerComponent;