ROOTPWA
evtTreeHelper.h
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 // helper functions that convert between standard ASCII PWA2000
29 // .evt files and the new ROOT tree format
30 //
31 //
32 // Author List:
33 // Boris Grube TUM (original author)
34 //
35 //
36 //-------------------------------------------------------------------------
37 
38 
39 #include <string>
40 #include <vector>
41 #include <complex>
42 
43 
44 #if !defined (__CINT__) && !defined (ROOT_CINT)
45 // CINT and ACLiC have problems parsing Boost stuff; ROOT_CINT is set in rootlogon.C
46 #include "isobarAmplitude.h"
47 #endif
48 
49 
50 class TTree;
51 class TClonesArray;
52 
53 
54 namespace rpwa {
55 
56 
57  class isobarDecayTopology;
58  class isobarAmplitude;
59 
60 
61  double getParticleMass(const std::string& name);
62 
63 
64  void parseLeafAndObjNames(const std::string& cmdLineString,
65  std::string& prodKinPartNamesObjName,
66  std::string& prodKinMomentaLeafName,
67  std::string& decayKinPartNamesObjName,
68  std::string& decayKinMomentaLeafName); // parses leaf and object names from ;-delimited command line string
69 
70 
71  bool getParticleNamesFromRootFile(TFile& inFile,
72  TClonesArray*& prodKinPartNames, // array of particle names to be filled
73  TClonesArray*& decayKinPartNames, // array of particle names to be filled
74  const std::string& inTreeName = "rootPwaEvtTree",
75  const std::string& prodKinPartNamesObjName = "prodKinParticles",
76  const std::string& decayKinPartNamesObjName = "decayKinParticles");
77 
78  bool openRootEvtFiles(std::vector<TTree*>& inTrees, // array of trees from .root and .evt files
79  TClonesArray*& prodKinPartNames, // array of particle names to be filled
80  TClonesArray*& decayKinPartNames, // array of particle names to be filled
81  const std::vector<std::string>& rootFileNames, // .root files to be opened
82  const std::vector<std::string>& evtFileNames, // .evt files to be converted to trees
83  const std::string& inTreeName = "rootPwaEvtTree",
84  const std::string& prodKinPartNamesObjName = "prodKinParticles",
85  const std::string& prodKinMomentaLeafName = "prodKinMomenta",
86  const std::string& decayKinPartNamesObjName = "decayKinParticles",
87  const std::string& decayKinMomentaLeafName = "decayKinMomenta",
88  const bool debug = false);
89 
90 
91  bool fillTreeFromEvt(std::istream& inEvt,
92  TTree& outTree, // tree to be filled
93  TClonesArray& prodKinPartNames, // array of particle names to be filled
94  TClonesArray& decayKinPartNames, // array of particle names to be filled
95  const long int maxNmbEvents = -1,
96  const std::string& prodKinMomentaLeafName = "prodKinMomenta",
97  const std::string& decayKinMomentaLeafName = "decayKinMomenta",
98  const bool debug = false,
99  const long int treeCacheSize = 25000000); // 25 MByte ROOT tree read cache
100 
101 
102  bool writeEvtFromTree(TTree& inTree,
103  std::ostream& outEvt,
104  const TClonesArray& prodKinPartNames,
105  const TClonesArray& decayKinPartNames,
106  const long int maxNmbEvents = -1,
107  const std::string& inTreeName = "rootPwaEvtTree",
108  const std::string& prodKinMomentaLeafName = "prodKinMomenta",
109  const std::string& decayKinMomentaLeafName = "decayKinMomenta",
110  const bool debug = false);
111 
112 
113 #if !defined (__CINT__) && !defined (ROOT_CINT)
114  // CINT and ACLiC have problems parsing Boost stuff; ROOT_CINT is set in rootlogon.C
115  bool processTree(TTree& tree, // tree to be read
116  const TClonesArray& prodKinPartNames, // array of particle names
117  const TClonesArray& decayKinPartNames, // array of particle names
118  const isobarAmplitudePtr& amplitude,
119  std::vector<std::complex<double> >& ampValues,
120  const long int maxNmbEvents = -1,
121  const std::string& prodKinMomentaLeafName = "prodKinMomenta",
122  const std::string& decayKinMomentaLeafName = "decayKinMomenta",
123  const bool printProgress = true,
124  const std::string& treePerfStatOutFileName = "", // root file name for tree performance result
125  const long int treeCacheSize = 25000000); // 25 MByte ROOT tree read cache
126 #endif
127 
128 
129 } // namespace rpwa