FairRoot/PandaRoot
production/scripts/prod_sim.C
Go to the documentation of this file.
1 // Macro for running Panda simulation with Geant3 or Geant4 (M. Al-Turany)
2 // This macro is supposed to run the full simulation of the panda detector
3 // It takes basic parameter as input for flexible use
4 //
5 // to print usage information:
6 // root -l -b -q prod_sim.C
7 //
8 // to run with specific setting:
9 // root -l -b -q 'prod_sim.C("EvtD0D0b", 100, "D0toKpi.dec:pbarpSystem0", 12.)'
10 // root -l -b -q 'prod_sim.C("DpmInel", 100, "DPM", 12.)'
11 // root -l -b -q 'prod_sim.C("Box1Kp", 100, "BOX:type(321,1):p(0.1,10):tht(22,140):phi(0,360)",1.)'
12 
13 int prod_sim(TString prefix="", Int_t nEvents = 100, TString inputGen="", Float_t pbeam = 0. )
14 {
15  if (prefix=="" || inputGen=="" || pbeam==0.)
16  {
17  cout << "USAGE:\n";
18  cout << "prod_sim.C( <pref>, <nevt>, <gen>, <pbeam> )\n\n";
19  cout << " <pref> : output file names prefix\n";
20  cout << " <nevt> : number of events\n";
21  cout << " <gen> : generator input: EvtGen decfile; DPM/FTF/BOX uses DPM/FTF generator (inelastic mode) or BOX generator instead\n";
22  cout << " DPM settings: DPM = inelastic only, DPM1 = inel. + elastic, DPM2 = elastic only\n";
23  cout << " FTF settings: FTF = inel. + elastic, FTF1 = inelastic only\n";
24  cout << " BOX settings: type[pdgcode,mult] and optional ranges 'p/tht/phi[min,max]' separated with colon; example: 'BOX:type[211,1]:p[1,5]:tht[45]:phi[90,210]'\n";
25  cout << " <pbeam> : pbar momentum (for BOX generator it still controls the magnetic field) \n\n";
26  // cout << " <opt> : option string for PndRunAna (e.g. \"day1\")\n\n";
27  cout << "Example 1 : root -l -b -q 'prod_sim.C(\"EvtD0D0b\", 100, \"D0toKpi.dec:pbarpSystem0\", 12.)'\n";
28  cout << "Example 2 : root -l -b -q 'prod_sim.C(\"DpmInel\", 100, \"DPM\", 12.)'\n";
29  cout << "Example 3 : root -l -b -q 'prod_sim.C(\"SingleK\", 100, \"BOX:type[321,1]:p[0.1,10]:tht[22,140]:phi[0,360]\", 12.)'\n\n";
30 
31  return 0;
32  }
33 
34  // set random random seed
35  gRandom->SetSeed();
36 
37  // runsim option
38  TString opt="PndFiltPrim"; // for PndFilteredPrimaryGenerator the options must contain this key word
39 
40  double mp = 0.938272;
41 
42  // if pbeam<0, it's -E_cm -> compute momentum
43  if (pbeam<0)
44  {
45  double X = (pbeam*pbeam-2*mp*mp)/(2*mp);
46  pbeam = sqrt(X*X-mp*mp);
47  }
48 
49  // Allow shortcut for resonance
50  if (inputGen.Contains(":pbp")) inputGen.ReplaceAll(":pbp",":pbarpSystem");
51 
52  //-----User Settings:-----------------------------------------------
53  TString SimEngine = "TGeant3";
54  TString Workdir = gSystem->Getenv("VMCWORKDIR");
55  TString parAsciiFile = "all.par";
56 
57  // ---- check flag for DPM/FTF -------------------------------------
58  Int_t genflag = 0;
59  if (inputGen=="DPM1" || inputGen=="FTF1") genflag=1;
60  if (inputGen=="DPM2") genflag=2;
61 
62  //-------------------------------------------------------------------------
63  // ----- Create the Simulation run manager ------------------------------
65  fRun->SetInput(inputGen);
66  fRun->SetDpmFlag(genflag);
67  fRun->SetFtfFlag(genflag);
68  fRun->SetName(SimEngine);
69  fRun->SetParamAsciiFile(parAsciiFile);
71  fRun->SetBeamMom(pbeam);
72  if (opt!="") fRun->SetOptions(opt);
73  // ----- Initialization ------------------------------------------------
74  fRun->Setup(prefix);
75  // ----- Geometry -----------------------------------------------------
76  fRun->CreateGeometry();
77  // ----- Event generator ----------------------------------------------
78  fRun->SetGenerator();
79 
80  // ----- Event filter setup -------------------------------------------
81  // fetch the PndFilteredPrimaryGenerator (only existing if option contains 'PndFiltPrim')
83  // ---- Example configuration for the event filter ------------------------
84  //primGen->SetVerbose(1);
85  //primGen->AddFilter("(t+-;4..) && M(e+ e-; m[3.1,0.6])"); //require 4 tracks and at least one e+e- candidate in mass window [2.8,3.4]
86 
87  // ----- Add tasks ----------------------------------------------------
88  fRun->AddSimTasks();
89  // ----- Intialise and run --------------------------------------------
90  fRun->Init();
91  fRun->Run(nEvents);
92  fRun->Finish();
93 
94  return 0;
95 }
96 
void Finish()
Final diagnostics.
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Bool_t Setup(TString outprefix="")
Initial setup.
PndFilteredPrimaryGenerator * GetPndFilteredPrimaryGenerator()
void SetParamAsciiFile(TString par)
Setter of the parameter ascii file.
static const double mp
Definition: mzparameters.h:11
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
void SetInput(TString par)
Input of the simulation This string can be: a) the name of the dec file for EvtGen, ending w/ .dec b) &quot;dpm&quot; if you want to use dpm c) &quot;ftf&quot; if you want to use ftf d) &quot;box:[...]&quot; if you want to use box.
FairRunAna * fRun
Definition: hit_dirc.C:58
void AddSimTasks()
Add simulation tasks.
Int_t nEvents
Definition: hit_dirc.C:11
Primary generator with added event filtering capabilities.
void SetNumberOfEvents(Int_t par)
Setter of the number of events.
void CreateGeometry()
It switches between different standard geometry volumes.
Class for the master simulation chain.
double X
Definition: anaLmdDigi.C:68
void SetOptions(TString par)
Setter of the simulation options This string can be: &quot;&quot; -&gt; default settings full setup &quot;day1&quot; -&gt; Set...
void SetFtfFlag(Int_t Mode)
Set the FTF noelastic flag.
int prod_sim(TString prefix="", Int_t nEvents=100, TString inputGen="", Float_t pbeam=0.)
void SetGenerator()
Set the event generator.
void SetDpmFlag(Int_t Mode)
Set the DPM flag.