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

#include <PndHypMSAnaTask.h>

Inheritance diagram for PndHypMSAnaTask:

Public Member Functions

 PndHypMSAnaTask ()
 
 ~PndHypMSAnaTask ()
 
virtual void SetParContainers ()
 
virtual InitStatus Init ()
 
virtual void Exec (Option_t *opt)
 
virtual void Finish ()
 
void WriteHistograms ()
 

Private Member Functions

void Register ()
 
void Reset ()
 
void ProduceHits ()
 
std::map< int, std::vector< int > > AssignHitsToTracks ()
 
 ClassDef (PndHypMSAnaTask, 1)
 

Private Attributes

TClonesArray * fMCHits
 
TClonesArray * fMCTracks
 
TClonesArray * fTrackParGeane
 
TClonesArray * fTrackParIni
 
TClonesArray * fTrackParFinal
 
FairGeanePro * fPro
 
PndHypGeoHandlingfGeoH
 
TH1F * histo
 
int fEventNr
 
std::map< int, std::vector< int > > mcHitMap
 
std::map< int, std::vector< int > > fTrackPixHitIdMap
 
std::map< int, std::vector< int > > fTrackStripHitIdMap
 

Detailed Description

Definition at line 32 of file PndHypMSAnaTask.h.

Constructor & Destructor Documentation

PndHypMSAnaTask::PndHypMSAnaTask ( )

Default constructor

Definition at line 33 of file PndHypMSAnaTask.cxx.

References histo.

33  : FairTask("Geane Task for PANDA PndHyp"), fEventNr(0)
34 {
35  histo = new TH1F("h1","h1",3000,0,20);
36 }
PndHypMSAnaTask::~PndHypMSAnaTask ( )

Destructor

Definition at line 41 of file PndHypMSAnaTask.cxx.

References fGeoH, and histo.

42 {delete(histo);delete fGeoH;
43 }
PndHypGeoHandling * fGeoH

Member Function Documentation

std::map< int, std::vector< int > > PndHypMSAnaTask::AssignHitsToTracks ( )
private

Definition at line 232 of file PndHypMSAnaTask.cxx.

References fMCHits, fMCTracks, i, and mom.

Referenced by Exec().

233 {
234  std::map<int, std::vector<int> > result;
235  for (int i = 0; i < fMCHits->GetEntriesFast(); i++){ //get all MC Hits
236  PndHypPoint* myPoint = (PndHypPoint*)(fMCHits->At(i)); //sort MCHits with Tracks
237  //if(myPoint->GetTrackID()>1000)continue;
238  TVector3 mom;
239  myPoint->Momentum(mom);
240 
241  // if(mom.Mag()>0.05){
242  //std::cout<<" hyp "<<myPoint->GetTrackID()<<std::endl;
243  //}
244 
245  PndMCTrack* myTrack = (PndMCTrack*)(fMCTracks->At(myPoint->GetTrackID()));
246  result[myPoint->GetTrackID()].push_back(i);
247  //}
248 
249  }
250  return result;
251  //result.clear();
252 }
Int_t i
Definition: run_full.C:25
Double_t mom
Definition: plot_dirc.C:14
TClonesArray * fMCTracks
TClonesArray * fMCHits
PndHypMSAnaTask::ClassDef ( PndHypMSAnaTask  ,
 
)
private
void PndHypMSAnaTask::Exec ( Option_t *  opt)
virtual

Virtual method Exec

Definition at line 93 of file PndHypMSAnaTask.cxx.

References AssignHitsToTracks(), fEventNr, Finish(), fMCHits, fMCTracks, PndMCTrack::GetMotherID(), PndMCTrack::GetPdgCode(), histo, map, mcHitMap, MotherId, and Motherpdg.

94 {
95  // mcHitMap.clear(); //Track -> MCHits
96  TVector3 vpi2;
97 
98 // fTrackParGeane->Delete();
99 // fTrackParIni->Delete();
100 // fTrackParFinal->Delete();
101 
103 
104  std::cout << "------------Event " << fEventNr << "-------------" << std::endl;
105  fEventNr++;
106  std::cout<<" size map "<<mcHitMap.size()<<std::endl;
107 
108  for (std::map<int, std::vector<int> >::const_iterator it = mcHitMap.begin();
109  it!= mcHitMap.end();
110  it++)
111  { //go through all tracks
112  PndMCTrack* myTrack = (PndMCTrack*)(fMCTracks->At(it->first));
113  std::vector<int> MChits = it->second;
114 
115  /* if(myTrack==0)
116  {
117  it++;
118  continue;
119  }
120  */
121 
122 
123  //if(myTrack->GetPdgCode()>1010000000||myTrack->GetPdgCode()>1020000000)
124  //std::cout<<" hypernuclei "<<std::endl;
125 
126  if (MChits.size() >=3){
127 
128  PndHypPoint* startPoint = (PndHypPoint*)(fMCHits->At(0));
129  std::cout<<" hits "<<MChits.size()<<(it->first)<<std::endl;
130  //std::cout << "StartPoint: " << *startPoint << std::endl;
131 
132  //PndMCTrack* mctruth=(PndMCTrack*)fMCTracks->At( startPoint->GetTrackID());
133  //if(mctruth==0)continue;
134  std::cout<<" pid "<<startPoint->GetTrackID()<<" "<<it->first<<std::endl;
135  Int_t MotherId, Motherpdg;
136  MotherId= myTrack->GetMotherID();
137 
138  if (MotherId==-1)Motherpdg = myTrack->GetPdgCode();
139  else {
140  PndMCTrack *mother =(PndMCTrack*)fMCTracks->At(MotherId);
141  Motherpdg = mother->GetPdgCode();
142  }
143  if((myTrack->GetPdgCode()==-211)&&( Motherpdg>1010000000&&
144  Motherpdg<1020050130) )
145  { //startPoint->MomentumIn(vpi2);//vpi2 = mctruth->GetMomentum();
146  std::cout<<" hits "<<MChits.size()<<" "<<Motherpdg<<std::endl;
147 
148  histo->Fill(MChits.size());//vpi2.Mag());
149  }
150 
151  /*
152  TVector3 StartPos(startPoint->GetPosition());
153  TVector3 StartPosErr(0.0, 0.0, 0.0);
154  TVector3 StartMom(startPoint->GetPx(), startPoint->GetPy(), startPoint->GetPz());
155  TVector3 StartMomErr(0.0, 0.0, 0.0);
156  TVector3 startO, startU, startV;
157 
158  fGeoH->GetOUVId(startPoint->GetDetName(), startO, startU, startV);
159  fPro->PropagateFromPlane(startU, startV);
160 
161  Int_t PDGCode = myTrack->GetPdgCode();
162  TDatabasePDG *fdbPDG= TDatabasePDG::Instance();
163  TParticlePDG *fParticle= fdbPDG->GetParticle(PDGCode);
164  Double_t fCharge= fParticle->Charge();
165 
166  TClonesArray& clref1 = *fTrackParIni;
167  Int_t size1 = clref1.GetEntriesFast();
168  FairTrackParP *fStart= new (clref1[size1]) FairTrackParP(StartPos, StartMom, StartPosErr, StartMomErr, fCharge, startO, startU, startV);
169 
170  for (int p = 1; p < MChits.size(); p++){ //go through all hits in track
171  PndHypPoint* myPoint = (PndHypPoint*)(fMCHits->At(MChits[p]));
172  std::cout << "PropagationPoint: " << *myPoint << std::endl;
173 
174  TVector3 StopPos(myPoint->GetPosition());
175  TVector3 StopPosErr(0.0, 0.0, 0.0);
176  TVector3 StopMom(myPoint->GetPx(), myPoint->GetPy(), myPoint->GetPz());
177  TVector3 StopMomErr(0.0, 0.0, 0.0);
178 
179  TVector3 o, u, v;
180  fGeoH->GetOUVId(myPoint->GetDetName(), o, u, v);
181 
182  TClonesArray& clref2 = *fTrackParFinal;
183  Int_t size2 = clref2.GetEntriesFast();
184  FairTrackParP *fStop= new (clref2[size2]) FairTrackParP(StopPos, StopMom, StopPosErr, StopMomErr, fCharge, o, u, v);
185 
186  TClonesArray& clref = *fTrackParGeane;
187  Int_t size = clref.GetEntriesFast();
188  FairTrackParP *fRes= new(clref[size]) FairTrackParP();
189 
190  std::cout << "Propagation Plane:" << std::endl;
191  std::cout << "o: " << o[0] << " " << o[1] << " " << o[2] << std::endl;
192  std::cout << "u: " << u[0] << " " << u[1] << " " << u[2] << std::endl;
193  std::cout << "v: " << v[0] << " " << v[1] << " " << v[2] << std::endl;
194 
195  TVector3 endPoint(myPoint->GetPosition());
196  //fPro->SetPoint(endPoint);
197  //fPro->PropagateToPCA(1);
198 
199  fPro->PropagateToPlane(o, u, v);
200  if(fCharge>0)fPro->Propagate(fStart, fRes, 211);
201  if(fCharge<0)fPro->Propagate(fStart, fRes, -211);
202 
203  std::cout << std::endl;
204  std::cout << "Propagation Points: " << std::endl;
205  std::cout << fRes->GetX() << " +/- " << fRes->GetDX() << std::endl;
206  std::cout << fRes->GetY() << " +/- " << fRes->GetDY() << std::endl;
207  std::cout << fRes->GetZ() << " +/- " << fRes->GetDZ() << std::endl;
208  std::cout << std::endl;
209 
210  TVector3 global(fRes->GetX(), fRes->GetY(), fRes->GetZ());
211  TVector3 local = fGeoH->MasterToLocalId(global, myPoint->GetDetName());
212 
213  std::cout << "Propagation Point local: " << std::endl;
214  std::cout << local[0] << " " << local[1] << " " << local[2] << std::endl;
215  std::cout << std::endl;
216  }
217  */
218  }
219  }
220  fMCTracks->Delete();
221  fMCHits->Delete();
222  Finish();
223 
224 
225 }
Int_t Motherpdg
std::map< int, std::vector< int > > AssignHitsToTracks()
PndTransMap * map
Definition: sim_emc_apd.C:99
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
TClonesArray * fMCTracks
std::map< int, std::vector< int > > mcHitMap
virtual void Finish()
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
TClonesArray * fMCHits
Int_t MotherId
void PndHypMSAnaTask::Finish ( )
virtual

Definition at line 227 of file PndHypMSAnaTask.cxx.

References fMCHits, and fMCTracks.

Referenced by Exec().

228 { fMCTracks->Delete();
229  fMCHits->Delete();
230 }
TClonesArray * fMCTracks
TClonesArray * fMCHits
InitStatus PndHypMSAnaTask::Init ( )
virtual

Definition at line 46 of file PndHypMSAnaTask.cxx.

References fGeoH, fMCHits, fMCTracks, and gGeoManager.

47 {
48  // Get RootManager
49  FairRootManager* ioman = FairRootManager::Instance();
50  if ( !ioman){
51  std::cout << "-E- PndHypMSAnaTask::Init: "<< "RootManager not instantiated!" << std::endl;
52  return kFATAL;
53  }
54 
55  // Get input arrays
56  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
57  if (!fMCTracks){
58  std::cout << "-W- PndHypMSAnaTask::Init: "<< "No MCTrack" << " array!" << std::endl;
59  return kERROR;
60  }
61 
62  fMCHits = (TClonesArray*) ioman->GetObject("HypPoint");
63  if ( !fMCHits) {
64  std::cout << "-W- PndHypMSAnaTask::Init: "<< "No MVDPoint"<<" array!" << std::endl;
65  return kERROR;
66  }
67 
68  /* fTrackParGeane = new TClonesArray("FairTrackParP");
69  ioman->Register("GeaneTrackPar","Geane", fTrackParGeane, kTRUE);
70 
71  fTrackParIni = new TClonesArray("FairTrackParP");
72  ioman->Register("GeaneTrackIni","Geane", fTrackParIni, kTRUE);
73 
74  fTrackParFinal = new TClonesArray("FairTrackParP");
75  ioman->Register("GeaneTrackFinal","Geane", fTrackParFinal, kTRUE);*/
76 
77  // fPro = new FairGeanePro();
79 
80  return kSUCCESS;
81 }
Class to access the naming information of the MVD.
TGeoManager * gGeoManager
TClonesArray * fMCTracks
PndHypGeoHandling * fGeoH
TClonesArray * fMCHits
void PndHypMSAnaTask::ProduceHits ( )
private
void PndHypMSAnaTask::Register ( )
private
void PndHypMSAnaTask::Reset ( )
private
void PndHypMSAnaTask::SetParContainers ( )
virtual

Virtual method Init

Definition at line 83 of file PndHypMSAnaTask.cxx.

84 {
85  // Get Base Container
86  //FairRunAna* ana = FairRunAna::Instance();
87  //FairRuntimeDb* rtdb=ana->GetRuntimeDb();
88 
89 }
void PndHypMSAnaTask::WriteHistograms ( )

Definition at line 254 of file PndHypMSAnaTask.cxx.

References file, and histo.

254  {
255  TFile* file = FairRootManager::Instance()->GetOutFile();
256  file->cd();
257  file->mkdir("Dedx_detid");
258  file->cd("Dedx_detid");
259 
260  histo->Write();
261  delete histo;
262  histo=NULL;
263 }
TFile * file

Member Data Documentation

int PndHypMSAnaTask::fEventNr
private

Definition at line 66 of file PndHypMSAnaTask.h.

Referenced by Exec().

PndHypGeoHandling* PndHypMSAnaTask::fGeoH
private

Definition at line 62 of file PndHypMSAnaTask.h.

Referenced by Init(), and ~PndHypMSAnaTask().

TClonesArray* PndHypMSAnaTask::fMCHits
private

Definition at line 54 of file PndHypMSAnaTask.h.

Referenced by AssignHitsToTracks(), Exec(), Finish(), and Init().

TClonesArray* PndHypMSAnaTask::fMCTracks
private

Definition at line 55 of file PndHypMSAnaTask.h.

Referenced by AssignHitsToTracks(), Exec(), Finish(), and Init().

FairGeanePro* PndHypMSAnaTask::fPro
private

Definition at line 61 of file PndHypMSAnaTask.h.

TClonesArray* PndHypMSAnaTask::fTrackParFinal
private

Definition at line 59 of file PndHypMSAnaTask.h.

TClonesArray* PndHypMSAnaTask::fTrackParGeane
private

Definition at line 57 of file PndHypMSAnaTask.h.

TClonesArray* PndHypMSAnaTask::fTrackParIni
private

Definition at line 58 of file PndHypMSAnaTask.h.

std::map<int, std::vector<int> > PndHypMSAnaTask::fTrackPixHitIdMap
private

Definition at line 68 of file PndHypMSAnaTask.h.

std::map<int, std::vector<int> > PndHypMSAnaTask::fTrackStripHitIdMap
private

Definition at line 69 of file PndHypMSAnaTask.h.

TH1F* PndHypMSAnaTask::histo
private

Definition at line 65 of file PndHypMSAnaTask.h.

Referenced by Exec(), PndHypMSAnaTask(), WriteHistograms(), and ~PndHypMSAnaTask().

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

Definition at line 67 of file PndHypMSAnaTask.h.

Referenced by Exec().


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