#include "hbrowserdb.h"
#include "honlinecontrol.h"
#include "hdetsetcont.h"
#include "hdetset.h"
#include "hlocalcont.h"
#include "hlocalcondition.h"
#include "hglobalcont.h"
#include "hglobalcondition.h"
#include "hhistocont.h"
#include "hhistogram.h"
#include "hparameter.h"
ClassImp(HBrowserDB)
HBrowserDB::HBrowserDB() : TObject() {
clear();
fContainer = new TObjArray(200);
if(fContainer) putDefault();
if(gOnline) putUserPar();
}
HBrowserDB::~HBrowserDB() {
if(fContainer) {
HUserParameter *pDel;
for(Int_t i=0; i<getEntries(); i++) {
pDel = (HUserParameter*) fContainer->RemoveAt(i);
if(pDel) {
delete pDel;
pDel = 0;
}
}
delete fContainer;
}
}
Bool_t HBrowserDB::add(HUserParameter *p) {
if(!p) return kFALSE;
Char_t nulstr[50] = "";
if(!strcmp(nulstr,p->GetName())) return kFALSE;
Int_t idx = find(p->GetName());
if(idx != -1) return kFALSE;
if(p->getIndex() == 0) return kFALSE;
HUserParameter *pNewCopy = new HUserParameter();
if(!pNewCopy) return kFALSE;
p->copy(pNewCopy);
fContainer->Add(pNewCopy);
return kTRUE;
}
Int_t HBrowserDB::getEntries() {
if(!fContainer) return -1;
return (fContainer->GetLast() + 1);
}
HUserParameter* HBrowserDB::at(Int_t idx) {
if(!fContainer) return 0;
if(idx < 0) return 0;
HUserParameter *pRetVal = (HUserParameter*) fContainer->At(idx);
return pRetVal;
}
Int_t HBrowserDB::find(const Char_t* name) {
if(!name) return -1;
HUserParameter *pPar;
for(Int_t i=0; i<getEntries(); i++) {
pPar = at(i);
if(!strcmp(pPar->GetName(),name)) return i;
}
return -1;
}
void HBrowserDB::putDefault() {
HUserParameter *pParam;
const Char_t* tofrawn[] = { "cell_R_TO", "timeL_TO", "timeR_TO",
"amplL_TO", "amplR_TO" };
const Char_t* tofhitn[] = { "cell_H_TO", "t-o-f_TO", "x-pos_TO",
"xlab_TO", "ylab_TO", "zlab_TO", "dist_TO",
"theta_TO", "phi_TO" };
const Char_t* mdccal1n[] = { "time1_MD", "time2_MD" };
const Char_t* mdccal2n[] = { "dist1_MD", "dist2_MD", "errdist1_MD",
"errdist2_MD" };
const Char_t* mdchitn[] = { "X_MD", "Y_MD", "THETA_MD", "PHI_MDC" };
const Char_t* richrawn[] = { "charge_R_RI", "row_R_RI", "col_R_RI" };
const Char_t* richcaln[] = { "charge_C_RI", "row_C_RI", "col_C_RI" };
const Char_t* richhitn[] = { "Xloc_RI", "Yloc_RI", "Xlab_RI", "Ylab_RI",
"Zlab_RI", "Theta_RI", "Phi_RI" };
const Char_t* shhitn[] = { "Xloc_SH", "Yloc_SH", "Xlab_SH", "Ylab_SH",
"Zlab_SH" };
Int_t i;
for(i=0;i<5;i++) {
pParam = new HUserParameter();
pParam->setCategory(96);
pParam->setIndex(i+1);
pParam->SetName(tofrawn[i]);
fContainer->Add(pParam);
}
for(i=0;i<9;i++) {
pParam = new HUserParameter();
pParam->setCategory(97);
pParam->setIndex(i+1);
pParam->SetName(tofhitn[i]);
fContainer->Add(pParam);
}
for(i=0;i<2;i++) {
pParam = new HUserParameter();
pParam->setCategory(2);
pParam->setIndex(i+1);
pParam->SetName(mdccal1n[i]);
fContainer->Add(pParam);
}
for(i=0;i<4;i++) {
pParam = new HUserParameter();
pParam->setCategory(4);
pParam->setIndex(i+1);
pParam->SetName(mdccal2n[i]);
fContainer->Add(pParam);
}
for(i=0;i<4;i++) {
pParam = new HUserParameter();
pParam->setCategory(1);
pParam->setIndex(i+1);
pParam->SetName(mdchitn[i]);
fContainer->Add(pParam);
}
for(i=0;i<3;i++) {
pParam = new HUserParameter();
pParam->setCategory(32);
pParam->setIndex(i+1);
pParam->SetName(richrawn[i]);
fContainer->Add(pParam);
}
for(i=0;i<3;i++) {
pParam = new HUserParameter();
pParam->setCategory(34);
pParam->setIndex(i+1);
pParam->SetName(richcaln[i]);
fContainer->Add(pParam);
}
for(i=0;i<7;i++) {
pParam = new HUserParameter();
pParam->setCategory(33);
pParam->setIndex(i+1);
pParam->SetName(richhitn[i]);
fContainer->Add(pParam);
}
pParam = new HUserParameter();
pParam->setCategory(64);
pParam->setIndex(1);
pParam->SetName("charge_R_SH");
fContainer->Add(pParam);
pParam = new HUserParameter();
pParam->setCategory(66);
pParam->setIndex(1);
pParam->SetName("charge_C_SH");
fContainer->Add(pParam);
for(i=0;i<5;i++) {
pParam = new HUserParameter();
pParam->setCategory(65);
pParam->setIndex(i+1);
pParam->SetName(shhitn[i]);
fContainer->Add(pParam);
}
}
void HBrowserDB::putUserPar() {
if(!gOnline) return;
HHistogram *pHisto = 0;
Int_t i;
for(i=0; i < gOnline->getHisto()->getEntries(); i++) {
pHisto = gOnline->getHisto()->at(i);
if(pHisto) {
add(pHisto->getParameter(1));
add(pHisto->getParameter(2));
}
}
}
void HBrowserDB::clear() {
for(Int_t i=0; i<501; i++) aridx[i] = -1;
cursor = 0;
tabpos = 0;
}
void HBrowserDB::changed(Int_t tab) {
if(!gOnline) return;
HDetSet *pSet;
HLocalCondition *pLocal;
HGlobalCondition *pGlobal;
HHistogram *pHisto;
Int_t i = 0;
clear();
switch(tab) {
case 1:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == TOF) aridx[++cursor] = i;
}
}
break;
case 2:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == MDC) aridx[++cursor] = i;
}
}
break;
case 3:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == RICH) aridx[++cursor] = i;
}
}
break;
case 4:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == SHOWER) aridx[++cursor] = i;
}
}
break;
case 5:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == START) aridx[++cursor] = i;
}
}
break;
case 6:
for(i=0; i < gOnline->getDetSet()->getEntries(); i++) {
pSet = gOnline->getDetSet()->at(i);
if(pSet) {
if(pSet->getDetName() == TOFINO) aridx[++cursor] = i;
}
}
break;
case 7:
for(i=0; i < gOnline->getHisto()->getEntries(); i++) {
pHisto = gOnline->getHisto()->at(i);
if(pHisto) aridx[++cursor] = i;
}
break;
case 8:
for(i=0; i < gOnline->getLocal()->getEntries(); i++) {
pLocal = gOnline->getLocal()->at(i);
if(pLocal) aridx[++cursor] = i;
}
break;
case 9:
for(i=0; i < gOnline->getGlobal()->getEntries(); i++) {
pGlobal = gOnline->getGlobal()->at(i);
if(pGlobal) aridx[++cursor] = i;
}
break;
default:
break;
}
tabpos = tab;
}
Last change: Sat May 22 12:53:44 2010
Last generated: 2010-05-22 12:53
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.