11 :kweight(kweight_), squareMode(squareMode_), mineta(mineta_), maxeta(maxeta_), minphi(minphi_), maxphi(maxphi_), countEvents(0)
14 if (mineta *
maxeta < 0) Neta--;
16 if (Nphi <0) Nphi += 360;
32 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)
34 int Nevents = eventMatrix.size();
36 std::vector<float> totalSolution(
Nchannels,1.);
37 std::vector<float> iterSolution;
38 std::vector<std::vector<float> > myEventMatrix(eventMatrix);
39 std::vector<float> myEnergyVector(energyVector);
44 for (
int iter=1;iter<=nIter;iter++)
53 for (i=0; i<Nevents; i++)
56 for (j=0; j<
Nxtals; j++) {sumOverEnergy += myEventMatrix[
i][
j];}
57 sumOverEnergy /= myEnergyVector[
i];
58 scale += sumOverEnergy;
62 for (i=0; i<Nevents; i++) {myEnergyVector[
i] *=
scale;}
66 for (
int iEvt=0; iEvt < Nevents; iEvt++)
68 addEvent(myEventMatrix[iEvt], VmaxCeta[iEvt], VmaxCphi[iEvt], myEnergyVector[iEvt]);
71 if (iterSolution.empty())
return iterSolution;
74 for (
int ievent = 0; ievent<Nevents; ievent++)
76 myEventMatrix[ievent] =
recalibrateEvent(myEventMatrix[ievent], VmaxCeta[ievent], VmaxCphi[ievent], iterSolution);
82 totalSolution[
i] *= iterSolution[
i];
95 float w, invsumXmatrix;
101 for (i=0; i<
Nxtals; i++) { sumXmatrix+=eventSquare[
i]; }
104 eventw = 1 - fabs(1 - sumXmatrix/energy);
107 if (sumXmatrix != 0.)
109 invsumXmatrix = 1/sumXmatrix;
113 w = eventSquare[
i] * invsumXmatrix;
119 wsum[iFull] += w*eventw;
120 Ewsum[iFull] += (w*eventw * energy * invsumXmatrix);
132 std::vector<float> solution(
Nchannels,1.);
155 std::vector<float>
MinL3Algorithm::recalibrateEvent(
const std::vector<float>& eventSquare,
const int& maxCeta,
const int& maxCphi,
const std::vector<float>& recalibrateVector)
157 std::vector<float> newEventSquare(eventSquare);
164 newEventSquare[
i] *= recalibrateVector[iFull];
166 return newEventSquare;
176 if (curr_eta * maxCeta <= 0) {
if (maxCeta > 0) curr_eta--;
else curr_eta++; }
179 if (curr_phi < 1) curr_phi += 360;
180 if (curr_phi > 360) curr_phi -= 360;
188 if ( (!negPhiDirection && (curr_phi >=
minphi && curr_phi <=
maxphi)) ||
189 (negPhiDirection && !(curr_phi >=
minphi && curr_phi <=
maxphi)) )
191 iFullphi = curr_phi -
minphi;
192 if (iFullphi < 0) iFullphi += 360;
193 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)