/////////////////////////////////////////////////////////////////////
//  Pluto Data Wrapper
//  Provides a lot of helpfull wrapper function to deal with the data
//  base. 
//
//
//                             Author:  M.A. Kagarlis
//                             Written: 31/01/99
//                             Revised: 24/05/2004 R.H.
//                             Reimplemented: 3/5/2007 IF
//
//////////////////////////////////////////////////////////////////////

#include "PStaticData.h"
#include "PStdData.h"
#include "PUtils.h"
#include "TString.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "PDefines.h"

extern char *version_string;

PStaticData &fStaticData() {
    static PStaticData *ans = new PStaticData();
    return *ans;
}

PStaticData * makeStaticData() {
    return &fStaticData();
}

PStaticData::PStaticData() {
    if (!makeStdData()->fillDataBase()) {
	Fatal("PStaticData", "Data base could not be filled");
	exit(1);
    }
    PDataBase *base = makeDataBase();
    i_result = NULL;
    c_result = NULL;
    d_result = NULL;
    t_result = NULL;
    
    freeze = kFALSE;

    pid_param    = base->GetParamInt("pid");
    name_param   = base->GetParamString("name");
    meson_param  = base->GetParamInt("meson");
    baryon_param = base->GetParamInt("baryon");
    lepton_param = base->GetParamInt("lepton");
    charge_param = base->GetParamInt("charge");
    spin_param   = base->GetParamInt("spin");
    ispin_param  = base->GetParamInt("ispin");
    parity_param = base->GetParamInt("parity");
    mass_param   = base->GetParamDouble("mass");
    width_param  = base->GetParamDouble("width");
    pkf_param    = base->GetParamInt("pythiakf");
    didx_param   = base->GetParamInt("didx");
    widx_param   = base->GetParamInt("widx");
    mesh_param   = base->GetParamTObj("mesh");
    tf1_param    = base->GetParamTObj("tf1");
    ethreshold_param = base->GetParamDouble("ethreshold");
    lmass_param  = base->GetParamDouble("lmass");
    umass_param  = base->GetParamDouble("umass");
    brflag_param = base->GetParamInt("brflag");
    tdepth_param = base->GetParamInt("tdepth");
    hdepth_param = base->GetParamInt("hdepth");
    br_param     = base->GetParamDouble("br");
    brorig_param = base->GetParamDouble("brorig");
    count_param  = base->GetParamInt("pnmodes");
    d1_param     = base->GetParamInt("d1");
    d2_param     = base->GetParamInt("d2");
    d3_param     = base->GetParamInt("d3");
    d4_param     = base->GetParamInt("d4");
    d5_param     = base->GetParamInt("d5");
    d6_param     = base->GetParamInt("d6");
    d7_param     = base->GetParamInt("d7");
    pnmodes_param= base->GetParamInt("pnmodes");
    ppid_param   = base->GetParamInt("ppid");

    nalias_param = base->GetParamInt("nalias");
    lalias_param = base->GetParamInt("lalias");
    
    enhance_br_param = base->MakeParamDouble ("enhance_br", "Enhancement for the free decay BR");

    //now loop over particles and normalize BRs
    //This is very important for the mass sampling
    Int_t pids = 0;
    Int_t key  = makeDataBase()->GetEntry("std_set");
    if (key < 0) Warning("PStaticData", "std_set not found");
    Int_t listkey = -1;
    while (makeDataBase()->MakeListIterator(key, "snpart", "slink", &listkey)) {
	//loop over all particles
	NormParticleBRbyKey(listkey);
	pids++;
    }

    //This is for the ctor of the PChannelModel
    defkey_param = base->MakeParamInt("defkey", "Model Def Key");

    //Add some useful aliases
    //no idea if this is the correct place, it the moment it should be OK
    AddAlias("dilepton", "dielectron");
    AddAlias("g", "gamma");

    AddAlias("w",  "omega");
    AddAlias("D0", "Delta0");
    AddAlias("D+", "Delta+");
    AddAlias("D++","Delta++");
    AddAlias("D-", "Delta-");
    AddAlias("D0", "Delta(1232)0");
    AddAlias("D+", "Delta(1232)+");
    AddAlias("D++","Delta(1232)++");
    AddAlias("D-", "Delta(1232)-");


    AddAlias("DP330", "Delta(1600)0");
    AddAlias("DP33+", "Delta(1600)+");
    AddAlias("DP33++","Delta(1600)++");
    AddAlias("DP33-", "Delta(1600)-");

    AddAlias("DS310", "Delta(1620)0");
    AddAlias("DS31+", "Delta(1620)+");
    AddAlias("DS31++","Delta(1620)++");
    AddAlias("DS31-", "Delta(1620)-");

    AddAlias("NP11+", "N*(1440)+");
    AddAlias("NP110", "N*(1440)0");
    AddAlias("ND13+", "N*(1520)+");
    AddAlias("ND130", "N*(1520)0");
    AddAlias("NS11+", "N*(1535)+");
    AddAlias("NS110", "N*(1535)0");

    //Increase mesh array for resonances
    makeDataBase()->SetParamInt("NS110", "maxmesh", 2000); 
    makeDataBase()->SetParamInt("NS11+", "maxmesh", 2000); 
    makeDataBase()->SetParamInt("NS11-", "maxmesh", 2000); 


    //Ingo's additions:
    makeDataBase()->SetParamDouble ("D+", "lmass", 1.); 
    //--> lmass=0 leads to endless loop in PHadronDecayM1:: maxBWWeight
    makeDataBase()->SetParamDouble ("D+", "umass", 3.);

    system_alloc_verbosity = GetBatchValue("_system_alloc_verbosity");
    (*system_alloc_verbosity) = 1.;

    *GetBatchValue("_system_weight_version") = 1.;
    *GetBatchValue("_system_unstable_width") = 0.0001;
    *GetBatchValue("_system_thermal_unstable_width") = 0.001;

    *GetBatchValue("_system_total_event_number")     = 0.;
    *GetBatchValue("_system_total_events_to_sample") = 0.;
    *GetBatchValue("_system_printout_percent")       = 20.;

    *GetBatchValue("_event_plane")           = 0.;
    *GetBatchValue("_event_impact_param")    = 0.;
    *GetBatchValue("_event_vertex_x")        = 0.;
    *GetBatchValue("_event_vertex_y")        = 0.;
    *GetBatchValue("_event_vertex_z")        = 0.;
    *GetBatchValue("_event_seqnr")           = -1.;

    Double_t *version= GetBatchValue("_system_version");

    if (!strncmp("Trunk", version_string, 3)) {
	(*version) = 999.;
    } else {
	sscanf(version_string, "%lf", version);
    }
}

int PStaticData::MakeDirectoryEntry(const char *name, const char *n, const char *l, const char *ename) {
    // Adds an entry of the form "dir"
    // if entry/dir is existing, the key w/o warning is returned
    // n and l are the data base columns of the list

    Int_t skey = -1;

    if (makeDataBase()->GetParamInt(n) < 0) 
	makeDataBase()->MakeParamInt(n, "number of links");
    if (makeDataBase()->GetParamInt(l) < 0) 
	makeDataBase()->MakeParamInt(l, "links");

    skey = makeDataBase()->GetEntry(name);
    if (skey < 0) skey = makeDataBase()->AddEntry(name);
    if (skey < 0) return -1; //failed

    skey = makeDataBase()->GetEntry(ename);
    if (skey < 0) skey = makeDataBase()->AddEntry(ename);
    if (skey < 0) return -1; //failed
    
    Int_t *dummy;
    if (!makeDataBase()->GetParamInt(skey,l,&dummy)) {
	//fresh entry
	skey = makeDataBase()->AddListEntry(name, n, l, ename);
    }    
    return skey;
}


Double_t *PStaticData::GetBatchValue(const char *name, Int_t make_val) {
    Int_t key_a = MakeDirectoryEntry("batch_objects", NBATCH_NAME, LBATCH_NAME, name);
    //Check if double is existing
    Double_t *val;
    Int_t batch_value_param = makeDataBase()->GetParamDouble("batch_value");
    if (batch_value_param < 0) 
	batch_value_param = makeDataBase()->MakeParamDouble("batch_value", "Double storage for batch");
    if (!makeDataBase()->GetParamDouble(key_a, batch_value_param, &val)) {
	if (make_val) {
	    Double_t *delme =  new Double_t(0.);
	    makeDataBase()->SetParamDouble(key_a, "batch_value", delme);
	    return delme;
	} else return NULL;
    }
    return val;
}

int PStaticData::GetParticleID(const char *id, int warn) {
    // pid by name
    if (!id) return 0;
    if (! makeDataBase()->GetParamInt(makeDataBase()->GetEntry((char*)id), pid_param, &i_result)) {
	Int_t key = GetAliasParent(id);
	if (key < 0) {
	    if (warn) {
		Warning("GetParticleID", "%s not found", id);
	    }
	    return 0;
	}
	return GetParticleIDByKey(key);
    }
    return *i_result;
}

const char *PStaticData::GetParticleName(const int &id) {
    // name by pid
    Int_t key = -1;
    if ((key = makeDataBase()->GetEntryInt(pid_param, id)) < 0) {
	Warning("GetParticleName", "id %i not found", id);
	return "";
    }
    makeDataBase()->GetParamString (key, name_param, &c_result);
    return c_result;
}

int PStaticData::GetParticleIDByKey(int key) {
    // pid by key
    // -1 if unvalid
    if (!makeDataBase()->GetParamInt (key, pid_param, &i_result)) 
	return -1;
    return *i_result;
}

int PStaticData::GetParticleKey(const int &id) {
    // data base key by pid
    Int_t key = -1;
    if ((key = makeDataBase()->GetEntryInt(pid_param, id)) < 0) {
	Warning("GetParticleKey", "id %i not found", id);
    }
    return key;
}

int PStaticData::GetDecayKey(const int &id) {
    // data base key by pid
    Int_t key = -1;
    if ((key = makeDataBase()->GetEntryInt(didx_param, id)) < 0) {
	Warning("GetDecayKey", "id %i not found", id);
    }
    return key;
}

int PStaticData::IsParticle(const int &id, const char *name) {
    // does pid correspond to given name?
    if (strcmp(name, GetParticleName(id)) == 0) return 1;
    return 0;
}

int PStaticData::IsParticleValid(const int &id) { 
    // check id range by id
    // Returns a "1" in any case if data base is filled with id
    // PFireball particles return 0;

    Int_t key = -1;
    if ((key = makeDataBase()->GetEntryInt(pid_param, id)) >= 0) {
	return id; //if in data base in any case say yes
    }
 
    if ((id>500) && (id<1000)) return id;

    return 0;
}
 
int PStaticData::IsParticleValid(const char *n) {
    // check id range by name

    if (!n) return 0;
    int pid = GetParticleID(n, 0);
    if (pid<0) return 0;

    return IsParticleValid(pid);
}

int PStaticData::AddAlias(const char *old_name, const char *new_name) { 
//adds an alias to primary_key, ret value is alias key
    PDataBase *base = makeDataBase();
    Int_t pkey = -1;
    
    if ((pkey = base->AddListEntry(old_name, "nalias", "lalias", new_name)) < 0) {
	Warning("AddAlias", "Name %s not found", old_name);
	return -1;
    }
    
    return pkey;
}

int PStaticData::GetAliasParent(const char *alias_name) {
    Int_t listkey=-1, *dummy;
    Int_t key = makeDataBase()->GetEntry(alias_name);
    if (key < 0) return -1;
    while (makeDataBase()->MakeListIterator(key, -1, lalias_param, &listkey)) {
	if (makeDataBase()->GetParamInt(listkey, nalias_param, &dummy)) {
	    //count found
	    return listkey;
	}
    }
    return -1;
}

int PStaticData::GetAliasParent(int key) {
    Int_t listkey=-1, *dummy;
    if (key < 0) return -1;
    if (!makeDataBase()->GetParamInt (key, lalias_param, &dummy)) return -1;
    while (makeDataBase()->MakeListIterator(key, -1, lalias_param, &listkey)) {
	if (makeDataBase()->GetParamInt(listkey, nalias_param, &dummy)) {
	    //count found
	    return listkey;
	}
    }
    return -1;
}
    
int PStaticData::GetSecondaryKey(int key, int defkey) {
    Int_t listkey = -1;

    Int_t *dummy;
    if (!makeDataBase()->GetParamInt(key, nalias_param,&dummy)) {
	//Warning("MakeListIterator","count %s not found",count);
	//try to find parent
	key = GetAliasParent(key);
	if (key<0)
	    return -1; //avoid messages 
    }

    while (makeDataBase()->MakeListIterator(key, nalias_param, lalias_param, &listkey)) {

	//loop over all secondaries
	if (makeDataBase()->GetParamInt(listkey, defkey_param, &dummy)) {
	    if (*dummy == defkey)
		return listkey;
	}
    }
    return -1;
}

int PStaticData::AddParticle(int pid, const char *name, double mass) {
    clearFreezeOut();
    PDataBase *base = makeDataBase();
    Int_t pkey = -1;
    
    //check if pid already exists
    if (pid >= 0)
	if (base->GetEntryInt("pid", pid) >=0 ) {
	    Warning("AddParticle", "pid %i already used in data base", pid);
	    return -1;
	}

    if (base->GetEntry(name) >= 0) {
	Warning("AddParticle", "Name %s already used in data base", name);
	return -1;
    }

    if (pid < 0) {
	pid = 0;
	while(makeDataBase()->GetEntryInt("pid", pid) >=0 ) {
	    pid++;
	}
	if (*system_alloc_verbosity)
	    Info("AddParticle", "(%s) PID: %i", PRINT_AUTO_ALLOC, pid);

    }

    if ((pkey = base->AddListEntry("std_set", "snpart", "slink", name)) < 0) {
	Warning("AddParticle", "particle header not found");
	return -1;
    }

    Int_t *ii = new int(pid);  //never destructed, but called only once!
    if (!base->SetParamInt (pkey, "pid", ii)) {
	delete ii;
	return -1;
    }
    Double_t *dd=new double(0.);
    if (!base->SetParamDouble (pkey, "width", dd)) {
	delete dd;
	return -1;
    }
    dd = new Double_t(mass);
    if (!base->SetParamDouble (pkey, "mass", dd)) { 
	delete dd;
	return -1;
    }
    dd = new Double_t(mass);
    if (!base->SetParamDouble (pkey, "ethreshold", dd)) { 
	delete dd;
	return -1;
    }
    ii = new int(0);
    if (!base->SetParamInt (pkey, "meson", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "baryon", ii))
	return -1;
    ii = new int(0); //Meson by default: No limitation in LMass
    if (!base->SetParamInt (pkey, "lepton", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "charge", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "spin", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "parity", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "ispin", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "pythiakf", ii))
	return -1;
    ii = new int(0);  
    if (!base->SetParamInt (pkey, "widx", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "tdepth", ii))
	return -1;
    ii = new int(0);
    if (!base->SetParamInt (pkey, "hdepth", ii))
	return -1;
    return pid;
}

void PStaticData::PrintParticle(int pid) {
    return PrintParticleByKey(makeDataBase()->GetEntryInt("pid", pid));
};


void PStaticData::PrintParticleByKey(int key) {
    makeDataBase()->ListEntries(key, 0, "name,pid,width,mass");

    Int_t listkey=-1, alias_printed=0;
    Int_t *dummy;
    if (makeDataBase()->GetParamInt(key, nalias_param, &dummy)) {
	while (makeDataBase()->MakeListIterator(key, "nalias", "lalias", &listkey)) {
	    alias_printed = 1;
	    cout << "Alias: " << makeDataBase()->GetName(listkey) << endl;;
	}
    }
    if (alias_printed) cout << endl;

    if (!GetParticleNChannelsByKey(key)) {
	cout << "This particle is stable" << endl;
	return;
    }

    cout << "This particle decays via the following modes:" << endl;

    //now loop over decay modes
    listkey = -1;

    while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	PrintDecayByKey(listkey);
    }
  
};

int PStaticData::GetParticleKF(const int id) {
    // return Pythia6 kf code
    if (!id) return 0;
    if (! makeDataBase()->GetParamInt(pid_param, id, pkf_param, &i_result)) {
	Warning("GetParticleKF", "id %i not found", id);
	return 0;
    }
    return *i_result;
}

int PStaticData::GetParticleIDbyKF(const int kf) {
    // return Id corresponding to Pythia6 kf code
    if (!kf) return 0;
    int *id, key;
    
    if ((key = makeDataBase()->GetEntryInt(pkf_param, kf)) < 0) {
	Warning("GetParticleIDbyKF", "invalid kf code %i", *id);
	return 0;
    }
    if (!makeDataBase()->GetParamInt(key, pid_param, &id))
	return 0;
    return *id;
}

int PStaticData::IsParticleMeson(const int &id) {
    // is meson?, by pid
    if (!id) return 0;
    if (! makeDataBase()->GetParamInt(pid_param, id, meson_param, &i_result)) {
	// if not found obviously not a meson
	return 0;
    }
    return *i_result;
}

int PStaticData::IsParticleHadron(const int &id) {
    // is hadron?, by pid
    if (IsParticleMeson(id) || GetParticleBaryon(id)) return 1;
    return 0;
}

int PStaticData::GetParticleBaryon(const int &id) {
    // baryon number by pid
    if (!makeDataBase()->GetParamInt(pid_param, id, baryon_param, &i_result)) {
	// if not found obviously not a baryon
	return 0;
    }
    return *i_result;
};

void PStaticData::SetParticleBaryon(const char *id, Int_t num) {
    // baryon number by name
    if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*)id), baryon_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "baryon", num);
	return;
    }
    *i_result = num;
}

void PStaticData::SetParticleMeson(const char * id, Int_t num) {
 // set meson number
    if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*)id), meson_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "meson", num);
	return;
    }
    *i_result = num;
}

void PStaticData::SetParticleLepton(const char *id, Int_t num) {
    if (! makeDataBase()->GetParamInt(pid_param, GetParticleID((char*)id), lepton_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "lepton", num);
	return;
    }
    *i_result = num;
}

void  PStaticData::SetParticleCharge(const char *id, Int_t charge) {
    if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*)id), charge_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "charge", charge);
	return;
    }
    *i_result = charge;
}

void PStaticData::SetParticleSpin(const char *id, Int_t spin) {
    if (!makeDataBase()->GetParamInt(pid_param, GetParticleID(id), spin_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "spin", spin);
	return;
    }
    *i_result = spin;
}

void PStaticData::SetParticleIsospin(const char *id, Int_t isospin) {
    if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*)id), ispin_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt(GetParticleName(GetParticleID(id)), "ispin", isospin);
    }
    *i_result = isospin;
}

void  PStaticData::SetParticleParity(const char *id, Int_t parity) {
    if (! makeDataBase()->GetParamInt (pid_param,  GetParticleID((char*)id), parity_param, &i_result)) {
	// if not found, set param
	makeDataBase()->SetParamInt (GetParticleName(GetParticleID(id)), "parity", parity);
    }
    *i_result = parity;
}

int PStaticData::GetParticleLepton(const int &id) {
    // lepton number by pid
    if (! makeDataBase()->GetParamInt (pid_param, id, lepton_param, &i_result)) {
	// if not found obviously not a lepton
	return 0;
    }
    return *i_result;
}

int PStaticData::GetParticleCharge(const int &id) {
    // charge by pid
    if (!makeDataBase()->GetParamInt(pid_param, id, charge_param, &i_result)) {
	Warning("GetParticleCharge", "Particle %i not found", id);
	return 0;
    }
    return *i_result;
}

int PStaticData::GetParticleCharge(const char *id) {
    // charge by name
    if (!makeDataBase()->GetParamInt (pid_param, GetParticleID(id), charge_param, &i_result)) {
	Warning("GetParticleCharge", "Particle %s not found", id);
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleSpin(const int &id) {
    // 2 x J by pid
    if (!makeDataBase()->GetParamInt (pid_param, id, spin_param, &i_result)) {
	Warning("GetParticleSpin", "Particle %i not found", id);
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleSpin(const char *id) {
    // 2 x J by name
    if (!makeDataBase()->GetParamInt (pid_param, GetParticleID(id), spin_param, &i_result)) {
	Warning("GetParticleSpin", "Particle %s not found", id);
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleIsospin(const int &id) {
    // 2 x I by pid
    if (!makeDataBase()->GetParamInt (pid_param, id, ispin_param, &i_result)) {
	Warning("GetParticleIsospin", "Particle %i not found", id);
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleIsospin(const char *id) {
    // 2 x I by name
    if (!makeDataBase()->GetParamInt (pid_param, GetParticleID(id),ispin_param , &i_result)) {
	Warning("GetParticleIsospin", "Particle %s not found", id);
	return 0;
    }
    return *i_result;
}

int PStaticData::GetParticleParity(const int &id) {
    // parity (0 if irrelevant)
    if (!makeDataBase()->GetParamInt (pid_param, id, parity_param, &i_result)) {
	Warning("GetParticleParity", "Particle %i not found", id);
	return 0;
    }
    return *i_result;
    
}

int PStaticData::GetParticleParity(const char *id) {
    // parity (0 if irrelevant)
    if (!makeDataBase()->GetParamInt (pid_param, GetParticleID(id), parity_param, &i_result)) {
	Warning("GetParticleParity", "Particle %s not found", id);
	return 0;
    }
    return *i_result;
}

double PStaticData::GetParticleMass(const int &id) {
    // mass by id
    if (!makeDataBase()->GetParamDouble (pid_param, id, mass_param, &d_result)) {
	Warning("GetParticleMass", "Particle %i not found", id);
	return 0;
    }
    return *d_result;
}

double PStaticData::GetParticleMass(const char *id) {
    // mass by name
    if (!makeDataBase()->GetParamDouble (pid_param, GetParticleID(id), mass_param, &d_result)) {
	Warning("GetParticleMass", "Particle %s not found", id);
	return 0;
    }
    return *d_result;
}

double PStaticData::GetParticleMassByKey(const int &id) {
    // mass by key
    if (!makeDataBase()->GetParamDouble (id, mass_param, &d_result)) {
	Warning("GetParticleMassByKey", "Particle %i not found", id);
	return 0;
    }
    return *d_result;
}

void PStaticData::SetParticleMass(Int_t id, Float_t mass) {
    //reset mass
    if (!makeDataBase()->GetParamDouble (pid_param, id, mass_param, &d_result)) {
	Warning("SetParticleMass", "Particle %i not found", id);
    }
    *d_result = mass;
}

void PStaticData::SetParticleMass(const char *id, Float_t mass) {
    //reset mass
    if (!makeDataBase()->GetParamDouble (pid_param, GetParticleID(id), mass_param, &d_result)) {
	Warning("SetParticleMass", "Particle %s not found", id);
    }
    *d_result = mass;
}


const char *PStaticData::GetDecayName(Int_t id) {
    if (!makeDataBase()->GetParamString (didx_param, id, name_param, &c_result)) {
	return "NONAME";
    }
    return c_result;
}

const char *PStaticData::GetDecayNameByKey(Int_t key) {
    if (!makeDataBase()->GetParamString (key, name_param, &c_result)) {
	return "NONAME";
    }
    return c_result;
}

void PStaticData::SetParticleTotalWidth(const char *id, Float_t wid) {   // set new total width
    if (! makeDataBase()->GetParamDouble (pid_param, GetParticleID(id), width_param, &d_result)) {
	Warning("SetParticleTotalWidth", "Particle %s not found", id);
    }
    *d_result = wid;

    SetParticleEmin(GetParticleID(id),GetParticleMass(id)-2*wid);

//TODO
//   Int_t n=PNModes[id], p0=GetPosition(id), p;
//   for (p=p0; p<p0+n; ++p) if (PWidx[p]!=-1) PWidx[p]=0;
//   TWidx[id]=0;
    //printf("\n*** Warning:  Use only at start of macro! ***\n\n");
}

void PStaticData::SetParticleTotalWidth(Int_t id, Float_t wid) {   // set new total width
    if (!makeDataBase()->GetParamDouble (pid_param, id, width_param, &d_result)) {
	Warning("SetParticleTotalWidth", "Particle %i not found", id);
    }
    *d_result = wid;
//TODO
//   Int_t n=PNModes[id], p0=GetPosition(id), p;
//   for (p=p0; p<p0+n; ++p) if (PWidx[p]!=-1) PWidx[p]=0;
//   TWidx[id]=0;
    Warning("SetParticleTotalWidth", "Use only at start of macro! ***");
}

int PStaticData::GetTWidx(const int &id) {
    // width flag from index
    // 0: static width only
    // 1: use dynamic width
    //-1: Disabled
    if (!makeDataBase()->GetParamInt (pid_param, id, widx_param, &i_result)) {
	Warning("GetTWidx", "Particle %i not found", id);
	return 0;
    }
    
    return *i_result;
}

int PStaticData::GetPWidx(const int &id) {
    // width flag from index
    // 0: static width only
    // 1: use dynamic width
    //-1: Disabled
    if (!makeDataBase()->GetParamInt (didx_param, id , widx_param, &i_result)) {
	Warning("GetPWidx", "Decay %i not found", id);
	return 0;
    }
    return *i_result;
}

void PStaticData::SetTWidx(const int & id, const int & v) {
    // width flag from index
    // 0: static width only
    // 1: use dynamic width
    
    if (! makeDataBase()->GetParamInt (pid_param, id , widx_param, &i_result)) {
	Error("SetTWidx", "Particle %i not found", id);
    }
    *i_result = v;
}

void PStaticData::SetPWidx(const int &id, const int &v) {
    // width flag from index
    // 0: static width only
    // 1: use dynamic width
    
    if (!makeDataBase()->GetParamInt (didx_param, id , widx_param, &i_result)) {
	Warning("SetPWidx", "Decay %i not found", id);
    }
    *i_result = v;
}

void PStaticData::SetTWidthMesh(const int &id, PMesh *mesh) {

    Int_t key = makeDataBase()->GetEntryInt("pid", id);
    if (!makeDataBase()->SetParamTObj(key, "mesh", mesh)) {
      Warning("SetTWidthMesh", "Particle %i: failed", id);
    }
}

PMesh *PStaticData::GetTWidthMesh(const int &id) {
    if (!makeDataBase()->GetParamTObj(pid_param, id, mesh_param, &t_result)) {
	Error("GetTWidthMesh", "Particle %i not found", id);
	return NULL;
    }
    return (PMesh *) t_result;
}

void PStaticData::SetPWidthMesh(const int &id, PMesh *mesh) {
    Int_t key = makeDataBase()->GetEntryInt("didx", id);
    if (!makeDataBase()->SetParamTObj(key, "mesh", mesh)) {
      Error("SetPWidthMesh", "Decay %i: failed", id);
    }
}


PMesh *PStaticData::GetPWidthMesh(const int &id) {
    if (!makeDataBase()->GetParamTObj (didx_param, id, mesh_param, &t_result)) {
	Error("GetPWidthMesh", "Decay %i not found", id);
	return NULL;
    }
    return (PMesh *) t_result;
}

void PStaticData::SetTF1(const int &id, TF1 *mesh) {
    Int_t key = makeDataBase()->GetEntryInt("pid", id);
    if (! makeDataBase()->SetParamTObj(key, "tf1", mesh)) {
      Error("SetTF1", "Particle %i: failed", id);
    }
}

TF1 *PStaticData::GetTF1(const int &id) {
    if (!makeDataBase()->GetParamTObj(pid_param, id, tf1_param, &t_result)) {
//	cout << "PStaticData::GetTF1: " << id << " not found" << endl;
	return NULL;
    }
    return (TF1 *) t_result;
};

Double_t PStaticData::GetDecayEmin(const int &id) {
    if (!makeDataBase()->GetParamDouble(didx_param, id, ethreshold_param, &d_result)) {
	Warning("GetDecayEmin", "Decay %i not found", id);
	return 0;
    }
    return *d_result;
}

int PStaticData::GetDecayBRFlag(int didx){
    if (!makeDataBase()->GetParamInt(didx_param, didx, brflag_param, &i_result)) {
	return 0;
    }
    return *i_result;
}

void PStaticData::SetDecayBRFlag(int didx, int flag) {
    //Set the BR flag for the "didx", thus the total normalization
    //is used (when flag=1) instead of the pole mass
    if (!makeDataBase()->GetParamInt (didx_param, didx, brflag_param, &i_result)) {
	Int_t *ii = new Int_t(flag);
	if (!makeDataBase()->SetParamInt (GetDecayKey(didx), "brflag", ii)) {
	    delete ii;
	    return;
	}
    } else {
	*i_result = flag;
    }
}

void PStaticData::SetTotalNormalization(char *p, int flag) {
    //Wrapper function which enables the total normalization
    //for a particle "p"
    Int_t listkey = -1;
    Int_t key = GetParticleKey(p);
    if (key < 0) {
	Warning("SetTotalNormalization", "Invalid particle %s", p);
	return;
    }
    
    while(makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	if (!makeDataBase()->GetParamInt(listkey, brflag_param, &i_result)) {
	    Int_t *ii = new Int_t(flag);
	    if (!makeDataBase()->SetParamInt(listkey, "brflag", ii)) {
		delete ii;
		return;
	    }
	} else {
	    *i_result = flag;
	}
    }
}

void PStaticData::SetDecayEmin(const int &id, const double v) {
    if (!makeDataBase()->GetParamDouble(didx_param, id , ethreshold_param, &d_result)) {
	Warning("SetDecayEmin", "Decay %i not found", id);
    }
    *d_result = v;   
}

Double_t PStaticData::GetParticleEmin(const int &id) {
    if (!makeDataBase()->GetParamDouble(pid_param, id, ethreshold_param, &d_result)) {
	Error("GetParticleEmin", "Particle %i not found", id);
	return 0;
    }
    return *d_result;   
}

void PStaticData::SetParticleEmin(const int &id, const double v) {
    if (! makeDataBase()->GetParamDouble (pid_param, id, ethreshold_param, &d_result)) {
	Warning("SetParticleEmin", "Particle %i not found", id);
    }
    *d_result = v;   
}

Double_t PStaticData::GetParticleLMass(const int &id) {
    if (! makeDataBase()->GetParamDouble(pid_param, id, lmass_param, &d_result)) {
	Warning("GetParticleLMass", "Particle %i not found", id);
	return 0;
    }
    return *d_result;   
}

void PStaticData::SetParticleLMass(const char *id, const double v) {
    if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID((char*)id), lmass_param, &d_result)) {
	// if not found, set param
	makeDataBase()->SetParamDouble(GetParticleName(GetParticleID(id)), "lmass", v);
	return;
    }
    *d_result = v;
}

Double_t PStaticData::GetParticleUMass(const int & id) {
    if (!makeDataBase()->GetParamDouble(pid_param, id, umass_param, &d_result)) {
	Warning("GetParticleUMass", "Particle %i not found", id);
	return 0;
    }
    return *d_result;   
}

void PStaticData::SetParticleUMass(const char *id, const double v) {
    if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID((char*)id), umass_param, &d_result)) {
	// if not found, set param
	makeDataBase()->SetParamDouble(GetParticleName(GetParticleID(id)), "umass", v);
	return;
    }
    *d_result = v;
}

int PStaticData::GetTDepth(const int &id) {
    if (!makeDataBase()->GetParamInt(pid_param, id, tdepth_param, &i_result)) {
	Warning("GetTDepth", "Particle %i not found", id);
	return 0;
    }
    return *i_result;   
}

void PStaticData::SetTDepth(const int &id, const int & depth) {
    if (!makeDataBase()->GetParamInt (pid_param, id, tdepth_param, &i_result)) {
	Warning("SetTDepth", "Particle %i not found", id);
    }
    *i_result = depth;   
}

int PStaticData::GetHDepth(const int & id) {
    if (!makeDataBase()->GetParamInt(pid_param, id, hdepth_param, &i_result)) {
	Warning("GetHDepth", "Particle %i not found", id);
	return 0;
    }
    return *i_result;   
}

void PStaticData::SetHDepth(const int & id, const int & depth) {
    if (!makeDataBase()->GetParamInt(pid_param, id, hdepth_param, &i_result)) {
	Warning("SetHDepth", "Particle %i not found", id);
    }
    *i_result=depth;   
}

Double_t PStaticData::GetDecayBR(Int_t id) {
    if (!makeDataBase()->GetParamDouble(didx_param, id, br_param, &d_result)) {
	Warning("GetDecayBR", "Decay %i not found", id);
    }
    return *d_result;

};

Double_t PStaticData::GetDecayPartialWidth(Int_t id) {
    double res = GetDecayBR(id)*GetParticleTotalWidth(GetDecayParent(id));
    return res;
};

Double_t PStaticData::GetDecayPartialWidthByKey(Int_t id) {
    double res = GetDecayBR(id)*GetParticleTotalWidth(GetDecayParentByKey(id));
    return res;
};


bool PStaticData::SetDecayBR(int didx, double br, int mode) {
    //Mode: see SetDecayBR(const char *parent, const char *daughters)

    clearFreezeOut();
    Int_t key = GetDecayKey(didx);
    Double_t *brorig;
    if (!makeDataBase()->GetParamDouble (key, "brorig", &brorig)) return kFALSE;

    if (mode) {
	Double_t other = 1.-GetDecayBR(didx);
	br = (other * br)/(1.-br);
    }

    *brorig = br;
    
    return NormParticleBRbyKey(GetParticleKey(GetDecayParentByKey(key)));
}

bool PStaticData::SetDecayBRByKey(int key, double br, int mode) {
    //Mode: see SetDecayBR(const char *parent, const char *daughters)
    clearFreezeOut();
    Double_t *brorig;
    if (!makeDataBase()->GetParamDouble (key, "brorig", &brorig)) return kFALSE;

    if (mode) {
	Double_t other = 1.-GetDecayBR(GetDecayIdxByKey(key));
	br = (other * br)/(1.-br);
    }

    *brorig = br;
    return NormParticleBRbyKey(GetParticleKey(GetDecayParentByKey(key)));
}

bool PStaticData::SetDecayBR(const char *parent, const char *daughters, 
			     double br, int mode) {
    // Resets the decay branching ratio of an existing decay
    // Handle this functon with care!
    // Do not use this function to change the weighting etc.
    // because the change of the decay b.r. will affect the
    // shape of the parent resonance
    // 
    // If you have really physics arguments to change the b.r.
    // (e.g. update of PDG values)
    // you *must* use this function at the very beginning of your macro,
    // but at least before the "GetWidth" is called
    //
    // Mode flag:
    // 0: Add the new b.r. to the existing ones + re-weighting
    // 1: No re-weighting (in this case br must be <1.)


    //get parent key
    Int_t parent_key = makeDataBase()->GetEntry(parent);
    if (parent_key < 0) {
	Warning("SetDecayBR", "Parent %s not found in data base", parent);
	return kFALSE;
    }

    Int_t pid = GetParticleIDByKey(parent_key);
    if (pid < 0) {
	return kFALSE;
    }

    //now check the daughters 
    //TODO: All this should go into a help function
    char *arr1[7];
    Int_t arr1_s = 7; //max 7 decay products
    
    PUtils::Tokenize(daughters, ",", arr1, &arr1_s);

    Int_t pids[8];
    pids[0] = pid;
    for (int pat = 0; pat<arr1_s; pat++) {
	pids[pat+1] = GetParticleID(arr1[pat]);
    }

    Int_t decay_key = GetDecayKey(pids, arr1_s);

    if (decay_key < 0) {
	Warning("SetDecayBR", "Decay %s -> %s not defined", parent,daughters);
	return kFALSE;
    }
    
    return SetDecayBRByKey(decay_key, br, mode);
}

// This was the old Kagarlis method:
//   if (brn<1 || brn>PNModes[id]) return;
//   Int_t pos = GetPosition(id);
//   if (pos!=-1) {
//      Int_t idx = pos+brn-1;
//      PBR[idx] = br;
//      if (freeze) {
//        PWidx[idx] = -1;   // Set BR flag to static
//        printf("Branch %3i set static to %f\n",idx,br);
//      }
//      printf("\n*** Warning:  Use only at start of macro! ***\n\n");
//   }
//}

bool PStaticData::NormParticleBR(Int_t id) { 
// normalize branching ratios for particle id
    //TODO: check if this works
    Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
    return NormParticleBRbyKey(key);
}

bool PStaticData::NormParticleBRbyKey(Int_t key) { 
// normalize branching ratios for particle id

    Int_t listkey = -1;
    double sum    = 0.;
    Double_t *br, *brorig, *width;
    Double_t twidth = GetParticleTotalWidthByKey(key);
    
    if (GetParticleNChannelsByKey(key) == 0) return kFALSE;

    while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	if (!makeDataBase()->GetParamDouble(listkey, "brorig", &brorig)) return kFALSE;
	sum += *brorig;
    }
    
    listkey = -1;
    if (sum > 0.) 
	while(makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	    if (!makeDataBase()->GetParamDouble (listkey, "brorig", &brorig)) return kFALSE;
	    if (!makeDataBase()->GetParamDouble (listkey, "br", &br)) return kFALSE;
	    *br = *brorig/sum;
	    if (makeDataBase()->GetParamDouble (listkey, "width", &width)) {
		*width= *br * twidth;
	    }
	}
    return kTRUE;
}

void PStaticData::FreezeDecayBR(Int_t, Int_t) { // set BR static
    Fatal("FreezeDecayBR", "not implemented");

    //TODO
//   Int_t pos = GetPosition(id);
//   if (pos!=-1) {
//      Int_t idx = pos+brn-1;
//      PWidx[idx] = -1;
//      printf("Branch %3i set static\n",idx);
//      printf("\n*** Warning:  Use only at start of macro! ***\n\n");
//   }
}

int PStaticData::GetParticleNChannels(const int &id) {
    // number of decay channels by pid
    if (! makeDataBase()->GetParamInt (pid_param, id, pnmodes_param, &i_result)) {
	// if not found obviously no decay
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleNChannels(const char *id) {
// number of decay channels by name
    if (! makeDataBase()->GetParamInt ((char*)id, "pnmodes", &i_result)) {
	return 0;
    }
    return *i_result;
};

int PStaticData::GetParticleNChannelsByKey(int key) {
// number of decay channels by key
    if (! makeDataBase()->GetParamInt (key, "pnmodes", &i_result)) {
	return 0;
    }
    return *i_result;
}

int PStaticData::IsDecayHadronic(Int_t didx) {
    Int_t tid[11];
    tid[0] = 10; 

    GetDecayMode(didx, tid); 
    for (int i=1; i<tid[0]; i++) {
	if (!IsParticleHadron(tid[1])) return 0;
    }
    return 1;
}

int PStaticData::AddDecay(int *ipid, int n) {
    //For internal use, e.g. PChannel

    TString *decay_string  = new TString("");
    TString *decay_string2 = new TString(makeStaticData()->GetParticleName(ipid[0]));
    decay_string2->Append(" --> ");	
    //first I have to check that my decay_string is big enough
    for (int i=1; i<=n; i++) {
	if (ipid[i] > 1000) 
	    decay_string2->Append("(");
	decay_string->Append(makeStaticData()->GetParticleName(ipid[i]));
	decay_string2->Append(makeStaticData()->GetParticleName(ipid[i]));
	if (ipid[i] > 1000) 
	    decay_string2->Append(")");
	if (i != n) decay_string->Append(" , ");	
	if (i != n) decay_string2->Append(" + ");
	
    }
    if (makeStaticData()->AddDecay(-1, (const char*) decay_string2->Data(), 
				   makeStaticData()->GetParticleName(ipid[0]), 
				   (const char*) decay_string->Data() , 1.0 )) {
	
	//Info("AddDecay","(%s) Decay of added: %s", PRINT_AUTO_ALLOC,decay_string->Data());
    } else {
	Warning("AddDecay", "Add Decay failed");
    }
    
    return makeStaticData()->GetDecayKey(ipid, n);
}

int PStaticData::AddDecay(int didx, const char *name, const char *parent, 
			  const char *daughters , double br) {
    //make new decay with decay index "didx"
    //the didx should be a free number (or set to -1 for auto-alloc)
    //parent particle is "parent", which must be existing
    //"name" is the new unique string identifier of the decay
    //daughers is an particle array of the format "p1,p2,p3,..."
    //br is the branching ratio
    //all branching ratios are re-normalized
    clearFreezeOut();
    PDataBase *base = makeDataBase();
  
    //get parent key
    Int_t parent_key = GetParticleKey(parent);
    if (parent_key < 0) {
	Warning("AddDecay", "Parent %s not found in data base", parent);
	return -1;
    }

    Int_t pid = GetParticleIDByKey(parent_key);
    if (pid < 0) {
	Error("AddDecay", "Parent %s has no pid", parent);
	return -1;
    }
    if (didx < 0) {
	if (pid < 1000) 
	    didx = pid*32;
	else 
	    didx = pid;
	while (makeDataBase()->GetEntryInt("didx",didx) >=0 ) {
	    didx++;
	}
	if (*system_alloc_verbosity)
	    Info("AddDecay", "(%s) Decay index %i: %s", PRINT_AUTO_ALLOC, didx, name);
    }

    //check if didx already exists
    if (makeDataBase()->GetEntryInt("didx",didx) >=0 ) {
	Error("AddDecay", "Didx %i already used in data base", didx);
	return -1;
    }
    Int_t dkey = makeDataBase()->AddListEntry(GetParticleName(pid),"pnmodes", "link", name);
    if (dkey < 0) {
	Warning("AddDecay", "Unable to add decay entry to data base");
	return -1;
    }

    //now add the daughters
    char *arr1[7];
    Int_t arr1_s = 7; //max 7 decay products
    
    PUtils::Tokenize(daughters, ",", arr1, &arr1_s);
    //does decay already exist?

    Int_t pids[8];
    pids[0] = pid;
    // cout << pid << endl;
    for (int pat = 0; pat<arr1_s; pat++) {
	pids[pat+1] = GetParticleID(arr1[pat]);
    }
    if (GetDecayKey(pids, arr1_s) >= 0) {
	Warning("AddDecay", "Decay already defined");
	return -1;
    }

    for (int pat = 0; pat<arr1_s; pat++) {
	char *partc = arr1[pat];
	//	Int_t *pkey = new int(base->GetEntry(partc));
	//This takes into account aliases:
	Int_t *pkey = new int(makeStaticData()->GetParticleKey(partc));
	if (*pkey < 0) {
	    Error("AddDecay", "processing decay: do not find pid %s", partc);
	} 
	const char *ds;
	if (pat == 0) ds = "d1";
	if (pat == 1) ds = "d2";
	if (pat == 2) ds = "d3";
	if (pat == 3) ds = "d4";
	if (pat == 4) ds = "d5";
	if (pat == 5) ds = "d6";
	if (pat == 6) ds = "d7";
	if (pat > 6) {
	    Warning("AddDecay", "Too many particles");
	    return -1;
	}
	
	base->SetParamInt(dkey, ds, pkey);
    }
    //set default values
    Int_t *ii;
    makeDataBase()->GetParamInt(parent_key, "pid", &ii);
    base->SetParamInt(dkey, "ppid", ii); //set parent id
    
    ii = new int(didx);
    base->SetParamInt(dkey, "didx", ii); //decay mode index
    
    ii = new int(0);  //never destructed, but called only once!
    if (!base->SetParamInt(dkey, "widx", ii))
	return -1;
    
    Double_t *dd = new double(br);
    if (!base->SetParamDouble(dkey, "br", dd))
	return -1;
    if (!base->SetParamDouble(dkey, "brorig", new Double_t(br)))
	return -1;
    dd = new Double_t(0.);
    if (!base->SetParamDouble(dkey, "ethreshold", dd))
	return -1;
    dd = new Double_t(1.);
    if (!base->SetParamDouble(dkey, "scfactor", dd))
	return -1;

    if (pid > 1000) //Do not norm compostite
	return didx;

    if (!NormParticleBRbyKey(parent_key) ) return -1;
    return didx;
}

void PStaticData::PrintDecayByKey(int key) {
    Int_t products = GetDecayNProductsByKey(key);
    if (products == 1)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name");
    if (products == 2)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name");
    if (products == 3)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name");
    if (products == 4)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name");
    if (products == 5)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name");
    if (products == 6)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name,d6:name");
    if (products == 7)
	makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name,d6:name,d7:name");
}

int PStaticData::GetDecayNProductsByKey(const int &key) {
// retrieve number of products by mode key
    if (makeDataBase()->GetParamInt(key, d7_param, &i_result))
	return 7;
    if (makeDataBase()->GetParamInt(key, d6_param, &i_result))
	return 6;
    if (makeDataBase()->GetParamInt(key, d5_param, &i_result))
	return 5;
    if (makeDataBase()->GetParamInt(key, d4_param, &i_result))
	return 4;
    if (makeDataBase()->GetParamInt(key, d3_param, &i_result))
	return 3;
    if (makeDataBase()->GetParamInt(key, d2_param, &i_result))
	return 2;
    if (makeDataBase()->GetParamInt(key, d1_param, &i_result))
	return 1;
    return 0;
}

int PStaticData::GetDecayNProducts(const int &id) {
// retrieve number of products by mode index 
    if (makeDataBase()->GetParamInt(didx_param, id, d7_param, &i_result))
	return 7;
    if (makeDataBase()->GetParamInt(didx_param, id, d6_param, &i_result))
	return 6;
    if (makeDataBase()->GetParamInt(didx_param, id, d5_param, &i_result))
	return 5;
    if (makeDataBase()->GetParamInt(didx_param, id, d4_param, &i_result))
	return 4;
    if (makeDataBase()->GetParamInt(didx_param, id, d3_param, &i_result))
	return 3;
    if (makeDataBase()->GetParamInt(didx_param, id, d2_param, &i_result))
	return 2;
    if (makeDataBase()->GetParamInt(didx_param, id, d1_param, &i_result))
	return 1;
    return 0;
}

int PStaticData::GetDecayNProducts(const char *id){
// number of products by name     
    if (makeDataBase()->GetParamInt((char*)id, "d7", &i_result))
	return 7;
    if (makeDataBase()->GetParamInt((char*)id, "d6", &i_result))
	return 6;
    if (makeDataBase()->GetParamInt((char*)id, "d5", &i_result))
	return 5;
    if (makeDataBase()->GetParamInt((char*)id, "d4", &i_result))
	return 4;
    if (makeDataBase()->GetParamInt((char*)id, "d3", &i_result))
	return 3;
    if (makeDataBase()->GetParamInt((char*)id, "d2", &i_result))
	return 2;
    if (makeDataBase()->GetParamInt((char*)id, "d1", &i_result))
	return 1;
    return 0;
}

int PStaticData::GetDecayParent(const int &id) {
    if (! makeDataBase()->GetParamInt (didx_param, id, ppid_param, &i_result)) {
	// if not found obviously no parent
	return 0;
    }
    return *i_result;
}

int PStaticData::GetDecayParentByKey(const int &id) {
    if (! makeDataBase()->GetParamInt (id, ppid_param, &i_result)) {
	// if not found obviously no parent
	return 0;
    }
    return *i_result;
}

int PStaticData::GetDecayIdxByKey(int key) {
    // return value is -1 on failure

    Int_t *pos;
    if (!makeDataBase()->GetParamInt(key, didx_param , &pos))
	return -1;
    return *pos;
}

int PStaticData::GetDecayIdx(int *pid, int n) {
    // decay-mode index from parent and product ids;
    // n is the size of the array
    // arguments: pointer to pid array of parent & products,
    //            number of products

    int i, nid[n];
    if (n<2 || !pid) return -1;
    for (i=0; i<=n; ++i) {
	if (!PStaticData::IsParticleValid(pid[i])) {
	    Warning("GetDecayIdx", "id %i not found", pid[i]);
	    return -2;
	}
	else if (i) nid[i-1]=pid[i];        // make own copy of product array
    }
    PUtils::isort(nid, n);                 // sort the array entries

    int id = pid[0], *nm;        // parent id, number of decay modes
    //Get count info
  
    if (!makeDataBase()->GetParamInt(pid_param, id, count_param, &nm)) {
	return -3;
    }
    if (!nm) return -4;
    Int_t count;
    //now loop over decay modes
    Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
    Int_t listkey = -1;
    Int_t tid[11];
    while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	tid[0] = 10; 
	GetDecayModeByKey(listkey, tid);      // retrieve current mode info
	if (tid[0] == n) {                    // number of products matches input
	    PUtils::isort(tid+1, n);          // sort the current mode product pid array
	    count = 0;                        // reset the match counter
	    for (i=0; i<n; ++i) count += (tid[i+1]==nid[i]);
	    if (count == n) {                 // input matched
		return GetDecayIdxByKey(listkey);          
	    }
	}
    }
  
    return -1;
}

int PStaticData::GetDecayIdx(const char *parent, const char *daughters) {
    //get parent key
    Int_t parent_key = GetParticleKey(parent);
    if (parent_key < 0) {
	Error("AddDecay", "Parent %s not found in data base", parent);
	return -1;
    }

    Int_t pid = GetParticleIDByKey(parent_key);
    if (pid < 0) {
	Error("AddDecay", "Parent %s has no pid", parent);
	return -1;
    }

    //now add the daughters
    char *arr1[MAX_DAUGHTERS];
    Int_t arr1_s = MAX_DAUGHTERS; //max decay products
    
    PUtils::Tokenize(daughters, ",", arr1, &arr1_s);
    //does decay already exist?

    Int_t pids[MAX_DAUGHTERS+1];
    pids[0] = pid;
 
    for (int pat=0; pat<arr1_s; pat++) {
	pids[pat+1] = GetParticleID(arr1[pat]);
    }

    Int_t key = GetDecayKey(pids, arr1_s);
    if (key >= 0) {	
	return GetDecayIdxByKey(key);
    }
    return -1;   
}

int PStaticData::GetDecayKey(int *pid, int n) {
    // decay-mode key from parent and product ids;
    // n is the size of the daughters array
    // arguments: pointer to pid array of parent & products,
    //            number of products

    int i, nid[n];
    if (n<1 || !pid) return -1;
    for (i=0; i<=n; ++i) {
	if (!PStaticData::IsParticleValid(pid[i])) {
	    Warning("GetDecayKey", "id %i not found", pid[i]);
	    return -2;
	} else if (i) { 
	    nid[i-1] = pid[i];        // make own copy of product array
	}
    }

    PUtils::isort(nid, n);                 // sort the array entries

    int id = pid[0], *nm;        // parent id, number of decay modes
    //Get count info
    if (!makeDataBase()->GetParamInt(pid_param, id, count_param, &nm)) {
	return -3;
    }
    if (!nm) return -4;
    Int_t count;
    //now loop over decay modes
    Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
    Int_t listkey = -1;
    Int_t tid[11];
    while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
	tid[0] = 10; 
	GetDecayModeByKey(listkey, tid);      // retrieve current mode info
	if (tid[0] == n) {                    // number of products matches input
	    PUtils::isort(tid+1, n);          // sort the current mode product pid array
	    count = 0;                        // reset the match counter
	    for (i=0; i<n; ++i) count += (tid[i+1]==nid[i]);
	    if (count ==n ) {                 // input matched
		return listkey;          
	    }
	}
    }
  
    return -1;
}

void PStaticData::GetDecayMode(int idx, int *id) {
    // Retrieves the decay mode info for a given channel n.
    // _______________________________________________________________________
    // ARGUMENTS: 1. decay-mode index (PPosition),
    // 2. pointer to existing integer array (must have large 
    // enough dimension), 3. pointer to existing double (optional).
    // _______________________________________________________________________
    // RETURNS: int array with N, i_1, i_2,..., i_N, where N is
    // the number of products for the decay mode with index n,
    // followed by the pids of these products
    //
    // N should contain the maximum number of the array-size of before
    // calling this function
    // if the maximum is exceeded, or any other error occurs, N is set to 0
    Int_t *d1_key, *d2_key, *d3_key, *d4_key, *d5_key, 
	*d6_key, *d7_key, found = 0;
    if (makeDataBase()->GetParamInt(didx_param, idx, d1_param, &d1_key)) 
	found = 1;
    if (makeDataBase()->GetParamInt(didx_param, idx, d2_param, &d2_key)) 
	found = 2;
    if (makeDataBase()->GetParamInt(didx_param, idx, d3_param, &d3_key)) 
	found = 3;
    if (makeDataBase()->GetParamInt(didx_param, idx, d4_param, &d4_key)) 
	found = 4;
    if (makeDataBase()->GetParamInt(didx_param, idx, d5_param, &d5_key)) 
	found = 5;
    if (makeDataBase()->GetParamInt(didx_param, idx, d6_param, &d6_key)) 
	found = 6;
    if (makeDataBase()->GetParamInt(didx_param, idx, d7_param, &d7_key)) 
	found = 7;
 
    if (found > *id) {
	Warning("GetDecayMode", "size too low");
	*id = 0;
	return;
    } else 
	*id = found;

    Int_t *d1_p=NULL, *d2_p=NULL, *d3_p=NULL, *d4_p=NULL,
	*d5_p=NULL, *d6_p=NULL, *d7_p=NULL;

    if ((found>0)&& !makeDataBase()->GetParamInt(*d1_key,pid_param,&d1_p)) {
	Warning("GetDecayMode", "unable to unpack key1 %i", *d1_key);
	*id = 0;	
    }
    else if ((found>1)&& !makeDataBase()->GetParamInt(*d2_key,pid_param,&d2_p)) {
	Warning("GetDecayMode", "unable to unpack key2 %i", *d2_key);
	*id = 0;
    } 
    else if ((found>2)&& !makeDataBase()->GetParamInt(*d3_key,pid_param,&d3_p)) {
	Warning("GetDecayMode", "unable to unpack key3 %i", *d3_key);
	*id = 0;
    } 
    else if ((found>3)&& !makeDataBase()->GetParamInt(*d4_key,pid_param,&d4_p)) {
	Warning("GetDecayMode", "unable to unpack key4 %i", *d4_key);
	*id = 0;
    } 
    else if ((found>4)&& !makeDataBase()->GetParamInt(*d5_key,pid_param,&d5_p)) {
	Warning("GetDecayMode", "unable to unpack key5 %i", *d5_key);
	*id = 0;
    } 
    else if ((found>5)&& !makeDataBase()->GetParamInt(*d6_key,pid_param,&d6_p)) {
	Warning("GetDecayMode", "unable to unpack key6 %i", *d6_key);
	*id = 0;
    } 
    else if ((found>6)&& !makeDataBase()->GetParamInt(*d7_key,pid_param,&d7_p)) {
	Warning("GetDecayMode", "unable to unpack key7 %i", *d7_key);
	*id = 0;
    } 
    if (d1_p) id[1] = *d1_p;
    if (d2_p) id[2] = *d2_p;
    if (d3_p) id[3] = *d3_p;
    if (d4_p) id[4] = *d4_p;
    if (d5_p) id[5] = *d5_p;
    if (d6_p) id[6] = *d6_p;
    if (d7_p) id[7] = *d7_p;
}


void PStaticData::GetDecayModeByKey(int idx, int *id) {
    //same as above, but by data base key    
    Int_t *d1_key, *d2_key, *d3_key, *d4_key, *d5_key,
	*d6_key, *d7_key, found=0;
    if (makeDataBase()->GetParamInt(idx, d1_param, &d1_key)) 
	found = 1;
    if (makeDataBase()->GetParamInt(idx, d2_param, &d2_key)) 
	found = 2;
    if (makeDataBase()->GetParamInt(idx, d3_param, &d3_key)) 
	found = 3;
    if (makeDataBase()->GetParamInt(idx, d4_param, &d4_key)) 
	found = 4;
    if (makeDataBase()->GetParamInt(idx, d5_param, &d5_key)) 
	found = 5;
    if (makeDataBase()->GetParamInt(idx, d6_param, &d6_key)) 
	found = 6;
    if (makeDataBase()->GetParamInt(idx, d7_param, &d7_key)) 
	found = 7;

    if (found > *id) {
	Warning("GetDecayModeByKey", "size too low");
	*id = 0;
	return;
    } else 
	*id = found;

    Int_t *d1_p=NULL, *d2_p=NULL, *d3_p=NULL, *d4_p=NULL,
	*d5_p=NULL, *d6_p=NULL, *d7_p=NULL;

    if (*id>0 && !makeDataBase()->GetParamInt(*d1_key,pid_param,&d1_p)) {
	Warning("GetDecayMode", "unable to unpack key1 %i", *d1_key);
	*id = 0;
    }
    else if (*id>1 && !makeDataBase()->GetParamInt(*d2_key,pid_param,&d2_p)) {	
	Warning("GetDecayMode", "unable to unpack key2 %i", *d2_key);
	*id = 0;
    } 
    else if (*id>2 && !makeDataBase()->GetParamInt(*d3_key,pid_param,&d3_p)) {
	Warning("GetDecayMode", "unable to unpack key3 %i", *d3_key);
	*id = 0;
    }
    else if (*id>3 && !makeDataBase()->GetParamInt(*d4_key,pid_param,&d4_p)) {
	Warning("GetDecayMode", "unable to unpack key4 %i", *d4_key);
	*id = 0;
    } 
    else if (*id>4 && !makeDataBase()->GetParamInt(*d5_key,pid_param,&d5_p)) {
	Warning("GetDecayMode", "unable to unpack key5 %i", *d5_key);
	*id = 0;
    }
    else if (*id>5 && !makeDataBase()->GetParamInt(*d6_key,pid_param,&d6_p)) {
	Warning("GetDecayMode", "unable to unpack key6 %i", *d6_key);
	*id = 0;
    } 
    else if (*id>6 && !makeDataBase()->GetParamInt(*d7_key,pid_param,&d7_p)) {
	Warning("GetDecayMode", "unable to unpack key7 %i", *d7_key);
	*id = 0;
    }
    if (d1_p) id[1] = *d1_p;
    if (d2_p) id[2] = *d2_p;
    if (d3_p) id[3] = *d3_p;
    if (d4_p) id[4] = *d4_p;
    if (d5_p) id[5] = *d5_p;
    if (d6_p) id[6] = *d6_p;
    if (d7_p) id[7] = *d7_p;
}

double PStaticData::GetParticleTotalWidth(const int &id) {
    // PWidth[id]
    if (!makeDataBase()->GetParamDouble(pid_param, id, width_param, &d_result)) {
	Warning("GetParticleTotalWidth", "Particle %i not found", id);
	return 0;
    }
    return *d_result;
}

double PStaticData::GetParticleTotalWidthByKey(const int &key) {
    // PWidth[id]
    if (!makeDataBase()->GetParamDouble(key, width_param, &d_result)) {
	Warning("GetParticleTotalWidthByKey", "Particle with key %i not found", key);
	return 0;
    }
    return *d_result;
}

void PStaticData::SetEnhanceChannelBR(const int id, const double factor) {
    if (!makeDataBase()->GetParamDouble(didx_param, id, enhance_br_param, &d_result)) {
	makeDataBase()->SetParamDouble(makeDataBase()->GetEntryInt(didx_param, id), 
				       "enhance_br", new Double_t(factor));
	return;
    }
    *d_result=factor;
};

void PStaticData::SetEnhanceChannelBR(const char *parent, const char *decay, Double_t factor) {
    Int_t didx = GetDecayIdx(parent, decay);
    if (didx < 0) {
	Error("SetEnhanceChannelBR", "Decay %s -> %s not found in data base", parent, decay);
	return;
    }
    SetEnhanceChannelBR(didx, factor);
}

void PStaticData::DisableAllChannelBR(const char *parent) {
    Int_t key = GetParticleKey(parent);
    if (key < 0) {
	Error("DisableAllChannelBR", "Parent %s not found in data base", parent);
	return;
    }
    Int_t *didx;
    Int_t listkey    = -1;
    Int_t link_param = makeDataBase()->GetParamInt("link");
    while (makeDataBase()->MakeListIterator
	   (key, pnmodes_param, link_param, &listkey)) {	
	makeDataBase()->GetParamInt 
	    (listkey, didx_param , &didx); //small workaround -> should work on keys
	SetEnhanceChannelBR(*didx, 0.);
    }
}

Double_t PStaticData::GetEnhanceChannelBR(const int id) {
    if (! makeDataBase()->GetParamDouble (didx_param, id , enhance_br_param, &d_result)) {
	return 1.;
    }
    return *d_result;
}

void listParticle(int id) {
   
    if (id<0) {
        makeStaticData(); //this fill data base
	makeDataBase()->ListEntries(-1, 1, "pid,*name");
    }
    else
        makeStaticData()->PrintParticle(id);
}

void listModes(int id) {
   makeStaticData()->PrintParticle(id);
}
 


ClassImp(PStaticData)
 PStaticData.cc:1
 PStaticData.cc:2
 PStaticData.cc:3
 PStaticData.cc:4
 PStaticData.cc:5
 PStaticData.cc:6
 PStaticData.cc:7
 PStaticData.cc:8
 PStaticData.cc:9
 PStaticData.cc:10
 PStaticData.cc:11
 PStaticData.cc:12
 PStaticData.cc:13
 PStaticData.cc:14
 PStaticData.cc:15
 PStaticData.cc:16
 PStaticData.cc:17
 PStaticData.cc:18
 PStaticData.cc:19
 PStaticData.cc:20
 PStaticData.cc:21
 PStaticData.cc:22
 PStaticData.cc:23
 PStaticData.cc:24
 PStaticData.cc:25
 PStaticData.cc:26
 PStaticData.cc:27
 PStaticData.cc:28
 PStaticData.cc:29
 PStaticData.cc:30
 PStaticData.cc:31
 PStaticData.cc:32
 PStaticData.cc:33
 PStaticData.cc:34
 PStaticData.cc:35
 PStaticData.cc:36
 PStaticData.cc:37
 PStaticData.cc:38
 PStaticData.cc:39
 PStaticData.cc:40
 PStaticData.cc:41
 PStaticData.cc:42
 PStaticData.cc:43
 PStaticData.cc:44
 PStaticData.cc:45
 PStaticData.cc:46
 PStaticData.cc:47
 PStaticData.cc:48
 PStaticData.cc:49
 PStaticData.cc:50
 PStaticData.cc:51
 PStaticData.cc:52
 PStaticData.cc:53
 PStaticData.cc:54
 PStaticData.cc:55
 PStaticData.cc:56
 PStaticData.cc:57
 PStaticData.cc:58
 PStaticData.cc:59
 PStaticData.cc:60
 PStaticData.cc:61
 PStaticData.cc:62
 PStaticData.cc:63
 PStaticData.cc:64
 PStaticData.cc:65
 PStaticData.cc:66
 PStaticData.cc:67
 PStaticData.cc:68
 PStaticData.cc:69
 PStaticData.cc:70
 PStaticData.cc:71
 PStaticData.cc:72
 PStaticData.cc:73
 PStaticData.cc:74
 PStaticData.cc:75
 PStaticData.cc:76
 PStaticData.cc:77
 PStaticData.cc:78
 PStaticData.cc:79
 PStaticData.cc:80
 PStaticData.cc:81
 PStaticData.cc:82
 PStaticData.cc:83
 PStaticData.cc:84
 PStaticData.cc:85
 PStaticData.cc:86
 PStaticData.cc:87
 PStaticData.cc:88
 PStaticData.cc:89
 PStaticData.cc:90
 PStaticData.cc:91
 PStaticData.cc:92
 PStaticData.cc:93
 PStaticData.cc:94
 PStaticData.cc:95
 PStaticData.cc:96
 PStaticData.cc:97
 PStaticData.cc:98
 PStaticData.cc:99
 PStaticData.cc:100
 PStaticData.cc:101
 PStaticData.cc:102
 PStaticData.cc:103
 PStaticData.cc:104
 PStaticData.cc:105
 PStaticData.cc:106
 PStaticData.cc:107
 PStaticData.cc:108
 PStaticData.cc:109
 PStaticData.cc:110
 PStaticData.cc:111
 PStaticData.cc:112
 PStaticData.cc:113
 PStaticData.cc:114
 PStaticData.cc:115
 PStaticData.cc:116
 PStaticData.cc:117
 PStaticData.cc:118
 PStaticData.cc:119
 PStaticData.cc:120
 PStaticData.cc:121
 PStaticData.cc:122
 PStaticData.cc:123
 PStaticData.cc:124
 PStaticData.cc:125
 PStaticData.cc:126
 PStaticData.cc:127
 PStaticData.cc:128
 PStaticData.cc:129
 PStaticData.cc:130
 PStaticData.cc:131
 PStaticData.cc:132
 PStaticData.cc:133
 PStaticData.cc:134
 PStaticData.cc:135
 PStaticData.cc:136
 PStaticData.cc:137
 PStaticData.cc:138
 PStaticData.cc:139
 PStaticData.cc:140
 PStaticData.cc:141
 PStaticData.cc:142
 PStaticData.cc:143
 PStaticData.cc:144
 PStaticData.cc:145
 PStaticData.cc:146
 PStaticData.cc:147
 PStaticData.cc:148
 PStaticData.cc:149
 PStaticData.cc:150
 PStaticData.cc:151
 PStaticData.cc:152
 PStaticData.cc:153
 PStaticData.cc:154
 PStaticData.cc:155
 PStaticData.cc:156
 PStaticData.cc:157
 PStaticData.cc:158
 PStaticData.cc:159
 PStaticData.cc:160
 PStaticData.cc:161
 PStaticData.cc:162
 PStaticData.cc:163
 PStaticData.cc:164
 PStaticData.cc:165
 PStaticData.cc:166
 PStaticData.cc:167
 PStaticData.cc:168
 PStaticData.cc:169
 PStaticData.cc:170
 PStaticData.cc:171
 PStaticData.cc:172
 PStaticData.cc:173
 PStaticData.cc:174
 PStaticData.cc:175
 PStaticData.cc:176
 PStaticData.cc:177
 PStaticData.cc:178
 PStaticData.cc:179
 PStaticData.cc:180
 PStaticData.cc:181
 PStaticData.cc:182
 PStaticData.cc:183
 PStaticData.cc:184
 PStaticData.cc:185
 PStaticData.cc:186
 PStaticData.cc:187
 PStaticData.cc:188
 PStaticData.cc:189
 PStaticData.cc:190
 PStaticData.cc:191
 PStaticData.cc:192
 PStaticData.cc:193
 PStaticData.cc:194
 PStaticData.cc:195
 PStaticData.cc:196
 PStaticData.cc:197
 PStaticData.cc:198
 PStaticData.cc:199
 PStaticData.cc:200
 PStaticData.cc:201
 PStaticData.cc:202
 PStaticData.cc:203
 PStaticData.cc:204
 PStaticData.cc:205
 PStaticData.cc:206
 PStaticData.cc:207
 PStaticData.cc:208
 PStaticData.cc:209
 PStaticData.cc:210
 PStaticData.cc:211
 PStaticData.cc:212
 PStaticData.cc:213
 PStaticData.cc:214
 PStaticData.cc:215
 PStaticData.cc:216
 PStaticData.cc:217
 PStaticData.cc:218
 PStaticData.cc:219
 PStaticData.cc:220
 PStaticData.cc:221
 PStaticData.cc:222
 PStaticData.cc:223
 PStaticData.cc:224
 PStaticData.cc:225
 PStaticData.cc:226
 PStaticData.cc:227
 PStaticData.cc:228
 PStaticData.cc:229
 PStaticData.cc:230
 PStaticData.cc:231
 PStaticData.cc:232
 PStaticData.cc:233
 PStaticData.cc:234
 PStaticData.cc:235
 PStaticData.cc:236
 PStaticData.cc:237
 PStaticData.cc:238
 PStaticData.cc:239
 PStaticData.cc:240
 PStaticData.cc:241
 PStaticData.cc:242
 PStaticData.cc:243
 PStaticData.cc:244
 PStaticData.cc:245
 PStaticData.cc:246
 PStaticData.cc:247
 PStaticData.cc:248
 PStaticData.cc:249
 PStaticData.cc:250
 PStaticData.cc:251
 PStaticData.cc:252
 PStaticData.cc:253
 PStaticData.cc:254
 PStaticData.cc:255
 PStaticData.cc:256
 PStaticData.cc:257
 PStaticData.cc:258
 PStaticData.cc:259
 PStaticData.cc:260
 PStaticData.cc:261
 PStaticData.cc:262
 PStaticData.cc:263
 PStaticData.cc:264
 PStaticData.cc:265
 PStaticData.cc:266
 PStaticData.cc:267
 PStaticData.cc:268
 PStaticData.cc:269
 PStaticData.cc:270
 PStaticData.cc:271
 PStaticData.cc:272
 PStaticData.cc:273
 PStaticData.cc:274
 PStaticData.cc:275
 PStaticData.cc:276
 PStaticData.cc:277
 PStaticData.cc:278
 PStaticData.cc:279
 PStaticData.cc:280
 PStaticData.cc:281
 PStaticData.cc:282
 PStaticData.cc:283
 PStaticData.cc:284
 PStaticData.cc:285
 PStaticData.cc:286
 PStaticData.cc:287
 PStaticData.cc:288
 PStaticData.cc:289
 PStaticData.cc:290
 PStaticData.cc:291
 PStaticData.cc:292
 PStaticData.cc:293
 PStaticData.cc:294
 PStaticData.cc:295
 PStaticData.cc:296
 PStaticData.cc:297
 PStaticData.cc:298
 PStaticData.cc:299
 PStaticData.cc:300
 PStaticData.cc:301
 PStaticData.cc:302
 PStaticData.cc:303
 PStaticData.cc:304
 PStaticData.cc:305
 PStaticData.cc:306
 PStaticData.cc:307
 PStaticData.cc:308
 PStaticData.cc:309
 PStaticData.cc:310
 PStaticData.cc:311
 PStaticData.cc:312
 PStaticData.cc:313
 PStaticData.cc:314
 PStaticData.cc:315
 PStaticData.cc:316
 PStaticData.cc:317
 PStaticData.cc:318
 PStaticData.cc:319
 PStaticData.cc:320
 PStaticData.cc:321
 PStaticData.cc:322
 PStaticData.cc:323
 PStaticData.cc:324
 PStaticData.cc:325
 PStaticData.cc:326
 PStaticData.cc:327
 PStaticData.cc:328
 PStaticData.cc:329
 PStaticData.cc:330
 PStaticData.cc:331
 PStaticData.cc:332
 PStaticData.cc:333
 PStaticData.cc:334
 PStaticData.cc:335
 PStaticData.cc:336
 PStaticData.cc:337
 PStaticData.cc:338
 PStaticData.cc:339
 PStaticData.cc:340
 PStaticData.cc:341
 PStaticData.cc:342
 PStaticData.cc:343
 PStaticData.cc:344
 PStaticData.cc:345
 PStaticData.cc:346
 PStaticData.cc:347
 PStaticData.cc:348
 PStaticData.cc:349
 PStaticData.cc:350
 PStaticData.cc:351
 PStaticData.cc:352
 PStaticData.cc:353
 PStaticData.cc:354
 PStaticData.cc:355
 PStaticData.cc:356
 PStaticData.cc:357
 PStaticData.cc:358
 PStaticData.cc:359
 PStaticData.cc:360
 PStaticData.cc:361
 PStaticData.cc:362
 PStaticData.cc:363
 PStaticData.cc:364
 PStaticData.cc:365
 PStaticData.cc:366
 PStaticData.cc:367
 PStaticData.cc:368
 PStaticData.cc:369
 PStaticData.cc:370
 PStaticData.cc:371
 PStaticData.cc:372
 PStaticData.cc:373
 PStaticData.cc:374
 PStaticData.cc:375
 PStaticData.cc:376
 PStaticData.cc:377
 PStaticData.cc:378
 PStaticData.cc:379
 PStaticData.cc:380
 PStaticData.cc:381
 PStaticData.cc:382
 PStaticData.cc:383
 PStaticData.cc:384
 PStaticData.cc:385
 PStaticData.cc:386
 PStaticData.cc:387
 PStaticData.cc:388
 PStaticData.cc:389
 PStaticData.cc:390
 PStaticData.cc:391
 PStaticData.cc:392
 PStaticData.cc:393
 PStaticData.cc:394
 PStaticData.cc:395
 PStaticData.cc:396
 PStaticData.cc:397
 PStaticData.cc:398
 PStaticData.cc:399
 PStaticData.cc:400
 PStaticData.cc:401
 PStaticData.cc:402
 PStaticData.cc:403
 PStaticData.cc:404
 PStaticData.cc:405
 PStaticData.cc:406
 PStaticData.cc:407
 PStaticData.cc:408
 PStaticData.cc:409
 PStaticData.cc:410
 PStaticData.cc:411
 PStaticData.cc:412
 PStaticData.cc:413
 PStaticData.cc:414
 PStaticData.cc:415
 PStaticData.cc:416
 PStaticData.cc:417
 PStaticData.cc:418
 PStaticData.cc:419
 PStaticData.cc:420
 PStaticData.cc:421
 PStaticData.cc:422
 PStaticData.cc:423
 PStaticData.cc:424
 PStaticData.cc:425
 PStaticData.cc:426
 PStaticData.cc:427
 PStaticData.cc:428
 PStaticData.cc:429
 PStaticData.cc:430
 PStaticData.cc:431
 PStaticData.cc:432
 PStaticData.cc:433
 PStaticData.cc:434
 PStaticData.cc:435
 PStaticData.cc:436
 PStaticData.cc:437
 PStaticData.cc:438
 PStaticData.cc:439
 PStaticData.cc:440
 PStaticData.cc:441
 PStaticData.cc:442
 PStaticData.cc:443
 PStaticData.cc:444
 PStaticData.cc:445
 PStaticData.cc:446
 PStaticData.cc:447
 PStaticData.cc:448
 PStaticData.cc:449
 PStaticData.cc:450
 PStaticData.cc:451
 PStaticData.cc:452
 PStaticData.cc:453
 PStaticData.cc:454
 PStaticData.cc:455
 PStaticData.cc:456
 PStaticData.cc:457
 PStaticData.cc:458
 PStaticData.cc:459
 PStaticData.cc:460
 PStaticData.cc:461
 PStaticData.cc:462
 PStaticData.cc:463
 PStaticData.cc:464
 PStaticData.cc:465
 PStaticData.cc:466
 PStaticData.cc:467
 PStaticData.cc:468
 PStaticData.cc:469
 PStaticData.cc:470
 PStaticData.cc:471
 PStaticData.cc:472
 PStaticData.cc:473
 PStaticData.cc:474
 PStaticData.cc:475
 PStaticData.cc:476
 PStaticData.cc:477
 PStaticData.cc:478
 PStaticData.cc:479
 PStaticData.cc:480
 PStaticData.cc:481
 PStaticData.cc:482
 PStaticData.cc:483
 PStaticData.cc:484
 PStaticData.cc:485
 PStaticData.cc:486
 PStaticData.cc:487
 PStaticData.cc:488
 PStaticData.cc:489
 PStaticData.cc:490
 PStaticData.cc:491
 PStaticData.cc:492
 PStaticData.cc:493
 PStaticData.cc:494
 PStaticData.cc:495
 PStaticData.cc:496
 PStaticData.cc:497
 PStaticData.cc:498
 PStaticData.cc:499
 PStaticData.cc:500
 PStaticData.cc:501
 PStaticData.cc:502
 PStaticData.cc:503
 PStaticData.cc:504
 PStaticData.cc:505
 PStaticData.cc:506
 PStaticData.cc:507
 PStaticData.cc:508
 PStaticData.cc:509
 PStaticData.cc:510
 PStaticData.cc:511
 PStaticData.cc:512
 PStaticData.cc:513
 PStaticData.cc:514
 PStaticData.cc:515
 PStaticData.cc:516
 PStaticData.cc:517
 PStaticData.cc:518
 PStaticData.cc:519
 PStaticData.cc:520
 PStaticData.cc:521
 PStaticData.cc:522
 PStaticData.cc:523
 PStaticData.cc:524
 PStaticData.cc:525
 PStaticData.cc:526
 PStaticData.cc:527
 PStaticData.cc:528
 PStaticData.cc:529
 PStaticData.cc:530
 PStaticData.cc:531
 PStaticData.cc:532
 PStaticData.cc:533
 PStaticData.cc:534
 PStaticData.cc:535
 PStaticData.cc:536
 PStaticData.cc:537
 PStaticData.cc:538
 PStaticData.cc:539
 PStaticData.cc:540
 PStaticData.cc:541
 PStaticData.cc:542
 PStaticData.cc:543
 PStaticData.cc:544
 PStaticData.cc:545
 PStaticData.cc:546
 PStaticData.cc:547
 PStaticData.cc:548
 PStaticData.cc:549
 PStaticData.cc:550
 PStaticData.cc:551
 PStaticData.cc:552
 PStaticData.cc:553
 PStaticData.cc:554
 PStaticData.cc:555
 PStaticData.cc:556
 PStaticData.cc:557
 PStaticData.cc:558
 PStaticData.cc:559
 PStaticData.cc:560
 PStaticData.cc:561
 PStaticData.cc:562
 PStaticData.cc:563
 PStaticData.cc:564
 PStaticData.cc:565
 PStaticData.cc:566
 PStaticData.cc:567
 PStaticData.cc:568
 PStaticData.cc:569
 PStaticData.cc:570
 PStaticData.cc:571
 PStaticData.cc:572
 PStaticData.cc:573
 PStaticData.cc:574
 PStaticData.cc:575
 PStaticData.cc:576
 PStaticData.cc:577
 PStaticData.cc:578
 PStaticData.cc:579
 PStaticData.cc:580
 PStaticData.cc:581
 PStaticData.cc:582
 PStaticData.cc:583
 PStaticData.cc:584
 PStaticData.cc:585
 PStaticData.cc:586
 PStaticData.cc:587
 PStaticData.cc:588
 PStaticData.cc:589
 PStaticData.cc:590
 PStaticData.cc:591
 PStaticData.cc:592
 PStaticData.cc:593
 PStaticData.cc:594
 PStaticData.cc:595
 PStaticData.cc:596
 PStaticData.cc:597
 PStaticData.cc:598
 PStaticData.cc:599
 PStaticData.cc:600
 PStaticData.cc:601
 PStaticData.cc:602
 PStaticData.cc:603
 PStaticData.cc:604
 PStaticData.cc:605
 PStaticData.cc:606
 PStaticData.cc:607
 PStaticData.cc:608
 PStaticData.cc:609
 PStaticData.cc:610
 PStaticData.cc:611
 PStaticData.cc:612
 PStaticData.cc:613
 PStaticData.cc:614
 PStaticData.cc:615
 PStaticData.cc:616
 PStaticData.cc:617
 PStaticData.cc:618
 PStaticData.cc:619
 PStaticData.cc:620
 PStaticData.cc:621
 PStaticData.cc:622
 PStaticData.cc:623
 PStaticData.cc:624
 PStaticData.cc:625
 PStaticData.cc:626
 PStaticData.cc:627
 PStaticData.cc:628
 PStaticData.cc:629
 PStaticData.cc:630
 PStaticData.cc:631
 PStaticData.cc:632
 PStaticData.cc:633
 PStaticData.cc:634
 PStaticData.cc:635
 PStaticData.cc:636
 PStaticData.cc:637
 PStaticData.cc:638
 PStaticData.cc:639
 PStaticData.cc:640
 PStaticData.cc:641
 PStaticData.cc:642
 PStaticData.cc:643
 PStaticData.cc:644
 PStaticData.cc:645
 PStaticData.cc:646
 PStaticData.cc:647
 PStaticData.cc:648
 PStaticData.cc:649
 PStaticData.cc:650
 PStaticData.cc:651
 PStaticData.cc:652
 PStaticData.cc:653
 PStaticData.cc:654
 PStaticData.cc:655
 PStaticData.cc:656
 PStaticData.cc:657
 PStaticData.cc:658
 PStaticData.cc:659
 PStaticData.cc:660
 PStaticData.cc:661
 PStaticData.cc:662
 PStaticData.cc:663
 PStaticData.cc:664
 PStaticData.cc:665
 PStaticData.cc:666
 PStaticData.cc:667
 PStaticData.cc:668
 PStaticData.cc:669
 PStaticData.cc:670
 PStaticData.cc:671
 PStaticData.cc:672
 PStaticData.cc:673
 PStaticData.cc:674
 PStaticData.cc:675
 PStaticData.cc:676
 PStaticData.cc:677
 PStaticData.cc:678
 PStaticData.cc:679
 PStaticData.cc:680
 PStaticData.cc:681
 PStaticData.cc:682
 PStaticData.cc:683
 PStaticData.cc:684
 PStaticData.cc:685
 PStaticData.cc:686
 PStaticData.cc:687
 PStaticData.cc:688
 PStaticData.cc:689
 PStaticData.cc:690
 PStaticData.cc:691
 PStaticData.cc:692
 PStaticData.cc:693
 PStaticData.cc:694
 PStaticData.cc:695
 PStaticData.cc:696
 PStaticData.cc:697
 PStaticData.cc:698
 PStaticData.cc:699
 PStaticData.cc:700
 PStaticData.cc:701
 PStaticData.cc:702
 PStaticData.cc:703
 PStaticData.cc:704
 PStaticData.cc:705
 PStaticData.cc:706
 PStaticData.cc:707
 PStaticData.cc:708
 PStaticData.cc:709
 PStaticData.cc:710
 PStaticData.cc:711
 PStaticData.cc:712
 PStaticData.cc:713
 PStaticData.cc:714
 PStaticData.cc:715
 PStaticData.cc:716
 PStaticData.cc:717
 PStaticData.cc:718
 PStaticData.cc:719
 PStaticData.cc:720
 PStaticData.cc:721
 PStaticData.cc:722
 PStaticData.cc:723
 PStaticData.cc:724
 PStaticData.cc:725
 PStaticData.cc:726
 PStaticData.cc:727
 PStaticData.cc:728
 PStaticData.cc:729
 PStaticData.cc:730
 PStaticData.cc:731
 PStaticData.cc:732
 PStaticData.cc:733
 PStaticData.cc:734
 PStaticData.cc:735
 PStaticData.cc:736
 PStaticData.cc:737
 PStaticData.cc:738
 PStaticData.cc:739
 PStaticData.cc:740
 PStaticData.cc:741
 PStaticData.cc:742
 PStaticData.cc:743
 PStaticData.cc:744
 PStaticData.cc:745
 PStaticData.cc:746
 PStaticData.cc:747
 PStaticData.cc:748
 PStaticData.cc:749
 PStaticData.cc:750
 PStaticData.cc:751
 PStaticData.cc:752
 PStaticData.cc:753
 PStaticData.cc:754
 PStaticData.cc:755
 PStaticData.cc:756
 PStaticData.cc:757
 PStaticData.cc:758
 PStaticData.cc:759
 PStaticData.cc:760
 PStaticData.cc:761
 PStaticData.cc:762
 PStaticData.cc:763
 PStaticData.cc:764
 PStaticData.cc:765
 PStaticData.cc:766
 PStaticData.cc:767
 PStaticData.cc:768
 PStaticData.cc:769
 PStaticData.cc:770
 PStaticData.cc:771
 PStaticData.cc:772
 PStaticData.cc:773
 PStaticData.cc:774
 PStaticData.cc:775
 PStaticData.cc:776
 PStaticData.cc:777
 PStaticData.cc:778
 PStaticData.cc:779
 PStaticData.cc:780
 PStaticData.cc:781
 PStaticData.cc:782
 PStaticData.cc:783
 PStaticData.cc:784
 PStaticData.cc:785
 PStaticData.cc:786
 PStaticData.cc:787
 PStaticData.cc:788
 PStaticData.cc:789
 PStaticData.cc:790
 PStaticData.cc:791
 PStaticData.cc:792
 PStaticData.cc:793
 PStaticData.cc:794
 PStaticData.cc:795
 PStaticData.cc:796
 PStaticData.cc:797
 PStaticData.cc:798
 PStaticData.cc:799
 PStaticData.cc:800
 PStaticData.cc:801
 PStaticData.cc:802
 PStaticData.cc:803
 PStaticData.cc:804
 PStaticData.cc:805
 PStaticData.cc:806
 PStaticData.cc:807
 PStaticData.cc:808
 PStaticData.cc:809
 PStaticData.cc:810
 PStaticData.cc:811
 PStaticData.cc:812
 PStaticData.cc:813
 PStaticData.cc:814
 PStaticData.cc:815
 PStaticData.cc:816
 PStaticData.cc:817
 PStaticData.cc:818
 PStaticData.cc:819
 PStaticData.cc:820
 PStaticData.cc:821
 PStaticData.cc:822
 PStaticData.cc:823
 PStaticData.cc:824
 PStaticData.cc:825
 PStaticData.cc:826
 PStaticData.cc:827
 PStaticData.cc:828
 PStaticData.cc:829
 PStaticData.cc:830
 PStaticData.cc:831
 PStaticData.cc:832
 PStaticData.cc:833
 PStaticData.cc:834
 PStaticData.cc:835
 PStaticData.cc:836
 PStaticData.cc:837
 PStaticData.cc:838
 PStaticData.cc:839
 PStaticData.cc:840
 PStaticData.cc:841
 PStaticData.cc:842
 PStaticData.cc:843
 PStaticData.cc:844
 PStaticData.cc:845
 PStaticData.cc:846
 PStaticData.cc:847
 PStaticData.cc:848
 PStaticData.cc:849
 PStaticData.cc:850
 PStaticData.cc:851
 PStaticData.cc:852
 PStaticData.cc:853
 PStaticData.cc:854
 PStaticData.cc:855
 PStaticData.cc:856
 PStaticData.cc:857
 PStaticData.cc:858
 PStaticData.cc:859
 PStaticData.cc:860
 PStaticData.cc:861
 PStaticData.cc:862
 PStaticData.cc:863
 PStaticData.cc:864
 PStaticData.cc:865
 PStaticData.cc:866
 PStaticData.cc:867
 PStaticData.cc:868
 PStaticData.cc:869
 PStaticData.cc:870
 PStaticData.cc:871
 PStaticData.cc:872
 PStaticData.cc:873
 PStaticData.cc:874
 PStaticData.cc:875
 PStaticData.cc:876
 PStaticData.cc:877
 PStaticData.cc:878
 PStaticData.cc:879
 PStaticData.cc:880
 PStaticData.cc:881
 PStaticData.cc:882
 PStaticData.cc:883
 PStaticData.cc:884
 PStaticData.cc:885
 PStaticData.cc:886
 PStaticData.cc:887
 PStaticData.cc:888
 PStaticData.cc:889
 PStaticData.cc:890
 PStaticData.cc:891
 PStaticData.cc:892
 PStaticData.cc:893
 PStaticData.cc:894
 PStaticData.cc:895
 PStaticData.cc:896
 PStaticData.cc:897
 PStaticData.cc:898
 PStaticData.cc:899
 PStaticData.cc:900
 PStaticData.cc:901
 PStaticData.cc:902
 PStaticData.cc:903
 PStaticData.cc:904
 PStaticData.cc:905
 PStaticData.cc:906
 PStaticData.cc:907
 PStaticData.cc:908
 PStaticData.cc:909
 PStaticData.cc:910
 PStaticData.cc:911
 PStaticData.cc:912
 PStaticData.cc:913
 PStaticData.cc:914
 PStaticData.cc:915
 PStaticData.cc:916
 PStaticData.cc:917
 PStaticData.cc:918
 PStaticData.cc:919
 PStaticData.cc:920
 PStaticData.cc:921
 PStaticData.cc:922
 PStaticData.cc:923
 PStaticData.cc:924
 PStaticData.cc:925
 PStaticData.cc:926
 PStaticData.cc:927
 PStaticData.cc:928
 PStaticData.cc:929
 PStaticData.cc:930
 PStaticData.cc:931
 PStaticData.cc:932
 PStaticData.cc:933
 PStaticData.cc:934
 PStaticData.cc:935
 PStaticData.cc:936
 PStaticData.cc:937
 PStaticData.cc:938
 PStaticData.cc:939
 PStaticData.cc:940
 PStaticData.cc:941
 PStaticData.cc:942
 PStaticData.cc:943
 PStaticData.cc:944
 PStaticData.cc:945
 PStaticData.cc:946
 PStaticData.cc:947
 PStaticData.cc:948
 PStaticData.cc:949
 PStaticData.cc:950
 PStaticData.cc:951
 PStaticData.cc:952
 PStaticData.cc:953
 PStaticData.cc:954
 PStaticData.cc:955
 PStaticData.cc:956
 PStaticData.cc:957
 PStaticData.cc:958
 PStaticData.cc:959
 PStaticData.cc:960
 PStaticData.cc:961
 PStaticData.cc:962
 PStaticData.cc:963
 PStaticData.cc:964
 PStaticData.cc:965
 PStaticData.cc:966
 PStaticData.cc:967
 PStaticData.cc:968
 PStaticData.cc:969
 PStaticData.cc:970
 PStaticData.cc:971
 PStaticData.cc:972
 PStaticData.cc:973
 PStaticData.cc:974
 PStaticData.cc:975
 PStaticData.cc:976
 PStaticData.cc:977
 PStaticData.cc:978
 PStaticData.cc:979
 PStaticData.cc:980
 PStaticData.cc:981
 PStaticData.cc:982
 PStaticData.cc:983
 PStaticData.cc:984
 PStaticData.cc:985
 PStaticData.cc:986
 PStaticData.cc:987
 PStaticData.cc:988
 PStaticData.cc:989
 PStaticData.cc:990
 PStaticData.cc:991
 PStaticData.cc:992
 PStaticData.cc:993
 PStaticData.cc:994
 PStaticData.cc:995
 PStaticData.cc:996
 PStaticData.cc:997
 PStaticData.cc:998
 PStaticData.cc:999
 PStaticData.cc:1000
 PStaticData.cc:1001
 PStaticData.cc:1002
 PStaticData.cc:1003
 PStaticData.cc:1004
 PStaticData.cc:1005
 PStaticData.cc:1006
 PStaticData.cc:1007
 PStaticData.cc:1008
 PStaticData.cc:1009
 PStaticData.cc:1010
 PStaticData.cc:1011
 PStaticData.cc:1012
 PStaticData.cc:1013
 PStaticData.cc:1014
 PStaticData.cc:1015
 PStaticData.cc:1016
 PStaticData.cc:1017
 PStaticData.cc:1018
 PStaticData.cc:1019
 PStaticData.cc:1020
 PStaticData.cc:1021
 PStaticData.cc:1022
 PStaticData.cc:1023
 PStaticData.cc:1024
 PStaticData.cc:1025
 PStaticData.cc:1026
 PStaticData.cc:1027
 PStaticData.cc:1028
 PStaticData.cc:1029
 PStaticData.cc:1030
 PStaticData.cc:1031
 PStaticData.cc:1032
 PStaticData.cc:1033
 PStaticData.cc:1034
 PStaticData.cc:1035
 PStaticData.cc:1036
 PStaticData.cc:1037
 PStaticData.cc:1038
 PStaticData.cc:1039
 PStaticData.cc:1040
 PStaticData.cc:1041
 PStaticData.cc:1042
 PStaticData.cc:1043
 PStaticData.cc:1044
 PStaticData.cc:1045
 PStaticData.cc:1046
 PStaticData.cc:1047
 PStaticData.cc:1048
 PStaticData.cc:1049
 PStaticData.cc:1050
 PStaticData.cc:1051
 PStaticData.cc:1052
 PStaticData.cc:1053
 PStaticData.cc:1054
 PStaticData.cc:1055
 PStaticData.cc:1056
 PStaticData.cc:1057
 PStaticData.cc:1058
 PStaticData.cc:1059
 PStaticData.cc:1060
 PStaticData.cc:1061
 PStaticData.cc:1062
 PStaticData.cc:1063
 PStaticData.cc:1064
 PStaticData.cc:1065
 PStaticData.cc:1066
 PStaticData.cc:1067
 PStaticData.cc:1068
 PStaticData.cc:1069
 PStaticData.cc:1070
 PStaticData.cc:1071
 PStaticData.cc:1072
 PStaticData.cc:1073
 PStaticData.cc:1074
 PStaticData.cc:1075
 PStaticData.cc:1076
 PStaticData.cc:1077
 PStaticData.cc:1078
 PStaticData.cc:1079
 PStaticData.cc:1080
 PStaticData.cc:1081
 PStaticData.cc:1082
 PStaticData.cc:1083
 PStaticData.cc:1084
 PStaticData.cc:1085
 PStaticData.cc:1086
 PStaticData.cc:1087
 PStaticData.cc:1088
 PStaticData.cc:1089
 PStaticData.cc:1090
 PStaticData.cc:1091
 PStaticData.cc:1092
 PStaticData.cc:1093
 PStaticData.cc:1094
 PStaticData.cc:1095
 PStaticData.cc:1096
 PStaticData.cc:1097
 PStaticData.cc:1098
 PStaticData.cc:1099
 PStaticData.cc:1100
 PStaticData.cc:1101
 PStaticData.cc:1102
 PStaticData.cc:1103
 PStaticData.cc:1104
 PStaticData.cc:1105
 PStaticData.cc:1106
 PStaticData.cc:1107
 PStaticData.cc:1108
 PStaticData.cc:1109
 PStaticData.cc:1110
 PStaticData.cc:1111
 PStaticData.cc:1112
 PStaticData.cc:1113
 PStaticData.cc:1114
 PStaticData.cc:1115
 PStaticData.cc:1116
 PStaticData.cc:1117
 PStaticData.cc:1118
 PStaticData.cc:1119
 PStaticData.cc:1120
 PStaticData.cc:1121
 PStaticData.cc:1122
 PStaticData.cc:1123
 PStaticData.cc:1124
 PStaticData.cc:1125
 PStaticData.cc:1126
 PStaticData.cc:1127
 PStaticData.cc:1128
 PStaticData.cc:1129
 PStaticData.cc:1130
 PStaticData.cc:1131
 PStaticData.cc:1132
 PStaticData.cc:1133
 PStaticData.cc:1134
 PStaticData.cc:1135
 PStaticData.cc:1136
 PStaticData.cc:1137
 PStaticData.cc:1138
 PStaticData.cc:1139
 PStaticData.cc:1140
 PStaticData.cc:1141
 PStaticData.cc:1142
 PStaticData.cc:1143
 PStaticData.cc:1144
 PStaticData.cc:1145
 PStaticData.cc:1146
 PStaticData.cc:1147
 PStaticData.cc:1148
 PStaticData.cc:1149
 PStaticData.cc:1150
 PStaticData.cc:1151
 PStaticData.cc:1152
 PStaticData.cc:1153
 PStaticData.cc:1154
 PStaticData.cc:1155
 PStaticData.cc:1156
 PStaticData.cc:1157
 PStaticData.cc:1158
 PStaticData.cc:1159
 PStaticData.cc:1160
 PStaticData.cc:1161
 PStaticData.cc:1162
 PStaticData.cc:1163
 PStaticData.cc:1164
 PStaticData.cc:1165
 PStaticData.cc:1166
 PStaticData.cc:1167
 PStaticData.cc:1168
 PStaticData.cc:1169
 PStaticData.cc:1170
 PStaticData.cc:1171
 PStaticData.cc:1172
 PStaticData.cc:1173
 PStaticData.cc:1174
 PStaticData.cc:1175
 PStaticData.cc:1176
 PStaticData.cc:1177
 PStaticData.cc:1178
 PStaticData.cc:1179
 PStaticData.cc:1180
 PStaticData.cc:1181
 PStaticData.cc:1182
 PStaticData.cc:1183
 PStaticData.cc:1184
 PStaticData.cc:1185
 PStaticData.cc:1186
 PStaticData.cc:1187
 PStaticData.cc:1188
 PStaticData.cc:1189
 PStaticData.cc:1190
 PStaticData.cc:1191
 PStaticData.cc:1192
 PStaticData.cc:1193
 PStaticData.cc:1194
 PStaticData.cc:1195
 PStaticData.cc:1196
 PStaticData.cc:1197
 PStaticData.cc:1198
 PStaticData.cc:1199
 PStaticData.cc:1200
 PStaticData.cc:1201
 PStaticData.cc:1202
 PStaticData.cc:1203
 PStaticData.cc:1204
 PStaticData.cc:1205
 PStaticData.cc:1206
 PStaticData.cc:1207
 PStaticData.cc:1208
 PStaticData.cc:1209
 PStaticData.cc:1210
 PStaticData.cc:1211
 PStaticData.cc:1212
 PStaticData.cc:1213
 PStaticData.cc:1214
 PStaticData.cc:1215
 PStaticData.cc:1216
 PStaticData.cc:1217
 PStaticData.cc:1218
 PStaticData.cc:1219
 PStaticData.cc:1220
 PStaticData.cc:1221
 PStaticData.cc:1222
 PStaticData.cc:1223
 PStaticData.cc:1224
 PStaticData.cc:1225
 PStaticData.cc:1226
 PStaticData.cc:1227
 PStaticData.cc:1228
 PStaticData.cc:1229
 PStaticData.cc:1230
 PStaticData.cc:1231
 PStaticData.cc:1232
 PStaticData.cc:1233
 PStaticData.cc:1234
 PStaticData.cc:1235
 PStaticData.cc:1236
 PStaticData.cc:1237
 PStaticData.cc:1238
 PStaticData.cc:1239
 PStaticData.cc:1240
 PStaticData.cc:1241
 PStaticData.cc:1242
 PStaticData.cc:1243
 PStaticData.cc:1244
 PStaticData.cc:1245
 PStaticData.cc:1246
 PStaticData.cc:1247
 PStaticData.cc:1248
 PStaticData.cc:1249
 PStaticData.cc:1250
 PStaticData.cc:1251
 PStaticData.cc:1252
 PStaticData.cc:1253
 PStaticData.cc:1254
 PStaticData.cc:1255
 PStaticData.cc:1256
 PStaticData.cc:1257
 PStaticData.cc:1258
 PStaticData.cc:1259
 PStaticData.cc:1260
 PStaticData.cc:1261
 PStaticData.cc:1262
 PStaticData.cc:1263
 PStaticData.cc:1264
 PStaticData.cc:1265
 PStaticData.cc:1266
 PStaticData.cc:1267
 PStaticData.cc:1268
 PStaticData.cc:1269
 PStaticData.cc:1270
 PStaticData.cc:1271
 PStaticData.cc:1272
 PStaticData.cc:1273
 PStaticData.cc:1274
 PStaticData.cc:1275
 PStaticData.cc:1276
 PStaticData.cc:1277
 PStaticData.cc:1278
 PStaticData.cc:1279
 PStaticData.cc:1280
 PStaticData.cc:1281
 PStaticData.cc:1282
 PStaticData.cc:1283
 PStaticData.cc:1284
 PStaticData.cc:1285
 PStaticData.cc:1286
 PStaticData.cc:1287
 PStaticData.cc:1288
 PStaticData.cc:1289
 PStaticData.cc:1290
 PStaticData.cc:1291
 PStaticData.cc:1292
 PStaticData.cc:1293
 PStaticData.cc:1294
 PStaticData.cc:1295
 PStaticData.cc:1296
 PStaticData.cc:1297
 PStaticData.cc:1298
 PStaticData.cc:1299
 PStaticData.cc:1300
 PStaticData.cc:1301
 PStaticData.cc:1302
 PStaticData.cc:1303
 PStaticData.cc:1304
 PStaticData.cc:1305
 PStaticData.cc:1306
 PStaticData.cc:1307
 PStaticData.cc:1308
 PStaticData.cc:1309
 PStaticData.cc:1310
 PStaticData.cc:1311
 PStaticData.cc:1312
 PStaticData.cc:1313
 PStaticData.cc:1314
 PStaticData.cc:1315
 PStaticData.cc:1316
 PStaticData.cc:1317
 PStaticData.cc:1318
 PStaticData.cc:1319
 PStaticData.cc:1320
 PStaticData.cc:1321
 PStaticData.cc:1322
 PStaticData.cc:1323
 PStaticData.cc:1324
 PStaticData.cc:1325
 PStaticData.cc:1326
 PStaticData.cc:1327
 PStaticData.cc:1328
 PStaticData.cc:1329
 PStaticData.cc:1330
 PStaticData.cc:1331
 PStaticData.cc:1332
 PStaticData.cc:1333
 PStaticData.cc:1334
 PStaticData.cc:1335
 PStaticData.cc:1336
 PStaticData.cc:1337
 PStaticData.cc:1338
 PStaticData.cc:1339
 PStaticData.cc:1340
 PStaticData.cc:1341
 PStaticData.cc:1342
 PStaticData.cc:1343
 PStaticData.cc:1344
 PStaticData.cc:1345
 PStaticData.cc:1346
 PStaticData.cc:1347
 PStaticData.cc:1348
 PStaticData.cc:1349
 PStaticData.cc:1350
 PStaticData.cc:1351
 PStaticData.cc:1352
 PStaticData.cc:1353
 PStaticData.cc:1354
 PStaticData.cc:1355
 PStaticData.cc:1356
 PStaticData.cc:1357
 PStaticData.cc:1358
 PStaticData.cc:1359
 PStaticData.cc:1360
 PStaticData.cc:1361
 PStaticData.cc:1362
 PStaticData.cc:1363
 PStaticData.cc:1364
 PStaticData.cc:1365
 PStaticData.cc:1366
 PStaticData.cc:1367
 PStaticData.cc:1368
 PStaticData.cc:1369
 PStaticData.cc:1370
 PStaticData.cc:1371
 PStaticData.cc:1372
 PStaticData.cc:1373
 PStaticData.cc:1374
 PStaticData.cc:1375
 PStaticData.cc:1376
 PStaticData.cc:1377
 PStaticData.cc:1378
 PStaticData.cc:1379
 PStaticData.cc:1380
 PStaticData.cc:1381
 PStaticData.cc:1382
 PStaticData.cc:1383
 PStaticData.cc:1384
 PStaticData.cc:1385
 PStaticData.cc:1386
 PStaticData.cc:1387
 PStaticData.cc:1388
 PStaticData.cc:1389
 PStaticData.cc:1390
 PStaticData.cc:1391
 PStaticData.cc:1392
 PStaticData.cc:1393
 PStaticData.cc:1394
 PStaticData.cc:1395
 PStaticData.cc:1396
 PStaticData.cc:1397
 PStaticData.cc:1398
 PStaticData.cc:1399
 PStaticData.cc:1400
 PStaticData.cc:1401
 PStaticData.cc:1402
 PStaticData.cc:1403
 PStaticData.cc:1404
 PStaticData.cc:1405
 PStaticData.cc:1406
 PStaticData.cc:1407
 PStaticData.cc:1408
 PStaticData.cc:1409
 PStaticData.cc:1410
 PStaticData.cc:1411
 PStaticData.cc:1412
 PStaticData.cc:1413
 PStaticData.cc:1414
 PStaticData.cc:1415
 PStaticData.cc:1416
 PStaticData.cc:1417
 PStaticData.cc:1418
 PStaticData.cc:1419
 PStaticData.cc:1420
 PStaticData.cc:1421
 PStaticData.cc:1422
 PStaticData.cc:1423
 PStaticData.cc:1424
 PStaticData.cc:1425
 PStaticData.cc:1426
 PStaticData.cc:1427
 PStaticData.cc:1428
 PStaticData.cc:1429
 PStaticData.cc:1430
 PStaticData.cc:1431
 PStaticData.cc:1432
 PStaticData.cc:1433
 PStaticData.cc:1434
 PStaticData.cc:1435
 PStaticData.cc:1436
 PStaticData.cc:1437
 PStaticData.cc:1438
 PStaticData.cc:1439
 PStaticData.cc:1440
 PStaticData.cc:1441
 PStaticData.cc:1442
 PStaticData.cc:1443
 PStaticData.cc:1444
 PStaticData.cc:1445
 PStaticData.cc:1446
 PStaticData.cc:1447
 PStaticData.cc:1448
 PStaticData.cc:1449
 PStaticData.cc:1450
 PStaticData.cc:1451
 PStaticData.cc:1452
 PStaticData.cc:1453
 PStaticData.cc:1454
 PStaticData.cc:1455
 PStaticData.cc:1456
 PStaticData.cc:1457
 PStaticData.cc:1458
 PStaticData.cc:1459
 PStaticData.cc:1460
 PStaticData.cc:1461
 PStaticData.cc:1462
 PStaticData.cc:1463
 PStaticData.cc:1464
 PStaticData.cc:1465
 PStaticData.cc:1466
 PStaticData.cc:1467
 PStaticData.cc:1468
 PStaticData.cc:1469
 PStaticData.cc:1470
 PStaticData.cc:1471
 PStaticData.cc:1472
 PStaticData.cc:1473
 PStaticData.cc:1474
 PStaticData.cc:1475
 PStaticData.cc:1476
 PStaticData.cc:1477
 PStaticData.cc:1478
 PStaticData.cc:1479
 PStaticData.cc:1480
 PStaticData.cc:1481
 PStaticData.cc:1482
 PStaticData.cc:1483
 PStaticData.cc:1484
 PStaticData.cc:1485
 PStaticData.cc:1486
 PStaticData.cc:1487
 PStaticData.cc:1488
 PStaticData.cc:1489
 PStaticData.cc:1490
 PStaticData.cc:1491
 PStaticData.cc:1492
 PStaticData.cc:1493
 PStaticData.cc:1494
 PStaticData.cc:1495
 PStaticData.cc:1496
 PStaticData.cc:1497
 PStaticData.cc:1498
 PStaticData.cc:1499
 PStaticData.cc:1500
 PStaticData.cc:1501
 PStaticData.cc:1502
 PStaticData.cc:1503
 PStaticData.cc:1504
 PStaticData.cc:1505
 PStaticData.cc:1506
 PStaticData.cc:1507
 PStaticData.cc:1508
 PStaticData.cc:1509
 PStaticData.cc:1510
 PStaticData.cc:1511
 PStaticData.cc:1512
 PStaticData.cc:1513
 PStaticData.cc:1514
 PStaticData.cc:1515
 PStaticData.cc:1516
 PStaticData.cc:1517
 PStaticData.cc:1518
 PStaticData.cc:1519
 PStaticData.cc:1520
 PStaticData.cc:1521
 PStaticData.cc:1522
 PStaticData.cc:1523
 PStaticData.cc:1524
 PStaticData.cc:1525
 PStaticData.cc:1526
 PStaticData.cc:1527
 PStaticData.cc:1528
 PStaticData.cc:1529
 PStaticData.cc:1530
 PStaticData.cc:1531
 PStaticData.cc:1532
 PStaticData.cc:1533
 PStaticData.cc:1534
 PStaticData.cc:1535
 PStaticData.cc:1536
 PStaticData.cc:1537
 PStaticData.cc:1538
 PStaticData.cc:1539
 PStaticData.cc:1540
 PStaticData.cc:1541
 PStaticData.cc:1542
 PStaticData.cc:1543
 PStaticData.cc:1544
 PStaticData.cc:1545
 PStaticData.cc:1546
 PStaticData.cc:1547
 PStaticData.cc:1548
 PStaticData.cc:1549
 PStaticData.cc:1550
 PStaticData.cc:1551
 PStaticData.cc:1552
 PStaticData.cc:1553
 PStaticData.cc:1554
 PStaticData.cc:1555
 PStaticData.cc:1556
 PStaticData.cc:1557
 PStaticData.cc:1558
 PStaticData.cc:1559
 PStaticData.cc:1560
 PStaticData.cc:1561
 PStaticData.cc:1562
 PStaticData.cc:1563
 PStaticData.cc:1564
 PStaticData.cc:1565
 PStaticData.cc:1566
 PStaticData.cc:1567
 PStaticData.cc:1568
 PStaticData.cc:1569
 PStaticData.cc:1570
 PStaticData.cc:1571
 PStaticData.cc:1572
 PStaticData.cc:1573
 PStaticData.cc:1574
 PStaticData.cc:1575
 PStaticData.cc:1576
 PStaticData.cc:1577
 PStaticData.cc:1578
 PStaticData.cc:1579
 PStaticData.cc:1580
 PStaticData.cc:1581
 PStaticData.cc:1582
 PStaticData.cc:1583
 PStaticData.cc:1584
 PStaticData.cc:1585
 PStaticData.cc:1586
 PStaticData.cc:1587
 PStaticData.cc:1588
 PStaticData.cc:1589
 PStaticData.cc:1590
 PStaticData.cc:1591
 PStaticData.cc:1592
 PStaticData.cc:1593
 PStaticData.cc:1594
 PStaticData.cc:1595
 PStaticData.cc:1596
 PStaticData.cc:1597
 PStaticData.cc:1598
 PStaticData.cc:1599
 PStaticData.cc:1600
 PStaticData.cc:1601
 PStaticData.cc:1602
 PStaticData.cc:1603
 PStaticData.cc:1604
 PStaticData.cc:1605
 PStaticData.cc:1606
 PStaticData.cc:1607
 PStaticData.cc:1608
 PStaticData.cc:1609
 PStaticData.cc:1610
 PStaticData.cc:1611
 PStaticData.cc:1612
 PStaticData.cc:1613
 PStaticData.cc:1614
 PStaticData.cc:1615
 PStaticData.cc:1616
 PStaticData.cc:1617
 PStaticData.cc:1618
 PStaticData.cc:1619
 PStaticData.cc:1620
 PStaticData.cc:1621
 PStaticData.cc:1622
 PStaticData.cc:1623
 PStaticData.cc:1624
 PStaticData.cc:1625
 PStaticData.cc:1626
 PStaticData.cc:1627
 PStaticData.cc:1628
 PStaticData.cc:1629
 PStaticData.cc:1630
 PStaticData.cc:1631
 PStaticData.cc:1632
 PStaticData.cc:1633
 PStaticData.cc:1634
 PStaticData.cc:1635
 PStaticData.cc:1636
 PStaticData.cc:1637
 PStaticData.cc:1638
 PStaticData.cc:1639
 PStaticData.cc:1640
 PStaticData.cc:1641
 PStaticData.cc:1642
 PStaticData.cc:1643
 PStaticData.cc:1644
 PStaticData.cc:1645
 PStaticData.cc:1646
 PStaticData.cc:1647
 PStaticData.cc:1648
 PStaticData.cc:1649
 PStaticData.cc:1650
 PStaticData.cc:1651
 PStaticData.cc:1652
 PStaticData.cc:1653
 PStaticData.cc:1654
 PStaticData.cc:1655
 PStaticData.cc:1656
 PStaticData.cc:1657
 PStaticData.cc:1658
 PStaticData.cc:1659
 PStaticData.cc:1660
 PStaticData.cc:1661
 PStaticData.cc:1662
 PStaticData.cc:1663
 PStaticData.cc:1664
 PStaticData.cc:1665
 PStaticData.cc:1666
 PStaticData.cc:1667
 PStaticData.cc:1668
 PStaticData.cc:1669
 PStaticData.cc:1670
 PStaticData.cc:1671
 PStaticData.cc:1672
 PStaticData.cc:1673
 PStaticData.cc:1674
 PStaticData.cc:1675
 PStaticData.cc:1676
 PStaticData.cc:1677
 PStaticData.cc:1678
 PStaticData.cc:1679
 PStaticData.cc:1680
 PStaticData.cc:1681
 PStaticData.cc:1682
 PStaticData.cc:1683
 PStaticData.cc:1684
 PStaticData.cc:1685
 PStaticData.cc:1686
 PStaticData.cc:1687
 PStaticData.cc:1688
 PStaticData.cc:1689
 PStaticData.cc:1690
 PStaticData.cc:1691
 PStaticData.cc:1692
 PStaticData.cc:1693
 PStaticData.cc:1694
 PStaticData.cc:1695
 PStaticData.cc:1696
 PStaticData.cc:1697
 PStaticData.cc:1698
 PStaticData.cc:1699
 PStaticData.cc:1700
 PStaticData.cc:1701
 PStaticData.cc:1702
 PStaticData.cc:1703
 PStaticData.cc:1704
 PStaticData.cc:1705
 PStaticData.cc:1706
 PStaticData.cc:1707
 PStaticData.cc:1708
 PStaticData.cc:1709
 PStaticData.cc:1710
 PStaticData.cc:1711
 PStaticData.cc:1712
 PStaticData.cc:1713
 PStaticData.cc:1714
 PStaticData.cc:1715
 PStaticData.cc:1716
 PStaticData.cc:1717
 PStaticData.cc:1718
 PStaticData.cc:1719
 PStaticData.cc:1720
 PStaticData.cc:1721
 PStaticData.cc:1722
 PStaticData.cc:1723
 PStaticData.cc:1724
 PStaticData.cc:1725
 PStaticData.cc:1726
 PStaticData.cc:1727
 PStaticData.cc:1728
 PStaticData.cc:1729
 PStaticData.cc:1730
 PStaticData.cc:1731
 PStaticData.cc:1732
 PStaticData.cc:1733
 PStaticData.cc:1734
 PStaticData.cc:1735
 PStaticData.cc:1736
 PStaticData.cc:1737
 PStaticData.cc:1738
 PStaticData.cc:1739
 PStaticData.cc:1740
 PStaticData.cc:1741
 PStaticData.cc:1742
 PStaticData.cc:1743
 PStaticData.cc:1744
 PStaticData.cc:1745
 PStaticData.cc:1746
 PStaticData.cc:1747
 PStaticData.cc:1748
 PStaticData.cc:1749
 PStaticData.cc:1750
 PStaticData.cc:1751
 PStaticData.cc:1752
 PStaticData.cc:1753
 PStaticData.cc:1754
 PStaticData.cc:1755
 PStaticData.cc:1756
 PStaticData.cc:1757
 PStaticData.cc:1758
 PStaticData.cc:1759
 PStaticData.cc:1760
 PStaticData.cc:1761
 PStaticData.cc:1762
 PStaticData.cc:1763
 PStaticData.cc:1764
 PStaticData.cc:1765
 PStaticData.cc:1766
 PStaticData.cc:1767
 PStaticData.cc:1768
 PStaticData.cc:1769
 PStaticData.cc:1770
 PStaticData.cc:1771
 PStaticData.cc:1772
 PStaticData.cc:1773
 PStaticData.cc:1774
 PStaticData.cc:1775
 PStaticData.cc:1776
 PStaticData.cc:1777
 PStaticData.cc:1778
 PStaticData.cc:1779
 PStaticData.cc:1780
 PStaticData.cc:1781
 PStaticData.cc:1782
 PStaticData.cc:1783
 PStaticData.cc:1784
 PStaticData.cc:1785
 PStaticData.cc:1786
 PStaticData.cc:1787
 PStaticData.cc:1788
 PStaticData.cc:1789
 PStaticData.cc:1790
 PStaticData.cc:1791
 PStaticData.cc:1792
 PStaticData.cc:1793
 PStaticData.cc:1794
 PStaticData.cc:1795
 PStaticData.cc:1796