Message: Re: Making multiple sensitive Detectors - a probelm Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Making multiple sensitive Detectors - a probelm 

Keywords: sensitive detector hits collection geometry output problem
Forum: Hits, Digitization and Pileup
Re: Question Making multiple sensitive Detectors - a probelm (Laura Harkness)
Date: 19 Dec, 2007
From: Laura Harkness <Laura Harkness>

Hi,

thanks for that, I checked through my loops for the geometry, and they are ok. I don't have an events action file. I have primarygenerator, physicslist, detector construction, detectorhits and sensitivedetector.

I think the problem lies either in detectorhits or sensitivedetector, though I am not experienced enough in c++ to know what it is. Perhaps I need multuple hits collection to be defined?

My sensitive detector file: -----------------------------------------------------------

SPDetectorSD::SPDetectorSD(G4String name)
  :G4VSensitiveDetector(name)
{
  G4String HCname;
  collectionName.insert(HCname="detectorCollection");

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

SPDetectorSD::~SPDetectorSD(){ }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void SPDetectorSD::Initialize(G4HCofThisEvent* HCE)
{
  DetectorCollection = new SPDetectorHitsCollection(SensitiveDetectorName,collectionName[0]); 
   static G4int HCID = -1;
  if(HCID<0)
    //   { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
    { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(DetectorCollection); }

HCE->AddHitsCollection( HCID, DetectorCollection ); }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4bool SPDetectorSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
  G4double edep = aStep->GetTotalEnergyDeposit();

  if(edep==0.) return false;

  SPDetectorHit* newHit = new SPDetectorHit();
  newHit->SetTrackID  (aStep->GetTrack()->GetTrackID());
  newHit->SetDetectorspNb(aStep->GetPreStepPoint()->GetTouchable()
                                               ->GetReplicaNumber());
  newHit->SetHitTime (aStep->GetPostStepPoint()->GetGlobalTime());
  newHit->SetEdep     (edep);
  // newHit->SetDelEnergy (aStep->GetDeltaEnergy());
  newHit->SetPos      (aStep->GetPostStepPoint()->GetPosition());
  // newHit->SetProcessPost (aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName());
  DetectorCollection->insert( newHit );

  newHit->Print();
  newHit->Draw();

return true; }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void SPDetectorSD::EndOfEvent(G4HCofThisEvent*)
{
  if (verboseLevel>0) { 
    G4int NbHits = DetectorCollection->entries();
    G4cout << "\n--->Hits Collection: in this event there are " << NbHits 
        << " hits in the detector : " << G4endl;
     for (G4int i=0;i<NbHits;i++) (*DetectorCollection)[i]->Print();
  } 
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

------------------------------------------------------------------------- My detector hits file:

----------------------------------------------------------------------- G4Allocator<SPDetectorHit> SPDetectorHitAllocator;

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

SPDetectorHit::SPDetectorHit() {}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

SPDetectorHit::~SPDetectorHit() {}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

SPDetectorHit::SPDetectorHit(const SPDetectorHit& right)
  : G4VHit()
{
  trackID   = right.trackID;
  // processPost  = right.processPost;
  time      = right.time;
  detectorspNb = right.detectorspNb;
  edep      = right.edep;
  // delEnergy = right.delEnergy;
  pos       = right.pos;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

const SPDetectorHit& SPDetectorHit::operator=(const SPDetectorHit& right)
{
  trackID   = right.trackID;
  //processPost  = right.processPost;
  time      = right.time;
  detectorspNb = right.detectorspNb;
  edep      = right.edep;
  // delEnergy = right.delEnergy;
  pos       = right.pos;
  return *this;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4int SPDetectorHit::operator==(const SPDetectorHit& right) const
{
  return (this==&right) ? 1 : 0;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void SPDetectorHit::Draw()
{
  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
  if(pVVisManager)
  {
    G4Circle circle(pos);
    circle.SetScreenSize(3.);
    circle.SetFillStyle(G4Circle::filled);
    G4Colour colour(1.,0.,0.);
    G4VisAttributes attribs(colour);
    circle.SetVisAttributes(attribs);
    pVVisManager->Draw(circle);
  }
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void SPDetectorHit::Print()
{
  G4cout << "  trackID: "<< trackID 
    //	 << "  process "<< processPost
    	 << "  time: "<<G4BestUnit(time,"Time")
    	 << "  SPDetector No: "<< detectorspNb
	 << "  energy dep: "  << G4BestUnit(edep,"Energy") << G4endl;
    //	 << "  energy loss: "  << G4BestUnit(delEnergy,"Energy")

// << " x,y,z: " << G4BestUnit(pos,"Length") << G4endl; }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

-----------------------------------------------------------------------

Any help with this would be greatly appreciated as I have been trying to figure this one out for a while. Thank you very much in advance,

Laura

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Re: Making multiple sensitive Detectors - a probelm"

 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 ]