FairRoot/PandaRoot
PndMCTruthMatch.cxx
Go to the documentation of this file.
1 /*
2  * PndIdealTrackFinders.cpp
3  *
4  * Created on: Apr 12, 2010
5  * Author: stockman
6  */
7 
8 #include "PndMCTruthMatch.h"
9 
10 #include "FairRootManager.h"
11 #include "FairMultiLinkedData.h"
12 #include "FairMultiLinkedData_Interface.h"
13 
14 #include "PndMCTrack.h"
15 
17 
19  fInBranchName("")
20 {
21  // TODO Auto-generated constructor stub
22 }
23 
24 
26  fInBranchName(inBranchName)
27 {
28 }
29 
31  // TODO Auto-generated destructor stub
32 }
33 
34 // ----- Public method Init --------------------------------------------
36 {
37 
38  FairRootManager* ioman = FairRootManager::Instance();
39  if (!ioman) {
40  std::cout << "-E- PndMCTruthMatch::Init: "
41  << "RootManager not instantiated!" << std::endl;
42  return kFATAL;
43  }
44 
45  if (fInBranchName == ""){
46  // Use hits of all tracking subsystems if nothing is given
47  std::cout << "-E- PndMCTruthMatch::Init no InBranchName given" << std::endl;
48  }
49 
50  fInBranch = (TClonesArray*)ioman->GetObject(fInBranchName);
51 
52  fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack");
53 
54  return kSUCCESS;
55 }
56 
57 //void PndMCTruthMatch::Exec(Option_t*)
58 //{
59 // std::cout << "------------ EventNr " << FairRootManager::Instance()->GetEntryNr() << " ------------" << std::endl;
60 // std::cout << FairRootManager::Instance()->GetBranchId(fInBranchName) << " : " << fInBranchName << " Entries: " << fInBranch->GetEntriesFast() << std::endl;
61 //
62 // for (int i = 0; i < fInBranch->GetEntriesFast(); i++)
63 // {
64 // FairMultiLinkedData_Interface* myData = (FairMultiLinkedData_Interface*)fInBranch->At(i);
65 // std::cout << i << " : " << *myData << std::endl;
66 // FairMultiLinkedData myLinks = myData->GetLinksWithType(FairRootManager::Instance()->GetBranchId("MCTrack"));
67 // for (int trackIndex = 0; trackIndex < myLinks.GetNLinks(); trackIndex++)
68 // {
69 // PndMCTrack* myTrack = (PndMCTrack*)FairRootManager::Instance()->GetCloneOfLinkData(myLinks.GetLink(trackIndex));
70 // std::cout << myLinks.GetLink(trackIndex) << " : " << *myTrack;
71 // delete (myTrack);
72 // }
73 // std::cout << std::endl;
74 // }
75 //}
76 
77 void PndMCTruthMatch::Exec(Option_t*)
78 {
79  std::cout << "------------ EventNr " << FairRootManager::Instance()->GetEntryNr() << " ------------" << std::endl;
80  std::cout << FairRootManager::Instance()->GetBranchId(fInBranchName) << " : " << fInBranchName << " Entries: " << fInBranch->GetEntriesFast() << std::endl;
81 
82  for (int i = 0; i < fInBranch->GetEntriesFast(); i++)
83  {
84  FairMultiLinkedData_Interface* myData = (FairMultiLinkedData_Interface*)fInBranch->At(i);
85  std::cout << i << " : " << *myData << std::endl;
86  std::vector<FairLink> myLinks = myData->GetSortedMCTracks();
87  for (unsigned int trackIndex = 0; trackIndex < myLinks.size(); trackIndex++)
88  {
89  PndMCTrack* myTrack = (PndMCTrack*)FairRootManager::Instance()->GetCloneOfLinkData(myLinks[trackIndex]);
90  std::cout << myLinks[trackIndex] << " : " << *myTrack;
91  delete (myTrack);
92  }
93  std::cout << std::endl;
94  }
95 }
96 
virtual void Exec(Option_t *opt)
Int_t i
Definition: run_full.C:25
virtual InitStatus Init()
TClonesArray * fMCTrack
TClonesArray * fInBranch
virtual ~PndMCTruthMatch()
ClassImp(PndAnaContFact)