]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
Coding conventions and removal of obsolete files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
CommitLineData
2410262d 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
2374af72 4 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
2410262d 5 * *
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 **************************************************************************/
14
2410262d 15#include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
2410262d 16#include "AliHLTPHOSPhysicsAnalyzerPeakFitter.h"
d2b84453 17//#include "AliHLTPHOSPhysicsDefinitions.h"
2374af72 18#include "AliHLTPHOSDefinitions.h"
91b95d47 19#include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
20#include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
2374af72 21#include "AliHLTPHOSRecPointDataStruct.h"
d2b84453 22//#include "Rtypes.h"
91b95d47 23
2374af72 24/** @file AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
25 @author Oystein Djuvsland
26 @date
27 @brief An invariant mass spectrum component for PHOS HLT
28*/
29
30// see header file for class documentation
31// or
32// refer to README to build package
33// or
34// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35
36//class AliHLTPHOSDefinitions;
2410262d 37
91b95d47 38const AliHLTComponentDataType AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
39UInt_t AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgCount = 0;
2410262d 40
41AliHLTPHOSPhysicsAnalyzerSpectrumComponent gAliHLTPHOSPhysicsAnalyzerSpectrumComponent;
42
9c9d15d6 43// removed by PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSBase(), AliHLTProcessor(), fAnalyzerPtr(0),
44// fPeakFitter(0), fRootHistPtr(0),
45// fWriteInterval(0)
46
47AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), // added by PTH
6e709a0d 48 fPeakFitter(0), fRootHistPtr(0),
49 fWriteInterval(0)
2410262d 50{
91b95d47 51 //Constructor
2410262d 52}
53
54AliHLTPHOSPhysicsAnalyzerSpectrumComponent::~AliHLTPHOSPhysicsAnalyzerSpectrumComponent()
55{
91b95d47 56 //Destructor
57 if(fPeakFitter)
58 {
59 delete fPeakFitter;
60 fPeakFitter = 0;
61 }
62
63 if(fAnalyzerPtr)
64 {
65 delete fAnalyzerPtr;
66 fAnalyzerPtr = 0;
67 }
68
69 if(fRootHistPtr)
70 {
71 delete fRootHistPtr;
72 fRootHistPtr = 0;
73 }
74
2410262d 75}
76
d2b84453 77// PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &):AliHLTProcessor(), fAnalyzerPtr(0),
78// fPeakFitter(0), fRootHistPtr(0),
79// fWriteInterval(0)
80//{
91b95d47 81 //Copy constructor not implemented
d2b84453 82//}
2410262d 83
84Int_t
85AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
86{
91b95d47 87 //Deinitialize the component
88 if(fPeakFitter)
89 {
90 fPeakFitter->SetHistogram(fRootHistPtr);
2374af72 91 fPeakFitter->FitGaussian();
91b95d47 92 delete fPeakFitter;
93 fPeakFitter = 0;
94 }
2410262d 95
91b95d47 96 if(fAnalyzerPtr)
97 {
2374af72 98 fAnalyzerPtr->WriteHistogram("~/hist_fin.root");
91b95d47 99 delete fAnalyzerPtr;
100 fAnalyzerPtr = 0;
101 }
102
103 if(fRootHistPtr)
104 {
105 delete fRootHistPtr;
106 fRootHistPtr = 0;
107 }
108
2410262d 109 return 0;
110}
111
2410262d 112const Char_t*
113AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
114{
115 return "AliHltPhosPhysicsAnalyzerSpectrum";
116}
117
118void
119AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
120{
91b95d47 121 //Get the input data types
122 const AliHLTComponentDataType* pType=fgkInputDataTypes;
2410262d 123 while (pType->fID!=0) {
124 list.push_back(*pType);
125 pType++;
126 }
127}
128
129AliHLTComponentDataType
130AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
131{
d2b84453 132 // return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
133 return AliHLTPHOSDefinitions::fgkAliHLTSpectrumDataType;
2410262d 134}
135
136void
137AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
138
139{
91b95d47 140 //Get the data size of the output
2410262d 141 constBase = 30;
6e709a0d 142 inputMultiplier = 2;
2410262d 143}
144
145
2374af72 146Int_t
147AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
148 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
149 std::vector<AliHLTComponentBlockData>& outputBlocks)
150{
91b95d47 151 //Do event
2374af72 152
2410262d 153 const AliHLTComponentBlockData* iter = NULL;
154 unsigned long ndx;
155
156 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
157 {
158 iter = blocks+ndx;
159
2374af72 160 if(iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTRecPointDataType)
2410262d 161 {
162 cout << "Warning: data type is not fgkAliHLTClusterDataType " << endl;
163 continue;
164 }
165
2374af72 166 fRecPointArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(iter->fPtr);
2410262d 167
168 }
169
2374af72 170 fAnalyzerPtr->Analyze(fRecPointArrayPtr, ndx);
2410262d 171
91b95d47 172 if(fgCount%fWriteInterval == 0 && fgCount != 0)
2410262d 173 {
6e709a0d 174 // PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
2374af72 175 fAnalyzerPtr->WriteHistogram("~/hist.root");
2410262d 176 }
177
91b95d47 178 fgCount++;
6e709a0d 179
2374af72 180 if(fgCount%100==0)
181 {
182 cout << "fgCount: " << fgCount << endl;
183 }
2410262d 184
185 return 0;
186
187}
6e709a0d 188
2374af72 189
190//int
191//AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData &/*evtData*/, AliHLTComponentTriggerData &/*trigData*/)
192/*
6e709a0d 193{
194 const AliHLTComponentBlockData* iter = NULL;
195 int ndx = 0;
196 //int nBlocks = GetNumberOfInputBlocks();
197
d2b84453 198 // PTH if((iter = GetFirstInputBlock(AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)))
199 if((iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkAliHLTClusterDataType)))
6e709a0d 200 {
201 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
202 }
203
204 while((iter = GetNextInputBlock()))
205 {
206 ndx++;
207 fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
208 }
209
210 fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
211
212 if(fgCount%fWriteInterval == 0 && fgCount != 0)
213 {
214 PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
215 }
216
217 fgCount++;
218
219 if(fgCount%100==0)
220 {
221 //printf("fgCount: %d\n\n", fgCount);
222 cout << "fgCount: " << fgCount << endl;
223 }
224
225 return 0;
226}
2374af72 227*/
228
2410262d 229
230Int_t
7c4091c1 231AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(int argc, const char** argv )
2410262d 232{
91b95d47 233 //Initialize the component
2410262d 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]);
240
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);
246
247 if (argc==0 && argv==NULL) {
248 // this is currently just to get rid of the warning "unused parameter"
249 }
250
251 return 0;
252}
253
254AliHLTComponent*
255AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
256{
91b95d47 257 //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
2410262d 258 return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();
259}