]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
update of data handling classes for SSD calibration
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
CommitLineData
cbab66dd 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"
ee7849e6 17#include "AliHLTPHOSRawAnalyzerPeakFinder.h"
43dd7c5e 18//#include <cstdlib>
19//#include "AliHLTPHOSCommonDefs.h"
d504c864 20
21
ee7849e6 22AliHLTPHOSRawAnalyzerPeakFinderComponent gAliHLTPHOSRawAnalyzerPeakFinderComponent;
cbab66dd 23
d504c864 24//___________________________________________________________________________________________________________
ee7849e6 25AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponent()
cbab66dd 26{
146c463a 27 fAnalyzerPtr = new AliHLTPHOSRawAnalyzerPeakFinder();
06c4998b 28
fb27c8ca 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 }
fb27c8ca 37}
38
05be0766 39
d504c864 40//___________________________________________________________________________________________________________
fb27c8ca 41AliHLTPHOSRawAnalyzerPeakFinderComponent::~AliHLTPHOSRawAnalyzerPeakFinderComponent()
42{
43
d949e02e 44 if(fAnalyzerPtr)
45 {
46 delete fAnalyzerPtr;
47 fAnalyzerPtr = 0;
48 }
fb27c8ca 49}
50
51
d504c864 52//___________________________________________________________________________________________________________
fb27c8ca 53AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponent()
54{
55
56}
57
d949e02e 58//-----------------------------------------------------------------------------------------------------------
59int
60AliHLTPHOSRawAnalyzerPeakFinderComponent::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}
fb27c8ca 71
d504c864 72//___________________________________________________________________________________________________________
fb27c8ca 73const char*
74AliHLTPHOSRawAnalyzerPeakFinderComponent::GetComponentID()
75{
76 return "PhosRawPeakFinder";
77}
78
d504c864 79//___________________________________________________________________________________________________________
fb27c8ca 80Bool_t
81AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector()
82{
83 return LoadPFVector(PF_DEFAULT_STARTINDEX, PF_DEFAULT_N_SAMPLES, DEFAULT_TAU, DEFAULT_FS );
84}
06c4998b 85
fb27c8ca 86
d504c864 87//___________________________________________________________________________________________________________
fb27c8ca 88Bool_t
89AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector(int startIndex, int nSamples, int tau, int fs)
90{
91 char tmpPFPath[PF_MAX_PATH_LENGTH];
e83e889b 92 Double_t * tmpAVector = new Double_t[nSamples];
93 Double_t * tmpTVector = new Double_t[nSamples];
fb27c8ca 94 sprintf(tmpPFPath,"%s%s/start%dN%dtau%dfs%d.txt", getenv("ALICE_ROOT"), PF_VECTOR_DIR, startIndex, nSamples, tau, fs);
68d9caee 95 FILE *fp;
06c4998b 96 fp = fopen(tmpPFPath, "r");
68d9caee 97
98 if(fp != 0)
99 {
fb27c8ca 100 for(int i=0; i < nSamples; i++)
68d9caee 101 {
102 fscanf(fp, "%lf", &tmpAVector[i]);
103 }
104
105 fscanf(fp, "\n");
106
fb27c8ca 107 for(int i=0; i < nSamples; i++)
68d9caee 108 {
109 fscanf(fp, "%lf", &tmpTVector[i]);
110 }
146c463a 111 fAnalyzerPtr->SetAVector(tmpAVector, nSamples);
112 fAnalyzerPtr->SetTVector(tmpTVector, nSamples);
68d9caee 113 fclose(fp);
e83e889b 114 delete [] tmpAVector;
115 delete [] tmpTVector;
fb27c8ca 116 return kTRUE;
68d9caee 117 }
118
119 else
120 {
e83e889b 121 delete [] tmpAVector;
122 delete [] tmpTVector;
06c4998b 123 HLTFatal("ERROR: could not open PF vector file");
fb27c8ca 124 return kFALSE;
68d9caee 125 }
cbab66dd 126}
127
128
d504c864 129//___________________________________________________________________________________________________________
ee7849e6 130AliHLTComponent*
131AliHLTPHOSRawAnalyzerPeakFinderComponent::Spawn()
132{
133 return new AliHLTPHOSRawAnalyzerPeakFinderComponent;
134}
68d9caee 135