Abnormal deposited energy in array of detectors

Hi all,
My sensitive detector is an array of detectors. I want to add deposited energy of the same detector. For example, if in one event two detectors have deposited energy, then I want to store the two IDs of the detectors and the corresponding deposited energy. My code implemented as following,

void MySensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){
G4int copyNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber();
   G4double edep= aStep->GetTotalEnergyDeposit();
   G4String pname=aStep->GetTrack()->GetDefinition()->GetParticleName();
   if (edep > 0.0){
        if (std::find(id_unique.begin(), id_unique.end(), copyNumber) == id_unique.end()){
        G4cout<<"ID: "<<copyNumber<<" energy: "<<G4BestUnit(edep,"Energy")<<" particle: "<<pname<<G4endl;

void MySensitiveDetector::EndOfEvent(G4HCofThisEvent*)
  G4double deposit=0.0; 
  for(unsigned int k=0; k< energyStep.size(); k++){
    deposit +=energyStep.at(k);
  if(deposit > 0.0) {
      G4AnalysisManager *man=G4AnalysisManager::Instance();
      for (const G4int & id: id_unique ){
          G4double deposited_energy=0.0;
          for(unsigned int i=0; i< copyNumbers.size(); i++){
                deposited_energy += energyStep.at(i);
          if(deposited_energy > 0.0){
              G4cout<<"summary: id: "<<id<<" total energy: "<<G4BestUnit(deposited_energy,"Energy")<<G4endl;



It seems that the codes work for most events, but I noticed abnormal pheno in a few events like,

G4WT9 > ID: 1 energy: 3.5354 keV particle: gamma
G4WT7 > ID: 0 energy: 4.3397 keV particle: gamma
G4WT9 > ID: 1 energy: 296.777 eV  particle: e-
G4WT7 > ID: 0 energy: 9.6224 keV particle: gamma
G4WT7 > ID: 0 energy: 920.745 eV  particle: e-
G4WT7 > ID: 0 energy: 16.9222 keV particle: e-
G4WT7 > ID: 0 energy: 409.465 eV  particle: e-
G4WT7 > ID: 0 energy: 17.7855 keV particle: e-
G4WT7 > summary: id: 0 total energy: 50 keV
G4WT7 > -------- event ID: 99669 end---------

In the event above, the detector with id=0 and id=1 both have deposited energy, but when I sum the energy of each detector, it seems only the detector withid=0 have deposited energy. The tested incoming particles are gamma ray with energy 50.0 keV .
The energy deposited in detector with id=0 is 50 keV, in this case the detector withid=1 should not have deposits. The code is excuted in multi-threads mode. Is there any thing needed to modify in my code to make it more reasonable?

seems like this is the mixed output of two different events running on two different workers (G4WT9 vs G4WT7).