Message: Warp a process? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Warp a process? 

Forum: Physics List
Date: 09 Aug, 2011
From: Tom Roberts <Tom Roberts>

How can I wrap a physics process from a physics list? (I want to re-weight a specific process, specified by its name and a particle name.)

The design of G4WrapperProcess assumes that it is applied before the process is added to the particle(s). But that is not possible when using a pre-packaged physics list. My code is limited to the pre-packaged physics lists, and I'm stumped how to apply a wrapper to a given process while keeping the order of the processes unchanged.

Here's what I tried -- note that:
  a) this happens after the physics list has been created and 
     G4RunManager::Initialize() has been called.
  b) this does not apply to any continuous process (i.e. in the
     AlongStep list).
  c) my class ReweightProcess needs to be added to the end of the
     AlongStep list (in order to update the weight along each step).
  d) when wrapProcess() is called, pmgr points to the G4ProcessManager of
     the desired particle, and proc points to the desired process that is
     known to be present in one or both of its AtRest and PostStep lists,
     and known to be absent in the AlongStep list.

  void wrapProcess(G4ProcessManager *pmgr,G4VProcess *proc) {
      // validity checks not shown...
      ReweightProcess *rp = new ReweightProcess(pmgr,proc);
      int orderAtRest = pmgr->GetProcessOrdering(proc,idxAtRest);
      int orderAlongStep = ordLast;
      int orderPostStep = pmgr->GetProcessOrdering(proc,idxPostStep);
      pmgr->RemoveProcess(proc);
      pmgr->AddProcess(rp,orderAtRest,orderAlongStep,orderPostStep);
  }

While this appears to work for simple cases, the process list sometimes gets re-ordered. Specifically, processes that were ordered ordDefault were placed at the end of the list at an earlier time, but the list is longer now and they are placed at the end of the longer list (my code adds StepLimiter and perhaps other utility processes).

I have tried simply replacing entries in the various ProcessVector-s, but that confuses the G4ProcessManager because its G4ProcessAttribute-s become inconsistent with the vectors. I also tried using GetProcessIndex() to determine the ordering, but could not get it to work, either. Inverting the order of RemoveProcess() and AddProcess() does not help.

Is there any way to do this without changing the order of the list? If the re-ordering only happens for processes that were ordered with ordDefault or ordLast, is it OK to re-order the list?

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

1 Idea: Re: Wrap a process?   (Tom Roberts - 09 Aug, 2011)
 Add Message Add Message
to: "Warp a process?"

 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 ]