Message: multiple placements od a single detector and hitsCollection? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question multiple placements od a single detector and hitsCollection?  

Forum: Hits, Digitization and Pileup
Date: 04 Sep, 2012
From: Ivan Koralt <Ivan Koralt>

Hello, I assembled the detector as a box inside another box. Both boxes have logical volumes but the one inside is sensitive. In my DetectorConstruction.cc I make only inside logical volume as a sensitive volume and then I place the entire assembled detector in the World couple of times. Now, in my Hit class I have set two variables that set the mother number (outer box nbr.) and physical volume of the sensitive box. My question is, do I have to have an array of hitsCollections (*hitsCollection)[copyNo] or by placing an assembled volume a new hitsCollection is created with the info on numbers and physical volumes of each placed physical volume?

To make this question easier, I copy-paste parts of my DetectorConstruction and my Hit and SD classes. Thanx and Cheers Ivan

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //scintillator into interior

    new G4PVPlacement(0,
                      //the same as Si plane but different Z
                      scintTV,
                      scintWrapLogical,
                      //scint and wrap assembly
                      "scintWrapAssy",
                      RPInteriorLogical,
                      false,
                      0,
                      checkForOverlaps);

    //=============================================================
    //interior into housing
    //=============================================================

    new G4PVPlacement(0,
                      G4ThreeVector(0,(RPHsngFrntBckThck+steelFoilThck)/2.,0),
                      RPInteriorLogical,
                      "RPInterior_Phys",
                      RPHousingLogical,
                      false,
                      0,
                      checkForOverlaps);

    //=============================================================
    //Sensitive detector
    //=============================================================
    G4SDManager* SDman = G4SDManager::GetSDMpointer();
    G4VSensitiveDetector* ScintSD = new ScintilatorSD("ScintSD");
    SDman->AddNewDetector(ScintSD);
    scintLogical->SetSensitiveDetector(ScintSD);

    //=============================================================
    //housings into world
    //=============================================================

    new G4PVPlacement(EHI_RM,
                      G4ThreeVector(-(RPOuterSizeY/2.+12.5*mm),0.,0.),
                      RPHousingLogical,
                      RPname[0],
                      worldLogical,
                      false,
                      0,
                      checkForOverlaps);

    new G4PVPlacement(EHO_RM,
                      G4ThreeVector((RPOuterSizeY/2.+12.5*mm),0.,0.),
                      RPHousingLogical,
                      RPname[1],
                      worldLogical,
                      false,
                      1,
                      checkForOverlaps);

    new G4PVPlacement(EVU_RM,
                      G4ThreeVector(0.,(RPOuterSizeY/2.+12.5*mm),3.*m),
                      RPHousingLogical,
                      RPname[2],
                      worldLogical,
                      false,
                      2,
                      checkForOverlaps);

etc... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#include "ScintilatorSD.hh"
#include "ScintilatorHit.hh"
#include "G4HCofThisEvent.hh"
#include "G4TouchableHistory.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"

ScintilatorSD::ScintilatorSD(G4String name) 
: G4VSensitiveDetector(name)
{
    collectionName.insert("ScintCollection");
    HCID = -1;
}

ScintilatorSD::~ScintilatorSD(){;}

void ScintilatorSD::Initialize(G4HCofThisEvent*HCE)
{
    hitsCollection = new ScintilatorHitsCollection
        (SensitiveDetectorName,collectionName[0]);
    if(HCID<0)
    { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(hitsCollection); }
    HCE->AddHitsCollection(HCID,hitsCollection);
}

G4bool ScintilatorSD::ProcessHits(G4Step*aStep,G4TouchableHistory* /*ROhist*/)
{
    G4double edep = aStep->GetTotalEnergyDeposit();
    if(edep==0.) return false; //No edep so dont count as hit

    G4int RPNbr =
        aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(3);
    G4VPhysicalVolume* physVol=
        aStep->GetPreStepPoint()->GetTouchable()->GetVolume();

    ScintilatorHit* aHit = new ScintilatorHit();
    aHit->SetScintNbr(RPNbr);
    aHit->SetScintPhysVol(physVol);
    aHit->SetEdep(edep);
    hitsCollection->insert(aHit);

    return true;
}

void ScintilatorSD::EndOfEvent(G4HCofThisEvent* /*HCE*/) {;}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#ifndef ScintilatorSD_h
#define ScintilatorSD_h 1

#include "G4VSensitiveDetector.hh"
#include "ScintilatorHit.hh"
class G4Step; class G4HCofThisEvent; class G4TouchableHistory;

class ScintilatorSD : public G4VSensitiveDetector {

public:
    ScintilatorSD(G4String name);
    virtual ~ScintilatorSD();

    virtual void Initialize(G4HCofThisEvent*HCE);
    virtual G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
    virtual void EndOfEvent(G4HCofThisEvent*HCE);

private:
    ScintilatorHitsCollection* hitsCollection;
    G4int HCID;
};

#endif

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Add Message Add Message
to: "multiple placements od a single detector and hitsCollection? "

 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 ]