EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmMCMatch.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmMCMatch.h
1 /*
2  * CbmMCMatch.h
3  *
4  * Created on: Nov 23, 2009
5  * Author: stockman
6  */
7 
8 #ifndef CBMMCMATCH_H_
9 #define CBMMCMATCH_H_
10 
11 
12 #include "CbmDetectorList.h"
13 #include "CbmMCStage.h"
14 #include "CbmMCResult.h"
15 #include "CbmMCEntry.h"
16 
17 #include "FairLink.h"
18 #include "FairMultiLinkedData.h"
19 
20 #include "TNamed.h"
21 
22 #include <map>
23 
25 
26 typedef std::map<DataType, CbmMCStage*>::iterator TListIterator;
27 typedef std::map<DataType, CbmMCStage*>::const_iterator TListIteratorConst;
28 
29 class CbmMCMatch: public TNamed {
30 public:
31  CbmMCMatch();
32  CbmMCMatch(const char* name, const char* title)
33  :TNamed(name, title), fUltimateStage(kMCTrack),
34  fList(), fFinalStageML() {};
35  virtual ~CbmMCMatch();
36 
37  void AddElement(DataType type, int index, FairLink link);
38  void AddElement(DataType sourceType, int index, DataType targetType, int link);
39  void SetElements(DataType sourceType, int index, FairMultiLinkedData* links);
40  void InitStage(DataType type, std::string fileName, std::string branchName);
41  void RemoveStage(DataType type);
42  void LoadInMCLists(TClonesArray* myLinkArray);
43  void ClearMCList();
44 
45  void SetCommonWeightStages(Float_t weight);
46 
47  CbmMCEntry GetEntry(DataType type, int index);
49 
52 
53  int GetNMCStages() const {return fList.size();}
54 
55  CbmMCStage* GetMCStage(int index) const{
56  TListIteratorConst iter = fList.begin();
57  for (int i = 0; i < index; i++)
58  iter++;
59  return (iter->second);
60  }
61 
63  return fList[type];
64  }
65 
66  void CreateArtificialStage(DataType stage, std::string fileName = "", std::string branchName = "");
67 
69 
70  bool IsTypeInList(DataType type);
71 
72  void Print(std::ostream& out = std::cout){out << *this;}
73 
74  friend std::ostream& operator<< (std::ostream& out, const CbmMCMatch& match){
75  for (int i = 0; i < match.GetNMCStages(); i++){
76  if (match.GetMCStage(i)->GetLoaded() == kTRUE){
77  match.GetMCStage(i)->Print(out);
78  out << std::endl;
79  }
80  }
81  return out;
82  }
83 
84 private:
86  std::map<DataType, CbmMCStage*> fList;
88 
91 
95  CbmMCEntry GetMCInfoBackwardSingle(FairLink link, DataType stop, Double_t weight = 1.);
96 
97  void GetNextStage(FairMultiLinkedData& startEntry, DataType stopStage);
98  void AddToFinalStage(FairLink link, Float_t mult);
99  void ClearFinalStage();
100  ClassDef(CbmMCMatch, 1);
101 };
102 
103 #endif /* PNDMCMATCH_H_ */