13 :kweight(kweight_), squareMode(squareMode_), mineta(mineta_), maxeta(maxeta_), minphi(minphi_), maxphi(maxphi_), countEvents(0)
16 if (mineta *
maxeta < 0) Neta--;
18 if (Nphi <0) Nphi += 360;
34 std::vector<float>
MinL3Algorithm::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)
36 int Nevents = eventMatrix.size();
38 std::vector<float> totalSolution(
Nchannels,1.);
39 std::vector<float> iterSolution;
40 std::vector<std::vector<float> > myEventMatrix(eventMatrix);
41 std::vector<float> myEnergyVector(energyVector);
46 for (
int iter=1;iter<=nIter;iter++)
55 for (i=0; i<Nevents; i++)
58 for (j=0; j<
Nxtals; j++) {sumOverEnergy += myEventMatrix[
i][
j];}
59 sumOverEnergy /= myEnergyVector[
i];
60 scale += sumOverEnergy;
64 for (i=0; i<Nevents; i++) {myEnergyVector[
i] *=
scale;}
68 for (
int iEvt=0; iEvt < Nevents; iEvt++)
70 addEvent(myEventMatrix[iEvt], VmaxCeta[iEvt], VmaxCphi[iEvt], myEnergyVector[iEvt]);
73 if (iterSolution.empty())
return iterSolution;
76 for (
int ievent = 0; ievent<Nevents; ievent++)
78 myEventMatrix[ievent] =
recalibrateEvent(myEventMatrix[ievent], VmaxCeta[ievent], VmaxCphi[ievent], iterSolution);
84 totalSolution[
i] *= iterSolution[
i];
97 float w, invsumXmatrix;
103 for (i=0; i<
Nxtals; i++) { sumXmatrix+=eventSquare[
i]; }
106 eventw = 1 - fabs(1 - sumXmatrix/energy);
109 if (sumXmatrix != 0.)
111 invsumXmatrix = 1/sumXmatrix;
115 w = eventSquare[
i] * invsumXmatrix;
121 wsum[iFull] += w*eventw;
122 Ewsum[iFull] += (w*eventw * energy * invsumXmatrix);
134 std::vector<float> solution(
Nchannels,1.);
157 std::vector<float>
MinL3Algorithm::recalibrateEvent(
const std::vector<float>& eventSquare,
const int& maxCeta,
const int& maxCphi,
const std::vector<float>& recalibrateVector)
159 std::vector<float> newEventSquare(eventSquare);
166 newEventSquare[
i] *= recalibrateVector[iFull];
168 return newEventSquare;
178 if (curr_eta * maxCeta <= 0) {
if (maxCeta > 0) curr_eta--;
else curr_eta++; }
181 if (curr_phi < 1) curr_phi += 360;
182 if (curr_phi > 360) curr_phi -= 360;
190 if ( (!negPhiDirection && (curr_phi >=
minphi && curr_phi <=
maxphi)) ||
191 (negPhiDirection && !(curr_phi >=
minphi && curr_phi <=
maxphi)) )
193 iFullphi = curr_phi -
minphi;
194 if (iFullphi < 0) iFullphi += 360;
195 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)