44 #include "reportingUtils.hpp"
45 #include "fileUtils.hpp"
55 const int errCode = 0)
57 cerr <<
"computes integral matrix for given amplitude files" << endl
61 <<
" [-o output file -i TKey name -n max. # of events -r max. # of events -w weight file -v -h] "
62 <<
"amplitude files" << endl
64 <<
" -o path path to output file (default: './norm.int')" << endl
65 <<
" -i name integral TKey name (only for .root format, default: 'integral')" << endl
66 <<
" -n # maximum number of events to process (default: all)" << endl
67 <<
" -r # number of events to renormalize to (default: no renormalization)" << endl
68 <<
" -w path path to MC weight file for de-weighting (default: none)" << endl
69 <<
" -v verbose; print debug output (default: false)" << endl
70 <<
" -h print help" << endl
90 const string progName = argv[0];
91 string outFileName =
"./norm.int";
92 string integralName =
"integral";
93 unsigned int maxNmbEvents = 0;
94 unsigned int nmbEventsRenorm = 0;
95 string weightFileName =
"";
100 while ((c = getopt(argc, argv,
"o:i:n:r:w:vh")) != -1)
103 outFileName = optarg;
106 integralName = optarg;
109 maxNmbEvents =
atoi(optarg);
112 nmbEventsRenorm =
atoi(optarg);
115 weightFileName = optarg;
126 ampIntegralMatrix::setDebug(debug);
129 if (optind >= argc) {
130 printErr <<
"you need to specify at least one amplitude file to process. aborting." << endl;;
133 vector<string> rootAmpFileNames;
134 vector<string> binAmpFileNames;
135 while (optind < argc) {
136 const string fileName = argv[optind++];
137 const string fileExt = extensionFromPath(fileName);
138 if (fileExt ==
"root") {
139 #ifdef USE_STD_COMPLEX_TREE_LEAFS
140 rootAmpFileNames.push_back(fileName);
142 printErr <<
"reading of amplitudes in .root format not supported. "
143 <<
"upgrade your ROOT installation. skipping." << endl;
145 }
else if (fileExt ==
"amp")
146 binAmpFileNames.push_back(fileName);
148 printWarn <<
"input file '" << fileName <<
"' is neither a .root nor a .amp file. "
149 <<
"skipping." << endl;
151 if ((rootAmpFileNames.size() == 0) and (binAmpFileNames.size() == 0)) {
152 printErr <<
"none of the specified input files is a .root or .amp file. aborting.";
158 integral.
integrate(binAmpFileNames, rootAmpFileNames, maxNmbEvents, weightFileName);
159 if (nmbEventsRenorm > 0)
163 const string outFileExt = extensionFromPath(outFileName);
164 if (outFileExt ==
"root") {
165 #ifdef USE_STD_COMPLEX_TREE_LEAFS
166 TFile* outFile = TFile::Open(outFileName.c_str(),
"RECREATE");
168 printErr <<
"cannot open output file '" << outFileName <<
"'. aborting." << endl;
171 const int nmbBytes = integral.Write(integralName.c_str());
174 printErr <<
"problems writing integral to TKey '" << integralName <<
"' "
175 <<
"in file '" << outFileName <<
"'" << endl;
178 printSucc <<
"wrote integral to TKey '" << integralName <<
"' "
179 <<
"in file '" << outFileName <<
"'" << endl;
181 printErr <<
"writing of integrals in .root format not supported. "
182 <<
"upgrade your ROOT installation. aborting." << endl;
184 #endif // USE_STD_COMPLEX_TREE_LEAFS
185 }
else if (outFileExt ==
"int")
188 printErr <<
"output file '" << outFileName <<
"' should be either a .root or a .int file. "