BeamDet_sim.C

Vitaliy Schetinin, 09/15/2017 11:22 AM

Download (4.58 KB)

 
1
void BeamDet_sim(Int_t nEvents = 100){
2
  //---------------------Files-----------------------------------------------
3
  TString outFile= "sim1.root";
4
  TString parFile= "par1.root";
5
  // ------------------------------------------------------------------------
6

    
7
  // -----   Timer   --------------------------------------------------------
8
  TStopwatch timer;
9
  timer.Start(); 
10
  // ----
11
  // -----   Create simulation run   ----------------------------------------
12
  FairRunSim* run = new FairRunSim();
13
/** Select transport engine
14
* TGeant3
15
* TGeant4
16
**/
17
  run->SetName("TGeant4");              // Transport engine
18
  run->SetOutputFile(outFile.Data());          // Output file
19
// ------------------------------------------------------------------------
20
// -----   Runtime database   ---------------------------------------------
21
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
22
// ------------------------------------------------------------------------
23
// -----   Create media   -------------------------------------------------
24
  run->SetMaterials("media.geo");       // Materials
25
// ------------------------------------------------------------------------
26

    
27
  //-------- Set MC event header --------------------------------------------
28
  ERMCEventHeader* header = new ERMCEventHeader();
29
  run->SetMCEventHeader(header);
30
  //---------------------------------
31
  // -----   Create detectors  ----------------------------------------------
32
  FairModule* cave= new ERCave("CAVE");
33
  cave->SetGeometryFileName("cave.geo");
34
  run->AddModule(cave);
35

    
36
  // Det definition
37
  /* Select verbosity level
38
   * 0 - only standard logs
39
   * 1 - Print points after each event
40
  */
41
  Int_t verbose = 0;
42
  ERBeamDet* beamDet= new ERBeamDet("ERBeamDet", kTRUE,verbose);
43
  beamDet->SetGeometryFileName("beamdet.v3.geo_2.root");
44

    
45
  beamDet->SetIonPID(1000160280);
46
  run->AddModule(beamDet);
47

    
48
 // FairModule* target = new ERTarget("BeamDetTarget", kTRUE, 1);
49
  //target->SetGeometryFileName("target.h.geo.root");
50
  //run->AddModule(target);
51
  // ---------------.q
52
  //--------------------------------------------------------
53
  // -----   Create PrimaryGenerator   --------------------------------------
54
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
55
  //Ion 28S
56
  Int_t A = 28;
57
  Int_t Z = 16;
58
  Int_t Q = 16;
59

    
60
  ERIonMixGenerator* generator = new ERIonMixGenerator("28S", Z, A, Q, 1);
61
  Double32_t kin_energy = 40 * 1e-3 * 28; //GeV
62
  //generator->SetKinESigma(kin_energy, 0);
63
  generator->SetPSigma(6.7835, 6.7835*0.003);
64
//  generator->SetKinESigma(kin_energy, 0);
65

    
66
  /*
67
   * Set flag to spread corrdinates parameters on target and reconstruct   
68
   * coordinates of beam start by received values 
69
  */
70
  generator->SpreadingOnTarget();
71

    
72
  Double32_t theta = 0;
73
  Double32_t sigmaTheta = 0.004*TMath::RadToDeg();
74
  generator->SetThetaSigma(theta, sigmaTheta);
75
  
76
  generator->SetPhiRange(0, 360);
77

    
78
  Double32_t distanceToTarget = 1533;
79
  Double32_t sigmaOnTarget = 0.5;
80
  generator->SetSigmaXYZ(0, 0, -distanceToTarget, sigmaOnTarget, sigmaOnTarget);
81
  //generator->SetBoxXYZ(-0.4,-0.4,0.4,0.4, -distanceToTarget);
82

    
83
  generator->AddBackgroundIon("26P", 15, 26, 15, 0.25);
84
  generator->AddBackgroundIon("26S", 16, 26, 16, 0.25);
85
  generator->AddBackgroundIon("24Si", 14, 24, 14, 0.25);
86

    
87
  primGen->AddGenerator(generator);
88
  run->SetGenerator(primGen);
89
  // ------------------------------------------------------------------------
90
  //-------Set visualisation flag to true------------------------------------
91
  run->SetStoreTraj(kTRUE);
92

    
93
  //-------Set LOG verbosity  -----------------------------------------------
94
  FairLogger::GetLogger()->SetLogVerbosityLevel("LOW");
95
  // —– Initialize simulation run ———————————— 
96
  run->Init();
97
  Int_t nSteps = -15000;
98

    
99
  // —– Runtime database ——————————————— 
100
  Bool_t kParameterMerged = kTRUE; 
101
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
102
  parOut->open(parFile.Data()); 
103
  rtdb->setOutput(parOut); 
104
  rtdb->saveOutput(); 
105
  rtdb->print(); // 
106
  // -----   Run simulation  ------------------------------------------------
107
    run->Run(nEvents);
108

    
109
    // -----   Finish   -------------------------------------------------------
110
    timer.Stop();
111
    Double_t rtime = timer.RealTime();
112
    Double_t ctime = timer.CpuTime();
113
    cout << endl << endl;
114
    cout << "Macro finished succesfully." << endl;
115
    cout << "Output file is sim.root" << endl;
116
    cout << "Parameter file is par.root" << endl;
117
    cout << "Real time " << rtime << " s, CPU time " << ctime
118
                    << "s" << endl << endl;
119
   // cout << "Energy " << momentum << "; mass " << mass << endl; 
120
}