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 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &) :
78 AliHLTPHOSProcessor(),
84 //Copy constructor not implemented
88 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
90 //Deinitialize the component
93 fPeakFitter->SetHistogram(fRootHistPtr);
94 fPeakFitter->FitGaussian();
101 fAnalyzerPtr->WriteHistogram("~/hist_fin.root");
116 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
118 return "AliHltPhosPhysicsAnalyzerSpectrum";
122 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
124 //Get the input data types
125 const AliHLTComponentDataType* pType=fgkInputDataTypes;
126 while (pType->fID!=0) {
127 list.push_back(*pType);
132 AliHLTComponentDataType
133 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
135 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
136 return AliHLTPHOSDefinitions::fgkSpectrumDataType;
140 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
143 //Get the data size of the output
150 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
151 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
152 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
156 const AliHLTComponentBlockData* iter = NULL;
159 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
163 if(iter->fDataType != AliHLTPHOSDefinitions::fgkRecPointDataType)
165 cout << "Warning: data type is not fgkRecPointDataType " << endl;
169 fRecPointArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(iter->fPtr);
173 //fAnalyzerPtr->Analyze(fRecPointArrayPtr, ndx);
175 if(fgCount%fWriteInterval == 0 && fgCount != 0)
177 // PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
178 fAnalyzerPtr->WriteHistogram("~/hist.root");
185 cout << "fgCount: " << fgCount << endl;
194 //AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData &/*evtData*/, AliHLTComponentTriggerData &/*trigData*/)
197 const AliHLTComponentBlockData* iter = NULL;
199 //int nBlocks = GetNumberOfInputBlocks();
201 // PTH if((iter = GetFirstInputBlock(AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)))
202 if((iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkAliHLTClusterDataType)))
204 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
207 while((iter = GetNextInputBlock()))
210 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
213 fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
215 if(fgCount%fWriteInterval == 0 && fgCount != 0)
217 PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
224 //printf("fgCount: %d\n\n", fgCount);
225 cout << "fgCount: " << fgCount << endl;
234 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(int argc, const char** argv )
236 //Initialize the component
237 Float_t firstThreshold = atof(argv[0]);
238 Float_t secondThreshold = atof(argv[1]);
239 fWriteInterval = atoi(argv[2]);
240 Int_t nBins = atoi(argv[3]);
241 Float_t lowLimit = atof(argv[4]);
242 Float_t highLimit = atof(argv[5]);
244 fPeakFitter = new AliHLTPHOSPhysicsAnalyzerPeakFitter();
245 fRootHistPtr = new TH1F("hist", "hist", nBins, lowLimit, highLimit);
246 fAnalyzerPtr = new AliHLTPHOSPhysicsAnalyzerSpectrum();
247 fAnalyzerPtr->SetThreshold(firstThreshold,secondThreshold);
248 fAnalyzerPtr->SetHistogram(fRootHistPtr);
250 if (argc==0 && argv==NULL) {
251 // this is currently just to get rid of the warning "unused parameter"
258 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
260 //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
261 return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();