FairRoot/PandaRoot
Functions
sim_hypGe_COSY.C File Reference

Go to the source code of this file.

Functions

int sim_hypGe_COSY (Double_t ProtonMomentum=2.95, Int_t nEvents=100, Int_t PDG_ext=2212, Double_t TargetThickness=5, Double_t TargetAngle=0, Bool_t GausSmearedBeam=0, Bool_t BremsStahlungActivated=0, Bool_t WithBeamDump=1, Double_t ClusterRadius=30, Double_t BeamDumpDist=200, Double_t RunNo)
 

Function Documentation

int sim_hypGe_COSY ( Double_t  ProtonMomentum = 2.95,
Int_t  nEvents = 100,
Int_t  PDG_ext = 2212,
Double_t  TargetThickness = 5,
Double_t  TargetAngle = 0,
Bool_t  GausSmearedBeam = 0,
Bool_t  BremsStahlungActivated = 0,
Bool_t  WithBeamDump = 1,
Double_t  ClusterRadius = 30,
Double_t  BeamDumpDist = 200,
Double_t  RunNo 
)

Definition at line 3 of file sim_hypGe_COSY.C.

References Bool_t, boxGen, BuildOutputNameDetector(), BuildOutputNameInBeamStuff(), BuildOutputNameTarget(), Cave, ctime, Double_t, Drc, fRun, gDebug, HypGe, kParameterMerged, nam, nEvents, outFile, output, primGen, printf(), rtdb, rtime, PndHypGe::SetPathGeo(), PndBoxGenerator::SetPhiRange(), PndBoxGenerator::SetPRange(), PndBoxGenerator::SetThetaRange(), PndBoxGenerator::SetXYZ(), Target, timer, and TString.

6 {
7  Bool_t FirstBeamTime = false; // set this true to activate in beam stuff and beam dump of 2013 beam time at TOF area
8  Int_t ParticlePDG = PDG_ext; //(-)2212 = (Anti)Proton
9 
10  // Load basic libraries
11  // If it does not work, please check the path of the libs and put it by hands
12  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
13  gSystem->Load("libHypGe");
14  gSystem->Load("libHyp");
15 
16  //create Target geometry
17  //gROOT->ProcessLine(".L ../Geometry/hypGeTargetAbsorptionTest.C");
18  //TString TargetFilename = hypGeTargetAbsorptionTest(TargetThickness);
19 
20  FairRunSim *fRun = new FairRunSim();
21 
22  TStopwatch timer;
23  timer.Start();
24  gDebug=0;
25 
26  //Choose geometry
27  TString outFile="$SIMDATADIR/COSY/"; // If no SIMDATADIR, data in subdir COSY
28  TString GeoFile;
29 
30  //GeoFile = "hypGeGeoSingle.root";
31  outFile += "hypGeCOSYBeamTime_";
32  if (ParticlePDG < 0)
33  outFile += "ANTI";
34  outFile += "protons_mom";
35  outFile += ProtonMomentum;
36  outFile += "GeV_";
37 
38 
39  // Set the number of events
40 
41  outFile += nEvents;
42  outFile += "Evts";
43 
44  if (GausSmearedBeam)
45  outFile += "_GausianSmearedBeam";
46  if (!BremsStahlungActivated)
47  outFile += "_withoutBremsStahlung";
48 
49  outFile += "_Target";
50  outFile +=TargetThickness;
51  outFile +="cm";
52  outFile +=TargetAngle;
53  outFile +="Deg";
54 
55  outFile += "_DetectorDist";
56  outFile += ClusterRadius;
57  outFile += "cm";
58 
59  if (WithBeamDump)
60  {
61  outFile += "_WithDumpDist";
62  outFile += BeamDumpDist;
63  outFile += "cm__Run_";
64  }
65  outFile += RunNo;
66  TString SimparamsFile;
67  SimparamsFile=outFile;
68  outFile +=".root";
69  SimparamsFile += "__Simparams.root";
70 
71  // set the MC version used
72  // ------------------------
73 
74  fRun->SetName("TGeant4");
75 
76  fRun->SetOutputFile(outFile);
77  // Set Material file Name
78  //-----------------------
79  cout << outFile << endl;
80  fRun->SetMaterials("media_pnd_hypGe.geo");//("moded_media_pnd_hypGe.geo");//("../macro/hypGe/Marcell/MiscFiles/moded_media_pnd_hypGe.geo");
81 
82  // Create and add detectors
83  //-------------------------
84 
85  FairModule *Cave= new PndCave("CAVE");
86  Cave->SetGeometryFileName("pndcave.geo");
87  fRun->AddModule(Cave);
88 
89 
90 
91  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE); // Germaniums + SiPm + Piezo
92  TString nam = gSystem->Getenv("VMCWORKDIR");
93  HypGe->SetPathGeo(nam.Data());
94  if (FirstBeamTime)
95  gROOT->ProcessLine(".L ../Geometry/hypGeGeoCOSYGermaniums.C"); // load macro to create detecter geo name --> setup of 2013 beam time
96  else
97  gROOT->ProcessLine(".L ../Geometry/hypGeGeoBuilderSingle.C"); // load macro to create detecter geo name --> setup of 2014 beam time
98  GeoFile = BuildOutputNameDetector( ClusterRadius); //add ClusterRadius and BeamDumpDist
99  HypGe->SetGeometryFileName(GeoFile.Data());
100  fRun->AddModule(HypGe);
101 
102  // add target
103  FairModule *Target = new PndHyp("Target",kFALSE);
104  //Target->SetPathGeo(nam.Data());
105  gROOT->ProcessLine(".L ../Geometry/hypGeGeoCOSYTarget.C"); // load macro to create target geo name
106  TString TargetFile = BuildOutputNameTarget(TargetThickness,TargetAngle); // create target geo
107  Target->SetGeometryFileName(TargetFile.Data());
108  fRun->AddModule(Target);
109 
110 
111 
112  //PndHyp *BeamDump = new PndHyp("BeamDump",kFALSE);
113  //BeamDump->SetPathGeo(nam.Data());
114  //gROOT->ProcessLine(".L ../Geometry/hypGeGeoCOSYBeamDumpTOF.C"); // load macro to create beam dump geo name
115  //TString BeamDumpFile = "hypGeGeoCOSYBeamDumpTOF_dist200cm.root";
116  //BeamDump->SetGeometryFileName(BeamDumpFile.Data());
117  //fRun->AddModule(BeamDump);
118 
119 
120  // add stuff in beam (in front of target)
121 
122  FairModule *InBeamStuff = new PndHyp("InBeamStuff",kFALSE);
123  //InBeamStuff->SetPathGeo(nam.Data());
124  gROOT->ProcessLine(".L ../Geometry/hypGeGeoCOSYInBeamStuff.C"); // load macro to create target geo name
125  TString InBeamStuffFile = BuildOutputNameInBeamStuff(); // create target geo
126  InBeamStuff->SetGeometryFileName(InBeamStuffFile.Data());
127  //fRun->AddModule(InBeamStuff);
128 
129 
130  PndDrc *Drc = new PndDrc("DIRC", kFALSE);
131  Drc->SetGeometryFileName(InBeamStuffFile.Data());
132  if (FirstBeamTime) fRun->AddModule(Drc);
133 
134  // add beam dump
135  PndGemDetector *BeamDump = new PndGemDetector("BeamDump", kFALSE);
136  BeamDump->SetGeometryFileName("hypGeGeoCOSYBeamDumpTOF_dist200cm.root");
137  if (FirstBeamTime) fRun->AddModule(BeamDump);
138 
139  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
140  fRun->SetGenerator(primGen);
141 
142 
143  PndBoxGenerator* boxGen = new PndBoxGenerator(ParticlePDG, 1);
144  boxGen->SetPRange(ProtonMomentum,ProtonMomentum); // GeV/c
145 
146  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
147  boxGen->SetThetaRange(0, 0.2); // Polar angle in lab system range [degree]
148  //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
149  boxGen->SetXYZ(0., 0., -1000); // vertex coordinates [cm]
150 
151  if (GausSmearedBeam)
152  {
153  primGen->SetBeam(0, 0, 0.2, 0.2);
154  primGen->SmearVertexXY(1);
155  }
156  primGen->AddGenerator(boxGen);
157 
158 
159 
160 
161  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
162 
163 
164 
165 
166  // seg error somewhere!!!!
167 
168  cout << "init now" << endl;
169  fRun->Init();
170 
171  // Fill the Parameter containers for this run
172  //-------------------------------------------
173 
174  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
175  Bool_t kParameterMerged=kTRUE;
176 
177 
178  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
179  output->open(SimparamsFile);
180  rtdb->setOutput(output);
181  rtdb->saveOutput();
182  rtdb->print();
183 
184 
185  // Transport nEvents
186  // -----------------
187  gRandom->SetSeed(); // sets a random seed, added 08.06.14
188  fRun->Run(nEvents);
189 
190  timer.Stop();
191 
192  Double_t rtime = timer.RealTime();
193  Double_t ctime = timer.CpuTime();
194  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
195 
196  return 0;
197 }
PndDrc * Drc
Definition: sim_emc_apd.C:75
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
TString BuildOutputNameInBeamStuff()
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
TString BuildOutputNameDetector(Double_t ClusterRadius)
TFile * Target
Definition: hadd.C:35
TString BuildOutputNameTarget(Double_t TargetThickness_Ext, Double_t Angle)
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
Definition: PndDrc.h:31
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