FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMultiLinkedData_Interface.cxx
Go to the documentation of this file.
1 /*
2  * FairMultiLinkedData_Interface.cxx
3  *
4  * Created on: Dec 7, 2009
5  * Author: stockman
6  */
7 
9 
10 #include "FairRootManager.h" // for FairRootManager
11 
13 
15 {
16  SetLinks(links);
17 }
18 
20  std::vector<Int_t> links,
21  Int_t fileId,
22  Int_t evtId,
23  Bool_t persistanceCheck,
24  Bool_t bypass,
25  Float_t mult)
26 {
27  FairMultiLinkedData data(dataType, links, fileId, evtId, persistanceCheck, bypass, mult);
28  SetLinks(data);
29 }
30 
32  std::vector<Int_t> links,
33  Int_t fileId,
34  Int_t evtId,
35  Bool_t persistanceCheck,
36  Bool_t bypass,
37  Float_t mult)
38 {
39  FairMultiLinkedData data(dataType, links, fileId, evtId, persistanceCheck, bypass, mult);
40  SetLinks(data);
41 }
42 
44  : TObject(toCopy)
45 {
46  if (toCopy.GetPointerToLinks() != 0) {
47  SetInsertHistory(kFALSE);
48  SetLinks(*(toCopy.GetPointerToLinks()));
49  SetEntryNr(toCopy.GetEntryNr());
50  // copy history flag information
52  }
53 }
54 
56 {
57  if (rhs.GetPointerToLinks() != 0) {
58  SetInsertHistory(kFALSE);
59  SetLinks(*(rhs.GetPointerToLinks()));
60  SetEntryNr(rhs.GetEntryNr());
61  SetInsertHistory(kTRUE);
62  }
63  return *this;
64 }
65 
67 {
68  if (FairRootManager::Instance() != nullptr) {
69  if (FairRootManager::Instance()->GetUseFairLinks()) {
70  if (fLink == nullptr) {
71  fLink.reset(new FairMultiLinkedData());
72  }
73  return fLink.get();
74  }
75  }
76  return 0;
77 }
78 
79 std::set<FairLink> FairMultiLinkedData_Interface::GetLinks() const
80 {
81  if (GetPointerToLinks() != 0) {
82  return GetPointerToLinks()->GetLinks();
83  } else {
84  std::set<FairLink> emptySet;
85  return emptySet;
86  }
87 }
88 
90 {
91  if (GetPointerToLinks() != 0) {
92  return GetPointerToLinks()->GetNLinks();
93  } else {
94  return 0;
95  }
96 }
97 
99 {
100  if (GetPointerToLinks() != 0) {
101  return GetPointerToLinks()->GetLink(pos);
102  } else {
103  FairLink emptyLink;
104  return emptyLink;
105  }
106 }
107 
109 {
110  if (GetPointerToLinks() != 0) {
111  return GetPointerToLinks()->GetEntryNr();
112  } else {
113  FairLink emptyLink;
114  return emptyLink;
115  }
116 }
117 
119 {
120  if (GetPointerToLinks() != 0) {
121  return GetPointerToLinks()->GetLinksWithType(type);
122  } else {
123  FairMultiLinkedData emptyLinks;
124  return emptyLinks;
125  }
126 }
127 
129 {
130  if (GetPointerToLinks() != 0) {
132  } else {
133  std::vector<FairLink> empty;
134  return empty;
135  }
136 }
137 
139 {
141  if (GetPointerToLinks() != 0) {
142  GetPointerToLinks()->SetLinks(links);
143  }
144 }
145 
147 {
149  if (GetPointerToLinks() != 0) {
150  GetPointerToLinks()->SetLink(link);
151  }
152 }
153 
155 {
157  if (GetPointerToLinks() != 0) {
159  }
160 }
161 
163 {
165  if (GetPointerToLinks() != 0) {
166  GetPointerToLinks()->AddLinks(links, mult);
167  }
168 }
169 
171 {
173  if (GetPointerToLinks() != 0) {
174  GetPointerToLinks()->AddLink(link);
175  }
176 }
177 
179 {
180  SetInsertHistory(kFALSE); // todo add previous history value
181  if (data->GetEntryNr().GetType() != -1)
182  AddLink(data->GetEntryNr());
183  else
184  std::cout << "-E- FairMultiLinkedData_Interface::AddInterfaceData EntryNr == " << data->GetEntryNr()
185  << std::endl;
186 
187  if (data->GetPointerToLinks() != 0) {
188  AddLinks(*data->GetPointerToLinks());
189  }
190  SetInsertHistory(GetPointerToLinks()->GetInsertHistory());
191 }
192 
194 {
196  if (GetPointerToLinks() != 0) {
198  }
199 }
200 
202 {
203  if (GetPointerToLinks() != 0) {
205  }
206 }
void SetLinks(FairMultiLinkedData links)
Sets the links as vector of FairLink.
FairMultiLinkedData_Interface()=default
Default constructor.
FairMultiLinkedData_Interface & operator=(const FairMultiLinkedData_Interface &rhs)
Int_t GetNLinks() const
returns the number of stored links
FairMultiLinkedData GetLinksWithType(Int_t type) const
returns all FairLinks with the corresponding type
void SetLink(FairLink link)
Sets the Links with a single FairLink.
virtual void SetEntryNr(FairLink entry)
virtual std::vector< FairLink > GetSortedMCTracks()
Gives you a list of all FairLinks pointing to a &quot;MCTrack&quot; sorted by their weight. ...
virtual void SetLinks(FairMultiLinkedData links, Float_t mult=1.0)
Sets the links as vector of FairLink.
virtual FairLink GetEntryNr() const
gives back the entryNr
std::set< FairLink > GetLinks() const
returns stored links as FairLinks
static FairRootManager * Instance()
virtual void ResetLinks()
Clears fLinks.
ClassImp(FairEventBuilder)
FairLink GetLink(Int_t pos) const
returns the FairLink at the given position
FairMultiLinkedData * GetPointerToLinks() const
returns non-owning pointer
std::unique_ptr< FairMultiLinkedData > fLink
virtual void AddLinks(FairMultiLinkedData links, Float_t mult=1.0)
Adds a List of FairLinks (FairMultiLinkedData) to fLinks.
virtual void SetLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
Sets the Links with a single FairLink.
void AddLinks(FairMultiLinkedData links, Float_t mult=1.0)
Adds a List of FairLinks (FairMultiLinkedData_Interface) to fLinks.
virtual Int_t GetNLinks() const
returns the number of stored links
virtual void SetInsertHistory(Bool_t val)
Toggles if history of a link is inserted or not.
Bool_t GetInsertHistory() const
virtual FairLink GetLink(Int_t pos) const
returns the FairLink at the given position
FairMultiLinkedData * CreateFairMultiLinkedData()
returns non-owning pointer
void AddInterfaceData(FairMultiLinkedData_Interface *data)
virtual void AddLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
virtual std::set< FairLink > GetLinks() const
returns stored links as FairLinks
virtual FairMultiLinkedData GetLinksWithType(Int_t type) const
Gives you a list of links which contain the given type.