FairRoot/PandaRoot
outdated/endrc/run_sim.C
Go to the documentation of this file.
1 // Macro for running Cbm with Geant3 or Geant4 (M. Al-Turany , D. Bertini)
2 // Modified 22/06/2005 D.Bertini
3 {
4  TStopwatch timer;
5  timer.Start();
6  gDebug=0;
7  // Load basic libraries
8  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
9 
10 
11  gSystem->Load("libEnDrc"); // our library
12 
13  FairRunSim *fRun = new FairRunSim();
14 
15  // set the MC version used
16  // ------------------------
17 
18  fRun->SetName("TGeant3");
19  // Choose the Geant Navigation System
20  // fRun->SetGeoModel("G3Native");
21 
22  fRun->SetOutputFile("testsimu10.root");
23 
24 
25  // Set Material file Name
26  //-----------------------
27 
28  fRun->SetMaterials("media_pnd.geo");
29 
30  // Create and add detectors
31  //-------------------------
32 
33  FairModule *Cave= new PndCave("CAVE");
34  Cave->SetGeometryFileName("pndcave.geo");
35  fRun->AddModule(Cave);
36 
37 // FairModule *Magnet= new PndMagnet("MAGNET");
38 // Magnet->SetGeometryFileName("magnet.geo");
39 // fRun->AddModule(Magnet);
40 
41 
42 // FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE);
43 // Mvd->SetGeometryFileName("MVD14.root");
44 // fRun->AddModule(Mvd);
45 
46 
47 // FairDetector *PndTpc = new PndTpcDetector("TPC", kTRUE);
48 // PndTpc->SetGeometryFileName("tpc.geo");
49 // fRun->AddModule(PndTpc);
50 
51 
52 // FairDetector *Emc = new PndEmc("EMC",kTRUE);
53 // Emc->SetGeometryFileName("emc_module12345.dat");
54 // //Emc->SetGeometryFileName("emc_module3.root");
55 // fRun->AddModule(Emc);
56 // // FairDetector *Muo = new PndMuo("MUO",kTRUE);
57 // // Muo->SetGeometryFileName("muon_super_light2.geo");
58 // // fRun->AddModule(Muo);
59 
60 
61 // FairDetector *Drc = new PndDrc("DIRC", kTRUE);
62 // Drc->SetGeometryFileName("dirc.geo");
63 // fRun->AddModule(Drc);
64 
65 
66  //And add the enddrc
67  FairDetector* Dsk = new PndEnDrc("EDRC", kTRUE);
68  Dsk->SetGeometryFileName("endrc.root");
69  fRun->AddModule(Dsk);
70 
71  // Create and Set Event Generator
72  //-------------------------------
73 
74  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
75  fRun->SetGenerator(primGen);
76 
77  // Urqmd Generator
78  // FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator("../../input/00-03fm.100ev.f14");
79  // primGen->AddGenerator(urqmdGen);
80 
81  // Particle Generator
82  //FairParticleGenerator* partGen = new FairParticleGenerator(13, 1, 0.5, 0., 0.);
83  //primGen->AddGenerator(partGen);
84 
85  // Box Generator
86  FairBoxGenerator* pGen = new FairBoxGenerator(2212, 1); // 13 = muon; 1 = multipl.
87  pGen->SetPRange(0.5,6.); // GeV/c
88  // boxGen->SetPtRange(1.,1.); // GeV/c
89  pGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
90  pGen->SetThetaRange(0., 25.); // Polar angle in lab system range [degree]
91  pGen->SetXYZ(0., 0., 0.); // mm o cm ??
92  primGen->AddGenerator(pGen);
93  FairBoxGenerator* piplGen = new FairBoxGenerator(211, 1); // 13 = muon; 1 = multipl.
94  piplGen->SetPRange(0.5,6.); // GeV/c
95  // boxGen->SetPtRange(1.,1.); // GeV/c
96  piplGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
97  piplGen->SetThetaRange(0., 25.); // Polar angle in lab system range [degree]
98  piplGen->SetXYZ(0., 0., 0.); // mm o cm ??
99  primGen->AddGenerator(piplGen);
100  FairBoxGenerator* pimiGen = new FairBoxGenerator(-211, 1); // 13 = muon; 1 = multipl.
101  pimiGen->SetPRange(0.5,6. ); // GeV/c
102  // boxGen->SetPtRange(1.,1.); // GeV/c
103  pimiGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
104  pimiGen->SetThetaRange(0., 25.); // Polar angle in lab system range [degree]
105  pimiGen->SetXYZ(0., 0., 0.); // mm o cm ??
106  primGen->AddGenerator(pimiGen);
107  FairBoxGenerator* KplGen = new FairBoxGenerator(321, 1); // 13 = muon; 1 = multipl.
108  KplGen->SetPRange(0.5,6. ); // GeV/c
109  // boxGen->SetPtRange(1.,1.); // GeV/c
110  KplGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
111  KplGen->SetThetaRange(0., 25.); // Polar angle in lab system range [degree]
112  KplGen->SetXYZ(0., 0., 0.); // mm o cm ??
113  primGen->AddGenerator(KplGen);
114  FairBoxGenerator* KmiGen = new FairBoxGenerator(-211, 1); // 13 = muon; 1 = multipl.
115  KmiGen->SetPRange(0.5,6. ); // GeV/c
116  // boxGen->SetPtRange(1.,1.); // GeV/c
117  KmiGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
118  KmiGen->SetThetaRange(0., 25.); // Polar angle in lab system range [degree]
119  KmiGen->SetXYZ(0., 0., 0.); // mm o cm ??
120  primGen->AddGenerator(KmiGen);
121  // proton 2212 pi+ 211 pi- -211
122 // Double_t randx, randy;
123 // for (Int_t n =0; n<1; n++){
124 // randx= gRandom->Gaus(0,1);
125 // randy= gRandom->Gaus(0,1);
126 // FairParticleGenerator* partGen = new FairParticleGenerator(2212, 1, 1*randx, 1*randy, 3.);
127 // primGen->AddGenerator(partGen);
128 // partGen = new FairParticleGenerator(321, 1, 1*randx, 1*randy, 3.);
129 // primGen->AddGenerator(partGen);
130 // partGen = new FairParticleGenerator(-321, 1, 1*randx, 1*randy, 3.);
131 // primGen->AddGenerator(partGen);
132 // partGen = new FairParticleGenerator(211, 1, 1*randx, 1*randy, 3.);
133 // primGen->AddGenerator(partGen);
134 // partGen = new FairParticleGenerator(-211, 1, 1*randx, 1*randy, 3.);
135 // primGen->AddGenerator(partGen);
136 // }
137 
138 
139  // Ion Generator
140  //FairIonGenerator *fIongen= new FairIonGenerator(79, 197,79,1, 0.,0., 25, 0.,0.,-1.);
141  // primGen->AddGenerator(fIongen);
142 
143 
144  //
145  fRun->SetStoreTraj(kTRUE);
146 
148 
149  PndTransMap *map= new PndTransMap("TransMap", "R");
150  PndDipoleMap *map1= new PndDipoleMap("DipoleMap", "R");
151  PndSolenoidMap *map2= new PndSolenoidMap("SolenoidMap", "R");
152  fField->AddField(map);
153  fField->AddField(map1);
154  fField->AddField(map2);
155 
156  //magnetic field
157  /* PndConstField *fMagField=new PndConstField();
158  fMagField->SetField(0.,0.,20.); // values are in kG
159  fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);// values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
160  fField->AddField(fMagField);
161  */
162  fRun->SetField(fField);
163 
164 
165 
166  fRun->Init();
167 
168  // -Trajectories Visualization
169  // ----------------------------
170  FairTrajFilter* trajFilter = FairTrajFilter::Instance();
171  // Set cuts for storing the trajectpries
172  trajFilter->SetStepSizeCut(0.01); // 1 cm
173 // trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.);
174 // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
175 // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
176  trajFilter->SetStorePrimaries(kTRUE);
177  trajFilter->SetStoreSecondaries(kTRUE);
178 
179 //
180 // // Fill the Parameter containers for this run
181 // //-------------------------------------------
182 //
183  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
185 
186 
187 
188 
189  //if a field is used save the parameters in the RTDB
190 /*
191  PndSolenoidPar* Par1 = (PndSolenoidPar*) rtdb->getContainer("PndSolenoidPar");
192  if ( map2 ) { Par1->SetParameters(map2); }
193  Par1->setChanged();
194  Par1->setInputVersion(fRun->GetRunId(),1);
195 
196  PndDipolePar* Par2 = (PndDipolePar*) rtdb->getContainer("PndDipolePar");
197  if (map1 ) { Par2->SetParameters(map1); }
198  Par2->setInputVersion(fRun->GetRunId(),1);
199  Par2->setChanged();
200 
201  PndTransPar* Par3 = (PndTransPar*) rtdb->getContainer("PndTransPar");
202  if (map ) { Par3->SetParameters(map); }
203  Par3->setInputVersion(fRun->GetRunId(),1);
204  Par3->setChanged();
205  */
206 
207  PndMultiFieldPar* Par = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
208  if (fField) { Par->SetParameters(fField); }
209  Par->setInputVersion(fRun->GetRunId(),1);
210  Par->setChanged();
211 
212  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
213  output->open("testparams.root");
214  rtdb->setOutput(output);
215  rtdb->saveOutput();
216  rtdb->print();
217  // Transport nEvents
218  // -----------------1
219 
220  Int_t nEvents = 1;
221  fRun->Run(nEvents);
222 
223  timer.Stop();
224 
225  Double_t rtime = timer.RealTime();
226  Double_t ctime = timer.CpuTime();
227  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
228 
229  cout << " Test passed" << endl;
230  cout << " All ok " << endl;
231  exit(0);
232 
233 }
234 
FairTrajFilter * trajFilter
Definition: run_DpmSim.C:112
PndMultiField * fField
Definition: sim_emc_apd.C:97
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
PndSolenoidMap * map2
Definition: sim_emc_apd.C:101
FairBoxGenerator * pGen
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
FairBoxGenerator * pimiGen
void SetParameters(FairField *field)
PndTransMap * map
Definition: sim_emc_apd.C:99
exit(0)
FairBoxGenerator * KmiGen
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairDetector * Dsk
Definition: run_DpmSim.C:66
FairRunAna * fRun
Definition: hit_dirc.C:58
FairBoxGenerator * KplGen
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
gDebug
Definition: sim_emc_apd.C:6
FairBoxGenerator * piplGen
Double_t ctime
Definition: hit_dirc.C:114
new FairTrajFilter()
PndDipoleMap * map1
Definition: sim_emc_apd.C:100
PndMultiFieldPar * Par
Definition: sim_emc_apd.C:115
void AddField(FairField *field)
Double_t rtime
Definition: hit_dirc.C:113
Definition: PndCave.h:8