#include #include "THashTable.h" #include "Stntuple/run1/StnRun1InitDataBlocks.hh" #include "Stntuple/obj/TGenParticle.hh" #include "Stntuple/obj/TGenpBlock.hh" #include "Stntuple/run1/TStnRun1Event.hh" class TCode: public TObject { Int_t fCdfCode; Int_t fPdgCode; public: TCode() {} TCode(Int_t CdfCode, Int_t PdgCode) {fCdfCode = CdfCode; fPdgCode = PdgCode;} virtual ~TCode() {} Int_t PdgCode() { return fPdgCode; } Int_t CdfCode() { return fCdfCode; } virtual ULong_t Hash() const { return fCdfCode; } }; //_____________________________________________________________________________ class TCdf2PdgConvTable: public TObject { TObjArray* fTable; public: TCdf2PdgConvTable(); virtual ~TCdf2PdgConvTable(); Int_t CdfCode(Int_t PdgCode); Int_t PdgCode(Int_t CdfCode); Int_t AddNewLine(Int_t CdfCode, Int_t PdgCode); }; //_____________________________________________________________________________ TCdf2PdgConvTable::TCdf2PdgConvTable() { fTable = new TObjArray(1000); char c[200]; int i, cdf_code, pdg_code; char pname[40]; char* name = getenv("HEPTBL"); if (name) { FILE* f = fopen(name,"r"); while ( (c[0]=getc(f)) != EOF) { // check if it is a comment line if (c[0] != '#') { ungetc(c[0],f); i = -1; fscanf(f,"%i",&i); fscanf(f,"%i",&cdf_code); fscanf(f,"%s",pname ); fscanf(f,"%i",&pdg_code); if (i > 0) AddNewLine(cdf_code,pdg_code); } // skip end of the line fgets(c,200,f); } } else { Error("TCdf2HepTable","cant open HEPTBL file"); } } //_____________________________________________________________________________ TCdf2PdgConvTable::~TCdf2PdgConvTable(){ fTable->Delete(); delete fTable; } //_____________________________________________________________________________ Int_t TCdf2PdgConvTable::AddNewLine(Int_t CdfCode, Int_t PdgCode) { TCode* code = new TCode(CdfCode,PdgCode); fTable->Add(code); return 0; } //_____________________________________________________________________________ Int_t TCdf2PdgConvTable::PdgCode(Int_t CdfCode) { Int_t n = fTable->GetEntriesFast(); for (int i=0; iUncheckedAt(i); if (code->CdfCode() == CdfCode) { return code->PdgCode(); } } return 0; } //_____________________________________________________________________________ Int_t TCdf2PdgConvTable::CdfCode(Int_t PdgCode) { Int_t n = fTable->GetEntriesFast(); for (int i=0; iUncheckedAt(i); if (code->PdgCode() == PdgCode) { return code->CdfCode(); } } return 0; } //_____________________________________________________________________________ int StnRun1InitGenpBlock(TStnDataBlock* Block, TStnEvent* Event, int Mode) { // initialize GENP data block starting from Run1 UC Stntuple static TCdf2PdgConvTable table; int ipart, iparent, fd, nd, isthep; TStnRun1Event* event = (TStnRun1Event*) Event; TGenpBlock* blk = (TGenpBlock*) Block; blk->Clear(); StnGenpBlock_t* r1genp = event->GenpBlock(); blk->fNInteractions = 1; blk->fInt[0].fFirst = 0; for (int i=0; iNgenp; i++) { int pdg_code = table.PdgCode(r1genp->Ngid[i]); float e = sqrt( r1genp->Gnp4[i][0]*r1genp->Gnp4[i][0]+ r1genp->Gnp4[i][1]*r1genp->Gnp4[i][1]+ r1genp->Gnp4[i][2]*r1genp->Gnp4[i][2]+ r1genp->Gnp4[i][3]*r1genp->Gnp4[i][3]); ipart = (r1genp->Ngn[i] & 0xffff) - 1; fd = ((r1genp->Ngn[i] >> 16) & 0xffff) - 1; iparent = (r1genp->Ngnp[i] & 0xffff) - 1; nd = (r1genp->Ngnp[i] >> 16) & 0xffff; if (fd < 0) isthep = 1; else isthep = 2; TGenParticle* p = blk->NewParticle(ipart, pdg_code, isthep, iparent, 0, fd, fd+nd-1, r1genp->Gnp4[i][0], r1genp->Gnp4[i][1], r1genp->Gnp4[i][2], e, 0,0,0,0); } return 0; }