20 #include <TClonesArray.h>
37 for (
TListIterator iter = fList.begin(); iter != fList.end(); ++iter) {
38 delete (iter->second);
53 fList[sourceType]->SetEntry(links, index);
58 if (fList[type] == 0) {
60 fList[type] = newStage;
62 std::cout <<
"InitStages: " << *newStage;
65 std::cout <<
"-W- FairMCMatch::InitStage: Stage " << type <<
" exists already!" << std::endl;
73 Int_t type = ioman->
GetBranchId(branchName.c_str());
77 std::cout <<
"-W- FairMCMatch::InitStage: Branch name " << branchName <<
" not registered!" << std::endl;
80 std::cout <<
"-W- FairMCMatch::InitStage: Branch name " << branchName <<
" not persistant!" << std::endl;
108 return GetMCInfoForward(start, stop);
110 return GetMCInfoBackward(start, stop);
126 if (!(fList[static_cast<Int_t>(aLink.
GetType())]->GetNEntries() > aLink.
GetIndex())) {
131 return GetMCInfoForwardSingle(aLink, stop);
133 return GetMCInfoBackwardSingle(aLink, stop);
137 FairMCResult FairMCMatch::GetMCInfoForward(Int_t start, Int_t stop)
144 FairMCEntry tempEntry(GetMCInfoForwardSingle(tempLink, stop));
145 if (tempEntry.GetNLinks() > 0)
146 if (tempEntry.GetLink(0).GetType() == start) {
147 tempEntry.DeleteLink(tempEntry.GetLink(0));
149 tempEntry.SetSource(start);
151 result.SetEntry(tempEntry);
164 FindStagesPointingToLinks(tempStage, stop);
169 FairMCResult FairMCMatch::GetMCInfoBackward(Int_t start, Int_t stop)
175 GetMCInfoBackwardSingle(tempLink, stop, startVec.
GetWeight());
176 result.SetEntry(&fFinalStageML, result.GetNEntries());
181 FairMCEntry FairMCMatch::GetMCInfoBackwardSingle(
FairLink aLink, Int_t stop, Double_t weight)
188 GetNextStage(multiLink, stop);
198 for (
int i = 0; i < links.
GetNLinks(); ++i) {
203 fFinalStageML.
AddLink(myLink,
true);
205 for (
int j = 0; j < myNewLinks.
GetNLinks(); ++j) {
206 if (myNewLinks.
GetLink(j).
GetType() ==
static_cast<Int_t
>(stop)) {
208 }
else if (myNewLinks.
GetLink(j).
GetType() >
static_cast<Int_t
>(stop)) {
209 fFinalStageML.
AddLink(myLink,
true);
217 FindStagesPointingToLinks(tempLinks, stop);
226 for (; iter != fList.end(); ++iter) {
227 if (iter->second->PosInList(link).GetNLinks() > 0) {
228 result.
AddLinks(iter->second->PosInList(link),
true);
247 std::cout <<
"Create Artificial Stage for " << branchName;
248 std::cout <<
" with ID " << ioman->
GetBranchId(branchName) << std::endl;
252 std::cout <<
"-E- FairMCMatch::CreateArtificialStage: Branch does not exist: " << branchName << std::endl;
264 for (
int i = 0; i < stageLinks.
GetNLinks(); ++i) {
269 fList[stage]->SetLoaded(kTRUE);
278 for (
int i = 0; i < startStage.
GetNLinks(); ++i) {
280 AddToFinalStage(startStage.
GetLink(i), 1);
282 std::cout <<
"FinalStage: " << fFinalStageML << std::endl;
283 std::cout <<
"---------------------" << std::endl;
289 std::cout <<
"TempStage Start";
291 std::cout <<
" --> " << tempStage << std::endl;
294 AddToFinalStage(startStage.
GetLink(i), 1);
296 std::cout <<
"FinalStage: " << fFinalStageML << std::endl;
297 std::cout <<
"---------------------" << std::endl;
304 std::cout <<
"Tempstage " << tempStage.
GetSource() <<
": weight " << tempStageWeight << std::endl;
305 std::cout <<
"StartLinkWeight " << startLinkWeight << std::endl;
309 if ((tempStageWeight * startLinkWeight) == 0) {
313 std::cout <<
" NLinks: " << tempStage.
GetNLinks() <<
" ";
314 std::cout <<
"AddAllWeights: " << startLinkWeight / startStage.
GetNLinks() << std::endl;
319 std::cout <<
"MultiplyAllWeights: " << startLinkWeight << std::endl;
324 std::cout <<
"TempStage Stop: " << tempStage << std::endl;
327 GetNextStage(tempStage, stopStage);
339 if (fList[type] == 0) {
342 if (fList[type]->GetNEntries() > index) {
343 return fList[type]->GetEntry(index);
353 void FairMCMatch::AddToFinalStage(
FairLink hitPair, Float_t mult) { fFinalStageML.
AddLink(hitPair,
true, mult); }
355 void FairMCMatch::ClearFinalStage() { fFinalStageML.
Reset(); }
359 for (
TListIterator iter = fList.begin(); iter != fList.end(); ++iter) {
360 if (iter->second != 0) {
361 iter->second->ClearEntries();
369 for (
TListIterator iter = fList.begin(); iter != fList.end(); ++iter) {
370 if (iter->first == type) {
379 for (
int i = 0; i < myLinkArray->GetEntriesFast(); ++i) {
382 fList[
static_cast<Int_t
>(myLink->
GetSource())]->SetEntry(*myLink);
383 fList[
static_cast<Int_t
>(myLink->
GetSource())]->SetLoaded(kTRUE);
FairMCResult GetMCInfo(Int_t start, Int_t stop)
FairMCEntry GetEntry(Int_t type, int index)
void SetWeight(Double_t weight)
void SetCommonWeightStages(Float_t weight)
virtual void AddAllWeights(Double_t weight)
Adds weight to all Links.
virtual void SetLinks(FairMultiLinkedData links, Float_t mult=1.0)
Sets the links as vector of FairLink.
bool IsTypeInList(Int_t type)
virtual void SetPersistanceCheck(Bool_t check)
Controls if a persistance check of a link is done or not.
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
void InitStage(Int_t type, const std::string &fileName, const std::string &branchName)
virtual void MultiplyAllWeights(Double_t weight)
Multiplies all Links with weight.
void SetElements(Int_t sourceType, int index, FairMultiLinkedData *links)
FairMCStage * GetMCStageType(TString branch)
FairMCEntry GetMCInfoSingle(FairLink aLink, Int_t stop)
virtual void AddLinks(FairMultiLinkedData links, Float_t mult=1.0)
Adds a List of FairLinks (FairMultiLinkedData) to fLinks.
void CreateArtificialStage(const TString &branchName, const std::string &fileName="")
Double_t GetWeight(void) const
void PrintLinkInfo(std::ostream &out=std::cout) const
virtual void SetLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
Sets the Links with a single FairLink.
virtual Int_t GetNLinks() const
returns the number of stored links
void RemoveStage(Int_t type)
virtual FairLink GetLink(Int_t pos) const
returns the FairLink at the given position
std::map< Int_t, FairMCStage * >::iterator TListIterator
Int_t CheckBranch(const char *BrName)
std::map< Int_t, FairMCStage * >::const_iterator TListIteratorConst
Int_t GetStageId(void) const
void AddElement(Int_t type, int index, FairLink link)
void LoadInMCLists(TClonesArray *myLinkArray)
virtual void AddLink(FairLink link, Bool_t bypass=kFALSE, Float_t mult=1.0)
FairMultiLinkedData FindLinksToStage(Int_t stage)
FairMCStage * GetMCStage(int index) const
Int_t GetBranchId(TString const &BrName)