ToyInteractionSelector.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab - December 05, 2004
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <TLorentzVector.h>
18 
28 
29 using namespace genie;
30 
31 //___________________________________________________________________________
33 InteractionSelectorI("genie::ToyInteractionSelector")
34 {
35 
36 }
37 //___________________________________________________________________________
39 InteractionSelectorI("genie::ToyInteractionSelector", config)
40 {
41 
42 }
43 //___________________________________________________________________________
45 {
46 
47 }
48 //___________________________________________________________________________
50  (const InteractionGeneratorMap * igmap, const TLorentzVector & p4) const
51 {
52  if(!igmap) {
53  LOG("IntSel", pERROR)
54  << "\n*** NULL InteractionGeneratorMap! Can't select interaction";
55  return 0;
56  }
57  if(igmap->size() <= 0) {
58  LOG("IntSel", pERROR)
59  << "\n*** Empty InteractionGeneratorMap! Can't select interaction";
60  return 0;
61  }
62 
63  // select a random event generator
65 
66  const InteractionList & ilst = igmap->GetInteractionList();
67 
68  unsigned int nint = ilst.size();
69  unsigned int iint = (unsigned int) rnd->RndISel().Integer(nint);
70 
71  Interaction * interaction = ilst[iint];
72 
73  // clone interaction
74  Interaction * selected_interaction = new Interaction( *interaction );
75  selected_interaction->InitStatePtr()->SetProbeP4(p4);
76  LOG("IntSel", pINFO)
77  << "Interaction to generate: \n" << *selected_interaction;
78 
79  // bootstrap the event record
80  EventRecord * evrec = new EventRecord;
81  evrec->AttachSummary(selected_interaction);
82 
83  return evrec;
84 }
85 //___________________________________________________________________________
void SetProbeP4(const TLorentzVector &P4)
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
#define pERROR
Definition: Messenger.h:60
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
Definition: config.py:1
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:30
virtual void AttachSummary(Interaction *interaction)
Definition: GHepRecord.cxx:143
Summary information for an interaction.
Definition: Interaction.h:56
An Interaction -> 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:97
#define pINFO
Definition: Messenger.h:63
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
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:66
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...