1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Ã
\98ystein Djuvsland <oysteind@ift.uib.no> *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
15 #include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
16 #include "AliHLTPHOSPhysicsAnalyzerPeakFitter.h"
17 //#include "AliHLTPHOSPhysicsDefinitions.h"
18 #include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
19 #include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
22 class AliHLTPHOSDefinitions;
24 const AliHLTComponentDataType AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
25 UInt_t AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgCount = 0;
27 AliHLTPHOSPhysicsAnalyzerSpectrumComponent gAliHLTPHOSPhysicsAnalyzerSpectrumComponent;
29 // removed by PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSBase(), AliHLTProcessor(), fAnalyzerPtr(0),
30 // fPeakFitter(0), fRootHistPtr(0),
33 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), // added by PTH
34 fPeakFitter(0), fRootHistPtr(0),
40 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::~AliHLTPHOSPhysicsAnalyzerSpectrumComponent()
63 // PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &):AliHLTProcessor(), fAnalyzerPtr(0),
64 // fPeakFitter(0), fRootHistPtr(0),
67 //Copy constructor not implemented
71 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
73 //Deinitialize the component
76 fPeakFitter->SetHistogram(fRootHistPtr);
77 fPeakFitter->FitLorentzian();
98 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoDeinit()
100 //Deinitialize the component
101 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSPhysicsAnalyzerSpectrumComponent DoDeinit");
108 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
110 return "AliHltPhosPhysicsAnalyzerSpectrum";
114 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
116 //Get the input data types
117 const AliHLTComponentDataType* pType=fgkInputDataTypes;
118 while (pType->fID!=0) {
119 list.push_back(*pType);
124 AliHLTComponentDataType
125 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
127 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
128 return AliHLTPHOSDefinitions::fgkAliHLTSpectrumDataType;
132 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
135 //Get the data size of the output
142 //AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
143 // AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
144 // std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
148 const AliHLTComponentBlockData* iter = NULL;
151 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
155 if(iter->fDataType != AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)
157 cout << "Warning: data type is not fgkAliHLTClusterDataType " << endl;
161 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
165 fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
167 if(fgCount%fWriteInterval == 0 && fgCount != 0)
169 // PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
174 // if(fgCount%100==0)
176 // printf("fgCount: %d\n\n", fgCount);
177 cout << "fgCount: " << fgCount << endl;
186 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData &/*evtData*/, AliHLTComponentTriggerData &/*trigData*/)
188 const AliHLTComponentBlockData* iter = NULL;
190 //int nBlocks = GetNumberOfInputBlocks();
192 // PTH if((iter = GetFirstInputBlock(AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)))
193 if((iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkAliHLTClusterDataType)))
195 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
198 while((iter = GetNextInputBlock()))
201 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
204 fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
206 if(fgCount%fWriteInterval == 0 && fgCount != 0)
208 PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
215 //printf("fgCount: %d\n\n", fgCount);
216 cout << "fgCount: " << fgCount << endl;
223 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(int argc, const char** argv )
225 //Initialize the component
226 Float_t firstThreshold = atof(argv[0]);
227 Float_t secondThreshold = atof(argv[1]);
228 fWriteInterval = atoi(argv[2]);
229 Int_t nBins = atoi(argv[3]);
230 Float_t lowLimit = atof(argv[4]);
231 Float_t highLimit = atof(argv[5]);
233 fPeakFitter = new AliHLTPHOSPhysicsAnalyzerPeakFitter();
234 fRootHistPtr = new TH1F("hist", "hist", nBins, lowLimit, highLimit);
235 fAnalyzerPtr = new AliHLTPHOSPhysicsAnalyzerSpectrum();
236 fAnalyzerPtr->SetThreshold(firstThreshold,secondThreshold);
237 fAnalyzerPtr->SetHistogram(fRootHistPtr);
239 if (argc==0 && argv==NULL) {
240 // this is currently just to get rid of the warning "unused parameter"
247 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
249 //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
250 return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();