Functions
cafanatree_module.cxx File Reference
#include "CAF.h"
#include "TFile.h"
#include "TTree.h"
#include <iostream>
#include <string>

Go to the source code of this file.

Functions

void ShowHelp ()
 
int main (int argc, char const *argv[])
 

Function Documentation

int main ( int  argc,
char const *  argv[] 
)

Definition at line 27 of file cafanatree_module.cxx.

28 {
29  if( argc == 1 || ((argc == 2) && ((std::string("--help") == argv[1]) || (std::string("-h") == argv[1]))) || argc < 8 ){
30  ShowHelp();
31  return 2;
32  }
33 
34  if( argv[1] != std::string("--infile") || argv[3] != std::string("--outfile") || argv[5] != std::string("--correct4origin") || argv[7] != std::string("--originTPC") ) {
35  ShowHelp();
36  return -2;
37  }
38 
39  // get command line options
40  std::string outfile = "";
41  std::string infile = "";
42  std::string correct4origin = "";
43  std::string x, y, z = "";
44  int p = 0;
45  while( p < argc )
46  {
47  if( argv[p] == std::string("--infile") ){
48  infile = argv[p+1];
49  p++;
50  }
51  else if( argv[p] == std::string("--outfile") ){
52  outfile = argv[p+1];
53  p++;
54  }
55  else if( argv[p] == std::string("--correct4origin") ){
56  correct4origin = argv[p+1];
57  p++;
58  }
59  else if( argv[p] == std::string("--originTPC") ){
60  //origin fixed
61  if( argc == 11 )
62  {
63  x = argv[p+1];
64  y = argv[p+2];
65  z = argv[p+3];
66  p += 3;
67  }
68  else{
69  std::cout << "Missing an origin coordinate!" << std::endl;
70  ShowHelp();
71  return -2;
72  }
73  }
74  else{
75  p++;
76  }
77  }
78 
79  if(correct4origin != "0" && correct4origin != "1")
80  {
81  ShowHelp();
82  return -2;
83  }
84 
85  if( x == "" && y == "" && z == "" )
86  {
87  printf("No TPC offset given, defaulting to (0, 0, 0)!!\n");
88  x = y = z = "0";
89  }
90 
91  printf( "Making CAF from tree dump: %s\n", infile.c_str() );
92  printf( "Output CAF file: %s\n", outfile.c_str() );
93  printf( "Correct for Origin: %s\n", correct4origin.c_str() );
94  printf( "TPC offset: (%s, %s, %s) cm\n", x.c_str(), y.c_str(), z.c_str() );
95 
96  double originTPC[3] = {std::atof(x.c_str()), std::atof(y.c_str()), std::atof(z.c_str())};
97 
98  CAF *caf = new CAF(infile, outfile, std::atoi(correct4origin.c_str()), &originTPC[0]);
99  if(not caf->BookTFile()) return -1;
100 
101  caf->loop();
102 
103  caf->WriteTTree();
104  printf( "-30-\n" );
105  caf->CloseTFile();
106 
107  return 0;
108 }
std::string string
Definition: nybbler.cc:12
void ShowHelp()
string infile
p
Definition: test.py:223
Definition: CAF.h:12
list x
Definition: train.py:276
Common Analysis Files.
Definition: SRGAr.h:13
QTextStream & endl(QTextStream &s)
void ShowHelp ( )

Definition at line 22 of file cafanatree_module.cxx.

23 {
24  std::cout << "./cafanatree_module --infile <inputfile> --outfile <outputfile> --correct4origin <0/1> --originTPC <x> <y> <z> (in cm)" << std::endl;
25 }
QTextStream & endl(QTextStream &s)