Two Sensitive Detectors - definition

Hi @weller,
Thanks for you reply. I did some trials, and I think that there is a problem here:

//sensitive detector for one layer //
SensitiveDetector::~SensitiveDetector() {}

void SensitiveDetector::Initialize(G4HCofThisEvent* hce) {
// Create hits collection
fHitsCollection = new HitsCollection(SensitiveDetectorName, collectionName[0]);

// Add this collection in hce
auto hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection(hcID, fHitsCollection);

// Create hit for each scintillator layer
for (G4int i=0; i<fNofLayers; i++) fHitsCollection->insert(new class Hit());
}

When I try to generalize to two sensitive volume (I defined fScoringVolume = “name” and fScoringVolume1 = “name” in DetectorConstruction.cc class), I cannot run my simulation. I tried to copy and paste in this way:

/*
//sensitive detector for the second layer

void SensitiveDetector::Initialize(G4HCofThisEvent* hce1) {
// Create hits collection
fHitsCollection1 = new HitsCollection(SensitiveDetectorName, collectionName[1]);

// Add this collection in hce
auto hcID1 = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[1]);
hce1->AddHitsCollection(hcID1, fHitsCollection1);

// Create hit for each scintillator layer
for (G4int j=0; j<fNofLayers; j++) fHitsCollection->insert(new class Hit());
}
*/
But I get an error when building, as if I defined twice the function Initialize.