FairRoot/PandaRoot
Functions
detectors/disc/sim.C File Reference

Go to the source code of this file.

Functions

 sim (Int_t nEvents=1, TString SimEngine="TGeant4", Float_t mom=6.231552)
 

Function Documentation

sim ( Int_t  nEvents = 1,
TString  SimEngine = "TGeant4",
Float_t  mom = 6.231552 
)

Definition at line 8 of file detectors/disc/sim.C.

References allDigiFile, BeamMomentum, Bool_t, boxGen, Cave, cos(), ctime, digiFile, Double_t, emcHitProd, fField, fIni, fRun, gDebug, kParameterMerged, mom, nEvents, output, parIo1, phi, Pi, primGen, printf(), r, rtdb, rtime, PndDisc::SetFilterInterval(), PndEvtGenDirect::SetStoreTree(), sqrt(), theta, timer, and TString.

Referenced by PndMasterRunSim::AddSimTasks(), CbmPlane::Initialize(), PndFtof::Initialize(), PndEmc::Initialize(), PndHypGe::Initialize(), PndSciT::Initialize(), main(), PndSoftTriggerTask::RemoveDoubles(), and PndPidCorrelator::SetSimulation().

9 {
10 
11  //-----User Settings:-----------------------------------------------
12  TString OutputFile ="sim.root";
13  TString ParOutputfile ="simparams.root";
14  TString MediaFile ="media_pnd.geo";
15  gDebug = 0;
16  TString digiFile = "all.par"; //The emc run the hit producer directly
17  // choose your event generator
18  Bool_t UseEvtGenDirect =kFALSE;
19  Bool_t UseDpm =kFALSE;
20  Bool_t UseFtf =kFALSE;
21  Bool_t UseBoxGenerator =kTRUE;
22 
23  Double_t BeamMomentum = 0.; // beam momentum ONLY for the scaling of the dipole field.
24  if (UseBoxGenerator)
25  {
26  BeamMomentum =4.0; // ** change HERE if you run Box generator
27  mom = 4.;
28  }
29  else
30  {
31  BeamMomentum = mom; // for DPM/EvtGen BeamMomentum is always = mom
32  }
33  //------------------------------------------------------------------
34  TLorentzVector fIni(0, 0, mom, sqrt(mom*mom+9.3827203e-01*9.3827203e-01)+9.3827203e-01);
35  TDatabasePDG::Instance()->AddParticle("pbarpSystem","pbarpSystem",fIni.M(),kFALSE,0.1,0, "",88888);
36  //------------------------------------------------------------------
37  TStopwatch timer;
38  timer.Start();
39  gRandom->SetSeed();
40 
41  // Create the Simulation run manager--------------------------------
42  FairRunSim *fRun = new FairRunSim();
43  fRun->SetName(SimEngine.Data() );
44  fRun->SetOutputFile(OutputFile.Data());
45  fRun->SetGenerateRunInfo(kFALSE);
46  fRun->SetBeamMom(BeamMomentum);
47  fRun->SetMaterials(MediaFile.Data());
48  fRun->SetUseFairLinks(kTRUE);
49  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
50 
51  // Set the parameters
52  //-------------------------------
53  TString allDigiFile = gSystem->Getenv("VMCWORKDIR");
54  allDigiFile += "/macro/params/";
55  allDigiFile += digiFile;
56 
57 
58  //-------Set the parameter output --------------------
59  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
60  parIo1->open(allDigiFile.Data(),"in");
61  rtdb->setFirstInput(parIo1);
62 
63  //---------------------Set Parameter output ----------
65  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
66  output->open(ParOutputfile.Data());
67  rtdb->setOutput(output);
68 
69  // Create and add detectors
70 
71  //------------------------- CAVE -----------------
72 
73  FairModule *Cave= new PndCave("CAVE");
74  Cave->SetGeometryFileName("pndcave.geo");
75  fRun->AddModule(Cave);
76  //------------------------- Magnet -----------------
77  //FairModule *Magnet= new PndMagnet("MAGNET");
78  //Magnet->SetGeometryFileName("FullSolenoid_V842.root");
79  //Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root");
80  //fRun->AddModule(Magnet);
81 
82  //------------------------- Disc DIRC ------------
83  PndDisc* Disc = new PndDisc("DISC", kTRUE);
84  Disc->SetVerboseLevel(2);
85  Disc->SetGeometryFileName("DIRC_GEO_SIO2.root");
86  Disc->SetFilterInterval(200., 800.);
87  fRun->AddModule(Disc);
88 
89  // Create and Set Event Generator
90  //-------------------------------
91  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
92  fRun->SetGenerator(primGen);
93 
94  if(UseBoxGenerator){ // Box Generator
95  FairBoxGenerator* boxGen = new FairBoxGenerator(211, 1); //211 = pion, 2212 = proton 321 = kaon
96  boxGen->SetPRange(mom,mom); // GeV/c
97  double deg = TMath::Pi()/180.;
98  double theta = 15.;
99  double phi = 45.;
100  double r = 193.9/cos(theta*deg);
101  boxGen->SetPhiRange(phi, phi); // Azimuth angle range [degree]
102  boxGen->SetThetaRange(theta, theta); // Polar angle in lab system range [degree]
103  theta = theta*deg;
104  phi = phi*deg;
105  //boxGen->SetXYZ(r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r*cos(theta)); // cm
106  //boxGen->SetXYZ(29.04, -42.71, 193.9); // cm
107  boxGen->SetXYZ(0, 0, 0); // cm
108  primGen->AddGenerator(boxGen);
109 
110  //FairBoxGenerator* boxGen2 = new FairBoxGenerator(321, 1);
111  //boxGen2->SetPRange(mom,mom); // GeV/c
112  //boxGen2->SetPhiRange(45., 45.); //Azimuth angle range [degree]
113  //boxGen2->SetThetaRange(15., 15.); // Polar angle in lab system range [degree]
114  //boxGen2->SetXYZ(0., 0., 0.); // cm
115  //primGen->AddGenerator(boxGen2);
116 
117  fRun->SetStoreTraj(kTRUE); // to store particle trajectories
118 
119  //Cherenkov photons for testing purpose
120  /*FairBoxGenerator* boxGen = new FairBoxGenerator(50000050, 100); //50000050 pid code for cherenov photons
121  boxGen->SetPRange(2.258e-9, 2.258e-9); // GeV/c
122  boxGen->SetPhiRange(75., 75.); //Azimuth angle range [degree]
123  boxGen->SetThetaRange(90.-32.5, 90.-32.5); // Polar angle in lab system range [degree]
124  boxGen->SetXYZ(3.200016, 104.742558, 195.); // cm
125  primGen->AddGenerator(boxGen);*/
126  }
127  if(UseDpm){
128  PndDpmDirect *Dpm= new PndDpmDirect(mom,1);
129  primGen->AddGenerator(Dpm);
130  }
131  if(UseFtf){
132  // TString macfile = gSystem->Getenv("VMCWORKDIR");
133  // macfile += "/pgenerators/FtfEvtGen/PbarP.mac";
134  // PndFtfDirect *Ftf = new PndFtfDirect(macfile.Data());
135  PndFtfDirect *Ftf = new PndFtfDirect("anti_proton", "G4_H", 1, "ftfp", mom, 123456);
136  primGen->AddGenerator(Ftf);
137  }
138  if(UseEvtGenDirect){
139  TString EvtInput =gSystem->Getenv("VMCWORKDIR");
140  EvtInput+="/macro/run/psi2s_Jpsi2pi_Jpsi_mumu.dec";
141  PndEvtGenDirect *EvtGen = new PndEvtGenDirect("pbarpSystem", EvtInput.Data(), mom);
142  EvtGen->SetStoreTree(kTRUE);
143  primGen->AddGenerator(EvtGen);
144  }
145 
146  //---------------------Create and Set the Field(s)----------
147  PndMultiField *fField= new PndMultiField("AUTO");
148  fRun->SetField(fField);
149 
150  // EMC Hit producer
151  //-------------------------------
153  fRun->AddTask(emcHitProd);
154 
155  //------------------------- Initialize the RUN -----------------
156  fRun->Init();
157  //------------------------- Run the Simulation -----------------
158  fRun->Run(nEvents);
159  //------------------------- Save the parameters -----------------
160  rtdb->saveOutput();
161  //------------------------Print some info and exit----------------
162  timer.Stop();
163  Double_t rtime = timer.RealTime();
164  Double_t ctime = timer.CpuTime();
165  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
166 
167  cout << " Test passed" << endl;
168  cout << " All ok " << endl;
169 
170  //exit(0);
171 
172 };
PndMultiField * fField
Definition: sim_emc_apd.C:97
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
double r
Definition: RiemannTest.C:14
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
creates PndEmcHits from PndEmcPoints
TString digiFile
Definition: bump_emc.C:20
Double_t mom
Definition: plot_dirc.C:14
double BeamMomentum
Definition: sim_ftof_stof.C:17
TString allDigiFile
Definition: hit_muo.C:36
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
FairRunAna * fRun
Definition: hit_dirc.C:58
void SetStoreTree(Bool_t store=true)
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
PndEmcHitProducer * emcHitProd
Double_t ctime
Definition: hit_dirc.C:114
FairParAsciiFileIo * parIo1
Definition: bump_emc.C:53
FairBoxGenerator * boxGen
Definition: sim_emc_apd.C:85
TLorentzVector fIni
Definition: full_core_ntp.C:29
Double_t rtime
Definition: hit_dirc.C:113
Double_t Pi
void SetFilterInterval(Double_t const &wl_min_nm_, Double_t const &wl_max_nm_)
Set the wavelength range of the bandpass filters.
Definition: PndDisc.cxx:634
Definition: PndCave.h:8