Changeset 14737


Ignore:
Timestamp:
12/06/12 14:37:44 (12 years ago)
Author:
Jens Buss
Message:
added main.C to compile a binary
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/marsmacros/mc2csv/mmc2csv.C

    r14724 r14737  
    33//
    44//
     5#include <iostream>
     6#include <string>
     7#include <stdlib.h>
     8
     9#include <TROOT.h>
    510#include <TSystem.h>
    611#include <TString.h>
    712#include <TStyle.h>
    8 //#include <TCanvas.h>
    9 //#include <TMath.h>
    10 //#include <TFile.h>
    11 //#include <TH1.h>
    12 //#include <TH2F.h>
    13 //#include <TF1.h>
    14 //#include <TTree.h>
    15 
    16 #include <endian.h>
    17 
    18 
    19 //#include "MStatusDisplay.h"
    20 //#include "MStatusArray.h"
    21 //#include "MRawEvtData.h"
    22 //#include "MArrayB.h"
    2313
    2414//#include <stdio.h>
    25 //#include <iostream.h>
    2615
    2716#include "MonteCarlo.h"
    2817
    2918using namespace std;
    30 using namespace TMath;
    3119
     20    int mmc2csv(
     21            TString     rootFile        = "",
     22            TString     csvDestination  = "",
     23            int         verbLvl         = 0
     24            )
     25    {
    3226
    33 int mmc2csv(
    34         TString     rootFile        = "/home_nfs/isdc/jbbuss/FACT-MC/00002249.001_D_MonteCarlo000.root",
    35         TString     csvDestination  = "/home_nfs/isdc/jbbuss/FACT-MC/",
    36         int         verbLvl         = 0
    37         )
     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[])
    3856{
     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:
    3972
    40     cout << "...loading MC file" << endl;
    41     TString temp = rootFile;
    42 //    if (!gSystem->BaseName(csvFile)){
    43 //        TString csvFile = gSystem->DirName(csvLocation);
     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;
    4479
    45         temp = temp.Remove(
    46                     rootFile.Last('.'),
    47                     rootFile.Length() - rootFile.Last('.')
    48                     );
    49 //        csvDestination += "/";
    50         csvDestination += gSystem->BaseName(temp);
    51         csvDestination += ".csv";
    52 //       }
     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        }
    53102
    54 //    cout << csvDestination << endl ;
    55 
    56     MonteCarlo MC( rootFile );
    57 
    58     cout << "...setting verbosity Level" << endl;
    59     MC.SetVerbosityLevel(verbLvl);
    60 
    61     cout << "...converting mc to csv" << endl;
    62     MC.WriteMc2Csv(csvDestination);
    63 
    64 return 0;
    65 
     103        //        mmc2csv(myFile, myOutPath, verbLvl);
     104        cout << "mmc2csv(" << inFile << ", " << outPath << ", "
     105             << verbLVL << " )" << endl;
     106        return 0;
    66107}
    67108
    68 
Note: See TracChangeset for help on using the changeset viewer.