#include "hrichanalysisIPU.h"
#include "hades.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hevent.h"
#include "richutildef.h"
#include "hrichdetector.h"
#include "hrichraw.h"
#include "hrichhitIPU.h"
#include "hrichhitIPUSim.h"
#include "hrichgeometrypar.h"
#include "hrichringfindIPU.h"
#include "triggerinfodef.h"
#include "htriggerdetector.h"
#include "hlocation.h"
#include "hmessagemgr.h"
#include <cstdlib>
HRichAnalysisIPU::HRichAnalysisIPU(void)
{
fIter = NULL;
pRings = NULL;
iRingNr = 0;
iRingNrTot = 0;
iEmulationContext = 0;
pHardRingFind = new HRichRingFindIPU();
}
HRichAnalysisIPU::HRichAnalysisIPU(const Text_t *name,const Text_t *title)
: HReconstructor(name, title)
{
fIter = NULL;
pRings = NULL;
iRingNr = 0;
iRingNrTot = 0;
iEmulationContext = 0;
pHardRingFind = new HRichRingFindIPU();
}
HRichAnalysisIPU::~HRichAnalysisIPU(void)
{
fIter = NULL;
if (pHardRingFind)
{
delete pHardRingFind;
pHardRingFind = NULL;
}
if (fIter)
{
delete fIter;
fIter = NULL;
}
}
HRichAnalysisIPU::HRichAnalysisIPU(const HRichAnalysisIPU& source)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"HRichAnalysisIPU object can not be initialized with values of another object!");
exit(-1);
}
HRichAnalysisIPU& HRichAnalysisIPU::operator=(const HRichAnalysisIPU& source)
{
if (this != &source)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"HRichAnalysisIPU object can not be assigned!");
}
return *this;
}
Bool_t HRichAnalysisIPU::init(void)
{
SEPERATOR_msg("-",60);
INFO_msg(10,HMessageMgr::DET_TRIGGER,"INIT of HRichAnalysisIPU()");
HRuntimeDb *rtdb = gHades->getRuntimeDb();
HRichDetector * pRichDet = (HRichDetector*)gHades->getSetup()->getDetector("Rich");
HTriggerDetector * pTriggerDet = (HTriggerDetector*)gHades->getSetup()->getDetector("Trigger");
if(!pRichDet)
{
return kFALSE;
}
if(!pTriggerDet)
{
return kFALSE;
}
m_pRawCat=gHades->getCurrentEvent()->getCategory(catRichRaw);
if (!m_pRawCat)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"HRichRaw category not found!");
return kFALSE;
}
fIter = (HIterator*)m_pRawCat->MakeIterator("native");
m_pHardHitCat=gHades->getCurrentEvent()->getCategory(catHardRichHit);
if (!m_pHardHitCat)
{
m_pHardHitCat=pTriggerDet->buildCategory(catHardRichHit);
if (!m_pHardHitCat)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Can not create HRichHardHit category!");
return kFALSE;
}
else
{
gHades->getCurrentEvent()->addCategory(catHardRichHit, m_pHardHitCat, "Trigger");
}
}
if(rtdb)
{
HRichGeometryPar *pGeomPar = (HRichGeometryPar*)rtdb->getContainer("RichGeometryParameters");
if (pGeomPar == NULL)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"RICH geometry parameters not found!");
return kFALSE;
}
setGeomPar(pGeomPar);
}
pHardRingFind->init(this);
if (!strcmp(pHardRingFind->checkParamContext(),"RICHIPUEmulation"))
{
gHades->getMsg()->info(10,HMessageMgr::DET_TRIGGER,GetName(),"%s %s",pHardRingFind->checkParamContext(),"is equal");
iEmulationContext = 1;
}
SEPERATOR_msg("-",60);
return kTRUE;
}
Bool_t HRichAnalysisIPU::finalize(void)
{
return kTRUE;
}
Int_t HRichAnalysisIPU::execute(void)
{
HRichRaw *pRaw;
pHardRingFind->ZeroArray();
fIter->Reset();
while((pRaw = (HRichRaw *)fIter->Next())!= NULL)
{
pHardRingFind->FiredPad(pRaw->getSector(),pRaw->getRow(),pRaw->getCol());
}
iRingNrTot=0;
for(Int_t i = 0; i < 6; i++)
{
pHardRingFind->SetSector(i);
iRingNr = pHardRingFind->Execute();
iRingNrTot+=iRingNr;
if (iRingNr)
{
if ( iEmulationContext )
{
DataWordCut(i);
}
updateHits(i);
}
}
return kTRUE;
}
void HRichAnalysisIPU::updateHits(Int_t nSec)
{
HRichHitIPU *hit=NULL;
for (Int_t i = 0; i < iRingNr; i++)
{
loc.set(1, nSec);
hit=(HRichHitIPU *)m_pHardHitCat->getNewSlot(loc);
if (hit!=NULL)
{
HRichHitIPU* myHit=((HRichHitIPUCont *)pRings->At(i))->getData();
hit=new(hit) HRichHitIPU(*myHit);
hit->setSector(nSec);
HRichPad * pad = ((HRichGeometryPar*)fpGeomPar)->getPadsPar()->
getPad(hit->getX(),hit->getY());
hit->setPhi(pad->getPhi(nSec));
hit->setTheta(pad->getTheta());
}
}
}
void HRichAnalysisIPU::DataWordCut(Int_t nSec)
{
for(Int_t jj=0; jj<iRingNr;jj++)
{
HRichHitIPU* hit=((HRichHitIPUCont*)pRings->At(jj))->getData();
hit->setY(100*hit->getY() + hit->getX());
}
HRichHitIPUSimCont::sortIncreasingOrder(kTRUE);
HRichHitIPUCont::sortIncreasingOrder(kTRUE);
Int_t size=pRings->GetLast();
if(size>=0) { pRings->Sort(size+1);}
Int_t currentNumberOfWords = 0;
Int_t newX, newY, oldX, oldY;
oldX = -111; oldY = -111;
for (Int_t jj = 0; jj <iRingNr; jj++)
{
HRichHitIPU* hit=((HRichHitIPUCont*)pRings->At(jj))->getData();
newX = hit->getX();
newY = (Int_t)hit->getY()/100;
if ( !( (newY==oldY) && (newX/8==oldX/8)) )
{
currentNumberOfWords++;
}
hit->setY(newY);
oldX = newX; oldY = newY;
hit->setDataWord(currentNumberOfWords);
if (hit->getDataWord()==999)
{
gHades->getMsg()->error(10,HMessageMgr::DET_TRIGGER,GetName(),"HELP !!!!! DataW %c",currentNumberOfWords);
}
}
}
ClassImp(HRichAnalysisIPU)
Last change: Sat May 22 13:08:07 2010
Last generated: 2010-05-22 13:08
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.