exp1803_sim_digi.C

макрос симуляции - Vitaliy Schetinin, 04/12/2018 06:35 PM

Download (11.4 KB)

 
1
void exp1803_sim_digi(Int_t nEvents = 100) {
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.h2.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, 0);
153
  generator->SetPhiRange(0, 360);
154
  generator->SetBoxXYZ(0, 0, 0, 0, beamStartPosition);
155
  generator->SpreadingOnTarget(); 
156

    
157
  primGen->AddGenerator(generator);
158
  run->SetGenerator(primGen);
159

    
160
  // ------- Decayer --------------------------------------------------------
161
  Double_t massH5 = 4.69036244;  // [GeV]
162

    
163
  ERDecayer* decayer = new ERDecayer();
164
  ERDecayEXP1803* targetDecay = new ERDecayEXP1803();
165
  targetDecay->SetAngularDistribution("Cs_6He_d_3He_5H_35-25AMeV.txt");
166
  targetDecay->SetTargetVolumeName("tubeH2");
167
  targetDecay->SetTargetThickness(targetH2Thickness);
168
  targetDecay->SetH5Mass(massH5);
169
  targetDecay->SetH5Exitation(0.0004, 0.00002355, 1);
170
  targetDecay->SetH5Exitation(0.0012, 0.0002355, 1);
171

    
172
  decayer->AddDecay(targetDecay);
173
  run->SetDecayer(decayer);
174

    
175
  // ------- Magnetic field -------------------------------------------------
176
  // ERFieldMap* magField = new ERFieldMap("exp1803Field","A"); //exp1803Field, testField
177
  // magField->SetVolume("magnet");
178
  // run->SetField(magField);
179
    // ------- QTelescope Digitizer -------------------------------------------
180
  ERQTelescopeDigitizer* qtelescopeDigitizer = new ERQTelescopeDigitizer(verbose);
181
  qtelescopeDigitizer->SetSiElossThreshold(0);
182
  qtelescopeDigitizer->SetSiElossSigma(0);
183
  qtelescopeDigitizer->SetSiTimeSigma(0);
184

    
185
  qtelescopeDigitizer->SetCsIElossThreshold(0);
186
  qtelescopeDigitizer->SetCsIElossSigma(0);
187
  qtelescopeDigitizer->SetCsITimeSigma(0);
188
  run->AddTask(qtelescopeDigitizer);
189
  // ------  Gadast Digitizer -----------------------------------------------
190
  ERGadastDigitizer* gadastDigitizer = new ERGadastDigitizer(verbose);
191
  //run->AddTask(gadastDigitizer);
192
  // -----  BeamDet Digitizer ----------------------------------------------
193
  ERBeamDetDigitizer* beamDetDigitizer = new ERBeamDetDigitizer(verbose);
194
  // beamDetDigitizer->SetMWPCElossThreshold(0.006);
195
  // beamDetDigitizer->SetToFElossThreshold(0.006);
196
  // beamDetDigitizer->SetToFElossSigmaOverEloss(0);
197
  // beamDetDigitizer->SetToFTimeSigma(1e-10);
198
  run->AddTask(beamDetDigitizer);
199

    
200
  ERBeamDetTrackFinder* trackFinder = new ERBeamDetTrackFinder(verbose);
201
  run->AddTask(trackFinder);
202
  //-------Set visualisation flag to true------------------------------------
203
  //run->SetStoreTraj(kTRUE);
204
  //-------Set LOG verbosity  ----------------------------------------------- 
205
  FairLogger::GetLogger()->SetLogScreenLevel("INFO");
206
  // -----   Initialize simulation run   ------------------------------------
207
  run->Init();
208
  Int_t nSteps = -15000;
209
  // -----   Runtime database   ---------------------------------------------
210
  Bool_t kParameterMerged = kTRUE;
211
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
212
  parOut->open(parFile.Data());
213
  rtdb->setOutput(parOut);
214
  rtdb->saveOutput();
215
  rtdb->print();
216
  //gMC->SetMaxNStep(nSteps);
217
  run->CreateGeometryFile("setup.root");
218
  // -----   Run simulation  ------------------------------------------------
219
  run->Run(nEvents);
220

    
221
  // -----   Finish   -------------------------------------------------------
222
  timer.Stop();
223
  Double_t rtime = timer.RealTime();
224
  Double_t ctime = timer.CpuTime();
225
  cout << endl << endl;
226
  cout << "Macro finished succesfully." << endl;
227
  cout << "Output file is sim.root" << endl;
228
  cout << "Parameter file is par.root" << endl;
229
  cout << "Real time " << rtime << " s, CPU time " << ctime
230
          << "s" << endl << endl;
231
}