FairRoot/PandaRoot
runGeaneTestSimBox.cxx
Go to the documentation of this file.
1 /*
2  * runLumiSimBox.cxx
3  *
4  * Created on: Nov 28, 2012
5  * Author: jasinski
6  */
7 
8 
9 
10 // Panda FullSim macro
11 
12 /*
13 #include<TString.h>
14 #include<TStopwatch.h>
15 #include<TROOT.h>
16 #include<FairModule.h>
17 #include<PndCave.h>
18 #include<PndMagnet.h>
19 #include<PndPipe.h>
20 #include<PndMvdDetector.h>
21 #include<FairRunSim.h>
22 #include<PndLmdDetector.h>
23 #include<FairPrimaryGenerator.h>
24 #include<FairBoxGenerator.h>
25 #include<PndMultiField.h>
26 #include<PndTransMap.h>
27 #include<PndDipoleMap.h>
28 #include<PndSolenoidMap.h>
29 #include<FairParRootFileIo.h>
30 #include<PndMultiFieldPar.h>
31 // important for compiled version ****************
32 #include<PndSensorNameContFact.h>
33 #include<FairBaseContFact.h>
34 #include<PndFieldContFact.h>
35 #include <PndPassiveContFact.h>
36 #include <TSystem.h>
37 // ******************important for compiled version
38 */
39 //#include<.h>
40 
41 int nEvents = 1000000; // number of primary events
42 double mom = 15; // beam momentum
43 double mom_spread = 1e-4; // HESR momentum resolution (relative to mom)
44 double dx = 0.; // displacement of the primary vertex in x
45 double dy = 0.; // displacement of the primary vertex in y
46 double phi_low = 0;
47 double phi_high = 360.;
48 double theta_low = 2.5e-3/3.141 *180.; //2.5 mrad
49 double theta_high = 10.e-3/3.141 *180.; //10 mrad
50 TString storePath="."; //tmpOutput";
51 const int particle=-2212; // particle id (-2212 = antiproton)
52 
53 //static TROOT* pROOT = gROOT;
54 
55 //void runLumi0SimBox(const int nEvents=10, const double mom=15, TString storePath="tmpOutput", const int verboseLevel=0, const int particle=-211)
57 {
58 
59 // cout << nEvents << " " << mom << " " << dx << " " << dy << " " << endl;
60  const int verboseLevel=0;//7;
61  TStopwatch timer;
62  timer.Start();
63  gDebug=0;
64 
65  //output1
66  TString simOutput=storePath+"/Lumi_MC.root";
67  TString parOutput=storePath+"/Lumi_Params.root";
68 
69  //Load basic libraries
70  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
71  gSystem->Load("libSds");
72  gSystem->Load("libLmd");
73  FairRunSim *fRun = new FairRunSim();
74  std::cout<<"All libraries succsesfully loaded!"<<std::endl;
75 
76  //set the MC version used
77  //fRun->SetName("TGeant4");
78  fRun->SetName("TGeant3");
79 
80  fRun->SetOutputFile(simOutput);
81  std::cout << "$VMCWORKDIR is " << getenv("VMCWORKDIR") << " ." << std::endl;
82 
83  /*
84  // ************ important when running standalone *********************
85  // initialization of singleton classes
86  PndSensorNameContFact& sensornamecontfact = PndSensorNameContFact::gPndSensorNameContFact();
87  FairBaseContFact& basecontfact = FairBaseContFact::gFairBaseContFact();
88  PndFieldContFact& fieldcontfact = PndFieldContFact::gPndFieldContFact();
89  PndPassiveContFact& passivecontfact = PndPassiveContFact::gPndPassiveContFact();
90  // ***********************************************************************
91 */
92 
93  //set material
94  fRun->SetMaterials("media_pnd.geo");
95 
96  //create and add detectors
97  FairModule *Cave= new PndCave("CAVE");
98  Cave->SetGeometryFileName("pndcaveVAC.geo");
99  fRun->AddModule(Cave);
100 
101  FairModule *Magnet= new PndMagnet("MAGNET");
102  Magnet->SetGeometryFileName("FullSolenoid.root");
103  fRun->AddModule(Magnet);
104 
105  FairModule *Dipole= new PndMagnet("MAGNET");
106  Dipole->SetGeometryFileName("dipole.geo");
107  fRun->AddModule(Dipole);
108 
109  //FairModule *Pipe= new PndPipe("PIPE");
110  //Pipe->SetGeometryFileName("pipebeamtarget.geo");
111  //fRun->AddModule(Pipe);
112 
113  //FairModule *Pipe= new PndPipe("PIPE");
114  //Pipe->SetGeometryFileName("../macro/lmd/geo/beampipe_201210.root");// with lumi beam pipe
115  //Pipe->SetGeometryFileName("beampipe_201202_no_lmd_pipe.root");
116  //Pipe->SetGeometryFileName("beampipe_201112.root");
117  //Pipe->SetGeometryFileName("../macro/lmd/geo/HV_MAPS-Design.root");
118  //fRun->AddModule(Pipe);
119 
120  /*FairDetector *Stt= new PndStt("STT", kFALSE);
121  Stt->SetGeometryFileName("straws_skewed_blocks.geo");
122  fRun->AddModule(Stt);*/
123 
124  //FairDetector *Mvd = new PndMvdDetector("MVD", kFALSE);
125  //Mvd->SetGeometryFileName("MVD_v1.0_woPassiveTraps.root");
126  //fRun->AddModule(Mvd);
127 
128  /* PndEmc *Emc = new PndEmc("EMC",kFALSE);
129  Emc->SetGeometryFileNameDouble("emc_module1245.dat","emc_module3new.root"); // if you want to use new geometry for FwEndCap
130  fRun->AddModule(Emc);
131 
132  FairDetector *Tof = new PndTof("TOF",kFALSE);
133  Tof->SetGeometryFileName("tofbarrel.geo");
134  fRun->AddModule(Tof);
135 
136  FairDetector *Drc = new PndDrc("DIRC", kFALSE);
137  Drc->SetGeometryFileName("dirc.geo");
138  fRun->AddModule(Drc);
139 
140  PndMdt *Muo = new PndMdt("MDT",kFALSE);
141  Muo->SetGeometryFileName("muopars.root");
142  Muo->SetMdtVersion("torino");
143  fRun->AddModule(Muo);*/
144 
145 
146 
147  PndLmdDetector *Lum = new PndLmdDetector("LUM", kTRUE);
148  Lum->SetExclusiveSensorType("LumActive"); //ignore MVD
149  //Lum->SetGeometryFileName("../macro/lmd/geo/F0-Design.root"); //!!!
150  Lum->SetGeometryFileName("lmd_geane_test.root");
151  //Lum->SetGeometryFileName("beampipe_201210_active.root");
152  //Lum->SetGeometryFileName("../macro/lmd/geo/beampipe_201205_w_sensors.root"); //!!!
153 
154  // Lum->SetGeometryFileName("../macro/lmd/geo/MyTest-Dipol-Design.root"); //!!!
155 
156  // Mvd->SetGeometryFileName("lumi.geo");
157  // Mvd->SetGeometryFileName("MVD14.root");
158  Lum->SetVerboseLevel(verboseLevel);
159  fRun->AddModule(Lum);
160 
161  // FairDetector *Stt= new CbmStt("STT", kTRUE);
162  // Stt->SetGeometryFileName("straws_axial.geo");
163  // fRun->AddModule(Stt);
164 
165  // FairDetector *Emc = new CbmEmc("EMC",kTRUE);
166  // Emc->SetGeometryFileName("emc_module12345.dat");
167  // fRun->AddModule(Emc);
168 
169  // FairDetector *Drc = new CbmDrc("DIRC", kTRUE);
170  // Drc->SetGeometryFileName("dirc.geo");
171  // fRun->AddModule(Drc);
172 
173 
174  //particle generator
175  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
176  fRun->SetGenerator(primGen);
177 
178  // Particle Generator (pdgid,mult, px,py,pz, vx,vy,vz)
179 
180  // single pions for testing
181  // FairParticleGenerator* partGenX = new FairParticleGenerator(211,1, 1.,0.,0., 0.,0.,0.);
182  // FairParticleGenerator* partGenY = new FairParticleGenerator(211,1, 0.,1.,0., 0.,0.,0.);
183  // FairParticleGenerator* partGenZ = new FairParticleGenerator(211,1, 0.,0.1,1., 0.,0.,0.);
184  // FairParticleGenerator* partGenXYZ = new FairParticleGenerator(211,1, 1.,1.,5., 0.,0.,0.);
185  // primGen->AddGenerator(partGenX);
186  // primGen->AddGenerator(partGenY);
187  // primGen->AddGenerator(partGenZ);
188  // primGen->AddGenerator(partGenXYZ);
189 
190  // Ion Generator
191  // FairIonGenerator *fIongen= new FairIonGenerator(79, 197,79,1, 0.,0., 25, 0.,0.,-1.);
192  // primGen->AddGenerator(fIongen);
193 
194  // Box Generator
195  FairBoxGenerator *fBox = new FairBoxGenerator(particle, 1);
196  //FairBoxGenerator *fBox = new FairBoxGenerator(0, 1);
197  fBox->SetPRange(mom,mom);//mom-mom*mom_spread,mom+mom*mom_spread); // momentum +- 10e-4
198  //fBox->SetThetaRange(0.2,0.4); //3...8 mrad
199  // fBox->SetThetaRange(0.13,0.56);
200  // fBox->SetThetaRange(0.13,0.7); // 2... 12 mrad
201  // fBox->SetThetaRange(0.3,0.3);
202  // fBox->SetThetaRange(0.,0.7);
203  //fBox->SetThetaRange(1e-3/3.141 *180., 10e-3/3.141 *180.);
204  //fBox->SetThetaRange(1e-8/3.141 *180., 1e-3/3.141 *180.);
205  //fBox->SetThetaRange(4e-3/3.141 *180., 8e-3/3.141 *180.);
206  // fBox->SetThetaRange(0., 3.14);
207  // fBox->SetThetaRange(0.4, 0.46); //7-8 mrad
208  //fBox->SetThetaRange(0.257831, 0.315127); //4.5 ... 5.5 mrad
209  // fBox->SetThetaRange(0.257831, 0.257831); //4.5 mrad
210  // fBox->SetThetaRange(0., 90.);
211  // fBox->SetPhiRange(0.,360.);
212  //fBox->SetThetaRange(0., 0.);
213  //fBox->SetPhiRange(89.,91.);
214  // fBox->SetPhiRange(0.,20.);//TEST
215  // fBox->SetPhiRange(44.,46.);
216  //fBox->SetPhiRange(-90.,90.);
217  // fBox->SetPhiRange(22.5,22.5);
218 
219  fBox->SetThetaRange(theta_low, theta_high);
220  fBox->SetPhiRange(phi_low, phi_high);
221 
222  fBox->SetXYZ(dx, dy, 0.);
223 
224  //fBox->SetThetaRange(0.,0.); //3.5 ... 8.? mrad
225  //fBox->SetPhiRange(-90.,-90.);
226  //
227  // fBox->SetPhiRange(1*180./TMath::Pi(),2*180./TMath::Pi());
228  //fBox->SetPhiRange(80.,100.);
229  primGen->AddGenerator(fBox);
230 
231 
232  // //EvtGen Generator
233  // PndEvtGenDirect *EvtGen = new PndEvtGenDirect("pbarpSystem","PBARSYSTEMTO4PIPHSP.DEC",mom);
234  // primGen->AddGenerator(EvtGen);
235 
236 
237  // Urqmd Generator
238  // FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator("../../input/00-03fm.100ev.f14");
239  // primGen->AddGenerator(urqmdGen);
240 
241  // DPM Generator
242  // PndDpmGenerator* dpmGen = new PndDpmGenerator("DpmInput/el_100k_aida/el_6_2GeV.root");
243  // primGen->AddGenerator(dpmGen);
244 
245 
246  //reading the new field map in the old format
247  fRun->SetBeamMom(mom);
249 
250  //PndTransMap *map_t = new PndTransMap("TransMap_v1", "R");
251  //PndDipoleMap *map_d1 = new PndDipoleMap("DipoleMap1_v1", "R");
252  //PndDipoleMap *map_d2 = new PndDipoleMap("DipoleMap2_v1", "R");
253  PndTransMap *map_t = new PndTransMap("TransMap", "R");
254  PndDipoleMap *map_d1 = new PndDipoleMap("DipoleMap1", "R");
255  PndDipoleMap *map_d2 = new PndDipoleMap("DipoleMap2", "R");
256  PndSolenoidMap *map_s1 = new PndSolenoidMap("SolenoidMap1", "R");
257  PndSolenoidMap *map_s2 = new PndSolenoidMap("SolenoidMap2", "R");
258  PndSolenoidMap *map_s3 = new PndSolenoidMap("SolenoidMap3", "R");
259  PndSolenoidMap *map_s4 = new PndSolenoidMap("SolenoidMap4", "R");
260 
261  fField->AddField(map_t);
262  fField->AddField(map_d1);
263  fField->AddField(map_d2);
264  fField->AddField(map_s1);
265  fField->AddField(map_s2);
266  fField->AddField(map_s3);
267  fField->AddField(map_s4);
268 
269  fRun->SetField(fField);
270 
271  if(nEvents<101)
272  fRun->SetStoreTraj(kTRUE); // toggle this for use with EVE
273  else
274  fRun->SetStoreTraj(kFALSE);
275 
276 
277  fRun->Init();
278 
279  // -Trajectories Visualization (TGeoManager Only )
280  // -----------------------------------------------
281 
282  // Set cuts for storing the trajectpries
283 // FairTrajFilter* trajFilter = FairTrajFilter::Instance();
284 // trajFilter->SetStepSizeCut(0.01); // 1 cm
285 // trajFilter->SetVertexCut(-200., -200., -200, 200., 200., 200.);
286 // trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
287 // trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
288 // trajFilter->SetStorePrimaries(kTRUE);
289 // trajFilter->SetStoreSecondaries(kTRUE);
290 
291 
292  // Fill the Parameter containers for this run
293  //-------------------------------------------
294  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
295  Bool_t kParameterMerged=kTRUE;
296  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
297  output->open(parOutput.Data(),"RECREATE");
298  rtdb->setOutput(output);
299  PndMultiFieldPar* Par = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
300  if (fField) { Par->SetParameters(fField); }
301  Par->setInputVersion(fRun->GetRunId(),1);
302  Par->setChanged();
303 
304  // Transport nEvents
305  // -----------------
306 
307  fRun->Run(nEvents);
308 
309  rtdb->saveOutput();
310  rtdb->print();
311 
312 
313  timer.Stop();
314  Double_t rtime = timer.RealTime();
315  Double_t ctime = timer.CpuTime();
316  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
317 }
318 
319 #include<TApplication.h>
320 #include<iostream>
321 
322 using namespace std;
323 
324 /* arguments
325  * 1: total number of events to simulate
326  * 2: energy of anti protons
327  * 3: displacement of the vertex in x [cm]
328  * 4: displacement of the vertex in y [cm]
329  */
330 
331 
332 int main(int argc, char **argv){
333  cout << " running box generator " << endl;
334  if (argc > 1){
335  nEvents = atoi(argv[1]);
336  cout << " generating " << nEvents << " anti protons " << endl;
337  }
338  if (argc > 2){
339  mom = atof(argv[2]);
340  cout << " with a momentum of " << mom << " GeV/c " << endl;
341  }
342  if (argc > 3){
343  dx = atof(argv[3]);
344  cout << " a displacement of " << dx << " [cm] in x " << endl;
345  }
346  if (argc > 4){
347  dy = atof(argv[4]);
348  cout << " a displacement of " << dy << " [cm] in y " << endl;
349  }
350  //TApplication myapp("runLumi0SimBox",0,0);
351  runLumiSimBox();// 8.9);
352  //myapp.Run();
353  return 0;
354 }
355 
PndMultiField * fField
Definition: sim_emc_apd.C:97
int main(int argc, char **argv)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
double dy
double theta_high
int verboseLevel
Definition: Lars/runMvdSim.C:7
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
void SetExclusiveSensorType(const TString sens)
void SetParameters(FairField *field)
TString storePath
Double_t mom
Definition: plot_dirc.C:14
PndDipoleMap * map_d2
Definition: sim_hit_emc.C:111
PndSolenoidMap * map_s1
Definition: sim_hit_emc.C:112
FairBoxGenerator * fBox
double theta_low
double phi_high
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
const int particle
TString parOutput
FairRunAna * fRun
Definition: hit_dirc.C:58
void runGeaneTestSimBox()
Double_t
FairModule * Dipole
Definition: sim_emc_apd.C:40
FairModule * Cave
Definition: sim_emc_apd.C:32
PndSolenoidMap * map_s3
Definition: sim_hit_emc.C:114
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
PndSolenoidMap * map_s2
Definition: sim_hit_emc.C:113
Double_t ctime
Definition: hit_dirc.C:114
double dx
void runLumiSimBox()
double phi_low
TString simOutput
PndMultiFieldPar * Par
Definition: sim_emc_apd.C:115
void AddField(FairField *field)
double mom_spread
void SetVerboseLevel(Int_t level)
PndDipoleMap * map_d1
Definition: sim_hit_emc.C:110
PndTransMap * map_t
Definition: sim_hit_emc.C:109
Double_t rtime
Definition: hit_dirc.C:113
FairModule * Magnet
Definition: sim_emc_apd.C:36
PndSolenoidMap * map_s4
Definition: sim_hit_emc.C:115
Definition: PndCave.h:8