FairRoot/PandaRoot
NeutronCombinedAnalysis.C
Go to the documentation of this file.
1 int NeutronCombinedAnalysis(TString Filename = "Combined_AnaGeo36urqmd_500000Evts.root")
2 {
3  gROOT->LoadMacro("$VMCWORKDIR/macro/hypGe/Marcell/SharedMacros/SharedMacroFunctions.C");
4  TString Path = getenv("SIMDATADIR");
5  TString FullPath= Path+"/Neutron/Ana/CombinedData/";
6  TString FilenameWithPath= FullPath+Filename;
7 
8  int GeoNumber =-1;
9  int TotalEvents=-1;
10 
11  sscanf(Filename.Data(),"Combined_AnaGeo%d%*5s_%dEvts.root",&GeoNumber,&TotalEvents);
12 
13  TFile *file = new TFile(FilenameWithPath);
14  TH1D* hCrystalHit;
15  file ->GetObject("hCrystalHit",hCrystalHit);
16 
17  cout << hCrystalHit->GetEntries() << endl;
18 
19  TString TxTOutFilename =FilenameWithPath + ".txt";
20  ofstream TxTOutfile(TxTOutFilename.Data());
21  Int_t CrystalNumber = 1;
22  cout << "Bin\tCrystal\tCluster\tNeutron hits"<<endl;
23  TxTOutfile << "Bin\tCrystal\tCluster\tNeutron hits"<<endl;
24  int MaxCrystalHits = -1;
25  for (Int_t iBin=0;iBin<2100;iBin++)
26  {
27 
28  if(hCrystalHit->GetBinContent(iBin))
29  {
30  cout << iBin << "\t"<< CrystalNumber <<"\t"<< iBin/100 <<"\t"<< hCrystalHit->GetBinContent(iBin)<< endl;
31 
32  TxTOutfile << iBin << "\t"<< CrystalNumber <<"\t"<< iBin/100 <<"\t"<< hCrystalHit->GetBinContent(iBin)<< endl;
33  CrystalNumber++;
34  if (MaxCrystalHits <hCrystalHit->GetBinContent(iBin))
35  MaxCrystalHits =hCrystalHit->GetBinContent(iBin);
36  }
37  }
38 
39  Double_t AverageCrystalHits = hCrystalHit->GetEntries()/CrystalNumber;
40  cout << "Average Hits:\n";
41  TxTOutfile << "Average Hits:\n";
42  cout << AverageCrystalHits<<endl;
43  TxTOutfile << AverageCrystalHits<<endl;
44  cout << "Max Hits:\n";
45  TxTOutfile << "Max Hits:\n";
46  cout << MaxCrystalHits<<endl;
47  TxTOutfile << MaxCrystalHits<<endl;
48  cout << "Total Events:\n";
49  TxTOutfile << "Total Events:\n";
50  cout << TotalEvents<<endl;
51  TxTOutfile << TotalEvents<<endl;
52 
53  TxTOutfile.close();
54  return 0;
55 }
int NeutronCombinedAnalysis(TString Filename="Combined_AnaGeo36urqmd_500000Evts.root")
TFile * file
Double_t