Message: Re: Automatically run example N06 for multiple energies Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Automatically run example N06 for multiple energies 

Forum: Run Management
Re: Question Automatically run example N06 for multiple energies (Brian)
Date: Mar 27, 01:43
From: Bogdan Sikach <Bogdan Sikach>

First of all, what was my problem.

I needed 1) Change the reflectivity of the wrapper every run 2) Fill histogram and write to a ROOT file with the name depending on the value of the reflectivity

How I reached that.

I added method `SetReflectivity( G4double r )` in my `DetectorConstruction` class (this method changes reflectivity, obviously).

I added method `SetFileName( G4String fn )` in my `RunAction` class (this method changes file name to write to).

Then in main file (where the `main()` function lives) I have the following

<code>

    G4RunManager* runManager = new G4RunManager();                                           

    DetectorConstruction* detector = new DetectorConstruction();
    runManager->SetUserInitialization( detector );

    runManager->SetUserInitialization( new PhysicsList() );

    runManager->SetUserAction( new PrimaryGeneratorAction() );

    RunAction* runAction           = new RunAction();
    runManager->SetUserAction( runAction );

    EventAction* eventAction = new EventAction();
    runManager->SetUserAction( eventAction );

    runManager->Initialize();

    ... something irrelevant ...

     G4String pathToDataDir = "/home/lrdprdx/BINP/g4work/LightCollection/data/reflectivity";
          for( G4int i = 0; i < 100; i++ )
          {
              detector->SetReflectivity( G4double(i) / 100.);
              runAction->SetFileName( pathToDataDir + "/ref" + std::to_string(i) );
  //
              runManager->ReinitializeGeometry();
              runManager->BeamOn( cs::nEvents );
          }
</code>

It works properly but I am not able to explain why.

 Add Message Add Message
to: "Re: Automatically run example N06 for multiple energies"

 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 ]