FairRoot/PandaRoot
runSimHF_GiB_DC.C
Go to the documentation of this file.
1 // Macro created A.Sanchez
2 // It creates a geant simulation file for hyp
3 // Parameters
4 //1) Generator option
5 // 1.a ) first step Xi m + Xib p --> Decfile,
6 //
7 // "box", Box generator
8 // "hist", Th2D Distribution in P (thet)from GiBUU model
9 // "Ascii", Ascii Gen, Intranuclear Cascade
10 // "giBUU", Xi m from giBUU on 12C target
11 // "param", Parametrization of a P(theta) dist from GiBUU
12 //
13 // 1.b ) second step , hypernuclei production "hypbup",
14 //2) detctor geo version
15 // 2.a) standard--> alicia version
16 // 2.b) current --> sebastian version
17 
18 int runSimHF_GiB_DC(TString Decfile = "hist", TString vers = "standard"){
19  TStopwatch timer;
20  timer.Start();
21  gRandom->SetSeed();
22  gDebug=0;
23 
24  // Load basic libraries
25  // If it does not work, please check the path of the libs and put it by hands
26  //gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
27  //basiclibs();
28 
29  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
30  //rootlogon();
31 
32  gSystem->Load("librazhyp");
33  gSystem->Load("libHyp");
34 
35  FairRunSim *fRun = new FairRunSim();
36 
37  // --- first step ----
38 
39  // -- GiBUU Parametrization TH2F Corr. Dist P(theta)
40 
41  TString inFile= "XiGengiBUUSamp.root";
42 
43  //--Second xi minus momentum solution.
44 
45  //TString inFile= "data/xibximin2AStpRate.dat";//data/ximinAsciiStpRate.dat";
46  //TString inFile= "data/ximinAsciiStpRate.dat";
47 
48  // -- UrqmdSmm/GiBUU SIGNAL/ background events
49 
50  // Int_t nEvents =99480;
51  if(Decfile=="giBUU")TString inFile= "carbon_onlyXi_2_5.root";
52 
53  //--- second step --
54  //--- HF from vertexes ----
55 
56  //TString inFile= "hypBupV1TDecay.root";
57 
58 
59  // set the MC version used
60 
61 
62 
63  // ------------------------
64 
65  fRun->SetName("TGeant4");
66 
67 
68 
69  // ----------first step -------------
70  // ++++++ Xi minus production ++++++
71 
72  fRun->SetOutputFile("Sim_hypFSG41TXm_SebGeo.root");
73 
74  // ----------first step XXb production -----------------------
75  //fRun->SetOutputFile("Sim_hypFSG41TXXb_Geo2.root");
76  // ---------- second step HF decay from secondary vertexes -------
77  //fRun->SetOutputFile("Bup_hypFSG41TXXb.root");
78 
79 
80  // Set Material file Name
81  //-----------------------
82 
83  //fRun->SetMaterials("media_pnd_hyp.geo");
84  //new media for hyp
85  fRun->SetMaterials("media_pnd.geo");
86 
87  // Create and add detectors
88  //-------------------------
89 
90  FairModule *Cave= new PndCave("CAVE");
91  Cave->SetGeometryFileName("pndcave.geo");
92  fRun->AddModule(Cave);
93  /*
94  FairModule *Magnet= new FairMagnet("MAGNET");
95  Magnet->SetGeometryFileName("magnet.geo");
96  fRun->AddModule(Magnet);
97  */
98 
99 
100 
101  PndHyp *Hyp = new PndHyp("HYP",kTRUE);
102  //FairDetector *Hyp = new PndHyp("HYP",kTRUE);
103 
104  //Hyp->SetGeometryFileName("HypST_block.geo");
105  //fRun->AddModule(Hyp);
106  //--blocks
107  //---Layers (si+abs)
108  //Hyp->SetGeometryFileName("HypST_prueba2.geo");
109  //fRun->AddModule(Hyp);
110  //--layers C+Si
111  // Hyp->SetGeometryFileName("HypST_prueba23.geo");
112  //fRun->AddModule(Hyp);
113  //--layers C+si+hyppipe
114  //Hyp->SetGeometryFileName("HypST_prueba24pipe.geo");
115  //Hyp->SetGeometryFileName("HypST_newxy3C.geo");
116 
117 
118 
119  // --- root geometry ------
120  // xxxxx Alicia's detector geo xxxx
121  if(vers=="standard"){
122 
123  Hyp->SetAbsorberVol("stglAb"); // absorber layer
124  Hyp->SetSensorVol("stglSi"); // silicon sensor
125  Hyp->SetGeoVersion("List");
126  Hyp->SetListMat("HYPdiamond");
127  Hyp->SetListMat("HYPcarbon");
128  //Hyp->SetGeometryFileName("HYPST_assexy3C5Lay.root");
129  Hyp->SetGeometryFileName("HYPST_assexy3C5Lay_mvd.root");//HYPST_assexy3C5Lay_test.root");
130 
131  }
132 
133  // xxxxxxxx Sebastian asymmetric geo root xxxxxxxxxxx
134  if(vers=="current"){
135  Hyp->SetAbsorberVol("Absorber"); // absorber layer
136  Hyp->SetSensorVol("Sensor"); // silicon sensor
137  Hyp->SetGeometryFileName("SekTarget_open_varAbs4Si5_3Q_HYPbe_1mm_MVD.root");
138  }
139 
140  // ---------------------------------
141 
142  //Hyp->SetTreeFName("hypBupV1T_Decay.root");
143  //Hyp->SetHypSDtoFile(true,false);
144  fRun->AddModule(Hyp);
145 
146  //gROOT->LoadMacro("$VMCWORKDIR/gconfig/SetFragments.C");
147  //FragConfig(fRun);
148 
149  //fRun->SetUserDecay(kTRUE);
150 
151  // MVD outer structure
152  //--------------------
153 
154  /* FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE);
155  Mvd->SetGeometryFileName("Mvd-2.2_Simplified_onlyStrip5_z-verschoben550.root"); // only sensors, update follows
156  Mvd->SetVerboseLevel(verboseLevel);
157  fRun->AddModule(Mvd);*/
158 
159  // Create and Set Event Generator
160  //-------------------------------
161 
162  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
163  fRun->SetGenerator(primGen);
164 
165 
166  // Box Generator:
167  if(Decfile=="box"){
168  PndBoxGenerator* boxGen = new PndBoxGenerator(3312, 1); // 13 = muon; 1 = multipl. // 211 = pi+
169  // first number: PDG particle code: 2nd number: particle multiplicity per event
170 
171  boxGen->SetPRange(.1,.5); // GeV/c
172  // boxGen->SetPtRange(1.,1.); // GeV/c
173  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree] 90
174  boxGen->SetThetaRange(0., 180.); // Polar angle in lab system range [degree] 70
175 
176  boxGen->SetXYZ(0., 0., -55.0); // vertex coordinates [cm]
177  primGen->AddGenerator(boxGen);
178  }
179 
180 
181 
182  // *** Signal events GiBUU + TH2F(correlated dist in P (theta)) ***first step
183  if(Decfile=="hist"){
184  PndCorrDistGenerator* GiBGen = new PndCorrDistGenerator(inFile);
185 
186  primGen->SetTarget(-55.5,0.);
187  primGen->AddGenerator(GiBGen);
188 
189  }
190  // *** Signal events GiBUU + Param from TH2F(correlated dist in P (theta)) ***first step
191  if(Decfile=="param"){
192  PndCorrDistGenerator* GiBGen = new PndCorrDistGenerator(inFile);
193  GiBGen->SetParam(); //setting parametrization to be be done.
194  GiBGen->SetThetaRange(60.,120.); // low momentum Xi minus
195  primGen->SetTarget(-55.5,0.);
196  primGen->AddGenerator(GiBGen);
197 
198  }
199  // *** SIGNAL events UrqmdSmm ***first step
200  if(Decfile=="giBUU"){
201 
203 
204  primGen->SetTarget(-55.5,0.);
205  primGen->AddGenerator(AsciiGen);
206  }
207 
208  // *** with Ascii inFile ***first step
209  //FairAsciiGenerator* AsciiGen = new FairAsciiGenerator(inFile);
210  // primGen->SetTarget(-55.5,0.);
211  //primGen->AddGenerator(AsciiGen);
212 
213  // *** with root inFile ***second step
214  /*PndHypBupGenerator* partGen = new PndHypBupGenerator(inFile);
215  primGen->AddGenerator(partGen);*/
216 
217 
218 
219 
221  fMagField->SetField(0, 0 ,10. ); // values are in kG
222  // MinX=-75, MinY=-40,MinZ=-12 ,MaxX=75, MaxY=40 ,MaxZ=124 ); // values are in cm
223  fMagField->SetFieldRegion(-50, 50,-50, 50, -200, 200);
224  fRun->SetField(fMagField);
225 
226 
227  /*PndMultiField *fField= new PndMultiField();
228  PndTransMap *map= new PndTransMap("TransMap", "R");
229  PndDipoleMap *map1= new PndDipoleMap("DipoleMap", "R");
230  PndSolenoidMap *map2= new PndSolenoidMap("SolenoidMap", "R");
231  fField->AddField(map);
232  fField->AddField(map1);
233  fField->AddField(map2);
234  fRun->SetField(fField);*/
235 
236  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
237 
238 
239  fRun->Init();
240 
241 
242  /*FairTrajFilter* trajFilter = FairTrajFilter::Instance();
243  trajFilter->SetStepSizeCut(0.001); // 1 cm
244  // trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.);
245  // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
246  // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
247  trajFilter->SetStorePrimaries(kTRUE);
248  trajFilter->SetStoreSecondaries(kTRUE);*/ // not used for the others.????
249 
250 
251 
252  // Fill the Parameter containers for this run
253  //-------------------------------------------
254  // cout<<" gGeoManager "<<gGeoManager<<endl;
255  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
256 
257  // PndMultiFieldPar* fieldPar = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
258  // if ( fField ) { fieldPar->SetParameters(fField); }
259  // fieldPar->setInputVersion(fRun->GetRunId(),1);
260  // fieldPar->setChanged();
261 
262  PndConstPar* fieldPar = (PndConstPar*) rtdb->getContainer("PndConstPar");
263  if ( fMagField ) { fieldPar->SetParameters(fMagField); }
264  fieldPar->setInputVersion(fRun->GetRunId(),1);
265  fieldPar->setChanged();
266 
267  Bool_t kParameterMerged=kTRUE;
268  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
269  //output->open("simparams.root");
270  output->open("Sim_hypFS1TG4Xm_SebGeoparams.root");
271  //output->open("Bup_hypFS1TG4XXbparams.root");
272  rtdb->setOutput(output);
273  rtdb->saveOutput();
274  rtdb->print();
275 
276  // Transport nEvents
277  // -----------------
278  // Set the number of events
279  Int_t nEvents =10000;//50505;
280 
281  fRun->Run(nEvents);
282 
283  timer.Stop();
284 
285  Double_t rtime = timer.RealTime();
286  Double_t ctime = timer.CpuTime();
287  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
288  // delete fRun;
289  //exit(0);
290  return 0;
291 }
292 
293 
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int runSimHF_GiB_DC(TString Decfile="hist", TString vers="standard")
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
void SetListMat(TString mat="carbon")
Definition: PndHyp.h:222
Definition: PndHyp.h:30
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
PndHyp * Hyp
Definition: runSimHF_ptr.C:73
PndUrqmdSmmGenerator * AsciiGen
Definition: sim_ftof.C:62
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
void SetSensorVol(TString VolSi)
Definition: PndHyp.h:195
FairRunAna * fRun
Definition: hit_dirc.C:58
TString inFile
Definition: hit_dirc.C:8
PndConstField * fMagField
Definition: runSimHF_ptr.C:154
Double_t
FairModule * Cave
Definition: sim_emc_apd.C:32
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Int_t nEvents
Definition: hit_dirc.C:11
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
TStopwatch timer
Definition: hit_dirc.C:51
void SetAbsorberVol(TString VolAb)
Definition: PndHyp.h:199
void SetParameters(FairField *field)
Definition: PndConstPar.cxx:54
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
gDebug
Definition: sim_emc_apd.C:6
void SetThetaRange(Double_t thetLow=0., Double_t thetHigh=0.)
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 SetPRange(Double32_t pmin=0, Double32_t pmax=10)
Double_t rtime
Definition: hit_dirc.C:113
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Definition: PndCave.h:8