ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/CrossSectionReader.C
Revision: 1.1
Committed: Wed Sep 7 13:37:48 2011 UTC (13 years, 8 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Log Message:
First cross section reader module ready for testing

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";
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     cout << "FILE NOT FOUND!" << endl;
28     return xsec;
29     }
30     std::string sLine;
31     while(std::getline(inFile, sLine))
32     {
33     int init_m0 = sLine.find("m0", 0);
34     if(init_m0 == string::npos) continue;
35    
36     //file structure
37     //|(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 |
38     //| Sub-processes | ng | ns | nn | ll | sb | ss | tb | bb | gg | sg |
39    
40     int m0=-1, m12=-1, tanb=-1;
41     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;
42     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 |",
43     &tngb,&a0,&ng,&ns,&nn,&ll,&sb,&ss,&tb,&bb,&gg,&sg);
44     sscanf(sLine.c_str(), " |(scale=1.0) m0=%d, m1/2=%d, %*s |",
45     &m0, &m12);
46    
47     pair< float, float > susyPoint;
48     map< string, float > subXsec;
49     susyPoint.first = m0; susyPoint.second = m12;
50     subXsec["ng"] = ng;
51     subXsec["ns"] = ns;
52     subXsec["nn"] = nn;
53     subXsec["ll"] = ll;
54     subXsec["sb"] = sb;
55     subXsec["ss"] = ss;
56     subXsec["tb"] = tb;
57     subXsec["bb"] = bb;
58     subXsec["gg"] = gg;
59     subXsec["sg"] = sg;
60     xsec[ susyPoint ] = subXsec;
61     }
62     inFile.close();
63     return xsec;
64     }
65    
66     float GetXSecForPointAndChannel(float m0, float m12, map < pair<float, float>, map<string, float> > &xsec, string channel) {
67     pair< float, float > susyPoint; susyPoint.first = m0; susyPoint.second = m12;
68     map< string, float > subXsec = xsec[susyPoint];
69     return subXsec[channel];
70     }
71    
72     float GetXSecForPointAndChannel(float m0, float m12, map < pair<float, float>, map<string, float> > &xsec, int channel) {
73     return GetXSecForPointAndChannel(m0, m12, xsec, inttoprocess(channel));
74     }
75    
76    
77    
78     /*
79     //This is how you use this implementation (a little example) :
80    
81     int main() {
82     cout << "This is an illustration of how this thing works :-)" << endl;
83     map < pair<float, float>, map<string, float> > xsec = getXsec("/scratch/buchmann/C/scale_xsection_nlo1.0_m0_m12_10_0_1v1.txt_INVALID");
84     float tester = GetXSecForPointAndChannel(1920,500,xsec,"sg");
85     cout << tester << endl;
86     return 0;
87     }
88    
89     */