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