FairRoot/PandaRoot
Functions
sim_Gamma.C File Reference

Go to the source code of this file.

Functions

int sim_Gamma (Int_t WhichDetector, Double_t Energy, Int_t nAllEvents, Int_t nEvents, Int_t GenType, Int_t addSecTar, Int_t JobNr, Bool_t OmegaMode=0, Double_t mu=0, Double_t Q=0)
 

Function Documentation

int sim_Gamma ( Int_t  WhichDetector,
Double_t  Energy,
Int_t  nAllEvents,
Int_t  nEvents,
Int_t  GenType,
Int_t  addSecTar,
Int_t  JobNr,
Bool_t  OmegaMode = 0,
Double_t  mu = 0,
Double_t  Q = 0 
)

Definition at line 7 of file sim_Gamma.C.

References Bool_t, boxGen, boxGen2, Cave, ComposeOutputFilename(), ComposeOutputFoldername(), ctime, Double_t, fRun, PndHypBupGenerator::GammaEmissPar(), gDebug, GeoFileChooser(), Hyp, HypGe, inFile, kParameterMerged, nam, outFile, output, partGen, primGen, printf(), rtdb, rtime, PndHyp::SetAbsorberVol(), PndBoxGenerator::SetCosTheta(), PndHyp::SetGeoVersion(), PndHyp::SetListMat(), PndHyp::SetMatbud(), PndBoxGenerator::SetPhiRange(), PndHypBupGenerator::SetPhiRange(), PndBoxGenerator::SetPRange(), PndHypBupGenerator::SetPRange(), PndHyp::SetSensorVol(), PndHypBupGenerator::SetThetaRange(), PndBoxGenerator::SetThetaRange(), PndBoxGenerator::SetXYZ(), timer, and TString.

17 {
18 
19  // Load basic libraries
20  // If it does not work, please check the path of the libs and put it by hands
21  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
22  gROOT->LoadMacro("$VMCWORKDIR/macro/hypGe/Marcell/SharedMacros/SharedMacroFunctions.C");
23  gSystem->Load("libHypGe");
24  gSystem->Load("librazhyp");
25  gSystem->Load("libHyp");
26  FairRunSim *fRun = new FairRunSim();
27 
28  TStopwatch timer;
29  timer.Start();
30  gDebug=0;
31 
32  Double_t EnergyGeV = Energy/1000;
33  //Choose geometry
34  TString outFile="$SIMDATADIR/Gamma/"; // If no SIMDATADIR, same folder as the macro
35  TString GeoFile=GeoFileChooser(WhichDetector);
36  TString outFolderPureName = ComposeOutputFoldername("Sim" ,WhichDetector,Energy,nAllEvents, nEvents, GenType,addSecTar,OmegaMode,mu,Q);
37  TString outFilePureName = ComposeOutputFilename("Sim" ,WhichDetector,Energy,nAllEvents, nEvents, GenType,addSecTar, JobNr,OmegaMode,mu,Q);
38 
39  outFile += outFolderPureName; // subfolder until here
40 
41  char CommandBuffer[400];
42  sprintf(CommandBuffer,".!mkdir -p %s",outFile.Data());
43  cout << "Processing " << CommandBuffer<< endl;
44  gROOT->ProcessLine(CommandBuffer); // create subfolder for the output
45 
46  outFile += "/";
47  outFile += outFilePureName;
48 
49  TString SimparamsFile;
50  SimparamsFile=outFile;
51  outFile +=".root";
52  SimparamsFile += "__Simparams.root";
53 
54  cout << outFile << endl;
55 
56  // set the MC version used
57  // ------------------------
58 
59  fRun->SetName("TGeant4");
60 
61  fRun->SetOutputFile(outFile);
62  // Set Material file Name
63  //-----------------------
64 
65  fRun->SetMaterials("media_pnd_hypGe.geo");
66 
67  // Create and add detectors
68  //-------------------------
69 
70  FairModule *Cave= new PndCave("CAVE");
71  Cave->SetGeometryFileName("pndcave.geo");
72  fRun->AddModule(Cave);
73 
74 
75  if (addSecTar)
76  {
77  //add sec. target
78  PndHyp *Hyp= new PndHyp("HYP",kTRUE);
79  Hyp->SetAbsorberVol("Absorber"); // absorber layer
80  Hyp->SetSensorVol("Sensor"); // silicon sensor
81  Hyp->SetGeoVersion("List");
82  Hyp->SetListMat("HYPboron");
83  Hyp->SetListMat("HYPaluminium");
84  Hyp->SetListMat("Al97Mg3");
85  Hyp->SetListMat("titanium");
86  Hyp->SetListMat("HYPcarbon");
87  Hyp->SetListMat("siliconinactive");
88  Hyp->SetListMat("acrylicGlass");
89  Hyp->SetMatbud(true); //activate hits in other parts than silicons or absorber
90  switch (addSecTar)
91  {
92  case 1: Hyp->SetGeometryFileName("TargetSystem_WindowTi_filledCorners_TcT1500um_longBP.root");break ;
93  case 2: Hyp->SetGeometryFileName("TargetSystem_AbsWindow_filledCorners_addSens.root");break ;
94  case 3: Hyp->SetGeometryFileName("TargetSystem_WindowAbsB_insideAbsB_primTarget.root");break;
95  case 12: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_iron.root");break;
96  case 13: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v3_iron.root");break;
97  case 22: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_titanium.root");break;
98  case 23: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v3_titanium.root");break;
99  case 32: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_tantalum.root");break;
100  case 33: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_tantalum.root");break;
101  case 42: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_lead.root");break;
102  case 43: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v3_lead.root");break;
103  case 52: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v2_gold.root");break;
104  case 53: Hyp->SetGeometryFileName("hypTargetSystem_XiAtoms_v3_gold.root");break;
105  }
106  fRun->AddModule(Hyp);
107  }
108 
109  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE);
110  TString nam = gSystem->Getenv("VMCWORKDIR");
111  //HypGe->SetPathGeo(nam.Data());
112  HypGe->SetGeometryFileName(GeoFile);
113  fRun->AddModule(HypGe);
114 
115  // Create and Set Event Generator
116  //-------------------------------
117 
118  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
119  fRun->SetGenerator(primGen);
120 
121  // Box Generator:
122  // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1);
123  // 13 = muon; 1 = multipl. // 211 = pi+
124  // first number: PDG particle code: 2nd number: particle multiplicity per event
125 
126  bool boxgen=0;
127  bool partgen=0;
128 
129  switch(GenType)
130  {
131  case 0 : boxgen = true; break;
132  case 1 : partgen = true; break;
133  }
134 
135 
136  if(boxgen)
137  {
138  bool isCo60 = false;
139  PndBoxGenerator* boxGen = new PndBoxGenerator(22, 1);
140  boxGen->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
141  if (!isCo60)
142  boxGen->SetPRange(EnergyGeV,EnergyGeV); // GeV/c
143  else
144  boxGen->SetPRange(0.001172,0.001172); //set first line of Co60 in GeV/c
145  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
146  boxGen->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
147  boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
148  primGen->AddGenerator(boxGen);
149  if (isCo60)
150  {
151  PndBoxGenerator* boxGen2 = new PndBoxGenerator(22, 1);
152  boxGen2->SetPRange(0.001332,0.001332); // GeV/c
153  //boxGen2->SetPtRange(1.,1.); // GeV/c
154  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
155  boxGen2->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
156  //boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
157  boxGen2->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
158  primGen->AddGenerator(boxGen2);
159  }
160  }
161 
162  if (partgen)
163  {
164  //TString inFile= "$VMCWORKDIR/hypGe/hypGeTools/partGenFiles/testgam_1_99All.root"; //22517 events
165  //TString inFile= "/home/steinen/work/GeneratorInput/XiAtoms/CombinedHypfile_Geo3_simruns_Events5000000.root"; //9686 events
166  TString inFile= "/home/steinen/work/GeneratorInput/XiAtoms/CombinedHypfile_Geo_3_simruns_Events10000000.root"; //52867 events
167  TString inFile= "/data/work/kpha1/steinen/XiAtoms/data/Hypfiles/CombinedHypfile_Geo_";
168  inFile+=addSecTar;
169  inFile+="_simruns_Events20000000";
170  if ((addSecTar % 10)==3)
171  inFile+="_Omega";
172  inFile+=".root";
173 
174 
175 // if (addSecTar ==4 || addSecTar == 7)
176 // TString inFile= "/home/steinen/work/GeneratorInput/XiAtoms/CombinedHypfile_Geo_3_simruns_Events10000000.root"; //52867 events
177 // else if (addSecTar ==6 || addSecTar == 8)
178 // TString inFile= "/home/steinen/work/GeneratorInput/XiAtoms/CombinedHypfile_Geo_5_simruns_Events10000000.root";
179 // else
180 // {
181 // cout << "no valid input file for partgen!!!!";
182 // return -1;
183 // }
184  PndHypBupGenerator* partGen = new PndHypBupGenerator(inFile.Data());
185  partGen->GammaEmissPar(kTRUE);
186  partGen->SetPRange(EnergyGeV,EnergyGeV);
187  partGen->SetPhiRange(0,360);
188  partGen->SetThetaRange(90,180); // only 2 pi of solid angle, since there are no germaniums in forward direction. This has to be taken into account in analysis of efficiency!!!
189  primGen->AddGenerator(partGen);
190  }
191 
192 
193  //boxGen->SetCosTheta(); // Set uniform distribution in cos(theta)
194 
195 
196 
197 
198  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
199 
200 
201  //magnetic field: no field when commented put
202  //FairFieldConst *fMagField=new FairFieldConst();
203  //fMagField->SetField(0.,0.,20.); // values are in kG
204  //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);
205  // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
206  //fRun->SetField(fMagField);
207 
208 
209 
210 
211  fRun->Init();
212 
213  // Fill the Parameter containers for this run
214  //-------------------------------------------
215 
216  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
217  Bool_t kParameterMerged=kTRUE;
218 
219 
220  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
221  output->open(SimparamsFile);
222  rtdb->setOutput(output);
223  rtdb->saveOutput();
224  rtdb->print();
225 
226 
227  // Transport nEvents
228  // -----------------
229  gRandom->SetSeed();
230  fRun->Run(nEvents);
231 
232  timer.Stop();
233 
234  Double_t rtime = timer.RealTime();
235  Double_t ctime = timer.CpuTime();
236  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
237 
238  return 0;
239 }
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)
TString GeoFileChooser(Int_t Geometry)
void SetListMat(TString mat="carbon")
Definition: PndHyp.h:222
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
TString inFile
Definition: hit_dirc.C:8
PndHypBupGenerator * partGen
Definition: runSimHF_ptr.C:144
void SetPRange(Double32_t pmin=0, Double32_t pmax=10)
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
TString ComposeOutputFoldername(char Type[4], Int_t Geometry, Double_t Energy, Int_t AllEvents, Int_t FileEvents, Int_t GenType, Int_t ST, Bool_t OmegaMode=0, Double_t mu=0, Double_t Q=0)
void SetMatbud(bool mbud)
Definition: PndHyp.h:188
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
void SetAbsorberVol(TString VolAb)
Definition: PndHyp.h:199
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
gDebug
Definition: sim_emc_apd.C:6
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Double_t ctime
Definition: hit_dirc.C:114
FairBoxGenerator * boxGen
Definition: sim_emc_apd.C:85
void SetGeoVersion(TString vers="standard")
Definition: PndHyp.h:210
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
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
TString ComposeOutputFilename(char Type[4], Int_t Geometry, Double_t Energy, Int_t AllEvents, Int_t FileEvents, Int_t GenType, Int_t ST, Int_t JobNr, Bool_t OmegaMode=0, Double_t mu=0, Double_t Q=0)
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Definition: PndCave.h:8