12 squareMode(squareMode_),
36 const std::vector<int>& VmaxCeta,
37 const std::vector<int>& VmaxCphi,
38 const std::vector<float>& energyVector,
40 const bool& normalizeFlag) {
41 int Nevents = eventMatrix.size();
43 std::vector<float> totalSolution(
Nchannels, 1.);
44 std::vector<float> iterSolution;
45 std::vector<std::vector<float> > myEventMatrix(eventMatrix);
46 std::vector<float> myEnergyVector(energyVector);
51 for (
int iter = 1; iter <= nIter; iter++) {
57 for (i = 0; i < Nevents; i++) {
59 for (j = 0; j <
Nxtals; j++) {
60 sumOverEnergy += myEventMatrix[
i][
j];
62 sumOverEnergy /= myEnergyVector[
i];
63 scale += sumOverEnergy;
67 for (i = 0; i < Nevents; i++) {
68 myEnergyVector[
i] *=
scale;
73 for (
int iEvt = 0; iEvt < Nevents; iEvt++) {
74 addEvent(myEventMatrix[iEvt], VmaxCeta[iEvt], VmaxCphi[iEvt], myEnergyVector[iEvt]);
77 if (iterSolution.empty())
81 for (
int ievent = 0; ievent < Nevents; ievent++) {
82 myEventMatrix[ievent] =
recalibrateEvent(myEventMatrix[ievent], VmaxCeta[ievent], VmaxCphi[ievent], iterSolution);
87 totalSolution[
i] *= iterSolution[
i];
101 float w, invsumXmatrix;
105 float sumXmatrix = 0.;
107 for (i = 0; i <
Nxtals; i++) {
108 sumXmatrix += eventSquare[
i];
112 eventw = 1 - fabs(1 - sumXmatrix / energy);
115 if (sumXmatrix != 0.) {
116 invsumXmatrix = 1 / sumXmatrix;
118 for (i = 0; i <
Nxtals; i++) {
119 w = eventSquare[
i] * invsumXmatrix;
124 wsum[iFull] += w * eventw;
125 Ewsum[iFull] += (w * eventw * energy * invsumXmatrix);
135 std::vector<float> solution(
Nchannels, 1.);
159 const std::vector<float>& recalibrateVector) {
160 std::vector<float> newEventSquare(eventSquare);
166 newEventSquare[
i] *= recalibrateVector[iFull];
168 return newEventSquare;
176 if (curr_eta * maxCeta <= 0) {
195 if ((!negPhiDirection && (curr_phi >=
minphi && curr_phi <=
maxphi)) ||
196 (negPhiDirection && !(curr_phi >=
minphi && curr_phi <=
maxphi))) {
197 iFullphi = curr_phi -
minphi;
200 regionIndex = (curr_eta -
mineta) * (
maxphi - minphi + 1 + 360 * negPhiDirection) + iFullphi;
MinL3Algorithm(float kweight_=0., int squareMode_=5, int mineta_=1, int maxeta_=85, int minphi_=1, int maxphi_=20)
std::vector< float > getSolution(bool resetsolution=true)
get the solution at the end of the calibration
int indexSqr2Reg(const int &sqrIndex, const int &maxCeta, const int &maxCphi)
method to translate from square indices to region indices
std::vector< float > wsum
~MinL3Algorithm()
Destructor.
void resetSolution()
reset for new iteration
void addEvent(const std::vector< float > &eventSquare, const int &maxCeta, const int &maxCphi, const float &energy)
add event to the calculation of the calibration vector
std::vector< float > Ewsum
std::vector< float > recalibrateEvent(const std::vector< float > &eventSquare, const int &maxCeta, const int &maxCphi, const std::vector< float > &recalibrateVector)
recalibrate before next iteration: give previous solution vector as argument
Power< A, B >::type pow(const A &a, const B &b)
std::vector< float > iterate(const std::vector< std::vector< float > > &eventMatrix, const std::vector< int > &VmaxCeta, const std::vector< int > &VmaxCphi, const std::vector< float > &energyVector, const int &nIter, const bool &normalizeFlag=false)