Functions
mcp_skimmer.cxx File Reference
#include "MCP_Skimmer.h"
#include <iostream>
#include <TFile.h>
#include <TTree.h>

Go to the source code of this file.

Functions

void ShowHelp ()
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 12 of file mcp_skimmer.cxx.

13 {
14  if( argc == 1 || ((argc == 2) && ((std::string("--help") == argv[1]) || (std::string("-h") == argv[1]))) || argc < 7 ){
15  ShowHelp();
16  return 2;
17  }
18 
19  if( argv[1] != std::string("--infile") || argv[3] != std::string("--outfile") || argv[5] != std::string("--debug") ) {
20  ShowHelp();
21  return -2;
22  }
23 
24  // get command line options
25  std::string outfile = "";
26  std::string infile = "";
27  std::string debug = "";
28  int p = 0;
29  while( p < argc )
30  {
31  if( argv[p] == std::string("--infile") ){
32  infile = argv[p+1];
33  p++;
34  }
35  else if( argv[p] == std::string("--outfile") ){
36  outfile = argv[p+1];
37  p++;
38  }
39  else if( argv[p] == std::string("--debug") ){
40  debug = argv[p+1];
41  p++;
42  }
43  else{
44  p++;
45  }
46  }
47 
48  printf( "Skimming from tree dump: %s\n", infile.c_str() );
49  printf( "Output Skimmed file: %s\n", outfile.c_str() );
50  printf( "Debug mode: %s\n", debug.c_str() );
51 
52  MCP_Skimmer *skimmer = new MCP_Skimmer(infile, outfile);
53  if(debug == "1")
54  skimmer->SetDebug(true);
55  if(not skimmer->BookTFile()) return -1;
56 
57  skimmer->SkimMCParticle();
58 
59  skimmer->WriteTTree();
60  skimmer->CloseTFile();
61  printf( "-30-\n" );
62 
63  return 0;
64 }
std::string string
Definition: nybbler.cc:12
string infile
p
Definition: test.py:223
void ShowHelp()
Definition: mcp_skimmer.cxx:7
void ShowHelp ( )

Definition at line 7 of file mcp_skimmer.cxx.

8 {
9  std::cout << "./mcp_skimmer --infile <inputfile> --outfile <outputfile> --debug <0/1>" << std::endl;
10 }
QTextStream & endl(QTextStream &s)