]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
Compilation with CC on Solaris x86
[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 }
45
46
47 //___________________________________________________________________________________________________________
48 AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponent()
49 {
50
51 }
52
53
54 //___________________________________________________________________________________________________________
55 const char* 
56 AliHLTPHOSRawAnalyzerPeakFinderComponent::GetComponentID()
57 {
58   return "PhosRawPeakFinder";
59 }
60
61 //___________________________________________________________________________________________________________
62 Bool_t 
63 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector()
64 {
65   return LoadPFVector(PF_DEFAULT_STARTINDEX,  PF_DEFAULT_N_SAMPLES, DEFAULT_TAU, DEFAULT_FS );
66 }
67
68
69 //___________________________________________________________________________________________________________
70 Bool_t 
71 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector(int startIndex, int nSamples, int tau, int fs)
72 {
73   char tmpPFPath[PF_MAX_PATH_LENGTH];
74   Double_t * tmpAVector = new Double_t[nSamples];
75   Double_t * tmpTVector = new Double_t[nSamples]; 
76   sprintf(tmpPFPath,"%s%s/start%dN%dtau%dfs%d.txt", getenv("ALICE_ROOT"), PF_VECTOR_DIR, startIndex, nSamples, tau, fs);
77   FILE *fp;
78   fp = fopen(tmpPFPath, "r");
79   
80   if(fp != 0)
81     {
82       for(int i=0; i <  nSamples; i++)
83         {
84           fscanf(fp, "%lf", &tmpAVector[i]);
85         }
86
87       fscanf(fp, "\n");
88
89       for(int i=0; i < nSamples; i++)
90         {
91                   fscanf(fp, "%lf", &tmpTVector[i]);
92         }
93       fAnalyzerPtr->SetAVector(tmpAVector,  nSamples);
94       fAnalyzerPtr->SetTVector(tmpTVector,  nSamples);
95       fclose(fp);
96       delete [] tmpAVector;
97       delete [] tmpTVector;
98       return kTRUE;
99     }
100   
101   else
102     {
103       delete [] tmpAVector;
104       delete [] tmpTVector;
105       HLTFatal("ERROR: could not  open PF vector file");
106       return kFALSE;
107     }
108 }
109
110
111 //___________________________________________________________________________________________________________
112 AliHLTComponent*
113 AliHLTPHOSRawAnalyzerPeakFinderComponent::Spawn()
114 {
115   return new AliHLTPHOSRawAnalyzerPeakFinderComponent;
116 }
117