]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/AliHLTCaloProcessor.cxx
- cleaning up debug output
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloProcessor.cxx
1 // $Id: AliHLTCaloProcessor.cxx 35966 2009-10-26 12:47:19Z odjuvsla $
2
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
18 #include "AliHLTCaloProcessor.h"
19 #include "unistd.h"
20
21
22
23 const AliHLTComponentDataType AliHLTCaloProcessor::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
24
25
26 AliHLTCaloProcessor::AliHLTCaloProcessor():AliHLTProcessor(), 
27                                            fCaloEventCount(0), 
28                                            fModuleID(2), 
29                                            fPrintInfoModule(0), 
30                                            fPrintInfoFrequncyModule(1000), 
31                                            fRunNumber(0)
32 {
33   //  ScanRunNumberFromFile();
34 }
35
36
37
38 AliHLTCaloProcessor::~AliHLTCaloProcessor()
39 {
40
41 }
42
43  
44 bool 
45 AliHLTCaloProcessor::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     {
52       //      if( (opt == "w")  || (opt == "a")) \\OD
53       if( (!strcmp(opt,"w"))  || (!strcmp(opt,"a")))
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     {
66       //      if( (opt == "w")  || (opt == "a")) \\OD
67       if( (!strcmp(opt,"w"))  || (!strcmp(opt,"a")))
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  
83 void 
84 AliHLTCaloProcessor::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
91
92 void 
93 AliHLTCaloProcessor::ScanRunNumberFromFile()
94 {
95   char tmpDirectory[512];
96   char tmpFileName[512];
97   sprintf(tmpDirectory, "%s", getenv("HOME"));  
98
99   //TODO, remove hardcoded file path
100  
101   
102   sprintf(tmpFileName, "%s%s", tmpDirectory, "/hlt/rundir/runNumber.txt");
103   int tmp = 0;
104   if(CheckFileLog( __FILE__ , tmpFileName , "r")== true) 
105     { 
106       FILE *fp = fopen(tmpFileName, "r");
107       tmp = fscanf(fp, "%d", &fRunNumber);
108       fclose(fp);
109     }
110
111   
112
113
114  }
115
116 const char*
117 AliHLTCaloProcessor::IntToChar(int number)
118 {
119   sprintf(lineNumber,"%d", number);
120   return lineNumber;
121 }
122
123
124
125 int
126 AliHLTCaloProcessor::ScanArgumentsModule(int argc, const char** argv)
127 {
128   fPrintInfoModule = kFALSE;
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];
146             fPrintInfoFrequncyModule = atoi(argv[i+1]);
147             fPrintInfoModule = kTRUE;
148           }
149         else
150           {
151             Logging(kHLTLogWarning, __FILE__ , "inconsistency during init" , "asking for event info, but no update frequency is specified, option is ignored");
152           }
153       }
154  
155     }
156   return 0;
157 }
158