11 #define CLUSTER_MULT_CUTOFF 5 //7
22 fCorrelationProbList(),
27 fThreshold(threshold),
38 fClusterList[moduleId][side].push_back(make_pair(clusterIndex,charge));
119 double oldcut =
fCut;
132 for (vector<pair<int,double> >::iterator topIt = modIt->second[0].begin(); topIt != modIt->second[0].end(); ++topIt)
134 for (vector<pair<int,double> >::iterator botIt = modIt->second[1].begin(); botIt != modIt->second[1].end(); ++botIt)
136 dq=
fabs((*topIt).second - (*botIt).second);
159 std::map<int,std::map<int,PndSdsStripCorrelatorCand> > matrix;
160 double top_total=0.,wert=0.;
161 int nTop=0, nBot=0, iBot=0;
162 for (vector<pair<int,double> >::iterator topIt = modIt->second[0].begin(); topIt != modIt->second[0].end(); ++topIt)
164 for (vector<pair<int,double> >::iterator botIt = modIt->second[1].begin(); botIt != modIt->second[1].end(); ++botIt)
166 wert = (*topIt).second - (*botIt).second;
169 top_total += wert*wert;
176 if(iBot>nBot)nBot=iBot;
182 std::vector<PndSdsStripCorrelatorCombi> combinations =
getCombinations(matrix,nTop,nBot);
184 if(combinations.size()==0)
continue;
187 double klein=-1.,ganzklein=-1.;
188 int who=-1, whoelse=-1;
190 for(
int like=0;like<(int)combinations.size();like++)
192 if(combinations[like].prob>klein)
194 if(combinations[like].prob>ganzklein)
198 ganzklein=combinations[like].prob;
203 klein=combinations[like].prob;
210 for (
int kk=0; kk<(int)combinations[who].pairlist.size(); ++kk)
212 fCorrelationList.push_back(make_pair(combinations[who].pairlist[kk].
top,combinations[who].pairlist[kk].bot));
229 std::vector<PndSdsStripCorrelatorCombi> combinations;
230 if (cols==1 && rows==1) {
233 combi.
prob=matrix[0][0].prob;
234 combinations.push_back(combi);
241 for (
int i=0;
i< rows;
i++) bsum+=matrix[0][
i].q_bot;
242 for (
int i=0;
i< rows;
i++) q_t[
i]=matrix[0][0].q_top - bsum + matrix[0][
i].q_bot;
245 for (
int i=0;
i< rows;
i++)
251 double prob_full=combi.
prob;
252 combinations.push_back(combi);
255 for (
int i=0;
i<rows; ++
i)
258 for (
int ii=0; ii<(int)combilist_reduced.size(); ii++)
260 combilist_reduced[ii].prob*=(1.-prob_full);
262 combinations.insert(combinations.end(),combilist_reduced.begin(),combilist_reduced.end());
270 for (
int i=0;
i<
cols;
i++) tsum+=matrix[
i][0].q_top;
271 for (
int i=0;
i<
cols;
i++) q_b[
i]=matrix[0][0].q_bot - tsum + matrix[
i][0].q_top;
280 double prob_full=combi.
prob;
281 combinations.push_back(combi);
287 for (
int ii=0; ii<(int)combilist_reduced.size(); ii++)
289 combilist_reduced[ii].prob*=(1.-prob_full);
291 combinations.insert(combinations.end(),combilist_reduced.begin(),combilist_reduced.end());
296 if (rows==2 && cols==2) {
302 combi1.
prob*=matrix[0][0].prob;
304 combi1.
prob*=matrix[1][1].prob;
306 combi2.
prob*=matrix[1][0].prob;
308 combi2.
prob*=matrix[0][1].prob;
309 combinations.push_back(combi1);
310 combinations.push_back(combi2);
314 for (
int j=0; j<rows; j++)
317 for (
int k=0; k<(int)combilist.size(); k++) {
319 combilist[k].prob*=matrix[
i][j].prob;
331 std::map<int,std::map<int,PndSdsStripCorrelatorCand> > result;
335 if (
i==pivotCol)
continue;
337 for (
int j=0; j<rows; j++)
339 result[ii][
jj]=matrix[
i][j];
340 if (j==pivotRow)
continue;
friend F32vec4 sqrt(const F32vec4 &a)
vector< pair< int, int > > GetCorrelationList()
vector< int > GetMultProbList()
vector< double > fSecondProbList
vector< double > GetProbList()
map< int, map< int, vector< pair< int, double > > > > fClusterList
vector< double > fCorrelationProbList
void Setup(int mode=0, double cut=0., double noise=0., double threshold=0.)
std::map< int, std::map< int, PndSdsStripCorrelatorCand > > getSubMatrix(std::map< int, std::map< int, PndSdsStripCorrelatorCand > > matrix, int cols, int rows, int pivotCol, int pivotRow)
void AddCluster(int moduleId, int side, int clusterIndex, double charge)
vector< pair< int, int > > fCorrelationList
PndSdsStripCorrelator(int mode=0, double cut=0., double noise=0., double threshold=0.)
friend F32vec4 fabs(const F32vec4 &a)
void CalcChargeDifferenceCut()
vector< double > GetSecondProbList()
void CalcLikelihoodAlgo()
#define CLUSTER_MULT_CUTOFF
std::vector< PndSdsStripCorrelatorCand > pairlist
vector< int > fMultProbList
std::vector< PndSdsStripCorrelatorCombi > getCombinations(std::map< int, std::map< int, PndSdsStripCorrelatorCand > > matrix, int cols, int rows)