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