#include "muEmulationExp.h"
#include "hdebug.h"
#include "hades.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hevent.h"
#include "heventheader.h"
#include "hrichhitIPU.h"
#include "htofhit.h"
#include "hshowerhit.h"
#include "hmatrixcatiter.h"
#include "triggerinfodef.h"
#include "htriggerdetector.h"
#include "tofdef.h"
#include "showerdef.h"
#include "hlocation.h"
#include "htriggerparmulep.h"
#include "htriggerparmommap.h"
#include "hrichIPUparthresholds.h"
#include "hrichIPUparlocmax.h"
#include "hmessagemgr.h"
#include "htriggerparshowermap.h"
#include "TArrayI.h"
#include "TArrayF.h"
#include "TObjArray.h"
HMUEmulationExp::HMUEmulationExp(void)
: HMUEmulation()
{
nEmuLeptons=0;
pRich= NULL;
pTof= NULL;
pShower= NULL;
pLeptons= NULL;
iterRich=NULL;
iterTof= NULL;
iterShower=NULL;
fRichIPUParThr=NULL;
reset();
}
HMUEmulationExp::HMUEmulationExp(const Text_t *name,const Text_t *title)
: HMUEmulation(name, title)
{
nEmuLeptons=0;
pRich= NULL;
pTof= NULL;
pShower= NULL;
pLeptons= NULL;
iterRich=NULL;
iterTof= NULL;
iterShower=NULL;
fRichIPUParThr=NULL;
reset();
}
HMUEmulationExp::~HMUEmulationExp(void)
{
if(pEmuLeptons)
{
delete pEmuLeptons;
pEmuLeptons=NULL;
}
nEmuLeptons=0;
if (iterRich)
{
delete iterRich;
iterRich= NULL;
}
if (iterTof)
{
delete iterTof;
iterTof= NULL;
}
if (iterShower)
{
delete iterShower;
iterShower= NULL;
}
for(Int_t sec=0;sec<6;sec++)
{
if(thetaRich[sec])
{
delete thetaRich[sec];
thetaRich[sec] = NULL;
}
if(phiRich[sec])
{
delete phiRich[sec];
phiRich[sec] = NULL;
}
if(thetaShower[sec])
{
delete thetaShower[sec];
thetaShower[sec] = NULL;
}
if(phiShower[sec])
{
delete phiShower[sec];
phiShower[sec] = NULL;
}
if(thetaTof[sec])
{
delete thetaTof[sec];
thetaTof[sec] = NULL;
}
if(phiTof[sec])
{
delete phiTof[sec];
phiTof[sec] = NULL;
}
if(flagTof[sec])
{
delete flagTof[sec];
flagTof[sec] = NULL;
}
}
}
Bool_t HMUEmulationExp::initParContainer(HSpectrometer *spec, HRuntimeDb *rtdb)
{
if (!fRichIPUParThr)
{
fRichIPUParThr=(HRichIPUParThresholds *)rtdb->getContainer("RichIPUParThresholds");
if (fRichIPUParThr)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"RichIPU Parameters Thresholds initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"RichIPU Parameters Thresholds Initialization failed!");
return kFALSE;
}
}
fRichIPUParLmax=(HRichIPUParLocMax *)rtdb->getContainer("RichIPUParLocMax");
if (fRichIPUParLmax)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"RichIPU Parameters LocMax initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"RichIPU Parameters LocMax Initialization failed!");
return kFALSE;
}
fTrigPar=(HTriggerParMuLep *)rtdb->getContainer("TriggerParMuLep");
if (fTrigPar)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"Trigger Parameters MU Lepton Emulation initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Trigger Parameter MU Lepton Emulation Initialization failed!");
return kFALSE;
}
fTrigParMom=(HTriggerParMomMap *)rtdb->getContainer("TriggerParMomMap");
if (fTrigParMom)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"Trigger Parameters MU Momentum Mapping initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Trigger Parameter MU Momentum Mapping Initialization failed!");
return kFALSE;
}
fShowerMap = (HTriggerParShowerMap *)rtdb->getContainer("TriggerParShowerMap");
if(fShowerMap)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"Trigger Parameters Shower Mapping initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Trigger Parameter SHOWER Mapping Initialization failed!");
return kFALSE;
}
return kTRUE;
}
Bool_t HMUEmulationExp::init(void)
{
SEPERATOR_msg("*",60);
INFO_msg(10,HMessageMgr::DET_TRIGGER,"INIT of HMUEmulationExp");
HSpectrometer *spec = gHades->getSetup();
HRuntimeDb *rtdb = gHades->getRuntimeDb();
HTriggerDetector * pTrigDet = (HTriggerDetector*)gHades->getSetup()->getDetector("Trigger");
HEvent *event = gHades->getCurrentEvent();
pEventHeader = event->getHeader();
if (pTrigDet)
{
if(!initParContainer(spec,rtdb))
{
return kFALSE;
}
}
if((pRich=event->getCategory(catHardRichHit))==NULL)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Category HRichHit not found!");
return kFALSE;
}
iterRich = (HIterator*)pRich->MakeIterator("native");
if((pTof=event->getCategory(catTofHit))==NULL)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Category HTofHit not found!");
return kFALSE;
}
iterTof = (HIterator*)pTof->MakeIterator("native");
if((pShower=event->getCategory(catShowerHit))==NULL)
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Category HShowerHit not found!");
return kFALSE;
}
iterShower = (HIterator*)pShower->MakeIterator("native");
pLeptons=event->getCategory(catMUEMULeptons);
if(!pLeptons)
{
pLeptons=pTrigDet->buildCategory(catMUEMULeptons);
if (!pLeptons)
{
return kFALSE;
}
else
{
event->addCategory(catMUEMULeptons, pLeptons, "EmuLeptons");
}
}
SEPERATOR_msg("*",60);
return kTRUE;
}
void HMUEmulationExp::prepareInput(void)
{
Int_t sector;
Int_t size;
HRichHitIPU *pMURich=NULL;
HTofHit *pMUTof=NULL;
HShowerHit *pMUShower=NULL;
iterRich->Reset();
size = pRich->getEntries();
for(Int_t sec=0;sec<6;sec++)
{
thetaRich[sec]->Set(size);
phiRich[sec]->Set(size);
thetaTof[sec]->Set(size);
phiTof[sec]->Set(size);
}
while ((pMURich = (HRichHitIPU *)iterRich->Next()) != 0)
{
sector = pMURich->getSector();
if(nRichHits[sector]>=size)
{
Error("prepareInput()","rich nHits >= size of array in event %i sequence number %i !",
gHades->getEventCounter(),
gHades->getCurrentEvent()->getHeader()->getEventSeqNumber());
break;
}
if((nRichHits[sector] < 600) && (nRichHits[sector] < size))
{
thetaRich[sector]->AddAt(pMURich->getTheta(),nRichHits[sector]);
phiRich[sector]->AddAt(pMURich->getPhi(),nRichHits[sector]);
nRichHits[sector]++;
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Maximum number of hits in RICH exceeded, skipping rest of event!");
break;
}
}
Float_t phi_tof, theta_tof;
iterTof->Reset();
iterTof->Reset();
size = pTof->getEntries();
for(Int_t sec=0;sec<6;sec++)
{
thetaTof[sec]->Set(size);
phiTof[sec]->Set(size);
flagTof[sec]->Set(size);
}
while ((pMUTof = (HTofHit *)iterTof->Next()) != 0)
{
sector = pMUTof->getSector();
if(nTofHits[sector]>=size)
{
Error("prepareInput()","tof nHits >= size of array in event %i sequence number %i !",
gHades->getEventCounter(),
gHades->getCurrentEvent()->getHeader()->getEventSeqNumber());
break;
}
if((nTofHits[sector] < 600) && (nTofHits[sector] < size))
{
pMUTof->getPhi(phi_tof);
pMUTof->getTheta(theta_tof);
phiTof[sector]->AddAt(phi_tof,nTofHits[sector]);
thetaTof[sector]->AddAt(theta_tof,nTofHits[sector]);
if (pMUTof->getTof() < fTrigPar->getMUtof())
{
flagTof[sector]->AddAt(1,nTofHits[sector]);
}
else
{
flagTof[sector]->AddAt(0,nTofHits[sector]);
}
nTofHits[sector]++;
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Maximum number of hits in Tof exceeded, skipping rest of event!");
break;
}
}
Float_t phi_shower, theta_shower;
iterShower->Reset();
size = pShower->getEntries();
for(Int_t sec=0;sec<6;sec++)
{
thetaShower[sec]->Set(size);
phiShower[sec]->Set(size);
}
while ((pMUShower = (HShowerHit *)iterShower->Next()) != 0)
{
sector = pMUShower->getSector();
if(nShowerHits[sector]>=size)
{
Error("prepareInput()","shower nHits >= size of array in event %i sequence number %i !",
gHades->getEventCounter(),
gHades->getCurrentEvent()->getHeader()->getEventSeqNumber());
break;
}
if((nShowerHits[sector] < 600) && (nShowerHits[sector]< size))
{
phi_shower = fShowerMap->getShowerPhi(pMUShower->getCol(),pMUShower->getRow());
theta_shower = fShowerMap->getShowerTheta(pMUShower->getCol(),pMUShower->getRow());
phiShower[sector]->AddAt(phi_shower,nShowerHits[sector]);
thetaShower[sector]->AddAt(theta_shower,nShowerHits[sector]);
nShowerHits[sector]++;
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Maximum number of hits in SHOWER exceeded, skipping rest of event!");
break;
}
}
}
Bool_t HMUEmulationExp::finalize(void)
{
return kTRUE;
}
ClassImp(HMUEmulationExp)
Last change: Sat May 22 12:59:18 2010
Last generated: 2010-05-22 12:59
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.