mcp_skimmer.cxx
Go to the documentation of this file.
1 #include "MCP_Skimmer.h"
2 #include <iostream>
3 
4 #include <TFile.h>
5 #include <TTree.h>
6 
7 void ShowHelp()
8 {
9  std::cout << "./mcp_skimmer --infile <inputfile> --outfile <outputfile> --debug <0/1>" << std::endl;
10 }
11 
12 int main(int argc, char **argv)
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 }
int main(int argc, char **argv)
Definition: mcp_skimmer.cxx:12
std::string string
Definition: nybbler.cc:12
string infile
p
Definition: test.py:223
void ShowHelp()
Definition: mcp_skimmer.cxx:7
QTextStream & endl(QTextStream &s)