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 "AliHLTPHOSSharedMemoryInterfacev2.h"
24 #include "AliHLTPHOSChannelDataHeaderStruct.h"
25 #include "AliHLTPHOSChannelDataStruct.h"
28 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
29 /*************************************************************************
30 * Class AliHLTPHOSRcuHistogramProducerComponent accumulating histograms *
31 * with amplitudes per PHOS channel *
32 * It is intended to run at the HLT farm *
33 * and it fills the histograms with amplitudes per channel. *
34 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
35 **************************************************************************/
36 AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(),
37 fHistoWriteFrequency(100),
38 fRcuHistoProducerPtr(0),
42 fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
47 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
54 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
56 //See html documentation of base class
57 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
58 char* arg = new char[9];
59 sprintf(arg, "recreate");
60 fRcuHistoProducerPtr->WriteAllHistograms(arg);
66 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
68 //See html documentation of base class
69 return "RcuHistogramProducer";
74 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
76 //See html documentation of base class
77 const AliHLTComponentDataType* pType=fgkInputDataTypes;
80 list.push_back(*pType);
86 AliHLTComponentDataType
87 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
89 //See html documentation of base class
90 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
95 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
97 //See html documentation of base class
104 int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, const AliHLTComponentBlockData* /*blocks*/,
105 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/,
106 AliHLTUInt32_t& /*size*/, vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
110 cout << " AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
112 //See html documentation of base class
115 // trigData--; //shutting up the compiler, we dont use trigData now but will do in near future
117 AliHLTComponentTriggerData &trDta = trigData;
119 trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
121 // AliHLTPHOSValidCellDataStruct *currentChannel =0;
123 AliHLTPHOSChannelDataStruct *currentChannel =0;
125 unsigned long ndx = 0;
129 const AliHLTComponentBlockData* iter = NULL;
131 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
132 AliHLTUInt8_t* outBPtr;
134 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
136 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
138 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
140 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
141 cout << "evtData.fSize =" << evtData.fStructSize << "evtData.fBlockCnt =" << evtData.fBlockCnt <<endl ;
146 cellDataPtr = (AliHLTPHOSChannelDataStruct*)( iter->fPtr);
147 fShmPtr->SetMemory(cellDataPtr);
148 currentChannel = fShmPtr->NextChannel();
150 Int_t* tmpDataPtr = 0;
152 if(cellDataPtr->fHasRawData == true)
154 while(currentChannel != 0)
156 tmpDataPtr = fShmPtr->GetRawData(nSamples);
157 fRcuHistoProducerPtr->FillEnergy(currentChannel->fX, currentChannel->fZ, currentChannel->fGain, currentChannel->fEnergy);
158 fRcuHistoProducerPtr->FillLiveChannels(tmpDataPtr, nSamples, currentChannel->fX, currentChannel->fZ,currentChannel->fGain);
159 currentChannel = fShmPtr->NextChannel();
165 Logging(kHLTLogFatal, __FILE__ , IntToChar( __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
171 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
172 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
173 fOutPtr->fModuleID = fModuleID;
174 fOutPtr->fRcuX = fRcuX;
175 fOutPtr->fRcuZ = fRcuZ;
177 for(int x=0; x < NXCOLUMNSRCU; x ++)
179 for(int z=0; z < NZROWSRCU; z ++)
181 for(int gain =0; gain < NGAINS; gain ++)
183 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
184 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
185 fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
190 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
191 AliHLTComponentBlockData bd;
195 bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
196 bd.fSpecification = 0xFFFFFFFF;
197 outputBlocks.push_back( bd );
203 Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
204 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
211 if( (fPhosEventCount%fHistoWriteFrequency == 0) && ( fPhosEventCount != 0))
213 char* arg = new char[9];
214 sprintf(arg, "recreate");
215 fRcuHistoProducerPtr->WriteAllHistograms(arg);
225 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
227 //See html documentation of base class
228 // fPrintInfo = kFALSE;
232 // iResult = ScanArguments(argc, argv);
235 if(fIsSetEquippmentID == kFALSE)
237 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
238 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
244 //fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
253 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
255 //See html documentation of base class
256 return new AliHLTPHOSRcuHistogramProducerComponent;