GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GHepVirtualListFolder.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 
14 
15 using namespace genie;
16 
17 //____________________________________________________________________________
19 //____________________________________________________________________________
21 {
22  fInstance = 0;
23 }
24 //____________________________________________________________________________
26 {
27  this->Clear();
28  fInstance = 0;
29 }
30 //____________________________________________________________________________
32 {
33  if(fInstance == 0) {
34 
35  static GHepVirtualListFolder::Cleaner cleaner;
37 
39  }
40  return fInstance;
41 }
42 //____________________________________________________________________________
44 {
45 // Adds a particle to the named virtual list - if the list does not exists it
46 // creates it first.
47 // The virtual list has no ownership of its
48  bool exists = this->VirtualListExists(listname);
49 
50  if(!exists) this->AddVirtualList(listname);
51 
52  int n = fVirtualListMap[listname]->GetEntries();
53  GHepVirtualList * vl = fVirtualListMap[listname];
54  (*vl)[n] = (TObject*)p;
55 }
56 //____________________________________________________________________________
58 {
59 // checks whether a virtual list exists
60 
61  bool exists = (fVirtualListMap.count(listname) == 1);
62  return exists;
63 }
64 //____________________________________________________________________________
65 void GHepVirtualListFolder::RemoveList(string listname)
66 {
67 // removes the input virtual list (if it exists)
68 
69  bool exists = (fVirtualListMap.count(listname) == 1);
70  if(!exists) return;
71 
72  map<string, GHepVirtualList *>::iterator
73  vlmiter = fVirtualListMap.find(listname);
74 
75  GHepVirtualList * vlist = vlmiter->second;
76  if(vlist) delete vlist;
77  vlist = 0;
78 
79  fVirtualListMap.erase(listname);
80 }
81 //____________________________________________________________________________
83 {
84 // removes all virtual lists
85 
86  map<string, GHepVirtualList *>::iterator vlmiter;
87  for (vlmiter = fVirtualListMap.begin();
88  vlmiter != fVirtualListMap.end(); ++vlmiter) {
89  GHepVirtualList * vlist = vlmiter->second;
90  if(vlist) delete vlist;
91  vlist = 0;
92  }
93  fVirtualListMap.clear();
94 }
95 //____________________________________________________________________________
97 {
98  bool exists = this->VirtualListExists(listname);
99 
100  if(!exists) return 0;
101  else return fVirtualListMap[listname];
102 }
103 //____________________________________________________________________________
105 {
106  GHepVirtualList * vl = new GHepVirtualList;
107  fVirtualListMap.insert(
108  map<string, GHepVirtualList *>::value_type(listname,vl) );
109 }
110 //____________________________________________________________________________
bool VirtualListExists(string listname)
A GHepVirtualList is a &#39;virtual&#39; collection of GHepParticles. Is virtual because it does not own but ...
A singleton class to manage all named GHepVirtualLists.
static GHepVirtualListFolder * fInstance
static GHepVirtualListFolder * Instance(void)
map< string, GHepVirtualList * > fVirtualListMap
void AddToVirtualList(string listname, GHepParticle *p)
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
GHepVirtualList * VirtualList(string listname)