#include "hmetamatch2.h"
#include "TMath.h"
#include "TBuffer.h"
using namespace std;
HMetaMatch2::HMetaMatch2() {
sector = -1;
trkCandInd = -1;
ownIndex = -1;
setDefForRest();
}
HMetaMatch2::HMetaMatch2(Short_t sec, Int_t tkInd, Int_t ind) {
sector = sec;
trkCandInd = tkInd;
ownIndex = ind;
setDefForRest();
}
void HMetaMatch2::setDefForRest(void) {
nRichId = 0;
nRichIPUId = 0;
nRpcClust = 0;
nShrHits = 0;
nTofHits = 0;
for(Int_t i = 0; i < META_TAB_SIZE; i++) {
rpcClstInd[i] = -1;
shrHitInd[i] = -1;
tofClstInd[i] = -1;
tofHit1Ind[i] = -1;
tofHit2Ind[i] = -1;
rpcQuality[i] = 0.f;
rpcDX[i] = 0.f;
rpcDY[i] = 0.f;
shrQuality[i] = 0.f;
shrDX[i] = 0.f;
shrDY[i] = 0.f;
tofClstQuality[i] = 0.f;
tofClstDX[i] = 0.f;
tofClstDY[i] = 0.f;
tofHit1Quality[i] = 0.f;
tofHit1DX[i] = 0.f;
tofHit1DY[i] = 0.f;
tofHit2Quality[i] = 0.f;
tofHit2DX[i] = 0.f;
tofHit2DY[i] = 0.f;
rkIndShower[i] = -1;
rkIndTofCl[i] = -1;
rkIndTof1[i] = -1;
rkIndTof2[i] = -1;
rkIndRpc[i] = -1;
kfIndShower[i] = -1;
kfIndTofCl[i] = -1;
kfIndTof1[i] = -1;
kfIndTof2[i] = -1;
kfIndRpc[i] = -1;
emcPath[i] = -1;
}
rungeKuttaInd = -1;
for(Int_t i = 0; i < RICH_TAB_SIZE; i++) {
richInd[i] = -1;
richIPUInd[i] = -1;
}
splineInd = -1;
kalmanFilterInd = -1;
flag = 0;
isFakeInner =kFALSE;
isFakeOuter =kFALSE;
}
void HMetaMatch2::setRpcClst(UChar_t el,Short_t ind,Float_t ql,Float_t dx,Float_t dy) {
if(el>nRpcClust) return;
rpcClstInd[el] = ind;
rpcQuality[el] = ql;
rpcDX[el] = dx;
rpcDY[el] = dy;
}
void HMetaMatch2::setShrHit(UChar_t el,Short_t ind,Float_t ql,Float_t dx,Float_t dy) {
if(el>nShrHits) return;
shrHitInd[el] = ind;
shrQuality[el] = ql;
shrDX[el] = dx;
shrDY[el] = dy;
}
void HMetaMatch2::setTofClst(UChar_t el,Short_t ind,Float_t ql,Float_t dx,Float_t dy) {
if(el>nTofHits) return;
tofClstInd[el] = ind;
tofClstQuality[el] = ql;
tofClstDX[el] = dx;
tofClstDY[el] = dy;
}
void HMetaMatch2::setTofHit1(UChar_t el,Short_t ind,Float_t ql,Float_t dx,Float_t dy) {
if(el>nTofHits) return;
tofHit1Ind[el] = ind;
tofHit1Quality[el] = ql;
tofHit1DX[el] = dx;
tofHit1DY[el] = dy;
}
void HMetaMatch2::setTofHit2(UChar_t el,Short_t ind,Float_t ql,Float_t dx,Float_t dy) {
if(el>nTofHits) return;
tofHit2Ind[el] = ind;
tofHit2Quality[el] = ql;
tofHit2DX[el] = dx;
tofHit2DY[el] = dy;
}
void HMetaMatch2::setRpcClstMMF(UChar_t nln,Short_t ind[],Float_t ql2[][3]) {
nRpcClust = nln<=META_TAB_SIZE ? nln : META_TAB_SIZE;
for(UChar_t l=0;l<nRpcClust;l++) {
rpcClstInd[l] = ind[l];
rpcQuality[l] = TMath::Sqrt(ql2[l][0]);
rpcDX[l] = ql2[l][1];
rpcDY[l] = ql2[l][2];
}
}
void HMetaMatch2::setShrHitMMF(UChar_t nln,Short_t ind[],Float_t ql2[][3]) {
nShrHits = nln<=META_TAB_SIZE ? nln : META_TAB_SIZE;
for(UChar_t l=0;l<nShrHits;l++) {
shrHitInd[l] = ind[l];
shrQuality[l] = TMath::Sqrt(ql2[l][0]);
shrDX[l] = ql2[l][1];
shrDY[l] = ql2[l][2];
}
}
void HMetaMatch2::setEmcClstMMF(UChar_t nln,Short_t ind[],Float_t ql2[][4]) {
setEmcClusterFlag();
nShrHits = nln<=META_TAB_SIZE ? nln : META_TAB_SIZE;
for(UChar_t l=0;l<nShrHits;l++) {
shrHitInd[l] = ind[l];
shrQuality[l] = TMath::Sqrt(ql2[l][0]);
shrDX[l] = ql2[l][1];
shrDY[l] = ql2[l][2];
emcPath[l] = ql2[l][3];
}
}
void HMetaMatch2::setTofClstMMF(UChar_t nln,Short_t ind[][3],Float_t ql2[][9]) {
nTofHits = nln<=META_TAB_SIZE ? nln : META_TAB_SIZE;
for(UChar_t l=0;l<nTofHits;l++) {
tofClstInd[l] = ind[l][0];
tofHit1Ind[l] = ind[l][1];
tofHit2Ind[l] = ind[l][2];
tofClstQuality[l] = TMath::Sqrt(ql2[l][0]);
tofClstDX[l] = ql2[l][1];
tofClstDY[l] = ql2[l][2];
tofHit1Quality[l] = TMath::Sqrt(ql2[l][3]);
tofHit1DX[l] = ql2[l][4];
tofHit1DY[l] = ql2[l][5];
tofHit2Quality[l] = TMath::Sqrt(ql2[l][6]);
tofHit2DX[l] = ql2[l][7];
tofHit2DY[l] = ql2[l][8];
}
}
Int_t HMetaMatch2::getSystem(void) const {
Int_t sys = nRpcClust>0 || nShrHits>0 ? 1 : 0;
if(nTofHits>0) sys |= 2;
return sys-1;
}
void HMetaMatch2::print(void) {
printf("HMetaMatch2: %i sector, index of trkCand=%i [index(quality)]\n",sector+1,trkCandInd);
if(nRpcClust>0) {
printf(" HRpcCluster's:");
for(UChar_t n=0;n<nRpcClust;n++) {
if(rpcClstInd[n]>=0) printf(" %i(%.3g)",rpcClstInd[n],rpcQuality[n]);
}
printf("\n");
}
if(nShrHits>0) {
printf(" HShowerHit's:");
for(UChar_t n=0;n<nShrHits;n++) {
if(shrHitInd[n]>=0) printf(" %i(%.3g)",shrHitInd[n],shrQuality[n]);
}
printf("\n");
}
if(nTofHits>0) {
for(UChar_t n=0;n<nTofHits;n++) {
if(tofClstInd[n]>=0) {
printf(" HTofCluster: %i(%.3g)",tofClstInd[n],tofClstQuality[n]);
if(tofHit1Ind[n]>=0) printf("/Hit1=%i(%.3g)",tofHit1Ind[n],tofHit1Quality[n]);
if(tofHit2Ind[n]>=0) printf("/Hit2=%i(%.3g)",tofHit2Ind[n],tofHit2Quality[n]);
printf("\n");
} else {
if(tofHit1Ind[n]>=0) printf(" HTofHit1: %i(%.3g)",tofHit1Ind[n],tofHit1Quality[n]);
if(tofHit2Ind[n]>=0) printf(" HTofHit2: %i(%.3g)",tofHit2Ind[n],tofHit2Quality[n]);
printf("\n");
}
}
}
if(nRichId>0) {
printf(" richHitInd =");
for(UChar_t n=0;n<nRichId;n++) printf(" %i",richInd[n]);
printf("\n");
}
if(nRichIPUId>0) {
printf(" richHitIPUInd =");
for(UChar_t n=0;n<nRichIPUId;n++) printf(" %i",richIPUInd[n]);
printf("\n");
}
if(splineInd>=0 || rungeKuttaInd>=0 || kalmanFilterInd>=0) {
printf(" Tracks:");
if(splineInd>=0) printf(" splineInd=%i",splineInd);
if(rungeKuttaInd>=0) printf(" rungeKuttaInd=%i",rungeKuttaInd);
if(kalmanFilterInd>=0) printf(" kalmanFilterInd=%i", kalmanFilterInd);
printf("\n");
} else printf(" No accepted tracks!\n");
}
void HMetaMatch2::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
TObject::Streamer(R__b);
R__b >> trkCandInd;
R__b >> ownIndex;
R__b >> sector;
R__b >> nRpcClust;
R__b >> nShrHits;
R__b >> nTofHits;
R__b >> rungeKuttaInd;
R__b.ReadStaticArray((short*)rkIndShower);
R__b.ReadStaticArray((short*)rkIndTofCl);
R__b.ReadStaticArray((short*)rkIndTof1);
R__b.ReadStaticArray((short*)rkIndTof2);
R__b.ReadStaticArray((short*)rkIndRpc);
R__b >> kalmanFilterInd;
R__b.ReadStaticArray((short*)kfIndShower);
R__b.ReadStaticArray((short*)kfIndTofCl);
R__b.ReadStaticArray((short*)kfIndTof1);
R__b.ReadStaticArray((short*)kfIndTof2);
R__b.ReadStaticArray((short*)kfIndRpc);
R__b.ReadStaticArray((short*)rpcClstInd);
R__b.ReadStaticArray((short*)shrHitInd);
R__b.ReadStaticArray((short*)tofClstInd);
R__b.ReadStaticArray((short*)tofHit1Ind);
R__b.ReadStaticArray((short*)tofHit2Ind);
R__b.ReadStaticArray((float*)rpcQuality);
R__b.ReadStaticArray((float*)rpcDX);
R__b.ReadStaticArray((float*)rpcDY);
R__b.ReadStaticArray((float*)shrQuality);
R__b.ReadStaticArray((float*)shrDX);
R__b.ReadStaticArray((float*)shrDY);
if(R__v>2) R__b.ReadStaticArray((float*)emcPath);
R__b.ReadStaticArray((float*)tofClstQuality);
R__b.ReadStaticArray((float*)tofClstDX);
R__b.ReadStaticArray((float*)tofClstDY);
R__b.ReadStaticArray((float*)tofHit1Quality);
R__b.ReadStaticArray((float*)tofHit1DX);
R__b.ReadStaticArray((float*)tofHit1DY);
R__b.ReadStaticArray((float*)tofHit2Quality);
R__b.ReadStaticArray((float*)tofHit2DX);
R__b.ReadStaticArray((float*)tofHit2DY);
R__b >> splineInd;
R__b >> nRichId;
R__b >> nRichIPUId;
R__b.ReadStaticArray((int*)richInd);
R__b.ReadStaticArray((int*)richIPUInd);
R__b >> flag;
R__b >> isFakeInner;
R__b >> isFakeOuter;
R__b.CheckByteCount(R__s, R__c, HMetaMatch2::IsA());
} else {
R__c = R__b.WriteVersion(HMetaMatch2::IsA(), kTRUE);
TObject::Streamer(R__b);
R__b << trkCandInd;
R__b << ownIndex;
R__b << sector;
R__b << nRpcClust;
R__b << nShrHits;
R__b << nTofHits;
R__b << rungeKuttaInd;
R__b.WriteArray(rkIndShower, 3);
R__b.WriteArray(rkIndTofCl, 3);
R__b.WriteArray(rkIndTof1, 3);
R__b.WriteArray(rkIndTof2, 3);
R__b.WriteArray(rkIndRpc, 3);
R__b << kalmanFilterInd;
R__b.WriteArray(kfIndShower, 3);
R__b.WriteArray(kfIndTofCl, 3);
R__b.WriteArray(kfIndTof1, 3);
R__b.WriteArray(kfIndTof2, 3);
R__b.WriteArray(kfIndRpc, 3);
R__b.WriteArray(rpcClstInd, 3);
R__b.WriteArray(shrHitInd, 3);
R__b.WriteArray(tofClstInd, 3);
R__b.WriteArray(tofHit1Ind, 3);
R__b.WriteArray(tofHit2Ind, 3);
R__b.WriteArray(rpcQuality, 3);
R__b.WriteArray(rpcDX, 3);
R__b.WriteArray(rpcDY, 3);
R__b.WriteArray(shrQuality, 3);
R__b.WriteArray(shrDX, 3);
R__b.WriteArray(shrDY, 3);
R__b.WriteArray(emcPath, 3);
R__b.WriteArray(tofClstQuality, 3);
R__b.WriteArray(tofClstDX, 3);
R__b.WriteArray(tofClstDY, 3);
R__b.WriteArray(tofHit1Quality, 3);
R__b.WriteArray(tofHit1DX, 3);
R__b.WriteArray(tofHit1DY, 3);
R__b.WriteArray(tofHit2Quality, 3);
R__b.WriteArray(tofHit2DX, 3);
R__b.WriteArray(tofHit2DY, 3);
R__b << splineInd;
R__b << nRichId;
R__b << nRichIPUId;
R__b.WriteArray(richInd, 3);
R__b.WriteArray(richIPUInd, 3);
R__b << flag;
R__b << isFakeInner;
R__b << isFakeOuter;
R__b.SetByteCount(R__c, kTRUE);
}
}
ClassImp(HMetaMatch2)