]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
ef2aa3b613cdc67f817aea5ccbe29c9ac90f20f3
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Ã\98ystein 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
15 #include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
16 #include "AliHLTPHOSPhysicsAnalyzerPeakFitter.h"
17 //#include "AliHLTPHOSPhysicsDefinitions.h"
18 #include "AliHLTPHOSPhysicsAnalyzerSpectrum.h"
19 #include "AliHLTPHOSPhysicsAnalyzerSpectrumComponent.h"
20 //#include "Rtypes.h"
21
22 class AliHLTPHOSDefinitions;
23
24 const AliHLTComponentDataType AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
25 UInt_t AliHLTPHOSPhysicsAnalyzerSpectrumComponent::fgCount = 0; 
26
27 AliHLTPHOSPhysicsAnalyzerSpectrumComponent gAliHLTPHOSPhysicsAnalyzerSpectrumComponent;
28
29 // removed by PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSBase(), AliHLTProcessor(), fAnalyzerPtr(0), 
30 //                                                                                       fPeakFitter(0), fRootHistPtr(0),
31 //                                                                                       fWriteInterval(0)
32                                                          
33 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), // added by PTH 
34                                                                                          fPeakFitter(0), fRootHistPtr(0),
35                                                                                          fWriteInterval(0)
36 {
37   //Constructor
38 }
39
40 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::~AliHLTPHOSPhysicsAnalyzerSpectrumComponent()
41 {
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       
61 }
62
63 // PTH AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &):AliHLTProcessor(), fAnalyzerPtr(0), 
64 //                                                                                                                                         fPeakFitter(0), fRootHistPtr(0), 
65 //                                                                                                                                         fWriteInterval(0)
66 //{
67   //Copy constructor not implemented 
68 //}
69
70 Int_t
71 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
72 {
73   //Deinitialize the component
74   if(fPeakFitter)
75     {
76       fPeakFitter->SetHistogram(fRootHistPtr);
77       fPeakFitter->FitLorentzian();
78       delete fPeakFitter;
79       fPeakFitter = 0;
80     }
81
82   if(fAnalyzerPtr)
83     {
84       delete fAnalyzerPtr;
85       fAnalyzerPtr = 0;
86     }
87   
88   if(fRootHistPtr)
89     {
90       delete fRootHistPtr;
91       fRootHistPtr = 0;
92     }
93       
94   return 0;
95 }
96
97 Int_t
98 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoDeinit()
99 {
100   //Deinitialize the component
101   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSPhysicsAnalyzerSpectrumComponent DoDeinit");
102
103   return 0;
104 }
105
106
107 const Char_t* 
108 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
109 {
110   return "AliHltPhosPhysicsAnalyzerSpectrum";
111 }
112
113 void
114 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
115 {
116   //Get the input data types
117   const AliHLTComponentDataType* pType=fgkInputDataTypes;
118   while (pType->fID!=0) {
119     list.push_back(*pType);
120     pType++;
121   }
122 }
123
124 AliHLTComponentDataType 
125 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
126 {
127   //  return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
128   return AliHLTPHOSDefinitions::fgkAliHLTSpectrumDataType;
129 }
130
131 void
132 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
133   
134 {
135   //Get the data size of the output
136   constBase = 30;
137   inputMultiplier = 2;
138 }
139
140
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 //{
146   //Do event
147   /*
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
167   if(fgCount%fWriteInterval == 0 && fgCount != 0)
168     {
169       //    PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
170     }
171
172   fgCount++; 
173
174   // if(fgCount%100==0) 
175   // {
176   //  printf("fgCount: %d\n\n", fgCount);
177   cout << "fgCount: " << fgCount << endl;
178       // }
179   
180   return 0;
181   
182 }
183 */
184
185 int 
186 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData &/*evtData*/, AliHLTComponentTriggerData &/*trigData*/)      
187 {
188   const AliHLTComponentBlockData* iter = NULL; 
189   int ndx = 0;
190   //int nBlocks = GetNumberOfInputBlocks();
191
192   // PTH  if((iter = GetFirstInputBlock(AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)))
193   if((iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkAliHLTClusterDataType)))
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 }
221
222 Int_t
223 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(int argc, const char** argv )
224 {
225   //Initialize the component
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
246 AliHLTComponent*
247 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
248 {
249   //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
250   return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();
251 }