FairRoot/PandaRoot
sim_hypGe_CrystalsOnly.C
Go to the documentation of this file.
1 // Macro created 5/04/2007 by A.Sanchez
2 // It creates a geant simulation file for hypGe
3 int sim_hypGe_CrystalsOnly(Int_t nEvents, Int_t WhichDetector,Double_t Energy,Bool_t addSecTar)
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/CrystalsOnly/"; // If no SIMDATADIR, same folder as the macro
18  TString GeoFile;
19  if (WhichDetector == 3)
20  {
21  GeoFile ="hypGe_GeoMarcellCrystalsOnly.root";
22  outFile += "TripleV2CrystalsOnly_";
23  }
24  else if (WhichDetector == 31)
25  {
26  GeoFile = "hypGeGeoTripleCluster_V3CrystalsOnly.root";
27  outFile += "TripleBall30CrystalsOnly_";
28  }
29  else if (WhichDetector == 32)
30  {
31  GeoFile = "hypGeGeoTripleCluster_StraightCrystalsOnly.root";
32  outFile += "TripleStraightCrystalsOnly_";
33  }
34  else if (WhichDetector == 33)
35  {
36  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10CrystalsOnly.root";
37  outFile += "TripleBall40Offset10CrystalsOnly_";
38  }
39  else if (WhichDetector == 34)
40  {
41  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20CrystalsOnly.root";
42  outFile += "TripleBall40Offset20CrystalsOnly_";
43  }
44  else if (WhichDetector == 35)
45  {
46  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset10_STTFittingCrystalsOnly.root";
47  outFile += "TripleBall40Offset10STTCrystalsOnly_";
48  }
49  else if (WhichDetector == 36)
50  {
51  GeoFile = "hypGeGeoTripleCluster_Ball40_Offset20_STTFittingCrystalsOnly.root";
52  outFile += "TripleBall40Offset20STTCrystalsOnly_";
53  }
54  else if (WhichDetector == 2)
55  {
56  GeoFile = "hypGe_GeoMarcell_2erCrystalsOnly.root";
57  outFile += "DoubleV2CrystalsOnly_";
58  }
59  else if (WhichDetector == 21)
60  {
61  GeoFile = "hypGeGeoDoubleCluster_V3CrystalsOnly.root";
62  outFile += "DoubleV3CrystalsOnly_";
63  }
64  // Set the number of events
65 
66  // Set the gamma energy
67 
68  // choose Co60
69  bool isCo60 = false;
70  //compose the name of the output file and the simparams file
71 
72  if (!isCo60)
73  {
74  outFile += Energy*1000;
75  outFile += "MeV_";
76  }
77  else
78  {
79  outFile += "Co60_";
80  }
81  outFile += nEvents;
82  outFile += "Evts";
83  if (addSecTar)
84  {
85  outFile += "withSecTar";
86  }
87 
88  TString SimparamsFile;
89  SimparamsFile=outFile;
90  outFile +=".root";
91  SimparamsFile += "__Simparams.root";
92 
93  //TString inFile="/d/panda02/urqmd_smm/pbarC_3_GeV.root";
94  //TString inFile="/u/asanchez/razhyp_gt12.dat";
95  // set the MC version used
96  // ------------------------
97 
98  fRun->SetName("TGeant4");
99 
100  fRun->SetOutputFile(outFile);
101  // Set Material file Name
102  //-----------------------
103 
104  fRun->SetMaterials("media_pnd_hypGe.geo");
105 
106  // Create and add detectors
107  //-------------------------
108 
109  FairModule *Cave= new PndCave("CAVE");
110  Cave->SetGeometryFileName("pndcave_vacuum.geo");
111  fRun->AddModule(Cave);
112 
113  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE);
114  TString nam = gSystem->Getenv("VMCWORKDIR");
115  HypGe->SetPathGeo(nam.Data());
116  HypGe->SetGeometryFileName(GeoFile);
117  fRun->AddModule(HypGe);
118 
119  if (addSecTar)
120  {
121  PndHyp *Hyp= new PndHyp("HYP",kFALSE);
122  Hyp->SetAbsorverVol("Absorber"); // absorber layer
123  Hyp->SetSensorVol("Sensor"); // silicon sensor
124  Hyp->SetGeometryFileName("SekTarget_open_varAbs4_3Q_HYPbe_1mm.root");
125  fRun->AddModule(Hyp);
126  }
127  // FairDetector *Drc = new FairDrc("DIRC", kTRUE);
128  // Drc->SetGeometryFileName("dirc.geo");
129  // fRun->AddModule(Drc);
130 
131  // FairModule *Magnet= new FairMagnet("MAGNET");
132  // Magnet->SetGeometryFileName("magnet.geo");
133  // fRun->AddModule(Magnet);
134 
135  // FairDetector *Emc = new FairEmc("EMC",kTRUE);
136  // Emc->SetGeometryFileName("emc_module123.dat");
137  // fRun->AddModule(Emc);
138 
139  // Create and Set Event Generator
140  //-------------------------------
141 
142  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
143  fRun->SetGenerator(primGen);
144 
145  // Box Generator:
146  // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1);
147  // 13 = muon; 1 = multipl. // 211 = pi+
148  // first number: PDG particle code: 2nd number: particle multiplicity per event
149 
150 
151  PndBoxGenerator* boxGen = new PndBoxGenerator(22, 1);
152  if (!isCo60)
153  boxGen->SetPRange(Energy,Energy); // GeV/c
154  else
155  boxGen->SetPRange(0.001172,0.001172); //set first line of Co60 in GeV/c
156  // boxGen->SetPtRange(1.,1.); // GeV/c
157  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
158  boxGen->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
159  //boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
160  boxGen->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
161  primGen->AddGenerator(boxGen);
162 
163  if (isCo60)
164  {
165  PndBoxGenerator* boxGen2 = new PndBoxGenerator(22, 1);
166  boxGen2->SetPRange(0.001332,0.001332); // GeV/c
167  //boxGen2->SetPtRange(1.,1.); // GeV/c
168  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
169  boxGen2->SetThetaRange(90., 180.); // Polar angle in lab system range [degree]
170  //boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
171  boxGen2->SetXYZ(0., 0., -55.); // vertex coordinates [cm]
172  primGen->AddGenerator(boxGen2);
173  }
174 
175 
176 /*
177  PndBoxGenerator* boxGen2 = new PndBoxGenerator(-211, 1);
178  boxGen2->SetPRange(0.09,0.1); // GeV/c
179  // boxGen->SetPtRange(1.,1.); // GeV/c
180  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
181  boxGen2->SetThetaRange(120., 180.); // Polar angle in lab system range [degree]
182  boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
183  boxGen2->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
184  */
185  //primGen->AddGenerator(boxGen);
186  /*
187  TChain *t =new TChain("data");
188  t->Add(inFile);
189  PndUrqmdSmmGenerator* AsciiGen = new PndUrqmdSmmGenerator(t);
190  primGen->SetTarget(-76.,0.);
191  primGen->AddGenerator(AsciiGen);
192  */
193 
194  /*FairAsciiGenerator* AsciiGen = new FairAsciiGenerator(inFile);
195  //primGen->SetTarget(-150.,0.);
196  primGen->AddGenerator(AsciiGen);
197  */
198 
199  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
200 
201 
202  //magnetic field: no field when commented put
203  //FairFieldConst *fMagField=new FairFieldConst();
204  //fMagField->SetField(0.,0.,20.); // values are in kG
205  //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);
206  // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
207  //fRun->SetField(fMagField);
208 
209 
210 
211 
212  fRun->Init();
213 
214  // Fill the Parameter containers for this run
215  //-------------------------------------------
216 
217  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
218  Bool_t kParameterMerged=kTRUE;
219 
220 
221  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
222  output->open(SimparamsFile);
223  rtdb->setOutput(output);
224  rtdb->saveOutput();
225  rtdb->print();
226 
227 
228  // Transport nEvents
229  // -----------------
230 
231  fRun->Run(nEvents);
232 
233  timer.Stop();
234 
235  Double_t rtime = timer.RealTime();
236  Double_t ctime = timer.CpuTime();
237  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
238 
239  return 0;
240 }
241 
242 
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
int sim_hypGe_CrystalsOnly(Int_t nEvents, Int_t WhichDetector, Double_t Energy, Bool_t addSecTar)
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