1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Oystein 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 "AliHLTPHOSDefinitions.h"
19 #include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
20 #include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
21 #include "AliHLTPHOSRecPointDataStruct.h"
24 /** @file AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
25 @author Oystein Djuvsland
27 @brief An invariant mass spectrum component for PHOS HLT
30 // see header file for class documentation
32 // refer to README to build package
34 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
36 //class AliHLTPHOSDefinitions;
38 const AliHLTComponentDataType AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
39 UInt_t AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgCount = 0;
41 AliHLTPHOSPhysicsAnalyzerSpectrumComponent gAliHLTPHOSPhysicsAnalyzerSpectrumComponent;
43 // removed by PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSBase(), AliHLTProcessor(), fAnalyzerPtr(0),
44 // fPeakFitter(0), fRootHistPtr(0),
47 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), // added by PTH
48 fPeakFitter(0), fRootHistPtr(0),
54 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::~AliHLTPHOSPhysicsAnalyzerSpectrumComponent()
77 // PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &):AliHLTProcessor(), fAnalyzerPtr(0),
78 // fPeakFitter(0), fRootHistPtr(0),
81 //Copy constructor not implemented
85 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
87 //Deinitialize the component
90 fPeakFitter->SetHistogram(fRootHistPtr);
91 fPeakFitter->FitGaussian();
98 fAnalyzerPtr->WriteHistogram("~/hist_fin.root");
113 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
115 return "AliHltPhosPhysicsAnalyzerSpectrum";
119 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
121 //Get the input data types
122 const AliHLTComponentDataType* pType=fgkInputDataTypes;
123 while (pType->fID!=0) {
124 list.push_back(*pType);
129 AliHLTComponentDataType
130 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
132 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
133 return AliHLTPHOSDefinitions::fgkAliHLTSpectrumDataType;
137 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
140 //Get the data size of the output
147 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
148 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& /*size*/,
149 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
153 const AliHLTComponentBlockData* iter = NULL;
156 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
160 if(iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTRecPointDataType)
162 cout << "Warning: data type is not fgkAliHLTClusterDataType " << endl;
166 fRecPointArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(iter->fPtr);
170 //fAnalyzerPtr->Analyze(fRecPointArrayPtr, ndx);
172 if(fgCount%fWriteInterval == 0 && fgCount != 0)
174 // PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
175 fAnalyzerPtr->WriteHistogram("~/hist.root");
182 cout << "fgCount: " << fgCount << endl;
191 //AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData &/*evtData*/, AliHLTComponentTriggerData &/*trigData*/)
194 const AliHLTComponentBlockData* iter = NULL;
196 //int nBlocks = GetNumberOfInputBlocks();
198 // PTH if((iter = GetFirstInputBlock(AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)))
199 if((iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkAliHLTClusterDataType)))
201 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
204 while((iter = GetNextInputBlock()))
207 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
210 fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
212 if(fgCount%fWriteInterval == 0 && fgCount != 0)
214 PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
221 //printf("fgCount: %d\n\n", fgCount);
222 cout << "fgCount: " << fgCount << endl;
231 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(int argc, const char** argv )
233 //Initialize the component
234 Float_t firstThreshold = atof(argv[0]);
235 Float_t secondThreshold = atof(argv[1]);
236 fWriteInterval = atoi(argv[2]);
237 Int_t nBins = atoi(argv[3]);
238 Float_t lowLimit = atof(argv[4]);
239 Float_t highLimit = atof(argv[5]);
241 fPeakFitter = new AliHLTPHOSPhysicsAnalyzerPeakFitter();
242 fRootHistPtr = new TH1F("hist", "hist", nBins, lowLimit, highLimit);
243 fAnalyzerPtr = new AliHLTPHOSPhysicsAnalyzerSpectrum();
244 fAnalyzerPtr->SetThreshold(firstThreshold,secondThreshold);
245 fAnalyzerPtr->SetHistogram(fRootHistPtr);
247 if (argc==0 && argv==NULL) {
248 // this is currently just to get rid of the warning "unused parameter"
255 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
257 //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
258 return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();