6 #include "TStopwatch.h" 
   10 #include "TClonesArray.h" 
   24    gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   25    gSystem->Load(
"libHypGe");
 
   34         TString Filename = 
"$SIMDATADIR/COSY/"+Filename_ext;
 
   38         outfile += Filename_ext;
 
   39         outfile.ReplaceAll(
".root",
"");
 
   41         outfile += StartEvent;
 
   42         outfile += 
"_nEvents_";
 
   43         outfile += NoOfEvents;
 
   45         cout << outfile << endl;
 
   46         TFile* InputFile = 
new TFile(Filename);
 
   47         TFile* OutputFile = 
new TFile(outfile,
"RECREATE");
 
   50   TTree *
b=(TTree *) InputFile->Get(
"pndsim") ;
 
   51   TClonesArray* 
hit_bar=
new TClonesArray(
"PndHypGePoint");
 
   52   b->SetBranchAddress(
"HypGePoint",&hit_bar);
 
   53   TClonesArray* 
mc_bar=
new TClonesArray(
"PndMCTrack");
 
   54   b->SetBranchAddress(
"MCTrack",&mc_bar);
 
   58         TH1D* hNHits = 
new TH1D(
"hNHits",
"Polar angle of primary neutrons interacting with the crystals",180, 90,180);
 
   59         hNHits->SetXTitle(
"#Theta [#circ]");
 
   60         hNHits->SetYTitle(
"Counts / 0.5 #circ");
 
   62         TH1D* hNHits_p = 
new TH1D(
"hNHits_p",
"Direction of polar momentum of primary neutrons interacting with the crystals",180, 90,180);
 
   63         hNHits_p->SetXTitle(
"#Theta [#circ]");
 
   64         hNHits_p->SetYTitle(
"Counts / 0.5 #circ");
 
   66         TH1D* hNAll = 
new TH1D(
"hNAll",
"All Neutrons",360, 0,180);
 
   67         hNAll->SetXTitle(
"#Theta [#circ]");
 
   68         hNAll->SetYTitle(
"Counts / 0.5 #circ");
 
   71         TH1D* hPAll = 
new TH1D(
"hPAll",
"All Protons",360, 0,180);
 
   72         hPAll->SetXTitle(
"#Theta [#circ]");
 
   73         hPAll->SetYTitle(
"Counts / 0.5 #circ");
 
   76         TH1D* hNMom = 
new TH1D(
"hNMom",
"E_{kin} of neutrons",1000, 0,0.5);
 
   77         hNMom->SetXTitle(
"E_{kin} of neutrons [GeV]");
 
   78         hNMom->SetYTitle(
"Counts / 0.5 MeV");
 
   80         TH1D* hCrystalHit = 
new TH1D(
"hCrystalHit",
"Hits per Crystal",1700,1,1700);
 
   81         hCrystalHit->SetXTitle(
"Crystal number");
 
   82         hCrystalHit->SetYTitle(
"Counts per crystal");
 
   84         TH1D* hNeutronEnergyDeposit = 
new TH1D(
"hNeutronEnergyDeposit",
"Energy deposited by Neutrons per Hit",500,0,0.005);
 
   85         hNeutronEnergyDeposit->SetXTitle(
"Energy [GeV]");
 
   86         hNeutronEnergyDeposit->SetYTitle(
"Counts / 10 keV");
 
   89         TH2D* hNeutronXYDistribution = 
new TH2D(
"hNeutronXYDistribution",
"Distribution of Neutrons",40, -40,40,40,-40,40);
 
   90         hNeutronXYDistribution->SetXTitle(
"X-postion [cm]");
 
   91         hNeutronXYDistribution->SetYTitle(
"Y-postion [cm]");
 
   92         gStyle->SetPalette(1);
 
   96         Int_t *ActualTrackID ;
 
  110         TVector3 StartVertex;
 
  115                 EndEvent = b->GetEntriesFast();
 
  117                 EndEvent = StartEvent + NoOfEvents;
 
  120         for (Int_t k=StartEvent; k< EndEvent; k++)
 
  124                 if (!((k*100)% NoOfEvents))     
 
  126                         cout << 
"Event number :\t" << k << endl;
 
  134                 for (Int_t 
i=0; 
i<hit_bar->GetEntriesFast(); 
i++)
 
  147                                 cout <<
"Event " <<k<< 
" \t\tStartVertex Radius: " <<StartVertex.Mag()<< endl;
 
  149                                 if (StartVertex.Mag() <20)      
 
  162                                                 NHit.SetX(hitgam->
GetX());
 
  163                                                 NHit.SetY(hitgam->
GetY());
 
  164                                                 NHit.SetZ(hitgam->
GetZ());                                      
 
  165                                                 hNHits->Fill(180/
TMath::Pi()*NHit.Theta());                             
 
  166                                                 cout << 
"Event " << k <<
"Crystal" << hitgam->
GetDetectorID()<<
" Theta " <<180/
TMath::Pi()*NHit.Theta()<<endl;
 
  170                                                 NHit_p.SetX(hitgam->
GetPx());
 
  171                                                 NHit_p.SetY(hitgam->
GetPy());
 
  172                                                 NHit_p.SetZ(hitgam->
GetPz());
 
  173                                                 hNHits_p->Fill(180/
TMath::Pi()*NHit_p.Theta());         
 
  175                                                 hNeutronXYDistribution->Fill(hitgam->
GetX(),hitgam->
GetY());
 
  188                 for (Int_t 
m = 0; 
m<mc_bar->GetEntriesFast();
m++)
 
  194                         if (StartVertex.Mag())
 
  201                                         hNAll->Fill(180/
TMath::Pi()*NAllMom.Theta());           
 
  207                                         hPAll->Fill(180/
TMath::Pi()*NAllMom.Theta());           
 
  216         hNeutronXYDistribution->DrawCopy(
"colz");
 
  227         hCrystalHit->Write();
 
  228         hNeutronEnergyDeposit->Write();
 
  229         hNeutronXYDistribution->Write();
 
  245         cout << endl << endl;
 
  246         cout << 
"Macro finished succesfully." << endl;
 
  248         cout << 
"Real time " << rtime << 
" s, CPU time " << ctime << 
" s" << endl;
 
  251         cout << 
"Hits\t" << Hits << endl;
 
TVector3 GetMomentum() const 
int NeutronAnalysis_COSY(TString Filename_ext, Int_t StartEvent=0, Int_t NoOfEvents=0)
TVector3 GetStartVertex() const 
Int_t GetMotherID() const 
Int_t GetDetectorID() const 
Double_t GetEnergyLoss() const 
Double_t GetpdgCode() const