Message: Problem in RecordEvent for storing in to map for accumulation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problem in RecordEvent for storing in to map for accumulation 

Forum: Hits, Digitization and Pileup
Date: 15 Aug, 2018
From: Abhijit Bhattacharyya <Abhijit Bhattacharyya>

Hello!

I have the following problem. I have two G4MultiFunctional Detectors defined in ParallelWorld each having nine Scorers as RegisterPrimitives.

In "ABRun.hh" I have:

 ...
  static const G4int fParaNumber = 2;      
  static const G4int fScorerNumber = 9;    
  std::vector<std::vector<G4int> > fCollID;
  G4THitsMap<G4double> fRunMapAB[fParaNumber][fScorerNumber]; // map for accumulation [i][j]: i for det j for scorer

 ...

In "ABRun.cxx" I have :

(a) The constructor : ABRun::ABRun() : G4Run() {

  fCollID.resize(fScorerNumber, std::vector<G4int>(fParaNumber, 0));
  G4SDManager* SDMan = G4SDManager::GetSDMpointer();
  SDMan->SetVerboseLevel(1);
  G4String fullName;

  for (G4int i = 0; i < fParaNumber; i++) {
    for (G4int j = 0; j < fScorerNumber; j++) {
      fullName = fParaName[i] + "/" + fScorerName[j];
      fCollID[i][j] = SDMan->GetCollectionID(fullName);
    }
  }
....
}

(b) The RecordEvent:
void ABRun::RecordEvent(const G4Event* thisEvent) {
  ++fNevt;
  G4HCofThisEvent* HCE = thisEvent->GetHCofThisEvent();
  if (!HCE) return;
  for (G4int i = 0; i <  fParaNumber; i++) {
    for (G4int j = 0; j <  fScorerNumber; j++) {
      G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fCollID[i][j]));
      fRunMapAB[i][j] += *evtMap; <<<<-------- PROBLEM
    }
  }
}

(c)The Merge :
void ABRun::Merge(const G4Run* thisRun) {
  const ABRun* localRun = static_cast<const ABRun *> (thisRun);

  for (G4int i = 0; i < fParaNumber; i++){
    for (G4int j = 0; j < fScorerNumber; j++) {
      fRunMapAB[i][j] += localRun->fRunMapAB[i][j];
    }
  }
}

If I run this code in Multithreading mode, I see core dumped file. Analysis of core using GDB shows :

0x0000559472bcfc46 in G4VTHitsMap<double, std::map<int, double*, std::less<int>, std::allocator<std::pair<int const, double*> > > >::GetMap (this=0x0) at /opt/G4MT_Master/include/Geant4/G4THitsMap.hh:118 118 { return (Map_t*)theCollection; } [Current thread is 1 (Thread 0x7fadaae87700 (LWP 7914))]

while backtracing shows
(gdb) bt
#0  0x0000559472bcfc46 in G4VTHitsMap<double, std::map<int, double*, std::less<int>, std::allocator<std::pair<int const, double*> > > >::GetMap (this=0x0) at /opt/G4MT_Master/include/Geant4/G4THitsMap.hh:118
#1  0x0000559472bcfb7e in G4VTHitsMap<double, std::map<int, double*, std::less<int>, std::allocator<std::pair<int const, double*> > > >::operator+=<double, std::map<int, double*, std::less<int>, std::allocator<std::pair<int const, double*> > > > (
    this=0x7fad94bc94d0, right=...) at /opt/G4MT_Master/include/Geant4/G4THitsMap.hh:102
#2  0x0000559472bcac3e in ABRun::RecordEvent (this=0x7fad94bc8b70, thisEvent=0x7fad94bc7f70)
    at /home/vega/G4Work/src/ABRun.cxx:411

This points to "fRunMapAB[i][j] += *evtMap; <<<<-------- PROBLEM" line.

Can anyone help me to rectify the error?

Thank you. Best Regards Abhijit Bhattacharyya

 Add Message Add Message
to: "Problem in RecordEvent for storing in to map for accumulation"

 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 ]