FairRoot/PandaRoot
GammaSpectraAnalysis.C
Go to the documentation of this file.
1 // root macro to analyze the simulation output
2 //void convertMCPoints()
3 {
4 
5  // ----- Load libraries ------------------------------------------------
6 //``gSystem->Load("fstream.h");
7  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
8 
9 
10  gSystem->Load("libHypGe");
11 
12  // ----- Timer --------------------------------------------------------
13  TStopwatch timer;
14  timer.Start();
15  // ------------------------------------------------------------------------
16 #include <vector>
17 
18 
19 
20  //photons from hyp electromag. decay
21 
22  TFile* g = new TFile("sim_hypGe_BgUrqmd2.root");
23  // the sim file you want to analyse
24  TTree *b=(TTree *) g->Get("pndsim") ;
25  TClonesArray* hit_bar=new TClonesArray("PndHypGePoint");
26  b->SetBranchAddress("HypGePoint",&hit_bar);//Branch names
27  TClonesArray* mc_bar=new TClonesArray("PndMCTrack");
28  b->SetBranchAddress("MCTrack",&mc_bar);//Branch names
29 
30 
31  //**** Energy deposited from particle backgroun
32 
33 
34  //****photons from hyp elect. decay
35  TH1D* gamTde = new TH1D("gamTde","total gam energy deposit ",500,0.006,0.0012);
36 
37 
38  bool verbose = false;
40 
41 
42 
43  TVector3 vecs,pos;
44  int mcpdg = -1,ev;
46 
47  //vector<int> event;
48  int count;
49  cout<<b->GetEntriesFast()<<endl;
50 
51 
52  for (Int_t k=0; k<b->GetEntriesFast(); k++)
53  {
54  Eng=0.;
55  b->GetEntry(k);
56  //if(verbose) cout<<"Event No "<<j<<endl;
57  for (Int_t i=0; i<hit_bar->GetEntriesFast(); i++)
58  {
59  PndHypGePoint *hitgam=(PndHypGePoint*)hit_bar->At(i);
60 
61  PndMCTrack *mcgam = (PndMCTrack*)mc_bar->At(hitgam->GetTrackID());
62 
63  Double_t rande;
64  //rande= gRandom->Gaus(hitgam->GetEnergyLoss(),0.000003);
65  //if (sci->Getpdgcode())
66 
67 
68 
69  //if (sci)cout<<sci->GetEnergyLoss()<<endl;
70  //En +=gRandom->Gaus(0,0.000003);
71  //randy= gRandom->Gaus(0,1);
72 
73 
74 
75 
76  Eng =Eng + (hitgam->GetEnergyLoss());
77  //Eng =Eng + (rande);
78 
79  }//end for i (points in event)
80  //count =0;
81  if(Eng>0)gamTde->Fill(Eng);
82 
83 
84 
85  }// end for j (events)
86 
87 
88 
89  TCanvas* can3 = new TCanvas("can3","germanium detector",0,0,1000,1000);
90 
91  gamTde->Draw();
92 
93 
94 
95 
96 
97  // ----- Finish -------------------------------------------------------
98  timer.Stop();
99  Double_t rtime = timer.RealTime();
100  Double_t ctime = timer.CpuTime();
101  cout << endl << endl;
102  cout << "Macro finished succesfully." << endl;
103  //cout << "Output file is " << outFile << endl;
104  //cout << "Parameter file is " << parFile << endl;
105  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
106  cout << endl;
107  // ------------------------------------------------------------------------
108 
109 }
TVector3 pos
Int_t Motherpdg
bool verbose
Int_t i
Definition: run_full.C:25
TTree * b
int ev
TFile * g
Int_t GetTrackID() const
Definition: PndHypGePoint.h:51
Double_t Enth
TStopwatch timer
Double_t rtime
TClonesArray * hit_bar
TVector3 vecs
Double_t En
Double_t
TH1D * gamTde
Double_t ctime
Double_t Eng
int mcpdg
TClonesArray * mc_bar
int count
TCanvas * can3
Int_t MotherId
Double_t mult
Double_t GetEnergyLoss() const
Definition: PndHypGePoint.h:62