11 : normaliseFlag(normalise)
18 const std::vector<float>& energyVector,
20 std::vector<float> solution;
21 std::vector<std::vector<float> > myEventMatrix(eventMatrix);
22 int Nevents = eventMatrix.size();
23 int Nchannels = eventMatrix[0].size();
24 std::vector<float> theCalibVector(Nchannels, 1.);
27 for (
int iter = 1; iter <= nIter; iter++) {
29 solution =
iterate(myEventMatrix, energyVector);
36 for (
int i = 0;
i < Nchannels;
i++) {
37 for (
int ievent = 0; ievent < Nevents; ievent++) {
38 myEventMatrix[ievent][
i] *= solution[
i];
41 theCalibVector[
i] *= solution[
i];
46 return theCalibVector;
50 const std::vector<float>& energyVector) {
51 std::vector<float> solution;
52 std::vector<float> myEnergyVector(energyVector);
54 int Nevents = eventMatrix.size();
55 int Nchannels = eventMatrix[0].size();
58 if (Nevents !=
int(myEnergyVector.size())) {
59 std::cout <<
"GenericMinL3Algorithm::iterate(): Error: bad matrix dimensions. Dropping out." << std::endl;
64 solution.assign(Nchannels, 1.);
73 std::cout <<
"GenericMinL3Algorithm::iterate(): Normalising event data" << std::endl;
75 for (
i = 0;
i < Nevents;
i++) {
77 for (
j = 0;
j < Nchannels;
j++) {
78 sumOverEnergy += eventMatrix[
i][
j];
80 sumOverEnergy /= myEnergyVector[
i];
81 scale += sumOverEnergy;
86 for (
i = 0;
i < Nevents;
i++) {
87 myEnergyVector[
i] *=
scale;
92 float sum25, invsum25;
94 std::vector<float> wsum(Nchannels, 0.);
95 std::vector<float> Ewsum(Nchannels, 0.);
98 for (ievent = 0; ievent < Nevents; ievent++) {
102 for (
i = 0;
i < Nchannels;
i++) {
103 sum25 += eventMatrix[ievent][
i];
107 invsum25 = 1 / sum25;
109 for (
i = 0;
i < Nchannels;
i++) {
110 w = eventMatrix[ievent][
i] * invsum25;
112 Ewsum[
i] += (
w * myEnergyVector[ievent] * invsum25);
115 std::cout <<
" Debug: dropping null event: " << ievent << std::endl;
121 for (
i = 0;
i < Nchannels;
i++) {
123 solution[
i] *= Ewsum[
i] / wsum[
i];
125 std::cout <<
"warning - no event data for crystal index " <<
i << std::endl;