source: fact/tools/marsmacros/mc2csv/mmc2csv.C@ 14737

Last change on this file since 14737 was 14737, checked in by Jens Buss, 12 years ago
added main.C to compile a binary
  • Property svn:executable set to *
File size: 3.2 KB
Line 
1//--------------------------------------------------------------------------------
2//
3//
4//
5#include <iostream>
6#include <string>
7#include <stdlib.h>
8
9#include <TROOT.h>
10#include <TSystem.h>
11#include <TString.h>
12#include <TStyle.h>
13
14//#include <stdio.h>
15
16#include "MonteCarlo.h"
17
18using namespace std;
19
20 int mmc2csv(
21 TString rootFile = "",
22 TString csvDestination = "",
23 int verbLvl = 0
24 )
25 {
26
27 cout << "...loading MC file" << endl;
28 TString temp = rootFile;
29 // if (!gSystem->BaseName(csvFile)){
30 // TString csvFile = gSystem->DirName(csvLocation);
31
32 temp = temp.Remove(
33 rootFile.Last('.'),
34 rootFile.Length() - rootFile.Last('.')
35 );
36 // csvDestination += "/";
37 csvDestination += gSystem->BaseName(temp);
38 csvDestination += ".csv";
39 // }
40
41 // cout << csvDestination << endl ;
42
43 MonteCarlo MC( rootFile );
44
45 cout << "...setting verbosity Level" << endl;
46 MC.SetVerbosityLevel(verbLvl);
47
48 cout << "...converting mc to csv" << endl;
49 MC.WriteMc2Csv(csvDestination);
50
51 return 0;
52
53 }
54
55int main(int argc, char* argv[])
56{
57 int verbLVL = 0;
58 std::string arg;
59 std::string inFile, outPath;
60 // Check the number of parameters
61 if (argc < 2) {
62 // Tell the user how to run the program
63 std::cerr << "Usage: " << argv[0]
64 << " -i <infile> -o <outdir> -vvvv \n"
65 << std::endl;
66 /* "Usage messages" are a conventional way of telling the user
67 * how to run a program if they enter the command incorrectly.
68 */
69 return 1;
70 }
71 // Print the user's name:
72
73 for ( int i = 0; i < argc; i++)
74 {
75 if (i < argc) // Check that we haven't finished parsing already
76 {
77 arg = argv[i];
78 // std::cout << "..." << arg << std::endl;
79
80 if (arg == "-i" || arg == "--input" )
81 {
82 inFile = argv[i+1];
83 std::cout << "inFile: " << inFile << std::endl;
84 }
85 else if (arg == "-o" || arg == "--output" )
86 {
87 outPath = argv[i+1];
88 std::cout << "outPath: " << outPath << std::endl;
89 }
90 else if ( arg.find_first_of("-") == 0 && arg.find_first_of("v") == 1 ){
91 verbLVL = arg.find_last_of("v") - arg.find_first_of("v") + 1;
92 std::cout << "verbosity level: " << verbLVL << std::endl;
93 }
94 }
95 else
96 {
97 std::cout << "Not enough or invalid arguments, please try again.\n";
98 exit(0);
99 }
100// std::cout << argv[0] << "says hello, " << argv[i] << std::endl;
101 }
102
103 // mmc2csv(myFile, myOutPath, verbLvl);
104 cout << "mmc2csv(" << inFile << ", " << outPath << ", "
105 << verbLVL << " )" << endl;
106 return 0;
107}
108
Note: See TracBrowser for help on using the repository browser.