FairRoot/PandaRoot
sim_pid.C
Go to the documentation of this file.
1 // Macro created A.Sanchez
2 // It creates a geant simulation file for hyp
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->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
10  //basiclibs();
11 
12  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
13  //rootlogon();
14 
15  //gSystem->Load("librazhyp");
16  gSystem->Load("libHyp");
17 
18  FairRunSim *fRun = new FairRunSim();
19 
20 
21 
22  //--Second xi minus momentum solution.
23 
24  //TString inFile= "froot/ximinAsciiStpRate.dat";
25  // set the MC version used
26  // ------------------------
27 
28  fRun->SetName("TGeant4");
29 
30  //fRun->SetOutputFile("./sim_hypgeantcheck.root");
31 
32 
33  fRun->SetOutputFile("sim_pidC.root");
34 
35  // Set Material file Name
36  //-----------------------
37 
38  //fRun->SetMaterials("media_pnd_hyp.geo");
39  //new media for hyp
40  fRun->SetMaterials("media_pnd.geo");
41 
42  // Create and add detectors
43  //-------------------------
44 
45  FairModule *Cave= new PndCave("CAVE");
46  Cave->SetGeometryFileName("pndcave.geo");
47  fRun->AddModule(Cave);
48  /*
49  FairModule *Magnet= new FairMagnet("MAGNET");
50  Magnet->SetGeometryFileName("magnet.geo");
51  fRun->AddModule(Magnet);
52  */
53 
54  PndHyp *Hyp = new PndHyp("HYP",kTRUE);
55  //FairDetector *Hyp = new PndHyp("HYP",kTRUE);
56 
57  //Hyp->SetGeometryFileName("HypST_block.geo");
58  //fRun->AddModule(Hyp);
59  //--blocks
60  //---Layers (si+abs)
61  //Hyp->SetGeometryFileName("HypST_prueba2.geo");
62  //fRun->AddModule(Hyp);
63  //--layers C+Si
64  // Hyp->SetGeometryFileName("HypST_prueba23.geo");
65  //fRun->AddModule(Hyp);
66  //--layers C+si+hyppipe
67  //Hyp->SetGeometryFileName("HypST_prueba24pipe.geo");
68  //Hyp->SetGeometryFileName("HypST_newxy3C.geo");
69 
70  // --- root geometry ------
71  Hyp->SetAbsorberVol("stglAb"); // absorber layer
72  Hyp->SetSensorVol("stglSi"); // silicon sensor
73  Hyp->SetGeometryFileName("HYPST_assexy3C.root");
74  // ---------------------------------
75 
76  //Hyp->SetHypSDtoFile(true,false);
77  fRun->AddModule(Hyp);
78 
79  //gROOT->LoadMacro("$VMCWORKDIR/gconfig/SetFragments.C");
80  //FragConfig(fRun);
81 
82 
83 
84  // Create and Set Event Generator
85  //-------------------------------
86 
87  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
88  fRun->SetGenerator(primGen);
89 
90 
91  // Box Generator:
92  PndBoxGenerator* boxGen = new PndBoxGenerator(3312, 1); // 13 = muon; 1 = multipl. // 211 = pi+
93  // first number: PDG particle code: 2nd number: particle multiplicity per event
94 
102  // 13 = muon; 1 = multipl. // 211 = pi+
103  // first number: PDG particle code: 2nd number: particle multiplicity per event
104 
105 
106  boxGen->SetPRange(.1,2.); // GeV/c
107  // boxGen->SetPtRange(1.,1.); // GeV/c
108  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
109  boxGen->SetThetaRange(30., 180.); // Polar angle in lab system range [degree]
110  boxGen->SetCosTheta(); // Set uniform ditribution in cos(theta)
111  boxGen->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
112  primGen->AddGenerator(boxGen);
113 
114  boxGen1->SetPRange(.1,2); // GeV/c
115  // boxGen->SetPtRange(1.,1.); // GeV/c
116  boxGen1->SetPhiRange(0., 360.); // Azimuth angle range [degree]
117  boxGen1->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
118  boxGen1->SetCosTheta(); // Set uniform ditribution in cos(theta)
119  boxGen1->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
120  primGen->AddGenerator(boxGen1);
121 
122 
123  boxGen2->SetPRange(.1,2); // GeV/c
124  // boxGen->SetPtRange(1.,1.); // GeV/c
125  boxGen2->SetPhiRange(0., 360.); // Azimuth angle range [degree]
126  boxGen2->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
127  boxGen2->SetCosTheta(); // Set uniform ditribution in cos(theta)
128  boxGen2->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
129  primGen->AddGenerator(boxGen2);
130 
131  boxGen3->SetPRange(.1,2); // GeV/c
132  // boxGen->SetPtRange(1.,1.); // GeV/c
133  boxGen3->SetPhiRange(0., 360.); // Azimuth angle range [degree]
134  boxGen3->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
135  boxGen3->SetCosTheta(); // Set uniform ditribution in cos(theta)
136  boxGen3->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
137  primGen->AddGenerator(boxGen3);
138 
139  boxGen4->SetPRange(.1,2); // GeV/c
140  // boxGen->SetPtRange(1.,1.); // GeV/c
141  boxGen4->SetPhiRange(0., 360.); // Azimuth angle range [degree]
142  boxGen4->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
143  boxGen4->SetCosTheta(); // Set uniform ditribution in cos(theta)
144  boxGen4->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
145  primGen->AddGenerator(boxGen4);
146 
147 
148  boxGen5->SetPRange(.1,2); // GeV/c
149  // boxGen->SetPtRange(1.,1.); // GeV/c
150  boxGen5->SetPhiRange(0., 360.); // Azimuth angle range [degree]
151  boxGen5->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
152  boxGen5->SetCosTheta(); // Set uniform ditribution in cos(theta)
153  boxGen5->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
154  primGen->AddGenerator(boxGen5);
155 
156  boxGen6->SetPRange(.1,2); // GeV/c
157  // boxGen->SetPtRange(1.,1.); // GeV/c
158  boxGen6->SetPhiRange(0., 360.); // Azimuth angle range [degree]
159  boxGen6->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
160  boxGen6->SetCosTheta(); // Set uniform ditribution in cos(theta)
161  boxGen6->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
162  primGen->AddGenerator(boxGen6);
163 
164 
165  boxGen7->SetPRange(.1,2); // GeV/c
166  // boxGen->SetPtRange(1.,1.); // GeV/c
167  boxGen7->SetPhiRange(0., 360.); // Azimuth angle range [degree]
168  boxGen7->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
169  boxGen7->SetCosTheta(); // Set uniform ditribution in cos(theta)
170  boxGen7->SetXYZ(0., 0., -76.); // vertex coordinates [cm]
171  primGen->AddGenerator(boxGen7);
172 
173 
174  //FairParticleGenerator* partGen = new FairParticleGenerator(3312, 1, -0.3,0.3,0.3, 0., 0., -76);
175  //primGen->AddGenerator(partGen);
176 
177  // *** with Ascii inFile ***
178  /* FairAsciiGenerator* AsciiGen = new FairAsciiGenerator(inFile);
179  primGen->AddGenerator(AsciiGen);*/
180 
181 
182 
183 
185  fMagField->SetField(0, 0 ,10. ); // values are in kG
186  // MinX=-75, MinY=-40,MinZ=-12 ,MaxX=75, MaxY=40 ,MaxZ=124 ); // values are in cm
187  fMagField->SetFieldRegion(-50, 50,-50, 50, -200, 200);
188  fRun->SetField(fMagField);
189 
190 
191  /*PndMultiField *fField= new PndMultiField();
192  PndTransMap *map= new PndTransMap("TransMap", "R");
193  PndDipoleMap *map1= new PndDipoleMap("DipoleMap", "R");
194  PndSolenoidMap *map2= new PndSolenoidMap("SolenoidMap", "R");
195  fField->AddField(map);
196  fField->AddField(map1);
197  fField->AddField(map2);
198  fRun->SetField(fField);*/
199 
200  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
201 
202 
203  fRun->Init();
204 
205  /*FairTrajFilter* trajFilter = FairTrajFilter::Instance();
206  trajFilter->SetStepSizeCut(0.001); // 1 cm
207  // trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.);
208  // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
209  // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
210  trajFilter->SetStorePrimaries(kTRUE);
211  trajFilter->SetStoreSecondaries(kTRUE);*/ // not used for the others.????
212 
213 
214 
215  // Fill the Parameter containers for this run
216  //-------------------------------------------
217 
218  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
219 
220  // PndMultiFieldPar* fieldPar = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
221  // if ( fField ) { fieldPar->SetParameters(fField); }
222  // fieldPar->setInputVersion(fRun->GetRunId(),1);
223  // fieldPar->setChanged();
224 
225  PndConstPar* fieldPar = (PndConstPar*) rtdb->getContainer("PndConstPar");
226  if ( fMagField ) { fieldPar->SetParameters(fMagField); }
227  fieldPar->setInputVersion(fRun->GetRunId(),1);
228  fieldPar->setChanged();
229 
231  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
232  //output->open("simparams.root");
233  output->open("pidparams.root");
234  rtdb->setOutput(output);
235  rtdb->saveOutput();
236  rtdb->print();
237 
238  // Transport nEvents
239  // -----------------
240  // Set the number of events
241  Int_t nEvents =100;
242 
243  fRun->Run(nEvents);
244 
245  timer.Stop();
246 
247  Double_t rtime = timer.RealTime();
248  Double_t ctime = timer.CpuTime();
249  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
250  delete fRun;
251  exit(0);
252 }
253 
void SetThetaRange(Double32_t thetamin=0, Double32_t thetamax=90)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
FairRuntimeDb * rtdb
Definition: sim_pid.C:218
Double_t ctime
Definition: sim_pid.C:248
Definition: PndHyp.h:30
FairRunSim * fRun
Definition: sim_pid.C:18
PndBoxGenerator * boxGen3
Definition: sim_pid.C:97
PndBoxGenerator * boxGen5
Definition: sim_pid.C:99
PndBoxGenerator * boxGen2
Definition: sim_pid.C:96
void SetXYZ(Double32_t x=0, Double32_t y=0, Double32_t z=0)
PndBoxGenerator * boxGen1
Definition: sim_pid.C:95
Int_t nEvents
Definition: sim_pid.C:241
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
PndBoxGenerator * boxGen4
Definition: sim_pid.C:98
void SetSensorVol(TString VolSi)
Definition: PndHyp.h:195
PndConstField * fMagField
Definition: sim_pid.C:184
FairPrimaryGenerator * primGen
Definition: sim_pid.C:87
PndBoxGenerator * boxGen7
Definition: sim_pid.C:101
Double_t
void SetField(Double_t bX, Double_t bY, Double_t bZ)
TStopwatch timer
Definition: hit_dirc.C:51
void SetAbsorberVol(TString VolAb)
Definition: PndHyp.h:199
void SetParameters(FairField *field)
Definition: PndConstPar.cxx:54
FairModule * Cave
Definition: sim_pid.C:45
PndHyp * Hyp
Definition: sim_pid.C:54
PndBoxGenerator * boxGen
Definition: sim_pid.C:92
Bool_t kParameterMerged
Definition: sim_pid.C:230
PndConstPar * fieldPar
Definition: sim_pid.C:225
gDebug
Definition: sim_pid.C:6
void SetPRange(Double32_t pmin=0, Double32_t pmax=10)
exit(0)
Double_t rtime
Definition: sim_pid.C:247
PndBoxGenerator * boxGen6
Definition: sim_pid.C:100
FairParRootFileIo * output
Definition: sim_pid.C:231
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)
Definition: PndCave.h:8