21 #include <TClonesArray.h>
31 , fPersistanceCheck(kTRUE)
32 , fInsertHistory(kTRUE)
41 , fPersistanceCheck(persistanceCheck)
42 , fInsertHistory(kTRUE)
48 const std::vector<Int_t>& links,
51 Bool_t persistanceCheck,
57 , fPersistanceCheck(persistanceCheck)
58 , fInsertHistory(kTRUE)
67 const std::vector<Int_t>& links,
70 Bool_t persistanceCheck,
76 , fPersistanceCheck(persistanceCheck)
77 , fInsertHistory(kTRUE)
86 if (pos < static_cast<Int_t>(
fLinks.size())) {
88 return *(std::next(
fLinks.begin(), pos));
90 std::cout <<
"-E- FairMultiLinkedData:GetLink(pos) pos " << pos <<
" outside range " <<
fLinks.size()
105 Float_t weight = link.
GetWeight() * mult;
112 std::set<FairLink> myLinks = links.
GetLinks();
113 for (
auto link : myLinks) {
114 link.SetWeight(link.GetWeight() * mult);
121 Float_t weight = link.
GetWeight() * mult;
128 std::cout <<
"-W- no IOManager present!" << std::endl;
132 std::cout <<
"Add FairLink: " << link << std::endl;
144 if (bypass == kFALSE) {
152 std::cout <<
"BYPASS!" << std::endl;
158 if (bypass == kTRUE) {
163 std::cout <<
"Entries in " << ioman->
GetBranchName(link.
GetType()) <<
" Array: " << array->GetEntries()
168 std::cout <<
"FairMultiLinkedData has " << links->
GetNLinks() <<
" Entries: " << std::endl;
169 std::cout << *links << std::endl;
191 std::set<FairLink>::iterator it =
fLinks.find(link);
196 fLinks.insert(myTempLink);
209 std::cout <<
"FairMultiLinkedData::InsertHistory for Link " << link
224 if (myObject->InheritsFrom(
"FairMultiLinkedData_Interface")) {
226 pointerToLinks = interface->GetPointerToLinks();
228 std::cout <<
"FairMultiLinkedData::InsertHistory Link to wrong Class: "
234 if (dataArray != 0 && link.
GetIndex() < dataArray->GetEntriesFast()) {
235 TObject* myObject = dataArray->At(link.
GetIndex());
236 if (myObject->InheritsFrom(
"FairMultiLinkedData_Interface")) {
238 pointerToLinks = interface->GetPointerToLinks();
240 std::cout <<
"FairMultiLinkedData::InsertHistory Link to wrong Class: "
246 if (pointerToLinks != 0) {
247 std::set<FairLink> linkSet = pointerToLinks->
GetLinks();
248 for (
auto tlink : linkSet) {
250 std::cout <<
"FairMultiLinkedData::InsertHistory inserting " << tlink << std::endl;
266 std::set<FairLink>::iterator it = std::find(
fLinks.begin(),
fLinks.end(),
FairLink(type, index));
268 return std::distance(
fLinks.begin(), it);
285 for (
auto link :
fLinks) {
286 if (link.GetType() == type) {
298 std::set<FairLink> mcSet = mcLinks.
GetLinks();
299 std::vector<FairLink> mcVector(mcSet.begin(), mcSet.end());
302 std::sort(begin(mcVector), end(mcVector),
LargerWeight);
311 TClonesArray* myArray =
static_cast<TClonesArray*
>(ioman->
GetObject(branchName));
313 if (myArray->GetEntries() > myLink.
GetIndex()) {
314 return myArray->At(myLink.
GetIndex());
316 std::cout <<
"-E- FairMultiLinkedData::GetData index out of bounds" << std::endl;
319 std::cout <<
"-E- FairMultiLinkedData::GetData no TClonesArray" << std::endl;
322 std::cout <<
"-E- FairMultiLinkedData::GetData Branch does not exist in Memory" << std::endl;
330 std::set<FairLink> tempLinks;
331 for (
auto link :
fLinks) {
332 link.SetWeight(weight);
333 tempLinks.insert(link);
340 std::set<FairLink> tempLinks;
341 for (
auto link :
fLinks) {
342 link.SetWeight(weight + link.GetWeight());
343 tempLinks.insert(link);
350 std::set<FairLink> tempLinks;
351 for (
auto link :
fLinks) {
352 link.SetWeight(weight * link.GetWeight());
353 tempLinks.insert(link);
void SetWeight(Float_t weight)
virtual void SimpleAddLinks(Int_t fileId, Int_t evtId, Int_t dataType, const std::vector< Int_t > &links, Bool_t, Float_t)
bool LargerWeight(FairLink val1, FairLink val2)
virtual Bool_t IsLinkInList(FairLink link)
Test if a given link is in fLinks.
TObject * GetData(FairLink &myLink)
Get the TObject the Link is pointing to.
virtual void AddAllWeights(Double_t weight)
Adds weight to all Links.
virtual std::vector< FairLink > GetSortedMCTracks()
Gives you a list of all FairLinks pointing to a "MCTrack" sorted by their weight. ...
virtual void SetLinks(FairMultiLinkedData links, Float_t mult=1.0)
Sets the links as vector of FairLink.
std::set< FairLink > fLinks
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
virtual Int_t LinkPosInList(FairLink link)
returns position of link in fLinks. If it is not in the list -1 is returned
virtual void SetAllWeights(Double_t weight)
Sets a common weight for Links.
TObject * GetObject(const char *BrName)
virtual void MultiplyAllWeights(Double_t weight)
Multiplies all Links with weight.
virtual void InsertHistory(FairLink link)
Adds the FairLinks of the inserted link to the set of links of this object.
virtual void InsertLink(FairLink link)
Inserts a link into the list of links without persistance checking.
static FairLinkManager * Instance()
Int_t GetMCTrackBranchId() const
virtual void AddLinks(FairMultiLinkedData links, Float_t mult=1.0)
Adds a List of FairLinks (FairMultiLinkedData) to fLinks.
FairMultiLinkedData()
Default constructor.
virtual void SetLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
Sets the Links with a single FairLink.
virtual void DeleteLink(FairLink link)
Deletes a link ouf of fLinks.
TString GetBranchName(Int_t id)
virtual Int_t GetNLinks() const
returns the number of stored links
virtual FairLink GetLink(Int_t pos) const
returns the FairLink at the given position
Int_t CheckBranch(const char *BrName)
virtual void AddLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
void AddWeight(Float_t weight)
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.