]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSProcessor.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSProcessor.cxx
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
16 #include "AliHLTPHOSProcessor.h"
17 #include "unistd.h"
18
19
20
21 const AliHLTComponentDataType AliHLTPHOSProcessor::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
22
23
24 AliHLTPHOSProcessor::AliHLTPHOSProcessor():AliHLTProcessor(), 
25                                            AliHLTPHOSBase(), 
26                                            fPhosEventCount(0), 
27                                            fModuleID(2), 
28                                            fPrintInfoModule(0), 
29                                            fPrintInfoFrequncyModule(1000), 
30                                            fRunNumber(0)
31 {
32   //  ScanRunNumberFromFile();
33 }
34
35
36
37 AliHLTPHOSProcessor::~AliHLTPHOSProcessor()
38 {
39
40 }
41
42  
43 bool 
44 AliHLTPHOSProcessor::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  
80 void 
81 AliHLTPHOSProcessor::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
88
89 void 
90 AliHLTPHOSProcessor::ScanRunNumberFromFile()
91 {
92   char tmpDirectory[512];
93   char tmpFileName[512];
94   sprintf(tmpDirectory, "%s", getenv("HOME"));  
95
96   //TODO, remove hardcoded file path
97  
98   
99   sprintf(tmpFileName, "%s%s", tmpDirectory, "/hlt/rundir/runNumber.txt");
100  
101   if(CheckFileLog( __FILE__ , tmpFileName , "r")== true) 
102     { 
103       FILE *fp = fopen(tmpFileName, "r");
104       fscanf(fp, "%d", &fRunNumber);
105       fclose(fp);
106     }
107
108   
109
110
111  }
112
113 const char*
114 AliHLTPHOSProcessor::IntToChar(int number)
115 {
116   sprintf(lineNumber,"%d", number);
117   return lineNumber;
118 }
119
120
121
122 int
123 AliHLTPHOSProcessor::ScanArgumentsModule(int argc, const char** argv)
124 {
125   fPrintInfoModule = kFALSE;
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];
143             fPrintInfoFrequncyModule = atoi(argv[i+1]);
144             fPrintInfoModule = kTRUE;
145           }
146         else
147           {
148             Logging(kHLTLogWarning, __FILE__ , "inconsistency during init" , "asking for event info, but no update frequency is specified, option is ignored");
149           }
150       }
151  
152     }
153   return 0;
154 }
155