GHepVirtualListFolder.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 - July 16, 2005
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
20 
21 using namespace genie;
22 
23 //____________________________________________________________________________
25 //____________________________________________________________________________
27 {
28  fInstance = 0;
29 }
30 //____________________________________________________________________________
32 {
33  this->Clear();
34  fInstance = 0;
35 }
36 //____________________________________________________________________________
38 {
39  if(fInstance == 0) {
40 
41  static GHepVirtualListFolder::Cleaner cleaner;
43 
45  }
46  return fInstance;
47 }
48 //____________________________________________________________________________
50 {
51 // Adds a particle to the named virtual list - if the list does not exists it
52 // creates it first.
53 // The virtual list has no ownership of its
54  bool exists = this->VirtualListExists(listname);
55 
56  if(!exists) this->AddVirtualList(listname);
57 
58  int n = fVirtualListMap[listname]->GetEntries();
59  GHepVirtualList * vl = fVirtualListMap[listname];
60  (*vl)[n] = (TObject*)p;
61 }
62 //____________________________________________________________________________
64 {
65 // checks whether a virtual list exists
66 
67  bool exists = (fVirtualListMap.count(listname) == 1);
68  return exists;
69 }
70 //____________________________________________________________________________
71 void GHepVirtualListFolder::RemoveList(string listname)
72 {
73 // removes the input virtual list (if it exists)
74 
75  bool exists = (fVirtualListMap.count(listname) == 1);
76  if(!exists) return;
77 
78  map<string, GHepVirtualList *>::iterator
79  vlmiter = fVirtualListMap.find(listname);
80 
81  GHepVirtualList * vlist = vlmiter->second;
82  if(vlist) delete vlist;
83  vlist = 0;
84 
85  fVirtualListMap.erase(listname);
86 }
87 //____________________________________________________________________________
89 {
90 // removes all virtual lists
91 
92  map<string, GHepVirtualList *>::iterator vlmiter;
93  for (vlmiter = fVirtualListMap.begin();
94  vlmiter != fVirtualListMap.end(); ++vlmiter) {
95  GHepVirtualList * vlist = vlmiter->second;
96  if(vlist) delete vlist;
97  vlist = 0;
98  }
99  fVirtualListMap.clear();
100 }
101 //____________________________________________________________________________
103 {
104  bool exists = this->VirtualListExists(listname);
105 
106  if(!exists) return 0;
107  else return fVirtualListMap[listname];
108 }
109 //____________________________________________________________________________
111 {
112  GHepVirtualList * vl = new GHepVirtualList;
113  fVirtualListMap.insert(
114  map<string, GHepVirtualList *>::value_type(listname,vl) );
115 }
116 //____________________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const char * p
Definition: xmltok.h:285
bool VirtualListExists(string listname)
A GHepVirtualList is a &#39;virtual&#39; collection of GHepParticles. Is virtual because it does not own but ...
std::void_t< T > n
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:40
GHepVirtualList * VirtualList(string listname)