/[PAMELA software]/PamVMC_update/src/PamVMCOptMgr.cxx
ViewVC logotype

Annotation of /PamVMC_update/src/PamVMCOptMgr.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Oct 15 15:51:43 2013 UTC (11 years, 1 month ago) by formato
Branch: MAIN, rel
CVS Tags: reltag, HEAD
Changes since 1.1: +0 -0 lines
PamVMC update

1 formato 1.1 #include <iostream>
2     #include <TString.h>
3     #include <TPDGCode.h>
4     #include <TMath.h>
5     #include "PamVMCOptMgr.h"
6    
7     ClassImp(PamVMCOptMgr)
8    
9     using std::cout;
10     using std::endl;
11     using TMath::Pi;
12     using TMath::TwoPi;
13    
14     PamVMCOptMgr * PamVMCOptMgr::fopt = 0;
15    
16     PamVMCOptMgr * PamVMCOptMgr::Instance(){
17    
18     if(fopt == 0) {
19     fopt = new PamVMCOptMgr();
20     }
21     return fopt;
22     }
23    
24     void PamVMCOptMgr::ParseOptions(TXMLNode *node){
25    
26     foptmap.DeleteAll();
27    
28    
29     if( node ){
30     if (strcmp(node->GetNodeName(), "Main_settings") == 0) {
31    
32     TXMLNode* ch_node=node->GetChildren();
33     for (; ch_node; ch_node = ch_node->GetNextNode()) {
34     if (ch_node->GetNodeType() == TXMLNode::kXMLElementNode) { // Element Node
35     if (strcmp(ch_node->GetNodeName(), "Init_mode_set") == 0) {
36     SetOpt("Init_mode_set",ParseInitOpt(ch_node->GetChildren()));
37     }
38     if (strcmp(ch_node->GetNodeName(), "Random_mode_set") == 0) {
39     SetOpt("Random_mode_set",ParseRandomOpt(ch_node->GetChildren()));
40     }
41     if (strcmp(ch_node->GetNodeName(), "Runtime_mode_set") == 0) {
42     SetOpt("Runtime_mode_set",ParseRuntimeOpt(ch_node->GetChildren()));
43     }
44     if (strcmp(ch_node->GetNodeName(), "Primary_mode_set") == 0) {
45     SetOpt("Primary_mode_set",ParsePrimaryOpt(ch_node->GetChildren()));
46     }
47     }
48     }
49     }
50     } else {
51     SetOpt("Init_mode_set",ParseInitOpt(0));
52     SetOpt("Random_mode_set",ParseRandomOpt(0));
53     SetOpt("Runtime_mode_set",ParseRuntimeOpt(0));
54     SetOpt("Primary_mode_set",ParsePrimaryOpt(0));
55     }
56     }
57    
58    
59     pInitModeOpt * PamVMCOptMgr::ParseInitOpt(TXMLNode *node){
60     //defaults
61     TString PAM_VMC = gSystem->Getenv("PAM_VMC");
62     TString path = PAM_VMC+"/config";
63     TString path_tmp = PAM_VMC+"/examples";
64     TString path_out = PAM_VMC+"/examples";
65     TString filepattern = "out";
66     TString C_name = "g4Config.C";
67     TString in_name = "g4config2.in";
68     Bool_t use_cookies = 0;
69     Bool_t use_nocalo = kFALSE;
70    
71    
72     if( node ){
73     for ( ; node; node = node->GetNextNode()) {
74     if ( (node->GetNodeType() == TXMLNode::kXMLElementNode) ) { // Element Node
75     TString val = node->GetText();
76     if( val.Length()){
77     if (strcmp(node->GetNodeName(), "g4Config_path") == 0){
78     path = val;
79     }
80     if (strcmp(node->GetNodeName(), "g4Config_C_name") == 0){
81     C_name = val;
82     }
83     if (strcmp(node->GetNodeName(), "g4Config_in_name") == 0){
84     in_name = val;
85     }
86     if (strcmp(node->GetNodeName(), "use_pbs_jobcookie") == 0){
87     use_cookies = kTRUE;
88     TXMLNode *node_ch = node->GetChildren();
89     for ( ; node_ch; node_ch = node_ch->GetNextNode()) {
90     if (strcmp(node_ch->GetNodeName(), "out_tmp_dir") == 0){
91     path_tmp = node_ch->GetText();
92     }
93     }
94     }
95     if (strcmp(node->GetNodeName(), "out_path") == 0){
96     path_out = val;
97     }
98     if (strcmp(node->GetNodeName(), "out_file_pattern") == 0){
99     filepattern = val;
100     }
101     }
102     if (strcmp(node->GetNodeName(), "dont_use_pbs_jobcookie") == 0){
103     use_cookies = kFALSE;
104     }
105     if (strcmp(node->GetNodeName(), "use_nocalo") == 0){
106     cout << "Found nocalo flag" << endl;
107     use_nocalo = kTRUE;
108     }
109     }
110     }
111     }
112     return new pInitModeOpt( path, C_name, in_name, use_cookies, use_nocalo, path_tmp, path_out, filepattern );
113     }
114    
115    
116     pRandomModeOpt * PamVMCOptMgr::ParseRandomOpt(TXMLNode *node){
117     //defaults
118     Bool_t read_f_mode = kFALSE;
119     TString PAM_VMC = gSystem->Getenv("PAM_VMC");
120     TString read_g4_seed_path=PAM_VMC+"/examples/radom_dump.root";
121     Bool_t custom_gen = kFALSE;
122     Int_t seed1 = 1000;
123     Int_t seed2 = 1001;
124     Bool_t write_mode = kFALSE;
125     TString write_path = PAM_VMC+"/examples";
126     TString writename = "random_dump.root";
127    
128     if( node ){
129     for ( ; node; node = node->GetNextNode()) {
130     if ( (node->GetNodeType() == TXMLNode::kXMLElementNode) ) { // Element Node
131     TString val = node->GetText();
132     if( val.Length()){
133     if (strcmp(node->GetNodeName(), "generate_g4_seed") == 0){
134     read_f_mode = kFALSE;
135     TXMLNode *node_ch = node->GetChildren();
136     for ( ; node_ch; node_ch = node_ch->GetNextNode()) {
137     if (strcmp(node_ch->GetNodeName(), "auto_g4_seed") == 0){
138     custom_gen = kFALSE;
139     }
140     if (strcmp(node_ch->GetNodeName(), "dont_save_g4rnd_in_file") == 0){
141     write_mode = kFALSE;
142     }
143     if (strcmp(node_ch->GetNodeName(), "save_g4rnd_in_file") == 0){
144     write_mode = kTRUE;
145     TXMLNode *node_ch2 = node_ch->GetChildren();
146     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
147     TString val_ch2 = node_ch2->GetText();
148     if (val_ch2.Length()){
149     if (strcmp(node_ch2->GetNodeName(), "g4_rnd_path") == 0){
150     write_path = node_ch2->GetText();
151     }
152     if (strcmp(node_ch2->GetNodeName(), "g4_rnd_filename") == 0){
153     writename = node_ch2->GetText();
154     }
155     }
156     }
157     }
158    
159     TString val_ch = node_ch->GetText();
160     if (val_ch.Length()){
161     if (strcmp(node_ch->GetNodeName(), "init_g4_seed1") == 0){
162     custom_gen = kTRUE;
163     seed1 = atoi(val_ch);
164     }
165     if (strcmp(node_ch->GetNodeName(), "init_g4_seed2") == 0){
166     custom_gen = kTRUE;
167     seed2 = atoi(val_ch);
168     }
169     }
170     }
171     }
172     if (strcmp(node->GetNodeName(), "read_g4_seed_filepath") == 0){
173     read_f_mode = kTRUE;
174     read_g4_seed_path = val;
175     }
176    
177    
178     }
179     }
180     }
181     }
182    
183     return new pRandomModeOpt( read_f_mode, read_g4_seed_path, custom_gen, seed1, seed2, write_mode, write_path, writename );
184     }
185    
186     pRuntimeModeOpt * PamVMCOptMgr::ParseRuntimeOpt(TXMLNode *node){
187     //defaults
188     Int_t verbose_lev = 0;
189     Int_t maxstep = 50000;
190     Save_cond sv_c = EVERYTHING;
191     Save_mode sv_m = ALL_DETECTORS;
192    
193    
194     if( node ){
195     for ( ; node; node = node->GetNextNode()) {
196     if ( (node->GetNodeType() == TXMLNode::kXMLElementNode) ) { // Element Node
197     TString val = node->GetText();
198     if( val.Length()){
199     if (strcmp(node->GetNodeName(), "verbose_level") == 0){
200     verbose_lev = atoi(val);
201     }
202     if (strcmp(node->GetNodeName(), "maxstep") == 0){
203     maxstep = atoi(val);
204     }
205     if (strcmp(node->GetNodeName(), "save_condition") == 0){
206     TXMLNode *node_ch = node->GetChildren();
207     for ( ; node_ch; node_ch = node_ch->GetNextNode()) {
208     if (strcmp(node_ch->GetNodeName(), "accept_only") == 0) sv_c = ACCEPT_ONLY;
209     if (strcmp(node_ch->GetNodeName(), "trig_only") == 0) sv_c = TRIG_ONLY;
210     if (strcmp(node_ch->GetNodeName(), "everything") == 0) sv_c = EVERYTHING;
211     }
212     }
213     if (strcmp(node->GetNodeName(), "save_mode") == 0){
214     TXMLNode *node_ch = node->GetChildren();
215     for ( ; node_ch; node_ch = node_ch->GetNextNode()) {
216     if (strcmp(node_ch->GetNodeName(), "all_detectors") == 0) sv_m = ALL_DETECTORS;
217     if (strcmp(node_ch->GetNodeName(), "only_primaries") == 0) sv_m = ONLY_PRIMARIES;
218     }
219     }
220    
221     }
222    
223     }
224     }
225     }
226     return new pRuntimeModeOpt(verbose_lev, maxstep, sv_c, sv_m );
227     }
228    
229    
230     pPrimaryModeOpt * PamVMCOptMgr::ParsePrimaryOpt(TXMLNode *node){
231     //defaults
232     Bool_t read_mode = kFALSE; //0 - generate primary kinematics, 1 -read from file;
233     TString read_path = "/set/path/to/kine.root"; // path to file with primary kinematics
234     Int_t pdg = kProton; //PDG code of primary
235     Bool_t spt_mode = kTRUE; // 0 - dome; 1 - user defined angles and vertex point
236     Bool_t vert_mode = kFALSE; //0 - fixed point, 1 - vertex box
237     Bool_t ang_mode = kFALSE; // 0 - fixed angle, 1 - isotropic
238     Momentum_mode mom_mode = FIXED; // fixed, flat, powerlaw
239    
240     Momentum_units units = GV_R; // GV_p, GV_R, GeV_T
241     Double_t mom_fix = 1.; //Momentum, Rig, Kine
242     Double_t mom_min = 1.;
243     Double_t mom_max = 2.;
244     Double_t gamma = 2.75;
245    
246     Nevents_mode nv_m = NEV_TOT; //Total, accept, trigg
247     Int_t nevents = 100; //number of events
248    
249     //Spatial and angular coordinates for fixed-isotropic case
250     Double_t x0 = 0.;
251     Double_t y0 = 0.;
252     Double_t z0 = 130.;
253     Double_t x0_min = -40.;
254     Double_t x0_max = 40.;
255     Double_t y0_min = -40.;
256     Double_t y0_max = 40.;
257     Double_t z0_min = 130.;
258     Double_t z0_max = 130.;
259     Double_t theta = 0.;
260     Double_t phi = 0.;
261     Double_t theta_min = 0.;
262     Double_t theta_max = Pi()/2.;
263     Double_t phi_min = 0.;
264     Double_t phi_max = TwoPi();
265    
266     if( node ){
267     for ( ; node; node = node->GetNextNode()) {
268     if ( (node->GetNodeType() == TXMLNode::kXMLElementNode) ) { // Element Node
269     if (strcmp(node->GetNodeName(), "read_from_file") == 0){
270     read_mode = kTRUE;
271     TString val = node->GetText();
272     if (val.Length() ) read_path = val;
273     }
274     if (strcmp(node->GetNodeName(), "define_primaries") == 0){
275     read_mode = kFALSE;
276     TXMLNode *node_ch = node->GetChildren();
277     for ( ; node_ch; node_ch = node_ch->GetNextNode()) {
278     if (strcmp(node_ch->GetNodeName(), "particle_type") == 0){
279     TXMLNode *node_ch2 = node_ch->GetChildren();
280     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
281     if (strcmp(node_ch2->GetNodeName(), "kProton") == 0){
282     pdg = kProton;
283     }
284     if (strcmp(node_ch2->GetNodeName(), "H-2") == 0){
285     pdg = 1000010020;
286     }
287     if (strcmp(node_ch2->GetNodeName(), "H-3") == 0){
288     pdg = 1000010030;
289     }
290     if (strcmp(node_ch2->GetNodeName(), "He-3") == 0){
291     pdg = 1000020030;
292     }
293     if (strcmp(node_ch2->GetNodeName(), "He-4") == 0){
294     pdg = 1000020040;
295     }
296     if (strcmp(node_ch2->GetNodeName(), "user_pdg") == 0){
297     TString val2 = node_ch2->GetText();
298     if( val2.Length() ) pdg = atoi(val2);
299     }
300     }
301     }
302     if (strcmp(node_ch->GetNodeName(), "gen_mode") == 0){
303     TXMLNode *node_ch2 = node_ch->GetChildren();
304     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
305     if (strcmp(node_ch2->GetNodeName(), "user_defined") == 0){
306     spt_mode = kTRUE;
307     TXMLNode *node_ch3 = node_ch2->GetChildren();
308     for ( ; node_ch3; node_ch3 = node_ch3->GetNextNode()) {
309    
310     //spatial
311     if (strcmp(node_ch3->GetNodeName(), "vertex_mode") == 0){
312     TXMLNode *node_ch4 = node_ch3->GetChildren();
313     for ( ; node_ch4; node_ch4 = node_ch4->GetNextNode()) {
314     if (strcmp(node_ch4->GetNodeName(), "vertex_box") == 0){
315     vert_mode = kTRUE;
316     TXMLNode *node_ch5 = node_ch4->GetChildren();
317     for ( ; node_ch5; node_ch5 = node_ch5->GetNextNode()) {
318     TString val5 = node_ch5->GetText();
319     if( val5.Length()){
320     if (strcmp(node_ch5->GetNodeName(), "x0_min") == 0) x0_min = atof(val5);
321     if (strcmp(node_ch5->GetNodeName(), "x0_max") == 0) x0_max = atof(val5);
322     if (strcmp(node_ch5->GetNodeName(), "y0_min") == 0) y0_min = atof(val5);
323     if (strcmp(node_ch5->GetNodeName(), "y0_max") == 0) y0_max = atof(val5);
324     if (strcmp(node_ch5->GetNodeName(), "z0_min") == 0) z0_min = atof(val5);
325     if (strcmp(node_ch5->GetNodeName(), "z0_max") == 0) z0_max = atof(val5);
326     }
327     }
328     }
329     if (strcmp(node_ch4->GetNodeName(), "vertex_fix_point") == 0){
330     vert_mode = kFALSE;
331     TXMLNode *node_ch5 = node_ch4->GetChildren();
332     for ( ; node_ch5; node_ch5 = node_ch5->GetNextNode()) {
333     TString val5 = node_ch5->GetText();
334     if( val5.Length()){
335     if (strcmp(node_ch5->GetNodeName(), "x0") == 0) x0 = atof(val5);
336     if (strcmp(node_ch5->GetNodeName(), "y0") == 0) y0 = atof(val5);
337     if (strcmp(node_ch5->GetNodeName(), "z0") == 0) z0 = atof(val5);
338     }
339     }
340     }
341     }
342    
343     }
344    
345     //angular
346     if (strcmp(node_ch3->GetNodeName(), "ang_mode") == 0){
347     TXMLNode *node_ch4 = node_ch3->GetChildren();
348     for ( ; node_ch4; node_ch4 = node_ch4->GetNextNode()) {
349     if (strcmp(node_ch4->GetNodeName(), "ang_fixed") == 0){
350     ang_mode = kFALSE;
351     TXMLNode *node_ch5 = node_ch4->GetChildren();
352     for ( ; node_ch5; node_ch5 = node_ch5->GetNextNode()) {
353     TString val5 = node_ch5->GetText();
354     if( val5.Length()){
355     if (strcmp(node_ch5->GetNodeName(), "theta") == 0) theta = atof(val5);
356     if (strcmp(node_ch5->GetNodeName(), "phi") == 0) phi = atof(val5);
357     }
358     }
359     }
360     if (strcmp(node_ch4->GetNodeName(), "ang_iso") == 0){
361     ang_mode = kTRUE;
362     TXMLNode *node_ch5 = node_ch4->GetChildren();
363     for ( ; node_ch5; node_ch5 = node_ch5->GetNextNode()) {
364     TString val5 = node_ch5->GetText();
365     if( val5.Length()){
366     if (strcmp(node_ch5->GetNodeName(), "theta_min") == 0) theta_min = atof(val5);
367     if (strcmp(node_ch5->GetNodeName(), "phi_min") == 0) phi_min = atof(val5);
368     if (strcmp(node_ch5->GetNodeName(), "theta_max") == 0) theta_min = atof(val5);
369     if (strcmp(node_ch5->GetNodeName(), "phi_max") == 0) phi_min = atof(val5);
370     }
371     }
372     }
373     }
374    
375     }
376    
377    
378     }
379     }
380    
381    
382     if (strcmp(node_ch2->GetNodeName(), "dome") == 0){
383     spt_mode = kFALSE;
384     }
385    
386     }
387     }
388    
389     //momentum mode
390     if (strcmp(node_ch->GetNodeName(), "momentum_mode") == 0){
391     TXMLNode *node_ch2 = node_ch->GetChildren();
392     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
393     if (strcmp(node_ch2->GetNodeName(), "momentum_mode_fixed") == 0){
394     mom_mode = FIXED;
395     TXMLNode *node_ch3 = node_ch2->GetChildren();
396     for ( ; node_ch3; node_ch3 = node_ch3->GetNextNode()) {
397     TString val3 = node_ch3->GetText();
398     if( val3.Length()){
399     if (strcmp(node_ch3->GetNodeName(), "P0") == 0) mom_fix = atof(val3);
400     }
401     }
402     }
403    
404     if (strcmp(node_ch2->GetNodeName(), "momentum_mode_flat") == 0){
405     mom_mode = FLAT;
406     TXMLNode *node_ch3 = node_ch2->GetChildren();
407     for ( ; node_ch3; node_ch3 = node_ch3->GetNextNode()) {
408     TString val3 = node_ch3->GetText();
409     if( val3.Length()){
410     if (strcmp(node_ch3->GetNodeName(), "P0_min") == 0) mom_min = atof(val3);
411     if (strcmp(node_ch3->GetNodeName(), "P0_max") == 0) mom_max = atof(val3);
412     }
413     }
414     }
415    
416     if (strcmp(node_ch2->GetNodeName(), "momentum_mode_powerlaw") == 0){
417     mom_mode = POWERLAW;
418     TXMLNode *node_ch3 = node_ch2->GetChildren();
419     for ( ; node_ch3; node_ch3 = node_ch3->GetNextNode()) {
420     TString val3 = node_ch3->GetText();
421     if( val3.Length()){
422     if (strcmp(node_ch3->GetNodeName(), "P0_min") == 0) mom_min = atof(val3);
423     if (strcmp(node_ch3->GetNodeName(), "P0_max") == 0) mom_max = atof(val3);
424     if (strcmp(node_ch3->GetNodeName(), "gamma") == 0) gamma = atof(val3);
425     }
426     }
427     }
428    
429     }
430     }
431     //momentum units
432     if (strcmp(node_ch->GetNodeName(), "momentum_units") == 0){
433     TXMLNode *node_ch2 = node_ch->GetChildren();
434     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
435     if (strcmp(node_ch2->GetNodeName(), "GV_p") == 0) units = GV_p;
436     if (strcmp(node_ch2->GetNodeName(), "GV_R") == 0) units = GV_R;
437     if (strcmp(node_ch2->GetNodeName(), "GeV_T") == 0) units = GeV_T;
438     }
439     }
440     //nevents
441     if (strcmp(node_ch->GetNodeName(), "nevents") == 0){
442     TXMLNode *node_ch2 = node_ch->GetChildren();
443     for ( ; node_ch2; node_ch2 = node_ch2->GetNextNode()) {
444     TString val2 = node_ch2->GetText();
445     if (strcmp(node_ch2->GetNodeName(), "nev_tot") == 0) nv_m = NEV_TOT;
446     if (strcmp(node_ch2->GetNodeName(), "nev_accept") == 0) nv_m = NEV_ACCEPT;
447     if (strcmp(node_ch2->GetNodeName(), "nev_trigg") == 0) nv_m = NEV_TRIGG;
448     if(val2.Length()) nevents = atoi(val2);
449     }
450     }
451    
452    
453     }
454     }
455     }
456     }
457     }
458     return new pPrimaryModeOpt(read_mode, read_path, pdg, spt_mode, vert_mode, ang_mode,
459     mom_mode, units, mom_fix, mom_min, mom_max, gamma, nv_m, nevents, x0, y0, z0,
460     x0_min, x0_max, y0_min, y0_max, z0_min, z0_max,
461     theta, phi, theta_min, theta_max, phi_min, phi_max);
462     }

  ViewVC Help
Powered by ViewVC 1.1.23