ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/CrossSectionReader.C
Revision: 1.1
Committed: Mon Jan 30 14:45:54 2012 UTC (13 years, 3 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Log Message:
Initial commit of Ice Cream versions

File Contents

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