FairRoot/PandaRoot
sim_hypGe.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 {
4  TStopwatch timer;
5  timer.Start();
6  gDebug=0;
7  // Load basic libraries
8  // If it does not work, please check the path of the libs and put it by hands
9  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
10 
11 
12  gSystem->Load("libHypGe");
13 
14  FairRunSim *fRun = new FairRunSim();
15 
16  // Set the number of events
17  Int_t nEvents = 2000; //6000 gamma spectra(hyp)
18  TString inFile="/d/panda02/urqmd_smm/pbarC_3_GeV.root";
19  //TString inFile="/u/asanchez/razhyp_gt12.dat";
20  // set the MC version used
21  // ------------------------
22 
23  fRun->SetName("TGeant4");
24  //0.5 cm thickness in scint absorver
25  //fRun->SetOutputFile("/d/panda01/asanchez/PANDA/sim_hypGe_test2.root");
26  //1cm thichness scint absorver
27  //fRun->SetOutputFile("/d/panda01/asanchez/PANDA/sim_hypGe_test3.root");
28  //capsula geometry
29  //fRun->SetOutputFile("/d/panda01/asanchez/PANDA/sim_hypGe_test5.root");
30  //capsula geometry + sci geometry
31  //fRun->SetOutputFile("/d/panda01/asanchez/PANDA/sim_hypGe_test6.root");
32 
33  //fRun->SetOutputFile("/d/panda01/asanchez/PANDA/sim_hypGe_BgUrqmd.root");
34  fRun->SetOutputFile("sim_hypGe_BgUrqmd2.root");
35  // Set Material file Name
36  //-----------------------
37 
38  fRun->SetMaterials("media_pnd.geo");
39 
40  // Create and add detectors
41  //-------------------------
42 
43  FairModule *Cave= new PndCave("CAVE");
44  Cave->SetGeometryFileName("pndcave.geo");
45  fRun->AddModule(Cave);
46 
47  PndHypGe *HypGe= new PndHypGe("HYPGE",kTRUE);
48  TString nam = gSystem->Getenv("VMCWORKDIR");
49  HypGe->SetPathGeo(nam.Data());
50  HypGe->SetGeometryFileName("HPGeCluster.root");
51  fRun->AddModule(HypGe);
52 
53  // FairDetector *Hyp= new FairHyp("HYP",kTRUE);
54  // Hyp->SetGeometryFileName("HypST_prueba24pipe.geo");
55  // fRun->AddModule(Hyp);
56 
57  // FairDetector *Drc = new FairDrc("DIRC", kTRUE);
58  // Drc->SetGeometryFileName("dirc.geo");
59  // fRun->AddModule(Drc);
60 
61  // FairModule *Magnet= new FairMagnet("MAGNET");
62  // Magnet->SetGeometryFileName("magnet.geo");
63  // fRun->AddModule(Magnet);
64 
65  // FairDetector *Emc = new FairEmc("EMC",kTRUE);
66  // Emc->SetGeometryFileName("emc_module123.dat");
67  // fRun->AddModule(Emc);
68 
69  // Create and Set Event Generator
70  //-------------------------------
71 
72  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
73  fRun->SetGenerator(primGen);
74 
75  // Box Generator:
76  // FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1);
77  // 13 = muon; 1 = multipl. // 211 = pi+
78  // first number: PDG particle code: 2nd number: particle multiplicity per event
79 
80 
82  boxGen->SetPRange(0.007,0.008); // GeV/c
83  // boxGen->SetPtRange(1.,1.); // GeV/c
84  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
85  boxGen->SetThetaRange(120., 180.); // Polar angle in lab system range [degree]
86  boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
87  boxGen->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
88 
89  primGen->AddGenerator(boxGen); /*
90 
91  PndBoxGenerator* boxGen2 = new PndBoxGenerator(-211, 1);
92  boxGen2->SetPRange(0.09,0.1); // GeV/c
93  // boxGen->SetPtRange(1.,1.); // GeV/c
94  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
95  boxGen2->SetThetaRange(120., 180.); // Polar angle in lab system range [degree]
96  boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
97  boxGen2->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
98 
99  primGen->AddGenerator(boxGen); */
100 
101  /*
102  TChain *t =new TChain("data");
103  t->Add(inFile);
104  PndUrqmdSmmGenerator* AsciiGen = new PndUrqmdSmmGenerator(t);
105  primGen->SetTarget(-76.,0.);
106  primGen->AddGenerator(AsciiGen);
107  */
108 
109  /*FairAsciiGenerator* AsciiGen = new FairAsciiGenerator(inFile);
110  //primGen->SetTarget(-150.,0.);
111  primGen->AddGenerator(AsciiGen);
112  */
113 
114  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
115 
116 
117  //magnetic field: no field when commented put
118  //FairFieldConst *fMagField=new FairFieldConst();
119  //fMagField->SetField(0.,0.,20.); // values are in kG
120  //fMagField->SetFieldRegion(-50, 50,-50, 50, -100, 100);
121  // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
122  //fRun->SetField(fMagField);
123 
124 
125 
126 
127  fRun->Init();
128 
129  // Fill the Parameter containers for this run
130  //-------------------------------------------
131 
132  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
134 
135 
136  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
137  output->open("simparams.root");
138  rtdb->setOutput(output);
139  rtdb->saveOutput();
140  rtdb->print();
141 
142 
143  // Transport nEvents
144  // -----------------
145 
146  fRun->Run(nEvents);
147 
148  timer.Stop();
149 
150  Double_t rtime = timer.RealTime();
151  Double_t ctime = timer.CpuTime();
152  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
153 
154 }
155 
156 
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)
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairRunAna * fRun
Definition: hit_dirc.C:58
TString inFile
Definition: hit_dirc.C:8
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