]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
Fixed the last compilation warnings
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
1 /**************************************************************************
2  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
3  *                                                                        *
4  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 #include "AliHLTPHOSRawAnalyzerPeakFinderComponent.h"
17 #include "AliHLTPHOSRawAnalyzerPeakFinder.h"
18 //#include <cstdlib>
19 //#include "AliHLTPHOSCommonDefs.h"
20
21
22 AliHLTPHOSRawAnalyzerPeakFinderComponent gAliHLTPHOSRawAnalyzerPeakFinderComponent;
23
24 //___________________________________________________________________________________________________________
25 AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponent()
26 {
27   fAnalyzerPtr = new AliHLTPHOSRawAnalyzerPeakFinder();
28
29   if(LoadPFVector() == kFALSE)
30     {
31       //      cout << "Warning, could not load PF vectors" << endl;
32     }
33   else 
34     {
35       //    cout << "Loaded PF vectors" << endl;
36     }
37
38
39
40 //___________________________________________________________________________________________________________
41 AliHLTPHOSRawAnalyzerPeakFinderComponent::~AliHLTPHOSRawAnalyzerPeakFinderComponent()
42 {
43
44   if(fAnalyzerPtr)
45     {
46       delete fAnalyzerPtr;
47       fAnalyzerPtr = 0;
48     }
49 }
50
51
52 //___________________________________________________________________________________________________________
53 AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponent()
54 {
55
56 }
57
58 //-----------------------------------------------------------------------------------------------------------
59 int
60 AliHLTPHOSRawAnalyzerPeakFinderComponent::Deinit()
61 {
62   
63   if(fAnalyzerPtr)
64     {
65       delete fAnalyzerPtr;
66       fAnalyzerPtr = 0;
67     }
68   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerCrudeComponent Deinit");
69   return 0;
70 }
71
72 //___________________________________________________________________________________________________________
73 const char* 
74 AliHLTPHOSRawAnalyzerPeakFinderComponent::GetComponentID()
75 {
76   return "PhosRawPeakFinder";
77 }
78
79 //___________________________________________________________________________________________________________
80 Bool_t 
81 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector()
82 {
83   return LoadPFVector(PF_DEFAULT_STARTINDEX,  PF_DEFAULT_N_SAMPLES, DEFAULT_TAU, DEFAULT_FS );
84 }
85
86
87 //___________________________________________________________________________________________________________
88 Bool_t 
89 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector(int startIndex, int nSamples, int tau, int fs)
90 {
91   char tmpPFPath[PF_MAX_PATH_LENGTH];
92   Double_t * tmpAVector = new Double_t[nSamples];
93   Double_t * tmpTVector = new Double_t[nSamples]; 
94   sprintf(tmpPFPath,"%s%s/start%dN%dtau%dfs%d.txt", getenv("ALICE_ROOT"), PF_VECTOR_DIR, startIndex, nSamples, tau, fs);
95   FILE *fp;
96   fp = fopen(tmpPFPath, "r");
97   
98   if(fp != 0)
99     {
100       for(int i=0; i <  nSamples; i++)
101         {
102           fscanf(fp, "%lf", &tmpAVector[i]);
103         }
104
105       fscanf(fp, "\n");
106
107       for(int i=0; i < nSamples; i++)
108         {
109                   fscanf(fp, "%lf", &tmpTVector[i]);
110         }
111       fAnalyzerPtr->SetAVector(tmpAVector,  nSamples);
112       fAnalyzerPtr->SetTVector(tmpTVector,  nSamples);
113       fclose(fp);
114       delete [] tmpAVector;
115       delete [] tmpTVector;
116       return kTRUE;
117     }
118   
119   else
120     {
121       delete [] tmpAVector;
122       delete [] tmpTVector;
123       HLTFatal("ERROR: could not  open PF vector file");
124       return kFALSE;
125     }
126 }
127
128
129 //___________________________________________________________________________________________________________
130 AliHLTComponent*
131 AliHLTPHOSRawAnalyzerPeakFinderComponent::Spawn()
132 {
133   return new AliHLTPHOSRawAnalyzerPeakFinderComponent;
134 }
135