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