ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/CrossSectionReader.C
Revision: 1.3
Committed: Mon Apr 30 08:39:44 2012 UTC (13 years ago) by buchmann
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +2 -1 lines
Log Message:
fixed some uint vs int comparisons; commented out/removed unused variables; made Wall happy

File Contents

# User Rev Content
1 buchmann 1.1 #include <string>
2     #include <map>
3     #include <iostream>
4     #include <fstream>
5    
6 buchmann 1.2 #define CrossSectionReaderLoaded
7    
8 buchmann 1.1 using namespace std;
9    
10     string inttoprocess(int id) {
11     if(id==1) return "ng";
12     if(id==2) return "ns";
13     if(id==3) return "nn";
14     if(id==4) return "ll";
15     if(id==5) return "sb";
16     if(id==6) return "ss";
17     if(id==7) return "tb";
18     if(id==8) return "bb";
19     if(id==9) return "gg";
20     if(id==10) return "sg";
21     return "ERROR_in_inttoprocess";
22     }
23    
24     map < pair<float, float>, map<string, float> > getXsec(string xsecfile) {
25    
26     map < pair<float, float>, map<string, float> > xsec;
27     std::ifstream inFile(xsecfile.c_str());
28     if(!inFile) {
29     write_error(__FUNCTION__,"SPECIFIED CROSS SECTION FILE WAS NOT FOUND!");
30     cout << "Attempted to read from " << xsecfile << endl;
31     return xsec;
32     }
33     std::string sLine;
34     while(std::getline(inFile, sLine))
35     {
36     int init_m0 = sLine.find("m0", 0);
37 buchmann 1.3 if(init_m0 == (int)string::npos) continue;
38 buchmann 1.1
39     //file structure
40     //|(scale=1.0) m0=1000, m1/2=100, tanbeta=3, A0=0, sign(mu)=+ve| 0.224611 | 0.0101205 | 53.1719 | 3.5998e-06 | 0.00592 | 0.0386 | 0.024632 | 0.001203 | 66.1 | 2.3 |
41     //| Sub-processes | ng | ns | nn | ll | sb | ss | tb | bb | gg | sg |
42    
43     int m0=-1, m12=-1, tanb=-1;
44 buchmann 1.3 tanb=-1;
45 buchmann 1.1 float ng=-1,ns=-1,nn=-1,ll=-1,sb=-1,ss=-1,tb=-1,bb=-1,gg=-1,sg=-1,tngb=-1,a0=-1;
46     sscanf(sLine.c_str(), " |(scale=1.0) m0=%*d, m1/2=%*d, tanbeta=%f, A0=%f, sign(mu)=+ve| %f | %e | %e | %e | %e | %e | %e | %e | %e | %e |",
47     &tngb,&a0,&ng,&ns,&nn,&ll,&sb,&ss,&tb,&bb,&gg,&sg);
48     sscanf(sLine.c_str(), " |(scale=1.0) m0=%d, m1/2=%d, %*s |",
49     &m0, &m12);
50    
51     pair< float, float > susyPoint;
52     map< string, float > subXsec;
53     susyPoint.first = m0; susyPoint.second = m12;
54     subXsec["ng"] = ng;
55     subXsec["ns"] = ns;
56     subXsec["nn"] = nn;
57     subXsec["ll"] = ll;
58     subXsec["sb"] = sb;
59     subXsec["ss"] = ss;
60     subXsec["tb"] = tb;
61     subXsec["bb"] = bb;
62     subXsec["gg"] = gg;
63     subXsec["sg"] = sg;
64     xsec[ susyPoint ] = subXsec;
65     }
66     inFile.close();
67     return xsec;
68     }
69    
70     float GetXSecForPointAndChannel(float m0, float m12, map < pair<float, float>, map<string, float> > &xsec, string channel) {
71     pair< float, float > susyPoint; susyPoint.first = m0; susyPoint.second = m12;
72     map< string, float > subXsec = xsec[susyPoint];
73     return subXsec[channel];
74     }
75    
76     float GetXSecForPointAndChannel(float m0, float m12, map < pair<float, float>, map<string, float> > &xsec, int channel) {
77     return GetXSecForPointAndChannel(m0, m12, xsec, inttoprocess(channel));
78     }
79    
80    
81    
82     /*
83     //This is how you use this implementation (a little example) :
84    
85     int main() {
86     cout << "This is an illustration of how this thing works :-)" << endl;
87     map < pair<float, float>, map<string, float> > xsec = getXsec("/scratch/buchmann/C/scale_xsection_nlo1.0_m0_m12_10_0_1v1.txt_INVALID");
88     float tester = GetXSecForPointAndChannel(1920,500,xsec,"sg");
89     cout << tester << endl;
90     return 0;
91     }
92    
93     */