Ignore:
Timestamp:
Jan 8, 2010, 3:02:48 PM (14 years ago)
Author:
garnier
Message:

update to geant4.9.3

Location:
trunk/examples/extended/eventgenerator/exgps/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/extended/eventgenerator/exgps/src/exGPSAnalysisManager.cc

    r807 r1230  
    3737
    3838exGPSAnalysisManager::exGPSAnalysisManager():
    39 fileName("exgps.aida"),fileType("xml"),analysisFactory(0), hFactory(0), tFactory(0),
    40 minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.)
     39fileName("exgps.aida"),fileType("xml"),analysisFactory(0), tree(0),plotter(0),
     40minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.),
     41enerHisto(0),posiXY(0),posiXZ(0),posiYZ(0),anglCTP(0),anglTP(0),tuple(0)
    4142{
    4243  // Define the messenger and the analysis system
     
    5556
    5657
    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....
    8459
    8560////////////////////////////////////////////////////////////////////////////////
     
    10883                                G4double t, G4double p, G4double w)
    10984{
    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  }
    11693
    11794  if (plotter) plotter->refresh();
     
    141118void exGPSAnalysisManager::BeginOfRun()
    142119{
     120  tree = 0;
     121  plotter = 0;
     122
     123  enerHisto =0;
     124  posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0;
     125  tuple = 0;
    143126
    144127  // Hooking an AIDA compliant analysis system.
    145128  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  {
    148137    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
    151145    delete treeFactory; // Will not delete the ITree.
    152146  }
    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);
    159149  if (hFactory)
    160150  {
     
    173163    anglTP = hFactory->createHistogram2D("Source phi-theta distribution",360,0,360
    174164                                                  ,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();
    178181    if (plotter)
    179182    {
    180183       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);
    187190       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  }
    199194}
    200195
     
    210205    if (!tree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl;
    211206    delete tree;
    212     delete tFactory;
    213     delete hFactory;
     207    tree = 0;
    214208    //    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  }
    218221}
    219222
  • trunk/examples/extended/eventgenerator/exgps/src/exGPSAnalysisMessenger.cc

    r807 r1230  
    2525//
    2626#ifdef G4ANALYSIS_USE
    27 
    28 #include <AIDA/AIDA.h>
    2927
    3028#include "exGPSAnalysisMessenger.hh"
  • trunk/examples/extended/eventgenerator/exgps/src/exGPSEventAction.cc

    r807 r1230  
    2828
    2929#ifdef G4ANALYSIS_USE
    30 #include <AIDA/AIDA.h>
    3130#include "exGPSAnalysisManager.hh"
    3231#endif
     
    8988      E=std::sqrt(P*P+E0*E0);   
    9089      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());
    9292      //
    9393      direction=direction*(1./direction.mag());               
     
    101101      z=position.z();
    102102      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);
    104105    }
    105106  }   
    106107#endif
    107  
     108
     109#ifdef G4VIS_USE
    108110  // extract the trajectories and draw them
    109111  if (G4VVisManager::GetConcreteInstance())
     
    122124       }
    123125   }             
     126#endif
    124127}
    125128
  • trunk/examples/extended/eventgenerator/exgps/src/exGPSEventActionMessenger.cc

    r807 r1230  
    3232//
    3333// $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 $
    3535//
    3636//
  • trunk/examples/extended/eventgenerator/exgps/src/exGPSRunAction.cc

    r807 r1230  
    3333
    3434#ifdef G4ANALYSIS_USE
    35 #include <AIDA/AIDA.h>
    3635#include "exGPSAnalysisManager.hh"
    3736#endif
     
    5554  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
    5655
     56#ifdef G4VIS_USE
    5757  if (G4VVisManager::GetConcreteInstance())
    5858    {
     
    6060      UI->ApplyCommand("/vis/scene/notifyHandlers");
    6161    }
     62#endif
    6263#ifdef G4ANALYSIS_USE
    6364  // If analysis is used reset the histograms
     
    7071void exGPSRunAction::EndOfRunAction(const G4Run* )
    7172{
     73#ifdef G4VIS_USE
    7274  if (G4VVisManager::GetConcreteInstance()) {
    7375     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
    7476  }
     77#endif
    7578  // If analysis is used
    7679#ifdef G4ANALYSIS_USE
Note: See TracChangeset for help on using the changeset viewer.