#include "hhyplistfillerinclusive.h"
#include "hhyplistfiller.h"
#define DEBUG 0
#define N_ALG 4 // Runge Kutta
#define MAX_N_PAR 8 // maximal number of one-sign leptons/hadrons
using namespace std;
ClassImp(HHypListFillerInclusive)
HHypListFillerInclusive::HHypListFillerInclusive(const Text_t * name,const Text_t * title):
HReconstructor(name, title)
{
nElectron = 0;
nPositron = 0;
nNegPion = 0;
nPosPion = 0;
nProton = 0;
numberOfParticles = 0;
}
HHypListFillerInclusive::HHypListFillerInclusive()
{
nElectron = 0;
nPositron = 0;
nNegPion = 0;
nPosPion = 0;
nProton = 0;
numberOfParticles = 0;
}
HHypListFillerInclusive::~HHypListFillerInclusive(void)
{
}
Bool_t HHypListFillerInclusive::SetExitList(Int_t e_list)
{
exitList = e_list;
return kTRUE;
}
Bool_t HHypListFillerInclusive::init()
{
if(DEBUG) cerr <<" with option : DEBUG"<<endl<<endl;
m_pContCatComb = gHades->getCurrentEvent()->getCategory(catHypComb);
if (!m_pContCatComb) {
m_pContCatComb = HHypComb::buildLinearCat("HHypComb");
if (!m_pContCatComb)
return kFALSE;
gHades->getCurrentEvent()->addCategory(catHypComb, m_pContCatComb,
"HypComb");
}
m_pContCatList = gHades->getCurrentEvent()->getCategory(catHypList);
if (!m_pContCatList) {
m_pContCatList = HHypList::buildLinearCat("HHypList");
if (!m_pContCatList)
return kFALSE;
gHades->getCurrentEvent()->addCategory(catHypList, m_pContCatList,
"HypList");
}
m_pContItPart = NULL;
m_pContCatPart = NULL;
if ((m_pContCatPart =
gHades->getCurrentEvent()->getCategory(catPidTrackCand)) == NULL) {
Error("init", "Cannot get catPidTrackCand cat");
return kFALSE;
}
m_pContItPart = (HIterator *) m_pContCatPart->MakeIterator();
nHadronPlus = nPosPion + nProton;
nHadronMinus = nNegPion;
nLeptonPlus = nPositron;
nLeptonMinus = nElectron;
nLepton = nPositron + nElectron;
if(DEBUG) cerr<<" nHadronPlus : "<<nHadronPlus<<endl
<<" nHadronMinus : "<<nHadronMinus<<endl
<<" nLeptonPlus : "<<nLeptonPlus<<endl
<<" nLeptonMinus : "<<nLeptonMinus<<endl
<<" nLepton : "<<nLepton<<endl;
return kTRUE;
}
Int_t HHypListFillerInclusive::execute()
{
Int_t index_comb = 0;
Int_t index_list = 0;
HLocation locDummy;
counterHadronPlus = 0;
counterHadronMinus = 0;
counterLeptonPlus = 0;
counterLeptonMinus = 0;
Int_t counter = 0;
Int_t Charge[HYP_MAX_TRACKCLEAN];
for(Int_t kk=0;kk<HYP_FILLINCL_LIMIT;kk++)
{
PosHadronIdx[kk] = -1;
NegHadronIdx[kk] = -1;
PositronIdx[kk] = -1;
ElectronIdx[kk] = -1;
LeptonIdx[kk] = -1;
}
const HPidHitData *pidHitData = NULL;
const HPidTrackData *PidTrack = NULL;
HPidTrackCand *PidCand = NULL;
m_pContItPart->Reset();
while (((PidCand = (HPidTrackCand *) m_pContItPart->Next()) != NULL)
&& (counter < HYP_MAX_TRACKCLEAN))
{
pidHitData = PidCand -> getHitData();
PidTrack = PidCand -> getTrackData();
Charge[counter] = PidCand -> getTrackData()->getPolarity(ALG_RUNGEKUTTA);
if (Charge[counter]==1 && PidCand->isFlagBit(HPidTrackCand::kIsUsed) )
{
if(pidHitData->hasRingCorrelation[N_ALG])
{
if(counterLeptonPlus+counterLeptonMinus==HYP_FILLINCL_LIMIT){ cerr << "too many counterLeptonPlus+counterLeptonMinus, exit"<<endl; exit(0);};
PositronIdx[counterLeptonPlus] = counter;
LeptonIdx[counterLeptonPlus+counterLeptonMinus] = counter;
counterLeptonPlus++;
}
else if( PidCand->isFlagBit(HPidTrackCand::kIsUsed) )
{
if(counterHadronPlus==HYP_FILLINCL_LIMIT){ cerr << "too many counterHadronPlus, exit"<<endl; exit(0);};
PosHadronIdx[counterHadronPlus] = counter;
counterHadronPlus++;
}
}
if (Charge[counter]==-1 && PidCand->isFlagBit(HPidTrackCand::kIsUsed) )
{
if(pidHitData->hasRingCorrelation[N_ALG])
{
if(counterLeptonPlus+counterLeptonMinus==HYP_FILLINCL_LIMIT){ cerr << "too many counterLeptonPlus+counterLeptonMinus, exit"<<endl; exit(0);};
ElectronIdx[counterLeptonMinus] = counter;
LeptonIdx[counterLeptonPlus+counterLeptonMinus] = counter;
counterLeptonMinus++;
}
else if( PidCand->isFlagBit(HPidTrackCand::kIsUsed) )
{
if(counterHadronMinus==HYP_FILLINCL_LIMIT){ cerr << "too many counterHadronMinus, exit"<<endl; exit(0);};
NegHadronIdx[counterHadronMinus] = counter;
counterHadronMinus++;
}
}
counter++;
}
numberOfParticles=counterLeptonPlus+counterHadronPlus+counterLeptonMinus+counterHadronMinus;
counterLepton=counterLeptonPlus+counterLeptonMinus;
if ( counterHadronPlus >= nHadronPlus && counterHadronPlus < MAX_N_PAR &&
counterHadronMinus>= nHadronMinus && counterHadronMinus< MAX_N_PAR &&
(counterLeptonMinus + counterLeptonPlus)>= nLepton &&
(counterLeptonMinus + counterLeptonPlus)< MAX_N_PAR )
{
HHypComb *hypcomb = NULL;
if(DEBUG) cerr<<
" counterHadronPlus: "<<counterHadronPlus<<
" counterHadronMinus: "<<counterHadronMinus<<
" counterLeptonPlus: "<<counterLeptonPlus<<
" counterLeptonMinus: "<<counterLeptonMinus<<endl;
numberOfCombinations = CalculateNComb(counterHadronPlus, nHadronPlus, nProton);
numberOfCombinations *= CalculateNComb(counterLeptonMinus + counterLeptonPlus, nLepton, nLepton);
if(DEBUG) cerr<<" numberOfCombinations: "<<numberOfCombinations<<
" nHadronPlus: "<<nHadronPlus<<
" nHadronMinus: "<<nHadronMinus<<
" nLeptonPlus: "<<nLeptonPlus<<
" nLeptonMinus: "<<nLeptonMinus<<
" nLepton: "<<nLepton<<endl;
hypcomb = (HHypComb *) m_pContCatComb->getNewSlot(locDummy, &index_comb);
if (hypcomb != 0)
hypcomb = new(hypcomb) HHypComb(numberOfCombinations,
nHadronPlus + nHadronMinus + nLeptonPlus + nLeptonMinus);
else
return ERROR_IDX;
fill_pid_table(hypcomb);
fill_pid_idx(hypcomb);
HHypList *hyplist = NULL;
hyplist = (HHypList *) m_pContCatList->getNewSlot(locDummy, &index_list);
if (hyplist != 0)
hyplist = new(hyplist) HHypList(index_comb);
else
return ERROR_IDX;
hyplist->setListId(exitList);
for (Int_t Icomb = 0; Icomb < numberOfCombinations; Icomb++) {
if (Icomb < MAX_USER_VALUES)
hyplist->setUserValue(FILLER_VALID_PIDTRACKS, numberOfParticles,
Icomb);
}
}
else {
return ERROR_IDX;
}
return index_list;
}
Bool_t HHypListFillerInclusive::finalize()
{
return kTRUE;
}
Bool_t HHypListFillerInclusive::AddTrack(Int_t particle)
{
switch(particle)
{
case 2 : nPositron++; break;
case 3 : nElectron++; break;
case 8 : nPosPion++; break;
case 9 : nNegPion++; break;
case 14 : nProton++; break;
default : cerr<<"HHypListFillerInclusive::AddTrack particle witch ID= "<<particle
<<" not implemented"<<endl; break;
}
return kTRUE;
}
void HHypListFillerInclusive::fill_pid_table(HHypComb * hypcomb)
{
if(DEBUG) cerr<<"HHypListFillerInclusive::fill_pid_table"<<endl;
for (Int_t i = 0; i < numberOfCombinations; i++) {
Int_t j=0, jj=0, jjj=0, jjjj=0, jjjjj=0;
for (j = 0; j < nProton; j++) {
hypcomb->setPid(i, j, 14);
}
for (jj = j; jj < nPosPion+j; jj++) {
hypcomb->setPid(i, jj, 8);
}
for (jjj = jj; jjj < nPositron+jj; jjj++) {
hypcomb->setPid(i, jjj, 2);
}
for (jjjj = jjj; jjjj < nNegPion+jjj; jjjj++) {
hypcomb->setPid(i, jjjj, 9);
}
for (jjjjj = jjjj; jjjjj < nElectron+jjjj; jjjjj++) {
hypcomb->setPid(i, jjjjj, 3);
}
}
}
Int_t HHypListFillerInclusive::fill_pid_idx(HHypComb * hypcomb)
{
Int_t NComb=0;
if(nHadronPlus==2 && nLepton==2)
{
if(nHadronPlus)
for(Int_t i=0; i<numberOfCombinations; i+=CalculateNComb(counterHadronPlus, nHadronPlus, nProton))
NComb=fill_pid_idx_double_part(hypcomb, counterHadronPlus,0 , i, 1, PosHadronIdx);
if(DEBUG) cerr<<"HHypListFillerInclusive::fill_pid_idx -> protons OK NComb = "<<NComb<<endl;
if(nLepton)
NComb=fill_pid_idx_double_part(hypcomb, counterLepton,2 , 0, NComb, LeptonIdx);
if(DEBUG) cerr<<"HHypListFillerInclusive::fill_pid_idx -> leptons OK NComb = "<<NComb<<endl;
}
else{
if(nHadronPlus)
for(Int_t i=0; i<numberOfCombinations; i+=CalculateNComb(counterHadronPlus, nHadronPlus, nProton))
{
if(nProton==2)
{
NComb = fill_pid_idx_double_part_first( hypcomb, counterHadronPlus,0 , 0, 1, PosHadronIdx);
NComb = fill_pid_idx_double_part_secound(hypcomb, counterHadronPlus,1 , 0, 1, PosHadronIdx);
}
else if(nProton==1 && nPosPion==1)
{
NComb = fill_pid_idx_double_part_first( hypcomb, counterHadronPlus,0 , 0, 1, PosHadronIdx);
NComb = fill_pid_idx_double_part_secound(hypcomb, counterHadronPlus,1 , 0, 1, PosHadronIdx);
NComb = fill_pid_idx_double_part_first( hypcomb, counterHadronPlus,1 , NComb, 1, PosHadronIdx);
NComb = fill_pid_idx_double_part_secound(hypcomb, counterHadronPlus,0 , NComb, 1, PosHadronIdx);
}
else NComb = fill_pid_idx_single_part(hypcomb, counterHadronPlus,0 , i, 1, PosHadronIdx);
}
if(DEBUG) cerr<<"HHypListFillerInclusive::fill_pid_idx -> protons OK NComb = "<<NComb<<endl;
if(nLepton)
{
if(nHadronPlus==2)
{
NComb=fill_pid_idx_double_part_first(hypcomb, counterLepton,2 , 0, NComb, LeptonIdx);
NComb=fill_pid_idx_double_part_secound(hypcomb, counterLepton,2 , 0, NComb, LeptonIdx);
}
else
{
NComb=fill_pid_idx_double_part(hypcomb, counterLepton,1 , 0, NComb, LeptonIdx);
}
}
}
if(DEBUG) cerr<<"HHypListFillerInclusive::fill_pid_idx -> leptons OK"<<endl;
if(DEBUG) hypcomb->print();
return NComb;
}
Int_t HHypListFillerInclusive::fill_pid_idx_double_part_first(HHypComb * hypcomb,
Int_t nTracks, Int_t iParPosition, Int_t iStartComb, Int_t Step, Int_t *pidIdx)
{
Int_t i=0;
Int_t iComb = 0;
Int_t idx = 0;
for(Int_t j = 0; j < nTracks-1; j++)
{
for (i = 0; i < nTracks-idx-1; i++)
{
for(Int_t kk=0; kk<Step; kk++)
{
hypcomb->setIdxPidTrackCand( iStartComb + iComb, iParPosition, pidIdx[idx]);
iComb++;
}
}
idx++;
}
return iComb;
}
Int_t HHypListFillerInclusive::fill_pid_idx_double_part_secound(HHypComb * hypcomb,
Int_t nTracks, Int_t iParPosition, Int_t iStartComb, Int_t Step, Int_t *pidIdx)
{
Int_t iComb = 0;
Int_t idx = 1;
for(Int_t j = 0; j < nTracks-1; j++)
{
for (Int_t i = idx; i < nTracks; i++)
{
for(Int_t kk=0; kk<Step;kk++)
{
hypcomb->setIdxPidTrackCand( iStartComb + iComb, iParPosition , pidIdx[i]);
iComb++;
}
}
idx++;
}
return iComb;
}
Int_t HHypListFillerInclusive::fill_pid_idx_double_part(HHypComb * hypcomb,
Int_t nTracks, Int_t iParPosition, Int_t iStartComb, Int_t Step, Int_t *pidIdx)
{
Int_t i=0;
Int_t iComb = 0;
Int_t idx = 0;
for(Int_t j = 0; j < nTracks-1; j++)
{
for (i = 0; i < nTracks-idx-1; i++)
{
for(Int_t kk=0; kk<Step; kk++)
{
hypcomb->setIdxPidTrackCand( iStartComb + iComb, iParPosition, pidIdx[idx]);
iComb++;
}
}
idx++;
}
iComb = 0;
idx = 1;
for(Int_t j = 0; j < nTracks-1; j++)
{
for (i = idx; i < nTracks; i++)
{
for(Int_t kk=0; kk<Step;kk++)
{
hypcomb->setIdxPidTrackCand( iStartComb + iComb, iParPosition + 1, pidIdx[i]);
iComb++;
}
}
idx++;
}
return iComb;
}
Int_t HHypListFillerInclusive::fill_pid_idx_single_part(HHypComb * hypcomb, Int_t nTracks, Int_t iParPosition,
Int_t iStartComb, Int_t iNComb,Int_t *pidIdx )
{
Int_t iComb=0;
for(Int_t idx=0; idx<nTracks; idx++)
{
for(Int_t i=0; i<iNComb; i++)
{
hypcomb->setIdxPidTrackCand( iStartComb + iComb, iParPosition , pidIdx[idx]);
iComb++;
}
}
return iComb;
}
Bool_t HHypListFillerInclusive::fill_pid_fprob(HHypComb * hypcomb,Int_t *numpidtracks)
{
for(Int_t i=0; i<numberOfCombinations; i++)
hypcomb->setProbComb(i, 1);
return kTRUE;
}
Int_t HHypListFillerInclusive::CalculateNComb(Int_t nTracksPlus,Int_t nPartPlus,Int_t nSamePartPlus)
{
static Int_t faculties[11] = {
1, 1, 2, 6,
24,
120,
720,
5040,
40320,
362880,
3628800
};
return faculties[nTracksPlus]/(faculties[nTracksPlus-nPartPlus]*faculties[nSamePartPlus]);
}
Last change: Sat May 22 12:57:51 2010
Last generated: 2010-05-22 12:57
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.