FairRoot/PandaRoot
AllNeutronAnalysis.C
Go to the documentation of this file.
1 
2 
3 
4 
6 {
7 Int_t *ActualTrackID ;
8  // ----- Load libraries ------------------------------------------------
9 //``gSystem->Load("fstream.h");
10  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
11 
12 
13  gSystem->Load("libHypGe");
14 
15  // ----- Timer --------------------------------------------------------
16  TStopwatch timer;
17  timer.Start();
18  // ------------------------------------------------------------------------
19 
20  TString Filename = "$SIMDATADIR/TripleBall40Offset10_urqmd_pbarC_1_5000Evts.root";
21 
22 
23 //Output Files
24  //TString Path = getenv("SIMDATADIR");
25  TString outfile= "$SIMDATADIR/Data_Marcell/TripleBall40Offset10_urqmd_pbarC_1_5000Evts_spectrum2.root";//"$SIMDATADIR/Data_Marcell/TripleBall40Offset10_urqmd_pbarC_1_5000Evts_spectrum.root";
26  TFile* g = new TFile(Filename);
27  TFile* fi = new TFile(outfile,"RECREATE");
28 
29 
30 
31  //photons from hyp electromag. decay
32  TTree *b=(TTree *) g->Get("pndsim") ;
33  TClonesArray* hit_bar=new TClonesArray("PndHypGePoint");
34  b->SetBranchAddress("HypGePoint",&hit_bar);//Branch names
35  TClonesArray* mc_bar=new TClonesArray("PndMCTrack");
36  b->SetBranchAddress("MCTrack",&mc_bar);//Branch names
37 
38 
39 
40 
41  //****photons from hyp elect. decay
42 
43  string Name = "Neutrons hitting the germaniums";
44  TH1D* hNHits = new TH1D("hNHits",Name.c_str(),180, 90,180);
45  TH1D* hNHits_p = new TH1D("hNHits_p",Name.c_str(),180, 90,180);
46  TH1D* hNAll = new TH1D("hNAll","All Neutrons",180, 90,180);
47  TH1D* hNMom = new TH1D("hNMom","Momentum of Neutrons",1000, 0,0.5);
48  TH1D* hCrystalHit = new TH1D("hCrystalHit","Crystals hit by neutrons",1700,1,1700);
49 
50  bool verbose = false;
51  Int_t MotherId,Motherpdg;
52 
53 
54 
55  TVector3 vecs,pos;
56  int mcpdg = -1,ev;
58 
59  //vector<int> event;
60  int count;
61  Int_t nEvents = b->GetEntriesFast();
62  cout<< "Number of Simulated Events: "<<nEvents<<endl;
63 
64 
65  Double_t Resolution = 2.; //keV
66  for (Int_t k=0; k<nEvents; k++)
67  {
68  //cout << k << endl;
69  Eng=0.;
70  b->GetEntry(k);
71  if (!((k*100)% nEvents))
72  {
73  cout << k << endl;
74  }
75  //if(verbose) cout<<"Event No "<<j<<endl;
76  for (Int_t i=0; i<hit_bar->GetEntriesFast(); i++)
77  {
78  //cout <<"Hit "<< i << endl;
79  if (i == 0)
80  {
81  //cout << hit_bar->GetEntriesFast()<<endl;
82  PndHypGePoint *hitgam=(PndHypGePoint*)hit_bar->At(i);
83 
84  ActualTrackID=-1;
85  PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam->GetTrackID());
86 
87 
88  //rande= gRandom->Gaus(hitgam->GetEnergyLoss(),0.000003);
89  if (hitgam->GetpdgCode()==2112 && mcgam->GetMotherID()==-1)
90  {
91  ActualTrackID= hitgam->GetTrackID();
92  TVector3 NHit;
93  NHit.SetX(hitgam->GetX());
94  NHit.SetY(hitgam->GetY());
95  NHit.SetZ(hitgam->GetZ()+55);
96  hNHits->Fill(180/TMath::Pi()*NHit.Theta());
97 
98  TVector3 NHit_p;
99  NHit_p.SetX(hitgam->GetPx());
100  NHit_p.SetY(hitgam->GetPy());
101  NHit_p.SetZ(hitgam->GetPz());
102  hNHits_p->Fill(180/TMath::Pi()*NHit_p.Theta());
103  hCrystalHit->Fill(hitgam->GetDetectorID());
104  //hNHits->Fill(180/TMath::Pi()*TMath::ACos(hitgam->GetZ()/TMath::Sqrt(hitgam->GetX()*hitgam->GetX()+hitgam->GetY()*hitgam->GetY()+hitgam->GetZ()* hitgam->GetZ()))); //Fill spectrum
105  }
106  if (mcgam->GetPdgCode()==2112 && mcgam->GetMotherID()==-1)
107  {
108  TVector3 NAllMom = mcgam->GetMomentum();
109  hNAll->Fill(180/TMath::Pi()*NAllMom.Theta());
110  hNMom->Fill(1./2.*NAllMom.Mag2()/0.939);
111 
112  cout << 1./2.*NAllMom.Mag2()/0.939<<endl;
113  }
114 
115  }
116  else
117  {
118  PndHypGePoint *hitgam=(PndHypGePoint*)hit_bar->At(i);
119 
120  PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam->GetTrackID());
121 
122 
123  //rande= gRandom->Gaus(hitgam->GetEnergyLoss(),0.000003);
124  if (hitgam->GetpdgCode()==2112 && mcgam->GetMotherID()==-1)
125  {
126  if (ActualTrackID != hitgam->GetTrackID())
127  {
128  TVector3 NHit;
129  NHit.SetX(hitgam->GetX());
130  NHit.SetY(hitgam->GetY());
131  NHit.SetZ(hitgam->GetZ()+55);
132  hNHits->Fill(180/TMath::Pi()*NHit.Theta());
133 
134  TVector3 NHit_p;
135  NHit_p.SetX(hitgam->GetPx());
136  NHit_p.SetY(hitgam->GetPy());
137  NHit_p.SetZ(hitgam->GetPz());
138  hNHits_p->Fill(180/TMath::Pi()*NHit_p.Theta());
139  ActualTrackID = hitgam->GetTrackID();
140  hCrystalHit->Fill(hitgam->GetDetectorID());
141  }
142  }
143  if (mcgam->GetPdgCode()==2112 && mcgam->GetMotherID()==-1)
144  {
145  TVector3 NAllMom = mcgam->GetMomentum();
146  hNAll->Fill(180/TMath::Pi()*NAllMom.Theta());
147  hNMom->Fill(1./2.*NAllMom.Mag2()/0.939);
148  cout << 1./2.*NAllMom.Mag2()/0.939<<endl;
149  }
150 
151  }
152  }
153 
154 
155  }// end for j (events)
156 
157 
158 
159  hNHits->Draw();
160 
161  //Analysis of spectrum
162  hNHits->Write();
163  hNHits_p->Write();
164  hNAll->Write();
165  hNMom->Write();
166  hCrystalHit->Write();
167 
168  fi->Close();
169 
170 
171 
172 
173  // ----- Finish -------------------------------------------------------
174  timer.Stop();
175  Double_t rtime = timer.RealTime();
176  Double_t ctime = timer.CpuTime();
177  cout << endl << endl;
178  cout << "Macro finished succesfully." << endl;
179 
180  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
181  cout << endl;
182  // ------------------------------------------------------------------------
183 
184  return 0;
185 }
TVector3 pos
Int_t Motherpdg
Int_t i
Definition: run_full.C:25
TTree * b
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
#define verbose
int AllNeutronAnalysis()
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
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
Double_t GetZ() const
Definition: PndHypGePoint.h:56
Double_t GetX() const
Definition: PndHypGePoint.h:54
Double_t GetY() const
Definition: PndHypGePoint.h:55
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 GetDetectorID() const
Definition: PndHypGePoint.h:53
Int_t MotherId
Double_t mult
TString outfile
Double_t GetpdgCode() const
Definition: PndHypGePoint.h:63