Message: Re: netron detector EventAction problem Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: netron detector EventAction problem 

Forum: Event and Track Management
Re: None netron detector EventAction problem (Davinder Siwal)
Date: 26 May, 2009
From: Paul Nicholas Colin Gloster <Paul Nicholas Colin Gloster>

On Sat, 23 May 2009, Davinder Siwal wrote:

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|"Hii all                                                                                                                                                                      |
|                                                                                                                                                                              |
|i am trying to simulate the neutron detector array to calculate the                                                                                                           |
|cross talk and following i am showing the the EventAction.cc                                                                                                                  |
|                                                                                                                                                                              |
|#include "psimNeutronDetector1Hit.hh"                                                                                                                                         |
|#include "psimNeutronDetector2Hit.hh"                                                                                                                                         |
|#include "psimEventAction.hh"                                                                                                                                                 |
|                                                                                                                                                                              |
|//#include "psimEventActionMessenger.hh"                                                                                                                                      |
|                                                                                                                                                                              |
|#ifdef G4ANALYSIS_USE                                                                                                                                                         |
|#include "psimAnalysisManager.hh"                                                                                                                                             |
|#endif // G4ANALYSIS_USE                                                                                                                                                      |
|                                                                                                                                                                              |
|#include "G4Event.hh"                                                                                                                                                         |
|#include "G4EventManager.hh"                                                                                                                                                  |
|#include "G4HCofThisEvent.hh"                                                                                                                                                 |
|#include "G4VHitsCollection.hh"                                                                                                                                               |
|#include "G4TrajectoryContainer.hh"                                                                                                                                           |
|#include "G4Trajectory.hh"                                                                                                                                                    |
|#include "G4VVisManager.hh"                                                                                                                                                   |
|#include "G4SDManager.hh"                                                                                                                                                     |
|#include "G4UImanager.hh"                                                                                                                                                     |
|#include "G4ios.hh"                                                                                                                                                           |
|                                                                                                                                                                              |
|psimEventAction::psimEventAction()                                                                                                                                            |
|{                                                                                                                                                                             |
|  G4String colName;                                                                                                                                                           |
|  G4SDManager* SDman = G4SDManager::GetSDMpointer();                                                                                                                          |
|   ND1HCID = SDman->GetCollectionID(colName="NeutronDetector1");                                                                                                              |
|   ND2HCID = SDman->GetCollectionID(colName="NeutronDetector2");                                                                                                              |
|                                                                                                                                                                              |
|#ifdef G4ANALYSIS_USE                                                                                                                                                         |
|  plotter = 0;                                                                                                                                                                |
|  tuple = 0;                                                                                                                                                                  |
|  nd1Hits = nd2Hts = 0;                                                                                                                                                       |
|                                                                                                                                                                              |
|  // Do some analysis                                                                                                                                                         |
|                                                                                                                                                                              |
|  psimAnalysisManager* analysisManager = psimAnalysisManager::getInstance();                                                                                                  |
|  IHistogramFactory* hFactory = analysisManager->getHistogramFactory();                                                                                                       |
|                                                                                                                                                                              |
|  if (hFactory)                                                                                                                                                               |
|  {                                                                                                                                                                           |
|    // Create some histograms                                                                                                                                                 |
|    nd1Hits = hFactory->createHistogramID("Neutron Detector 1 Hits",10,0,10);                                                                                                 |
|    nd2Hits = hFactory->createHistogramID("Neutron Detector 2 Hits",10,0,10);                                                                                                 |
|                                                                                                                                                                              |
|    plotter = analysisManager->createPlotter();                                                                                                                               |
|    if (plotter)                                                                                                                                                              |
|    {                                                                                                                                                                         |
|        plotter->createRegions(1,2);                                                                                                                                          |
|        plotter->region(0)->plot(*nd1Hits);                                                                                                                                   |
|        plotter->region(1)->plot(*nd2Hits);                                                                                                                                   |
|                                                                                                                                                                              |
|       plotter->show();                                                                                                                                                       |
|     }                                                                                                                                                                        |
|  }                                                                                                                                                                           |
|                                                                                                                                                                              |
|  // Create a Tuple                                                                                                                                                           |
|                                                                                                                                                                              |
|  ITupleFactory* tFactory = analysisManager->getTupleFactory();                                                                                                               |
|  if (tFactory)                                                                                                                                                               |
|  {                                                                                                                                                                           |
|    tuple = tFactory->create("myhisto","myhisto","int nd1Hits, nd2Hits","");                                                                                                  |
|                                                                                                                                                                              |
|  }                                                                                                                                                                           |
|#endif // G4ANALYSIS_USE                                                                                                                                                      |
|}                                                                                                                                                                             |
|                                                                                                                                                                              |
|psimEventAction::~psimEventAction() {                                                                                                                                         |
|                                                                                                                                                                              |
|}                                                                                                                                                                             |
|                                                                                                                                                                              |
|void psimEventAction::BeginOfEventAction(const G4Event*) { }                                                                                                                  |
|                                                                                                                                                                              |
|void psimEventAction::EndOfEventAction(const G4Event* evt) {                                                                                                                  |
|                                                                                                                                                                              |
|    G4HCofThisEvent* HCE = evt->GetHCofThisEvent();                                                                                                                           |
|    psimNeutronDetector1HitsCollection* ND1HC = NULL;                                                                                                                         |
|    psimNeutronDetector2HitsCollection* ND2HC = NULL;                                                                                                                         |
|                                                                                                                                                                              |
|// A01NeutrondetectorHitsCollection* ND1HC = 0;                                                                                                                               |
|                                                                                                                                                                              |
|  if(HCE)                                                                                                                                                                     |
|  {                                                                                                                                                                           |
|     ND1HC = (psimNeutronDetector1HitsCollection*)(HCE->GetHC(ND1HCID));                                                                                                      |
|     ND2HC = (psimNeutronDetector2HitsCollection*)(HCE->GetHC(ND2HCID));                                                                                                      |
|                                                                                                                                                                              |
|  }                                                                                                                                                                           |
|                                                                                                                                                                              |
|#ifdef G4ANALYSIS_USE                                                                                                                                                         |
|  // Fill some histograms                                                                                                                                                     |
|                                                                                                                                                                              |
|  if(ND1HC)                                                                                                                                                                   |
|  {                                                                                                                                                                           |
|     int n_hit1 = ND1HC->entries();                                                                                                                                           |
|     nd1Hits->Fill(n_hit1);                                                                                                                                                   |
|                                                                                                                                                                              |
|  }                                                                                                                                                                           |
|                                                                                                                                                                              |
|  if(ND2HC)                                                                                                                                                                   |
|  {                                                                                                                                                                           |
|   int n_hit2 = ND2HC->entries();                                                                                                                                             |
|   nd2Hits->Fill(n_hit2);                                                                                                                                                     |
|                                                                                                                                                                              |
|  }                                                                                                                                                                           |
|                                                                                                                                                                              |
|  // Fill the tuple                                                                                                                                                           |
|                                                                                                                                                                              |
|  if (tuple)                                                                                                                                                                  |
|  {                                                                                                                                                                           |
|    if(ND1HC) tuple->fill(0,ND1HC->entries());                                                                                                                                |
|    if(ND2HC) tuple->fill(1,ND2HC->entries());                                                                                                                                |
|                                                                                                                                                                              |
|  }                                                                                                                                                                           |
|  if (plotter) plotter->refresh();                                                                                                                                            |
|#endif // G4ANALYSIS_USE                                                                                                                                                      |
|                                                                                                                                                                              |
| when i am compliling the program it is not recogonising the psimNeutronDetector1HitsCollection and psimNeutronDetector2HitsCollection  what should i do to remove this error |
|                                                                                                                                                                              |
|did anybody knows the answer..............."                                                                                                                                  |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|


Hello,

I am not sure that you fully understand C++. You showed us
"[..]
    psimNeutronDetector1HitsCollection* ND1HC = NULL;
    psimNeutronDetector2HitsCollection* ND2HC = NULL;
[..]"
but there is no clear evidence that you would really have or need two
distinct classes (as opposed to objects) for collections of hits.

Regards,
Colin Paul Gloster

 Add Message Add Message
to: "Re: netron detector EventAction problem"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]