FairRoot/PandaRoot
runMC1.C
Go to the documentation of this file.
1 {
2  TStopwatch timer;
3  timer.Start();
4  gDebug=0;
5  // Load basic libraries
6  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
7  basiclibs();
8 
9  // Load this example libraries
10  gSystem->Load("libGeoBase");
11  gSystem->Load("libParBase");
12  gSystem->Load("libBase");
13  gSystem->Load("libField");
14  gSystem->Load("libPndData");
15  gSystem->Load("libPassive");
16  gSystem->Load("libStt");
17  gSystem->Load("libPlane");
18  gSystem->Load("libGen");
19  gSystem->Load("libPGen");
20 
21  FairRunSim *fRun = new FairRunSim();
22 
23  // set the MC version used
24  // ------------------------
25 
26  fRun->SetName("TGeant3");
27 
28  fRun->SetOutputFile("ex1.root");
29 
30 
31  // Set Material file Name
32  //-----------------------
33 
34  fRun->SetMaterials("media_pnd.geo");
35 
36  // Create and add detectors
37  //-------------------------
38 
39  FairModule *Cave= new PndCave("CAVE");
40  Cave->SetGeometryFileName("cave.geo");
41  fRun->AddModule(Cave);
42 
43  FairDetector *Pla = new CbmPlane("Plane", kTRUE);
44  Pla->SetGeometryFileName("plane3.geo");
45  fRun->AddModule(Pla);
46 
47  // FairDetector *Stt = new PndStt("STT", kTRUE);
48 // Stt->SetGeometryFileName("optimized_stt.geo");
49 // Stt->SetGeometryFileName("straws_skewed_blocks.geo");
50 // fRun->AddModule(Stt);
51 
52  // Create and Set Event Generator
53  //-------------------------------
54 
55  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
56  fRun->SetGenerator(primGen);
57 
59  boxGen->SetPRange(1.5,1.5); // GeV/c
60  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
61  boxGen->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
62  boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
63  // boxGen->SetXYZ(0., 0., 0.); // vertex coordinates [cm]
64  primGen->AddGenerator(boxGen);
65 
66  //magnetic field
68  fMagField->SetField(0.,0.,20.); // values are in kG
69  fMagField->SetFieldRegion(-150, 150, -150, 150, -250, 250);// values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
70  fRun->SetField(fMagField);
71 
72 
73  fRun->Init();
74 
75  // Fill the Parameter containers for this run
76  //-------------------------------------------
77 
78  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
80  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
81  output->open("ex1params.root");
82  rtdb->setOutput(output);
83 
84  PndConstPar* fieldPar = (PndConstPar*) rtdb->getContainer("PndConstPar");
85  if ( fMagField ) { fieldPar->SetParameters(fMagField); }
86  fieldPar->setInputVersion(fRun->GetRunId(),1);
87  fieldPar->setChanged(kTRUE);
88 
89  rtdb->saveOutput();
90  rtdb->print();
91 
92  // Transport nEvents
93  // -----------------
94 
95  Int_t nEvents = 1000;
96  fRun->Run(nEvents);
97 
98  timer.Stop();
99 
100  Double_t rtime = timer.RealTime();
101  Double_t ctime = timer.CpuTime();
102  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
103 }
104 
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
basiclibs()
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairRunAna * fRun
Definition: hit_dirc.C:58
PndConstField * fMagField
Definition: runSimHF_ptr.C:154
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Int_t nEvents
Definition: hit_dirc.C:11
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
TStopwatch timer
Definition: hit_dirc.C:51
void SetParameters(FairField *field)
Definition: PndConstPar.cxx:54
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)
Double_t rtime
Definition: hit_dirc.C:113
FairDetector * Pla
Definition: runMC1.C:43
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Definition: PndCave.h:8