ROOT logo
//*-- Author   : Pablo Cabanelas
//*-- Created  : 30/08/07
//*-- Modified : 18/12/07 Diego Gonzalez-Diaz
//*-- Modified : 13/12/09 Diego Gonzalez-Diaz Removed hard-coded
//*-- Modified :          parameters.
//*-- Modified : 03/07/12 Alessio Mangiarotti Added filling of Theta,
//*-- Modified :          Phi and InsideCellFlag for simulation.
//*-- Modified : 19/07/12 Alessio Mangiarotti General code cleanup.
//*-- Modified :          Geometry parameters used in several places
//*-- Modified :          are now stored as local variables (see D,
//*-- Modified :          HD, HDT, XL, W). Some fixed values have
//*-- Modified :          been introduced as constants (see rad2deg,
//*-- Modified :          ovang, invsqrt12). Namespace TMath used
//*-- Modified :          consistently everywhere. The different
//*-- Modified :          processing necessary for simulation and
//*-- Modified :          data has been merged in a single place.
//*-- Modified :          The variable xMod is now calculated in the
//*-- Modified :          same way for data and simulation.
//*-- Modified : 22/04/13 Georgy Kornakov. Correction of the time
//*-- Modified :          uncertainty calculated from RpcDigiPar,
//*-- Modified :          suggested by Alessio.
//*-- Modified : 28/08/13 Georgy Kornakov Added the new Slewing and
//*-- Modified :          Time-position (walking) correction. The
//*-- Modified :          parameters are stored in the HRpcTimePosPar
//*-- Modified :          and HRpcSlewingPar objects. The previous
//*-- Modified :          method was removed. The new time-charge
//*-- Modified :          correction uses two exponentials (3 params
//*-- Modified :          each) and a qcut to set the crossing point
//*-- Modified :          of the two behaviours. The position-time
//*-- Modified :          dependence correction uses a coposition
//*-- Modified :          of 5 sinusoidal terms (15 params) to
//*-- Modified :          compensate the effect.
//*-- Modified : 04/12/13 G.Kornakov Added RPC embedding mode.
//*-- Modified :          TODO: The Hit finder could be substantially
//*-- Modified :          simplified if the execute code is introduced
//*-- Modified :          in functions as fillHits(), calculateRealCorrections()
//*-- Modified :          calculateSimCorrection(), mergeHits()...
//*-- Modified :          That would improve the understanding
//*-- Modified :          of the code.
//*-- Modified :
//
//_HADES_CLASS_DESCRIPTION
////////////////////////////////////////////////////////////////////
//
//  HRpcHitF: RPC detector hit finder
//
//  Gets calibrated data from RpcCal(Sim) and writes to RpcHit(Sim)
//  In case of embedding mode, creates RpcHitSim from temporal category.
//  At the end of the procedure both are merged.
//
///////////////////////////////////////////////////////////////////

using namespace std;
#include "TRandom.h"
#include <time.h>
#include "hrpcdetector.h"
#include "hrpchitf.h"
#include "rpcdef.h"
#include "hrpccal.h"
#include "hrpccalsim.h"
#include "hrpchitsim.h"
#include "hgeantrpc.h"
#include "hrpcgeomcellpar.h"
#include "hrpcgeompar.h"
#include "hrpccellstatuspar.h"
#include "hrpcdigipar.h"
#include "hdebug.h"
#include "hades.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hspecgeompar.h"
#include "hdetector.h"
#include "hevent.h"
#include "hgeantkine.h"
#include "hcategory.h"
#include "hstart2detector.h"
#include "hstart2hit.h"
#include "hstartdef.h"
#include "hgeomvector.h"
#include "hgeomvector2.h"
#include "hgeomvolume.h"
#include "hgeomtransform.h"
#include "hrpcwtoqpar.h"
#include "hrpchitfpar.h"
#include "hrpctimepospar.h"
#include "hrpcslewingpar.h"

#include <iostream>
#include <iomanip>

void HRpcHitF::initParContainer() {
  pRpcGeometry   = (HRpcGeomPar*)(gHades->getRuntimeDb()->getContainer("RpcGeomPar"));
  pGeomCellPar   = (HRpcGeomCellPar*)(gHades->getRuntimeDb()->getContainer("RpcGeomCellPar"));
  pCellStatusPar = (HRpcCellStatusPar*)(gHades->getRuntimeDb()->getContainer("RpcCellStatusPar"));
  pDigiPar       = (HRpcDigiPar*)(gHades->getRuntimeDb()->getContainer("RpcDigiPar"));
  pWtoQPar       = (HRpcWtoQPar*)(gHades->getRuntimeDb()->getContainer("RpcWtoQPar"));
  pHitFPar       = (HRpcHitFPar*)(gHades->getRuntimeDb()->getContainer("RpcHitFPar"));
  pSpecGeomPar   = (HSpecGeomPar*)(gHades->getRuntimeDb()->getContainer("SpecGeomPar"));
  pTimePosPar    = (HRpcTimePosPar*)(gHades->getRuntimeDb()->getContainer("RpcTimePosPar"));
  pSlewingPar    = (HRpcSlewingPar*)(gHades->getRuntimeDb()->getContainer("RpcSlewingPar"));
}

HRpcHitF::HRpcHitF(void)
{
  pCalCat        = NULL;
  pHitCat        = NULL;
  iter           = NULL;
  pRpcGeometry   = NULL;
  pGeomCellPar   = NULL;
  pCellStatusPar = NULL;
  pDigiPar       = NULL;
  pWtoQPar       = NULL;
  pHitFPar       = NULL;
  pStartHitCat   = NULL;
  pTimePosPar    = NULL;
  pSlewingPar    = NULL;
}

HRpcHitF::HRpcHitF(const Text_t *name, const Text_t *title) :
HReconstructor(name,title)
{
  pCalCat        = NULL;
  pHitCat        = NULL;
  iter           = NULL;
  pRpcGeometry   = NULL;
  pGeomCellPar   = NULL;
  pCellStatusPar = NULL;
  pDigiPar       = NULL;
  pWtoQPar       = NULL;
  pHitFPar       = NULL;
  pStartHitCat   = NULL;
  pTimePosPar    = NULL;
  pSlewingPar    = NULL;
}

HRpcHitF::~HRpcHitF(void)
{
  if (iter) delete iter;
  iter=NULL;
}

Bool_t HRpcHitF::init(void)
{

  initParContainer();

  if (!pRpcGeometry){
    Error("init","No RPC Geometry!!");
    return kFALSE;
  }
  if (!pGeomCellPar){
    Error("init","No RpcGeomCellPar Parameters");
    return kFALSE;
  }
  if (!pCellStatusPar){
    Error("init","No RpcCellStatusPar Parameters");
    return kFALSE;
  }
  if (!pDigiPar){
    Error("init","No RpcDigiPar Parameters");
    return kFALSE;
  }
  if (!pWtoQPar){
    Error("init","No RpcWtoQPar Parameters");
    return kFALSE;
  }
  if (!pHitFPar){
    Error("init","No RpcHitFPar Parameters");
    return kFALSE;
  }
  if (!pSpecGeomPar){
    Error("init","No SpecGeomPar Parameters");
    return kFALSE;
  }

  if(!pTimePosPar) {
    Error("init","No RpcTimePosPar Parameters");
    return kFALSE;
  }

  if(!pSlewingPar) {
    Error("init","No RpcSlewingPar Parameters");
    return kFALSE;
  }


  HRpcDetector *rpc;
  rpc=(HRpcDetector *)gHades->getSetup()->getDetector("Rpc");

  if(!rpc){
    Error("init","No Rpc Detector found");
    return kFALSE;
  }


  pStartHitCat=gHades->getCurrentEvent()->getCategory(catStart2Hit);
  if (!pStartHitCat) Warning("init","Start hit level not defined; setting start time to 0");

  // Create category for calibrated data
  pCalCat=gHades->getCurrentEvent()->getCategory(catRpcCal);
  if (!pCalCat) {
    Error("init","No RpcCal Category");
    return kFALSE;
  }
  // Create category for embedded data
  if(gHades->getEmbeddingMode()>0) {
    pCalCatTmp = gHades->getCurrentEvent()->getCategory(catRpcCalTmp);
    if (!pCalCatTmp) {
      Error("init","No RpcCalTmp Category for embedding, whereas EmbeddingMode Flag ACTIVE!");
      return kFALSE;
    }
  }

  // Decide whether we are running for simulation or real data  (also useful for embedding mode!!!)
  HCategory* catKin=gHades->getCurrentEvent()->getCategory(catGeantKine);

  if(catKin) simulation=kTRUE;
  else       simulation=kFALSE;

  // Create category for hit data
  pHitCat=gHades->getCurrentEvent()->getCategory(catRpcHit);

  if (!pHitCat) {

    if (simulation)
      pHitCat=rpc->buildMatrixCategory("HRpcHitSim",0.5);
    else   pHitCat=rpc->buildMatrixCategory("HRpcHit",0.5);

    gHades->getCurrentEvent()->addCategory(catRpcHit,pHitCat,"Rpc");
  }

  // This is not used at all!! Can be removed
  if( simulation ) {
    pGeantRpcCat = gHades->getCurrentEvent()->getCategory(catRpcGeantRaw);
    if (!pGeantRpcCat) {
      Error("HRpcHitF::init()","No HGeant RPC Category");
      return kFALSE;
    }
  }

  iter=(HIterator *)pCalCat->MakeIterator();
  loc.set(3,0,0,0);

  return kTRUE;
}

Int_t HRpcHitF::execute(void)
{
  Float_t tof, charge, xCell, yCell, xSec, ySec, zSec, xMod, yMod, zMod, xLab, yLab, zLab;//[ns], [pC],[mm]
  Float_t D,HD,HDT,XL,W;
  Float_t startTime; //[ns]
  Float_t startTimeSmearing; //[ns]
  Float_t leftT, rightT;
  const Float_t rad2deg = 180./TMath::Pi();
  const Float_t ovang=TMath::Tan(24.5/rad2deg);
  const Float_t invsqrt12=1./TMath::Sqrt(12.);
  Float_t theta, phi; //[degrees]
  Float_t sigma_X, sigma_Y, sigma_Z, sigma_T;
  Float_t vprop, DPlanes; //[mm/ns], [mm], [mm]
  Int_t trackL[10], trackR[10], trackLDgtr[10], trackRDgtr[10];
  Bool_t isLMotherAtBox[10], isRMotherAtBox[10];

  // New RpcDigiPar params.
  // sigma_T = sigma0_T+sigma1_T/(1.+TMath::Exp(-sigma2_T*(1.-sigma3_T))); beta = 1, the worst possible case.
  Float_t sigma0_T, sigma1_T, sigma2_T, sigma3_T;
  sigma0_T    = (pDigiPar->getSigmaT())  / 1000.;                      //[ns]
  sigma1_T    = (pDigiPar->getSigmaT1()) / 1000.;                      //[ns]
  sigma2_T    = (pDigiPar->getSigmaT2());                              //pure number
  sigma3_T    = (pDigiPar->getSigmaT3());                              //pure number

  HRpcCalSim *pCal       = NULL; //Only reading, use the same class for HRpcCalSim and HRpcCal objects
  HRpcHitSim *pHitSim    = NULL; //Reading and STORING in category, use 2 different classes.
  HRpcHit    *pHit       = NULL; //Reading and STORING in category, use 2 different classes.
  HStart2Hit *pStartH    = NULL; //Start Hit object

  HGeomVector  rRpcInMod;
  HGeomVector2 rRpcInLab,rRpcInSec;
  //HGeomVector rRpcInLab;

  Float_t fQcut = pHitFPar->getQcut();

  //Getting start time. Only for real data!
  startTime         = 0.0;
  startTimeSmearing = 0.0;

  if (pStartHitCat && pStartHitCat->getEntries()>0) {
      if((pStartH = (HStart2Hit *) pStartHitCat->getObject(0)) != NULL) {
	    startTime = pStartH->getTime();
	    if(pStartH->getResolution()!=-1000) startTimeSmearing = pStartH->getResolution();
	}
  }



  if(gHades->getEmbeddingMode()>0 && gHades->getEmbeddingDebug()==1) pCalCat->Clear();  // remove real data in embedding ==3
  iter->Reset();

  while ((pCal = (HRpcCalSim *)iter->Next())!= NULL) {   // real data  or pure simulation objects

    loc[0] = pCal->getSector();
    loc[1] = pCal->getColumn();
    loc[2] = pCal->getCell();

    //Skip deactivated cells
    if (pCellStatusPar->getCellStatus(loc[0],loc[1],loc[2])!=1) continue;

    //Getting cell geometry params for cell dimensions and operations inside the module.

    DPlanes = pGeomCellPar->getDPlanes();
    vprop   = pDigiPar->getVprop();

    //Find object RpcHit

    if (simulation) {
      pHitSim = (HRpcHitSim*)pHitCat->getSlot(loc);
      if ( !pHitSim ) {
	Error ("execute()", "Can't get slot in hit finder: sec %i, col %i, cell %i",loc[0],loc[1],loc[2]);
	return EXIT_FAILURE;
      }
      pHitSim = new(pHitSim) HRpcHitSim;
    }
    else {
      pHit = (HRpcHit*)pHitCat->getSlot(loc);
      if ( !pHit ) {
	Error ("execute()", "Can't get slot in hit finder: sec %i, col %i, cell %i",loc[0],loc[1],loc[2]);
	return EXIT_FAILURE;
      }
      pHit = new(pHit) HRpcHit;
    }

    //Change to cell coordinate system (with origin at the cell center)
    D   =  pGeomCellPar->getLength(loc[1],loc[2]);    // Cell length in mm
    HD  =  0.5*D;                                     // Cell half length in mm
    HDT =  HD/vprop;                                  // Cell half length in ns
    XL  =  pGeomCellPar->getX(loc[1],loc[2]);         // Coordinates of cell LEFT corner in mm
    W   =  pGeomCellPar->getWidth(loc[1],loc[2]);     // Cell width in mm

    //Calculate the variables for filling the object RpcHit

    charge = 0.5*( pCal->getRightCharge() + pCal->getLeftCharge() );

    //
    //REAL DATA
    //
    if(!simulation || gHades->getEmbeddingMode()>0 ) {
      //conversion from tdc width to fC
      charge = pWtoQPar->getPar0() + pWtoQPar->getPar1()*charge +
	pWtoQPar->getPar2()*charge*charge +
	pWtoQPar->getPar3()*TMath::Power(charge,3) +
	pWtoQPar->getPar4()*TMath::Power(charge,4) +
	pWtoQPar->getPar5()*TMath::Power(charge,5);
      xCell  = pCal->getRightTime()*vprop;  // FIXME in analysis: temporary!!!!!!
      tof    = pCal->getLeftTime() - HDT;   // FIXME in analysis: temporary!!!!!!
      tof   -= startTime;
      //Applying Slewing Correction

      if(charge<fQcut) {
	const Float_t *params = pSlewingPar->getExpo1(loc[0],loc[1],loc[2]);
	tof = tof - (params[0] + params[1]*exp(charge*params[2]));
      } else {
	const Float_t *params = pSlewingPar->getExpo2(loc[0],loc[1],loc[2]);
	tof = tof - (params[0] + params[1]*exp(charge*params[2]));
      }

      //correction of the position - time correlation
      const Float_t *parPos =  pTimePosPar->getPars(loc[0],loc[1],loc[2]);
      tof -= parPos[1]*sin(pCal->getRightTime()*parPos[2]+parPos[3]) +
	parPos[4]*sin(pCal->getRightTime()*parPos[5]+parPos[6]) +
	parPos[7]*sin(pCal->getRightTime()*parPos[8]+parPos[9]) +
	parPos[10]*sin(pCal->getRightTime()*parPos[11]+parPos[12]) +
	parPos[13]*sin(pCal->getRightTime()*parPos[14]+parPos[15]);

      //
      //SIMULATION
      //
    } else {
	tof    = 0.5*( pCal->getRightTime() + pCal->getLeftTime()   ) - HDT;
        tof   -= startTimeSmearing;
	xCell  = 0.5*( pCal->getLeftTime() - pCal->getRightTime()  )*vprop;
    }

    yCell  = 0.5*W;

    xMod   = XL - HD - xCell;
    yMod   = pGeomCellPar->getY(loc[1],loc[2]) + yCell;
    zMod   = DPlanes*(loc[1]%2-0.5);

    rRpcInMod.setX(xMod);
    rRpcInMod.setY(yMod);
    rRpcInMod.setZ(zMod);

    //Flag for cell outliers
    Bool_t isInsideCell = kTRUE;
    Float_t extra    = W * ovang;
    Float_t minRange = XL-D-extra;
    Float_t maxRange = XL+extra;

    if(xMod<minRange || xMod>maxRange) isInsideCell = kFALSE;


    //Lab system: all sectors in Lab
    HGeomTransform& TransRpc2Lab = pRpcGeometry->getModule(loc[0],0)->getLabTransform();
    rRpcInLab = TransRpc2Lab.transFrom(rRpcInMod);

    xLab = rRpcInLab.getX();
    yLab = rRpcInLab.getY();
    zLab = rRpcInLab.getZ();

    //Sec system: all sectors referred as sector 0
    HGeomTransform &TransRpc2Sec = pSpecGeomPar->getSector(loc[0])->getTransform();
    rRpcInSec = TransRpc2Sec.transTo(rRpcInLab);

    xSec = rRpcInSec.getX();
    ySec = rRpcInSec.getY();
    zSec = rRpcInSec.getZ();

    theta = rad2deg * TMath::ATan2(TMath::Sqrt(xLab*xLab+yLab*yLab),zLab);
    phi   = rad2deg * TMath::ATan2(yLab,xLab);
    if (phi < 0.) phi += 360.;

    //Obtain the resolutions from both the digitizer info and the geometrical one
    sigma_X = pDigiPar->getSigmaX();

    //sigma_T = pDigiPar->getSigmaT()/1000; OLD VERSION of RpcDigiPar
    if((sigma1_T<=0.)||(sigma2_T<=0.)||(sigma3_T<=0.)) {
      // Digitizing model I.
      sigma_T=sigma0_T;
    } else {
      // Digitizing model II.
      sigma_T = sigma0_T+sigma1_T/(1.+TMath::Exp(-sigma2_T*(1.-sigma3_T)));
    }

    sigma_Z = (pGeomCellPar->getDeltaZ())*invsqrt12;
    sigma_Y = W*invsqrt12;

    //Fill the Hit

    if(simulation && gHades->getEmbeddingMode()==0) {    // pure simulation
      pHitSim->setAddress(pCal->getAddress());
      pHitSim->setHit(tof,charge,xMod,yMod,zMod);
      pHitSim->setXSec(xSec);
      pHitSim->setYSec(ySec);
      pHitSim->setZSec(zSec);
      pHitSim->setXYZLab(xLab,yLab,zLab);
      pHitSim->setRMS(sigma_T, sigma_X, sigma_Y, sigma_Z);
      pHitSim->setTheta(theta);
      pHitSim->setPhi(phi);
      pHitSim->setInsideCellFlag(isInsideCell);

      pHitSim->setRefL(pCal->getRefL());
      pHitSim->setRefR(pCal->getRefR());
      pHitSim->setRefLDgtr(pCal->getRefLDgtr());
      pHitSim->setRefRDgtr(pCal->getRefRDgtr());

      pCal->getLisAtBoxArray(isLMotherAtBox);
      pCal->getRisAtBoxArray(isRMotherAtBox);
      pCal->getTrackLArray(trackL);
      pCal->getTrackRArray(trackR);
      pCal->getTrackLDgtrArray(trackLDgtr);
      pCal->getTrackRDgtrArray(trackRDgtr);

      pHitSim->setLisAtBoxArray(isLMotherAtBox);
      pHitSim->setRisAtBoxArray(isRMotherAtBox);
      pHitSim->setTrackLArray(trackL);
      pHitSim->setTrackRArray(trackR);
      pHitSim->setTrackLDgtrArray(trackLDgtr);
      pHitSim->setTrackRDgtrArray(trackRDgtr);

    } else if (gHades->getEmbeddingMode()>0) {           // real data embedding
      pHitSim->setAddress(pCal->getAddress());
      pHitSim->setHit(tof,charge,xMod,yMod,zMod);
      pHitSim->setXSec(xSec);
      pHitSim->setYSec(ySec);
      pHitSim->setZSec(zSec);
      pHitSim->setXYZLab(xLab,yLab,zLab);
      pHitSim->setRMS(sigma_T, sigma_X, sigma_Y, sigma_Z);
      pHitSim->setTheta(theta);
      pHitSim->setPhi(phi);
      pHitSim->setInsideCellFlag(isInsideCell);

      pHitSim->setRefL(gHades->getEmbeddingRealTrackId());
      pHitSim->setRefR(gHades->getEmbeddingRealTrackId());
      pHitSim->setRefLDgtr(gHades->getEmbeddingRealTrackId());
      pHitSim->setRefRDgtr(gHades->getEmbeddingRealTrackId());


      for(Int_t ini = 0;ini<10; ini++) {
	trackL[ini]         = gHades->getEmbeddingRealTrackId();
	trackR[ini]         = gHades->getEmbeddingRealTrackId();
	trackLDgtr[ini]     = gHades->getEmbeddingRealTrackId();
	trackRDgtr[ini]     = gHades->getEmbeddingRealTrackId();
	isLMotherAtBox[ini] = kFALSE;
	isRMotherAtBox[ini] = kFALSE;
      }

      pHitSim->setLisAtBoxArray(isLMotherAtBox);
      pHitSim->setRisAtBoxArray(isRMotherAtBox);
      pHitSim->setTrackLArray(trackL);
      pHitSim->setTrackRArray(trackR);
      pHitSim->setTrackLDgtrArray(trackLDgtr);
      pHitSim->setTrackRDgtrArray(trackRDgtr);
    }
    else {       // real data
      pHit->setAddress(pCal->getAddress());
      pHit->setLogBit(pCal->getLogBit());
      pHit->setHit(tof,charge,xMod,yMod,zMod);
      pHit->setXSec(xSec);
      pHit->setYSec(ySec);
      pHit->setZSec(zSec);
      pHit->setXYZLab(xLab,yLab,zLab);
      pHit->setRMS(sigma_T, sigma_X, sigma_Y, sigma_Z);
      pHit->setTheta(theta);
      pHit->setPhi(phi);
      pHit->setInsideCellFlag(isInsideCell);
    }

  }
  // --------------------------------------------------------------
  // Repeat procedure for embedded mode (read from the temporary category)
  if(gHades->getEmbeddingMode()>0) {
    for( Int_t j = 0; j < pCalCatTmp->getEntries(); j++ ) {
      // This category Stores olways HitSim objects!
      // Location index:
      // pCal was already CalSim, we can recycle it
      pCal = (HRpcCalSim*) pCalCatTmp->getObject(j);
      if(!pCal) continue;

      loc[0] = pCal->getSector();
      loc[1] = pCal->getColumn();
      loc[2] = pCal->getCell();

      if (pCellStatusPar->getCellStatus(loc[0],loc[1],loc[2])!=1) continue;

      // Lets alocate the pHitSimTmp. At the end the information have to be or copied either combined with real hits
      HRpcHitSim pHitSimTmp;

      //Getting cell geometry params for cell dimensions and operations inside the module.

      DPlanes = pGeomCellPar->getDPlanes();
      vprop   = pDigiPar->getVprop();


      //Change to cell coordinate system (with origin at the cell center)
      D   =  pGeomCellPar->getLength(loc[1],loc[2]);    // Cell length in mm
      HD  =  0.5*D;                                     // Cell half length in mm
      HDT =  HD/vprop;                                  // Cell half length in ns
      XL  =  pGeomCellPar->getX(loc[1],loc[2]);         // Coordinates of cell LEFT corner in mm
      W   =  pGeomCellPar->getWidth(loc[1],loc[2]);     // Cell width in mm

      //Calculate the variables for filling the object RpcHit

      charge = 0.5*( pCal->getRightCharge() + pCal->getLeftCharge() );

      tof    = 0.5*( pCal->getRightTime() + pCal->getLeftTime()   ) - HDT;
      tof   -= startTimeSmearing;
      xCell  = 0.5*( pCal->getLeftTime() - pCal->getRightTime()  )*vprop;
      yCell  = 0.5*W;


      xMod   = XL - HD - xCell;
      yMod   = pGeomCellPar->getY(loc[1],loc[2]) + yCell;
      zMod   = DPlanes*(loc[1]%2-0.5);

      rRpcInMod.setX(xMod);
      rRpcInMod.setY(yMod);
      rRpcInMod.setZ(zMod);

      //Flag for cell outliers
      Bool_t isInsideCell = kTRUE;
      Float_t extra    = W * ovang;
      Float_t minRange = XL-D-extra;
      Float_t maxRange = XL+extra;

      if(xMod<minRange || xMod>maxRange) isInsideCell = kFALSE;


      //Lab system: all sectors in Lab
      HGeomTransform& TransRpc2Lab = pRpcGeometry->getModule(loc[0],0)->getLabTransform();
      rRpcInLab = TransRpc2Lab.transFrom(rRpcInMod);

      xLab = rRpcInLab.getX();
      yLab = rRpcInLab.getY();
      zLab = rRpcInLab.getZ();

      //Sec system: all sectors referred as sector 0
      HGeomTransform &TransRpc2Sec = pSpecGeomPar->getSector(loc[0])->getTransform();
      rRpcInSec = TransRpc2Sec.transTo(rRpcInLab);

      xSec = rRpcInSec.getX();
      ySec = rRpcInSec.getY();
      zSec = rRpcInSec.getZ();

      theta = rad2deg * TMath::ATan2(TMath::Sqrt(xLab*xLab+yLab*yLab),zLab);
      phi   = rad2deg * TMath::ATan2(yLab,xLab);
      if (phi < 0.) phi += 360.;

      //Obtain the resolutions from both the digitizer info and the geometrical one
      sigma_X = pDigiPar->getSigmaX();

      //sigma_T = pDigiPar->getSigmaT()/1000; OLD VERSION of RpcDigiPar
      if((sigma1_T<=0.)||(sigma2_T<=0.)||(sigma3_T<=0.)) {
	// Digitizing model I.
	sigma_T=sigma0_T;
      } else {
	// Digitizing model II.
	sigma_T = sigma0_T+sigma1_T/(1.+TMath::Exp(-sigma2_T*(1.-sigma3_T)));
      }

      sigma_Z = (pGeomCellPar->getDeltaZ())*invsqrt12;
      sigma_Y = W*invsqrt12;

      pHitSimTmp.setAddress(pCal->getAddress());
      pHitSimTmp.setHit(tof,charge,xMod,yMod,zMod);
      pHitSimTmp.setXSec(xSec);
      pHitSimTmp.setYSec(ySec);
      pHitSimTmp.setZSec(zSec);
      pHitSimTmp.setXYZLab(xLab,yLab,zLab);
      pHitSimTmp.setRMS(sigma_T, sigma_X, sigma_Y, sigma_Z);
      pHitSimTmp.setTheta(theta);
      pHitSimTmp.setPhi(phi);
      pHitSimTmp.setInsideCellFlag(isInsideCell);

      pHitSimTmp.setRefL(pCal->getRefL());
      pHitSimTmp.setRefR(pCal->getRefR());
      pHitSimTmp.setRefLDgtr(pCal->getRefLDgtr());
      pHitSimTmp.setRefRDgtr(pCal->getRefRDgtr());

      pCal->getLisAtBoxArray(isLMotherAtBox);
      pCal->getRisAtBoxArray(isRMotherAtBox);
      pCal->getTrackLArray(trackL);
      pCal->getTrackRArray(trackR);
      pCal->getTrackLDgtrArray(trackLDgtr);
      pCal->getTrackRDgtrArray(trackRDgtr);

      pHitSimTmp.setLisAtBoxArray(isLMotherAtBox);
      pHitSimTmp.setRisAtBoxArray(isRMotherAtBox);
      pHitSimTmp.setTrackLArray(trackL);
      pHitSimTmp.setTrackRArray(trackR);
      pHitSimTmp.setTrackLDgtrArray(trackLDgtr);
      pHitSimTmp.setTrackRDgtrArray(trackRDgtr);


      // Let check wether there is already a hit at this location, otherwise create alocate new memory

      pHitSim = (HRpcHitSim*) pHitCat-> getObject(loc);
      if(pHitSim && gHades->getEmbeddingMode()!=2 ) {  // embedding mode == 2 -> keep geanthits

	// an rpc hit was already stored!
	// We have to merge

	// Getting left and right time of the real hit


	rightT =  (pHitSim->getTof() + HDT) -   (XL - HD -pHitSim->getXMod())/vprop  ;
	leftT  =  (pHitSim->getTof() + HDT) +   (XL - HD -pHitSim->getXMod())/vprop  ;


	if(pCal->getRightTime()<rightT && pCal->getLeftTime()<leftT ) {
	  //!!OVERWRITE!! the real with the atributes of the embedded
	  new (pHitSim) HRpcHitSim(pHitSimTmp);
	}

	if(pCal->getRightTime()<rightT && pCal->getLeftTime()>leftT) {
	  // Combine BOTH Hits. Q should be the sum of BOTH!


	  pHitSim->setRisAtBoxArray(isRMotherAtBox);
	  pHitSim->setTrackRArray(trackR);
	  pHitSim->setTrackRDgtrArray(trackRDgtr);

	  //Recombine tof and position!
	  xCell  = 0.5*( pCal->getLeftTime() - rightT)*vprop;
	  xMod   = XL - HD - xCell;

	  rRpcInMod.setX(xMod);
	  rRpcInMod.setY(yMod);
	  rRpcInMod.setZ(zMod);

	  //Flag for cell outliers
	  Bool_t isInsideCell = kTRUE;
	  Float_t extra    = W * ovang;
	  Float_t minRange = XL-D-extra;
	  Float_t maxRange = XL+extra;
	  if(xMod<minRange || xMod>maxRange) isInsideCell = kFALSE;


	  //Lab system: all sectors in Lab
	  HGeomTransform& TransRpc2Lab = pRpcGeometry->getModule(loc[0],0)->getLabTransform();
	  rRpcInLab = TransRpc2Lab.transFrom(rRpcInMod);

	  xLab = rRpcInLab.getX();
	  yLab = rRpcInLab.getY();
	  zLab = rRpcInLab.getZ();

	  //Sec system: all sectors referred as sector 0
	  HGeomTransform &TransRpc2Sec = pSpecGeomPar->getSector(loc[0])->getTransform();
	  rRpcInSec = TransRpc2Sec.transTo(rRpcInLab);

	  xSec = rRpcInSec.getX();
	  ySec = rRpcInSec.getY();
	  zSec = rRpcInSec.getZ();

          theta = rad2deg * TMath::ATan2(TMath::Sqrt(xLab*xLab+yLab*yLab),zLab);
	  phi   = rad2deg * TMath::ATan2(yLab,xLab);
	  if (phi < 0.) phi += 360.;
	  pHitSim->setHit(0.5*(rightT+pCal->getLeftTime())-HDT,charge+pHitSim->getCharge(),xMod,yMod,zMod);
	  pHitSim->setXSec(xSec);
	  pHitSim->setYSec(ySec);
	  pHitSim->setZSec(zSec);
	  pHitSim->setXYZLab(xLab,yLab,zLab);
	  pHitSim->setTheta(theta);
	  pHitSim->setPhi(phi);
	  pHitSim->setInsideCellFlag(isInsideCell);

	}

	if (pCal->getRightTime()>rightT && pCal->getLeftTime()<leftT) {
	  // Combine BOTH Hits. Q should be the sum of BOTH!

	  pHitSim->setLisAtBoxArray(isLMotherAtBox);
	  pHitSim->setTrackLArray(trackL);
	  pHitSim->setTrackLDgtrArray(trackLDgtr);

	  //Recombine tof and position!
	  xCell  = 0.5*( leftT -  pCal->getRightTime())*vprop;
	  xMod   = XL - HD - xCell;

	  rRpcInMod.setX(xMod);
	  rRpcInMod.setY(yMod);
	  rRpcInMod.setZ(zMod);

	  //Flag for cell outliers
	  Bool_t isInsideCell = kTRUE;
	  Float_t extra    = W * ovang;
	  Float_t minRange = XL-D-extra;
	  Float_t maxRange = XL+extra;

	  if(xMod<minRange || xMod>maxRange) isInsideCell = kFALSE;


	  //Lab system: all sectors in Lab
	  HGeomTransform& TransRpc2Lab = pRpcGeometry->getModule(loc[0],0)->getLabTransform();
	  rRpcInLab = TransRpc2Lab.transFrom(rRpcInMod);

	  xLab = rRpcInLab.getX();
	  yLab = rRpcInLab.getY();
	  zLab = rRpcInLab.getZ();

	  //Sec system: all sectors referred as sector 0
	  HGeomTransform &TransRpc2Sec = pSpecGeomPar->getSector(loc[0])->getTransform();
	  rRpcInSec = TransRpc2Sec.transTo(rRpcInLab);

	  xSec = rRpcInSec.getX();
	  ySec = rRpcInSec.getY();
	  zSec = rRpcInSec.getZ();

          theta = rad2deg * TMath::ATan2(TMath::Sqrt(xLab*xLab+yLab*yLab),zLab);
	  phi   = rad2deg * TMath::ATan2(yLab,xLab);
	  if (phi < 0.) phi += 360.;
	  pHitSim->setHit(0.5*(rightT+pCal->getLeftTime())-HDT,charge+pHitSim->getCharge(),xMod,yMod,zMod);
	  pHitSim->setXSec(xSec);
	  pHitSim->setYSec(ySec);
	  pHitSim->setZSec(zSec);
	  pHitSim->setXYZLab(xLab,yLab,zLab);
	  pHitSim->setTheta(theta);
	  pHitSim->setPhi(phi);
	  pHitSim->setInsideCellFlag(isInsideCell);

	  pHitSim->setHit(0.5*(leftT+pCal->getRightTime())-HDT,charge+pHitSim->getCharge(),xMod,yMod,zMod);
	}
      } else {
	//Just copy the temporal hit to the output
	pHitSim = (HRpcHitSim*) pHitCat ->getSlot(loc);
	if(pHitSim){
	    new (pHitSim) HRpcHitSim(pHitSimTmp);
	}
	else {
	    Error("HRpcHitF at embedding","Could not retrieve slot in catRpcHit!");
	}

      }
    }
  }
  return EXIT_SUCCESS;
}

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