GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ToyInteractionSelector.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <c.andreopoulos \at cern.ch>
7  University of Liverpool
8 */
9 //____________________________________________________________________________
10 
11 #include <TLorentzVector.h>
12 
22 
23 using namespace genie;
24 
25 //___________________________________________________________________________
27 InteractionSelectorI("genie::ToyInteractionSelector")
28 {
29 
30 }
31 //___________________________________________________________________________
33 InteractionSelectorI("genie::ToyInteractionSelector", config)
34 {
35 
36 }
37 //___________________________________________________________________________
39 {
40 
41 }
42 //___________________________________________________________________________
44  (const InteractionGeneratorMap * igmap, const TLorentzVector & p4) const
45 {
46  if(!igmap) {
47  LOG("IntSel", pERROR)
48  << "\n*** NULL InteractionGeneratorMap! Can't select interaction";
49  return 0;
50  }
51  if(igmap->size() <= 0) {
52  LOG("IntSel", pERROR)
53  << "\n*** Empty InteractionGeneratorMap! Can't select interaction";
54  return 0;
55  }
56 
57  // select a random event generator
59 
60  const InteractionList & ilst = igmap->GetInteractionList();
61 
62  unsigned int nint = ilst.size();
63  unsigned int iint = (unsigned int) rnd->RndISel().Integer(nint);
64 
65  Interaction * interaction = ilst[iint];
66 
67  // clone interaction
68  Interaction * selected_interaction = new Interaction( *interaction );
69  selected_interaction->InitStatePtr()->SetProbeP4(p4);
70  LOG("IntSel", pINFO)
71  << "Interaction to generate: \n" << *selected_interaction;
72 
73  // bootstrap the event record
74  EventRecord * evrec = new EventRecord;
75  evrec->AttachSummary(selected_interaction);
76 
77  return evrec;
78 }
79 //___________________________________________________________________________
void SetProbeP4(const TLorentzVector &P4)
#define pERROR
Definition: Messenger.h:59
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
virtual void AttachSummary(Interaction *interaction)
Definition: GHepRecord.cxx:99
Summary information for an interaction.
Definition: Interaction.h:56
An Interaction -&gt; EventGeneratorI associative container. The container is being built for the loaded ...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
Defines the InteractionSelectorI interface to be implemented by algorithms selecting interactions to ...
EventRecord * SelectInteraction(const InteractionGeneratorMap *igmp, const TLorentzVector &p4) const
implement the InteractionSelectorI interface
const InteractionList & GetInteractionList(void) const
A vector of Interaction objects.
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
TRandom3 & RndISel(void) const
rnd number generator used by interaction selectors
Definition: RandomGen.h:65
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...