Changeset 1230 for trunk/examples/extended/eventgenerator/exgps/src
- Timestamp:
- Jan 8, 2010, 3:02:48 PM (14 years ago)
- Location:
- trunk/examples/extended/eventgenerator/exgps/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/extended/eventgenerator/exgps/src/exGPSAnalysisManager.cc
r807 r1230 37 37 38 38 exGPSAnalysisManager::exGPSAnalysisManager(): 39 fileName("exgps.aida"),fileType("xml"),analysisFactory(0), hFactory(0), tFactory(0), 40 minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.) 39 fileName("exgps.aida"),fileType("xml"),analysisFactory(0), tree(0),plotter(0), 40 minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.), 41 enerHisto(0),posiXY(0),posiXZ(0),posiYZ(0),anglCTP(0),anglTP(0),tuple(0) 41 42 { 42 43 // Define the messenger and the analysis system … … 55 56 56 57 57 IHistogramFactory* exGPSAnalysisManager::getHistogramFactory() 58 { 59 return hFactory; 60 } 61 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 63 64 65 ITupleFactory* exGPSAnalysisManager::getTupleFactory() 66 { 67 return tFactory; 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 71 72 IPlotter* exGPSAnalysisManager::createPlotter() 73 { 74 #ifdef JAIDA_HOME 75 if (analysisFactory) 76 { 77 IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0); 78 if (pf) return pf->create("Plotter"); 79 } 80 #endif 81 return 0; 82 } 83 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 84 59 85 60 //////////////////////////////////////////////////////////////////////////////// … … 108 83 G4double t, G4double p, G4double w) 109 84 { 110 enerHisto->fill(e/MeV,w); 111 posiXY->fill(x/cm,y/cm,w); 112 posiXZ->fill(x/cm,z/cm,w); 113 posiYZ->fill(y/cm,z/cm,w); 114 anglCTP->fill(p/deg,std::cos(t),w); 115 anglTP->fill(p/deg,t/deg,w); 85 if(enerHisto) { 86 enerHisto->fill(e/MeV,w); 87 posiXY->fill(x/cm,y/cm,w); 88 posiXZ->fill(x/cm,z/cm,w); 89 posiYZ->fill(y/cm,z/cm,w); 90 anglCTP->fill(p/deg,std::cos(t),w); 91 anglTP->fill(p/deg,t/deg,w); 92 } 116 93 117 94 if (plotter) plotter->refresh(); … … 141 118 void exGPSAnalysisManager::BeginOfRun() 142 119 { 120 tree = 0; 121 plotter = 0; 122 123 enerHisto =0; 124 posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0; 125 tuple = 0; 143 126 144 127 // Hooking an AIDA compliant analysis system. 145 128 analysisFactory = AIDA_createAnalysisFactory(); 146 if(analysisFactory){ 147 ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); 129 if(!analysisFactory) //Have to check that, it can fail. 130 { 131 G4cout << "exGPSAnalysisManager::BeginOfRun: can't get AIDA." << G4endl; 132 return; 133 } 134 AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); 135 if(treeFactory) 136 { 148 137 tree = treeFactory->create(fileName,fileType,false,true,"compress=yes"); 149 hFactory = analysisFactory->createHistogramFactory(*tree); 150 tFactory = analysisFactory->createTupleFactory(*tree); 138 if(!tree) //Have to check that, it can fail. 139 { 140 G4cout << "exGPSAnalysisManager::BeginOfRun:" 141 << " can't create the AIDA::ITree : " << fileName << G4endl; 142 return; 143 } 144 151 145 delete treeFactory; // Will not delete the ITree. 152 146 } 153 // 154 enerHisto =0; 155 posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0; 156 plotter = 0; 157 tuple = 0; 158 // 147 148 AIDA::IHistogramFactory* hFactory = analysisFactory->createHistogramFactory(*tree); 159 149 if (hFactory) 160 150 { … … 173 163 anglTP = hFactory->createHistogram2D("Source phi-theta distribution",360,0,360 174 164 ,180,0,180); 175 #ifdef JAIDA_HOME 176 plotter = createPlotter(); 177 165 delete hFactory; 166 } 167 168 // Create a Tuple 169 170 AIDA::ITupleFactory* tFactory = analysisFactory->createTupleFactory(*tree); 171 if (tFactory) 172 { 173 tuple = tFactory->create("MyTuple","MyTuple","string Pname, double Energy, X, Y, Z, Theta, Phi, Weight",""); 174 delete tFactory; 175 } 176 177 AIDA::IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0); 178 if(pf) 179 { 180 plotter = pf->create(); 178 181 if (plotter) 179 182 { 180 183 plotter->createRegions(2,3); 181 plotter->region(0)->plot(*enerHisto);182 plotter->region(1)->plot(*posiXY);183 plotter->region(2)->plot(*posiXZ);184 plotter->region(3)->plot(*posiYZ);185 plotter->region(4)->plot(*anglCTP);186 plotter->region(5)->plot(*anglTP);184 if(enerHisto) plotter->region(0)->plot(*enerHisto); 185 if(posiXY) plotter->region(1)->plot(*posiXY); 186 if(posiXZ) plotter->region(2)->plot(*posiXZ); 187 if(posiYZ) plotter->region(3)->plot(*posiYZ); 188 if(anglCTP) plotter->region(4)->plot(*anglCTP); 189 if(anglTP) plotter->region(5)->plot(*anglTP); 187 190 plotter->show(); 188 } 189 #endif 190 } 191 192 // Create a Tuple 193 194 if (tFactory) 195 { 196 tuple = tFactory->create("MyTuple","MyTuple","std::string Pname, std::double Energy, X, Y, Z, Theta, Phi, Weight",""); 197 } 198 191 } 192 delete pf; 193 } 199 194 } 200 195 … … 210 205 if (!tree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl; 211 206 delete tree; 212 delete tFactory; 213 delete hFactory; 207 tree = 0; 214 208 // G4cout << "Warning: Geant4 will NOT continue unless you close the JAS-AIDA window." << G4endl; 215 delete analysisFactory; 216 } 217 // dispose(); 209 210 delete plotter; 211 plotter = 0; 212 213 delete analysisFactory; //cleanup all AIDA related things. 214 analysisFactory = 0; 215 216 enerHisto = 0; 217 posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0; 218 tuple = 0; 219 220 } 218 221 } 219 222 -
trunk/examples/extended/eventgenerator/exgps/src/exGPSAnalysisMessenger.cc
r807 r1230 25 25 // 26 26 #ifdef G4ANALYSIS_USE 27 28 #include <AIDA/AIDA.h>29 27 30 28 #include "exGPSAnalysisMessenger.hh" -
trunk/examples/extended/eventgenerator/exgps/src/exGPSEventAction.cc
r807 r1230 28 28 29 29 #ifdef G4ANALYSIS_USE 30 #include <AIDA/AIDA.h>31 30 #include "exGPSAnalysisManager.hh" 32 31 #endif … … 89 88 E=std::sqrt(P*P+E0*E0); 90 89 E -= E0; 91 G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName(); 90 // G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName(); 91 G4double pid = G4double(evt->GetPrimaryVertex(j)->GetPrimary(i)->GetPDGcode()); 92 92 // 93 93 direction=direction*(1./direction.mag()); … … 101 101 z=position.z(); 102 102 w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight(); 103 exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w); 103 // exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w); 104 exGPSAnalysisManager::getInstance()->Fill(pid,E,x,y,z,Theta,Phi,w); 104 105 } 105 106 } 106 107 #endif 107 108 109 #ifdef G4VIS_USE 108 110 // extract the trajectories and draw them 109 111 if (G4VVisManager::GetConcreteInstance()) … … 122 124 } 123 125 } 126 #endif 124 127 } 125 128 -
trunk/examples/extended/eventgenerator/exgps/src/exGPSEventActionMessenger.cc
r807 r1230 32 32 // 33 33 // $Id: exGPSEventActionMessenger.cc,v 1.3 2006/06/29 17:14:43 gunter Exp $ 34 // GEANT4 tag $Name: $34 // GEANT4 tag $Name: geant4-09-03-cand-01 $ 35 35 // 36 36 // -
trunk/examples/extended/eventgenerator/exgps/src/exGPSRunAction.cc
r807 r1230 33 33 34 34 #ifdef G4ANALYSIS_USE 35 #include <AIDA/AIDA.h>36 35 #include "exGPSAnalysisManager.hh" 37 36 #endif … … 55 54 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 56 55 56 #ifdef G4VIS_USE 57 57 if (G4VVisManager::GetConcreteInstance()) 58 58 { … … 60 60 UI->ApplyCommand("/vis/scene/notifyHandlers"); 61 61 } 62 #endif 62 63 #ifdef G4ANALYSIS_USE 63 64 // If analysis is used reset the histograms … … 70 71 void exGPSRunAction::EndOfRunAction(const G4Run* ) 71 72 { 73 #ifdef G4VIS_USE 72 74 if (G4VVisManager::GetConcreteInstance()) { 73 75 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update"); 74 76 } 77 #endif 75 78 // If analysis is used 76 79 #ifdef G4ANALYSIS_USE
Note: See TracChangeset
for help on using the changeset viewer.