FairRoot/PandaRoot
AllNeutronAnalysis_save.C
Go to the documentation of this file.
2 {
3 
4  // ----- Load libraries ------------------------------------------------
5 //``gSystem->Load("fstream.h");
6  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
7 
8 
9  gSystem->Load("libHypGe");
10 
11  // ----- Timer --------------------------------------------------------
12  TStopwatch timer;
13  timer.Start();
14  // ------------------------------------------------------------------------
15 
16  TString Filename = "$SIMDATADIR/TripleBall40Offset10_urqmd_pbarC_1_5000Evts.root";
17 
18 
19 //Output Files
20  //TString Path = getenv("SIMDATADIR");
21  TString outfile= "$SIMDATADIR/Data_Marcell/TripleBall40Offset10_urqmd_pbarC_1_5000Evts_spectrum.root";//"$SIMDATADIR/Data_Marcell/TripleBall40Offset10_urqmd_pbarC_1_5000Evts_spectrum.root";
22  TFile* g = new TFile(Filename);
23  TFile* fi = new TFile(outfile,"RECREATE");
24 
25 
26 
27  //photons from hyp electromag. decay
28  TTree *b=(TTree *) g->Get("pndsim") ;
29  TClonesArray* hit_bar=new TClonesArray("PndHypGePoint");
30  b->SetBranchAddress("HypGePoint",&hit_bar);//Branch names
31  TClonesArray* mc_bar=new TClonesArray("PndMCTrack");
32  b->SetBranchAddress("MCTrack",&mc_bar);//Branch names
33 
34 
35 
36 
37  //****photons from hyp elect. decay
38 
39  string Name = "Neutrons hitting the germaniums";
40  TH1D* hNHits = new TH1D("hNHits",Name.c_str(),180, 90,180);
41  TH1D* hNAll = new TH1D("hNAll","All Neutrons",180, 90,180);
42 
43 
44  bool verbose = false;
45  Int_t MotherId,Motherpdg;
46 
47 
48 
49  TVector3 vecs,pos;
50  int mcpdg = -1,ev;
52 
53  //vector<int> event;
54  int count;
55  Int_t nEvents = b->GetEntriesFast();
56  cout<< "Number of Simulated Events: "<<nEvents<<endl;
57 
58 
59  Double_t Resolution = 2.; //keV
60  for (Int_t k=0; k<nEvents; k++)
61  {
62  //cout << k << endl;
63  Eng=0.;
64  b->GetEntry(k);
65  if (!((k*100)% nEvents))
66  {
67  cout << k << endl;
68  }
69  //if(verbose) cout<<"Event No "<<j<<endl;
70 
71 
72  //cout << hit_bar->GetEntriesFast()<<endl;
73  PndHypGePoint *hitgam0=(PndHypGePoint*)hit_bar->At(0);
74  PndHypGePoint *hitgam1=(PndHypGePoint*)hit_bar->At(1);
75  cout << hitgam0 << endl;
76  if (hitgam0 != 0 && hitgam1 !=0)
77  {
78  if(hitgam0->GetTrackID() != hitgam1->GetTrackID())
79  {
80  continue;
81  }
82  PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam0->GetTrackID());
83  if (mcgam->GetPdgCode()!=2112)
84  {
85  continue;
86  }
87 
88  hNHits->Fill(180/TMath::Pi()*TMath::ACos(hitgam0->GetPz()/TMath::Sqrt(hitgam0->GetPx()*hitgam0->GetPx()+hitgam0->GetPy()*hitgam0->GetPy()+hitgam0->GetPz()* hitgam0->GetPz()))); //Fill spectrum
89  if(mcgam->GetMotherID() ==-1)
90  {
91  TVector3 NAllMom = mcgam->GetMomentum();
92  hNAll->Fill(180/TMath::Pi()*NAllMom.Theta());
93  }
94  }
95 
96  if (hitgam0 != 0 )
97  {
98  if(hitgam0->GetTrackID() != hitgam1->GetTrackID())
99  {
100  continue;
101  }
102  PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam0->GetTrackID());
103  if (mcgam->GetPdgCode()!=2112)
104  {
105  continue;
106  }
107 
108  hNHits->Fill(180/TMath::Pi()*TMath::ACos(hitgam0->GetPz()/TMath::Sqrt(hitgam0->GetPx()*hitgam0->GetPx()+hitgam0->GetPy()*hitgam0->GetPy()+hitgam0->GetPz()* hitgam0->GetPz()))); //Fill spectrum
109  if(mcgam->GetMotherID() ==-1)
110  {
111  TVector3 NAllMom = mcgam->GetMomentum();
112  hNAll->Fill(180/TMath::Pi()*NAllMom.Theta());
113  }
114  }
115 
116  }// end for j (events)
117 
118 
119 
120  hNHits->Draw();
121 
122  //Analysis of spectrum
123  hNHits->Write();
124  hNAll->Write();
125  fi->Close();
126 
127 
128 
129 
130  // ----- Finish -------------------------------------------------------
131  timer.Stop();
132  Double_t rtime = timer.RealTime();
133  Double_t ctime = timer.CpuTime();
134  cout << endl << endl;
135  cout << "Macro finished succesfully." << endl;
136 
137  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
138  cout << endl;
139  // ------------------------------------------------------------------------
140 
141  return 0;
142 }
TVector3 pos
Int_t Motherpdg
TTree * b
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
#define verbose
int ev
Double_t GetPz() const
Definition: PndHypGePoint.h:59
TFile * g
Int_t GetTrackID() const
Definition: PndHypGePoint.h:51
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
Double_t Enth
int AllNeutronAnalysis()
TClonesArray * hit_bar
TVector3 vecs
Double_t En
TFile * fi
Double_t
Double_t GetPy() const
Definition: PndHypGePoint.h:58
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
Double_t GetPx() const
Definition: PndHypGePoint.h:57
Double_t Eng
int mcpdg
Double_t ctime
Definition: hit_dirc.C:114
TClonesArray * mc_bar
int count
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
Double_t rtime
Definition: hit_dirc.C:113
Double_t Pi
Int_t MotherId
Double_t mult
TString outfile