00001 #ifndef __SUSYCROSSSECTION__
00002 #define __SUSYCROSSSECTION__
00003
00004 #include <iostream>
00005 #include <fstream>
00006 #include <sstream>
00007 #include <string>
00008 #include <map>
00009 #include <stdlib.h>
00010
00011
00012
00013
00014 namespace SUSY
00015 {
00016
00017 unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId);
00018
00019 class CrossSectionDB
00020 {
00021 public:
00022 CrossSectionDB(const std::string& txtfilenameOrDir = "SUSYTools/data/mc15_13TeV/", bool usePathResolver = false, bool isExtended = false);
00023
00024
00025 void loadFile(const std::string&);
00026
00027 void extend(const std::string&);
00028
00029
00030 class Process
00031 {
00032 public:
00033 Process() :
00034 m_id(-1), m_name(""), m_cross_section(-1.f), m_kfactor(-1.f), m_efficiency(-1.f), m_relunc(-1.f), m_sumweight(-1.f), m_stat(-1.f) {}
00035
00036 Process(int id, const std::string& name, float cross_section, float kfactor, float efficiency, float relunc, float sumweight, float stat):
00037 m_id(id), m_name(name), m_cross_section(cross_section), m_kfactor(kfactor), m_efficiency(efficiency), m_relunc(relunc), m_sumweight(sumweight), m_stat(stat) {}
00038
00039 int ID() const { return m_id;}
00040 const std::string& name() const { return m_name;}
00041 float xsect() const { return m_cross_section;}
00042 float kfactor() const { return m_kfactor;}
00043 float efficiency() const { return m_efficiency;}
00044 float relunc() const { return m_relunc;}
00045 float sumweight() const { return m_sumweight;}
00046 float stat() const { return m_stat;}
00047 void sumweight(float s) { m_sumweight=s; }
00048 void stat(float s) { m_stat=s; }
00049 private:
00050 int m_id;
00051 std::string m_name;
00052 float m_cross_section;
00053 float m_kfactor;
00054 float m_efficiency;
00055 float m_relunc;
00056 float m_sumweight;
00057 float m_stat;
00058 };
00059
00060 class Key {
00061 int sample_id;
00062 int proc_id;
00063 public:
00064 Key(): sample_id(0), proc_id(0) {}
00065 Key(int _sample_id, int _proc_id): sample_id(_sample_id), proc_id(_proc_id) {}
00066 Key(int _sample_id, std::string name): sample_id(_sample_id) {
00067 proc_id = atoi(name.c_str());
00068 }
00069 bool operator<(const Key & k) const {
00070 return this->sample_id < k.sample_id || (this->sample_id == k.sample_id && this->proc_id < k.proc_id);
00071 }
00072 };
00073
00074
00075
00076 void setExtended(bool isExtended=true){ m_extended = isExtended; };
00077
00078
00079
00080 Process process(int id, int proc = 0) const;
00081 Process process(int id, int pdgId1, int pdgId2) const { return process(id, finalState(pdgId1, pdgId2)); }
00082
00083
00084 float xsectTimesEff(int id, int proc = 0) const {
00085 Process p = process(id, proc);
00086 return p.xsect() * p.kfactor() * p.efficiency();
00087 }
00088 float xsectTimesEff(int id, int pdgId1, int pdgId2) const { return xsectTimesEff(id, finalState(pdgId1, pdgId2)); }
00089 float rawxsect(int id, int proc = 0) const { return process(id, proc).xsect(); }
00090 float rawxsect(int id, int pdgId1, int pdgId2) const { return rawxsect(id, finalState(pdgId1, pdgId2)); }
00091 float kfactor(int id, int proc = 0) const { return process(id, proc).kfactor(); }
00092 float kfactor(int id, int pdgId1, int pdgId2) const { return kfactor(id, finalState(pdgId1, pdgId2)); }
00093 float efficiency(int id, int proc = 0) const { return process(id, proc).efficiency(); }
00094 float efficiency(int id, int pdgId1, int pdgId2) const { return efficiency(id, finalState(pdgId1, pdgId2)); }
00095 float rel_uncertainty(int id, int proc = 0) const { return process(id, proc).relunc(); }
00096 float rel_uncertainty(int id, int pdgId1, int pdgId2) const { return rel_uncertainty(id, finalState(pdgId1, pdgId2)); }
00097 float sumweight(int id, int proc = 0) const { return process(id, proc).sumweight(); }
00098 float sumweight(int id, int pdgId1, int pdgId2) const { return sumweight(id, finalState(pdgId1, pdgId2)); }
00099
00100
00101 std::string name(int id) const { return process(id, 0).name(); }
00102
00103
00104 private:
00105 typedef std::map<Key, Process> xsDB_t;
00106 bool m_extended;
00107 public:
00108 typedef xsDB_t::const_iterator iterator;
00109 iterator begin() const { return m_xsectDB.begin(); }
00110 iterator end() const {return m_xsectDB.end(); }
00111
00112 private:
00113
00114 xsDB_t::iterator my_find( const int proc );
00115 xsDB_t m_xsectDB;
00116 xsDB_t m_cache;
00117 };
00118
00119 }
00120
00121 #endif