EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmMCObject.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmMCObject.h
1 /*
2  * CbmMCStage.h
3  *
4  * Created on: Dec 1, 2009
5  * Author: stockman
6  */
7 
8 #ifndef CBMMCOBJECT_H_
9 #define CBMMCOBJECT_H_
10 
11 #include "CbmDetectorList.h"
12 #include "CbmMCEntry.h"
13 
14 #include "TObject.h"
15 
16 #include <vector>
17 #include <iostream>
18 
20 
21 class CbmMCObject: public TObject {
22  public:
23  CbmMCObject();
26  : TObject(), fStage(obj.GetEntryVector()), fStageId(obj.GetStageId())
27  {};
28  CbmMCObject(DataType type, std::vector<CbmMCEntry> stage)
29  : TObject(),
30  fStage(stage),
31  fStageId(type)
32  {
33  };
34  virtual ~CbmMCObject();
35 
36  void SetStageId(DataType type){fStageId = type;}
37 
38  void SetEntry(std::vector<Int_t> type, std::vector<Int_t> link, int index);
39  void SetEntry(FairMultiLinkedData* data, int index);
40  void SetEntry(CbmMCEntry link);
41 
42  void SetStage(std::vector<CbmMCEntry> stage) {fStage = stage;}
43  void SetLink(FairLink link, int index);
44  void AddLink(FairLink link, int index);
45 
46  CbmMCEntry GetEntry(int index) const {return fStage[index];}
47  FairLink GetSingleLink(int entryIndex, int linkIndex) const {
48  return fStage.at(entryIndex).GetLink(linkIndex);
49  }
50 
51  DataType GetStageId(void) const {return fStageId;}
52 
53  CbmMCEntry GetMCLink(Int_t index){return fStage.at(index);}
54 
55  int GetNEntries() const {return fStage.size();}
56  int GetNLinks(int entryIndex)const {return fStage.at(entryIndex).GetNLinks();}
57  std::vector<CbmMCEntry> GetEntryVector() const{return fStage;}
58 
59 // FairMultiLinkedData PosInList(std::pair<int, int> link);
61 
63  FairMultiLinkedData result;
64  for (int i = 0; i < GetNEntries(); i++){
65  result.AddLinks(GetMCLink(i).GetLinksWithType(type), false);
66  }
67  return result;
68  }
69 
70  virtual void ClearEntries(){fStage.clear();}
71 
72  virtual void Print(std::ostream& out = std::cout){out << *this;}
73 
75  TObject::operator=(obj);
76  fStageId = obj.GetStageId();
77  fStage = obj.GetEntryVector();
78  return *this;
79  }
80 
81  friend std::ostream& operator<< (std::ostream& out, const CbmMCObject& obj){
82  std::vector<CbmMCEntry> stages = obj.GetEntryVector();
83  for (int i = 0; i < stages.size(); i++){
84  out << i << ": ";
85  stages[i].Print(out);
86  }
87  return out;
88  }
89 
90 private:
91  void AdoptSize(int index);
92  std::vector<CbmMCEntry> fStage;
94 
95 
96 
98 };
99 
100 #endif /* PNDMCOBJECT_H_ */