Message: Null pointer Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Null pointer 

Forum: Processes Involving Optical Photons
Date: 01 May, 2009
From: Chibueze Zimuzo <Chibueze Zimuzo>


I am simulating a planar NaI(Tl) scintillation detector with 25 pmt tubes coupled at the back before a gamma-ray source. I largely used example LXe code except that I defined all my detectors (including my pmts) inside the detectorConstruction class instead of creating a separate volume for them. My problem is that simulation is outputing (0,0,0) for all the (x,y,z) reconstructed positions from pmts. Other parts/classes of my code is almost the same as LXe example.

Below is part of my code that show how I defined pmts are shown below:


class CCDetectorConstruction : public G4VUserDetectorConstruction



    G4VPhysicalVolume* Construct();
    void PlacePMTs(G4LogicalVolume* pmt_log, G4RotationMatrix *rot,
		   G4double dx, G4double dy, G4double xmin,
		   G4double ymin, G4int nx, G4int ny,
		   G4double &x1, G4double &y1, G4double z1,
		   G4int &k,CCPMTSD* sd);   

    CCPMTSD* sd;


  //Sensitive detectors
    static CCScintSD* scint_SD;
    static CCPMTSD* pmt_SD;

    G4int na, nb; 
    G4double c, amin, bmin, da, db;

  // PMT

    G4double innerRadius_pmt = 0.*cm;
    G4double outerRadius_pmt = 1.*cm;
    //G4double diag_pmt = 2*outerRadius_pmt;
    G4double halfHeight_pmt = 2.*cm;
    G4double startAngle_pmt = 0.*deg;
    G4double spanningAngle_pmt = 360.*deg;
    pmt = new G4Tubs("pmt_tube",innerRadius_pmt,outerRadius_pmt,

    //the "photocathode" is a metal slab at the back of the glass that
    //is only a very rough approximation of the real thing since it only
    //absorbs or detects the photons based on the efficiency set below
    photocath = new G4Tubs("photocath_tube",innerRadius_pmt,outerRadius_pmt,

    pmt_log = new G4LogicalVolume(pmt,Glass, "pmt_log",0,0,0);
    photocath_log = new G4LogicalVolume(photocath, Al, "photocath_log",0,0,0);

    photocath_phys = new G4PVPlacement(0,G4ThreeVector(0,0,halfHeight_pmt/2),

    G4double da, db, amin, bmin, x1, y1; G4int na=0; G4int nb=0;

 // The PMT sensitive detector 

    //The sensitive detector is not actually on the photocathode.
    //processHits gets done manually by the stepping action.
    //It is used to detect when photons hit and get absorbed/detected at the
    //boundary to the photocathode (which doesnt get done by attaching it to a
    //logical volume.
    //It does however need to be attached to something or else it doesnt get
    //reset at the begining of events

  pmt_SD = new CCPMTSD("pmt_SD");


  pmt_SD->InitPMTs(na*nb); // let pmtSD know # of pmts

  amin=bmin=-6.*cm; da=db=2.*cm; na=nb=5; G4int k=0;
  c = -(inter_Det_z + halfScint_z + halfHeight_pmt);


  G4VisAttributes* pmtAttributes = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.0));

void CCDetectorConstruction::PlacePMTs(G4LogicalVolume* pmt_log,
			      G4RotationMatrix *rot,
			      G4double dx, G4double dy, G4double xmin,
			      G4double ymin, G4int nx, G4int ny,
			      G4double &x1, G4double &y1, G4double z1,
			      G4int &k,CCPMTSD* sd){
  /*PlacePMTs : a different way to parameterize placement that does not depend on
  calculating the position from the copy number

  pmt_log = logical volume for pmts to be placed
  rot = rotation matrix to apply
  a,b = coordinates to vary(ie. if varying in the xy plane then pass x,y)
  da,db = value to increment a,b by
  amin,bmin = start values for a,b
  na,nb = number of repitions in a and b
  x,y,z = just pass x,y, and z by reference (the same ones passed for a,b)
  k = copy number to start with
  sd = sensitive detector for pmts*/

    for(G4int j=1;j<=nx;j++){
	for(G4int i=1;i<=ny;i++){
	    new G4PVPlacement(rot,G4ThreeVector(x1,y1,z1),pmt_log,"pmt",

I'm willing to provide more information in case I'm not clear enough. Please all kind suggestions are highly appreciated.


 Add Message Add Message
to: "Null pointer"

 Subscribe Subscribe

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