FairRoot/PandaRoot
Functions
sim_hypGe_extparameters.C File Reference

Go to the source code of this file.

Functions

void sim_Gamma (Int_t nEvents=1000, Int_t WhichDetector=36, Double_t Energy=0.001, Bool_t addSecTar=1)
 

Function Documentation

void sim_Gamma ( Int_t  nEvents = 1000,
Int_t  WhichDetector = 36,
Double_t  Energy = 0.001,
Bool_t  addSecTar = 1 
)

Definition at line 4 of file sim_hypGe_extparameters.C.

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

5 {
6  // Load basic libraries
7  // If it does not work, please check the path of the libs and put it by hands
8  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
9  gSystem->Load("libHypGe");
10  gSystem->Load("libHyp");
11  FairRunSim *fRun = new FairRunSim();
12 
13  TStopwatch timer;
14  timer.Start();
15  gDebug=0;
16  TDatime now;
17  gRandom->SetSeed(now.Convert());
18  cout << now.Convert() << endl;
19  //Choose geometry
20  TString outFile="$SIMDATADIR/Gamma/"; // If no SIMDATADIR, same folder as the macro
21  TString GeoFile;
22  if (WhichDetector == 3)
23  {
24  GeoFile ="hypGe_GeoMarcell.root";
25  outFile += "TripleV2_";
26  }
27  else if (WhichDetector == 31)
28  {
29  GeoFile = "hypGeGeoTripleCluster_V3.root";
30  outFile += "TripleBall30_";
31  }
32  else if (WhichDetector == 32)
33  {
34  GeoFile = "hypGeGeoTripleCluster_Straight.root";
35  outFile += "TripleStraight_";
36  }
37  else if (WhichDetector == 33)
38  {
39  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10.root";
40  outFile += "TripleBall40Offset10_";
41  }
42  else if (WhichDetector == 34)
43  {
44  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20.root";
45  outFile += "TripleBall40Offset20_";
46  }
47  else if (WhichDetector == 35)
48  {
49  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10_STTFitting.root";
50  outFile += "TripleBall40Offset10STT_";
51  }
52  else if (WhichDetector == 36)
53  {
54  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20_STTFitting.root";
55  outFile += "TripleBall40Offset20STT_";
56  }
57 
58  else if (WhichDetector == 2)
59  {
60  GeoFile = "hypGe_GeoMarcell_2er.root";
61  outFile += "DoubleV2_";
62  }
63  else if (WhichDetector == 21)
64  {
65  GeoFile = "hypGeGeoDoubleCluster_V3.root";
66  outFile += "DoubleV3_";
67  }
68 
69  // choose Co60
70  bool isCo60 = false;
71  //compose the name of the output file and the simparams file
72 
73  if (!isCo60)
74  {
75  outFile += Energy*1000;
76  outFile += "MeV_";
77  }
78  else
79  {
80  outFile += "Co60_";
81  }
82  outFile += nEvents;
83  outFile += "Evts";
84  if (addSecTar)
85  {
86  outFile += "withSecTar";
87  }
88 
89  TString SimparamsFile;
90  SimparamsFile=outFile;
91  outFile +=".root";
92  SimparamsFile += "__Simparams.root";
93 
94  //TString inFile="/d/panda02/urqmd_smm/pbarC_3_GeV.root";
95  //TString inFile="/u/asanchez/razhyp_gt12.dat";
96  // set the MC version used
97  // ------------------------
98 
99  fRun->SetName("TGeant4");
100 
101  fRun->SetOutputFile(outFile);
102  // Set Material file Name
103  //-----------------------
104 
105  fRun->SetMaterials("media_pnd_hypGe.geo");
106 
107  // Create and add detectors
108  //-------------------------
109 
110  FairModule *Cave= new PndCave("CAVE");
111  Cave->SetGeometryFileName("pndcave.geo");
112  fRun->AddModule(Cave);
113 
114 
115  if (addSecTar)
116  {
117  //acc sec. target
118  PndHyp *Hyp= new PndHyp("HYP",kFALSE);
119  Hyp->SetAbsorberVol("Absorber"); // absorber layer
120  Hyp->SetSensorVol("Sensor"); // silicon sensor
121  Hyp->SetGeometryFileName("../macro/hyp/Sebastian/SekTarget_open_varAbs4Si5_3Q_HYPbe_1mm_MVD.root");
122  fRun->AddModule(Hyp);
123 
124  //add MVD outer barrel
125  FairDetector *Mvd = new PndMvdDetector("MVD", kFALSE);
126  Mvd->SetGeometryFileName("../macro/hyp/Sebastian/Mvd-2.2_Simplified_onlyStrip5_z-verschoben550.root");
127  fRun->AddModule(Mvd);
128  }
129  else
130  {
131  PndHyp *Hyp= new PndHyp("HYP",kFALSE);
132  Hyp->SetAbsorberVol("Absorber"); // absorber layer
133  Hyp->SetSensorVol("Sensor"); // silicon sensor
134  Hyp->SetGeometryFileName("../macro/hyp/Sebastian/SekTarget_open_varAbs4Si5_3Q_HYPbe_1mm_MVD_air.root");
135  fRun->AddModule(Hyp);
136  }
137  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE);
138  TString nam = gSystem->Getenv("VMCWORKDIR");
139  HypGe->SetPathGeo(nam.Data());
140  HypGe->SetGeometryFileName(GeoFile);
141  fRun->AddModule(HypGe);
142 
143  // Create and Set Event Generator
144  //-------------------------------
145 
146  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
147  fRun->SetGenerator(primGen);
148 
149  // Box Generator:
150  // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1);
151  // 13 = muon; 1 = multipl. // 211 = pi+
152  // first number: PDG particle code: 2nd number: particle multiplicity per event
153 
154  bool boxgen = false;
155  bool volgen = true;
156  if(boxgen)
157  {
158  PndBoxGenerator* boxGen = new PndBoxGenerator(22, 1);
159  boxGen->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
160  if (!isCo60)
161  boxGen->SetPRange(Energy,Energy); // GeV/c
162  else
163  boxGen->SetPRange(0.001172,0.001172); //set first line of Co60 in GeV/c
164  if (isCo60)
165  {
166  PndBoxGenerator* boxGen2 = new PndBoxGenerator(22, 1);
167  boxGen2->SetPRange(0.001332,0.001332); // GeV/c
168  //boxGen2->SetPtRange(1.,1.); // GeV/c
169  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
170  boxGen2->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
171  //boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
172  boxGen2->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
173  primGen->AddGenerator(boxGen2);
174  }
175  }
176  if (volgen)
177  {
178  PndVolGenerator* boxGen = new PndVolGenerator(22, 1);
179  TF1 *f1 = new TF1("f1","0.427842106*exp(-x/3.35703)", 4.5, 8.4999); // Factor makes no difference!
180  //double r = f1->GetRandom();
181  boxGen->SetVolTgFc(2, f1); // 2=Setting quadrant 2
182  boxGen->SetPRange(Energy,Energy); // GeV/c
183  }
184 
185  // boxGen->SetPtRange(1.,1.); // GeV/c
186 
187  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
188  boxGen->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
189  //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
190 
191  primGen->AddGenerator(boxGen);
192 
193 
194  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
195 
196 
197  //magnetic field: no field when commented put
198  //FairFieldConst *fMagField=new FairFieldConst();
199  //fMagField->SetField(0.,0.,20.); // values are in kG
200  //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);
201  // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
202  //fRun->SetField(fMagField);
203 
204 
205 
206 
207  fRun->Init();
208 
209  // Fill the Parameter containers for this run
210  //-------------------------------------------
211 
212  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
213  Bool_t kParameterMerged=kTRUE;
214 
215 
216  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
217  output->open(SimparamsFile);
218  rtdb->setOutput(output);
219  rtdb->saveOutput();
220  rtdb->print();
221 
222 
223  // Transport nEvents
224  // -----------------
225 
226  fRun->Run(nEvents);
227 
228  timer.Stop();
229 
230  Double_t rtime = timer.RealTime();
231  Double_t ctime = timer.CpuTime();
232  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
233 
234 }
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)
void SetPRange(Double32_t pmin=0, Double32_t pmax=10)
Definition: PndHyp.h:30
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
TF1 * f1
Definition: reco_analys2.C:50
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)
FairDetector * Mvd
Definition: sim_emc_apd.C:51
PndHyp * Hyp
Definition: runSimHF_ptr.C:73
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
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
void SetVolTgFc(Int_t quad=2, TF1 *func=0)
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
void SetAbsorberVol(TString VolAb)
Definition: PndHyp.h:199
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)
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
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