]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
New html documentation
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerSpectrumComponent.cxx
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
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 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent():AliHLTProcessor(), fAnalyzerPtr(0), 
30                                                                                                fRootHistPtr(0)
31 {
32   //Constructor
33 }
34
35 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::~AliHLTPHOSPhysicsAnalyzerSpectrumComponent()
36 {
37   //Destructor
38   if(fPeakFitter)
39     {
40       delete fPeakFitter;
41       fPeakFitter = 0;
42     }
43
44   if(fAnalyzerPtr)
45     {
46       delete fAnalyzerPtr;
47       fAnalyzerPtr = 0;
48     }
49   
50   if(fRootHistPtr)
51     {
52       delete fRootHistPtr;
53       fRootHistPtr = 0;
54     }
55       
56 }
57
58 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::AliHLTPHOSPhysicsAnalyzerSpectrumComponent(const AliHLTPHOSPhysicsAnalyzerSpectrumComponent &):AliHLTProcessor(),
59                                                                                                                                                     fAnalyzerPtr(0),
60                                                                                                                                                     fRootHistPtr(0)
61 {
62   //Copy constructor not implemented 
63 }
64
65 Int_t
66 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Deinit()
67 {
68   //Deinitialize the component
69   if(fPeakFitter)
70     {
71       fPeakFitter->SetHistogram(fRootHistPtr);
72       fPeakFitter->FitLorentzian();
73       delete fPeakFitter;
74       fPeakFitter = 0;
75     }
76
77   if(fAnalyzerPtr)
78     {
79       delete fAnalyzerPtr;
80       fAnalyzerPtr = 0;
81     }
82   
83   if(fRootHistPtr)
84     {
85       delete fRootHistPtr;
86       fRootHistPtr = 0;
87     }
88       
89   return 0;
90 }
91
92 Int_t
93 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoDeinit()
94 {
95   //Deinitialize the component
96   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSPhysicsAnalyzerSpectrumComponent DoDeinit");
97
98   return 0;
99 }
100
101
102 const Char_t* 
103 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetComponentID()
104 {
105   return "AliHltPhosPhysicsAnalyzerSpectrum";
106 }
107
108 void
109 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
110 {
111   //Get the input data types
112   const AliHLTComponentDataType* pType=fgkInputDataTypes;
113   while (pType->fID!=0) {
114     list.push_back(*pType);
115     pType++;
116   }
117 }
118
119 AliHLTComponentDataType 
120 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataType()
121 {
122   return AliHLTPHOSPhysicsDefinitions::fgkAliHLTSpectrumDataType;
123 }
124
125 void
126 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
127   
128 {
129   //Get the data size of the output
130   constBase = 30;
131   inputMultiplier = 1;
132 }
133
134
135 Int_t 
136 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
137                                                     AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
138                                                     std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
139 {
140   //Do event
141   const AliHLTComponentBlockData* iter = NULL; 
142   unsigned long ndx; 
143   
144   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
145     {
146       iter = blocks+ndx;
147       
148       if(iter->fDataType != AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType)
149         {
150           cout << "Warning: data type is not fgkAliHLTClusterDataType " << endl;
151           continue;
152         }
153       
154       fClusterArrayPtr[ndx] = reinterpret_cast<AliHLTPHOSClusterDataStruct*>(iter->fPtr);
155       
156     } 
157   
158   fAnalyzerPtr->Analyze(fClusterArrayPtr, ndx);
159
160   if(fgCount%fWriteInterval == 0 && fgCount != 0)
161     {
162       PushBack(fRootHistPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
163     }
164
165   fgCount++; 
166   
167   return 0;
168   
169 }
170
171 Int_t
172 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::DoInit(Int_t argc, const Char_t** argv )
173 {
174   //Initialize the component
175   Float_t firstThreshold = atof(argv[0]);
176   Float_t secondThreshold = atof(argv[1]);
177   fWriteInterval = atoi(argv[2]);
178   Int_t nBins = atoi(argv[3]);
179   Float_t lowLimit  = atof(argv[4]);
180   Float_t highLimit = atof(argv[5]);
181
182   fPeakFitter = new AliHLTPHOSPhysicsAnalyzerPeakFitter();
183   fRootHistPtr = new TH1F("hist", "hist", nBins, lowLimit, highLimit);
184   fAnalyzerPtr = new AliHLTPHOSPhysicsAnalyzerSpectrum();
185   fAnalyzerPtr->SetThreshold(firstThreshold,secondThreshold);
186   fAnalyzerPtr->SetHistogram(fRootHistPtr);
187
188   if (argc==0 && argv==NULL) {
189     // this is currently just to get rid of the warning "unused parameter"
190   }
191   
192   return 0;
193 }
194
195 AliHLTComponent*
196 AliHLTPHOSPhysicsAnalyzerSpectrumComponent::Spawn()
197 {
198   //Spawn a new AliHLTPHOSPhysicsAnalyzerSpectrumComponent, for the HLT framework
199   return new AliHLTPHOSPhysicsAnalyzerSpectrumComponent();
200 }