ROOT logo
#include "hkalmetamatcher.h"

#include "hades.h"
#include "hcategory.h"
#include "hcategorymanager.h"
#include "hgeomvector.h"
#include "hmetamatchpar.h"
#include "hmdcsizescells.h"
#include "hphysicsconstants.h"
#include "hrpccluster.h"
#include "hrpcgeompar.h"
#include "hruntimedb.h"
#include "hshowerhit.h"
#include "hemccluster.h"
#include "hshowergeometry.h"
#include "hemcgeompar.h"
#include "hspectrometer.h"
#include "htofgeompar.h"
#include "htofhit.h"

#include "rpcdef.h"
#include "showerdef.h"
#include "emcdef.h"
#include "tofdef.h"

#include "hkalmetamatch.h"

//_HADES_CLASS_DESCRIPTION
///////////////////////////////////////////////////////////////////////////////
//
//

ClassImp (HKalMetaMatcher)

//  -----------------------------------
//  Ctors and Dtor
//  -----------------------------------

HKalMetaMatcher::HKalMetaMatcher() {
    // Be sure to call the init() function after HADES has
    // been initialized.

    bIsMatched      = kFALSE;
    clearMatches();

    fCatRpcCluster  = NULL;
    fCatShower      = NULL;
    fCatEmcCluster  = NULL;
    fCatTofCluster  = NULL;
    fCatTof         = NULL;

    fMatchPar       = NULL;
    fRpcGeometry    = NULL;
    fShowerGeometry = NULL;
    fEmcGeometry    = NULL;
    fTofGeometry    = NULL;

    pKalsys         = NULL;
}

//  -----------------------------------
//  Protected Methods
//  -----------------------------------

void HKalMetaMatcher::getMetaRecoPos(Float_t &xReco, Float_t &yReco, Float_t &zReco) const {
    // Return the META hit coordinates expected by the Kalman filter in sector coordinates.

    if(!pKalsys) {
        Error("getRecoMetaPos()", "Pointer to track propagator not found. This is disaster.");
        return;
    }
    Double_t x,y,z = -1.; // Type compatibility.
    pKalsys->getMetaPos(x, y, z);
    xReco = x;
    yReco = y;
    zReco = z;
}

Float_t HKalMetaMatcher::getP() const {
    // Returns the reconstructed momentum.

    if(!pKalsys) {
        Error("getP()", "Pointer to track propagator not found. This is disaster.");
        return -1.F;
    }

    Float_t qp = pKalsys->getSite(0)->getStateParam(Kalman::kSmoothed, Kalman::kIdxQP);
    if(qp == 0.F) return 0.F;
    Float_t p  = 1.F / (qp * HPhysicsConstants::charge(pKalsys->getPid()));
    return p;
}

Float_t HKalMetaMatcher::getTrackLength() const {
    // Returns track length from the Kalman filter.

    if(!pKalsys) {
        Error("getTrackLength()", "Pointer to track propagator not found. This is disaster.");
        return -1.F;
    }

    return pKalsys->getTrackLength();
}

Bool_t HKalMetaMatcher::traceToMeta(const TVector3 &metaHit, const TVector3 &metaNorm) {
    if(!pKalsys) {
        Error("traceToMeta()", "Pointer to track propagator not found. This is disaster.");
        return kFALSE;
    }
#if metaDebug > 0
    if(metaNorm.Mag() == 0.) {
        Error("traceToMeta()", "Normal vector of meta detector has magnitude zero.");
        return kFALSE;
    }
#endif
    return pKalsys->traceToMeta(metaHit, metaNorm);
}

//  -----------------------------------
//  Public Methods
//  -----------------------------------

void HKalMetaMatcher::clearMatches() {
    for(Int_t tab = 0; tab < nMetaTabs; tab++) {
        matchesRpc   [tab].clear();
        matchesShower[tab].clear();
        matchesEmc   [tab].clear();
        matchesRpc   [tab].setSystem(0);
        matchesShower[tab].setSystem(1);
        matchesEmc   [tab].setSystem(3);
        for(Int_t clstr = 0; clstr < tofClusterSize; clstr++) {
            matchesTof[tab][clstr].clear();
            matchesTof[tab][clstr].setSystem(2);
        }
    }
}

void HKalMetaMatcher::init() {
    // Get categories and coordinate transformations.
    // Call this after HADES has been initialized.

    if(!gHades) {
        Error("init()", "HADES not initialized.");
        return;
    }

    HRuntimeDb *rtdb=gHades->getRuntimeDb();

    if(!rtdb) {
        Error("init()", "HADES runtime database not found.");
        return;
    }

    fMatchPar       = (HMetaMatchPar*)rtdb->getContainer("MetaMatchPar");
    
    fCatRpcCluster  = HCategoryManager::getCategory(catRpcCluster);
    fCatShower      = HCategoryManager::getCategory(catShowerHit);
    fCatEmcCluster  = HCategoryManager::getCategory(catEmcCluster);
    fCatTofCluster  = HCategoryManager::getCategory(catTofCluster);
    fCatTof         = HCategoryManager::getCategory(catTof);

    if(!fCatShower && !fCatEmcCluster) Warning("init()", "Category catShower and catEmcCluster not found.");
    if(!fCatRpcCluster) Warning("init()", "Category catRpcCluster not found.");
    if(!fCatTofCluster) Warning("init()", "Category catTofCluster not found.");
    if(!fCatTof)        Warning("init()", "Category catTof not found.");

    HSpectrometer *spec = gHades->getSetup();

    if(spec->getDetector("Rpc")) {
        fRpcGeometry   = (HRpcGeomPar*)rtdb->getContainer("RpcGeomPar");
    }

    // Shower-geometry-for-metaEnergy loss calculation
    if(spec->getDetector("Shower")) {
        fShowerGeometry = (HShowerGeometry *)rtdb->getContainer("ShowerGeometry");
    } else if (spec->getDetector("Emc")) {
    // Emc-geometry
      fEmcGeometry = (HEmcGeomPar *)rtdb->getContainer("EmcGeomPar");
    }
     
    // TOF-geometry-for-metaEnergy loss calculation
    if(spec->getDetector("Tof")) { // has the user set up a TOF?
        fTofGeometry = (HTofGeomPar *)rtdb->getContainer("TofGeomPar");
    }

}

void HKalMetaMatcher::reinit() {

    HMdcSizesCells *fSizesCells = HMdcSizesCells::getExObject();  // check if is already there
    if(!fSizesCells) {
	fSizesCells = HMdcSizesCells::getObject();
	fSizesCells->initContainer();
    }

    // Geometry transformation from lab to sector coordinate system.
    for(Int_t i = 0; i < 6; i++) {
        HMdcSizesCellsSec& fSCSec = (*fSizesCells)[i];
        if(&fSCSec == 0) continue; // sector is not active
        labSecTrans[i] = *(fSCSec.getLabTrans());
    }

    for(Int_t iSec = 0; iSec < 6; iSec++) {
        if(fRpcGeometry) {
            HModGeomPar *module = fRpcGeometry->getModule(iSec,0);
            if(module) {
                // Transformation moudule->lab.
                HGeomTransform modTrans(module->getLabTransform());
                // Combine with transformation lab->sector
                // to get the transformation from module to sector.
                modTrans.transTo(labSecTrans[iSec]);

                modSecTransRpc[iSec] = modTrans;

                // Centre point.
                HGeomVector r0_mod(0.0, 0.0, 0.0);
                // Normal vector.
                HGeomVector rz_mod(0.0, 0.0, 1.0);
                HGeomVector nRpc = modTrans.transFrom(rz_mod) - modTrans.transFrom(r0_mod);
                normVecRpc[iSec].SetXYZ(nRpc.getX(), nRpc.getY(), nRpc.getZ());
            }
        }

        if (fShowerGeometry) {
            HGeomTransform modTrans(fShowerGeometry->getTransform(iSec));
            modTrans.transTo(labSecTrans[iSec]);

            modSecTransShower[iSec] = modTrans;

            HGeomVector r0_mod(0.0, 0.0, 0.);
            HGeomVector rz_mod(0.0, 0.0, 1.);
            HGeomVector nShower = modTrans.transFrom(rz_mod) - modTrans.transFrom(r0_mod);
            normVecShower[iSec].SetXYZ(nShower.getX(), nShower.getY(), nShower.getZ());
        }

        if (fEmcGeometry) {
          HModGeomPar *pmodgeom = fEmcGeometry->getModule(iSec);
          HGeomTransform modTrans(pmodgeom->getLabTransform());

          modTrans.transTo(labSecTrans[iSec]);

          modSecTransEmc[iSec] = modTrans;

          HGeomVector r0_mod(0.0, 0.0, 0.);
          HGeomVector rz_mod(0.0, 0.0, 1.);
          HGeomVector nEmc = modTrans.transFrom(rz_mod) - modTrans.transFrom(r0_mod);
          normVecEmc[iSec].SetXYZ(nEmc.getX(), nEmc.getY(), nEmc.getZ()) ;
        }
    
        if (fTofGeometry) {
            for(Int_t iTofMod = 0; iTofMod < 8; iTofMod++) {
                HModGeomPar *module = fTofGeometry->getModule(iSec,iTofMod);
                if(module) {
                    HGeomTransform modTrans(module->getLabTransform());
                    modTrans.transTo(labSecTrans[iSec]);

                    modSecTransTof[iSec][iTofMod] = modTrans;

                    HGeomVector r0_mod(0.0, 0.0, 0.0);
                    HGeomVector rz_mod(0.0, 0.0, 1.0);
                    HGeomVector nTof = modTrans.transFrom(rz_mod) - modTrans.transFrom(r0_mod);
                    normVecTof[iSec][iTofMod].SetXYZ(nTof.getX(), nTof.getY(), nTof.getZ());
                }
            }
        }
    }
}

Bool_t HKalMetaMatcher::matchWithMeta(const HMetaMatch2 *pMetaMatch, HKalIFilt* const kalsys) {

#if metaDebug > 1
    cout<<"***** Matching with Meta. *****"<<endl;
    cout<<"System "<<pMetaMatch->getSystem()<<" with "
        <<(Int_t)pMetaMatch->getNRpcClusters()<<" Rpc clusters, "
        <<(Int_t)pMetaMatch->getNShrHits()<<" Shower hits or "
        <<(Int_t)pMetaMatch->getNEmcClusters()<<" Emc Clusters and "
        <<(Int_t)pMetaMatch->getNTofHits()<<" Tof hits"<<endl;
#endif
    clearMatches();
    pKalsys = kalsys;
    bIsMatched = kFALSE;
    if(pMetaMatch->getSystem() == -1) return kFALSE;

    if(pMetaMatch->getNRpcClusters()) {
        bIsMatched = kTRUE;
        matchWithRpc(pMetaMatch);
    }

    if(fCatShower != NULL) {
      if(pMetaMatch->getNShrHits() > 0) {
          bIsMatched = kTRUE;
          matchWithShower(pMetaMatch);
      }
    } else {
      if(pMetaMatch->getNEmcClusters() > 0) {
          bIsMatched = kTRUE;
          matchWithEmc(pMetaMatch);
      }
    }

    if(pMetaMatch->getNTofHits()) {
        bIsMatched = kTRUE;
        matchWithTof(pMetaMatch);
    }

#if metaDebug > 1
    cout<<"***** Done matching with Meta. *****"<<endl;
#endif
    return bIsMatched;
}

void HKalMetaMatcher::matchWithRpc(HMetaMatch2 const* const pMetaMatch) {

    for(Int_t n = 0; n < (Int_t)pMetaMatch->getNRpcClusters(); ++n) {
        Int_t ind = (Int_t)pMetaMatch->getRpcClstInd(n);
        if(ind < 0) {
            Warning("matchWithRpc()","RPC cluster index is < 0, DISASTER!"); // Anar
            continue;
        }

        if(!fCatRpcCluster) continue;

        HRpcCluster *pRpc = (HRpcCluster*)fCatRpcCluster->getObject(ind);
        if(!pRpc) {
            Warning("matchWithRpc()","Pointer to Rpc is NULL, DISASTER!");
            continue;
        }

        Int_t s = (Int_t)pMetaMatch->getSector();
        if(s < 0 || s > 5) {
#if metaDebug > 0
            Warning("matchWithRpc()", Form("Sector in HRpcHit is %i.", s));
#endif
            continue;
        }

        matchesRpc[n].setIndex(ind);
        matchesRpc[n].setTof(pRpc->getTof());
        matchesRpc[n].setMetaEloss(pRpc->getCharge());

        matchesRpc[n].setMetaHit(pRpc->getXSec(), pRpc->getYSec(), pRpc->getZSec());

#if metaDebug > 1
        cout<<"---- Matching with Rpc cluster "<<n<<" ----"<<endl;
#endif

        traceToMeta(matchesRpc[n].getMetaHit(), normVecRpc[s]);

        // Matching quality.
        // -----------------
        // Propagate track to META.
        Float_t xReco, yReco, zReco;
        getMetaRecoPos(xReco, yReco, zReco);
        matchesRpc[n].setMetaReco(xReco, yReco, zReco);
        // Transform to module coordinates to determine matching quality.
        HGeomVector localMetaReco(xReco, yReco, zReco);
        localMetaReco = modSecTransRpc[s].transTo(localMetaReco);
        matchesRpc[n].setMetaHitLocal(pRpc->getXMod(), pRpc->getYMod(), pRpc->getZMod());
        matchesRpc[n].setMetaRecoLocal(localMetaReco.getX(), localMetaReco.getY(), localMetaReco.getZ());

#if metaDebug > 2
        cout<<"Meta hit in sector coords: \n"
            <<"  x = "<<matchesRpc[n].getMetaHit().X()
            <<", y = "<<matchesRpc[n].getMetaHit().Y()
            <<", z = "<<matchesRpc[n].getMetaHit().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<pRpc->getXMod()<<", y = "<<pRpc->getYMod()
            <<endl;
        cout<<"Reconstructed meta hit in sector coords: \n"
            <<"  x = "<<xReco<<", y = "<<yReco<<", z = "<< zReco
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaReco.getX()<<", y = "<<localMetaReco.getY()
            <<"\n"<<endl;
#endif

        //? why subtract SigmaOffset?
        Float_t dX     = localMetaReco.getX() - pRpc->getXMod() - fMatchPar->getRpcSigmaXOffset(s);
        Float_t dY     = localMetaReco.getY() - pRpc->getYMod() - fMatchPar->getRpcSigmaYOffset(s);
        // HRpcHit->getXRMS() returns sigma of X.
        //? why add two sigmas
        Float_t dXsig2 =  TMath::Power(pRpc->getXRMS(), 2.F) + TMath::Power(fMatchPar->getRpcSigmaXMdc(s), 2.F);
        Float_t dYsig2 =  TMath::Power(pRpc->getYRMS(), 2.F) + TMath::Power(fMatchPar->getRpcSigmaYMdc(s), 2.F);
        matchesRpc[n].setQuality(calcQuality(dX, dY, dXsig2, dYsig2));
        // -----------------

        // beta and mass^2.
        Float_t length = getTrackLength();
        Float_t time   = matchesRpc[n].getTof();
        Float_t beta   = 1.0e6 * (length / time) / TMath::C();
        matchesRpc[n].setBeta(beta);

        Float_t beta2  = TMath::Power(beta, 2.F);
        Float_t p      = getP();
        Float_t mass2  = p * p * (1.F / beta2 - 1.F);
        matchesRpc[n].setMass2(mass2);
    }
}

void HKalMetaMatcher::matchWithShower(HMetaMatch2 const* const pMetaMatch) {

    for(Int_t n = 0; n < (Int_t)pMetaMatch->getNShrHits(); ++n) {
        Int_t ind = (Int_t)pMetaMatch->getShowerHitInd(n);

        if(ind < 0) {
            Warning("matchWithShower()","Index of shower is < 0, DISASTER!");
            continue;
        }

        if(!fCatShower) continue;

        HShowerHit *pShowerHit = (HShowerHit*)fCatShower->getObject(ind);

        if(!pShowerHit) {
            Warning("matchWithShower()","Pointer to Shower is NULL, DISASTER!");
            continue;
        }

        Int_t s = (Int_t)pMetaMatch->getSector();
        if(s < 0 || s > 5) {
#if metaDebug > 0
            Warning("matchWithShower()", Form("Sector in HShowerHit is %i.", s));
#endif
            continue;
        }

#if metaDebug > 1
        cout<<"---- Matching with Shower hit "<<n<<" ----"<<endl;
#endif

        matchesShower[n].setIndex(ind);

        // Store shower hit in sector coordinates.
        Float_t xTof, yTof, zTof;
        pShowerHit->getLabXYZ(&xTof, &yTof, &zTof);
        HGeomVector metaHit(xTof, yTof, zTof);

        metaHit = labSecTrans[s].transTo(metaHit);
        matchesShower[n].setMetaHit(metaHit.getX(), metaHit.getY(), metaHit.getZ());

        // Matching quality.
        // -----------------

        // Propagate track to META.
        traceToMeta(matchesShower[n].getMetaHit(), normVecShower[s]);

        Float_t xReco, yReco, zReco;
        getMetaRecoPos(xReco, yReco, zReco);
        matchesShower[n].setMetaReco(xReco, yReco, zReco);

        // Transform to module coordinates to determine matching quality.
        HGeomVector localMetaReco(xReco, yReco, zReco);
        localMetaReco = modSecTransShower[s].transTo(localMetaReco);
        matchesShower[n].setMetaRecoLocal(localMetaReco.getX(), localMetaReco.getY(), localMetaReco.getZ());

        Float_t xHit, yHit, zHit;
        matchesShower[n].getMetaHit(xHit, yHit, zHit);
        HGeomVector localMetaHit(xHit, yHit, zHit);
        localMetaHit  = modSecTransShower[s].transTo(localMetaHit);
        //?
        localMetaHit -= HGeomVector(0., 0., pShowerHit->getZ());
        matchesShower[n].setMetaHitLocal(localMetaHit.getX(), localMetaHit.getY(), localMetaHit.getZ());

#if metaDebug > 2
        cout<<"Meta hit in sector coords: \n"
            <<"  x = "<<matchesShower[n].getMetaHit().X()
            <<", y = "<<matchesShower[n].getMetaHit().Y()
            <<", z = "<<matchesShower[n].getMetaHit().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaHit.getX()<<", y = "<<localMetaHit.getY()
            <<endl;
        cout<<"Reconstructed meta hit in sector coords: \n"
            <<"  x = "<<matchesShower[n].getMetaReco().X()
            <<", y = "<<matchesShower[n].getMetaReco().Y()
            <<", z = "<<matchesShower[n].getMetaReco().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaReco.getX()<<", y = "<<localMetaReco.getY()
            <<"\n"<<endl;
#endif

        //? why subtract SigmaOffset?
        Float_t dX     = localMetaReco.getX() - localMetaHit.getX() - fMatchPar->getShowerSigmaXOffset(s);
        Float_t dY     = localMetaReco.getY() - localMetaHit.getY() - fMatchPar->getShowerSigmaYOffset(s);
        Float_t dXsig2 = TMath::Power(pShowerHit->getSigmaX(), 2.F);
        Float_t dYsig2 = TMath::Power(pShowerHit->getSigmaY(), 2.F);
        matchesShower[n].setQuality(calcQuality(dX, dY, dXsig2, dYsig2));
        // -----------------
    }
}

void HKalMetaMatcher::matchWithEmc(HMetaMatch2 const* const pMetaMatch) {

    if(!fCatEmcCluster) return;
    
    for(Int_t n = 0; n < (Int_t)pMetaMatch->getNEmcClusters(); ++n) {
        Int_t ind = (Int_t)pMetaMatch->getEmcClusterInd(n);

        if(ind < 0) {
            Warning("matchWithEmc()","Index of emc is < 0, DISASTER!");
            continue;
        }

        HEmcCluster *pEmcCluster = (HEmcCluster*)fCatEmcCluster->getObject(ind);

        if(!pEmcCluster) {
            Warning("matchWithEmc()","Pointer to EmcCluster is NULL, DISASTER!");
            continue;
        }

        Int_t s = (Int_t)pMetaMatch->getSector();
        if(s < 0 || s > 5) {
#if metaDebug > 0
            Warning("matchWithEmc()", Form("Sector in HEmcCluster is %i.", s));
#endif
            continue;
        }

#if metaDebug > 1
        cout<<"---- Matching with Emc hit "<<n<<" ----"<<endl;
#endif

        matchesEmc[n].setIndex(ind);
        matchesEmc[n].setTof(pEmcCluster->getTime());
        matchesEmc[n].setMetaEloss(pEmcCluster->getEnergy());

        // Store emc hit in sector coordinates.
        HGeomVector metaHit(pEmcCluster->getXLab(), pEmcCluster->getYLab(), pEmcCluster->getZLab());

        metaHit = labSecTrans[s].transTo(metaHit);
        matchesEmc[n].setMetaHit(metaHit.getX(), metaHit.getY(), metaHit.getZ());

        // Matching quality.
        // -----------------

        // Propagate track to META.
        traceToMeta(matchesEmc[n].getMetaHit(), normVecEmc[s]);

        Float_t xReco, yReco, zReco;
        getMetaRecoPos(xReco, yReco, zReco);
        matchesEmc[n].setMetaReco(xReco, yReco, zReco);

        // Transform to module coordinates to determine matching quality.
        HGeomVector localMetaReco(xReco, yReco, zReco);
        localMetaReco = modSecTransEmc[s].transTo(localMetaReco);
        matchesEmc[n].setMetaRecoLocal(localMetaReco.getX(), localMetaReco.getY(), localMetaReco.getZ());

        Float_t xHit, yHit, zHit;
        matchesEmc[n].getMetaHit(xHit, yHit, zHit);
        HGeomVector localMetaHit(xHit, yHit, zHit);
        localMetaHit  = modSecTransEmc[s].transTo(localMetaHit);
        //?
        //localMetaHit -= HGeomVector(0., 0., pEmcCluster->getZ());
        matchesEmc[n].setMetaHitLocal(localMetaHit.getX(), localMetaHit.getY(), localMetaHit.getZ());

#if metaDebug > 2
        cout<<"Meta hit in sector coords: \n"
            <<"  x = "<<matchesEmc[n].getMetaHit().X()
            <<", y = "<<matchesEmc[n].getMetaHit().Y()
            <<", z = "<<matchesEmc[n].getMetaHit().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaHit.getX()<<", y = "<<localMetaHit.getY()
            <<endl;
        cout<<"Reconstructed meta hit in sector coords: \n"
            <<"  x = "<<matchesEmc[n].getMetaReco().X()
            <<", y = "<<matchesEmc[n].getMetaReco().Y()
            <<", z = "<<matchesEmc[n].getMetaReco().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaReco.getX()<<", y = "<<localMetaReco.getY()
            <<"\n"<<endl;
#endif

        //? why subtract SigmaOffset?
        Float_t dX     = localMetaReco.getX() - localMetaHit.getX() - fMatchPar->getEmcSigmaXOffset(s);
        Float_t dY     = localMetaReco.getY() - localMetaHit.getY() - fMatchPar->getEmcSigmaYOffset(s);
        Float_t dXsig2 = TMath::Power(pEmcCluster->getSigmaXMod(), 2.F);
        Float_t dYsig2 = TMath::Power(pEmcCluster->getSigmaYMod(), 2.F);
        matchesEmc[n].setQuality(calcQuality(dX, dY, dXsig2, dYsig2));
        // -----------------
    }
}

void HKalMetaMatcher::matchWithTof(HMetaMatch2 const* const pMetaMatch) {
    for(Int_t n = 0; n < (Int_t)pMetaMatch->getNTofHits(); ++n) {
        // A TOF cluster may consist of up to two hits from different
        // scintillator rods. Match the individual hits and the cluster
        // separately.
        for(Int_t i = 0; i < tofClusterSize; ++i ) {

            Int_t ind = -1;
            if(i == 0) ind = (Int_t)pMetaMatch->getTofHit1Ind(n);
            if(i == 1) ind = (Int_t)pMetaMatch->getTofHit2Ind(n);
            if(i == 2) ind = (Int_t)pMetaMatch->getTofClstInd(n);

            if(ind < 0) continue;

            HTofHit *pTofHit = NULL;

            if(i == 2) {
                if(!fCatTofCluster) continue;
                pTofHit = (HTofHit*)fCatTofCluster->getObject(ind);
            } else {
                if(!fCatTof) continue;
                pTofHit = (HTofHit*)fCatTof->getObject(ind);
            }

            if(!pTofHit) {
                Warning("matchWithTof()", "Pointer to Tof is NULL, DISASTER!");
                continue;
            }

            Int_t s      = (Int_t)pTofHit->getSector();
            if(s < 0 || s > 5) {
#if metaDebug > 0
                Warning("matchWithTof()", Form("Sector in HTofHit is %i.", s));
#endif
                continue;
            }

#if metaDebug > 1
            cout<<"---- Matching with Tof cluster "<<n<<", hit "<<i<<"----"<<endl;
#endif

            matchesTof[n][i].setIndex(ind);
            matchesTof[n][i].setTof(pTofHit->getTof());
            matchesTof[n][i].setMetaEloss(pTofHit->getEdep());

            Float_t xTof, yTof, zTof;
            pTofHit->getXYZLab(xTof, yTof, zTof);
            HGeomVector hitMeta(xTof, yTof, zTof);
            hitMeta = labSecTrans[s].transTo(hitMeta);
            matchesTof[n][i].setMetaHit(hitMeta.getX(), hitMeta.getY(), hitMeta.getZ());

            // Propagate track to META.
            Int_t tofMod = (Int_t)pTofHit->getModule();
            traceToMeta(matchesTof[n][i].getMetaHit(), normVecTof[s][tofMod]);

            Float_t xReco, yReco, zReco;
            getMetaRecoPos(xReco, yReco, zReco);
            matchesTof[n][i].setMetaReco(xReco, yReco, zReco);
            // Transform to module coordinates to determine matching quality.
            HGeomVector localMetaReco(xReco, yReco, zReco);
            localMetaReco = modSecTransTof[s][tofMod].transTo(localMetaReco);
            matchesTof[n][i].setMetaRecoLocal(localMetaReco.getX(), localMetaReco.getY(), localMetaReco.getZ());

            Float_t xHit, yHit, zHit;
            matchesTof[n][i].getMetaHit(xHit, yHit, zHit);
            HGeomVector localMetaHit(xHit, yHit, zHit);
            localMetaHit  = modSecTransTof[s][tofMod].transTo(localMetaHit);
            matchesTof[n][i].setMetaHitLocal(localMetaHit.getX(), localMetaHit.getY(), localMetaHit.getZ());

#if metaDebug > 2
        cout<<"Meta hit in sector coords: \n"
            <<"  x = "<<matchesTof[n][i].getMetaHit().X()
            <<", y = "<<matchesTof[n][i].getMetaHit().Y()
            <<", z = "<<matchesTof[n][i].getMetaHit().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaHit.getX()<<", y = "<<localMetaHit.getY()
            <<endl;
        cout<<"Reconstructed meta hit in sector coords: \n"
            <<"  x = "<<matchesTof[n][i].getMetaReco().X()
            <<", y = "<<matchesTof[n][i].getMetaReco().Y()
            <<", z = "<<matchesTof[n][i].getMetaReco().Z()
            <<"\n in module coords: \n"
            <<"  x = "<<localMetaReco.getX()<<", y = "<<localMetaReco.getY()
            <<"\n"<<endl;
#endif

            // Matching quality.
            Float_t dX     = localMetaReco.getX() - localMetaHit.getX() - fMatchPar->getTofSigmaXOffset(s);
            Float_t dY     = localMetaReco.getY() - localMetaHit.getY() - fMatchPar->getTofSigmaYOffset(s);
            Float_t dXsig2 = TMath::Power(fMatchPar->getTofSigmaX(s), 2.F);
            Float_t dYsig2 = TMath::Power(fMatchPar->getTofSigmaY(s), 2.F);
            matchesTof[n][i].setQuality(calcQuality(dX, dY, dXsig2, dYsig2));

            // beta and mass^2.
            Float_t length = getTrackLength();
            Float_t time   = matchesTof[n][i].getTof();
            Float_t beta   = 1.0e6 * (length / time) / TMath::C();
            matchesTof[n][i].setBeta(beta);

            Float_t beta2  = TMath::Power(beta, 2.F);
            Float_t p      = getP();
            Float_t mass2  = p * p * (1.F / beta2 - 1.F);
            matchesTof[n][i].setMass2(mass2);
        }
    }
}

Int_t HKalMetaMatcher::getClstrSize(Int_t sys) const {

    if(sys == 0 || sys == 1 || sys == 3) return 1; // Rpc or Shower or Emc
    if(sys == 2) return tofClusterSize; // Tof
    return 0; // Unknown.
}

const HKalMetaMatch& HKalMetaMatcher::getMatch(Int_t sys, Int_t tab, Int_t clstr) const {

    if(tab > (nMetaTabs - 1) || tab < 0) {
        Error("getMatch()", Form("Invalid tab parameter: %i. Must be between 0 and %i.", tab, nMetaTabs));
        return matchesRpc[0];
    }

    switch (sys) {
    case 0:
        return matchesRpc[tab];
        break;
    case 1:
        return matchesShower[tab];
        break;
    case 2:
        if(clstr >= 0 && clstr < tofClusterSize) {
            return matchesTof[tab][clstr];
        } else {
            Error("getMatch()", Form("Invalid Tof cluster: %i", clstr));
            return matchesRpc[0];
        }
        break;
    case 3:
        return matchesEmc[tab];
        break;
    default:
        Error("getMatch()", Form("Invalid Meta detector: %i", sys));
        return matchesRpc[0];
        break;
    }
    Error("getMatch()", Form("Invalid Meta detector: %i", sys));
    return matchesRpc[0];
}
 hkalmetamatcher.cc:1
 hkalmetamatcher.cc:2
 hkalmetamatcher.cc:3
 hkalmetamatcher.cc:4
 hkalmetamatcher.cc:5
 hkalmetamatcher.cc:6
 hkalmetamatcher.cc:7
 hkalmetamatcher.cc:8
 hkalmetamatcher.cc:9
 hkalmetamatcher.cc:10
 hkalmetamatcher.cc:11
 hkalmetamatcher.cc:12
 hkalmetamatcher.cc:13
 hkalmetamatcher.cc:14
 hkalmetamatcher.cc:15
 hkalmetamatcher.cc:16
 hkalmetamatcher.cc:17
 hkalmetamatcher.cc:18
 hkalmetamatcher.cc:19
 hkalmetamatcher.cc:20
 hkalmetamatcher.cc:21
 hkalmetamatcher.cc:22
 hkalmetamatcher.cc:23
 hkalmetamatcher.cc:24
 hkalmetamatcher.cc:25
 hkalmetamatcher.cc:26
 hkalmetamatcher.cc:27
 hkalmetamatcher.cc:28
 hkalmetamatcher.cc:29
 hkalmetamatcher.cc:30
 hkalmetamatcher.cc:31
 hkalmetamatcher.cc:32
 hkalmetamatcher.cc:33
 hkalmetamatcher.cc:34
 hkalmetamatcher.cc:35
 hkalmetamatcher.cc:36
 hkalmetamatcher.cc:37
 hkalmetamatcher.cc:38
 hkalmetamatcher.cc:39
 hkalmetamatcher.cc:40
 hkalmetamatcher.cc:41
 hkalmetamatcher.cc:42
 hkalmetamatcher.cc:43
 hkalmetamatcher.cc:44
 hkalmetamatcher.cc:45
 hkalmetamatcher.cc:46
 hkalmetamatcher.cc:47
 hkalmetamatcher.cc:48
 hkalmetamatcher.cc:49
 hkalmetamatcher.cc:50
 hkalmetamatcher.cc:51
 hkalmetamatcher.cc:52
 hkalmetamatcher.cc:53
 hkalmetamatcher.cc:54
 hkalmetamatcher.cc:55
 hkalmetamatcher.cc:56
 hkalmetamatcher.cc:57
 hkalmetamatcher.cc:58
 hkalmetamatcher.cc:59
 hkalmetamatcher.cc:60
 hkalmetamatcher.cc:61
 hkalmetamatcher.cc:62
 hkalmetamatcher.cc:63
 hkalmetamatcher.cc:64
 hkalmetamatcher.cc:65
 hkalmetamatcher.cc:66
 hkalmetamatcher.cc:67
 hkalmetamatcher.cc:68
 hkalmetamatcher.cc:69
 hkalmetamatcher.cc:70
 hkalmetamatcher.cc:71
 hkalmetamatcher.cc:72
 hkalmetamatcher.cc:73
 hkalmetamatcher.cc:74
 hkalmetamatcher.cc:75
 hkalmetamatcher.cc:76
 hkalmetamatcher.cc:77
 hkalmetamatcher.cc:78
 hkalmetamatcher.cc:79
 hkalmetamatcher.cc:80
 hkalmetamatcher.cc:81
 hkalmetamatcher.cc:82
 hkalmetamatcher.cc:83
 hkalmetamatcher.cc:84
 hkalmetamatcher.cc:85
 hkalmetamatcher.cc:86
 hkalmetamatcher.cc:87
 hkalmetamatcher.cc:88
 hkalmetamatcher.cc:89
 hkalmetamatcher.cc:90
 hkalmetamatcher.cc:91
 hkalmetamatcher.cc:92
 hkalmetamatcher.cc:93
 hkalmetamatcher.cc:94
 hkalmetamatcher.cc:95
 hkalmetamatcher.cc:96
 hkalmetamatcher.cc:97
 hkalmetamatcher.cc:98
 hkalmetamatcher.cc:99
 hkalmetamatcher.cc:100
 hkalmetamatcher.cc:101
 hkalmetamatcher.cc:102
 hkalmetamatcher.cc:103
 hkalmetamatcher.cc:104
 hkalmetamatcher.cc:105
 hkalmetamatcher.cc:106
 hkalmetamatcher.cc:107
 hkalmetamatcher.cc:108
 hkalmetamatcher.cc:109
 hkalmetamatcher.cc:110
 hkalmetamatcher.cc:111
 hkalmetamatcher.cc:112
 hkalmetamatcher.cc:113
 hkalmetamatcher.cc:114
 hkalmetamatcher.cc:115
 hkalmetamatcher.cc:116
 hkalmetamatcher.cc:117
 hkalmetamatcher.cc:118
 hkalmetamatcher.cc:119
 hkalmetamatcher.cc:120
 hkalmetamatcher.cc:121
 hkalmetamatcher.cc:122
 hkalmetamatcher.cc:123
 hkalmetamatcher.cc:124
 hkalmetamatcher.cc:125
 hkalmetamatcher.cc:126
 hkalmetamatcher.cc:127
 hkalmetamatcher.cc:128
 hkalmetamatcher.cc:129
 hkalmetamatcher.cc:130
 hkalmetamatcher.cc:131
 hkalmetamatcher.cc:132
 hkalmetamatcher.cc:133
 hkalmetamatcher.cc:134
 hkalmetamatcher.cc:135
 hkalmetamatcher.cc:136
 hkalmetamatcher.cc:137
 hkalmetamatcher.cc:138
 hkalmetamatcher.cc:139
 hkalmetamatcher.cc:140
 hkalmetamatcher.cc:141
 hkalmetamatcher.cc:142
 hkalmetamatcher.cc:143
 hkalmetamatcher.cc:144
 hkalmetamatcher.cc:145
 hkalmetamatcher.cc:146
 hkalmetamatcher.cc:147
 hkalmetamatcher.cc:148
 hkalmetamatcher.cc:149
 hkalmetamatcher.cc:150
 hkalmetamatcher.cc:151
 hkalmetamatcher.cc:152
 hkalmetamatcher.cc:153
 hkalmetamatcher.cc:154
 hkalmetamatcher.cc:155
 hkalmetamatcher.cc:156
 hkalmetamatcher.cc:157
 hkalmetamatcher.cc:158
 hkalmetamatcher.cc:159
 hkalmetamatcher.cc:160
 hkalmetamatcher.cc:161
 hkalmetamatcher.cc:162
 hkalmetamatcher.cc:163
 hkalmetamatcher.cc:164
 hkalmetamatcher.cc:165
 hkalmetamatcher.cc:166
 hkalmetamatcher.cc:167
 hkalmetamatcher.cc:168
 hkalmetamatcher.cc:169
 hkalmetamatcher.cc:170
 hkalmetamatcher.cc:171
 hkalmetamatcher.cc:172
 hkalmetamatcher.cc:173
 hkalmetamatcher.cc:174
 hkalmetamatcher.cc:175
 hkalmetamatcher.cc:176
 hkalmetamatcher.cc:177
 hkalmetamatcher.cc:178
 hkalmetamatcher.cc:179
 hkalmetamatcher.cc:180
 hkalmetamatcher.cc:181
 hkalmetamatcher.cc:182
 hkalmetamatcher.cc:183
 hkalmetamatcher.cc:184
 hkalmetamatcher.cc:185
 hkalmetamatcher.cc:186
 hkalmetamatcher.cc:187
 hkalmetamatcher.cc:188
 hkalmetamatcher.cc:189
 hkalmetamatcher.cc:190
 hkalmetamatcher.cc:191
 hkalmetamatcher.cc:192
 hkalmetamatcher.cc:193
 hkalmetamatcher.cc:194
 hkalmetamatcher.cc:195
 hkalmetamatcher.cc:196
 hkalmetamatcher.cc:197
 hkalmetamatcher.cc:198
 hkalmetamatcher.cc:199
 hkalmetamatcher.cc:200
 hkalmetamatcher.cc:201
 hkalmetamatcher.cc:202
 hkalmetamatcher.cc:203
 hkalmetamatcher.cc:204
 hkalmetamatcher.cc:205
 hkalmetamatcher.cc:206
 hkalmetamatcher.cc:207
 hkalmetamatcher.cc:208
 hkalmetamatcher.cc:209
 hkalmetamatcher.cc:210
 hkalmetamatcher.cc:211
 hkalmetamatcher.cc:212
 hkalmetamatcher.cc:213
 hkalmetamatcher.cc:214
 hkalmetamatcher.cc:215
 hkalmetamatcher.cc:216
 hkalmetamatcher.cc:217
 hkalmetamatcher.cc:218
 hkalmetamatcher.cc:219
 hkalmetamatcher.cc:220
 hkalmetamatcher.cc:221
 hkalmetamatcher.cc:222
 hkalmetamatcher.cc:223
 hkalmetamatcher.cc:224
 hkalmetamatcher.cc:225
 hkalmetamatcher.cc:226
 hkalmetamatcher.cc:227
 hkalmetamatcher.cc:228
 hkalmetamatcher.cc:229
 hkalmetamatcher.cc:230
 hkalmetamatcher.cc:231
 hkalmetamatcher.cc:232
 hkalmetamatcher.cc:233
 hkalmetamatcher.cc:234
 hkalmetamatcher.cc:235
 hkalmetamatcher.cc:236
 hkalmetamatcher.cc:237
 hkalmetamatcher.cc:238
 hkalmetamatcher.cc:239
 hkalmetamatcher.cc:240
 hkalmetamatcher.cc:241
 hkalmetamatcher.cc:242
 hkalmetamatcher.cc:243
 hkalmetamatcher.cc:244
 hkalmetamatcher.cc:245
 hkalmetamatcher.cc:246
 hkalmetamatcher.cc:247
 hkalmetamatcher.cc:248
 hkalmetamatcher.cc:249
 hkalmetamatcher.cc:250
 hkalmetamatcher.cc:251
 hkalmetamatcher.cc:252
 hkalmetamatcher.cc:253
 hkalmetamatcher.cc:254
 hkalmetamatcher.cc:255
 hkalmetamatcher.cc:256
 hkalmetamatcher.cc:257
 hkalmetamatcher.cc:258
 hkalmetamatcher.cc:259
 hkalmetamatcher.cc:260
 hkalmetamatcher.cc:261
 hkalmetamatcher.cc:262
 hkalmetamatcher.cc:263
 hkalmetamatcher.cc:264
 hkalmetamatcher.cc:265
 hkalmetamatcher.cc:266
 hkalmetamatcher.cc:267
 hkalmetamatcher.cc:268
 hkalmetamatcher.cc:269
 hkalmetamatcher.cc:270
 hkalmetamatcher.cc:271
 hkalmetamatcher.cc:272
 hkalmetamatcher.cc:273
 hkalmetamatcher.cc:274
 hkalmetamatcher.cc:275
 hkalmetamatcher.cc:276
 hkalmetamatcher.cc:277
 hkalmetamatcher.cc:278
 hkalmetamatcher.cc:279
 hkalmetamatcher.cc:280
 hkalmetamatcher.cc:281
 hkalmetamatcher.cc:282
 hkalmetamatcher.cc:283
 hkalmetamatcher.cc:284
 hkalmetamatcher.cc:285
 hkalmetamatcher.cc:286
 hkalmetamatcher.cc:287
 hkalmetamatcher.cc:288
 hkalmetamatcher.cc:289
 hkalmetamatcher.cc:290
 hkalmetamatcher.cc:291
 hkalmetamatcher.cc:292
 hkalmetamatcher.cc:293
 hkalmetamatcher.cc:294
 hkalmetamatcher.cc:295
 hkalmetamatcher.cc:296
 hkalmetamatcher.cc:297
 hkalmetamatcher.cc:298
 hkalmetamatcher.cc:299
 hkalmetamatcher.cc:300
 hkalmetamatcher.cc:301
 hkalmetamatcher.cc:302
 hkalmetamatcher.cc:303
 hkalmetamatcher.cc:304
 hkalmetamatcher.cc:305
 hkalmetamatcher.cc:306
 hkalmetamatcher.cc:307
 hkalmetamatcher.cc:308
 hkalmetamatcher.cc:309
 hkalmetamatcher.cc:310
 hkalmetamatcher.cc:311
 hkalmetamatcher.cc:312
 hkalmetamatcher.cc:313
 hkalmetamatcher.cc:314
 hkalmetamatcher.cc:315
 hkalmetamatcher.cc:316
 hkalmetamatcher.cc:317
 hkalmetamatcher.cc:318
 hkalmetamatcher.cc:319
 hkalmetamatcher.cc:320
 hkalmetamatcher.cc:321
 hkalmetamatcher.cc:322
 hkalmetamatcher.cc:323
 hkalmetamatcher.cc:324
 hkalmetamatcher.cc:325
 hkalmetamatcher.cc:326
 hkalmetamatcher.cc:327
 hkalmetamatcher.cc:328
 hkalmetamatcher.cc:329
 hkalmetamatcher.cc:330
 hkalmetamatcher.cc:331
 hkalmetamatcher.cc:332
 hkalmetamatcher.cc:333
 hkalmetamatcher.cc:334
 hkalmetamatcher.cc:335
 hkalmetamatcher.cc:336
 hkalmetamatcher.cc:337
 hkalmetamatcher.cc:338
 hkalmetamatcher.cc:339
 hkalmetamatcher.cc:340
 hkalmetamatcher.cc:341
 hkalmetamatcher.cc:342
 hkalmetamatcher.cc:343
 hkalmetamatcher.cc:344
 hkalmetamatcher.cc:345
 hkalmetamatcher.cc:346
 hkalmetamatcher.cc:347
 hkalmetamatcher.cc:348
 hkalmetamatcher.cc:349
 hkalmetamatcher.cc:350
 hkalmetamatcher.cc:351
 hkalmetamatcher.cc:352
 hkalmetamatcher.cc:353
 hkalmetamatcher.cc:354
 hkalmetamatcher.cc:355
 hkalmetamatcher.cc:356
 hkalmetamatcher.cc:357
 hkalmetamatcher.cc:358
 hkalmetamatcher.cc:359
 hkalmetamatcher.cc:360
 hkalmetamatcher.cc:361
 hkalmetamatcher.cc:362
 hkalmetamatcher.cc:363
 hkalmetamatcher.cc:364
 hkalmetamatcher.cc:365
 hkalmetamatcher.cc:366
 hkalmetamatcher.cc:367
 hkalmetamatcher.cc:368
 hkalmetamatcher.cc:369
 hkalmetamatcher.cc:370
 hkalmetamatcher.cc:371
 hkalmetamatcher.cc:372
 hkalmetamatcher.cc:373
 hkalmetamatcher.cc:374
 hkalmetamatcher.cc:375
 hkalmetamatcher.cc:376
 hkalmetamatcher.cc:377
 hkalmetamatcher.cc:378
 hkalmetamatcher.cc:379
 hkalmetamatcher.cc:380
 hkalmetamatcher.cc:381
 hkalmetamatcher.cc:382
 hkalmetamatcher.cc:383
 hkalmetamatcher.cc:384
 hkalmetamatcher.cc:385
 hkalmetamatcher.cc:386
 hkalmetamatcher.cc:387
 hkalmetamatcher.cc:388
 hkalmetamatcher.cc:389
 hkalmetamatcher.cc:390
 hkalmetamatcher.cc:391
 hkalmetamatcher.cc:392
 hkalmetamatcher.cc:393
 hkalmetamatcher.cc:394
 hkalmetamatcher.cc:395
 hkalmetamatcher.cc:396
 hkalmetamatcher.cc:397
 hkalmetamatcher.cc:398
 hkalmetamatcher.cc:399
 hkalmetamatcher.cc:400
 hkalmetamatcher.cc:401
 hkalmetamatcher.cc:402
 hkalmetamatcher.cc:403
 hkalmetamatcher.cc:404
 hkalmetamatcher.cc:405
 hkalmetamatcher.cc:406
 hkalmetamatcher.cc:407
 hkalmetamatcher.cc:408
 hkalmetamatcher.cc:409
 hkalmetamatcher.cc:410
 hkalmetamatcher.cc:411
 hkalmetamatcher.cc:412
 hkalmetamatcher.cc:413
 hkalmetamatcher.cc:414
 hkalmetamatcher.cc:415
 hkalmetamatcher.cc:416
 hkalmetamatcher.cc:417
 hkalmetamatcher.cc:418
 hkalmetamatcher.cc:419
 hkalmetamatcher.cc:420
 hkalmetamatcher.cc:421
 hkalmetamatcher.cc:422
 hkalmetamatcher.cc:423
 hkalmetamatcher.cc:424
 hkalmetamatcher.cc:425
 hkalmetamatcher.cc:426
 hkalmetamatcher.cc:427
 hkalmetamatcher.cc:428
 hkalmetamatcher.cc:429
 hkalmetamatcher.cc:430
 hkalmetamatcher.cc:431
 hkalmetamatcher.cc:432
 hkalmetamatcher.cc:433
 hkalmetamatcher.cc:434
 hkalmetamatcher.cc:435
 hkalmetamatcher.cc:436
 hkalmetamatcher.cc:437
 hkalmetamatcher.cc:438
 hkalmetamatcher.cc:439
 hkalmetamatcher.cc:440
 hkalmetamatcher.cc:441
 hkalmetamatcher.cc:442
 hkalmetamatcher.cc:443
 hkalmetamatcher.cc:444
 hkalmetamatcher.cc:445
 hkalmetamatcher.cc:446
 hkalmetamatcher.cc:447
 hkalmetamatcher.cc:448
 hkalmetamatcher.cc:449
 hkalmetamatcher.cc:450
 hkalmetamatcher.cc:451
 hkalmetamatcher.cc:452
 hkalmetamatcher.cc:453
 hkalmetamatcher.cc:454
 hkalmetamatcher.cc:455
 hkalmetamatcher.cc:456
 hkalmetamatcher.cc:457
 hkalmetamatcher.cc:458
 hkalmetamatcher.cc:459
 hkalmetamatcher.cc:460
 hkalmetamatcher.cc:461
 hkalmetamatcher.cc:462
 hkalmetamatcher.cc:463
 hkalmetamatcher.cc:464
 hkalmetamatcher.cc:465
 hkalmetamatcher.cc:466
 hkalmetamatcher.cc:467
 hkalmetamatcher.cc:468
 hkalmetamatcher.cc:469
 hkalmetamatcher.cc:470
 hkalmetamatcher.cc:471
 hkalmetamatcher.cc:472
 hkalmetamatcher.cc:473
 hkalmetamatcher.cc:474
 hkalmetamatcher.cc:475
 hkalmetamatcher.cc:476
 hkalmetamatcher.cc:477
 hkalmetamatcher.cc:478
 hkalmetamatcher.cc:479
 hkalmetamatcher.cc:480
 hkalmetamatcher.cc:481
 hkalmetamatcher.cc:482
 hkalmetamatcher.cc:483
 hkalmetamatcher.cc:484
 hkalmetamatcher.cc:485
 hkalmetamatcher.cc:486
 hkalmetamatcher.cc:487
 hkalmetamatcher.cc:488
 hkalmetamatcher.cc:489
 hkalmetamatcher.cc:490
 hkalmetamatcher.cc:491
 hkalmetamatcher.cc:492
 hkalmetamatcher.cc:493
 hkalmetamatcher.cc:494
 hkalmetamatcher.cc:495
 hkalmetamatcher.cc:496
 hkalmetamatcher.cc:497
 hkalmetamatcher.cc:498
 hkalmetamatcher.cc:499
 hkalmetamatcher.cc:500
 hkalmetamatcher.cc:501
 hkalmetamatcher.cc:502
 hkalmetamatcher.cc:503
 hkalmetamatcher.cc:504
 hkalmetamatcher.cc:505
 hkalmetamatcher.cc:506
 hkalmetamatcher.cc:507
 hkalmetamatcher.cc:508
 hkalmetamatcher.cc:509
 hkalmetamatcher.cc:510
 hkalmetamatcher.cc:511
 hkalmetamatcher.cc:512
 hkalmetamatcher.cc:513
 hkalmetamatcher.cc:514
 hkalmetamatcher.cc:515
 hkalmetamatcher.cc:516
 hkalmetamatcher.cc:517
 hkalmetamatcher.cc:518
 hkalmetamatcher.cc:519
 hkalmetamatcher.cc:520
 hkalmetamatcher.cc:521
 hkalmetamatcher.cc:522
 hkalmetamatcher.cc:523
 hkalmetamatcher.cc:524
 hkalmetamatcher.cc:525
 hkalmetamatcher.cc:526
 hkalmetamatcher.cc:527
 hkalmetamatcher.cc:528
 hkalmetamatcher.cc:529
 hkalmetamatcher.cc:530
 hkalmetamatcher.cc:531
 hkalmetamatcher.cc:532
 hkalmetamatcher.cc:533
 hkalmetamatcher.cc:534
 hkalmetamatcher.cc:535
 hkalmetamatcher.cc:536
 hkalmetamatcher.cc:537
 hkalmetamatcher.cc:538
 hkalmetamatcher.cc:539
 hkalmetamatcher.cc:540
 hkalmetamatcher.cc:541
 hkalmetamatcher.cc:542
 hkalmetamatcher.cc:543
 hkalmetamatcher.cc:544
 hkalmetamatcher.cc:545
 hkalmetamatcher.cc:546
 hkalmetamatcher.cc:547
 hkalmetamatcher.cc:548
 hkalmetamatcher.cc:549
 hkalmetamatcher.cc:550
 hkalmetamatcher.cc:551
 hkalmetamatcher.cc:552
 hkalmetamatcher.cc:553
 hkalmetamatcher.cc:554
 hkalmetamatcher.cc:555
 hkalmetamatcher.cc:556
 hkalmetamatcher.cc:557
 hkalmetamatcher.cc:558
 hkalmetamatcher.cc:559
 hkalmetamatcher.cc:560
 hkalmetamatcher.cc:561
 hkalmetamatcher.cc:562
 hkalmetamatcher.cc:563
 hkalmetamatcher.cc:564
 hkalmetamatcher.cc:565
 hkalmetamatcher.cc:566
 hkalmetamatcher.cc:567
 hkalmetamatcher.cc:568
 hkalmetamatcher.cc:569
 hkalmetamatcher.cc:570
 hkalmetamatcher.cc:571
 hkalmetamatcher.cc:572
 hkalmetamatcher.cc:573
 hkalmetamatcher.cc:574
 hkalmetamatcher.cc:575
 hkalmetamatcher.cc:576
 hkalmetamatcher.cc:577
 hkalmetamatcher.cc:578
 hkalmetamatcher.cc:579
 hkalmetamatcher.cc:580
 hkalmetamatcher.cc:581
 hkalmetamatcher.cc:582
 hkalmetamatcher.cc:583
 hkalmetamatcher.cc:584
 hkalmetamatcher.cc:585
 hkalmetamatcher.cc:586
 hkalmetamatcher.cc:587
 hkalmetamatcher.cc:588
 hkalmetamatcher.cc:589
 hkalmetamatcher.cc:590
 hkalmetamatcher.cc:591
 hkalmetamatcher.cc:592
 hkalmetamatcher.cc:593
 hkalmetamatcher.cc:594
 hkalmetamatcher.cc:595
 hkalmetamatcher.cc:596
 hkalmetamatcher.cc:597
 hkalmetamatcher.cc:598
 hkalmetamatcher.cc:599
 hkalmetamatcher.cc:600
 hkalmetamatcher.cc:601
 hkalmetamatcher.cc:602
 hkalmetamatcher.cc:603
 hkalmetamatcher.cc:604
 hkalmetamatcher.cc:605
 hkalmetamatcher.cc:606
 hkalmetamatcher.cc:607
 hkalmetamatcher.cc:608
 hkalmetamatcher.cc:609
 hkalmetamatcher.cc:610
 hkalmetamatcher.cc:611
 hkalmetamatcher.cc:612
 hkalmetamatcher.cc:613
 hkalmetamatcher.cc:614
 hkalmetamatcher.cc:615
 hkalmetamatcher.cc:616
 hkalmetamatcher.cc:617
 hkalmetamatcher.cc:618
 hkalmetamatcher.cc:619
 hkalmetamatcher.cc:620
 hkalmetamatcher.cc:621
 hkalmetamatcher.cc:622
 hkalmetamatcher.cc:623
 hkalmetamatcher.cc:624
 hkalmetamatcher.cc:625
 hkalmetamatcher.cc:626
 hkalmetamatcher.cc:627
 hkalmetamatcher.cc:628
 hkalmetamatcher.cc:629
 hkalmetamatcher.cc:630
 hkalmetamatcher.cc:631
 hkalmetamatcher.cc:632
 hkalmetamatcher.cc:633
 hkalmetamatcher.cc:634
 hkalmetamatcher.cc:635
 hkalmetamatcher.cc:636
 hkalmetamatcher.cc:637
 hkalmetamatcher.cc:638
 hkalmetamatcher.cc:639
 hkalmetamatcher.cc:640
 hkalmetamatcher.cc:641
 hkalmetamatcher.cc:642
 hkalmetamatcher.cc:643
 hkalmetamatcher.cc:644
 hkalmetamatcher.cc:645
 hkalmetamatcher.cc:646
 hkalmetamatcher.cc:647
 hkalmetamatcher.cc:648
 hkalmetamatcher.cc:649
 hkalmetamatcher.cc:650
 hkalmetamatcher.cc:651
 hkalmetamatcher.cc:652
 hkalmetamatcher.cc:653
 hkalmetamatcher.cc:654
 hkalmetamatcher.cc:655
 hkalmetamatcher.cc:656
 hkalmetamatcher.cc:657
 hkalmetamatcher.cc:658
 hkalmetamatcher.cc:659
 hkalmetamatcher.cc:660
 hkalmetamatcher.cc:661
 hkalmetamatcher.cc:662
 hkalmetamatcher.cc:663
 hkalmetamatcher.cc:664
 hkalmetamatcher.cc:665
 hkalmetamatcher.cc:666
 hkalmetamatcher.cc:667
 hkalmetamatcher.cc:668
 hkalmetamatcher.cc:669
 hkalmetamatcher.cc:670
 hkalmetamatcher.cc:671
 hkalmetamatcher.cc:672
 hkalmetamatcher.cc:673
 hkalmetamatcher.cc:674
 hkalmetamatcher.cc:675
 hkalmetamatcher.cc:676
 hkalmetamatcher.cc:677
 hkalmetamatcher.cc:678
 hkalmetamatcher.cc:679
 hkalmetamatcher.cc:680
 hkalmetamatcher.cc:681
 hkalmetamatcher.cc:682
 hkalmetamatcher.cc:683
 hkalmetamatcher.cc:684
 hkalmetamatcher.cc:685
 hkalmetamatcher.cc:686
 hkalmetamatcher.cc:687
 hkalmetamatcher.cc:688
 hkalmetamatcher.cc:689
 hkalmetamatcher.cc:690
 hkalmetamatcher.cc:691
 hkalmetamatcher.cc:692
 hkalmetamatcher.cc:693
 hkalmetamatcher.cc:694
 hkalmetamatcher.cc:695
 hkalmetamatcher.cc:696
 hkalmetamatcher.cc:697
 hkalmetamatcher.cc:698
 hkalmetamatcher.cc:699
 hkalmetamatcher.cc:700
 hkalmetamatcher.cc:701
 hkalmetamatcher.cc:702
 hkalmetamatcher.cc:703
 hkalmetamatcher.cc:704
 hkalmetamatcher.cc:705
 hkalmetamatcher.cc:706
 hkalmetamatcher.cc:707
 hkalmetamatcher.cc:708
 hkalmetamatcher.cc:709
 hkalmetamatcher.cc:710
 hkalmetamatcher.cc:711
 hkalmetamatcher.cc:712
 hkalmetamatcher.cc:713
 hkalmetamatcher.cc:714
 hkalmetamatcher.cc:715
 hkalmetamatcher.cc:716
 hkalmetamatcher.cc:717
 hkalmetamatcher.cc:718
 hkalmetamatcher.cc:719
 hkalmetamatcher.cc:720
 hkalmetamatcher.cc:721
 hkalmetamatcher.cc:722
 hkalmetamatcher.cc:723
 hkalmetamatcher.cc:724
 hkalmetamatcher.cc:725
 hkalmetamatcher.cc:726