-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNucDB.C
299 lines (237 loc) · 9.43 KB
/
NucDB.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#include <stdio.h>
#include <getopt.h>
#include "NucDBDataPoint.h"
#include "NucDBManager.h"
#include "TRint.h"
#define PACKAGE "getoptex"
#define VERSION "0.0.1"
/*! \mainpage Nucleon Database NucDB
\subpage install
\subpage intro
\subpage tutorial
(incomplete)
\subpage addingdata
*/
/*! \page install Installation
\section requirements Requirements
- ROOT ( cd $ROOTSYS; ./configure --enable-python --enable-mysql ; make)
- Python (with modules:)
- numpy
- MySQLdb
- MySQL database access
- easy_install (optional) See <a href="http://mg.pov.lt/blog/easy-easy-install.html"> easyinstall setup </a>
\code
# easy_install
# directions from http://mg.pov.lt/blog/easy-easy-install.html
export PYTHONPATH=$HOME/py-lib:$PYTHONPATH
alias easy_install="easy_install -s ~/bin -d ~/py-lib"
\endcode
\section git Download the code
Grab it from the git repository with the following command:
\code
git clone http://quarks.temple.edu/~git/NucDB.git
\endcode
\section envvariables Configure your environment
Add lib directory to $LD_LIBRARY_PATH and python directory to $PYTHON_PATH in your $HOME/.bashrc
\code
# NucDB
export NucDB_DIR=$HOME/work/NucDB
export LD_LIBRARY_PATH=$NucDB_DIR/lib:$ROOTSYS/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$NucDB_DIR/python:$ROOTSYS/lib:$PYTHONPATH
\endcode
\section rootlogon Configure your ROOT logon scripts
Put thins in your $HOME/.rootlogon.C
\code
/// NucDB Libraries
gSystem->AddIncludePath("-I$NucDB_DIR/include");
gSystem->Load("$NucDB_DIR/lib/libNucDB.so");
\endcode
In your $HOME/.rootlogon.py you might want to add something like this
\code
print 'o Found .rootlogon.py !!!'
import os
from ROOT import gROOT,gSystem
gSystem.Load( 'libNucDB' )
\endcode
\section compile Compile and Build Database
Compile and build the database
\code
make
make database
\endcode
*/
/*! \page intro Introduction to NucDB
\image html TBrowser_NucDB.png
Here is the abstracted structure of NucDB :
- Experiment
- Measurement
- Datapoint
- Statistical Error
- Systematic Error
- Binned variable
Each item above can be considered an array
\todo Create a way of defining units!
*/
/*! \page addingdata Adding New Data to NucDB
\section addingfirststep First Step: Gathering data
So you want to add more data to NucDB? First thin you should gather the best most complete
data for each measurment/experiment. A good source of experimental data is <a href="http://durpdg.dur.ac.uk/">
The Durham HepData Project </a>.
You will need the following information:
- experiment name (eg, SLAC_E143,SMC,EMC). Note, try to use underscores instead of "-".
- measurement name (eg, F2p, F1n, g1p/F1p)
- data points and bin sizes
- data point errors (statisitcal and systematic)
- Any extra data on beam energies, spectrometer angles, etc...
\subsection addexample1 Example SLAC E143
Say you want to add data on \f$ R = \frac{\sigma_L}{\sigma_T} \f$ from the SLAC E143 experiment
from <a href="http://durpdg.dur.ac.uk/cgi-hepdata/struct3/E143/PL452B194/R"> this data file </a>
from the <a href="http://durpdg.dur.ac.uk/">Durham HepData Project</a>.
- Create a new experiment directory in $NucDB_DIR/experiments if it does not already exist.
This is where all data files used to fill the database will be stored.
\code cd experiments
mkdir SLAC-E143
cd SLAC-E143
wget http://durpdg.dur.ac.uk/cgi-hepdata/struct3/E143/PL452B194/R # downloads a raw data file
mv R R.dat
\endcode
- Clean up up data file so that the last lines are just the data we are interested in.
(This just makes writing the extractor easier.) So we have text file,
$NucDB_DIR/experiments/SLAC-E143/R.dat, that looks like this:
\code
EXPeriment = SLAC-E-143
REACtion = e- C --> e- X
Collaboration = E143
Author = Abe et al
REFerence = Phys. Lett. B452 (1999) 194
Additional info : Measurement of R (R = sig(L)/sig(T)) in deep inelastic
electron scattering on a Carbon target at incident
electron energy of 29 GeV. The data cover the x range
0.03 to 0.1 and Q**2 range 1.3 to 2.7 GeV**2.
==========================================================================
x Q^2 epsilon R errors
GeV^2 stat. sys.
0.0325 .32 0.474 0.45 0.01 0.07
0.0375 1.47 0.519 0.51 0.02 0.09
0.0450 1.67 0.578 0.40 0.01 0.10
0.0550 1.90 0.641 0.28 0.01 0.09
0.0650 2.11 0.692 0.29 0.02 0.10
0.0750 2.29 0.734 0.18 0.02 0.11
0.0850 2.46 0.767 0.26 0.03 0.10
0.0950 2.60 0.795 0.25 0.03 0.14
0.1050 2.73 0.818 0.17 0.03 0.13
\endcode
- The next step will be creating the extractor using the python class NucDBRawDataExtractor.
- For organization purposes create the extractor in experiments directory with the name exp_NucDB.py
- For this example we would create the extractor as
\code touch experiments/SLAC-E143_NucDB.py \endcode
\section creatingextractor Second step: Create Extractor
Next you will want to create a concrete class inheriting the NucDBRawDataExtractor.
If your data file has multiple measurements per row, it is probably best to inherit your concrete
class for the first measurment and only change the column indicies as need (see \ref RSS_NucDB.py).
\subsection addexample2 Extractor for SLAC E143 "R" Measurement
A good starting point to copy and paste would be the following code
\include exp_NucDB.py
You want to run the extractor from the $NucDB_DIR so that it can then be added to the makefile.
\code python experiments/SLAC-E143_NucDB.py \endcode
At this point you will likely have to debug.
Once this is done send me an email ([email protected]) with your additions.
Or better yet, setup your git repository so I can pull from it and send me a pull request!
(see <a href="http://blog.mhartl.com/2008/10/14/setting-up-your-git-repositories-for-open-source-projects-at-github/">this</a> if you want to understand why or what this means)
\todo Figure out how to deal with evolved data in a nice way
*/
/*! \page tutorial A Brief Tutorial
\section usage Using NucDB
\subsection themanager The Manager
The singleton class for database management.
\include usage.cxx
See \ref NucDBManager for complete doc.
\subsection expandmeas Experiments and Measurements
See \ref NucDBExperiment and \ref NucDBMeasurement for complete doc.
\section usageexamples Examples demonstrating usage
\subsection example1 F2p
Plot the unpolarized structure fucntion \f$ F_2^p(x) \f$.
From examples/F2p.cxx
\include F2p.cxx
\subsection example2 \ref A1p.cxx
Plot the virtual Compton scattering asymmetry \f$ A_1^p(x) \f$..
From examples/A1p.cxx
\include A1p.cxx
*/
/*! \page install Installation
*/
void print_help(int exval);
void list_measurments();
void print_experiments();
int main(int argc, char *argv[]) {
int opt;
// no arguments given
if(argc == 1) {
fprintf(stderr, "This program needs arguments....\n\n");
print_help(1);
}
int fnargs = 2;
char * fargs[2] = {"NucDB","-l"};
TRint * theApp = new TRint("NucDB", &fnargs, &fargs[0], NULL, 2);
while((opt = getopt(argc, argv, "lhVvaf:o:")) != -1) {
switch(opt) {
case 'h':
print_help(0);
break;
case 'V':
printf("%s %s\n\n", PACKAGE, VERSION);
return(0);
break;
case 'v':
printf("%s: Verbose option is set `%c'\n", PACKAGE, optopt);
break;
case 'l':
list_measurments();
break;
case 'a':
printf("List the measurments \n");
/* man = NucDBManager::GetManager();*/
/* theApp->Run(true);*/
break;
case 'f':
printf("%s: Filename %s\n", PACKAGE, optarg);
break;
case 'o':
printf("Output: %s\n", optarg);
break;
case ':':
fprintf(stderr, "%s: Error - Option `%c' needs a value\n\n", PACKAGE, optopt);
print_help(1);
break;
case '?':
fprintf(stderr, "%s: Error - No such option: `%c'\n\n", PACKAGE, optopt);
print_help(1);
}
}
/*
// print all remaining options
*/
for(; optind < argc; optind++)
printf("argument: %s\n", argv[optind]);
return 0;
}
void print_help(int exval) {
printf(" Nuclear Database \n");
printf("=========================================\n");
printf("%s,%s show working getopt example\n", PACKAGE, VERSION);
printf("%s [-h] [-V] [-f FILE] [-o FILE]\n\n", PACKAGE);
printf(" -h print this help and exit\n");
printf(" -V print version and exit\n\n");
printf(" -v set verbose flag\n");
printf(" -l list the measurements\n");
printf(" -f FILE set intput file\n");
printf(" -o FILE set output file\n\n");
printf("=========================================\n");
}
void list_measurments(){
NucDBManager * man = NucDBManager::GetManager();
/*TList * meas = */man->ListExperiments();
// meas->Print();
}
void print_experiments(){
}