#include "hgeantkine.h"
#include "hlinearcategory.h"
#include "hlinkeddataobject.h"
#include "hgeantmdc.h"
#include "hgeanttof.h"
#include "hgeantrich.h"
#include "hgeantshower.h"
#include "hgeantrpc.h"
#include "hgeantwall.h"
#include "TRandom.h"
ClassImp(HGeantKine)
HGeantKine::HGeantKine(void) {
trackNumber = 0;
parentTrack = 0;
particleID = 0;
mediumNumber = 0;
creationMechanism = 0;
xVertex = yVertex = zVertex = 0.;
xMom = yMom = zMom = 0.;
generatorInfo = 0.;
generatorInfo1 = 0.;
generatorInfo2 = 0.;
generatorWeight = 1.;
firstRichHit = firstMdcHit = firstTofHit = firstShowerHit = firstRpcHit = firstWallHit = -1;
pRich = pMdc = pTof = pShow = pRpc = pWall = NULL;
richIndex = mdcIndex = showIndex = tofIndex = rpcIndex = wallIndex = 0;
active = kFALSE;
suppressed = kFALSE;
userVal = -1;
}
HGeantKine::HGeantKine(HGeantKine &aKine) {
trackNumber = aKine.trackNumber;
parentTrack = aKine.parentTrack;
particleID = aKine.particleID;
mediumNumber = aKine.mediumNumber;
creationMechanism = aKine.creationMechanism;
xVertex = aKine.xVertex;
yVertex = aKine.yVertex;
zVertex = aKine.zVertex;
xMom = aKine.xMom;
yMom = aKine.yMom;
zMom = aKine.zMom;
generatorInfo = aKine.generatorInfo;
generatorInfo1 = aKine.generatorInfo1;
generatorInfo2 = aKine.generatorInfo2;
generatorWeight = aKine.generatorWeight;
firstRichHit = aKine.firstRichHit;
firstMdcHit = aKine.firstMdcHit;
firstTofHit = aKine.firstTofHit;
firstRpcHit = aKine.firstRpcHit;
firstShowerHit = aKine.firstShowerHit;
firstWallHit = aKine.firstWallHit;
active = aKine.active;
suppressed = aKine.suppressed;
userVal = aKine.userVal;
}
HGeantKine::~HGeantKine(void) {
}
void HGeantKine::setParticle(Int_t aTrack, Int_t aID) {
trackNumber = aTrack;
particleID = aID;
}
void HGeantKine::setCreator(Int_t aPar, Int_t aMed, Int_t aMech) {
parentTrack = aPar;
mediumNumber = aMed;
creationMechanism = aMech;
}
void HGeantKine::setVertex(Float_t ax, Float_t ay, Float_t az) {
xVertex = ax;
yVertex = ay;
zVertex = az;
}
void HGeantKine::setMomentum(Float_t apx, Float_t apy, Float_t apz) {
xMom = apx;
yMom = apy;
zMom = apz;
}
void HGeantKine::setGenerator(Float_t aInfo, Float_t aWeight) {
generatorInfo = aInfo;
generatorWeight = aWeight;
}
void HGeantKine::setGenerator(Float_t aInfo, Float_t aInfo1, Float_t aInfo2) {
generatorInfo = aInfo;
generatorInfo1 = aInfo1;
generatorInfo2 = aInfo2;
}
void HGeantKine::getParticle(Int_t &aTrack, Int_t &aID) {
aTrack = trackNumber;
aID = particleID;
}
void HGeantKine::getCreator(Int_t &aPar, Int_t &aMed, Int_t &aMech) {
aPar = parentTrack;
aMed = mediumNumber;
aMech = creationMechanism;
}
void HGeantKine::getVertex(Float_t &ax, Float_t &ay, Float_t &az) {
ax = xVertex;
ay = yVertex;
az = zVertex;
}
void HGeantKine::getMomentum(Float_t &apx, Float_t &apy, Float_t &apz) {
apx = xMom;
apy = yMom;
apz = zMom;
}
void HGeantKine::getGenerator(Float_t &aInfo, Float_t &aWeight) {
aInfo = generatorInfo;
aWeight = generatorWeight;
}
void HGeantKine::getGenerator(Float_t &aInfo, Float_t &aInfo1, Float_t &aInfo2) {
aInfo = generatorInfo;
aInfo1 = generatorInfo1;
aInfo2 = generatorInfo2;
}
Int_t HGeantKine::getPhiThetaDeg(Float_t& theta,Float_t& phi, Bool_t labSys)
{
Float_t mom = getTotalMomentum();
theta = (mom>0.) ? (TMath::RadToDeg() * TMath::Abs(TMath::ACos(zMom / mom))) : 0.;
phi = TMath::RadToDeg() * TMath::ATan2( yMom, xMom);
if (phi < 0.) phi += 360.;
Int_t s = (phi < 60.)? 5 : ((Int_t) (phi / 60.) - 1);
if(!labSys) phi=fmod(phi,60.f)+60.;
return s;
}
void HGeantKine::setNewTrackNumber(Int_t track) {
Int_t next = 0;
HLinkedDataObject* p = NULL;
trackNumber = track;
if ( (next = (Int_t)firstMdcHit) != -1) {
resetMdcIter();
do {
p = (HLinkedDataObject*)(pMdc->getObject(next));
( (HGeantMdc*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
if ( (next = (Int_t)firstRichHit) != -1) {
resetRichIter();
do {
p = (HLinkedDataObject*)(pRich->getObject(next));
( (HGeantRichPhoton*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
if ( (next = (Int_t)firstTofHit) != -1) {
resetTofIter();
do {
p = (HLinkedDataObject*)(pTof->getObject(next));
( (HGeantTof*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
if ( (next = (Int_t)firstRpcHit) != -1) {
resetRpcIter();
do {
p = (HLinkedDataObject*)(pRpc->getObject(next));
( (HGeantRpc*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
if ( (next = (Int_t)firstShowerHit) != -1) {
resetShowerIter();
do {
p = (HLinkedDataObject*)(pShow->getObject(next));
( (HGeantShower*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
if ( (next = (Int_t)firstWallHit) != -1) {
resetWallIter();
do {
p = (HLinkedDataObject*)(pWall->getObject(next));
( (HGeantWall*)p )->setTrack(track);
} while( (next = p->getNextHitIndex()) != -1);
}
}
Int_t HGeantKine::setHitIndex(HCategory* pCat,Short_t& firstHit, Int_t index) {
if(pCat == NULL) return 1;
if(pCat->getObject(index) == NULL) return 1;
if(firstHit == -1) {
firstHit = (Short_t)index;
active = kTRUE;
} else {
HLinkedDataObject* p = NULL;
Int_t next = (Int_t)firstHit;
do {
p = (HLinkedDataObject*)(pCat->getObject(next));
next = p->getNextHitIndex();
} while(next != -1);
p->setNextHitIndex(index);
}
return 0;
}
void HGeantKine::sortRichHits(void) {
if(pRich == NULL) return;
Int_t nHits = getNRichHits();
if(nHits < 2) return;
HLinkedDataObject* p = NULL;
for(Int_t i=0; i<nHits-1;i++) {
resetRichIter();
Int_t next = (Int_t)firstRichHit;
do {
p = (HLinkedDataObject*)(pRich->getObject(next));
next = p->getNextHitIndex();
} while(next != -1);
}
return;
}
void HGeantKine::sortMdcHits(void) {
if(pMdc == NULL) return;
Int_t nHits = getNMdcHits();
if(nHits < 2) return;
HLinkedDataObject *pPrevPrev, *pPrev, *pHere;
Float_t tofHere = 1000000.0;
Float_t tofPrev = 1000000.0;
for(Int_t i=0; i<nHits-1;i++) {
resetMdcIter();
Int_t prev = -2;
Int_t here = -1;
Int_t next = (Int_t)firstMdcHit;
pPrevPrev = pPrev = NULL;
do {
pHere = (HLinkedDataObject*)(pMdc->getObject(next));
if(pHere == NULL) {
printf("\nNULL in HGeantKine::sortMdcHits() at index %d ! \n",next);
return;
}
prev = here;
here = next;
next = pHere->getNextHitIndex();
tofHere = pHere->sortVariable;
if(pPrev != NULL) {
if(tofHere < tofPrev) {
if(pPrevPrev == NULL) firstMdcHit = (Short_t)here;
else pPrevPrev->setNextHitIndex(here);
pPrev->setNextHitIndex(next);
pHere->setNextHitIndex(prev);
pPrevPrev = pHere;
here = prev;
continue;
}
}
pPrevPrev = pPrev;
pPrev = pHere;
tofPrev = tofHere;
} while(next != -1);
}
return;
}
void HGeantKine::sortTofHits(void) {
if(pTof == NULL) return;
Int_t nHits = getNTofHits();
if(nHits < 2) return;
HLinkedDataObject *pPrevPrev, *pPrev, *pHere;
Float_t tofHere = 1000000.0;
Float_t tofPrev = 1000000.0;
for(Int_t i=0; i<nHits-1;i++) {
resetTofIter();
Int_t prev = -2;
Int_t here = -1;
Int_t next = (Int_t)firstTofHit;
pPrevPrev = pPrev = NULL;
do {
pHere = (HLinkedDataObject*)(pTof->getObject(next));
if(pHere == NULL) {
printf("\nNULL in HGeantKine::sortTofHits() at index %d ! \n",next);
return;
}
prev = here;
here = next;
next = pHere->getNextHitIndex();
tofHere = pHere->sortVariable;
if(pPrev != NULL) {
if(tofHere < tofPrev) {
if(pPrevPrev == NULL) firstTofHit = (Short_t)here;
else pPrevPrev->setNextHitIndex(here);
pPrev->setNextHitIndex(next);
pHere->setNextHitIndex(prev);
pPrevPrev = pHere;
here = prev;
continue;
}
}
pPrevPrev = pPrev;
pPrev = pHere;
tofPrev = tofHere;
} while(next != -1);
}
return;
}
void HGeantKine::sortRpcHits(void) {
if(pRpc == NULL) return;
Int_t nHits = getNRpcHits();
if(nHits < 2) return;
HLinkedDataObject *pPrevPrev, *pPrev, *pHere;
Float_t tofHere = 1000000.0;
Float_t tofPrev = 1000000.0;
for(Int_t i=0; i<nHits-1;i++) {
resetRpcIter();
Int_t prev = -2;
Int_t here = -1;
Int_t next = (Int_t)firstRpcHit;
pPrevPrev = pPrev = NULL;
do {
pHere = (HLinkedDataObject*)(pRpc->getObject(next));
if(pHere == NULL) {
printf("\nNULL in HGeantKine::sortRpcHits() at index %d ! \n",next);
return;
}
prev = here;
here = next;
next = pHere->getNextHitIndex();
tofHere = pHere->sortVariable;
if(pPrev != NULL) {
if(tofHere < tofPrev) {
if(pPrevPrev == NULL) firstRpcHit = (Short_t)here;
else pPrevPrev->setNextHitIndex(here);
pPrev->setNextHitIndex(next);
pHere->setNextHitIndex(prev);
pPrevPrev = pHere;
here = prev;
continue;
}
}
pPrevPrev = pPrev;
pPrev = pHere;
tofPrev = tofHere;
} while(next != -1);
}
return;
}
void HGeantKine::sortShowerHits(void) {
if(pShow == NULL) return;
Int_t nHits = getNShowerHits();
if(nHits < 2) return;
HLinkedDataObject* p = NULL;
for(Int_t i=0; i<nHits-1;i++) {
resetShowerIter();
Int_t next = (Int_t)firstShowerHit;
do {
p = (HLinkedDataObject*)(pShow->getObject(next));
next = p->getNextHitIndex();
} while(next != -1);
}
return;
}
void HGeantKine::sortWallHits(void) {
if(pWall == NULL) return;
Int_t nHits = getNWallHits();
if(nHits < 2) return;
HLinkedDataObject *pPrevPrev, *pPrev, *pHere;
Float_t tofHere = 1000000.0;
Float_t tofPrev = 1000000.0;
for(Int_t i=0; i<nHits-1;i++) {
resetWallIter();
Int_t prev = -2;
Int_t here = -1;
Int_t next = (Int_t)firstWallHit;
pPrevPrev = pPrev = NULL;
do {
pHere = (HLinkedDataObject*)(pWall->getObject(next));
if(pHere == NULL) {
printf("\nNULL in HGeantKine::sortWallHits() at index %d ! \n",next);
return;
}
prev = here;
here = next;
next = pHere->getNextHitIndex();
tofHere = pHere->sortVariable;
if(pPrev != NULL) {
if(tofHere < tofPrev) {
if(pPrevPrev == NULL) firstWallHit = (Short_t)here;
else pPrevPrev->setNextHitIndex(here);
pPrev->setNextHitIndex(next);
pHere->setNextHitIndex(prev);
pPrevPrev = pHere;
here = prev;
continue;
}
}
pPrevPrev = pPrev;
pPrev = pHere;
tofPrev = tofHere;
} while(next != -1);
}
return;
}
HLinkedDataObject* HGeantKine::nextHit(HCategory* pCat,Int_t& index) {
if(index == -1 || pCat == NULL) return NULL;
HLinkedDataObject* p = (HLinkedDataObject*)(pCat->getObject(index));
index = p->getNextHitIndex();
return p;
}
Int_t HGeantKine::getNRichHits(void) {
Int_t n = 0;
if(firstRichHit > -1) {
resetRichIter();
while(nextRichHit() != NULL) n++;
resetRichIter();
}
return n;
}
Int_t HGeantKine::getNMdcHits(void) {
Int_t n = 0;
if(firstMdcHit > -1) {
resetMdcIter();
while(nextMdcHit() != NULL) n++;
resetMdcIter();
}
return n;
}
Int_t HGeantKine::getNMdcHits(Int_t module) {
Int_t n = 0;
if (module >= 0 && module <4)
{
if(firstMdcHit > -1)
{
HGeantMdc* hit = NULL;
resetMdcIter();
while((hit = (HGeantMdc*) nextMdcHit()) != NULL)
{
if (hit->getModule() == module)
{
n++;
}
}
resetMdcIter();
return n;
}
}
else
{
return -1;
}
return n;
}
Int_t HGeantKine::getNTofHits(void) {
Int_t n = 0;
if(firstTofHit > -1) {
resetTofIter();
while(nextTofHit() != NULL) n++;
resetTofIter();
}
return n;
}
Int_t HGeantKine::getNRpcHits(void) {
Int_t n = 0;
if(firstRpcHit > -1) {
resetRpcIter();
while(nextRpcHit() != NULL) n++;
resetRpcIter();
}
return n;
}
Int_t HGeantKine::getNShowerHits(void) {
Int_t n = 0;
if(firstShowerHit > -1) {
resetShowerIter();
while(nextShowerHit() != NULL) n++;
resetShowerIter();
}
return n;
}
Int_t HGeantKine::getNWallHits(void) {
Int_t n = 0;
if(firstWallHit > -1) {
resetWallIter();
while(nextWallHit() != NULL) n++;
resetWallIter();
}
return n;
}
Int_t HGeantKine::getSystem(void)
{
Int_t n = -1;
Int_t n0 = 0;
Int_t n1 = 0;
if(firstTofHit > -1) {
HGeantTof* hit = NULL;
resetTofIter();
while((hit = (HGeantTof*) nextTofHit()) != NULL)
{
if (hit->getModule()<22)
{
n1++;
}
else
{
n0++;
}
}
resetTofIter();
if ( n0 > 0 && n1 <= 0) n = 0;
if ( n1 > 0 && n0 <= 0) n = 1;
if ( n0 > 0 && n1 > 0) n = 2;
}
return n;
}
UInt_t HGeantKine::getMdcSectorBitArray(void)
{
UInt_t n=0;
if(firstMdcHit > -1)
{
HGeantMdc* hit = NULL;
resetMdcIter();
while((hit = (HGeantMdc*) nextMdcHit()) != NULL)
{
n|=(0x1<<hit->getSector());
}
resetMdcIter();
return n&0x3f;
}
return n&0x3f;
}
UInt_t HGeantKine::getMdcSectorDecimalArray(void)
{
UInt_t bit = getMdcSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
UInt_t HGeantKine::getShowerSectorBitArray(void)
{
UInt_t n=0;
if(firstShowerHit > -1)
{
HGeantShower* hit = NULL;
resetShowerIter();
while((hit = (HGeantShower*) nextShowerHit()) != NULL)
{
n|=(0x1<<hit->getSector());
}
resetShowerIter();
return n&0x3f;
}
return n&0x3f;
}
UInt_t HGeantKine::getShowerSectorDecimalArray(void)
{
UInt_t bit = getShowerSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
UInt_t HGeantKine::getTofSectorBitArray(void)
{
UInt_t n=0;
if(firstTofHit > -1)
{
HGeantTof* hit = NULL;
resetTofIter();
while((hit = (HGeantTof*) nextTofHit()) != NULL)
{
n|=(0x1<<hit->getSector());
}
resetTofIter();
return n&0x3f;
}
return n&0x3f;
}
UInt_t HGeantKine::getTofSectorDecimalArray(void)
{
UInt_t bit = getTofSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
UInt_t HGeantKine::getRpcSectorBitArray(void)
{
UInt_t n=0;
if(firstRpcHit > -1)
{
HGeantRpc* hit = NULL;
resetRpcIter();
while((hit = (HGeantRpc*) nextRpcHit()) != NULL)
{
n|=(0x1<<hit->getSector());
}
resetRpcIter();
return n&0x3f;
}
return n&0x3f;
}
UInt_t HGeantKine::getRpcSectorDecimalArray(void)
{
UInt_t bit = getRpcSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
UInt_t HGeantKine::getRichSectorBitArray(void)
{
UInt_t n=0;
if(firstRichHit > -1)
{
HGeantRichPhoton* hit = NULL;
resetRichIter();
while((hit = (HGeantRichPhoton*) nextRichHit()) != NULL)
{
n|=(0x1<<hit->getSector());
}
resetRichIter();
return n&0x3f;
}
return n&0x3f;
}
UInt_t HGeantKine::getRichSectorDecimalArray(void)
{
UInt_t bit = getRichSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
UInt_t HGeantKine::getSectorBitArray(void)
{
UInt_t n=0;
n|=getRichSectorBitArray();
n|=getTofSectorBitArray();
n|=getRpcSectorBitArray();
n|=getMdcSectorBitArray();
n|=getShowerSectorBitArray();
return n&0x3f;
}
UInt_t HGeantKine::getSectorDecimalArray(void)
{
UInt_t bit = getSectorBitArray() && 0x3f;
UInt_t n=0;
for (Int_t p=0; p<6; p++)
{
if ((bit>>p)&0x1)
{
n+=(UInt_t) pow(10.,p);
}
}
return n;
}
Int_t HGeantKine::getSector(void)
{
UInt_t n=getSectorBitArray();
if (n==0) return -7;
Int_t sector=-1;
Int_t ctr=0;
for (Int_t p=0; p<6; p++)
{
if ((n>>p)&0x1)
{
if (ctr==0)
{
sector = p;
ctr++;
}
else ctr++;
}
}
return (ctr>1)?-ctr:sector;
}
void HGeantKine::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
TObject::Streamer(R__b);
R__b >> trackNumber;
R__b >> parentTrack;
R__b >> particleID;
R__b >> mediumNumber;
R__b >> creationMechanism;
R__b >> xVertex;
R__b >> yVertex;
R__b >> zVertex;
R__b >> xMom;
R__b >> yMom;
R__b >> zMom;
R__b >> generatorInfo;
if (R__v > 4) {
R__b >> generatorInfo1;
R__b >> generatorInfo2;
} else {
generatorInfo1 = 0.;
generatorInfo2 = 0.;
}
R__b >> generatorWeight;
firstRichHit = -1;
firstMdcHit = -1;
firstTofHit = -1;
firstRpcHit = -1;
firstShowerHit = -1;
firstWallHit = -1;
if (R__v > 1) {
R__b >> firstRichHit;
R__b >> firstMdcHit;
R__b >> firstTofHit;
if (R__v > 5) {
R__b >> firstRpcHit;
}
R__b >> firstShowerHit;
if (R__v > 7) {
R__b >> firstWallHit;
}
}
active = kFALSE;
if (R__v > 2) {
R__b >> active;
if(R__v > 5)
{
if (firstRichHit > -1 ||
firstMdcHit > -1 ||
firstTofHit > -1 ||
firstRpcHit > -1 ||
firstShowerHit>-1 ) active = kTRUE;
if(R__v > 7)
{
if (firstRichHit > -1 ||
firstMdcHit > -1 ||
firstTofHit > -1 ||
firstRpcHit > -1 ||
firstShowerHit> -1 ||
firstWallHit > -1 ) active = kTRUE;
}
} else {
if (firstRichHit > -1 ||
firstMdcHit > -1 ||
firstTofHit > -1 ||
firstShowerHit> -1 ) active = kTRUE;
}
} else {
if (parentTrack==0) active = kTRUE;
else active = kFALSE;
}
if (R__v > 3) {
R__b >> suppressed;
} else {
suppressed = kFALSE;
}
if (R__v > 6) {
R__b >> userVal;
} else {
userVal = -1;
}
} else {
R__b.WriteVersion(HGeantKine::IsA());
TObject::Streamer(R__b);
R__b << trackNumber;
R__b << parentTrack;
R__b << particleID;
R__b << mediumNumber;
R__b << creationMechanism;
R__b << xVertex;
R__b << yVertex;
R__b << zVertex;
R__b << xMom;
R__b << yMom;
R__b << zMom;
R__b << generatorInfo;
R__b << generatorInfo1;
R__b << generatorInfo2;
R__b << generatorWeight;
R__b << firstRichHit;
R__b << firstMdcHit;
R__b << firstTofHit;
R__b << firstRpcHit;
R__b << firstShowerHit;
R__b << firstWallHit;
R__b << active;
R__b << suppressed;
R__b << userVal;
}
}
Bool_t HGeantKine::setChainActive(Int_t track, Bool_t flag, HLinearCategory* cat)
{
HLinearCategory* catKine;
if (track < 1) return kFALSE;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return kFALSE;
HGeantKine* pKine = (HGeantKine*)catKine->getObject(track-1);
if (pKine == NULL) return kFALSE;
do {
pKine->setActive(flag);
track = pKine->getTrack();
} while ((pKine=getParent(track,catKine)) != NULL);
return kTRUE;
}
Bool_t HGeantKine::setAllDescendentsActive(Int_t trackIn, Bool_t flag, HLinearCategory* cat)
{
HLinearCategory* catKine;
if (trackIn < 1) return kFALSE;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return kFALSE;
HGeantKine* pKine = (HGeantKine*)catKine->getObject(trackIn-1);
Int_t nEntries=catKine->getEntries();
for (Int_t i=0; i<nEntries; i++) {
pKine = (HGeantKine*)catKine->getObject(i);
if (pKine->hasAncestor(trackIn,catKine)) pKine->setActive(flag);
}
return kTRUE;
}
Bool_t HGeantKine::setAllDescendentsSuppressed(Int_t trackIn, Bool_t flag, HLinearCategory* cat)
{
HLinearCategory* catKine;
if (trackIn < 1) return kFALSE;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return kFALSE;
HGeantKine* pKine = (HGeantKine*)catKine->getObject(trackIn-1);
if (pKine == NULL) return kFALSE;
Int_t nEntries=catKine->getEntries();
for (Int_t i=0; i<nEntries; i++) {
pKine = (HGeantKine*)catKine->getObject(i);
if (pKine->hasAncestor(trackIn,catKine)) {
pKine->setSuppressed(flag);
if (flag==kTRUE) pKine->setActive(kFALSE);
}
}
return kTRUE;
}
Bool_t HGeantKine::suppressTracks(Int_t id, Float_t acceptedFraction, HLinearCategory* cat) {
if (id<0 || acceptedFraction < 0. || acceptedFraction > 1.) return kFALSE;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
Int_t track=1;
HGeantKine* pKine;
pKine = (HGeantKine*)catKine->getObject(track-1);
if (pKine == NULL) return kFALSE;
while (pKine && pKine->isPrimary()) {
if ((pKine->getID()) == id) {
if (gRandom->Rndm() > acceptedFraction)
setAllDescendentsSuppressed(track, kTRUE, catKine);
}
track++;
pKine = (HGeantKine*)catKine->getObject(track-1);
}
return kTRUE;
}
HGeantKine* HGeantKine::getParent(Int_t track, HLinearCategory* cat)
{
if (track < 1) return NULL;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return NULL;
HGeantKine* pKine = (HGeantKine*)catKine->getObject(track-1);
if (pKine == NULL) return NULL;
Int_t parent = pKine->getParentTrack();
if (parent == 0) return NULL;
else return (HGeantKine*)catKine->getObject(parent-1);
}
HGeantKine* HGeantKine::getGrandParent(Int_t track, HLinearCategory* cat)
{
if (track < 1) return NULL;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return NULL;
HGeantKine* pKine = getParent(track,catKine);
if (pKine == NULL) return NULL;
Int_t grandparent = pKine->getParentTrack();
if(grandparent == 0) return NULL;
else return (HGeantKine*)catKine->getObject(grandparent-1);
}
HGeantKine* HGeantKine::getPrimary(Int_t trackIn, HLinearCategory* cat)
{
if (trackIn < 1) return NULL;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return NULL;
HGeantKine* pKine = (HGeantKine*)catKine->getObject(trackIn-1);
if (pKine == NULL) return NULL;
HGeantKine* pSave;
Int_t track=0;
do {
pSave = pKine;
track = pKine->getTrack();
} while ((pKine=pKine->getParent(track,catKine)) != NULL);
return pSave;
}
Bool_t HGeantKine::hasAncestor(Int_t trackIn, HLinearCategory* cat)
{
if (trackIn < 1) return kFALSE;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return kFALSE;
HGeantKine* pKine = this;
Int_t track = -1;
do {
track = pKine->getTrack();
if (track == trackIn) return kTRUE;
} while ((pKine=getParent(track,catKine)) != NULL);
return kFALSE;
}
HGeantKine* HGeantKine::getCommonAncestor(Int_t track1, Int_t track2, HLinearCategory* cat)
{
if (track1 < 1 || track2 < 1) return NULL;
HLinearCategory* catKine;
if (cat != NULL) catKine = cat;
else catKine = (HLinearCategory*)gHades->getCurrentEvent()
->getCategory(catGeantKine);
if (catKine == NULL) return NULL;
HGeantKine* pKine1 = (HGeantKine*)catKine->getObject(track1-1);
if (pKine1 == NULL) return NULL;
HGeantKine* pKine2 = (HGeantKine*)catKine->getObject(track2-1);
if (pKine2 == NULL) return NULL;
Int_t track=0;
if (track1 < track2) {
do {
track = pKine1->getTrack();
if (pKine2->hasAncestor(track,catKine)) return pKine1;
} while ((pKine1=pKine1->getParent(track,catKine)) != NULL);
return NULL;
} else {
do {
track = pKine2->getTrack();
if (pKine1->hasAncestor(track,catKine)) return pKine2;
} while ((pKine2=pKine2->getParent(track,catKine)) != NULL);
return NULL;
}
}
Last change: Sat May 22 12:55:51 2010
Last generated: 2010-05-22 12:55
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.