ROOTPWA
convertTreeToAmp.C
Go to the documentation of this file.
1 
2 //
3 // Copyright 2010
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-------------------------------------------------------------------------
22 // File and Version Information:
23 // $Rev:: $: revision of last commit
24 // $Author:: $: author of last commit
25 // $Date:: $: date of last commit
26 //
27 // Description:
28 // program that converts standrad ASCII PWA2000 .evt files into
29 // new ROOT tree format
30 //
31 //
32 // Author List:
33 // Boris Grube TUM (original author)
34 //
35 //
36 //-------------------------------------------------------------------------
37 
38 
39 #include <fstream>
40 #include <string>
41 #include <iomanip>
42 #include <limits>
43 #include <algorithm>
44 
45 #include "TChain.h"
46 #include "TClonesArray.h"
47 #include "TObjString.h"
48 #include "TVector3.h"
49 
50 #include "reportingUtils.hpp"
51 #include "amplitudeTreeHelper.h"
52 
53 
54 using namespace std;
55 using namespace rpwa;
56 
57 
58 bool
59 convertTreeToAmp(const string& inFileNamePattern = "testAmpTree.root",
60  const string& inTreeName = "1-1++1+rho770_21_pi-.amp",
61  const string& outFileName = "1-1++1+rho770_21_pi-.test.amp",
62  const long int maxNmbEvents = -1,
63  const string& ampLeafName = "amplitude",
64  const bool debug = false)
65 {
66  // open input file
67  printInfo << "opening input file(s) '" << inFileNamePattern << "'" << endl;
68  TChain chain(inTreeName.c_str());
69  if (chain.Add(inFileNamePattern.c_str()) < 1) {
70  printWarn << "no events in input file(s) '" << inFileNamePattern << "'" << endl;
71  return false;
72  }
73  chain.GetListOfFiles()->ls();
74  printInfo << "reading from tree '" << inTreeName << "'" << endl;
75 
76  // doit
77  const bool success = writeAmpFromTree(chain, outFileName, maxNmbEvents, ampLeafName, debug);
78 
79  if (success)
80  printInfo << "wrote events to file '" << outFileName << "'" << endl;
81  else
82  printWarn << "problems processing events" << endl;
83  return success;
84 }