////////////////////////////////////////////////////////////////////////
//
// $Id: Prob.h,v 1.4 2001/11/28 21:25:31 bviren Exp $
//
// Prob
//
// Package: elbo
//
// Interface to oscilation probabilities
//
// Contact: bv@bnl.gov
//
// Created on: Sat Nov 17 13:29:23 2001
//
////////////////////////////////////////////////////////////////////////

#ifndef ELBO_PROB_H
#define ELBO_PROB_H

#include "NuoscParam.h"
#include <vector>

class InterFunc;

class Prob
{

public:

    Prob();
    ~Prob();

    // from text file, format: <energy in ev> <pnue> <pnumu> <pnuatu>
    bool LoadDataFile(int id, NuoscParam& params, const char* filename);

    // from DB, needs ID# 
    bool LoadDataDB(int id, const char* db_host=0, 
                  const char* db_user=0, const char* db_pass=0);

    // get any data stored
    void GetData(int& id, NuoscParam& params,
                 vector<double>& evec, 
                 vector<double>& pnue,
                 vector<double>& pnumu,
                 vector<double>& pnutau);
    // Set cross section data
    void SetData(int id, NuoscParam& params,
                 vector<double>& evec, 
                 vector<double>& pnue,
                 vector<double>& pnumu,
                 vector<double>& pnutau);

    // Store into file
    bool StoreDataFile(const char* filename);
    // Store into DB
    bool StoreDataDB(const char* db_host, const char* db_user, 
                   const char* db_pass);


    InterFunc* CreatePnueFunc();
    InterFunc* CreatePnumuFunc();
    InterFunc* CreatePnutauFunc();

    // Get available ids and descriptions
    static bool GetAvailable(const char* db_host, 
                             const char* db_user, const char* db_pass,
                             vector<int>& id, vector<NuoscParam>& params);

    // return Id of matching entry (doubles are compared to w/in 1%)
    // or 0 if not found
    static int GetId(NuoscParam& params,
                     const char* db_host=0, 
                     const char* db_user=0, const char* db_pass=0);
    
private:

    // copy constructor, assignment:
    Prob(const Prob& rhs); // copy constructor
    Prob& operator=(const Prob& rhs); // assignment

    vector<double> E, Pnue, Pnumu, Pnutau;
    NuoscParam fParams;
    int fId;
    
};                              // end of class Prob

#endif  // ELBO_PROB_H
