30 #include <AIDA/AIDA.h>
37 exGPSAnalysisManager* exGPSAnalysisManager::fInstance = 0;
40 exGPSAnalysisManager::exGPSAnalysisManager():
41 fIleName(
"exgps.aida"),fIleType(
"xml"),fAnalysisFactory(0),
42 fTree(0),fPlotter(0),fMinpos(-10.),fMaxpos(10),fMineng(0.),fMaxeng(1000.),
43 fEnerHisto(0),fPosiXY(0),fPosiXZ(0),fPosiYZ(0),fAnglCTP(0),fAnglTP(0),fTuple(0)
46 fAnalysisMessenger =
new exGPSAnalysisMessenger(
this);
52 exGPSAnalysisManager::~exGPSAnalysisManager() {
53 delete fAnalysisMessenger;
60 if (fInstance == 0) fInstance =
new exGPSAnalysisManager();
66 void exGPSAnalysisManager::Dispose()
82 fEnerHisto->fill(e/
MeV,w);
83 fPosiXY->fill(x/
cm,y/
cm,w);
84 fPosiXZ->fill(x/
cm,z/
cm,w);
85 fPosiYZ->fill(y/
cm,z/
cm,w);
86 fAnglCTP->fill(p/
deg,std::cos(t),w);
87 fAnglTP->fill(p/
deg,t/
deg,w);
90 if (fPlotter) fPlotter->refresh();
95 fTuple->fill(0,pname);
96 fTuple->fill(1,e/
MeV);
100 fTuple->fill(5,t/
deg);
101 fTuple->fill(6,p/
deg);
113 void exGPSAnalysisManager::BeginOfRun()
118 fPosiXY = fPosiXZ = fPosiYZ = fAnglCTP =fAnglTP = 0;
122 fAnalysisFactory = AIDA_createAnalysisFactory();
123 if(!fAnalysisFactory)
125 G4cout <<
"exGPSAnalysisManager::BeginOfRun: can't get AIDA." <<
G4endl;
128 AIDA::ITreeFactory* treeFactory = fAnalysisFactory->createTreeFactory();
131 fTree = treeFactory->create(fIleName,fIleType,
false,
true,
"compress=yes");
134 G4cout <<
"exGPSAnalysisManager::BeginOfRun:"
135 <<
" can't create the AIDA::ITree : " << fIleName <<
G4endl;
142 AIDA::IHistogramFactory* hFactory =
143 fAnalysisFactory->createHistogramFactory(*fTree);
147 fEnerHisto = hFactory->createHistogram1D(
"Source Energy Spectrum",100,
151 fPosiXY = hFactory->createHistogram2D(
"Source X-Y distribution",100,
152 fMinpos/
cm,fMaxpos/
cm,100,fMinpos/
cm,fMaxpos/
cm);
153 fPosiXZ = hFactory->createHistogram2D(
"Source X-Z distribution",100,
154 fMinpos/
cm,fMaxpos/
cm,100,fMinpos/
cm,fMaxpos/
cm);
155 fPosiYZ = hFactory->createHistogram2D(
"Source Y-Z distribution",100,
156 fMinpos/
cm,fMaxpos/
cm,100,fMinpos/
cm,fMaxpos/
cm);
157 fAnglCTP = hFactory->createHistogram2D(
"Source phi-std::cos(theta) distribution",
158 360,0,360,100, -1, 1);
159 fAnglTP = hFactory->createHistogram2D(
"Source phi-theta distribution",
160 360,0,360,180,0,180);
166 AIDA::ITupleFactory* tFactory = fAnalysisFactory->createTupleFactory(*fTree);
169 fTuple = tFactory->create(
"MyTuple",
"MyTuple",
170 "string Pname, double Energy, X, Y, Z, Theta, Phi, Weight",
"");
174 AIDA::IPlotterFactory* pf = fAnalysisFactory->createPlotterFactory(0,0);
177 fPlotter = pf->create();
180 fPlotter->createRegions(2,3);
181 if(fEnerHisto) fPlotter->region(0)->plot(*fEnerHisto);
182 if(fPosiXY) fPlotter->region(1)->plot(*fPosiXY);
183 if(fPosiXZ) fPlotter->region(2)->plot(*fPosiXZ);
184 if(fPosiYZ) fPlotter->region(3)->plot(*fPosiYZ);
185 if(fAnglCTP) fPlotter->region(4)->plot(*fAnglCTP);
186 if(fAnglTP) fPlotter->region(5)->plot(*fAnglTP);
198 void exGPSAnalysisManager::EndOfRun()
200 if (fAnalysisFactory)
202 if (!fTree->commit()) G4cout <<
"Commit failed: no AIDA file produced!"
210 delete fAnalysisFactory;
211 fAnalysisFactory = 0;
214 fPosiXY = fPosiXZ = fPosiYZ = fAnglCTP =fAnglTP = 0;
221 #endif // G4ANALYSIS_USE