sherpa is hosted by Hepforge, IPPP Durham
close Warning: Can't synchronize with repository "(default)" (/hepforge/svn/sherpa does not appear to be a Subversion repository.). Look in the Trac log for more information.

Ticket #204: MyInterface.texi

File MyInterface.texi, 2.7 KB (added by Frank Siegert, 13 years ago)
Line 
1@node My own interface
2@section My own interface
3
4It is possible to pass Sherpa output to an external Fortran or C++ framework on-the-flight.
5To 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.
7It also exemplifies how to retrieve the weight of weighted events and how to access information
8about the total cross section of the event sample at the end of the run.
9
10Note that only the event converter is included in the sources, you will still need to implement
11the calling function and an initialize and finalize method, see below. However, these are rather
12simple.
13
14The 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
22class My_Sherpa {
23private:
24  SHERPA::Sherpa m_sherpa;
25public:
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
68To use this interface, create the additional library for Sherpa by running
69
70@example
71make SHERPA_PREFIX=/path/to/sherpa
72@end example
73
74in the directory @kbd{AddOns/HEPEVTInterface}. After copying the library,
75run Sherpa from your interface.
76
77Note: You don't have to modify or recompile any part of Sherpa to use this
78interface. As long as the @code{SHERPA_LDADD} parameter is specified as above,
79Sherpa will pick up the HEPEVT converter automatically.