#ifndef L1Triplet_H #define L1Triplet_H class L1TripletV { public: static float_m compareChain(const L1TripletV *a, const L1TripletV *b){ return (a->chi2Chain < b->chi2Chain); } int_v w0; // left hit (16b) index in vStsHits array int_v w1; // middle hit(16b) int_v w2; // right hit(16b) // unsigned char b0; // chi2(5b) + level(3b) int_v bl; // level fvec b1; // qp (8b) int_v st; // staL (4b), staM-1-staL (2b), staR-2-staL (2b) fvec chi2double; public: static float_m compare(const L1TripletV *a, const L1TripletV *b){ // sort in back order return ( ( a->GetLHit() > b->GetLHit() ) ) || ( ( a->GetLHit() == b->GetLHit() ) && ( a->GetMHit() < b->GetMHit() ) ) || ( ( a->GetLHit() == b->GetLHit() ) && ( a->GetMHit() == b->GetMHit() ) && ( a->GetRHit() < b->GetRHit() ) ); // return a.GetLHit() > b.GetLHit(); } static float_m compareLevel(const L1TripletV *a, const L1TripletV *b){ // sort in back order return ( a->GetLevel() > b->GetLevel() ); } fvec Cqp; fvec chi2Chain; L1TripletV(){}; void Set( int_v iHitL, int_v iHitM, int_v iHitR, int_v iStaL, int_v iStaM, int_v iStaR, int_v Level, fvec Qp, fvec Chi2 ){ w0 = iHitL; w1 = iHitM; w2 = iHitR; // Chi2 = sqrt(fabs(Chi2))*31./3.5 ; // 3.5 == 31 chi2double = Chi2; // if( Chi2>31 || !finite(Chi2) ) Chi2 = 31; // b0 = ( (static_cast( Chi2 ))<<3 ) + (Level%8); b1 = Qp; bl = Level; st = (iStaL<<4) + ((iStaM-iStaL-1)<<2) + (iStaR-iStaL-2); } void SetLevel(int_v Level) { bl = Level; } int_v GetLHit() const { return w0; } int_v GetMHit() const { return w1; } int_v GetRHit() const { return w2; } // unsigned int GetFirstNeighbour() const { // return w1; // } // unsigned int GetNNeighbours() const { // return w2; // } int_v GetLevel() const { // return b0%8; return bl; } fvec GetQp() const { return b1; } fvec GetChi2() const { // float x = (b0>>3)*3.5/31.; // return x*x; return chi2double; } fvec GetQpOrig(){ return b1; } // fvec GetLSta() const { // return st>>4; // } // fvec GetMSta() const { // return ((st%16)>>2) + GetLSta() + 1; // } // fvec GetRSta() const { // return (st%4) + GetLSta() + 2; // } }; class L1Triplet { public: static bool compareChain(const L1Triplet *a, const L1Triplet *b){ return a->chi2Chain < b->chi2Chain; } private: THitI w0; // left hit (16b) index in vStsHits array THitI w1; // middle hit(16b) THitI w2; // right hit(16b) // unsigned char b0; // chi2(5b) + level(3b) unsigned char bl; // level fscal b1; // qp (8b) unsigned char st; // staL (4b), staM-1-staL (2b), staR-2-staL (2b) fscal chi2double; public: static bool compare(const L1Triplet *a, const L1Triplet *b){ // sort in back order return ( ( a->GetLHit() > b->GetLHit() ) ) || ( ( a->GetLHit() == b->GetLHit() ) && ( a->GetMHit() < b->GetMHit() ) ) || ( ( a->GetLHit() == b->GetLHit() ) && ( a->GetMHit() == b->GetMHit() ) && ( a->GetRHit() < b->GetRHit() ) ); // return a.GetLHit() > b.GetLHit(); } static bool compareLevel(const L1Triplet *a, const L1Triplet *b){ // sort in back order return ( a->GetLevel() > b->GetLevel() ); } fscal Cqp; fscal chi2Chain; // L1Triplet* neibourBest; std::vector neighbours; L1Triplet(){}; void Set( unsigned int iHitL, unsigned int iHitM, unsigned int iHitR, unsigned int iStaL, unsigned int iStaM, unsigned int iStaR, unsigned char Level, fscal Qp, fscal Chi2 ){ w0 = iHitL; w1 = iHitM; w2 = iHitR; // Chi2 = sqrt(fabs(Chi2))*31./3.5 ; // 3.5 == 31 chi2double = Chi2; // if( Chi2>31 || !finite(Chi2) ) Chi2 = 31; // b0 = ( (static_cast( Chi2 ))<<3 ) + (Level%8); b1 = Qp; bl = Level; st = (iStaL<<4) + ((iStaM-iStaL-1)<<2) + (iStaR-iStaL-2); } void SetOneEntry(L1TripletV t, int iV){ w0 = t.w0[iV]; w1 = t.w1[iV]; w2 = t.w2[iV]; chi2double = t.chi2double[iV]; b1 = t.b1[iV]; bl = t.bl[iV]; st = t.st[iV]; } void SetLevel(unsigned char Level) { bl = Level; } THitI GetLHit() const { return w0; } THitI GetMHit() const { return w1; } THitI GetRHit() const { return w2; } // unsigned int GetFirstNeighbour() const { // return w1; // } // unsigned int GetNNeighbours() const { // return w2; // } unsigned char GetLevel() const { // return b0%8; return bl; } fscal GetQp() const { return b1; } fscal GetChi2() const { // float x = (b0>>3)*3.5/31.; // return x*x; return chi2double; } fscal GetQpOrig(){ return b1; } int GetLSta() const { return st>>4; } int GetMSta() const { return ((st%16)>>2) + GetLSta() + 1; } int GetRSta() const { return (st%4) + GetLSta() + 2; } }; #endif