//------------------------------------------------------------------------------------ //---------------- PndSdsStripCorrelator.h ------------------------- // Class to correlate top and bottom clusters on double sided strip sensors // // Authors: R. Kliemt (Uni Bonn) // H.G. Zaunick (Uni Bonn) // Date: June 2012 // //------------------------------------------------------------------------------------ #ifndef PNDSDSSTRIPCLUSTECORRELATOR_H #define PNDSDSSTRIPCLUSTECORRELATOR_H 1 #include #include #include #include using namespace std; //Data types struct PndSdsStripCorrelatorCand { PndSdsStripCorrelatorCand() : top(), bot(), q_top(), q_bot(), prob(1.) {} PndSdsStripCorrelatorCand(int t, int b, double qt, double qb, double p) : top(t), bot(b), q_top(qt), q_bot(qb), prob(p) {} int top,bot; double q_top, q_bot; double prob; }; struct PndSdsStripCorrelatorCombi { public: PndSdsStripCorrelatorCombi() : pairlist(),prob(1.) {} PndSdsStripCorrelatorCombi(const std::vector& list, double p) : prob(p) { pairlist.insert(pairlist.end(),list.begin(),list.end()); } PndSdsStripCorrelatorCombi(const PndSdsStripCorrelatorCombi& a_combi) : prob(a_combi.prob) { pairlist.insert(pairlist.end(),a_combi.pairlist.begin(),a_combi.pairlist.end()); } std::vector pairlist; double prob; }; // Now the "real" class class PndSdsStripCorrelator { public: PndSdsStripCorrelator(int mode=0, double cut=0., double noise=0., double threshold=0.); ~PndSdsStripCorrelator(); void Reset(); void Setup(int mode=0, double cut=0., double noise=0., double threshold=0.); void AddCluster(int moduleId, int side, int clusterIndex, double charge); vector > GetCorrelationList(); vector GetProbList(); vector GetSecondProbList(); vector GetMultProbList(); private: void CalcChargeDifferenceCut(); void CalcLikelihoodAlgo(); void CalcAll(); std::vector getCombinations(std::map > matrix, int cols, int rows); std::map > getSubMatrix(std::map > matrix, int cols, int rows, int pivotCol, int pivotRow); // Module Side clusterindex charge map > > > fClusterList; //List of the cluster indices and their charges vector > fCorrelationList; //List of matching top/bottom clusters vector fCorrelationProbList; //List of associated prob values for each module vector fSecondProbList; //List of the second prob values for each module vector fMultProbList; //List of number of correlations double fCut; //Cut parameter: ChargeDifference or minimum Likelihood double fNoise; //Noise sigma[e-] double fThreshold; //Discrimination threshold [e-] int fMode; //which mode to use 0:ChargeDifferenceCut 1:Liklelihood bool fCalculated; //flag for automatic calculation calls }; #endif