#pragma implementation
#include "hhypcomb.h"
#include <iostream>
using namespace std;
ClassImp(HHypComb)
HHypComb::HHypComb(Int_t Ncomb, Int_t Npart)
{
clear();
ncomb = Ncomb;
npart = Npart;
prepareHypComb();
}
Bool_t HHypComb::clear()
{
ncomb = 0;
npart = 0;
return kTRUE;
}
void HHypComb::Clear(const Option_t * opt)
{
fprobcomb.Set(0);
idx.Set(0);
pid.Set(0);
}
Bool_t HHypComb::Join(HHypComb * addme)
{
if (npart != addme->getNpart()) {
Error("Join", "The NUMBER of particles has to be the same!");
return kFALSE;
}
if (addme->getNcomb() <= 0) {
Error("Join", "Nr of Combination <=0!");
return kFALSE;
}
Int_t oldncomb;
oldncomb = ncomb;
ncomb += addme->getNcomb();
idx.Set(ncomb * npart);
pid.Set(ncomb * npart);
fprobcomb.Set(ncomb);
for (Int_t Icomb = 0; Icomb < addme->getNcomb(); Icomb++) {
Int_t nci;
nci = Icomb + oldncomb;
setProbComb(nci, addme->getProbComb(Icomb));
for (Int_t Ipart = 0; Ipart < npart; Ipart++) {
setPid(nci, Ipart, addme->getPid(Icomb, Ipart));
setIdxPidTrackCand( nci, Ipart, addme->getIdxPidTrackCand(Icomb, Ipart));
}
}
return kTRUE;
}
Bool_t HHypComb::setCombId(Int_t Cid)
{
cid = Cid;
return kTRUE;
}
Int_t HHypComb::getCombId()
{
return cid;
}
Bool_t HHypComb::setNcomb(Int_t Ncomb)
{
ncomb = Ncomb;
return kTRUE;
}
Int_t HHypComb::getNcomb()
{
return ncomb;
}
Bool_t HHypComb::setNpart(Int_t Npart)
{
npart = Npart;
return kTRUE;
}
Int_t HHypComb::getNpart()
{
return npart;
}
Bool_t HHypComb::setProbComb(Int_t Icomb, Float_t Prob)
{
if (Icomb < ncomb) {
fprobcomb[Icomb] = Prob;
return kTRUE;
} else {
cout << "Error: HHypComb::setProbComb (Icomb out of bounds)" << endl;
return kFALSE;
}
}
Float_t HHypComb::getProbComb(Int_t Icomb)
{
if (Icomb < ncomb) {
return fprobcomb[Icomb];
} else {
cout << "Error: HHypComb::getProbComb (Icomb out of bounds)" << endl;
return -1;
}
}
Bool_t HHypComb::prepareHypComb()
{
if ((ncomb != 0) && (npart != 0)) {
idx.Set(ncomb * npart);
pid.Set(ncomb * npart);
fprobcomb.Set(ncomb);
for (Int_t Icomb = 0; Icomb < ncomb; Icomb++) {
setProbComb(Icomb, 1);
for (Int_t Ipart = 0; Ipart < npart; Ipart++) {
setIdxPidTrackCand(Icomb, Ipart, -1);
}
}
return kTRUE;
} else {
cout << "Error: HHypComb::prepareHypComb (ncomb or npart equal 0)" << endl;
return kFALSE;
}
}
Bool_t HHypComb::setIdxPidTrackCand(Int_t Icomb, Int_t Ipart, Int_t Idx)
{
if ((Icomb < ncomb) && (Ipart < npart)) {
idx[Icomb * npart + Ipart] = Idx;
return kTRUE;
} else {
cout << "Error: HHypComb::setIdxPidTrackCand (Icomb or Ipart out of bounds)" <<
endl;
return kFALSE;
}
}
Int_t HHypComb::getIdxPidTrackCand(Int_t Icomb, Int_t Ipart)
{
if ((Icomb < ncomb) && (Ipart < npart)) {
return idx[Icomb * npart + Ipart];
} else {
cout << "ERROR: HHypComb::getIdxPidTrackCand (Icomb or Ipart out of bounds)" <<
endl;
return -1;
}
}
Bool_t HHypComb::setPid(Int_t Icomb, Int_t Ipart, Int_t Pid)
{
if ((Icomb < ncomb) && (Ipart < npart)) {
pid[Icomb * npart + Ipart] = Pid;
return kTRUE;
} else {
cout << "ERROR: HHypComb::setPid (Icomb or Ipart out of bounds)" << endl;
return kFALSE;
}
}
Int_t HHypComb::getPid(Int_t Icomb, Int_t Ipart)
{
if ((Icomb < ncomb) && (Ipart < npart)) {
return pid[Icomb * npart + Ipart];
} else {
cout << "ERROR: HHypComb::getPid (Icomb or Ipart out of range)" << endl;
return -1;
}
}
Int_t HHypComb::getNvalid(Int_t Icomb)
{
if ((Icomb < ncomb)) {
Int_t v=0;
for(Int_t n=0; n<npart; n++){
if(getIdxPidTrackCand(Icomb,n)>=0) v++;
}
return v;
} else {
cout << "ERROR: HHypComb::getNvalid (Icomb out of range)" << endl;
return -1;
}
}
Bool_t HHypComb::print()
{
cout << "\t\t[Debug] HHypComb::print()" << endl;
cout << "\t\t[Debug] Number of Comb : " << ncomb << endl;
cout << "\t\t[Debug] Number of Part : " << npart << endl;
for (Int_t i = 0; i < ncomb; i++) {
for (Int_t j = 0; j < npart; j++) {
cout << "\t" << getIdxPidTrackCand(i, j);
}
cout << " !";
for (Int_t j = 0; j < npart; j++) {
cout << "\t" << getPid(i, j);
}
cout << " !\t" << getProbComb(i) << endl;
}
cout << "\n";
return kTRUE;
}
HCategory *HHypComb::buildLinearCat(const Text_t * classname)
{
HLinearCategory *category = NULL;
Int_t size = 1000;
category = new HLinearCategory(classname, size);
category->setDynamicObjects(kTRUE);
return category;
}
void HHypComb::Streamer(TBuffer & R__b)
{
if (R__b.IsReading())
{
Version_t R__v = R__b.ReadVersion();
if (R__v != 1) {
cout << "HHypComb::Streamer: version is not 1" << endl;
}
TObject::Streamer(R__b);
R__b >> ncomb;
R__b >> npart;
fprobcomb.Set(ncomb);
for (Int_t i = 0; i < ncomb; i++) {
R__b >> fprobcomb[i];
}
idx.Set(ncomb * npart);
pid.Set(ncomb * npart);
for (Int_t i = 0; i < idx.GetSize(); i++) {
R__b >> idx[i];
R__b >> pid[i];
}
} else
{
R__b.WriteVersion(HHypComb::IsA());
TObject::Streamer(R__b);
R__b << ncomb;
R__b << npart;
for (Int_t i = 0; i < getNcomb(); i++) {
R__b << fprobcomb[i];
}
for (Int_t i = 0; i < idx.GetSize(); i++) {
R__b << idx[i];
R__b << pid[i];
}
}
}
Last change: Sat May 22 12:57:42 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.