3 #include "sumAccumulators.hpp"
8 using namespace boost::accumulators;
67 in.seekg (0, ifstream::end);
68 int length = in.tellg();
72 cerr <<
"File "<< *fileList <<
" has zero length. Skipping." << endl;
74 cerr <<
"File "<< *fileList <<
" not found." << endl;
76 fList.push_back(*fileList);
88 list<string>::const_iterator file = fileList.begin();
89 while (file != fileList.end()) {
101 list<string> fileList;
102 map<string, int>::const_iterator
i =
_index.begin();
103 while (i !=
_index.end() ) {
104 fileList.push_back(i->first);
113 char** fileList = (
char**)malloc((
_nwaves + 1) *
sizeof(
char*));
115 map<string, int>::const_iterator
i =
_index.begin();
116 while (i !=
_index.end()) {
117 const string fileName = i->first;
118 fileList[
index] = (
char*)malloc((fileName.size() + 1) *
sizeof(
char));
119 strcpy(fileList[index], fileName.c_str());
123 fileList[
index] = NULL;
135 bool hasWeight =
false;
140 throw "file not found";
145 ifstream* ampfile =
new ifstream [
_nwaves];
146 for (map<string, int>::const_iterator
i =
_index.begin();
i !=
_index.end(); ++
i) {
147 const string fileName =
i->first;
148 const int fileIndex =
i->second;
149 ampfile[fileIndex].open((fileName).c_str());
150 if(!ampfile[fileIndex]) {
151 cerr <<
"error: cannot open " << fileName << endl;
152 throw "file not found";
156 complex<double>* amps =
new complex<double>[
_nwaves];
159 accumulator_set<double, stats<tag::sum(compensated)> > weightInt;
160 accumulator_set<complex<double>, stats<tag::sum(compensated)> > sums[
_nwaves][
_nwaves];
165 const double weight = 1. / w;
168 for (map<string, int>::const_iterator
i =
_index.begin();
i !=
_index.end(); ++
i) {
169 const int index =
i->second;
170 ampfile[
index].read((
char*)&s[index],
sizeof(complex<double>));
171 if ((eof = ampfile[index].eof()))
180 cerr << nRead <<
"\r" << flush;
182 for (map<string, int>::const_iterator
i =
_index.begin();
i !=
_index.end(); ++
i) {
183 const int indexI =
i->second;
184 for (map<string, int>::const_iterator j =
_index.begin(); j !=
_index.end(); ++j) {
185 const int indexJ = j->second;
186 complex<double>
val = amps[indexI] *
conj(amps[indexJ]);
189 sums[indexI][indexJ](
val);
194 for (
int j = 0; j <
_nwaves; ++j)
199 const double weightNorm = sum(weightInt) / (double)nRead;
200 cerr <<
"Weight integral= " << weightNorm << endl;
201 _sum *= 1. / weightNorm;
239 cerr <<
"error: " << iName <<
" not in integral" << endl;
240 throw "bad wave access";
243 cerr <<
"error: " << jName <<
" not in integral" << endl;
244 throw "bad wave access";
255 fList.push_back(*fileList);
266 for (list<string>::const_iterator
i = fileList.begin();
i != fileList.end(); ++
i)
268 cerr <<
"error: " << *
i <<
" not in integral" << endl;
269 throw "bad wave access";
274 for (list<string>::const_iterator
i = fileList.begin();
i != fileList.end(); ++
i)
275 for (list<string>::const_iterator j = fileList.begin(); j != fileList.end(); ++j)
276 ret.
el(*
i, *j) =
el(*
i, *j);
284 return ((complex<double>)(1.0 / ((
double)
_nevents))) *
_sum;
295 map<string, int>::const_iterator
i =
_index.begin();
296 while (i !=
_index.end()) {
297 os << i->first <<
" " << i->second << endl;
315 int indexSize = 0,
index = 0;
318 while (indexSize--) {
321 int slashpos = name.rfind(
'/');
322 if (slashpos != (
int) string::npos) {
323 name.erase(0, slashpos + 1);