ROOT logo
// $Id$
//
// Configuration macro for running aliroot with Geant4
// with primary events read from external file.
//
// By I. Hrivnacova, IPN Orsay
 	

void Config()
{
  cout << "Running g4Config.C ... " << endl;

  // AliRoot setup
  //
  gROOT->LoadMacro("$ALICE_ROOT/test/vmctest/ppbench/commonConfig.C");
  commonConfig();

  // TPC primary ionization 
  AliTPC* TPC = (AliTPC*)gAlice->GetDetector("TPC");
  if ( ! TPC )
    cerr << "Cannot get TPC detector" << endl;
  else  { 
    cerr << "Setting TPC primary ionization" << endl;
    TPC->SetPrimaryIonisation(); // not used with Geant3
  }  

  // Load Geant4 + Geant4 VMC libraries
  //
  if (gClassTable->GetID("TGeant4") == -1) {
    // Load Geant4 libraries 
    if (!gInterpreter->IsLoaded("$ALICE/geant4_vmc/examples/macro/g4libs.C")) {
      gROOT->LoadMacro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
      gInterpreter->ProcessLine("g4libs()");
    }
  }    

  // Create Geant4 VMC
  //  
  TGeant4 *geant4 = 0;
  if ( ! gMC ) {
    TG4RunConfiguration* runConfiguration 
      = new TG4RunConfiguration("geomRoot", 
                                "FTFP_BERT_EMV+optical", 
                                "specialCuts+stackPopper+stepLimiter",
                                 true);
//      = new TG4RunConfiguration("geomRootToGeant4",
//                                "FTFP_BERT_EMV+optical", 
//                                "specialCuts+specialControls+stackPopper+stepLimiter",
//                                 true);

    geant4 = new TGeant4("TGeant4", 
                         "The Geant4 Monte Carlo : FTFP_BERT_EMV+optical", 
                         runConfiguration);
             // Repeat physics selection in the title; to be removed
             // with new geant4_vmc tag (1.13)            

    cout << "Geant4 has been created." << endl;
  } 
  else {
    cout << "Monte Carlo has been already created." << endl;
  }  

  // Customization of Geant4 VMC
  //

    geant4->ProcessGeantCommand("/mcVerbose/all 1");  
    geant4->ProcessGeantCommand("/mcVerbose/geometryManager 1");  
    geant4->ProcessGeantCommand("/mcVerbose/opGeometryManager 1");  
    geant4->ProcessGeantCommand("/mcTracking/loopVerbose 1");     
    geant4->ProcessGeantCommand("/mcPhysics/rangeCuts 0.01 mm"); 
    geant4->ProcessGeantCommand("/mcTracking/skipNeutrino true");
    
    // Activate step limit defined in low density materials
    // (the default value is 10 cm)
    geant4->ProcessGeantCommand("/mcDet/setIsMaxStepInLowDensityMaterials true");
    geant4->ProcessGeantCommand("/mcDet/setMaxStepInLowDensityMaterials 10 m");

    // Activate step limit defined in tracking media
    // (Note: this slows down simulation significantly)
    //geant4->ProcessGeantCommand("/mcDet/setIsUserMaxStep true");
   
    // for Geant4 <= 9.4.p03
    //geant4->ProcessGeantCommand("/mcPhysics/selectOpProcess Scintillation");
    //geant4->ProcessGeantCommand("/mcPhysics/setOpProcessActivation false");
    // for Geant4 >= 9.5
    geant4->ProcessGeantCommand("/optics_engine/selectOpProcess Scintillation");
    geant4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
    geant4->ProcessGeantCommand("/optics_engine/selectOpProcess OpWLS");
    geant4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
    geant4->ProcessGeantCommand("/optics_engine/selectOpProcess OpMieHG");
    geant4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
    geant4->ProcessGeantCommand("/optics_engine/selectOpProcess Cerenkov");
    geant4->ProcessGeantCommand("/optics_engine/setTrackSecondariesFirst false");   

    // Activate saving random engine status
    // (the file per event will be re-written with each new event)
    //gAlice->GetMCApp()->SetSaveRndmStatus(kTRUE);
    //geant4->ProcessGeantCommand("/mcRun/saveRandom true");

    // Activate saving random engine status for each event
    // (a new file will be written for each event)
    //gAlice->GetMCApp()->SetSaveRndmStatusPerEvent(kTRUE);
    //geant4->ProcessGeantCommand("/mcRun/saveRandom true");
    //geant4->ProcessGeantCommand("/mcEvent/saveRandom true");
    
    // Activate printing size of used memory per event
    geant4->ProcessGeantCommand("/mcEvent/printMemory true");

  // Uncomment this line to get a detail info from each step 
  //geant4->ProcessGeantCommand("/tracking/verbose 1");  
  
  // More info from the physics list
  // the verbosity level is passed to all contained physics lists and their
  // physics builders
  //geant4->ProcessGeantCommand("/mcVerbose/composedPhysicsList 2");  
  
  // More info from optical processes
  //geant4->ProcessGeantCommand("/mcVerbose/opticalPhysicsList 3");  
  
  // More info from geometry building
  //geant4->ProcessGeantCommand("/mcVerbose/geometryManager 1");  

  // More info from setting geometry properties (in materials and surfaces)
  // for optical physics
  //geant4->ProcessGeantCommand("/mcVerbose/opGeometryManager 1");  
  
  // More info about regions construction 
  // and conversion of VMC cuts in cuts in range per regions 
  // geant4->ProcessGeantCommand("/mcVerbose/regionsManager 2");
  // geant4->ProcessGeantCommand("/mcRegions/print true");
  
  // Suppress verbose info from tracks which reached maximum number of steps
  // (default value is 30000)  
  //geant4->ProcessGeantCommand("/mcTracking/loopVerbose 0"); 
    
  //
  // Set apply cuts 
  // geant4->ProcessGeantCommand("/process/em/applyCuts true");
  // geant4->ProcessGeantCommand("/mcVerbose/geometryManager 2");  
/*
  geant4->ProcessGeantCommand("/mcVerbose/composedPhysicsList 2");  
  geant4->ProcessGeantCommand("/mcDet/volNameSeparator !");
  geant4->ProcessGeantCommand("/mcPhysics/setStackPopperSelection e+ e- pi+ pi- kaon+ kaon- gamma");
  //geant4->ProcessGeantCommand("/tracking/verbose 1");  

  geant4->ProcessGeantCommand("/mcControl/g3Defaults");
!!!!n Generates warnings:
>>> Event 0
G4ProcessTable::Insert : arguments are 0 pointer 
G4ProcessTable::Insert : arguments are 0 pointer 
G4ProcessTable::Insert : arguments are 0 pointer 
G4ProcessTable::Insert : arguments are 0 pointer 
G4ProcessTable::Insert : arguments are 0 pointer 

*/

  // AliRoot event generator
  // (it has to be created after MC, as it may use decayer via VMC)
  //
  gROOT->LoadMacro("$ALICE_ROOT/test/vmctest/ppbench/genPPbenchConfig.C");
  gROOT->LoadMacro("$ALICE_ROOT/test/vmctest/ppbench/genExtFileConfig.C");
            // The event generator selection (srun) is done in genPPbenchConfig.C
            // thatīs why we have to load it too
  genExtFileConfig(srun);

  cout << "Running g4Config.C finished ... " << endl;
}
 g4Config.C:1
 g4Config.C:2
 g4Config.C:3
 g4Config.C:4
 g4Config.C:5
 g4Config.C:6
 g4Config.C:7
 g4Config.C:8
 g4Config.C:9
 g4Config.C:10
 g4Config.C:11
 g4Config.C:12
 g4Config.C:13
 g4Config.C:14
 g4Config.C:15
 g4Config.C:16
 g4Config.C:17
 g4Config.C:18
 g4Config.C:19
 g4Config.C:20
 g4Config.C:21
 g4Config.C:22
 g4Config.C:23
 g4Config.C:24
 g4Config.C:25
 g4Config.C:26
 g4Config.C:27
 g4Config.C:28
 g4Config.C:29
 g4Config.C:30
 g4Config.C:31
 g4Config.C:32
 g4Config.C:33
 g4Config.C:34
 g4Config.C:35
 g4Config.C:36
 g4Config.C:37
 g4Config.C:38
 g4Config.C:39
 g4Config.C:40
 g4Config.C:41
 g4Config.C:42
 g4Config.C:43
 g4Config.C:44
 g4Config.C:45
 g4Config.C:46
 g4Config.C:47
 g4Config.C:48
 g4Config.C:49
 g4Config.C:50
 g4Config.C:51
 g4Config.C:52
 g4Config.C:53
 g4Config.C:54
 g4Config.C:55
 g4Config.C:56
 g4Config.C:57
 g4Config.C:58
 g4Config.C:59
 g4Config.C:60
 g4Config.C:61
 g4Config.C:62
 g4Config.C:63
 g4Config.C:64
 g4Config.C:65
 g4Config.C:66
 g4Config.C:67
 g4Config.C:68
 g4Config.C:69
 g4Config.C:70
 g4Config.C:71
 g4Config.C:72
 g4Config.C:73
 g4Config.C:74
 g4Config.C:75
 g4Config.C:76
 g4Config.C:77
 g4Config.C:78
 g4Config.C:79
 g4Config.C:80
 g4Config.C:81
 g4Config.C:82
 g4Config.C:83
 g4Config.C:84
 g4Config.C:85
 g4Config.C:86
 g4Config.C:87
 g4Config.C:88
 g4Config.C:89
 g4Config.C:90
 g4Config.C:91
 g4Config.C:92
 g4Config.C:93
 g4Config.C:94
 g4Config.C:95
 g4Config.C:96
 g4Config.C:97
 g4Config.C:98
 g4Config.C:99
 g4Config.C:100
 g4Config.C:101
 g4Config.C:102
 g4Config.C:103
 g4Config.C:104
 g4Config.C:105
 g4Config.C:106
 g4Config.C:107
 g4Config.C:108
 g4Config.C:109
 g4Config.C:110
 g4Config.C:111
 g4Config.C:112
 g4Config.C:113
 g4Config.C:114
 g4Config.C:115
 g4Config.C:116
 g4Config.C:117
 g4Config.C:118
 g4Config.C:119
 g4Config.C:120
 g4Config.C:121
 g4Config.C:122
 g4Config.C:123
 g4Config.C:124
 g4Config.C:125
 g4Config.C:126
 g4Config.C:127
 g4Config.C:128
 g4Config.C:129
 g4Config.C:130
 g4Config.C:131
 g4Config.C:132
 g4Config.C:133
 g4Config.C:134
 g4Config.C:135
 g4Config.C:136
 g4Config.C:137
 g4Config.C:138
 g4Config.C:139
 g4Config.C:140
 g4Config.C:141
 g4Config.C:142
 g4Config.C:143
 g4Config.C:144
 g4Config.C:145
 g4Config.C:146
 g4Config.C:147
 g4Config.C:148
 g4Config.C:149
 g4Config.C:150
 g4Config.C:151
 g4Config.C:152
 g4Config.C:153
 g4Config.C:154
 g4Config.C:155
 g4Config.C:156
 g4Config.C:157
 g4Config.C:158
 g4Config.C:159
 g4Config.C:160
 g4Config.C:161
 g4Config.C:162
 g4Config.C:163
 g4Config.C:164
 g4Config.C:165
 g4Config.C:166
 g4Config.C:167
 g4Config.C:168