FairRoot/PandaRoot
Functions
sim_hypGe_TestGeo.C File Reference

Go to the source code of this file.

Functions

int sim_hypGe_TestGeo (Int_t nEvents, Int_t WhichDetector, Double_t Energy, Bool_t addSecTar)
 

Function Documentation

int sim_hypGe_TestGeo ( Int_t  nEvents,
Int_t  WhichDetector,
Double_t  Energy,
Bool_t  addSecTar 
)

Definition at line 3 of file sim_hypGe_TestGeo.C.

References Bool_t, boxGen, boxGen2, Cave, ctime, Double_t, fRun, gDebug, Hyp, HypGe, kParameterMerged, nam, nEvents, outFile, output, primGen, printf(), rtdb, rtime, PndHypGe::SetPathGeo(), PndBoxGenerator::SetPhiRange(), PndBoxGenerator::SetPRange(), PndHyp::SetSensorVol(), PndBoxGenerator::SetThetaRange(), PndBoxGenerator::SetXYZ(), timer, and TString.

4 {
5  // Load basic libraries
6  // If it does not work, please check the path of the libs and put it by hands
7  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
8  gSystem->Load("libHypGe");
9  gSystem->Load("libHyp");
10  FairRunSim *fRun = new FairRunSim();
11 
12  TStopwatch timer;
13  timer.Start();
14  gDebug=0;
15 
16  //Choose geometry
17  TString outFile="$SIMDATADIR/GeantTest/"; // If no SIMDATADIR, same folder as the macro
18  TString GeoFile;
19 
20  GeoFile = "hypGeGeoGeantTestGeometry.root";
21  outFile += "hypGeGeoGeantTestGeometry_";
22 
23  // Set the number of events
24 
25  // Set the gamma energy
26 
27  // choose Co60
28  bool isCo60 = false;
29  //compose the name of the output file and the simparams file
30 
31  if (!isCo60)
32  {
33  outFile += Energy*1000;
34  outFile += "MeV_";
35  }
36  else
37  {
38  outFile += "Co60_";
39  }
40  outFile += nEvents;
41  outFile += "Evts";
42  if (addSecTar)
43  {
44  outFile += "withSecTar";
45  }
46 
47  TString SimparamsFile;
48  SimparamsFile=outFile;
49  outFile +=".root";
50  SimparamsFile += "__Simparams.root";
51 
52  //TString inFile="/d/panda02/urqmd_smm/pbarC_3_GeV.root";
53  //TString inFile="/u/asanchez/razhyp_gt12.dat";
54  // set the MC version used
55  // ------------------------
56 
57  fRun->SetName("TGeant4");
58 
59  fRun->SetOutputFile(outFile);
60  // Set Material file Name
61  //-----------------------
62 
63  fRun->SetMaterials("media_pnd_hypGe.geo");
64 
65  // Create and add detectors
66  //-------------------------
67 
68  FairModule *Cave= new PndCave("CAVE");
69  Cave->SetGeometryFileName("pndcave_vacuum.geo");
70  fRun->AddModule(Cave);
71 
72  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE);
73  TString nam = gSystem->Getenv("VMCWORKDIR");
74  HypGe->SetPathGeo(nam.Data());
75  HypGe->SetGeometryFileName(GeoFile);
76  fRun->AddModule(HypGe);
77 
78  if (addSecTar)
79  {
80  PndHyp *Hyp= new PndHyp("HYP",kFALSE);
81  Hyp->SetAbsorverVol("Absorber"); // absorber layer
82  Hyp->SetSensorVol("Sensor"); // silicon sensor
83  Hyp->SetGeometryFileName("SekTarget_open_varAbs4_3Q_HYPbe_1mm.root");
84  fRun->AddModule(Hyp);
85  }
86  // FairDetector *Drc = new FairDrc("DIRC", kTRUE);
87  // Drc->SetGeometryFileName("dirc.geo");
88  // fRun->AddModule(Drc);
89 
90  // FairModule *Magnet= new FairMagnet("MAGNET");
91  // Magnet->SetGeometryFileName("magnet.geo");
92  // fRun->AddModule(Magnet);
93 
94  // FairDetector *Emc = new FairEmc("EMC",kTRUE);
95  // Emc->SetGeometryFileName("emc_module123.dat");
96  // fRun->AddModule(Emc);
97 
98  // Create and Set Event Generator
99  //-------------------------------
100 
101  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
102  fRun->SetGenerator(primGen);
103 
104  // Box Generator:
105  // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1);
106  // 13 = muon; 1 = multipl. // 211 = pi+
107  // first number: PDG particle code: 2nd number: particle multiplicity per event
108 
109 
110  PndBoxGenerator* boxGen = new PndBoxGenerator(22, 1);
111  if (!isCo60)
112  boxGen->SetPRange(Energy,Energy); // GeV/c
113  else
114  boxGen->SetPRange(0.001172,0.001172); //set first line of Co60 in GeV/c
115  // boxGen->SetPtRange(1.,1.); // GeV/c
116  boxGen->SetPhiRange(0., 0.); // Azimuth angle range [degree]
117  boxGen->SetThetaRange(180., 180.); // Polar angle in lab system range [degree]
118  //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
119  boxGen->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
120  primGen->AddGenerator(boxGen);
121 
122  if (isCo60)
123  {
124  PndBoxGenerator* boxGen2 = new PndBoxGenerator(22, 1);
125  boxGen2->SetPRange(0.001332,0.001332); // GeV/c
126  //boxGen2->SetPtRange(1.,1.); // GeV/c
127  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
128  boxGen2->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
129  //boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
130  boxGen2->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
131  primGen->AddGenerator(boxGen2);
132  }
133 
134 
135 /*
136  PndBoxGenerator* boxGen2 = new PndBoxGenerator(-211, 1);
137  boxGen2->SetPRange(0.09,0.1); // GeV/c
138  // boxGen->SetPtRange(1.,1.); // GeV/c
139  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
140  boxGen2->SetThetaRange(120., 180.); // Polar angle in lab system range [degree]
141  boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
142  boxGen2->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
143  */
144  //primGen->AddGenerator(boxGen);
145  /*
146  TChain *t =new TChain("data");
147  t->Add(inFile);
148  PndUrqmdSmmGenerator* AsciiGen = new PndUrqmdSmmGenerator(t);
149  primGen->SetTarget(-76.,0.);
150  primGen->AddGenerator(AsciiGen);
151  */
152 
153  /*FairAsciiGenerator* AsciiGen = new FairAsciiGenerator(inFile);
154  //primGen->SetTarget(-150.,0.);
155  primGen->AddGenerator(AsciiGen);
156  */
157 
158  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
159 
160 
161  //magnetic field: no field when commented put
162  //FairFieldConst *fMagField=new FairFieldConst();
163  //fMagField->SetField(0.,0.,20.); // values are in kG
164  //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);
165  // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
166  //fRun->SetField(fMagField);
167 
168 
169 
170 
171  fRun->Init();
172 
173  // Fill the Parameter containers for this run
174  //-------------------------------------------
175 
176  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
177  Bool_t kParameterMerged=kTRUE;
178 
179 
180  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
181  output->open(SimparamsFile);
182  rtdb->setOutput(output);
183  rtdb->saveOutput();
184  rtdb->print();
185 
186 
187  // Transport nEvents
188  // -----------------
189 
190  fRun->Run(nEvents);
191 
192  timer.Stop();
193 
194  Double_t rtime = timer.RealTime();
195  Double_t ctime = timer.CpuTime();
196  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
197 
198  return 0;
199 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
PndHypGe * HypGe
Definition: sim_hypGe.C:47
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
Definition: PndHyp.h:30
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
TString outFile
Definition: hit_dirc.C:17
PndBoxGenerator * boxGen2
Definition: sim_pid.C:96
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
PndHyp * Hyp
Definition: runSimHF_ptr.C:73
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
void SetSensorVol(TString VolSi)
Definition: PndHyp.h:195
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
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)
Double_t rtime
Definition: hit_dirc.C:113
TString nam
Definition: sim_hypGe.C:48
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
void SetPathGeo(TString pgeo)
Definition: PndHypGe.h:136
Definition: PndCave.h:8