FairRoot/PandaRoot
Functions
NeutronAnalysis.C File Reference

Go to the source code of this file.

Functions

int NeutronAnalysis ()
 

Function Documentation

int NeutronAnalysis ( )

Definition at line 1 of file NeutronAnalysis.C.

References b, c2, count, ctime, Double_t, En, Eng, Enth, ev, fi, g, gamTde, PndHypGePoint::GetDetectorID(), PndHypGePoint::GetpdgCode(), PndHypGePoint::GetPx(), PndHypGePoint::GetPy(), PndHypGePoint::GetPz(), hit_bar, i, mc_bar, mcpdg, MotherId, Motherpdg, mult, nEvents, outfile, Pi, pos, rtime, CAMath::Sqrt(), timer, TString, vecs, and verbose.

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* gamTde = new TH1D("gamTde",Name.c_str(),150, 150,180);
41  TH1D* hCrystalHit = new TH1D("hCrystalHit","Crystals hit by neutrons",1700,1,1700);
42 
43 
44  bool verbose = false;
45  Int_t MotherId,Motherpdg;
46 
47  TH1D *hNoHits = new TH1D("Number of Hits", "Number of Hits", 16,0,15);
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  for (Int_t i=0; i<hit_bar->GetEntriesFast(); i++)
71  {
72  //cout << hit_bar->GetEntriesFast()<<endl;
73  PndHypGePoint *hitgam=(PndHypGePoint*)hit_bar->At(i);
74 
75  //PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam->GetTrackID());
76 
77 
78  //rande= gRandom->Gaus(hitgam->GetEnergyLoss(),0.000003);
79  if (hitgam->GetpdgCode()==2112)
80  {
81  gamTde->Fill(180/TMath::Pi()*TMath::ACos(hitgam->GetPz()/TMath::Sqrt(hitgam->GetPx()*hitgam->GetPx()+hitgam->GetPy()*hitgam->GetPy()+hitgam->GetPz()* hitgam->GetPz()))); //Fill spectrum
82  hCrystalHit->Fill(hitgam->GetDetectorID());
83  }
84  }
85 
86 
87  }// end for j (events)
88 
89  gamTde->Write();
90  hCrystalHit->Write();
91 
92  gamTde->Draw();
93  TCanvas* c2 = new TCanvas("c2","c2",800,600);
94  c2->cd();
95  hCrystalHit->Draw();
96  //Analysis of spectrum
97 
98  fi->Close();
99 
100 
101 
102 
103  // ----- Finish -------------------------------------------------------
104  timer.Stop();
105  Double_t rtime = timer.RealTime();
106  Double_t ctime = timer.CpuTime();
107  cout << endl << endl;
108  cout << "Macro finished succesfully." << endl;
109 
110  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
111  cout << endl;
112  // ------------------------------------------------------------------------
113 
114  return 0;
115 }
TVector3 pos
Int_t Motherpdg
Int_t i
Definition: run_full.C:25
TTree * b
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
#define verbose
int ev
Double_t GetPz() const
Definition: PndHypGePoint.h:59
TFile * g
Double_t Enth
c2
Definition: plot_dirc.C:39
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
TH1D * gamTde
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
Double_t rtime
Definition: hit_dirc.C:113
Double_t Pi
Int_t GetDetectorID() const
Definition: PndHypGePoint.h:53
Int_t MotherId
Double_t mult
TString outfile
Double_t GetpdgCode() const
Definition: PndHypGePoint.h:63