]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
Added new files to build system
[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
23
24 AliHLTPHOSRawAnalyzerPeakFinderComponent gAliHLTPHOSRawAnalyzerPeakFinderComponent;
25
26 //___________________________________________________________________________________________________________
27 AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponent()
28 {
29   fAnalyzerPtr = new AliHLTPHOSRawAnalyzerPeakFinder();
30
31   if(LoadPFVector() == kFALSE)
32     {
33       //      cout << "Warning, could not load PF vectors" << endl;
34     }
35   else 
36     {
37       //    cout << "Loaded PF vectors" << endl;
38     }
39
40
41
42 //___________________________________________________________________________________________________________
43 AliHLTPHOSRawAnalyzerPeakFinderComponent::~AliHLTPHOSRawAnalyzerPeakFinderComponent()
44 {
45
46 }
47
48
49 //___________________________________________________________________________________________________________
50 AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponent()
51 {
52
53 }
54
55
56 //___________________________________________________________________________________________________________
57 const char* 
58 AliHLTPHOSRawAnalyzerPeakFinderComponent::GetComponentID()
59 {
60   return "PhosRawPeakFinder";
61 }
62
63 //___________________________________________________________________________________________________________
64 Bool_t 
65 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector()
66 {
67   return LoadPFVector(PF_DEFAULT_STARTINDEX,  PF_DEFAULT_N_SAMPLES, DEFAULT_TAU, DEFAULT_FS );
68 }
69
70
71 //___________________________________________________________________________________________________________
72 Bool_t 
73 AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector(int startIndex, int nSamples, int tau, int fs)
74 {
75   char tmpPFPath[PF_MAX_PATH_LENGTH];
76   Double_t tmpAVector[nSamples];
77   Double_t tmpTVector[nSamples]; 
78   sprintf(tmpPFPath,"%s%s/start%dN%dtau%dfs%d.txt", getenv("ALICE_ROOT"), PF_VECTOR_DIR, startIndex, nSamples, tau, fs);
79   FILE *fp;
80   fp = fopen(tmpPFPath, "r");
81   
82   if(fp != 0)
83     {
84       for(int i=0; i <  nSamples; i++)
85         {
86           fscanf(fp, "%lf", &tmpAVector[i]);
87         }
88
89       fscanf(fp, "\n");
90
91       for(int i=0; i < nSamples; i++)
92         {
93                   fscanf(fp, "%lf", &tmpTVector[i]);
94         }
95       fAnalyzerPtr->SetAVector(tmpAVector,  nSamples);
96       fAnalyzerPtr->SetTVector(tmpTVector,  nSamples);
97       fclose(fp);
98       return kTRUE;
99     }
100   
101   else
102     {
103       HLTFatal("ERROR: could not  open PF vector file");
104       return kFALSE;
105     }
106 }
107
108
109 //___________________________________________________________________________________________________________
110 AliHLTComponent*
111 AliHLTPHOSRawAnalyzerPeakFinderComponent::Spawn()
112 {
113   return new AliHLTPHOSRawAnalyzerPeakFinderComponent;
114 }
115