FairRoot/PandaRoot
sim_ftof_stof.C
Go to the documentation of this file.
1 // Macro created A.Sanchez
2 // It creates a geant simulation file for forward tof wall and side tof plates
3 {
4  TStopwatch timer;
5  timer.Start();
6  gDebug=0;
7  // Load basic libraries
8  // If it does not work, please check the path of the libs and put it by hands
9 
10  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
11  gSystem->Load("libFtof");
12 
13  FairRunSim *fRun = new FairRunSim();
14 
15 
16  TString inFile3= "pbarC_3_GeV.root";
17  double BeamMomentum;
18 
19  BeamMomentum = 15;
20 
21  // set the MC version used
22  // ------------------------
23 
24  fRun->SetBeamMom(BeamMomentum);
25 
26  fRun->SetName("TGeant3");
27 
28  fRun->SetOutputFile("test.root");
29 
30  // Set Material file Name
31  //-----------------------
32 
33  fRun->SetMaterials("media_pnd.geo");
34 
35  // Create and add detectors
36  //-------------------------
37 
38  FairModule *Cave= new PndCave("CAVE");
39  Cave->SetGeometryFileName("cave.geo");
40  fRun->AddModule(Cave);
41 
42 /* FairModule *Magnet= new PndMagnet("MAGNET");
43  Magnet->SetGeometryFileName("magnet.geo");
44  fRun->AddModule(Magnet);
45 
46 
47  FairModule *Dipole= new PndMagnet("MAGNET");
48  Dipole->SetGeometryFileName("dipole.geo");
49  fRun->AddModule(Dipole);
50 
51  */
52  FairDetector *FTof = new PndFtof("FTOF",kTRUE);
53  FTof->SetGeometryFileName("ftofwall+stof.root");
54  fRun->AddModule(FTof);
55  //
56 
57  //--------- FTS --------
58  FairDetector *Fts= new PndFts("FTS", kTRUE);
59  Fts->SetGeometryFileName("fts.geo");
60  fRun->AddModule(Fts);
61 
62 
63  // Create and Set Event Generator
64  //-------------------------------
65 
66  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
67  fRun->SetGenerator(primGen);
68 
69 /*
70  PndUrqmdSmmGenerator* AsciiGen = new PndUrqmdSmmGenerator(inFile3);
71  //primGen->SetTarget(-76.,0.);
72  primGen->AddGenerator(AsciiGen);
73 
74  */
75 
76 // Box Generator:
77  PndBoxGenerator* boxGen = new PndBoxGenerator(13, 10); // 13 = muon; 1 = multipl. // 211 = pi+
78  // first number: PDG particle code: 2nd number: particle multiplicity per event
79  boxGen->SetPRange(.2,7.); // GeV/c
80  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
81  boxGen->SetThetaRange(0., 15.); // Polar angle in lab system range [degree]
82  //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
83  boxGen->SetXYZ(0., 0., 0.); // vertex coordinates [cm]
84  primGen->AddGenerator(boxGen);
85 
86 
87 
89  fRun->SetField(fField);
90 
91 
92  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
93 
94 
95  fRun->Init();
96 
97 
98  // Fill the Parameter containers for this run
99  //-------------------------------------------
100 
101  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
102 
103  PndMultiFieldPar* fieldPar = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
104  if ( fField ) { fieldPar->SetParameters(fField); }
105  fieldPar->setInputVersion(fRun->GetRunId(),1);
106  fieldPar->setChanged();
107 
109  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
110  output->open("simparams.root");
111  rtdb->setOutput(output);
112  rtdb->saveOutput();
113  rtdb->print();
114 
115  // Transport nEvents
116  // -----------------
117 
118  // Set the number of events
119  Int_t nEvents = 100;
120  fRun->Run(nEvents);
121 
122  timer.Stop();
123 
124  Double_t rtime = timer.RealTime();
125  Double_t ctime = timer.CpuTime();
126  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
127  delete fRun;
128  exit(0);
129 
130 }
131 
PndMultiField * fField
Definition: sim_emc_apd.C:97
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
FairDetector * FTof
Definition: sim_ftof.C:49
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
void SetParameters(FairField *field)
exit(0)
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
double BeamMomentum
Definition: sim_ftof_stof.C:17
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
Int_t nEvents
Definition: hit_dirc.C:11
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
gDebug
Definition: sim_emc_apd.C:6
Double_t ctime
Definition: hit_dirc.C:114
FairBoxGenerator * boxGen
Definition: sim_emc_apd.C:85
void SetPRange(Double32_t pmin=0, Double32_t pmax=10)
TString inFile3
Definition: sim_ftof.C:16
Double_t rtime
Definition: hit_dirc.C:113
FairDetector * Fts
Definition: sim_ftof_stof.C:58
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Definition: PndFts.h:25
Definition: PndCave.h:8