FairRoot/PandaRoot
runDPMsim.C
Go to the documentation of this file.
1 /*
2  * rumDPMsim.C* * Created on: Jan 4, 2010 * Author: huagen
3  */
4 //The macro is to make the simulation run after constructing the detector Geometry, defining
5 // the physics process, creating the event generator.
6 
7 void runMCsim()
8 { TStopwatch timer;
9  timer.Start();
10 
11  Int_t nEvents = 1e3;
12  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
13  rootlogon();
14 
16  FairRunSim *fRun = new FairRunSim();
17 
18  //Output data FileNames
19 // TString simOutput="/private2/huagen/fairroot/pandaroot_bak/macro/lmd/Lmd_DPM_6.2_elastic_1.9mrad_3M.root";
20  TString simOutput="/private/huagen/simdata/Lmd_MC_DPM_elastic_6.2_1.9mrad_10M_test.root";
21  TString parOutput="/private/huagen/simdata/LmdParamsRecoil.root";// ?
22 
23  fRun->SetName("TGeant3");
24  fRun->SetOutputFile(simOutput);
25  fRun->SetMaterials("media_pnd.geo");
26 
27 // *************************************************************
28 // Step 1 of the main flowchart to create detector
29 // *************************************************************
30  // Create and add detectors // Add cave of panda, it's one of the FAIR moduel
31  FairModule *Cave= new PndCave("CAVE");
32  Cave->SetGeometryFileName("pndcave.geo");
33  fRun->AddModule(Cave);
34  // Add magnet of panda on this macro, also FAIR module
35 // FairModule *Magnet= new PndMagnet("MAGNET");
36 // Magnet->SetGeometryFileName("magnet.geo");
37 // fRun->AddModule(Magnet);
38  // Add beam pine around target, FAIR module
39  FairModule *Pipe= new PndPipe("PIPE");
40 // Pipe->SetGeometryFileName("pipebeamtarget_recoil.geo");
41  fRun->AddModule(Pipe);
42  // Define the Lumi monitor detector, it's a FairDetector instead of FAIR module.
43  //cout<<"the fairdetector definition is OK!";
44  FairDetector* Lmd= new PndLmdDetector("lmd",kTRUE);
45  Lmd->SetGeometryFileName("recoil.geo");
46  Lmd->SetVerboseLevel(1);
47  fRun->AddModule(Lmd);
48 
49 // ***************************************************************
50 // Step 2 of the main flowchart to define the event generator
51 // ***************************************************************
52  // Create and set event generator // Invoke the primGen for this simulation run
53  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
54  fRun->SetGenerator(primGen);
55 
56  // Dpm Generator
58  new PndDpmGenerator("/home/huagen/fairroot/pandarootJun24/trunk/pgenerators/DpmEvtGen/Background-micro_6.2_elastic_0.113_1.9mrad_10M.root");
59  primGen->AddGenerator(dpmGen);
60 
61 // Field Map Definition
62  // // MultiField:
64 
65  PndTransMap *map_t = new PndTransMap("TransMap", "R");
66  PndDipoleMap *map_d = new PndDipoleMap("DipoleMap", "R");
67 // PndSolenoidMap *map_s = new PndSolenoidMap("SolenoidMap", "R");
68  PndSolenoidMap *map_s1 = new PndSolenoidMap("SolenoidMap1", "R");
69  PndSolenoidMap *map_s2 = new PndSolenoidMap("SolenoidMap2", "R");
70  PndSolenoidMap *map_s3 = new PndSolenoidMap("SolenoidMap3", "R");
71  PndSolenoidMap *map_s4 = new PndSolenoidMap("SolenoidMap4", "R");
72 
73 // fField->AddField(map_t);
74 // fField->AddField(map_d);
75 // fField->AddField(map_s);
76 // fField->AddField(map_s1);
77 // fField->AddField(map_s2);
78 // fField->AddField(map_s3);
79 // fField->AddField(map_s4);
80 
81 //switch offf the field on Jul. 13 2009
82 // fRun->SetField(fField);
83 
84  fRun->SetStoreTraj(kTRUE);
85  //fRun->SetStoreTraj(kFALSE);
86  fRun->Init();
87 
88  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
90  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
91  output->open(parOutput.Data(), "RECREATE");
92  rtdb->setOutput(output);
93 
94  // Initalize the monte carlo // ------------------------
95  PndMultiFieldPar* fieldPar = (PndMultiFieldPar*) rtdb->getContainer("PndMultiFieldPar");
96  if ( fField ) { fieldPar->SetParameters(fField); }
97  fieldPar->setInputVersion(fRun->GetRunId(),1);
98  fieldPar->setChanged(kTRUE);
99 
100  rtdb->saveOutput();
101  rtdb->print();
102 
103  fRun->Run(nEvents);
104 
105  timer.Stop();
106  Double_t rtime = timer.RealTime();
107  Double_t ctime = timer.CpuTime();
108  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
109 }
111 {
112  runMCsim();
113  return 0;
114 }
PndMultiField * fField
Definition: sim_emc_apd.C:97
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
PndDpmGenerator * dpmGen
void SetParameters(FairField *field)
#define pi
Definition: createSTT.C:60
PndSolenoidMap * map_s1
Definition: sim_hit_emc.C:112
FairParRootFileIo * output
Definition: sim_emc_apd.C:120
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
TString parOutput
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t
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
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
PndSolenoidMap * map_s2
Definition: sim_hit_emc.C:113
Double_t ctime
Definition: hit_dirc.C:114
int runDPMsim()
Definition: runDPMsim.C:110
TString simOutput
PndTransMap * map_t
Definition: sim_hit_emc.C:109
FairModule * Pipe
Definition: sim_emc_apd.C:44
Double_t rtime
Definition: hit_dirc.C:113
void runMCsim()
Definition: runDPMsim.C:7
Double_t Pi
PndSolenoidMap * map_s4
Definition: sim_hit_emc.C:115
Definition: PndCave.h:8