#include "muDilepEmulation.h"
#include "hades.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "hevent.h"
#include "heventheader.h"
#include "hmatchurich.h"
#include "hmatchutof.h"
#include "hmatchushower.h"
#include "hmuleptons.h"
#include "hmatrixcatiter.h"
#include "triggerinfodef.h"
#include "htriggerdetector.h"
#include "hlocation.h"
#include "hgeomvector.h"
#include "htriggerparmudilep.h"
#include "hmuEmuleptons.h"
#include "hmessagemgr.h"
Bool_t HMUDilepEmulation::initParContainer(HSpectrometer *spec, HRuntimeDb *rtdb)
{
fTrigParDil=(HTriggerParMuDilep *)rtdb->getContainer("TriggerParMuDilep");
if (fTrigParDil)
{
INFO_msg(10,HMessageMgr::DET_TRIGGER,"Trigger Parameters MU Dilepton Emulation initialized");
}
else
{
ERROR_msg(HMessageMgr::DET_TRIGGER,"Trigger Parameter MU Dilepton Emulation Initialization failed!");
return kFALSE;
}
return kTRUE;
}
HMUDilepEmulation::HMUDilepEmulation(void)
{
fTrigParDil = NULL;
pEmuDiLeptons=NULL;
nEmuDiLeptons=0;
ptlHMULeptons=NULL;
ptlHMUEMUDiLeptons=NULL;
iterHMULeptons=NULL;
iterHMULeptons2=NULL;
nLep=0;
reset();
pEmuDiLeptons = new TObjArray(2);
}
HMUDilepEmulation::HMUDilepEmulation(const Text_t *name,const Text_t *title)
: HReconstructor(name, title)
{
fTrigParDil = NULL;
pEmuDiLeptons=NULL;
nEmuDiLeptons=0;
ptlHMULeptons=NULL;
ptlHMUEMUDiLeptons=NULL;
iterHMULeptons=NULL;
iterHMULeptons2=NULL;
nLep=0;
reset();
pEmuDiLeptons = new TObjArray(2);
}
HMUDilepEmulation::~HMUDilepEmulation()
{
if(pEmuDiLeptons)
{
delete pEmuDiLeptons;
pEmuDiLeptons=NULL;
}
nEmuDiLeptons=0;
ptlHMULeptons=NULL;
ptlHMUEMUDiLeptons=NULL;
if (iterHMULeptons) delete iterHMULeptons;
iterHMULeptons=NULL;
if (iterHMULeptons2) delete iterHMULeptons2;
iterHMULeptons2=NULL;
nLep=0;
}
void HMUDilepEmulation::reset(void)
{
nLep=0;
for (Int_t h =0; h<600;h++)
{
thetaRich[h]=0;
phiRich[h]=0;
mom[h]=0;
flag[h]=0;
}
}
Bool_t HMUDilepEmulation::init(void)
{
HSpectrometer *spec = gHades->getSetup();
HRuntimeDb *rtdb = gHades->getRuntimeDb();
HTriggerDetector * pTrigDet = (HTriggerDetector*)gHades->getSetup()->getDetector("Trigger");
if (pTrigDet)
{
if(!initParContainer(spec,rtdb))
{
return kFALSE;
}
}
if((ptlHMULeptons=gHades->getCurrentEvent()->getCategory(catMatchULeptons))==NULL) return kFALSE;
iterHMULeptons = (HIterator*)ptlHMULeptons->MakeIterator("native");
ptlHMUEMUDiLeptons=gHades->getCurrentEvent()->getCategory(catMUEMUDiLeptons);
if(!ptlHMUEMUDiLeptons)
{
ptlHMUEMUDiLeptons=pTrigDet->buildCategory(catMUEMUDiLeptons);
if (!ptlHMUEMUDiLeptons)
{
return kFALSE;
}
else
{
gHades->getCurrentEvent()->addCategory(catMUEMUDiLeptons, ptlHMUEMUDiLeptons, "EmuDiLeptons");
}
}
return kTRUE;
}
Int_t HMUDilepEmulation::execute()
{
reset();
prepareInput();
searchDilep();
if (nEmuDiLeptons)
{
updateEmuDiLeptons();
}
pEmuDiLeptons->Delete();
return 0;
}
void HMUDilepEmulation::prepareInput(void)
{
HMULeptons *pLeptons =NULL;
iterHMULeptons->Reset();
while (( pLeptons = (HMULeptons *)iterHMULeptons->Next()) != 0)
{
if(nLep>599)
{
Error("prepareInput()","number of leptons >= size of array in event %i sequence number %i !",
gHades->getEventCounter(),
gHades->getCurrentEvent()->getHeader()->getEventSeqNumber());
break;
}
if (pLeptons->getMom()>0)
{
thetaRich[nLep]=pLeptons->getThetaRich();
phiRich[nLep]=pLeptons->getPhiRich();
mom[nLep]=pLeptons->getMom();
flag[nLep]=pLeptons->getFlag();
nLep++;
}
}
}
Int_t HMUDilepEmulation::searchDilep(void)
{
Int_t i1,i2;
HGeomVector pp1,pp2;
pp1=pp2=0;
nEmuDiLeptons=0;
if ( nEmuDiLeptons < fTrigParDil->getMUcutoff() )
{
i1=0;
for (Int_t act_Lep =0; act_Lep < nLep; act_Lep++)
{
i1++;
i2=0;
for (Int_t act_Lep2 =act_Lep; act_Lep2 < nLep; act_Lep2++)
{
i2++;
if ( nEmuDiLeptons < fTrigParDil->getMUcutoff() )
{
if (flag[act_Lep] != flag[act_Lep2])
{
pp1.setX( sin(thetaRich[act_Lep]* TMath::Pi()/180)*cos(phiRich[act_Lep]* TMath::Pi()/180));
pp1.setY( sin(thetaRich[act_Lep]* TMath::Pi()/180)*sin(phiRich[act_Lep]* TMath::Pi()/180));
pp1.setZ( cos(thetaRich[act_Lep]* TMath::Pi()/180) );
pp2.setX( sin(thetaRich[act_Lep2]* TMath::Pi()/180)*cos(phiRich[act_Lep2]* TMath::Pi()/180) );
pp2.setY( sin(thetaRich[act_Lep2]* TMath::Pi()/180)*sin(phiRich[act_Lep2]* TMath::Pi()/180) );
pp2.setZ( cos(thetaRich[act_Lep2]* TMath::Pi()/180) );
Float_t cOpening = pp1.scalarProduct(pp2);
Float_t openAngle=acos(cOpening);
HMUEMUDiLeptons *dilepton = new HMUEMUDiLeptons();
dilepton->setOpangle(openAngle * 180/TMath::Pi());
dilepton->setMass(2 * mom[act_Lep] * mom[act_Lep2] * (1-cOpening));
dilepton->setN1(i1);
dilepton->setN2(i2);
pEmuDiLeptons->Add(dilepton);
nEmuDiLeptons++;
}
}
}
}
}
return nEmuDiLeptons;
}
void HMUDilepEmulation::updateEmuDiLeptons()
{
HMUEMUDiLeptons *emuDiLepton=NULL;
for (Int_t i = 0; i < nEmuDiLeptons; i++)
{
loc.set(1, 0);
emuDiLepton=(HMUEMUDiLeptons *)ptlHMUEMUDiLeptons->getNewSlot(loc);
if (emuDiLepton!=NULL)
{
emuDiLepton=new(emuDiLepton) HMUEMUDiLeptons(*((HMUEMUDiLeptons*)pEmuDiLeptons->At(i)));
}
}
}
Bool_t HMUDilepEmulation::finalize(void)
{
return kTRUE;
}
ClassImp(HMUDilepEmulation)
Last change: Sat May 22 12:59:09 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.