////////////////////////////////////////////////////////////////////////
//
// $Id: Xsec.h,v 1.5 2001/11/28 21:25:31 bviren Exp $
//
// Xsec
//
// Package: elbo
//
// Handle neutrino cross sections.
//
// Contact: bv@bnl.gov
//
// Created on: Fri Nov 16 16:35:32 2001
//
////////////////////////////////////////////////////////////////////////

#ifndef XSEC_H
#define XSEC_H

#include <vector>
#include <string>

class InterFunc;

class Xsec
{

public:

    Xsec();
    ~Xsec();

    // from text file, format: <energy in ev> <xsec in 10^-38 cm^2>
    bool LoadDataFile(int id, const char* desc, const char* filename);

    // from DB, needs ID# of xsec
    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, string description,
                 vector<double>& evec, vector<double>& xvec);
    // Set cross section data
    void SetData(int id, const char* description,
                 vector<double>& evec, vector<double>& xvec);

    // 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);


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

    const char* GetDescription () { return fDescription.c_str(); }

private:

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


    void Clear();

    // data if we have been Load()ed
    int fId;
    string fDescription;
    vector<double> fEnergy, fXsec;    
    
    const char* desc_table;
    const char* data_table;
};                              // end of class Xsec

InterFunc* xsec_creator(int channels[], double weights[]);
InterFunc* xsec_create_nue_cc();
InterFunc* xsec_create_nue_nc();
InterFunc* xsec_create_numu_cc();
InterFunc* xsec_create_numu_nc();

#endif  // XSEC_H
