FairRoot/PandaRoot
sim_dsk.C
Go to the documentation of this file.
2  TString the_RunName = "test"
3 )
4 {
5  TString fGeantVersion = "TGeant4"; // simulation to run
6 
7  TString fOutFile = TString("./sim_dsk.").Append(the_RunName).Append(".root");
8  TString fMediaFile = "media_pnd.geo";
9  TString fGeoFile = "dsk.root";
10  Int_t fParticle = 211; // pi+
11 
12  Double_t fPMin = 2.; // momentum in Gev/c for the created particle
14 
15  Bool_t fStoreGeoTraj = kTRUE;
16  Bool_t fStoreDskTraj = kTRUE;
17  Bool_t fStoreCerenkovs = kTRUE;
18  Int_t fNofEvents = 1;
19 
20  // set coords
21  Double_t fDiskDistanzZ = 196.;
22  Double_t fHitX; Double_t fHitY; Double_t fHitZ; // [cm]
23  Double_t fHitTheta; Double_t fHitPhi; // [degree]
25  TVector3 fVertexPos;
26  // by angle
27  fHitTheta = 15.;
28  fHitPhi = 0.;
29  fHitX = fDiskDistanzZ*TMath::Tan(fHitTheta*TMath::DegToRad())*TMath::Cos(fHitPhi*TMath::DegToRad());
30  fHitY = fDiskDistanzZ*TMath::Tan(fHitTheta*TMath::DegToRad())*TMath::Sin(fHitPhi*TMath::DegToRad());
31  fHitZ = fDiskDistanzZ;
32  fVertexPos.SetXYZ(fHitX,fHitY,fHitZ);
33  fVertexPos *= (fDiskDistanzZ-1.)/fDiskDistanzZ; // one cm before disk
34  fThetaMin = fHitTheta;
35  fThetaMax = fThetaMin;
36  fPhiMin = fHitPhi;
37  fPhiMax = fPhiMin;
38  // by position
39 // fHitX = 0.;
40 // fHitY = 60.;
41 // fHitZ = fDiskDistanzZ;
42 // fVertexPos.SetXYZ(fHitX,fHitY,fHitZ);
43 // fVertexPos *= (fDiskDistanzZ-1.)/fDiskDistanzZ; // one cm before disk
44 // fHitTheta = fVertexPos.Theta()*TMath::RadToDeg();
45 // fHitPhi = fVertexPos.Phi()*TMath::RadToDeg();
46 // fThetaMin = fHitTheta;
47 // fThetaMax = fThetaMin;
48 // fPhiMin = fHitPhi;
49 // fPhiMax = fPhiMin;
50  // by range
51 // fVertexPos.SetXYZ(0.,0.,0.);
52 // fThetaMin = 15.;
53 // fThetaMax = fThetaMin;
54 // fPhiMin = 0.;
55 // fPhiMax = fPhiMin;
56 
57 
58 
59 
60 
61 
62 
63 
64 
65  TStopwatch timer;
66  timer.Start();
67  gDebug=0;
68 
69  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
70  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
71  rootlogon();
72  basiclibs();
73 
74  gSystem->Load("libDsk");
75 
76  FairRunSim* fRun = 0;
77  if (0 != (FairRunSim::Instance())) {
78  cout << "[ ** ] FairRunSim instance found. Please restart root." << endl;
79  return;
80  } else {
81  fRun = new FairRunSim();
82  }
83 
84  fRun->SetName(fGeantVersion);
85  fRun->SetOutputFile(fOutFile);
86  fRun->SetMaterials(fMediaFile);
87 
88  // --- Modules ---------------------------------------------------------------
89 
90  FairModule *Cave= new PndCave("CAVE");
91  Cave->SetGeometryFileName("pndcave.geo");
92  fRun->AddModule(Cave);
93 
94  PndDsk* Dsk = new PndDsk("DSK", kTRUE);
95  Dsk->SetGeometryFileName(fGeoFile);
96  Dsk->SetStoreCerenkovs(fStoreCerenkovs);
97  Dsk->SetStoreTrackPoints(fStoreDskTraj);
98  fRun->AddModule(Dsk);
99 
100 // FairModule *Pipe= new PndPipe("PIPE");
101 // Pipe->SetGeometryFileName("pipe.geo");
102 // fRun->AddModule(Pipe);
103 
104 // PndDrc *Drc = new PndDrc("DIRC", kTRUE);
105 // Drc->SetRunCherenkov(kTRUE);
106 // fRun->AddModule(Drc);
107 
108 
109 
110  // --- Generators ------------------------------------------------------------
111 
112  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
113  fRun->SetGenerator(primGen);
114 
115  FairBoxGenerator* boxGen = new FairBoxGenerator(fParticle, 1);
116  boxGen->SetXYZ(fVertexPos.X(),fVertexPos.Y(),fVertexPos.Z());
117  boxGen->SetPRange(fPMin, fPMax); // momentum GeV/c
118  boxGen->SetPhiRange(fPhiMin, fPhiMax); // Azimuth angle range [degree]
119  boxGen->SetThetaRange(fThetaMin, fThetaMax); // Polar angle in lab system range [degree]
120  primGen->AddGenerator(boxGen);
121 
122  // --- Trajectories ----------------------------------------------------------
123 
124  fRun->SetStoreTraj(fStoreGeoTraj);
125 
126  // --- Fields ----------------------------------------------------------------
127 
128  // --- Init ------------------------------------------------------------------
129 
130  fRun->Init();
131 
132  // --- RuntimeDB -------------------------------------------------------------
133 
134  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
135  Bool_t kParameterMerged = kTRUE;
136  FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged);
137  output->open(TString("./simparams.").Append(the_RunName).Append(".root").Data());
138  rtdb->setOutput(output);
139  rtdb->saveOutput();
140  rtdb->print();
141 
142  // --- Run -------------------------------------------------------------------
143 
144  fRun->Run(fNofEvents);
145 
146  timer.Stop();
147 
148  Double_t rtime = timer.RealTime();
149  Double_t ctime = timer.CpuTime();
150  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
151 
152 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
basiclibs()
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
static T Sin(const T &x)
Definition: PndCAMath.h:42
float Tan(float x)
Definition: PndCAMath.h:165
static T Cos(const T &x)
Definition: PndCAMath.h:43
Double_t fThetaMin
Definition: run_full.C:19
Double_t fPMin
Definition: run_full.C:16
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairDetector * Dsk
Definition: run_DpmSim.C:66
TString fOutFile
Definition: run_full.C:10
FairRunAna * fRun
Definition: hit_dirc.C:58
Int_t * fParticle
Definition: run_full.C:24
void SetStoreTrackPoints(Bool_t storeTrackPoints)
Definition: PndDsk.h:148
void SetStoreCerenkovs(Bool_t storeCerenkovs)
Definition: PndDsk.h:146
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
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
TString fMediaFile
Definition: run_full.C:11
Double_t fPMax
Definition: run_full.C:18
TString fGeantVersion
Definition: run_full.C:14
Double_t fThetaMax
Definition: run_full.C:21
sim_dsk(TString the_RunName="test")
Definition: sim_dsk.C:1
Double_t rtime
Definition: hit_dirc.C:113
TString fGeoFile
Definition: PndDsk.h:23
Definition: PndCave.h:8