exp1803_sim_digi.C

Mikhail Kozlov, 07/15/2018 04:04 PM

Download (12.5 KB)

 
1
void exp1803_sim_digi(Int_t nEvents = 1000) {
2
  // --------------- Telescope T1 -------------------------------------------
3
  Double_t T1Dl = 0.5;         // [cm]      
4
  Double_t T1PosZ = 10.;       // [cm] 
5
  Double_t T1D1Thick = 0.002;  // [cm]  
6
  Double_t T1D2Thick = 0.1;    // [cm] 
7
  Double_t T1Side = 6.2;       // [cm]  this parameter should coincide with SD1 side length from /db/QTelescope/QTelescopeParts.xml
8
  Double_t T1Aperture = 3.1;   // [cm]  
9
  // --------------- Telescope D1 -------------------------------------------
10
  Double_t D1PosZ = 20.;       // [cm]
11
  Double_t D1Thick = 0.03;     // [cm]
12
  // --------------- BeamDet ------------------------------------------------
13
  Double_t BeamDetLToF = 1500.;     // [cm] 
14
  Double_t BeamDetPosZToF = -50;  // [cm] 
15
  Double_t BeamDetLMWPC = 32.;     // [cm]
16
  Double_t BeamDetPosZMWPC = -8;  // [cm]  
17
  // --------------- Beam start position ------------------------------------
18
  Double_t beamStartPosition = -1600;  // [cm]
19
  // --------------- Target -------------------------------------------------
20
  Double_t targetH2Thickness = 0.4;  // [cm] this parameter should coincide with target H2 thickness in /macro/geo/create_target_h2_geo.C
21
  //---------------------Files-----------------------------------------------
22
  TString outFile= "sim_digi.root";
23
  TString parFile= "par.root";
24
  TString workDirPath = gSystem->Getenv("VMCWORKDIR");
25
  TString paramFileQTelescope = workDirPath
26
                         + "/db/QTelescope/QTelescopeParts.xml";
27
  TString paramFileBeamDet = workDirPath
28
                         + "/db/BeamDet/BeamDetParts.xml";
29
  TString targetGeoFileName = workDirPath + "/geometry/target_CD2_geo.root";
30
  TString gadastGeoFileName = workDirPath + "/geometry/partOfGadast.v1.geo.root";
31
  TString ndGeoFileName = workDirPath + "/geometry/ND.geo.root";
32
  TString magnetGeoFileName = workDirPath + "/geometry/magnet.geo.root";
33
  // ------------------------------------------------------------------------
34

    
35
  // -----   Timer   --------------------------------------------------------
36
  TStopwatch timer; 
37
  timer.Start();
38
  // ------------------------------------------------------------------------
39
  // -----   Create simulation run   ----------------------------------------
40
  ERRunSim* run = new ERRunSim();
41
  /** Select transport engine
42
  * TGeant3
43
  * TGeant4
44
  **/
45
  run->SetName("TGeant4");              // Transport engine
46
  run->SetOutputFile(outFile.Data());          // Output file
47
  // ------------------------------------------------------------------------
48
  // -----   Runtime database   ---------------------------------------------
49
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
50
  //-------- Set MC event header --------------------------------------------
51
  ERDecayMCEventHeader* decayMCheader = new ERDecayMCEventHeader();
52
  run->SetMCEventHeader(decayMCheader);
53
  // -----   Create media   -------------------------------------------------
54
  run->SetMaterials("media.geo");       // Materials
55
  // -----   Create detectors  ----------------------------------------------   
56
  FairModule* cave= new ERCave("CAVE");
57
  cave->SetGeometryFileName("cave.geo");
58
  run->AddModule(cave);
59
   
60
  Int_t verbose = 0;
61
  // -----  BeamDet Setup ---------------------------------------------------
62
  ERBeamDetSetup* setupBeamDet = ERBeamDetSetup::Instance();
63
  setupBeamDet->SetXmlParametersFile(paramFileBeamDet);
64

    
65
  // -----  BeamDet parameters ----------------------------------------------
66
  setupBeamDet->AddToF("ToF1", BeamDetPosZToF - BeamDetLToF);       // 
67
  setupBeamDet->AddToF("ToF1", BeamDetPosZToF);                     //  BeamDet parts should be added in ascending order   
68
  setupBeamDet->AddMWPC("MWPC1", BeamDetPosZMWPC - BeamDetLMWPC);   //  of Z-coordinate of part.
69
  setupBeamDet->AddMWPC("MWPC1", BeamDetPosZMWPC);                  // 
70
  // setupBeamDet->SetSensitiveTarget();
71

    
72
  // -----   Create target  -------------------------------------------------
73
  FairModule* target = new ERTarget("targetH2", kTRUE, 1);
74
  target->SetGeometryFileName(targetGeoFileName);
75
  run->AddModule(target);
76

    
77
  // -----   Create Part of Gadast ------------------------------------------
78
  ERGadast* gadast = new ERGadast("PartofGadast", kTRUE, 1);
79
  gadast->SetGeometryFileName(gadastGeoFileName);
80
  //run->AddModule(gadast);
81

    
82
  // -----   Create Stilbene wall -------------------------------------------
83
  ERND* neutronDetector = new ERND("StilbeneWall", kTRUE, 1);
84
  neutronDetector->SetGeometryFileName(ndGeoFileName);
85
  //run->AddModule(neutronDetector);
86

    
87
  // -----   Create Magnet geometry -----------------------------------------
88
  FairModule* magnet = new ERTarget("magnet", 1, kTRUE);
89
  magnet->SetGeometryFileName(magnetGeoFileName);
90
  //run->AddModule(magnet);
91

    
92
  // -----  QTelescope Setup ------------------------------------------------
93
  ERQTelescopeSetup* setupQTelescope = ERQTelescopeSetup::Instance();
94
  setupQTelescope->SetXMLParametersFile(paramFileQTelescope);
95
  setupQTelescope->SetGeoName("QTelescopeTmp");
96
  // ----- T1 parameters ----------------------------------------------------
97
  Double_t xPos, yPos, zPos;
98
  Double_t radius = 23.;
99
  TVector3 rotationT1(0., 12., 0.);
100
  xPos = radius * TMath::Sin(rotationT1.Y() * TMath::DegToRad());
101
  yPos = 0.;
102
  zPos = radius * TMath::Cos(rotationT1.Y() * TMath::DegToRad());
103
  ERGeoSubAssembly* assemblyT1 = new ERGeoSubAssembly("T1", TVector3(xPos, yPos, zPos), rotationT1);
104
  ERQTelescopeGeoComponentSingleSi* thinT1 = new ERQTelescopeGeoComponentSingleSi("SingleSi", "SingleSi_1", 
105
                                                                                  TVector3(0., 0., -5.36), TVector3(), "X");
106
  ERQTelescopeGeoComponentDoubleSi* thickT1 = new ERQTelescopeGeoComponentDoubleSi("DoubleSi", "DoubleSi_SD2", 
107
                                                                                  TVector3(0, 0, 0.), TVector3(), "X");
108
  ERQTelescopeGeoComponentCsI* csi1 = new ERQTelescopeGeoComponentCsI("CsI", "CsI_1", TVector3(0, 0, 5.), TVector3());
109
  assemblyT1->AddComponent(thinT1);
110
  assemblyT1->AddComponent(thickT1);
111
  assemblyT1->AddComponent(csi1);
112

    
113
  setupQTelescope->AddSubAssembly(assemblyT1);
114
  // ----- T2 parameters ----------------------------------------------------
115
  radius = 29.;
116
  TVector3 rotationT2(0., -8.27, 0.);
117
  xPos = radius * TMath::Sin(rotationT2.Y() * TMath::DegToRad());
118
  yPos = 0.;
119
  zPos = radius * TMath::Cos(rotationT2.Y() * TMath::DegToRad());
120
  ERGeoSubAssembly* assemblyT2 = new ERGeoSubAssembly("T2", TVector3(xPos, yPos, zPos), rotationT2);
121
  /*ERQTelescopeGeoComponentSingleSi* thinT2 = new ERQTelescopeGeoComponentSingleSi("SingleSi", "SingleSi_1", 
122
                                                                                  TVector3(0, 0, 0.), TVector3(), "X");*/
123
  ERQTelescopeGeoComponentDoubleSi* thickT2 = new ERQTelescopeGeoComponentDoubleSi("DoubleSi", "DoubleSi_SD2", 
124
                                                                                  TVector3(0, 0, 0.), TVector3(), "X");
125
  ERQTelescopeGeoComponentCsI* csi2 = new ERQTelescopeGeoComponentCsI("CsI", "CsI_1", TVector3(0, 0, 5.), TVector3());
126
  //assemblyT2->AddComponent(thinT2);
127
  assemblyT2->AddComponent(thickT2);
128
  assemblyT2->AddComponent(csi2);
129

    
130
  setupQTelescope->AddSubAssembly(assemblyT2);
131
  // ------QTelescope -------------------------------------------------------
132
  ERQTelescope* qtelescope= new ERQTelescope("ERQTelescope", kTRUE,verbose);
133
  run->AddModule(qtelescope);
134

    
135
  // ------BeamDet ----------------------------------------------------------
136
  ERBeamDet* beamdet= new ERBeamDet("ERBeamDet", kTRUE,verbose);
137
  run->AddModule(beamdet);
138

    
139
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
140

    
141
  Double_t  kinE_MevPerNucleon = 40.;
142
  // Int_t     Z = 1, A = 3, Q = 1;
143
  // TString   ionName = "3H";
144
    Int_t Z = 2, A = 6, Q = 2;
145
  TString ionName = "6He";
146
  ERIonMixGenerator* generator = new ERIonMixGenerator(ionName, Z, A, Q, 1);
147
  Double32_t kin_energy = kinE_MevPerNucleon * 1e-3 * A; //GeV
148
  generator->SetKinE(kin_energy);
149
  generator->SetPSigmaOverP(0);
150
  Double32_t sigmaTheta = 0.004*TMath::RadToDeg();
151
  // generator->SetKinERange(0,kin_energy);
152
  generator->SetThetaSigma(0, sigmaTheta);
153
  generator->SetPhiRange(0, 360);
154
  generator->SetBoxXYZ(0, 0, 0., 0., beamStartPosition);
155
  generator->SpreadingOnTarget(); 
156

    
157
  /* List of internal FairRoot names of particles that should coincide with 
158
     user defined ones (character case is important):
159
      * Alpha and AntiAlpha (2, 4, 2),
160
      * Deuteron and AntiDeuteron (1, 2, 1),
161
      * Triton and AntiTriton (1, 3, 1),
162
      * HE3 and AntiHE3 (2, 3, 2).
163
  */
164
  generator->AddBackgroundIon("Deuteron", 1, 2, 1, 1. / 13.);
165
  generator->AddBackgroundIon("Triton", 1, 3, 1, 1. / 13.);
166
  generator->AddBackgroundIon("HE3", 2, 3, 2, 1. / 13.);
167
  generator->AddBackgroundIon("Alpha", 2, 4, 2, 1. / 13.);
168
  generator->AddBackgroundIon("6Li", 3, 6, 3, 1. / 13.);
169
  generator->AddBackgroundIon("7Li", 3, 7, 3, 1. / 13.);
170
  generator->AddBackgroundIon("8Li", 3, 8, 3, 1. / 13.);
171
  generator->AddBackgroundIon("9Li", 3, 9, 3, 1. / 13.);
172
  generator->AddBackgroundIon("9Be", 4, 9, 4, 1. / 13.);
173
  generator->AddBackgroundIon("10Be", 4, 10, 4, 1. / 13.);
174
  generator->AddBackgroundIon("11Be", 4, 11, 4, 1. / 13.);
175
  generator->AddBackgroundIon("12Be", 4, 12, 4, 1. / 13.);
176

    
177
  primGen->AddGenerator(generator);
178
  run->SetGenerator(primGen);
179

    
180
  // ------- Decayer --------------------------------------------------------
181
  Double_t massH5 = 4.69036244;  // [GeV]
182

    
183
  ERDecayer* decayer = new ERDecayer();
184
  ERDecayEXP1803* targetDecay = new ERDecayEXP1803();
185
  targetDecay->SetInteractionVolumeName("boxCD");
186
  targetDecay->SetNuclearInteractionLength(1e-3);
187
  targetDecay->SetAngularDistribution("Cs_6He_d_3He_5H_35-25AMeV.txt");
188
  targetDecay->SetTargetThickness(targetH2Thickness);
189
  targetDecay->SetH5Mass(massH5);
190
  targetDecay->SetH5Exitation(0.0004, 0.00002355, 1);
191
  targetDecay->SetH5Exitation(0.0012, 0.0002355, 1);
192
  targetDecay->SetMinStep(1e-5);
193
  targetDecay->SetMaxPathLength(2e-4 * 10 * 1.1);
194

    
195
  decayer->AddDecay(targetDecay);
196
  run->SetDecayer(decayer);
197

    
198
  // ------- Magnetic field -------------------------------------------------
199
  // ERFieldMap* magField = new ERFieldMap("exp1803Field","A"); //exp1803Field, testField
200
  // magField->SetVolume("magnet");
201
  // run->SetField(magField);
202
    // ------- QTelescope Digitizer -------------------------------------------
203
  ERQTelescopeDigitizer* qtelescopeDigitizer = new ERQTelescopeDigitizer(verbose);
204
  qtelescopeDigitizer->SetSiElossThreshold(0);
205
  qtelescopeDigitizer->SetSiElossSigma(0);
206
  qtelescopeDigitizer->SetSiTimeSigma(0);
207

    
208
  qtelescopeDigitizer->SetCsIElossThreshold(0);
209
  qtelescopeDigitizer->SetCsIElossSigma(0);
210
  qtelescopeDigitizer->SetCsITimeSigma(0);
211
  run->AddTask(qtelescopeDigitizer);
212
  // ------  Gadast Digitizer -----------------------------------------------
213
  ERGadastDigitizer* gadastDigitizer = new ERGadastDigitizer(verbose);
214
  //run->AddTask(gadastDigitizer);
215
  // -----  BeamDet Digitizer ----------------------------------------------
216
  ERBeamDetDigitizer* beamDetDigitizer = new ERBeamDetDigitizer(verbose);
217
  // beamDetDigitizer->SetMWPCElossThreshold(0.006);
218
  // beamDetDigitizer->SetToFElossThreshold(0.006);
219
  // beamDetDigitizer->SetToFElossSigmaOverEloss(0);
220
  // beamDetDigitizer->SetToFTimeSigma(1e-10);
221
  run->AddTask(beamDetDigitizer);
222

    
223
  ERBeamDetTrackFinder* trackFinder = new ERBeamDetTrackFinder(verbose);
224
  trackFinder->SetTargetVolume("boxCD");
225
  run->AddTask(trackFinder);
226
  //-------Set visualisation flag to true------------------------------------
227
  run->SetStoreTraj(kTRUE);
228
  //-------Set LOG verbosity  ----------------------------------------------- 
229
  FairLogger::GetLogger()->SetLogScreenLevel("DEBUG");
230
  // -----   Initialize simulation run   ------------------------------------
231
  run->Init();
232
  Int_t nSteps = -15000;
233
  // -----   Runtime database   ---------------------------------------------
234
  Bool_t kParameterMerged = kTRUE;
235
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
236
  parOut->open(parFile.Data());
237
  rtdb->setOutput(parOut);
238
  rtdb->saveOutput();
239
  rtdb->print();
240
  //gMC->SetMaxNStep(nSteps);
241
  run->CreateGeometryFile("setup.root");
242
  // -----   Run simulation  ------------------------------------------------
243
  run->Run(nEvents);
244

    
245
  // -----   Finish   -------------------------------------------------------
246
  timer.Stop();
247
  Double_t rtime = timer.RealTime();
248
  Double_t ctime = timer.CpuTime();
249
  cout << endl << endl;
250
  cout << "Macro finished succesfully." << endl;
251
  cout << "Output file is sim.root" << endl;
252
  cout << "Parameter file is par.root" << endl;
253
  cout << "Real time " << rtime << " s, CPU time " << ctime
254
          << "s" << endl << endl;
255
}