EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmMCObject.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmMCObject.cxx
1 /*
2  * CbmMCObject.cpp
3  *
4  * Created on: Dec 1, 2009
5  * Author: stockman
6  */
7 
8 #include "CbmMCObject.h"
9 
11 
13  : TObject(),
14  fStage(),
15  fStageId()
16 {
17  //std::cout << "-I- CbmMCObject::CbmMCObject : Use of default constructor" << std::endl;
18 }
19 
21  // TODO Auto-generated destructor stub
22 }
23 
24 
26  if (entry.GetPos() < 0){
27  std::cout << "-E- CbmMCObject::SetEntry(CbmMCEntry): pos " << entry.GetPos() << std::endl;
28  return;
29  }
30  AdoptSize(entry.GetPos());
31  fStage[entry.GetPos()] = entry;
32 }
33 
34 void CbmMCObject::SetEntry(std::vector<Int_t> type, std::vector<Int_t> link, int index){
35  CbmMCEntry myEntry;
36  myEntry.SetPos(index);
37  for (int i = 0; i < type.size(); i++){
38  myEntry.AddLink(FairLink(type[i],link[i]));
39  }
40  SetEntry(myEntry);
41 }
42 
44 {
45  AdoptSize(index);
46  fStage[index].SetLinks(data->GetLinks());
47 }
48 
49 void CbmMCObject::SetLink(FairLink link, int index)
50 {
51  if (index < fStage.size()){
52  fStage[index].Reset();
53  }
54  AddLink(link, index);
55 }
56 
57 
58 void CbmMCObject::AddLink(FairLink link, int index)
59 {
60  AdoptSize(index);
61  fStage[index].AddLink(link);
62  //std::cout << "AddLink " << index << ": "<< fStageDet[index][fStageDet[index].size()-1] << " " << fStageHit[index][fStageHit[index].size()-1] << std::endl;
63 }
64 
65 void CbmMCObject::AdoptSize(int index){
66  int start = fStage.size();
67  while (fStage.size() < index+1){
68  CbmMCEntry myVec;
69  myVec.SetPos(fStage.size());
70  myVec.SetSource(GetStageId());
71  //std::pair<int,int> myPair(fStageId, start);
72  //myVec.AddLink(myPair);
73  fStage.push_back(myVec);
74  start++;
75  }
76 }
77 
79  FairMultiLinkedData result;
80  for (int i = 0; i < fStage.size(); i++){
81  if (fStage[i].IsLinkInList(link.GetType(), link.GetIndex()))
82  result.AddLink(FairLink(GetStageId(), i));
83  }
84  return result;
85 }