FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndHypGeIdealTrackFinderTask Class Reference

#include <PndHypGeIdealTrackFinderTask.h>

Inheritance diagram for PndHypGeIdealTrackFinderTask:

Public Member Functions

 PndHypGeIdealTrackFinderTask ()
 
virtual ~PndHypGeIdealTrackFinderTask ()
 
virtual void SetParContainers ()
 
virtual InitStatus Init ()
 
virtual InitStatus ReInit ()
 
virtual void Exec (Option_t *opt)
 
void WriteHistograms ()
 

Private Member Functions

 ClassDef (PndHypGeIdealTrackFinderTask, 1)
 

Private Attributes

TString fMcBranch
 
TString fTrackBranch
 
TClonesArray * fMcArray
 
TClonesArray * fTrackArray
 
TH1F * hismom
 
int fEventNr
 
std::map< int, std::vector< int > > mcHitMap
 
Int_t fVerbose
 

Detailed Description

Definition at line 26 of file PndHypGeIdealTrackFinderTask.h.

Constructor & Destructor Documentation

PndHypGeIdealTrackFinderTask::PndHypGeIdealTrackFinderTask ( )

Default constructor

Definition at line 22 of file PndHypGeIdealTrackFinderTask.cxx.

References fMcBranch, and fTrackBranch.

22  :
23  FairTask("HYP Ideal Track Finding Task"), fEventNr(0)
24 {
25 
26 
27  fMcBranch = "HypGePoint";
28  fTrackBranch = "MCTrack";
29 }
PndHypGeIdealTrackFinderTask::~PndHypGeIdealTrackFinderTask ( )
virtual

Destructor

Definition at line 36 of file PndHypGeIdealTrackFinderTask.cxx.

References hismom.

37 {
38  delete(hismom);
39 }

Member Function Documentation

PndHypGeIdealTrackFinderTask::ClassDef ( PndHypGeIdealTrackFinderTask  ,
 
)
private
void PndHypGeIdealTrackFinderTask::Exec ( Option_t *  opt)
virtual

Virtual method Exec

Definition at line 109 of file PndHypGeIdealTrackFinderTask.cxx.

References Double_t, fEventNr, fMcArray, fTrackArray, PndMCTrack::GetMotherID(), PndMCTrack::GetPdgCode(), PndHypGePoint::GetTrackID(), hismom, i, map, mcHitMap, mom, and PndHypGePoint::Momentum().

110 {
111  // Reset output array
112  // if ( ! fTrackCandArray )
113  // Fatal("Exec", "No trackCandArray");
114  // fTrackCandArray->Delete();
115 
116 
117 
118  //mcHitMap = AssignHitsToTracks();
119  for (int i = 0; i < fMcArray->GetEntriesFast(); i++){ //get all MC Hits
120  PndHypGePoint* myPoint = (PndHypGePoint*)(fMcArray->At(i)); //sort MCHits with Tracks
121 
122  TVector3 mom;
123  myPoint->Momentum(mom);
124 
125 
126  PndMCTrack* myTrack = (PndMCTrack*)(fTrackArray->At(myPoint->GetTrackID()));
127  mcHitMap[myPoint->GetTrackID()].push_back(i);
128 
129 
130  }
131 
132  std::cout << "------------Event " << fEventNr << "-------------" << std::endl;
133  fEventNr++;
134  std::cout<<" size map "<<mcHitMap.size()<<std::endl;
135 
136 
137 
138  for (std::map<int, std::vector<int> >::const_iterator it = mcHitMap.begin();
139  it!= mcHitMap.end(); it++) { //go through all tracks
140 
141  PndMCTrack* myTrack = (PndMCTrack*)(fTrackArray->At(it->first));
142  if(myTrack==0)continue;
143 
144  std::vector<int> MChits = it->second;
145 
146 
147  if (MChits.size() >0){
148 
149  PndHypGePoint* startPoint = (PndHypGePoint*)(fMcArray->At(MChits[0]));
150  if(startPoint==0)continue;
151 
152  TVector3 mome,momst;
153 
154  startPoint->Momentum(momst);
155 
156 
157  Int_t MothId, Mothpdg;
158  MothId= myTrack->GetMotherID();
159 
160  if (MothId==-1){
161  Mothpdg = myTrack->GetPdgCode();
162  if(Mothpdg==2112){
163  /*else {
164  cout<<"mother id "<<MothId<<endl;
165  PndMCTrack *mother =(PndMCTrack*)fMcTr->At(MothId);
166  Mothpdg = mother->GetPdgCode();
167  }
168  */
169 
170  Double_t Theta;
171  hismom->Fill(180/3.1416*momst.Theta());
172  }
173  }
174  }
175  }
176 
177 
178  fMcArray->Delete();
179  fTrackArray->Delete();
180 
181 }
Int_t i
Definition: run_full.C:25
PndTransMap * map
Definition: sim_emc_apd.C:99
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
Int_t GetTrackID() const
Definition: PndHypGePoint.h:51
Double_t mom
Definition: plot_dirc.C:14
Double_t
void Momentum(TVector3 &mom)
Definition: PndHypGePoint.h:65
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
std::map< int, std::vector< int > > mcHitMap
InitStatus PndHypGeIdealTrackFinderTask::Init ( )
virtual

Definition at line 69 of file PndHypGeIdealTrackFinderTask.cxx.

References fMcArray, fMcBranch, fTrackArray, fTrackBranch, and hismom.

70 {
71 
72  FairRootManager* ioman = FairRootManager::Instance();
73 
74  if ( ! ioman )
75  {
76  std::cout << "-E- PndHypGeIdealTrackFinderTask::Init: "
77  << "RootManager not instantiated!" << std::endl;
78  return kFATAL;
79  }
80 
81 
82 // Get input array
83 
84  fMcArray = (TClonesArray*) ioman->GetObject(fMcBranch);
85  if ( !fMcArray){
86  std::cout << "-W- PndHypGeIdealTrackFinderTask::Init: " << "No mcArray!" << std::endl;
87  return kERROR;
88  }
89 
90  fTrackArray = (TClonesArray*) ioman->GetObject(fTrackBranch);
91  if ( !fTrackArray){
92  std::cout << "-W- PndHypGeIdealTrackFinderTask::Init: " << "No trackArray!" << std::endl;
93  return kERROR;
94  }
95 
96  hismom = new TH1F("hismom","HYPGe MC Points, momentum",100,0.,180.);
97  hismom->SetTitle("Kinetic energy GeV");
98 
99 
100 
101  std::cout << "-I- PndHypGeIdealTrackFinderTask: Initialisation successfull" << std::endl;
102  return kSUCCESS;
103 }
InitStatus PndHypGeIdealTrackFinderTask::ReInit ( )
virtual

Definition at line 53 of file PndHypGeIdealTrackFinderTask.cxx.

54 {
55 
56  InitStatus stat=kERROR;
57  return stat;
58 
59  /*
60  FairRunAna* ana = FairRunAna::Instance();
61  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
62  fGeoPar=(PndHypGeoPar*)(rtdb->getContainer("PndHypGeoPar"));
63 
64  return kSUCCESS;
65  */
66 }
void PndHypGeIdealTrackFinderTask::SetParContainers ( )
virtual

Virtual method Init

Definition at line 43 of file PndHypGeIdealTrackFinderTask.cxx.

44 {
45  // Get Base Container
46 /*
47  FairRunAna* ana = FairRunAna::Instance();
48  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
49  fGeoPar = (PndHypGeoPar*)(rtdb->getContainer("PndHypGeoPar"));
50 */
51 }
void PndHypGeIdealTrackFinderTask::WriteHistograms ( )

Definition at line 205 of file PndHypGeIdealTrackFinderTask.cxx.

References file, and hismom.

205  {
206  TFile* file = FairRootManager::Instance()->GetOutFile();
207  file->cd();
208  file->mkdir("neutron");
209  file->cd("neutron");
210 
211  hismom->Write();
212  delete hismom;
213  hismom=NULL;
214 }
TFile * file

Member Data Documentation

int PndHypGeIdealTrackFinderTask::fEventNr
private

Definition at line 60 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Exec().

TClonesArray* PndHypGeIdealTrackFinderTask::fMcArray
private

Input array of PndHypDigis

Definition at line 54 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Exec(), and Init().

TString PndHypGeIdealTrackFinderTask::fMcBranch
private

Definition at line 49 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Init(), and PndHypGeIdealTrackFinderTask().

TClonesArray* PndHypGeIdealTrackFinderTask::fTrackArray
private

Definition at line 55 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Exec(), and Init().

TString PndHypGeIdealTrackFinderTask::fTrackBranch
private

Definition at line 50 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Init(), and PndHypGeIdealTrackFinderTask().

Int_t PndHypGeIdealTrackFinderTask::fVerbose
private

Definition at line 62 of file PndHypGeIdealTrackFinderTask.h.

TH1F* PndHypGeIdealTrackFinderTask::hismom
private

Output array of PndHypHits

Definition at line 59 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Exec(), Init(), WriteHistograms(), and ~PndHypGeIdealTrackFinderTask().

std::map<int, std::vector<int> > PndHypGeIdealTrackFinderTask::mcHitMap
private

Definition at line 61 of file PndHypGeIdealTrackFinderTask.h.

Referenced by Exec().


The documentation for this class was generated from the following files: