45 #include "TClonesArray.h"
46 #include "TObjString.h"
49 #include "reportingUtils.hpp"
59 const string& outFileName =
"testEvents.root",
60 const long int maxNmbEvents = -1,
61 const string& outTreeName =
"rootPwaEvtTree",
62 const string& prodKinPartNamesObjName =
"prodKinParticles",
63 const string& prodKinMomentaLeafName =
"prodKinMomenta",
64 const string& decayKinPartNamesObjName =
"decayKinParticles",
65 const string& decayKinMomentaLeafName =
"decayKinMomenta",
66 const bool debug =
false)
69 printInfo <<
"opening input file '" << evtFileName <<
"'" << endl;
70 ifstream evtFile(evtFileName.c_str());
71 if (not evtFile or not evtFile.good()) {
72 printWarn <<
"cannot open input file '" << evtFileName <<
"'" << endl;
77 printInfo <<
"creating output file '" << outFileName <<
"'" << endl;
78 TFile* outFile = TFile::Open(outFileName.c_str(),
"RECREATE");
80 printErr <<
"cannot open output file '" << outFileName <<
"'" << endl;
85 TTree* tree =
new TTree(outTreeName.c_str(), outTreeName.c_str());
87 printErr <<
"problems creating tree '" << outTreeName <<
"' "
88 <<
"in file '" << outFileName <<
"'" << endl;
93 TClonesArray* prodKinPartNames =
new TClonesArray(
"TObjString");
94 TClonesArray* decayKinPartNames =
new TClonesArray(
"TObjString");
96 *prodKinPartNames, *decayKinPartNames,
98 prodKinMomentaLeafName, decayKinMomentaLeafName,
101 prodKinPartNames->Write (prodKinPartNamesObjName.c_str (), TObject::kSingleKey);
102 decayKinPartNames->Write(decayKinPartNamesObjName.c_str(), TObject::kSingleKey);
106 printSucc <<
"wrote events to file '" << outFileName <<
"'" << endl;
108 printWarn <<
"problems processing events" << endl;