FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMCObject.cxx
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  ********************************************************************************/
8 /*
9  * FairMCObject.cpp
10  *
11  * Created on: Dec 1, 2009
12  * Author: stockman
13  */
14 
15 #include "FairMCObject.h"
16 
18 
20  : TObject()
21  , fStage(0)
22  , fStageId()
23 {}
24 
26 
28 {
29  if (entry.GetPos() < 0) {
30  std::cout << "-E- FairMCObject::SetEntry(FairMCEntry): pos " << entry.GetPos() << std::endl;
31  return;
32  }
33  AdoptSize(entry.GetPos());
34  fStage[entry.GetPos()] = entry;
35 }
36 
37 void FairMCObject::SetEntry(std::vector<Int_t> type, std::vector<Int_t> link, int index)
38 {
39  FairMCEntry myEntry;
40  myEntry.SetPos(index);
41  myEntry.SetPersistanceCheck(kFALSE);
42  for (unsigned int i = 0; i < type.size(); i++) {
43  myEntry.AddLink(FairLink(type[i], link[i]));
44  }
45  SetEntry(myEntry);
46 }
47 
49 {
50  AdoptSize(index);
51  fStage[index].SetLinks(data->GetLinks());
52 }
53 
54 void FairMCObject::SetLink(FairLink link, int index)
55 {
56  if (index < static_cast<int>(fStage.size())) {
57  fStage[index].ResetLinks();
58  }
59  AddLink(link, index);
60 }
61 
62 void FairMCObject::AddLink(FairLink link, int index)
63 {
64  AdoptSize(index);
65  fStage[index].AddLink(link);
66 }
67 
68 void FairMCObject::AdoptSize(int index)
69 {
70  int start = fStage.size();
71  while (static_cast<int>(fStage.size()) < index + 1) {
72  FairMCEntry myVec;
73  myVec.SetPos(fStage.size());
74  myVec.SetSource(GetStageId());
75  myVec.SetPersistanceCheck(kFALSE);
76  fStage.push_back(myVec);
77  start++;
78  }
79 }
80 
82 {
83  FairMultiLinkedData result;
84  result.SetPersistanceCheck(kFALSE);
85  for (unsigned int i = 0; i < fStage.size(); i++) {
86  if (fStage[i].IsLinkInList(link.GetType(), link.GetIndex())) {
87  result.AddLink(FairLink(GetStageId(), i));
88  }
89  }
90  return result;
91 }
92 
93 void FairMCObject::RemoveType(Int_t type)
94 {
95  for (unsigned int i = 0; i < fStage.size(); i++) {
96  fStage[i].RemoveType(type);
97  }
98 }
FairMultiLinkedData PosInList(std::pair< int, int > link)
void RemoveType(Int_t type)
virtual void SetPersistanceCheck(Bool_t check)
Controls if a persistance check of a link is done or not.
void SetLink(FairLink link, int index)
ClassImp(FairEventBuilder)
void SetSource(Int_t source)
Definition: FairMCEntry.h:45
virtual ~FairMCObject()
void SetPos(Int_t pos)
Definition: FairMCEntry.h:46
void AddLink(FairLink link, int index)
Int_t GetPos() const
Definition: FairMCEntry.h:49
Int_t GetStageId(void) const
Definition: FairMCObject.h:76
virtual void AddLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
virtual std::set< FairLink > GetLinks() const
returns stored links as FairLinks
void SetEntry(std::vector< Int_t > type, std::vector< Int_t > link, int index)