Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
exGPSHistoManager Class Reference

#include <exGPSHistoManager.hh>

Public Member Functions

 exGPSHistoManager ()
 
 ~exGPSHistoManager ()
 
void book ()
 
void save ()
 
void Fill (G4int PDGid, G4double e, G4double x, G4double y, G4double z, G4double t, G4double p, G4double w)
 
void PrintStatistic ()
 
void SetEMin (G4double emin)
 
void SetEMax (G4double emax)
 
void SetPosMin (G4double posmin)
 
void SetPosMax (G4double posmax)
 
void SetFileName (G4String name)
 

Detailed Description

Definition at line 50 of file exGPSHistoManager.hh.

Constructor & Destructor Documentation

exGPSHistoManager::exGPSHistoManager ( )

Definition at line 42 of file exGPSHistoManager.cc.

42  :
43 fMinpos(-10.),fMaxpos(10),fMineng(0.),fMaxeng(1000.),
44 fEnerHisto(0),fPosiXY(0),fPosiZX(0),fPosiYZ(0),fAnglCTP(0),fAnglTP(0)
45 {
46  fFileName[0] = "expGPS";
47  fFactoryOn = false;
48  fMessenger = new exGPSHistoMessenger(this);
49 }
exGPSHistoManager::~exGPSHistoManager ( )

Definition at line 53 of file exGPSHistoManager.cc.

54 { }

Member Function Documentation

void exGPSHistoManager::book ( )

Definition at line 58 of file exGPSHistoManager.cc.

References G4VAnalysisManager::CreateH1(), G4VAnalysisManager::CreateH2(), G4VAnalysisManager::CreateNtuple(), G4VAnalysisManager::CreateNtupleDColumn(), G4VAnalysisManager::CreateNtupleIColumn(), G4VAnalysisManager::FinishNtuple(), G4cout, G4endl, G4VAnalysisManager::GetFileType(), G4RootAnalysisManager::GetH1(), G4RootAnalysisManager::GetH2(), G4VAnalysisManager::OpenFile(), G4VAnalysisManager::SetFirstHistoId(), G4VAnalysisManager::SetFirstNtupleId(), G4VAnalysisManager::SetHistoDirectoryName(), G4VAnalysisManager::SetNtupleDirectoryName(), and G4VAnalysisManager::SetVerboseLevel().

Referenced by exGPSRunAction::BeginOfRunAction().

59 {
60  // Create or get analysis manager
61  // The choice of analysis technology is done via selection of a namespace
62  // in exGPSHistoManager.hh
63  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
64  analysisManager->SetVerboseLevel(2);
65  G4String extension = analysisManager->GetFileType();
66  fFileName[1] = fFileName[0] + "." + extension;
67 
68  // Create directories
69  analysisManager->SetHistoDirectoryName("histo");
70  analysisManager->SetNtupleDirectoryName("ntuple");
71 
72  // Open an output file
73  //
74  G4bool fileOpen = analysisManager->OpenFile(fFileName[0]);
75  if (!fileOpen) {
76  G4cout << "\n---> exGPSHistoManager::book(): cannot open " << fFileName[1]
77  << G4endl;
78  return;
79  }
80 
81  // create selected histograms
82  //
83  analysisManager->SetFirstHistoId(1);
84  analysisManager->SetFirstNtupleId(1);
85 
86  G4int id = analysisManager->CreateH1("1","Ekin primary",100,fMineng,fMaxeng);
87  fEnerHisto= analysisManager->GetH1(id);
88 
89  id = analysisManager->CreateH2("2","Position XY",100,fMinpos,fMaxpos,
90  100,fMinpos,fMaxpos);
91  fPosiXY= analysisManager->GetH2(id);
92 
93  id = analysisManager->CreateH2("3","Position YZ",100,fMinpos,fMaxpos,
94  100,fMinpos,fMaxpos);
95  fPosiYZ= analysisManager->GetH2(id);
96 
97  id = analysisManager->CreateH2("4","Position ZX",100,fMinpos,fMaxpos,
98  100,fMinpos,fMaxpos);
99  fPosiZX= analysisManager->GetH2(id);
100 
101  id =analysisManager->CreateH2("5","Source phi-std::cos(theta) distribution",
102  360,0,360,100, -1, 1);
103  fAnglCTP =analysisManager->GetH2(id);
104 
105  id =analysisManager->CreateH2("6","Source phi-theta distribution",
106  360,0,360,180,0,180);
107  fAnglTP = analysisManager->GetH2(id);
108 
109  // Create 1st ntuple (id = 1)
110  //
111  analysisManager->CreateNtuple("MyTuple", "Primary Particle Tuple");
112  id = analysisManager->CreateNtupleIColumn("particleID");
113  id = analysisManager->CreateNtupleDColumn("Ekin");
114  id = analysisManager->CreateNtupleDColumn("posX");
115  id = analysisManager->CreateNtupleDColumn("posY");
116  id = analysisManager->CreateNtupleDColumn("posZ");
117  id = analysisManager->CreateNtupleDColumn("dirTheta");
118  id = analysisManager->CreateNtupleDColumn("dirPhi");
119  id = analysisManager->CreateNtupleDColumn("weight");
120  analysisManager->FinishNtuple();
121 
122  fFactoryOn = true;
123  G4cout << "\n----> Histogram Tree is opened in " << fFileName[1] << G4endl;
124 }
G4bool SetHistoDirectoryName(const G4String &dirName)
G4int CreateNtupleIColumn(const G4String &name)
G4bool SetFirstHistoId(G4int firstId)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void SetVerboseLevel(G4int verboseLevel)
G4int CreateNtuple(const G4String &name, const G4String &title)
G4bool SetNtupleDirectoryName(const G4String &dirName)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4String GetFileType() const
G4bool SetFirstNtupleId(G4int firstId)
#define G4endl
Definition: G4ios.hh:61
G4int CreateNtupleDColumn(const G4String &name)
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
tools::histo::h2d * GetH2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")
void exGPSHistoManager::Fill ( G4int  PDGid,
G4double  e,
G4double  x,
G4double  y,
G4double  z,
G4double  t,
G4double  p,
G4double  w 
)

Definition at line 141 of file exGPSHistoManager.cc.

References G4VAnalysisManager::AddNtupleRow(), python.hepunit::cm, python.hepunit::deg, G4VAnalysisManager::FillNtupleDColumn(), G4VAnalysisManager::FillNtupleIColumn(), and python.hepunit::MeV.

Referenced by exGPSEventAction::EndOfEventAction().

144 {
145  fEnerHisto->fill(e, w);
146  fEnerHisto->fill(e/MeV,w);
147  fPosiXY->fill(x/cm,y/cm,w);
148  fPosiZX->fill(z/cm,x/cm,w);
149  fPosiYZ->fill(y/cm,z/cm,w);
150  fAnglCTP->fill(p/deg,std::cos(t),w);
151  fAnglTP->fill(p/deg,t/deg,w);
152 
153  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
154  analysisManager->FillNtupleIColumn(1,0,PDGid);
155  analysisManager->FillNtupleDColumn(1,1,e);
156  analysisManager->FillNtupleDColumn(1,2,x);
157  analysisManager->FillNtupleDColumn(1,3,y);
158  analysisManager->FillNtupleDColumn(1,4,z);
159  analysisManager->FillNtupleDColumn(1,5,t);
160  analysisManager->FillNtupleDColumn(1,6,p);
161  analysisManager->FillNtupleDColumn(1,7,w);
162  analysisManager->AddNtupleRow(1);
163 }
G4double z
Definition: TRTMaterials.hh:39
const char * p
Definition: xmltok.h:285
G4bool FillNtupleIColumn(G4int id, G4int value)
G4bool FillNtupleDColumn(G4int id, G4double value)
void exGPSHistoManager::PrintStatistic ( )

Definition at line 167 of file exGPSHistoManager.cc.

References G4cout, and G4endl.

168 {
169  if(fFactoryOn) {
170  G4cout << "\n ----> print histograms statistic \n" << G4endl;
171 
172  /*G4cout
173  << " EAbs : mean = " << G4BestUnit(fHistPt[1]->mean(), "Energy")
174  << " rms = " << G4BestUnit(fHistPt[1]->rms(), "Energy")
175  << G4endl;
176  G4cout
177  << " EGap : mean = " << G4BestUnit(fHistPt[2]->mean(), "Energy")
178  << " rms = " << G4BestUnit(fHistPt[2]->rms(), "Energy")
179  << G4endl;
180  G4cout
181  << " LAbs : mean = " << G4BestUnit(fHistPt[3]->mean(), "Length")
182  << " rms = " << G4BestUnit(fHistPt[3]->rms(), "Length")
183  << G4endl;
184  G4cout
185  << " LGap : mean = " << G4BestUnit(fHistPt[4]->mean(), "Length")
186  << " rms = " << G4BestUnit(fHistPt[4]->rms(), "Length")
187  << G4endl;
188  */
189  }
190 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void exGPSHistoManager::save ( )

Definition at line 128 of file exGPSHistoManager.cc.

References G4VAnalysisManager::CloseFile(), G4cout, G4endl, and G4VAnalysisManager::Write().

Referenced by exGPSRunAction::EndOfRunAction().

129 {
130  if (fFactoryOn) {
131  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
132  analysisManager->Write();
133  analysisManager->CloseFile();
134  G4cout << "\n----> Histogram Tree is saved in " << fFileName[1] << G4endl;
135 
136  delete G4AnalysisManager::Instance();
137  fFactoryOn = false;
138  }
139 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void exGPSHistoManager::SetEMax ( G4double  emax)
inline

Definition at line 77 of file exGPSHistoManager.hh.

Referenced by exGPSHistoMessenger::SetNewValue().

77 {fMaxeng = emax;}
void exGPSHistoManager::SetEMin ( G4double  emin)
inline

Definition at line 76 of file exGPSHistoManager.hh.

Referenced by exGPSHistoMessenger::SetNewValue().

76 {fMineng = emin;}
void exGPSHistoManager::SetFileName ( G4String  name)
inline

Definition at line 80 of file exGPSHistoManager.hh.

Referenced by exGPSHistoMessenger::SetNewValue().

80 {fFileName[0] = name;}
const XML_Char * name
void exGPSHistoManager::SetPosMax ( G4double  posmax)
inline

Definition at line 79 of file exGPSHistoManager.hh.

Referenced by exGPSHistoMessenger::SetNewValue().

79 {fMaxpos = posmax;}
void exGPSHistoManager::SetPosMin ( G4double  posmin)
inline

Definition at line 78 of file exGPSHistoManager.hh.

Referenced by exGPSHistoMessenger::SetNewValue().

78 {fMinpos = posmin;}

The documentation for this class was generated from the following files: