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