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 |
|
---|
18 | using 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 |
|
---|
55 | int 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 |
|
---|