Ticket #204: MyInterface.texi
File MyInterface.texi, 2.7 KB (added by , 13 years ago) |
---|
Line | |
---|---|
1 | @node My own interface |
2 | @section My own interface |
3 | |
4 | It is possible to pass Sherpa output to an external Fortran or C++ framework on-the-flight. |
5 | To illustrate this option, a simple, yet functional example is included in the directory |
6 | @code{./AddOns/HEPEVTInterface}, showing how to fill the HEPEVT common from Sherpa output. |
7 | It also exemplifies how to retrieve the weight of weighted events and how to access information |
8 | about the total cross section of the event sample at the end of the run. |
9 | |
10 | Note that only the event converter is included in the sources, you will still need to implement |
11 | the calling function and an initialize and finalize method, see below. However, these are rather |
12 | simple. |
13 | |
14 | The important features of this example include: |
15 | @itemize @bullet |
16 | |
17 | @item Your part of the interface (The rest is handled in @code{HEPEVT_Interface.C}) |
18 | |
19 | @verbatim |
20 | #include "SHERPA/Main/Sherpa.H" |
21 | |
22 | class My_Sherpa { |
23 | private: |
24 | SHERPA::Sherpa m_sherpa; |
25 | public: |
26 | void init(int argc,char *argv[]) |
27 | { |
28 | // initialize the generator |
29 | m_sherpa.InitializeTheRun(argc,argv); |
30 | // set it up for event generation |
31 | m_sherpa.InitializeTheEventHandler(); |
32 | } |
33 | bool one_event() |
34 | { |
35 | // generate event and return status |
36 | if (!m_sherpa.GenerateOneEvent()) return false; |
37 | // now the HEPEVT common is filled and you can use it |
38 | return true; |
39 | } |
40 | void finish() |
41 | { |
42 | // clean up and store total cross section |
43 | m_sherpa.SummarizeRun(); |
44 | } |
45 | };// end of class My_Sherpa |
46 | @end verbatim |
47 | |
48 | @item The source file @code{HEPEVT_Interface.C}. |
49 | |
50 | This file defines a pseudo-analysis, which implements the conversion to HEPEVT. |
51 | |
52 | @item An example @code{Makefile}. |
53 | |
54 | This shows how to compile the source into a shared library called @code{libSherpaHEPEVT.so}. |
55 | The library can either be copied into the directory @code{<prefix>/lib/SHERPA-MC}, |
56 | or it can be placed in the run path. |
57 | |
58 | @item The line @code{SHERPA_LDADD = SherpaHEPEVT} in the @code{(run)} section of the run-card. |
59 | |
60 | This line tells Sherpa to load the extra library created from the *.C file above. |
61 | |
62 | @item The line @code{ANALYSIS = HEPEVT} in the @code{(run)} section of the run-card. |
63 | |
64 | This line tells Sherpa to run the pseudo-analysis implementing your HEPEVT interface. |
65 | |
66 | @end itemize |
67 | |
68 | To use this interface, create the additional library for Sherpa by running |
69 | |
70 | @example |
71 | make SHERPA_PREFIX=/path/to/sherpa |
72 | @end example |
73 | |
74 | in the directory @kbd{AddOns/HEPEVTInterface}. After copying the library, |
75 | run Sherpa from your interface. |
76 | |
77 | Note: You don't have to modify or recompile any part of Sherpa to use this |
78 | interface. As long as the @code{SHERPA_LDADD} parameter is specified as above, |
79 | Sherpa will pick up the HEPEVT converter automatically. |