FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMCMatch.h
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  * FairMCMatch.h
10  *
11  * Created on: Nov 23, 2009
12  * Author: stockman
13  */
14 
15 #ifndef FAIRMCMATCH_H_
16 #define FAIRMCMATCH_H_
17 
18 #include "FairMCEntry.h" // for FairMCEntry
19 #include "FairMCResult.h" // for FairMCResult
20 #include "FairMCStage.h" // for FairMCStage
21 #include "FairMultiLinkedData.h" // for FairMultiLinkedData
22 #include "FairRootManager.h" // for FairRootManager
23 
24 #include <Rtypes.h> // for Int_t, FairMCMatch::Class, etc
25 #include <TNamed.h> // for TNamed
26 #include <TString.h> // for TString
27 #include <iostream> // for ostream, cout, endl
28 #include <map> // for map, etc
29 #include <string> // for string
30 #include <utility> // for pair
31 
32 class FairLink;
33 class TClonesArray;
34 
35 typedef std::map<Int_t, FairMCStage*>::iterator TListIterator;
36 typedef std::map<Int_t, FairMCStage*>::const_iterator TListIteratorConst;
37 
38 class FairMCMatch : public TNamed
39 {
40  public:
41  FairMCMatch();
42  FairMCMatch(const char* name, const char* title)
43  : TNamed(name, title)
44  , fUltimateStage(0)
45  , fList()
46  , fFinalStageML()
47  , fVerbose(0)
48  {
49  fFinalStageML.SetPersistanceCheck(kFALSE);
50  }
51 
52  virtual ~FairMCMatch();
53 
54  void AddElement(Int_t type, int index, FairLink link);
55  void AddElement(Int_t sourceType, int index, Int_t targetType, int link);
56  void SetElements(Int_t sourceType, int index, FairMultiLinkedData* links);
57  void InitStage(Int_t type, const std::string& fileName, const std::string& branchName);
58  void InitStage(const std::string& fileName, const std::string& branchName = "");
59  void RemoveStage(Int_t type);
60  void LoadInMCLists(TClonesArray* myLinkArray);
61  void ClearMCList();
62 
63  void SetCommonWeightStages(Float_t weight);
64 
65  FairMCEntry GetEntry(Int_t type, int index);
67 
68  FairMCResult GetMCInfo(Int_t start, Int_t stop);
69  FairMCResult GetMCInfo(TString start, TString stop);
70  FairMCEntry GetMCInfoSingle(FairLink aLink, Int_t stop);
71  FairMCEntry GetMCInfoSingle(FairLink aLink, TString stop);
72 
73  int GetNMCStages() const { return fList.size(); }
74 
75  FairMCStage* GetMCStage(int index) const
76  {
77  TListIteratorConst iter = fList.begin();
78  for (int i = 0; i < index; i++) {
79  iter++;
80  }
81  return (iter->second);
82  }
83 
84  FairMCStage* GetMCStageType(TString branch)
85  {
87  if (ioman->GetBranchId(branch) > 0) {
88  return fList[ioman->GetBranchId(branch)];
89  } else {
90  return 0;
91  }
92  }
93 
94  FairMCStage* GetMCStageType(Int_t type) { return fList[type]; }
95 
96  void CreateArtificialStage(const TString& branchName, const std::string& fileName = "");
97  void CreateArtificialStage(Int_t stage, const std::string& fileName = "", const std::string& branchName = "");
98 
100 
101  bool IsTypeInList(Int_t type);
102 
103  void PrintInfo(std::ostream& out = std::cout) { out << *this; }
104 
105  friend std::ostream& operator<<(std::ostream& out, const FairMCMatch& match)
106  {
107  for (int i = 0; i < match.GetNMCStages(); i++) {
108  if (match.GetMCStage(i)->GetLoaded() == kTRUE) {
109  match.GetMCStage(i)->PrintInfo(out);
110  out << std::endl;
111  }
112  }
113  return out;
114  }
115 
116  private:
117  Int_t fUltimateStage;
118  std::map<Int_t, FairMCStage*> fList;
119  FairMultiLinkedData fFinalStageML;
120  Int_t fVerbose;
121 
122  void FindStagesPointingToLinks(FairMultiLinkedData links, Int_t stop);
123  FairMultiLinkedData FindStagesPointingToLink(FairLink link);
124 
125  FairMCResult GetMCInfoForward(Int_t start, Int_t stop);
126  FairMCResult GetMCInfoBackward(Int_t start, Int_t stop);
127  FairMCEntry GetMCInfoForwardSingle(FairLink link, Int_t stop);
128  FairMCEntry GetMCInfoBackwardSingle(FairLink link, Int_t stop, Double_t weight = 1.);
129 
130  void GetNextStage(FairMultiLinkedData& startEntry, Int_t stopStage);
131  void AddToFinalStage(FairLink link, Float_t mult);
132  void ClearFinalStage();
133 
134  ClassDef(FairMCMatch, 1);
135 };
136 
137 #endif /* FAIRMCMATCH_H_ */
FairMCResult GetMCInfo(Int_t start, Int_t stop)
FairMCEntry GetEntry(Int_t type, int index)
virtual ~FairMCMatch()
Definition: FairMCMatch.cxx:35
int GetNMCStages() const
Definition: FairMCMatch.h:73
void SetCommonWeightStages(Float_t weight)
Definition: FairMCMatch.cxx:86
void PrintInfo(std::ostream &out=std::cout)
Definition: FairMCMatch.h:103
FairMCMatch(const char *name, const char *title)
Definition: FairMCMatch.h:42
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()
void InitStage(Int_t type, const std::string &fileName, const std::string &branchName)
Definition: FairMCMatch.cxx:56
void SetElements(Int_t sourceType, int index, FairMultiLinkedData *links)
Definition: FairMCMatch.cxx:51
FairMCStage * GetMCStageType(TString branch)
Definition: FairMCMatch.h:84
friend std::ostream & operator<<(std::ostream &out, const FairMCMatch &match)
Definition: FairMCMatch.h:105
FairMCEntry GetMCInfoSingle(FairLink aLink, Int_t stop)
void CreateArtificialStage(const TString &branchName, const std::string &fileName="")
virtual void PrintInfo(std::ostream &out)
Definition: FairMCStage.h:76
Bool_t GetLoaded(void) const
Definition: FairMCStage.h:67
void RemoveStage(Int_t type)
Definition: FairMCMatch.cxx:84
void ClearMCList()
FairMCStage * GetMCStageType(Int_t type)
Definition: FairMCMatch.h:94
std::map< Int_t, FairMCStage * >::iterator TListIterator
Definition: FairMCMatch.h:33
std::map< Int_t, FairMCStage * >::const_iterator TListIteratorConst
Definition: FairMCMatch.h:36
void AddElement(Int_t type, int index, FairLink link)
Definition: FairMCMatch.cxx:49
void LoadInMCLists(TClonesArray *myLinkArray)
FairMultiLinkedData FindLinksToStage(Int_t stage)
FairMCStage * GetMCStage(int index) const
Definition: FairMCMatch.h:75
Int_t GetBranchId(TString const &BrName)