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 "AliHLTPHOSValidCellDataStruct.h"
25 #include "AliHLTPHOSChannelDataHeaderStruct.h"
26 #include "AliHLTPHOSChannelDataStruct.h"
27 //#include "AliHLTPHOSUtilities.h"
30 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
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 **************************************************************************/
38 AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(),
39 fHistoWriteFrequency(100),
40 fRcuHistoProducerPtr(0),
44 fShmPtr = new AliHLTPHOSSharedMemoryInterfacev2();
49 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
56 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
58 //See html documentation of base class
59 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
60 char* arg = new char[9];
61 sprintf(arg, "recreate");
62 fRcuHistoProducerPtr->WriteAllHistograms(arg);
68 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
70 //See html documentation of base class
71 return "RcuHistogramProducer";
76 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
78 //See html documentation of base class
79 const AliHLTComponentDataType* pType=fgkInputDataTypes;
82 list.push_back(*pType);
88 AliHLTComponentDataType
89 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
91 //See html documentation of base class
92 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
97 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
99 //See html documentation of base class
106 int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, const AliHLTComponentBlockData* /*blocks*/,
107 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/,
108 AliHLTUInt32_t& /*size*/, vector<AliHLTComponentBlockData>& /*outputBlocks*/ )
112 cout << " AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
114 //See html documentation of base class
117 // trigData--; //shutting up the compiler, we dont use trigData now but will do in near future
119 AliHLTComponentTriggerData &trDta = trigData;
121 trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
123 // AliHLTPHOSValidCellDataStruct *currentChannel =0;
125 AliHLTPHOSChannelDataStruct *currentChannel =0;
127 unsigned long ndx = 0;
131 const AliHLTComponentBlockData* iter = NULL;
133 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
134 AliHLTUInt8_t* outBPtr;
136 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
138 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
140 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
142 cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
143 cout << "evtData.fSize =" << evtData.fStructSize << "evtData.fBlockCnt =" << evtData.fBlockCnt <<endl ;
148 cellDataPtr = (AliHLTPHOSChannelDataStruct*)( iter->fPtr);
149 fShmPtr->SetMemory(cellDataPtr);
150 currentChannel = fShmPtr->NextChannel();
152 Int_t* tmpDataPtr = 0;
154 if(cellDataPtr->fHasRawData == true)
156 while(currentChannel != 0)
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();
167 Logging(kHLTLogFatal, __FILE__ , IntToChar( __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
173 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
174 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
175 fOutPtr->fModuleID = fModuleID;
176 fOutPtr->fRcuX = fRcuX;
177 fOutPtr->fRcuZ = fRcuZ;
179 for(int x=0; x < NXCOLUMNSRCU; x ++)
181 for(int z=0; z < NZROWSRCU; z ++)
183 for(int gain =0; gain < NGAINS; gain ++)
185 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
186 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
187 fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
192 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
193 AliHLTComponentBlockData bd;
197 bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
198 bd.fSpecification = 0xFFFFFFFF;
199 outputBlocks.push_back( bd );
205 Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
206 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
213 if( (fPhosEventCount%fHistoWriteFrequency == 0) && ( fPhosEventCount != 0))
215 char* arg = new char[9];
216 sprintf(arg, "recreate");
217 fRcuHistoProducerPtr->WriteAllHistograms(arg);
227 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
229 //See html documentation of base class
230 // fPrintInfo = kFALSE;
234 // iResult = ScanArguments(argc, argv);
237 if(fIsSetEquippmentID == kFALSE)
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>");
246 //fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
255 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
257 //See html documentation of base class
258 return new AliHLTPHOSRcuHistogramProducerComponent;