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

Last change on this file since 18123 was 14796, checked in by ftemme, 12 years ago
uncomment the call of mmc2csv(inFile,outPath,verbLVL) in main() of mmc2csv.C
  • Property svn:executable set to *
File size: 3.0 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
72 for ( int i = 0; i < argc; i++)
73 {
74 if (i < argc) // Check that we haven't finished parsing already
75 {
76 arg = argv[i];
77
78 if (arg == "-i" || arg == "--input" )
79 {
80 inFile = argv[i+1];
81 std::cout << "inFile: " << inFile << std::endl;
82 }
83 else if (arg == "-o" || arg == "--output" )
84 {
85 outPath = argv[i+1];
86 std::cout << "outPath: " << outPath << std::endl;
87 }
88 else if ( arg.find_first_of("-") == 0 && arg.find_first_of("v") == 1 ){
89 verbLVL = arg.find_last_of("v") - arg.find_first_of("v") + 1;
90 std::cout << "verbosity level: " << verbLVL << std::endl;
91 }
92 }
93 else
94 {
95 std::cout << "Not enough or invalid arguments, please try again.\n";
96 exit(0);
97 }
98 }
99
100
101 cout << "mmc2csv(" << inFile << ", " << outPath << ", "
102 << verbLVL << " )" << endl;
103 mmc2csv(inFile, outPath, verbLVL);
104 return 0;
105}
106
Note: See TracBrowser for help on using the repository browser.