AliRoot Core  edcc906 (edcc906)
TestKinematics.C
Go to the documentation of this file.
1 
12 #if !defined(__CINT__) || defined(__MAKECINT__)
13 
14 // Root include files
15 #include <Riostream.h>
16 #include <TFile.h>
17 //#include <TSystem.h>
18 #include <TParticle.h>
19 
20 // AliRoot include files
21 #include "AliRunLoader.h"
22 #include "AliStack.h"
23 
24 #endif
25 
30 {
31  // Open galice.root
33 
34  if (rl == 0x0)
35  cout<<"Can not instantiate the Run Loader"<<endl;
36 
37  // Load Kinematics
38  rl->LoadKinematics();
39 
40  // Get maximum number of events
41  Int_t maxevent = rl->GetNumberOfEvents();
42  cout<<"Number of events "<<maxevent<<endl;
43 
44  // Event loop
45  for ( Int_t iEvent=0; iEvent<maxevent; iEvent++)
46  {
47  // Load Event
48  rl->GetEvent(iEvent);
49  cout << " ======> Event " << iEvent << " "<<rl->GetEventNumber() <<endl ;
50 
51  // Call kinematic stack
52  AliStack *sta=rl->Stack();
53 
54  cout << "# tracks in runloader " << sta->GetNtrack() // Number of all generated particles by the event generator + particles (secondaries) generated by GEANT
55  << " # primaries in runloader " << sta->GetNprimary() // Number of all generated particles by the event generator
56  << endl;
57 
58  // Loop only on particles generated (no secondaries)
59  for (Int_t iprim=0; iprim<sta->GetNprimary() ; iprim++)
60  {
61  TParticle * primary=sta->Particle(iprim);
62 
63  Float_t phi = primary->Phi()*TMath::RadToDeg();
64 
65  if ( TMath::Abs(primary->Eta()) < 0.7 &&
66  ( (phi >= 80 && phi <= 187) || (phi >= 260 && phi <= 327) ) &&
67  ( primary->GetStatusCode() == 1 || primary->GetStatusCode() == 21 ) && // physical primary or prompt/fragment photon
68  primary->GetPdgCode() == 22 && primary->Pt() > 3 )
69  {
70  cout
71  <<"primary "<<iprim
72  <<"; pdg "<<primary->GetPdgCode()
73  <<"; status"<<primary->GetStatusCode()
74  <<"; Energy "<<primary->Energy()
75  <<"; pT "<<primary->Pt()
76  <<"; phi "<<phi
77  <<"; Eta "<<primary->Eta()
78  <<
79  endl;
80  }
81  }
82  }
83 }
Int_t GetEventNumber() const
Definition: AliRunLoader.h:59
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
void TestKinematics()
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
Int_t GetNprimary() const
Definition: AliStack.h:137
virtual Int_t GetNtrack() const
Definition: AliStack.h:134
Int_t GetNumberOfEvents()
Int_t GetEvent(Int_t evno)
TParticle * Particle(Int_t id, Bool_t useInEmbedding=kFALSE)
Definition: AliStack.cxx:688
Int_t LoadKinematics(Option_t *option="READ")
AliStack * Stack() const
Definition: AliRunLoader.h:95