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