1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE *
5 * offline/HLT Project. Contributors are mentioned in the code where *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
20 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
21 //#include "AliHLTPHOSModuleCellAccumulatedEnergyDataStruct.h"
22 #include "AliHLTPHOSRcuHistogramProducer.h"
23 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
27 const AliHLTComponentDataType AliHLTPHOSRcuHistogramProducerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
28 const AliHLTComponentDataType AliHLTPHOSRcuHistogramProducerComponent::outputDataType=kAliHLTVoidDataType;
29 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
31 //AliHLTPHOSHistogramProducerComponent gAliHLTPHOSHistogramProducerComponent;
32 /*************************************************************************
33 * Class AliHLTPHOSRcuHistogramProducerComponent accumulating histograms *
34 * with amplitudes per PHOS channel *
35 * It is intended to run at the HLT farm *
36 * and it fills the histograms with amplitudes per channel. *
37 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
38 **************************************************************************/
39 AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent():AliHLTProcessor(), fEventCount(0), fRcuHistoProducerPtr(0)
46 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
52 AliHLTPHOSRcuHistogramProducerComponent::AliHLTPHOSRcuHistogramProducerComponent(const AliHLTPHOSRcuHistogramProducerComponent & ) : AliHLTProcessor(), fEventCount(0), fRcuHistoProducerPtr(0)
59 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
61 cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
62 fRcuHistoProducerPtr->WriteEnergyHistograms();
68 AliHLTPHOSRcuHistogramProducerComponent::DoDeinit()
70 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRcuHistogramProducer DoDeinit");
76 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
78 return "RcuHistogramProducer";
83 AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
85 const AliHLTComponentDataType* pType=inputDataTypes;
88 list.push_back(*pType);
94 AliHLTComponentDataType
95 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
97 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
102 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
109 int AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
110 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
111 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
113 unsigned long ndx = 0;
117 const AliHLTComponentBlockData* iter = NULL;
118 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
119 AliHLTUInt8_t* outBPtr;
121 // outBPtr = outputPtr;
122 // fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
125 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
128 cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
129 tmpCnt = cellDataPtr->fCnt;
131 for(int i= 0; i <= tmpCnt; i ++)
133 fRcuHistoProducerPtr->FillEnergy(cellDataPtr->fValidData[i].fX,
134 cellDataPtr->fValidData[i].fZ,
135 cellDataPtr->fValidData[i].fGain,
136 cellDataPtr->fValidData[i].fEnergy);
141 fOutPtr = (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
142 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
144 fOutPtr->fModuleID = fModuleID;
145 fOutPtr->fRcuX = fRcuX;
146 fOutPtr->fRcuZ = fRcuZ;
149 for(int x=0; x < N_XCOLUMNS_RCU; x ++)
151 for(int z=0; z < N_XCOLUMNS_RCU; z ++)
153 for(int gain =0; gain < N_GAINS; gain ++)
155 fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
156 fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
162 //pushing data to shared output memory
163 mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
164 AliHLTComponentBlockData bd;
168 bd.fDataType = AliHLTPHOSDefinitions::gkCellAccumulatedEnergyDataType;
169 bd.fSpecification = 0xFFFFFFFF;
170 outputBlocks.push_back( bd );
176 Logging( kHLTLogFatal, "HLT::AliHLTRcuHistogramProducerComponent::DoEvent", "Too much data",
177 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
188 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int argc, const char** argv )
192 // fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer();
193 AliHLTUInt8_t tmpRcuX;
194 AliHLTUInt8_t tmpRcuZ;
195 AliHLTUInt8_t tmpModuleID;
196 Bool_t isSetEquippmentID = kFALSE;
198 for(int i=0; i<argc && iResult>=0; i++)
202 if (argument.IsNull())
206 if (argument.CompareTo("-equipmentID") == 0)
210 fEquippmentID = atoi(argv[i+1]);
211 isSetEquippmentID = kTRUE;
216 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
217 "The argument -equippmentID expects a number");
222 int rcuIndex = (fEquippmentID - 1792)%N_RCUS_PER_MODULE;
223 // fModuleID = (fEquippmentID -1792 -rcuIndex)/N_RCUS_PER_MODULE;
224 tmpModuleID = ((fEquippmentID -1792 -rcuIndex)/N_RCUS_PER_MODULE);
225 SetModuleID(tmpModuleID);
253 cout <<"********InitInfo************"<< endl;
254 cout <<"AliHLTPHOSRcuHistogramProducerComponent::SetCoordinate"<< endl;
255 cout <<"Equpippment ID =\t"<< fEquippmentID <<endl;
256 cout <<"Module ID =\t"<< (int) tmpModuleID<<endl;
257 cout <<"RCUX =\t\t" << (int)tmpRcuX << endl;
258 cout <<"RCUZ =\t\t" << (int)tmpRcuZ << endl;
261 if(isSetEquippmentID == kFALSE)
263 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
264 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
269 fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( tmpModuleID, tmpRcuX, tmpRcuZ);
277 AliHLTPHOSRcuHistogramProducerComponent::SetRcuX(AliHLTUInt8_t X)
284 AliHLTPHOSRcuHistogramProducerComponent::SetRcuZ(AliHLTUInt8_t Z)
291 AliHLTPHOSRcuHistogramProducerComponent::SetModuleID(AliHLTUInt8_t moduleID)
293 fModuleID = moduleID;
298 AliHLTPHOSRcuHistogramProducerComponent::SetEquippmentId(int id)
301 fRcuHistoProducerPtr->SetEquippmentId(id);
306 AliHLTPHOSRcuHistogramProducerComponent::GetEquippmentId()
308 return fEquippmentID;
313 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
315 return new AliHLTPHOSRcuHistogramProducerComponent;