EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairLink.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairLink.h
1 /*
2  * FairLink.h
3  *
4  * Created on: Dec 23, 2009
5  * Author: stockman
6  */
7 
8 #ifndef FAIRLINK_H_
9 #define FAIRLINK_H_
10 
11 #include "TObject.h"
12 #include "TString.h"
13 
14 #include <utility>
15 #include <iostream>
16 
17 class FairLink : public TObject
18 {
19  public:
20  FairLink();
21  FairLink(Int_t type, Int_t index, Float_t weight = 1.);
22  FairLink(TString branchName, Int_t index, Float_t weight = 1.);
23  FairLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.);
24  FairLink(Int_t file, Int_t entry, TString branchName, Int_t index, Float_t weight = 1.);
25  virtual ~FairLink();
26 
27  void SetLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.) {
28  fFile = file;
29  fEntry = entry;
30  fType = type;
31  fIndex = index;
32  fWeight = weight;
33  };
34  void SetLink(Int_t type, Int_t index, Float_t weight = 1.) {
35  fFile = -1;
36  fEntry = -1;
37  fType = type;
38  fIndex = index;
39  fWeight = weight;
40  };
41  Int_t GetFile() const {return fFile;}
42  Int_t GetEntry() const {return fEntry;}
43  Int_t GetType() const {return fType;}
44  Int_t GetIndex() const {return fIndex;}
45  Float_t GetWeight() const {return fWeight;}
46 
47  void SetWeight(Float_t weight) {fWeight = weight;}
48  void AddWeight(Float_t weight) {fWeight += weight;}
49 
50  virtual void Print(std::ostream& out = std::cout) const;
51 
52  virtual bool operator==(const FairLink& link) const {
53  if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType == link.GetType() && fIndex == link.GetIndex()) {
54  return true;
55  } else {
56  return false;
57  }
58  }
59 
60  virtual bool operator<(const FairLink& link) const {
61  if (fFile < link.GetFile()) {
62  return true;
63  } else if (fFile == link.GetFile() && fEntry < link.GetEntry()) {
64  return true;
65  } else if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType < link.GetType()) {
66  return true;
67  } else if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType == link.GetType() && fIndex < link.GetIndex()) {
68  return true;
69  } else {
70  return false;
71  }
72  }
73 
74  friend std::ostream& operator<< (std::ostream& out, const FairLink& link) {
75  link.Print(out);
76  return out;
77  }
78 
79  ClassDef(FairLink, 3);
80 
81 
82  private:
83  Int_t fFile;
84  Int_t fEntry;
85  Int_t fType;
86  Int_t fIndex;
87  Float_t fWeight;
88 
89 };
90 
91 #endif /* FAIRLINK_H_ */