ROOT logo
//Task for all Matchings, fills hmetamatch
//*-- Author : V. Pechenov (29.07.2009)

using namespace std;

#include "hmdcclusmetamatch.h"
#include "hades.h"
#include "hevent.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hspectrometer.h"
#include "hruntimedb.h"
#include "hspecgeompar.h"
#include "tofdef.h"
#include "showerdef.h"
#include "emcdef.h"
#include "hshowergeometry.h"
#include "hemcgeompar.h"
#include "htofhitsim.h"
#include "htofclustersim.h"
#include "htofgeompar.h"
#include "hmetamatchpar.h"
#include "hmdcsizescells.h"
#include "hmdcgetcontainers.h"
#include "hmdcdetector.h"
#include "hshowerhittoftrack.h"
#include "hmdccluster.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "rpcdef.h"
#include "hrpcgeompar.h"
#include "hrpccluster.h"
#include "hemccluster.h"
#include <iostream>

ClassImp(HMdcClusMetaMatch)

HMdcClusMetaMatch::HMdcClusMetaMatch() {
  setInitParam();
}

void HMdcClusMetaMatch::setInitParam(void) {
  pMatchPar      = NULL;
  pTofGeometry   = NULL;
  pCatTof        = NULL;
  iterTof        = NULL;
  pCatTofCluster = NULL;
  iterTofCluster = NULL;
  pRpcGeometry   = NULL;
  pCatRpc        = NULL;
  iterRpc        = NULL;
  pShrGeometry   = NULL;
  pCatShower     = NULL;
  iterShower     = NULL;
  fEmcGeometry   = NULL;
  fCatEmc        = NULL;
  
  qualityMulp2   = 1.5*1.5;
  
  fillPlots      = kFALSE;
  for(Int_t s=0;s<6;s++) {
    rpcPlots[s] = 0;
    shrPlots[s] = 0;
    tofPlots[s] = 0;
  }
}

HMdcClusMetaMatch::~HMdcClusMetaMatch() {
  if(iterTof) {
    delete iterTof;
    iterTof=0;
  }
  if(iterShower) {
    delete iterShower;
    iterShower=0;
  }
}

Bool_t HMdcClusMetaMatch::init(void) {
  if (!gHades) return kFALSE;
  HRuntimeDb *rtdb = gHades->getRuntimeDb();
  if(!rtdb)    return kFALSE;
  HEvent *event = gHades->getCurrentEvent();
  if(!event)   return kFALSE;
  HSpectrometer *spec = gHades->getSetup();

  // TOF:
  pCatTof = event->getCategory(catTofHit);
  if(pCatTof == NULL) Warning("init",
    "No catTofHit in input! \n Matching with TofHits will be skipped!");
  else {
    iterTof = (HIterator*)pCatTof->MakeIterator();
    pTofGeometry = (HTofGeomPar *)rtdb->getContainer("TofGeomPar");
  }
  pCatTofCluster = event->getCategory(catTofCluster);
  if(pCatTofCluster == NULL) Warning("init",
    "NO catTofCluster in input! \n Matching with TofClusters will be skipped!");
  else iterTofCluster = (HIterator*)pCatTofCluster->MakeIterator();
  if(pCatTof == NULL && pCatTofCluster == NULL) {
    Error("init","No catTofHit and catTofCluster in input! Stop!");
    return kFALSE;
  }


  // RPC:
  pCatRpc = event->getCategory(catRpcCluster);
  if(!pCatRpc) {
    Warning("init","NO catRpcCluster in input! \n Matching with RpcClusters will be skipped!");
  } else {
    iterRpc = (HIterator*)pCatRpc->MakeIterator("native");
    pRpcGeometry   = (HRpcGeomPar*)rtdb->getContainer("RpcGeomPar");
  }

  
  // Shower & Emc:
  if(spec->getDetector("Shower")) {
    pCatShower = event->getCategory(catShowerHit);
    if(pCatShower != NULL) {
      iterShower   = (HIterator*)pCatShower->MakeIterator();
      pShrGeometry = (HShowerGeometry*)rtdb->getContainer("ShowerGeometry");
    }
  } else if(spec->getDetector("Emc")) {
    fCatEmc    = event->getCategory(catEmcCluster);
    if(fCatEmc != NULL) fEmcGeometry = (HEmcGeomPar *)rtdb->getContainer("EmcGeomPar");
  }
  if(pCatShower == NULL && fCatEmc == NULL) {
    Warning("init","No catShowerHit and catEmcCluster in input! Will be ignored!");
    iterShower = NULL;
  }
  
  pMatchPar    = (HMetaMatchPar*)rtdb->getContainer("MetaMatchPar");
  
  printf("HMdcClusMetaMatch is inited!\n");
  
  return kTRUE;
}

Bool_t HMdcClusMetaMatch::reinit(void) {
//  if(!pSizesCells->initContainer()) return kFALSE;
      
  HMdcGetContainers* pGetCont = HMdcGetContainers::getObject();

  if(pTofGeometry && !HMdcGetContainers::isInited(pTofGeometry)) return kFALSE;
  if(pShrGeometry && !HMdcGetContainers::isInited(pShrGeometry)) return kFALSE;
  
  if(pMatchPar==NULL || !HMdcGetContainers::isInited(pMatchPar)) {
    Error("reinit","no parameters for matching!");
    return kFALSE;
  }
  
  for(Int_t sec=0; sec<6; sec++) {
    if(pGetCont->getMdcDetector()->isSectorActive(sec)) {
      const HGeomTransform& labSecTr = pGetCont->getLabTransSec(sec);
      if((&labSecTr) == NULL) return kFALSE;
      if(pTofGeometry != NULL) {
        for(Int_t tofMod=0;tofMod<8;tofMod++) {
          HModGeomPar *pTofMod = pTofGeometry->getModule(sec,tofMod);
          if(pTofMod==0) {
            Error("reinit","Sec.%i Can't get tof module %i!",sec+1,tofMod+1);
            return kFALSE;
          }
          HGeomTransform trans(pTofMod->getLabTransform());
          HMdcSizesCells::copyTransfToArr(trans,tofLabModTrans[sec][tofMod]);
          trans.transTo(labSecTr);
          HMdcSizesCells::copyTransfToArr(trans,tofSecModTrans[sec][tofMod]);
        }
      }
      
      // Shower mod=0 is used only:
      if(pShrGeometry != NULL) {
        HGeomTransform transS(pShrGeometry->getTransform(sec));
        transS.transTo(labSecTr);
        HMdcSizesCells::copyTransfToArr(transS,shrSecModTrans[sec]);
      }
      
      // EMC:
      if (fEmcGeometry) {
        HModGeomPar *pmodgeom = fEmcGeometry->getModule(sec);
        HGeomTransform transS(pmodgeom->getLabTransform());
        transS.transTo(labSecTr);
        HMdcSizesCells::copyTransfToArr(transS,shrSecModTrans[sec]);
      }
      
      // RPC:
      if(pCatRpc != NULL) {
        HModGeomPar *pRpcMod = pRpcGeometry->getModule(sec,0);
        if(pRpcMod==0) {
          Error("reinit","Sec.%i Can't get rpc geometry!",sec+1);
          return kFALSE;
        }
        HGeomTransform transR(pRpcMod->getLabTransform());
        transR.transTo(labSecTr);
        HMdcSizesCells::copyTransfToArr(transR,rpcSecModTrans[sec]);
      }

      sigma2RpcX[sec]      = pMatchPar->getRpcSigmaXMdc(sec);
      sigma2RpcX[sec]     *= sigma2RpcX[sec];
      sigma2RpcY[sec]      = pMatchPar->getRpcSigmaYMdc(sec);
      sigma2RpcY[sec]     *= sigma2RpcY[sec];
      offsetRpcX[sec]      = pMatchPar->getRpcSigmaXOffset(sec);
      offsetRpcY[sec]      = pMatchPar->getRpcSigmaYOffset(sec);
      quality2RpcCut[sec]  = pMatchPar->getRpcQualityCut(sec);
      quality2RpcCut[sec] *= quality2RpcCut[sec];

      sigma2ShrX[sec]      = pMatchPar->getShowerSigmaXMdc(sec);
      sigma2ShrX[sec]     *= sigma2ShrX[sec];
      sigma2ShrY[sec]      = pMatchPar->getShowerSigmaYMdc(sec);
      sigma2ShrY[sec]     *= sigma2ShrY[sec];
      offsetShrX[sec]      = pMatchPar->getShowerSigmaXOffset(sec);
      offsetShrY[sec]      = pMatchPar->getShowerSigmaYOffset(sec);
      quality2ShrCut[sec]  = pMatchPar->getShowerQualityCut(sec);
      quality2ShrCut[sec] *= quality2ShrCut[sec];

      sigma2EmcX[sec]      = pMatchPar->getShowerSigmaXMdc(sec);
      sigma2EmcX[sec]     *= sigma2ShrX[sec];
      sigma2EmcY[sec]      = pMatchPar->getShowerSigmaYMdc(sec);
      sigma2EmcY[sec]     *= sigma2ShrY[sec];
      offsetEmcX[sec]      = pMatchPar->getShowerSigmaXOffset(sec);
      offsetEmcY[sec]      = pMatchPar->getShowerSigmaYOffset(sec);
      quality2EmcCut[sec]  = pMatchPar->getShowerQualityCut(sec);
      quality2EmcCut[sec] *= quality2ShrCut[sec];

      sigma2TofXi[sec]     = 1./pMatchPar->getTofSigmaX(sec);
      sigma2TofXi[sec]    *= sigma2TofXi[sec];
      sigma2TofYi[sec]     = 1./pMatchPar->getTofSigmaY(sec);
      sigma2TofYi[sec]    *= sigma2TofYi[sec];
      offsetTofX[sec]      = pMatchPar->getTofSigmaXOffset(sec);
      offsetTofY[sec]      = pMatchPar->getTofSigmaYOffset(sec);
      quality2TofCut[sec]  = pMatchPar->getTofQualityCut(sec);
      quality2TofCut[sec] *= quality2TofCut[sec];
      
      if(fillPlots) {
        Char_t name[100];
        Char_t title[100];
        sprintf(name,"RpcSec%i",sec+1);
        sprintf(title,"Sec.%i Rpc;X_{RPC}-X_{MDC} [mm];Y_{RPC}-Y_{MDC} [mm];",sec+1);
        rpcPlots[sec] = new TH2F(name,title,100,-250.,250.,100,-250.,250.);
        if(pShrGeometry != NULL) {
          sprintf(name,"ShrSec%i",sec+1);
          sprintf(title,"Sec.%i Shower;X_{Shower}-X_{MDC} [mm];Y_{Shower}-Y_{MDC} [mm];",sec+1);
          shrPlots[sec] = new TH2F(name,title,100,-250.,250.,100,-250.,250.);
        } else {
          sprintf(name,"EmcSec%i",sec+1);
          sprintf(title,"Sec.%i Emc;X_{EMC}-X_{MDC} [mm];Y_{EMC}-Y_{MDC} [mm];",sec+1);
          shrPlots[sec] = new TH2F(name,title,100,-250.,250.,100,-250.,250.);
        } 

        sprintf(name,"TofSec%i",sec+1);
        sprintf(title,"Sec.%i TOF;X_{TOF}-X_{MDC} [mm];Y_{Shower}-Y_{MDC} [mm];",sec+1);
        tofPlots[sec] = new TH2F(name,title,100,-250.,250.,100,-250.,250.);
      }
    }
  }

  return kTRUE;
}

void HMdcClusMetaMatch::collectMetaHits(void) {
  for(Int_t s=0;s<6;s++) {
    nShowerHits[s] = 0;
    nRpcHits[s]    = 0;
    nTofHits[s]    = 0;
  }
  collectRpcClusters();
  collectShowerHits();
  collectEmcClusters();
  collectTofHits();
}

void HMdcClusMetaMatch::collectRpcClusters(void) {
  if(pCatRpc == NULL) return;
  iterRpc->Reset();
  HRpcCluster *pRpcCluster;
  while((pRpcCluster=(HRpcCluster*)(iterRpc->Next()))!=0) {
    Int_t sec = pRpcCluster->getSector();
    UInt_t& nRpcHSec = nRpcHits[sec];
    if(nRpcHSec>=200) continue; //!!!     
    RpcHit &rpcHit = rpcHitArr[sec][nRpcHSec];
    
    rpcHit.x = pRpcCluster->getXMod() - offsetRpcX[sec];
    rpcHit.y = pRpcCluster->getYMod() - offsetRpcY[sec];
    rpcHit.z = pRpcCluster->getZMod();
    rpcHit.xSigma2i = pRpcCluster->getXRMS()*pRpcCluster->getXRMS();
    rpcHit.xSigma2i = 1.f/(rpcHit.xSigma2i + sigma2RpcX[sec]);
    rpcHit.ySigma2i = pRpcCluster->getYRMS()*pRpcCluster->getYRMS();
    rpcHit.ySigma2i = 1.f/(rpcHit.ySigma2i + sigma2RpcY[sec]);
    nRpcHSec++;
  }
}

void HMdcClusMetaMatch::collectShowerHits(void) {
  if(!pCatShower) return;
  iterShower->Reset();
  HShowerHit *pShowerHit;
  while((pShowerHit=(HShowerHit*)(iterShower->Next()))!=0) {
    if(pShowerHit->getModule() != 0) continue;
    Int_t sec = pShowerHit->getSector();
    UInt_t& nShrHSec = nShowerHits[sec];
    if(nShrHSec>=200) continue; //!!!     
    ShowerHit &shrHit = shrHitArr[sec][nShrHSec];
    Float_t x,y;
    pShowerHit->getXY(&x,&y);
    
    shrHit.x = x - offsetShrX[sec];
    shrHit.y = y - offsetShrY[sec];
    shrHit.z = pShowerHit->getZ();
    shrHit.xSigma2i = pShowerHit->getSigmaX()*pShowerHit->getSigmaX();
    shrHit.xSigma2i = 1.f/(shrHit.xSigma2i + sigma2ShrX[sec]);
    shrHit.ySigma2i = pShowerHit->getSigmaY()*pShowerHit->getSigmaY();
    shrHit.ySigma2i = 1.f/(shrHit.ySigma2i + sigma2ShrY[sec]);
    nShrHSec++;
  }
}

void HMdcClusMetaMatch::collectEmcClusters(void) {
  if(fCatEmc == NULL) return;
  Int_t nclus = fCatEmc->getEntries();
  for(Int_t ind=0;ind<nclus;ind++) {
    HEmcCluster *pEmcCluster = (HEmcCluster*)fCatEmc->getObject(ind);
    if( !pEmcCluster->ifActive() ) continue;              // Bad cluster
    Int_t sec = pEmcCluster->getSector();
    UInt_t& nShrHSec = nShowerHits[sec];
    if(nShrHSec>=200) continue; //!!!     
    ShowerHit &shrHit = shrHitArr[sec][nShrHSec];
    
    shrHit.x = pEmcCluster->getXMod() - offsetShrX[sec];
    shrHit.y = pEmcCluster->getYMod() - offsetShrY[sec];
    shrHit.z = 0.;
    shrHit.xSigma2i = pEmcCluster->getSigmaXMod()*pEmcCluster->getSigmaXMod();
    shrHit.xSigma2i = 1.f/(shrHit.xSigma2i + sigma2ShrX[sec]);
    shrHit.ySigma2i = pEmcCluster->getSigmaYMod()*pEmcCluster->getSigmaYMod();
    shrHit.ySigma2i = 1.f/(shrHit.ySigma2i + sigma2ShrY[sec]);
    nShrHSec++;
  }
}

void HMdcClusMetaMatch::collectTofHits(void) {
  if(pCatTof) iterTof->Reset();
  HTofHit *pTofHit;
  if(!pCatTofCluster) {
    // No TofCluster category:
    if(pCatTof)
      while((pTofHit=(HTofHit*)(iterTof->Next()))!=0 ) addTofHit(pTofHit);
  } else {
    // TofCluster category exist:
    iterTofCluster->Reset();
    HTofCluster *pTofCluster;
    while((pTofCluster=(HTofCluster*)(iterTofCluster->Next()))!=0 ) {
      Int_t tofClSize=pTofCluster->getClusterSize();
// ???      if(tofClSize>2) continue;     // tofClSize<=2 only !????????????
      addTofHit(pTofCluster);
      if(tofClSize<2) continue;
      if(pCatTof==0)  continue;
      Int_t sec  = pTofCluster->getSector();
      Int_t mod  = pTofCluster->getModule();
      Int_t cell = pTofCluster->getCell();
      while((pTofHit=(HTofHit*)(iterTof->Next()))!=0 ) {
        if(sec!=pTofHit->getSector() || mod!=pTofHit->getModule() ||
            cell != pTofHit->getCell()) continue;
        if(tofClSize==2) {  // two TofHits adding, tofClSize==2 only !
          addTofHit(pTofHit);                  // first TofHit for TofCluster
          pTofHit = (HTofHit*)(iterTof->Next());   // second ...
          addTofHit(pTofHit);                  // clust.size==2 selected !!!
        } else {            // tofClSize>2 only HTofHits can be used
          addTofHit(pTofHit);
          for(Int_t h=0;h<tofClSize-1;h++) {
            pTofHit = (HTofHit*)(iterTof->Next());
            addTofHit(pTofHit);
          }
        }
        break;
      }
    }
  }
}

void HMdcClusMetaMatch::addTofHit(HTofHit* pTofHit) {
  Int_t   sec      = pTofHit->getSector();
  Int_t   mod      = pTofHit->getModule();
  UInt_t &nTofHSec = nTofHits[sec];
  TofHit &tofHit   = tofHitArr[sec][nTofHSec];
  Float_t Xtof,Ytof,Ztof;
  pTofHit->getXYZLab(Xtof,Ytof,Ztof);
  Double_t *tSysRLab = tofLabModTrans[sec][mod];
  Double_t xt = Xtof-tSysRLab[ 9];
  Double_t yt = Ytof-tSysRLab[10];
  Double_t zt = Ztof-tSysRLab[11];
  tofHit.x    = tSysRLab[0]*xt+tSysRLab[3]*yt+tSysRLab[6]*zt;
  tofHit.y    = tSysRLab[1]*xt+tSysRLab[4]*yt+tSysRLab[7]*zt;
  //tofHit.z   = tSysRLab[2]*xt+tSysRLab[5]*yt+tSysRLab[8]*zt;
  tofHit.x   -= offsetTofX[sec];
  tofHit.y   -= offsetTofY[sec];
  tofHit.mod = mod;
  nTofHSec++;
}

Bool_t HMdcClusMetaMatch::hasClusMathToMeta(Int_t sec,const HGeomVector& targ,
                                       Double_t xcl,Double_t ycl,Double_t zcl) {
  if(fillPlots) return testAndFill(sec,targ,xcl,ycl,zcl);
  Double_t xd  = xcl-targ(0);
  Double_t yd  = ycl-targ(1);
  Double_t zd  = zcl-targ(2);
  
  // Matching with rpc:
  if(nRpcHits[sec]>0) {
    Double_t *tSysRSec = rpcSecModTrans[sec];
    Double_t  xci = xcl-tSysRSec[ 9];
    Double_t  yci = ycl-tSysRSec[10];
    Double_t  zci = zcl-tSysRSec[11];
    Double_t  a1  = tSysRSec[2]*xci+tSysRSec[5]*yci;
    Double_t  a2  = 1./(tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
    Float_t   x   = 0.;
    Float_t   y   = 0.;
    Float_t   zPr = -1000.;
    for(UInt_t n=0;n<nRpcHits[sec];n++) {
      RpcHit &rpcHit = rpcHitArr[sec][n];
      if(rpcHit.z != zPr) {
        // Calculation of cross poin with rpc module (in mod.coor.sys.)
        zPr = rpcHit.z;
        Double_t zc = zci-rpcHit.z;
        Double_t mp = (a1+tSysRSec[8]*zc)*a2;
        Double_t xc = xci-xd*mp;
        Double_t yc = yci-yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX   = rpcHit.x - x;
      Float_t dY   = rpcHit.y - y;
      Float_t qual = dX*dX*rpcHit.xSigma2i + dY*dY*rpcHit.ySigma2i;
      if(qual <= quality2RpcCut[sec]*qualityMulp2) return kTRUE;
    }
  }
  
  // Matching with shower or emc:
  if(nShowerHits[sec]>0) {
    Double_t *tSysRSec = shrSecModTrans[sec];
    Double_t  xci = xcl-tSysRSec[ 9];
    Double_t  yci = ycl-tSysRSec[10];
    Double_t  zci = zcl-tSysRSec[11];
    Double_t  a1  = tSysRSec[2]*xci+tSysRSec[5]*yci;
    Double_t  a2  = 1./(tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
    Float_t   x   = 0.;
    Float_t   y   = 0.;
    Float_t   zPr = -1000.;
    for(UInt_t n=0;n<nShowerHits[sec];n++) {
      ShowerHit &shrHit = shrHitArr[sec][n];
      if(shrHit.z != zPr) {
        // Calculation of cross poin with shower module (in mod.coor.sys.)
        zPr = shrHit.z;
        Double_t zc = zci-shrHit.z;
        Double_t mp = (a1+tSysRSec[8]*zc)*a2;
        Double_t xc = xci-xd*mp;
        Double_t yc = yci-yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX   = shrHit.x - x;
      Float_t dY   = shrHit.y - y;
      Float_t qual = dX*dX*shrHit.xSigma2i + dY*dY*shrHit.ySigma2i;
      if(qual <= quality2ShrCut[sec]*qualityMulp2) return kTRUE;
    }
  }
  
  // Matching with tof:
  if(nTofHits[sec]>0) {
    Float_t x   = 0.;
    Float_t y   = 0.;
    UChar_t mPr = 255;
    for(UInt_t n=0;n<nTofHits[sec];n++) {
      TofHit &tofHit = tofHitArr[sec][n];
      if(tofHit.mod != mPr) {
        mPr = tofHit.mod;
        Double_t *tSysRSec = tofSecModTrans[sec][tofHit.mod];

        // Calculation of cross poin with tof module (in mod.coor.sys.)
        Double_t xc = xcl-tSysRSec[ 9];
        Double_t yc = ycl-tSysRSec[10];
        Double_t zc = zcl-tSysRSec[11];
        Double_t mp = (tSysRSec[2]*xc+tSysRSec[5]*yc+tSysRSec[8]*zc) /
                      (tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
        xc -= xd*mp;
        yc -= yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX   = tofHit.x - x;
      Float_t dY   = tofHit.y - y;
      Float_t qual = dX*dX*sigma2TofXi[sec] +dY*dY*sigma2TofYi[sec];

      if(qual <= quality2TofCut[sec]*qualityMulp2) return kTRUE;
    }
  }
  // No matching
  return kFALSE;
}

Bool_t HMdcClusMetaMatch::testAndFill(Int_t sec,const HGeomVector& targ,
                                       Double_t xcl,Double_t ycl,Double_t zcl) {
  Bool_t exitFlag = kFALSE;
  Double_t xd  = xcl-targ(0);
  Double_t yd  = ycl-targ(1);
  Double_t zd  = zcl-targ(2);
  
  // Matching with rpc:
  if(nRpcHits[sec]>0) {
    TH2F* rpcPlot = rpcPlots[sec];
    Double_t *tSysRSec = rpcSecModTrans[sec];
    Double_t  xci = xcl-tSysRSec[ 9];
    Double_t  yci = ycl-tSysRSec[10];
    Double_t  zci = zcl-tSysRSec[11];
    Double_t  a1  = tSysRSec[2]*xci+tSysRSec[5]*yci;
    Double_t  a2  = 1./(tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
    Float_t   x   = 0.;
    Float_t   y   = 0.;
    Float_t   zPr = -1000.;
    for(UInt_t n=0;n<nRpcHits[sec];n++) {
      RpcHit &rpcHit = rpcHitArr[sec][n];
      if(rpcHit.z != zPr) {
        // Calculation of cross poin with rpc module (in mod.coor.sys.)
        zPr = rpcHit.z;
        Double_t zc = zci-rpcHit.z;
        Double_t mp = (a1+tSysRSec[8]*zc)*a2;
        Double_t xc = xci-xd*mp;
        Double_t yc = yci-yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX = rpcHit.x - x;
      Float_t dY = rpcHit.y - y;
      if(rpcPlot) rpcPlot->Fill(dX,dY);
      if(!exitFlag) {
        Float_t qual = dX*dX*rpcHit.xSigma2i + dY*dY*rpcHit.ySigma2i;  
        if(qual <= quality2RpcCut[sec]*qualityMulp2) exitFlag = kTRUE;
      }
    }
  }
  
  // Matching with shower:
  if(nShowerHits[sec]>0) {
    TH2F* shrPlot = shrPlots[sec];
    Double_t *tSysRSec = shrSecModTrans[sec];
    Double_t  xci = xcl-tSysRSec[ 9];
    Double_t  yci = ycl-tSysRSec[10];
    Double_t  zci = zcl-tSysRSec[11];
    Double_t  a1  = tSysRSec[2]*xci+tSysRSec[5]*yci;
    Double_t  a2  = 1./(tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
    Float_t   x   = 0.;
    Float_t   y   = 0.;
    Float_t   zPr = -1000.;
    for(UInt_t n=0;n<nShowerHits[sec];n++) {
      ShowerHit &shrHit = shrHitArr[sec][n];
      if(shrHit.z != zPr) {
        // Calculation of cross poin with shower module (in mod.coor.sys.)
        zPr = shrHit.z;
        Double_t zc = zci-shrHit.z;
        Double_t mp = (a1+tSysRSec[8]*zc)*a2;
        Double_t xc = xci-xd*mp;
        Double_t yc = yci-yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX = shrHit.x - x;
      Float_t dY = shrHit.y - y;
      if(shrPlot) shrPlot->Fill(dX,dY);
      if(!exitFlag) {
        Float_t qual = dX*dX*shrHit.xSigma2i + dY*dY*shrHit.ySigma2i;  
        if(qual <= quality2ShrCut[sec]*qualityMulp2) exitFlag = kTRUE;
      }
    }
  }
  
  // Matching with tof:
  if(nTofHits[sec]>0) {
    TH2F* tofPlot = tofPlots[sec];
    Float_t x   = 0.; 
    Float_t y   = 0.;
    UChar_t mPr = 255;
    for(UInt_t n=0;n<nTofHits[sec];n++) {
      TofHit &tofHit = tofHitArr[sec][n];
      if(tofHit.mod != mPr) {
        mPr = tofHit.mod;
        Double_t *tSysRSec = tofSecModTrans[sec][tofHit.mod];

        // Calculation of cross poin with tof module (in mod.coor.sys.)
        Double_t xc = xcl-tSysRSec[ 9];
        Double_t yc = ycl-tSysRSec[10];
        Double_t zc = zcl-tSysRSec[11];
        Double_t mp = (tSysRSec[2]*xc+tSysRSec[5]*yc+tSysRSec[8]*zc) /
                      (tSysRSec[2]*xd+tSysRSec[5]*yd+tSysRSec[8]*zd);
        xc -= xd*mp;
        yc -= yd*mp;
        zc -= zd*mp;
        x   = tSysRSec[0]*xc+tSysRSec[3]*yc+tSysRSec[6]*zc;
        y   = tSysRSec[1]*xc+tSysRSec[4]*yc+tSysRSec[7]*zc;
      }
      Float_t dX   = tofHit.x - x;
      Float_t dY   = tofHit.y - y;
      if(tofPlot != NULL) tofPlot->Fill(dX,dY);
      if(!exitFlag) {
        Float_t qual = dX*dX*sigma2TofXi[sec] +dY*dY*sigma2TofYi[sec];  
        if(qual <= quality2TofCut[sec]*qualityMulp2) exitFlag = kTRUE;
      }
    }
  }
  // No matching
  return exitFlag;
}

void HMdcClusMetaMatch::deletePlots(void) {
  for(Int_t s=0;s<6;s++) {
    if(rpcPlots[s] != NULL) delete rpcPlots[s];
    if(shrPlots[s] != NULL) delete shrPlots[s];
    if(tofPlots[s] != NULL) delete tofPlots[s];
    rpcPlots[s] = 0;
    shrPlots[s] = 0;
    tofPlots[s] = 0;
  }
}

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