FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairPrintFairLinks.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- FairPrintFairLinks source file -----
3 // ----- Created 18/07/08 by T.Stockmanns -----
4 // -------------------------------------------------------------------------
5 // libc includes
6 #include <FairPrintFairLinks.h>
7 
8 // Root includes
9 #include <TClonesArray.h>
10 
11 // framework includes
12 #include "FairLogger.h"
14 #include "FairRootManager.h"
15 
17  : FairTask("Creates PndMCMatch")
18  , fSelectedBranches(new TList())
19 {}
20 
22 
24 {
26  if (!ioman) {
27  LOG(error) << "-E- FairPrintFairLinks::Init: "
28  << "RootManager not instantiated!";
29  return kFATAL;
30  }
31 
32  TList* branchNames;
33  if (fSelectedBranches->GetEntries() > 0) {
34  branchNames = fSelectedBranches;
35  } else {
36  branchNames = ioman->GetBranchNameList();
37  }
38 
39  InitBranchList(branchNames);
40 
42 
43  return kSUCCESS;
44 }
45 
47 {
49  for (int i = 0; i < branches->GetEntries();
50  ++i) { // removes branches which do not contain objects derived from FairMultiLinkedData_Interface
51  TObjString* branchName = (TObjString*)branches->At(i);
52  if (branchName->String().Contains("_link"))
53  continue;
54  if (branchName->String().Contains("MCTrack"))
55  continue;
56  if (branchName->String().Contains("."))
57  continue;
58  if (branchName->String().Contains("GeoTracks"))
59  continue;
60  if (branchName->String().Contains("Header"))
61  continue;
62  if (branchName->String().Contains("Info"))
63  continue;
64  if (branchName->String().Contains("ID"))
65  continue;
66  if (branchName->String().Contains("PidAlgo"))
67  continue;
68  if (branchName->String().Contains("Riemann"))
69  continue;
70 
71  LOG(debug) << "FairPrintFairLinks::Init() branches: " << branchName->String();
72  if ((TClonesArray*)ioman->GetObject(branchName->String()) != 0) {
73  fBranches[ioman->GetBranchId(branchName->String())] = (TClonesArray*)ioman->GetObject(branchName->String());
74  } else {
75  LOG(warning) << "-E- FairPrintFairLinks " << branchName->String().Data() << " is not a valid branch name!";
76  }
77  }
78 }
79 
81 {
82  LOG(info) << "-I- FairPrintFairLinks Branches:";
83 
84  for (int i = 0; i < branches->GetEntries(); ++i) {
85  TObjString* branchName = (TObjString*)branches->At(i);
86  LOG(info) << i << " : " << branchName->String().Data() << "\n";
87  }
88  LOG(info) << "\n";
89 }
90 
92 {
93  // Get Base Container
94  // FairRun* ana = FairRun::Instance();
95  // FairRuntimeDb* rtdb=ana->GetRuntimeDb();
96 }
97 
98 void FairPrintFairLinks::Exec(Option_t*)
99 {
100  LOG(info) << "\n--------------------- Event " << FairRootManager::Instance()->GetEntryNr() << " at "
101  << FairRootManager::Instance()->GetEventTime() << " ns ----------------------";
102  for (std::map<Int_t, TClonesArray*>::iterator iter = fBranches.begin(); iter != fBranches.end(); ++iter) {
103  LOG(info) << "\n"
104  << iter->first << " : " << FairRootManager::Instance()->GetBranchName(iter->first)
105  << " Entries: " << iter->second->GetEntriesFast();
106  for (int i = 0; i < iter->second->GetEntriesFast(); ++i) {
107  FairMultiLinkedData_Interface* myLinks = (FairMultiLinkedData_Interface*)iter->second->At(i);
108  if (myLinks->GetPointerToLinks() != 0) {
109  LOG(info) << i << " : " << *myLinks << "\n";
110  }
111  }
112  }
113 }
114 
116 
InitStatus
Definition: FairTask.h:33
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
TList * GetBranchNameList()
FairMultiLinkedData * GetPointerToLinks() const
returns non-owning pointer
Double_t GetEventTime()
TString GetBranchName(Int_t id)
Int_t GetBranchId(TString const &BrName)