]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - macros/g4menu.C
PAR: includes from previously enabled PARfiles
[u/mrichter/AliRoot.git] / macros / g4menu.C
index 0f8eb4f2a42137c651176f97fab26e11192a049d..5e55d13b89d63d813c8fcf03841886c8fd1df581 100644 (file)
@@ -5,13 +5,19 @@
 //  To run aliroot with Geant4 using the g4menu.C:
 //  aliroot
 //  root [0] .x g4menu.C
-//  --> Select "Init" and then "Run" button
+//  --> First select "Geometry" to build geometry.root file
+//  --> Then re-run aliroot and select "Run" button
 //         
-// The the bar enables to start Geant4 interactive session:
+// The Init button is kept for debugging purposes,
+// it itializes MonteCarlo but it does not itialize
+// completely ALICE framework. That's why to run simulation,
+// you have to re-run aliroot and select Run button.
+//
+// The menu enables to start Geant4 interactive session:
 //  --> Select "Geant4UI" button and use Geant4 interactive commands;
-//      In case TGeant4 has not yet been created you need first
-//      select "Geant4" button before selecting  "Geant4UI".       
 // To go back to Root UI, type exit.
+//
+// By I. Hrivnacova, IPN Orsay
 
 
 #include <iostream>
@@ -24,34 +30,122 @@ void g4menu()
     gROOT->LoadMacro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
   gInterpreter->ProcessLine("g4libs()");
 
+  // Load ALICE Geant4 library
+  //cout << "Loading g4alice library ..." << endl;
+  //gSystem->Load("libg4alice");
+
   // Menu
   TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu");
   
-  menu->AddButton("Init",     "gAlice->Init(\"g4Config.C\")", "Initialize \" AliRun \"");
-  menu->AddButton("Run",      "gAlice->Run()",  "Process Alice run");
-  menu->AddButton("Geant4",   "CreateGeant4()", "Create Geant4 only (without initializing AliRun)");
+  menu->AddButton("Geometry", "MakeGeometry()",  "Generate Root geometry file");
+  menu->AddButton("Run G4",   "RunG4Simulation()",  "Process Alice run");
+  menu->AddButton("Run G4 batch",   "RunG4Simulation(); >& g4.out",  "Process Alice run");
+  menu->AddButton("Run G3",   "RunG3Simulation()",  "Process Alice run");
+  menu->AddButton("Run G3 batch",   "RunG3Simulation(); >& g3.out",  "Process Alice run");
+  menu->AddButton("Init",     "Init();",  "Initialize Alice for G4 simulation");
+  menu->AddButton("Init batch","Init(); >& g4init.out",  "Initialize Alice for G4 simulation");
   menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
+  menu->AddButton("AGDD",     "GenerateAGDD()","Generate XML (AGDD) file with geometry description");
+  //menu->AddButton("GDML",     "GenerateGDML()","Generate XML (GDML) file with geometry description");
+  menu->AddButton("Quit",     "Quit()", "Quit aliroot");
   gROOT->SaveContext();
+  
+  cout << endl
+       << "**************************************************************" << endl
+       << "  To run simulation:"                                           << endl
+       << "  First select <Geometry> to build geometry.root file."         << endl
+       << "  Then re-run aliroot and select <Run> button"                  << endl
+       << endl
+       << "  The <Init> button is kept for debugging purposes,"            << endl
+       << "  it itializes MonteCarlo but it does not itialize"             << endl
+       << "  completely ALICE framework. That's why to run simulation,"    << endl
+       << "  you have to re-run aliroot and select Run button."            << endl
+       << endl
+       << "  The menu enables to start Geant4 interactive session:"        << endl
+       << "  Select <Geant4UI> button and use Geant4 interactive commands" << endl
+       << "  To go back to Root UI, type exit."                            << endl
+       << "**************************************************************" << endl
+       << endl;
+  
   menu->Show();
 }
 
-void CreateGeant4()
+void MakeGeometry()
 {  
-  if (!gMC) {
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  man->SetRun(1);
+
+  // MC application initialization
+  TString configFileName = "$ALICE_ROOT/macros/g4ConfigGeometry.C";
+  gROOT->LoadMacro(configFileName.Data());
+  gInterpreter->ProcessLine(gAlice->GetConfigFunction());
+  gAlice->GetMCApp()->Init();
   
-     // TG4RunConfiguration for Geant4
-     TG4RunConfiguration* runConfiguration 
-      = new TG4RunConfiguration(true);
+  // Generate geometry file
+  //
+  gGeoManager->Export("geometry.root");
   
-    // TGeant4
-    TGeant4* geant4
-      = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
-
-    cout << "Geant4 has been created." << endl;
-   }      
-  else {
-    cout << "Monte Carlo has been already created." << endl;
-  }       
+  cout << endl
+       << "Geometry file geometry.root has been generated." << endl
+       << "You have to re-run aliroot and choose Run in g4menu." << endl;
+       
+  exit(0);     
+}    
+
+
+void Init()
+{  
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  man->SetRun(0);
+  // MC application initialization
+  TString configFileName = "$ALICE_ROOT/macros/g4Config.C";
+  gROOT->LoadMacro(configFileName.Data());
+  gInterpreter->ProcessLine(gAlice->GetConfigFunction());
+  gAlice->GetMCApp()->Init();
+
+  ((TGeant4*)gMC)->ProcessGeantCommand("/mcDet/printMedia");
+
+  cout << endl
+       << "Only MonteCarlo initialization has been performed. " << endl
+       << "To run simulation you have to re-run aliroot and choose Run in g4menu." << endl;
+}    
+
+
+void RunG4Simulation()
+{  
+  AliSimulation sim("$ALICE_ROOT/macros/g4Config.C");
+  sim.SetMakeSDigits("");
+  sim.SetMakeDigits("");
+  //sim.SetMakeDigitsFromHits("ITS TPC");
+  //sim.SetMakeDigitsFromHits("ITS");
+  sim.SetMakeDigitsFromHits("");
+  sim.SetRunHLT("");
+  sim.SetNumberOfEvents(1000);
+  TStopwatch timer;
+  timer.Start();
+  sim.Run(1);
+  timer.Stop();
+  timer.Print();
+}    
+
+void RunG3Simulation()
+{  
+  AliSimulation sim("$ALICE_ROOT/macros/g3Config.C");
+  sim.SetMakeSDigits("");
+  sim.SetMakeDigits("");
+  //sim.SetMakeDigitsFromHits("ITS TPC");
+  //sim.SetMakeDigitsFromHits("ITS");
+  sim.SetMakeDigitsFromHits("");
+  sim.SetRunHLT("");
+  sim.SetNumberOfEvents(1000);
+  TStopwatch timer;
+  timer.Start();
+  sim.Run(1);
+  timer.Stop();
+  timer.Print();
 }    
 
 void StartGeant4UI()
@@ -73,4 +167,54 @@ void StartGeant4UI()
   else {  
     cout << "Monte Carlo has not been yet created." << endl;
   }       
+} 
+
+void GenerateAGDD()
+{
+  if (gMC) {
+    // release Root terminal control
+
+    // go into non-raw term mode
+    //Getlinem(kCleanUp, 0);
+    
+    // add test if gMC is TGeant4
+    TGeant4* g4 = (TGeant4*)gMC;
+    
+    g4->ProcessGeantCommand("/vgm/generateAGDD");
+
+    // new Root prompt
+    //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());  
+  }
+  else {  
+    cout << "Monte Carlo has not been yet created." << endl;
+  } 
+}        
+/*
+void GenerateGDML()
+{
+  if (gMC) {
+    // release Root terminal control
+
+    // go into non-raw term mode
+    //Getlinem(kCleanUp, 0);
+    
+    // add test if gMC is TGeant4
+    TGeant4* g4 = (TGeant4*)gMC;
+    
+    g4->ProcessGeantCommand("/vgm/generateGDML");
+
+    // new Root prompt
+    //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());  
+  }
+  else {  
+    cout << "Monte Carlo has not been yet created." << endl;
+  } 
+}        
+*/
+void Quit()
+{
+  delete AliRunLoader::Instance();
+  delete gAlice;
+  
+  exit(0);
 }