FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMultiLinkedData.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
15 #ifndef FAIRMULTILINKEDDATA_H_
16 #define FAIRMULTILINKEDDATA_H_
17 
18 #include "FairLink.h" // for FairLink
19 
20 #include <Rtypes.h> // for Int_t, Bool_t, kFALSE, etc
21 #include <TObject.h> // for TObject
22 #include <TString.h> // for TString
23 #include <iosfwd> // for ostream
24 #include <iostream> // for operator<<, ostream, cout
25 #include <set> // for set
26 #include <vector> // for vector
27 
28 class FairMultiLinkedData : public TObject
29 {
30  public:
32  FairMultiLinkedData(const std::set<FairLink>& links, Bool_t persistanceCheck = kTRUE);
33  FairMultiLinkedData(TString dataType,
34  const std::vector<Int_t>& links,
35  Int_t fileId = -1,
36  Int_t evtId = -1,
37  Bool_t persistanceCheck = kTRUE,
38  Bool_t bypass = kFALSE,
39  Float_t mult = 1.0);
40  FairMultiLinkedData(Int_t dataType,
41  const std::vector<Int_t>& links,
42  Int_t fileId = -1,
43  Int_t evtId = -1,
44  Bool_t persistanceCheck = kTRUE,
45  Bool_t bypass = kFALSE,
46  Float_t mult = 1.0);
47 
48  virtual ~FairMultiLinkedData(){};
49 
50  virtual std::set<FairLink> GetLinks() const { return fLinks; }
51  virtual FairLink GetEntryNr() const { return fEntryNr; }
52  virtual Int_t GetNLinks() const { return fLinks.size(); }
53  virtual FairLink GetLink(Int_t pos) const;
55  Int_t type) const;
56  virtual std::vector<FairLink>
58  TObject* GetData(FairLink& myLink);
59  virtual Int_t GetDefaultType() { return fDefaultType; }
60  Bool_t GetPersistanceCheck() { return fPersistanceCheck; }
61  Int_t GetVerbose() { return fVerbose; }
62  virtual void SetDefaultType(Int_t type) { fDefaultType = type; }
63  virtual void SetPersistanceCheck(Bool_t check)
64  {
65  fPersistanceCheck = check;
66  }
67  virtual void SetVerbose(Int_t level) { fVerbose = level; }
68  virtual void SetInsertHistory(Bool_t val)
69  {
70  fInsertHistory = val;
71  }
72  Bool_t GetInsertHistory() const { return fInsertHistory; }
73 
74  virtual void SetEntryNr(FairLink entry) { fEntryNr = entry; }
75  virtual void SetLinks(FairMultiLinkedData links, Float_t mult = 1.0);
76  virtual void SetLink(FairLink link,
77  Bool_t bypass = kFALSE,
78  Float_t mult = 1.0);
79 
80  virtual void AddLinks(FairMultiLinkedData links,
81  Float_t mult = 1.0);
82  virtual void AddLink(FairLink link,
83  Bool_t bypass = kFALSE,
84  Float_t mult = 1.0);
85 
87  virtual void InsertLink(FairLink link);
88  virtual void InsertHistory(
89  FairLink link);
90 
91  virtual void AddAllWeights(Double_t weight);
92  virtual void SetAllWeights(Double_t weight);
93  virtual void MultiplyAllWeights(Double_t weight);
94 
95  virtual Bool_t IsLinkInList(FairLink link)
96  {
97  return IsLinkInList(link.GetType(), link.GetIndex());
98  }
99  virtual Bool_t IsLinkInList(
100  Int_t type,
101  Int_t index);
102  virtual Int_t LinkPosInList(FairLink link)
103  {
104  return LinkPosInList(link.GetType(), link.GetIndex());
105  }
106  virtual Int_t LinkPosInList(Int_t type, Int_t index);
107 
108  virtual void DeleteLink(FairLink link)
109  {
110  DeleteLink(link.GetType(), link.GetIndex());
111  }
112  virtual void DeleteLink(Int_t type, Int_t index);
113 
114  virtual void Reset() { ResetLinks(); }
115  virtual void ResetLinks() { fLinks.clear(); }
116 
117  std::ostream& PrintLinkInfo(std::ostream& out = std::cout) const
118  {
119  out << GetEntryNr() << " -> [";
120  for (Int_t i = 0; i < GetNLinks(); i++) {
121  GetLink(i).PrintLinkInfo(out);
122  out << " ";
123  }
124  out << "]";
125  return out;
126  }
127 
128  friend std::ostream& operator<<(std::ostream& out, const FairMultiLinkedData& data)
129  {
130  data.PrintLinkInfo(out);
131  return out;
132  }
133 
134  protected:
135  std::set<FairLink> fLinks;
138  Bool_t fInsertHistory;
139  Int_t fVerbose;
140 
141  virtual void SimpleAddLinks(Int_t fileId,
142  Int_t evtId,
143  Int_t dataType,
144  const std::vector<Int_t>& links,
145  Bool_t,
146  Float_t)
147  {
148  for (UInt_t i = 0; i < links.size(); i++) {
149  fLinks.insert(FairLink(fileId, evtId, dataType, links[i]));
150  }
151  }
153 
155 };
156 
169 #endif /* FAIRMULTILinkedData_H_ */
virtual void SimpleAddLinks(Int_t fileId, Int_t evtId, Int_t dataType, const std::vector< Int_t > &links, Bool_t, Float_t)
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.
ClassDef(FairMultiLinkedData, 4)
virtual void AddAllWeights(Double_t weight)
Adds weight to all Links.
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
virtual void SetPersistanceCheck(Bool_t check)
Controls if a persistance check of a link is done or not.
std::set< FairLink > fLinks
virtual void ResetLinks()
Clears fLinks.
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.
virtual void MultiplyAllWeights(Double_t weight)
Multiplies all Links with weight.
friend std::ostream & operator<<(std::ostream &out, const FairMultiLinkedData &data)
Output.
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.
Bool_t GetPersistanceCheck()
Returns the value of PersistanceCheck.
std::ostream & PrintLinkInfo(std::ostream &out=std::cout) const
Output.
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.
Int_t GetVerbose()
Returns the verbosity level.
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
virtual void SetVerbose(Int_t level)
Sets the verbosity level.
virtual void AddLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
virtual Int_t GetDefaultType()
virtual std::set< FairLink > GetLinks() const
returns stored links as FairLinks
virtual void SetDefaultType(Int_t type)
virtual FairMultiLinkedData GetLinksWithType(Int_t type) const
Gives you a list of links which contain the given type.