]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSProcessor.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSProcessor.cxx
CommitLineData
56673b84 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Author: Per Thomas Hille <perthi@fys.uio.no> *
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
c83e4f55 16#include "AliHLTPHOSProcessor.h"
939c67e7 17#include "unistd.h"
c83e4f55 18
c83e4f55 19
8efbf5fe 20
b60bd496 21const AliHLTComponentDataType AliHLTPHOSProcessor::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
c83e4f55 22
23
8efbf5fe 24AliHLTPHOSProcessor::AliHLTPHOSProcessor():AliHLTProcessor(),
25 AliHLTPHOSBase(),
26 fPhosEventCount(0),
04751caa 27 fModuleID(2),
28 fPrintInfoModule(0),
29 fPrintInfoFrequncyModule(1000),
8efbf5fe 30 fRunNumber(0)
c83e4f55 31{
b2b32475 32 // ScanRunNumberFromFile();
c83e4f55 33}
34
c83e4f55 35
9c9d15d6 36
b60bd496 37AliHLTPHOSProcessor::~AliHLTPHOSProcessor()
c83e4f55 38{
c83e4f55 39
c83e4f55 40}
41
8efbf5fe 42
43bool
44AliHLTPHOSProcessor::CheckFileLog(const char *origin, const char *filename, const char *opt)
45{
46 sprintf(fFilepath, "%s/%s", getenv("PWD"), filename);
47 FILE *fp = fopen(filename, opt);
48
49 if(fp == 0)
50 {
51 if( (opt == "w") || (opt == "a"))
52 {
53 sprintf(fMessage, "for writing please check that the directory exists and that you have write access to it" );
54 }
55 else
56 {
57 sprintf(fMessage, "for reading please check that the directory exists and that you have read access to it" );
58 }
59 Logging(kHLTLogFatal, origin , "cannot open file" , "Was not able to open file %s %s", fFilepath, fMessage);
60 return false;
61 }
62 else
63 {
64 if( (opt == "w") || (opt == "a"))
65 {
66 sprintf(fMessage, "for writing" );
67 }
68 else
69 {
70 sprintf(fMessage, "for reading");
71 }
72 // Logging(kHLTLogInfo, origin , "opening file" , "Sucessfully opening %s %s", fFilepath, fMessage);
73 fclose(fp);
74 return true;
75 }
76
77}
78
79
80void
81AliHLTPHOSProcessor::DoneWritingLog(const char *origin, const char *filename)
82{
83 // char filepath[1024];
84 sprintf(fFilepath, "%s/%s", getenv("PWD"), filename);
85 Logging(kHLTLogInfo, origin , "finnished writing file" , "wrote file %s", fFilepath);
86}
87
c83e4f55 88
939c67e7 89void
90AliHLTPHOSProcessor::ScanRunNumberFromFile()
91{
92 char tmpDirectory[512];
93 char tmpFileName[512];
94 sprintf(tmpDirectory, "%s", getenv("HOME"));
939c67e7 95
8efbf5fe 96 //TODO, remove hardcoded file path
b2b32475 97
98
8efbf5fe 99 sprintf(tmpFileName, "%s%s", tmpDirectory, "/hlt/rundir/runNumber.txt");
100
101 if(CheckFileLog( __FILE__ , tmpFileName , "r")== true)
102 {
939c67e7 103 FILE *fp = fopen(tmpFileName, "r");
104 fscanf(fp, "%d", &fRunNumber);
105 fclose(fp);
106 }
b2b32475 107
108
109
110
8efbf5fe 111 }
939c67e7 112
8efbf5fe 113const char*
114AliHLTPHOSProcessor::IntToChar(int number)
115{
116 sprintf(lineNumber,"%d", number);
117 return lineNumber;
939c67e7 118}
8efbf5fe 119
120
121
25b7f84c 122int
04751caa 123AliHLTPHOSProcessor::ScanArgumentsModule(int argc, const char** argv)
25b7f84c 124{
04751caa 125 fPrintInfoModule = kFALSE;
25b7f84c 126 int iResult=0;
127 TString argument="";
128
129 for(int i=0; i<argc && iResult>=0; i++)
130 {
131 argument=argv[i];
132
133 if (argument.IsNull())
134 {
135 continue;
136 }
137
138 if (argument.CompareTo("-printinfo") == 0)
139 {
140 if(i+1 <= argc)
141 {
142 argument=argv[i+1];
04751caa 143 fPrintInfoFrequncyModule = atoi(argv[i+1]);
144 fPrintInfoModule = kTRUE;
25b7f84c 145 }
146 else
147 {
8efbf5fe 148 Logging(kHLTLogWarning, __FILE__ , "inconsistency during init" , "asking for event info, but no update frequency is specified, option is ignored");
25b7f84c 149 }
150 }
151
152 }
153 return 0;
154}
04751caa 155