exp1803_sim_digi.C

Ivan Muzalevsky, 03/06/2018 06:13 PM

Download (12.5 KB)

 
1
void exp1803_sim_digi(Int_t nEvents = 10000) {
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 = -40;  // [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= "/store/ivan/EXP1803/temp/sim.root";
23
  TString parFile= "/store/ivan/EXP1803/temp/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
 
40
  // -----   Create simulation run   ----------------------------------------
41
  ERRunSim* run = new ERRunSim();
42
  /** Select transport engine
43
  * TGeant3
44
  * TGeant4
45
  **/
46
  run->SetName("TGeant4");              // Transport engine
47
  run->SetOutputFile(outFile.Data());          // Output file
48
  // ------------------------------------------------------------------------
49
  // -----   Runtime database   ---------------------------------------------
50
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
51
    //-------- Set MC event header --------------------------------------------
52
  ERDecayMCEventHeader* decayMCheader = new ERDecayMCEventHeader();
53
  run->SetMCEventHeader(decayMCheader);
54
  // -----   Create media   -------------------------------------------------
55
  run->SetMaterials("media.geo");       // Materials
56
  // -----   Create detectors  ----------------------------------------------   
57
  FairModule* cave= new ERCave("CAVE");
58
  cave->SetGeometryFileName("cave.geo");
59
  run->AddModule(cave);
60
   
61
  Int_t verbose = 0;
62
  // -----  BeamDet Setup ---------------------------------------------------
63
  ERBeamDetSetup* setupBeamDet = ERBeamDetSetup::Instance();
64
  setupBeamDet->SetXmlParametersFile(paramFileBeamDet);
65

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

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

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

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

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

    
93
  // -----  QTelescope Setup ------------------------------------------------
94
  ERQTelescopeSetup* setupQTelescope = ERQTelescopeSetup::Instance();
95
  setupQTelescope->SetXmlParametersFile(paramFileQTelescope);
96

    
97
  // ----- T1 parameters ----------------------------------------------------
98
  // ----- T1.1--------------------------------------------------------------
99
  setupQTelescope->AddSi("DoubleSi_SD1", TVector3( T1Side/2 + T1Aperture/2, 
100
                                                   T1Side/2 - T1Aperture/2,  
101
                                                   T1PosZ + T1D1Thick/2), "X");
102
  setupQTelescope->AddSi("DoubleSi_SD2", TVector3( T1Side/2 + T1Aperture/2, 
103
                                                   T1Side/2 - T1Aperture/2,  
104
                                                   T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), "X");
105
  // ----- T1.2--------------------------------------------------------------
106
  setupQTelescope->AddSi("DoubleSi_SD1", TVector3( T1Side/2 - T1Aperture/2, 
107
                                                  -T1Side/2 - T1Aperture/2,  
108
                                                   T1PosZ + T1D1Thick/2), "X");
109
  setupQTelescope->AddSi("DoubleSi_SD2", TVector3( T1Side/2 - T1Aperture/2, 
110
                                                  -T1Side/2 - T1Aperture/2,  
111
                                                   T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), "X");
112
  // ----- T1.3 -------------------------------------------------------------
113
  setupQTelescope->AddSi("DoubleSi_SD1", TVector3(-T1Side/2 - T1Aperture/2, 
114
                                                  -T1Side/2 + T1Aperture/2,  
115
                                                   T1PosZ + T1D1Thick/2), "X");
116
  setupQTelescope->AddSi("DoubleSi_SD2", TVector3(-T1Side/2 - T1Aperture/2, 
117
                                                  -T1Side/2 + T1Aperture/2,  
118
                                                   T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), "X");
119
  // ----- T1.4--------------------------------------------------------------
120
  setupQTelescope->AddSi("DoubleSi_SD1", TVector3(-T1Side/2 + T1Aperture/2, 
121
                                                   T1Side/2 + T1Aperture/2,  
122
                                                   T1PosZ + T1D1Thick/2), "X");
123
  setupQTelescope->AddSi("DoubleSi_SD2", TVector3(-T1Side/2 + T1Aperture/2, 
124
                                                   T1Side/2 + T1Aperture/2,  
125
                                                   T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), "X");
126

    
127
  // ----- D1 parameters ----------------------------------------------------
128
  setupQTelescope->AddSi("DoubleSi_D1", TVector3( 0, 
129
                                                  0,  
130
                                                  D1PosZ + D1Thick/2), "X");
131

    
132
  // ------QTelescope -------------------------------------------------------
133
  ERQTelescope* qtelescope= new ERQTelescope("ERQTelescope", kTRUE,verbose);
134
  run->AddModule(qtelescope);
135

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

    
140
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
141

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

    
158
  primGen->AddGenerator(generator);
159
  run->SetGenerator(primGen);
160
  // ------- Decayer --------------------------------------------------------
161
  Double_t massH5 = 4.8;  // [GeV]
162

    
163
  ERDecayer* decayer = new ERDecayer();
164
  ERDecayEXP1803* targetDecay = new ERDecayEXP1803();
165
  targetDecay->SetTargetVolumeName("tubeH2");
166
  targetDecay->SetTargetThickness(targetH2Thickness);
167
  // targetDecay->SetH5Mass(massH5);
168
  targetDecay->SetH5Exitation(0.4, 0.02355, 1);
169
  targetDecay->SetH5Exitation(1.2, 0.2355, 1);
170
  decayer->AddDecay(targetDecay);
171
  run->SetDecayer(decayer);
172

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

    
183
  qtelescopeDigitizer->SetCsIElossThreshold(0);
184
  qtelescopeDigitizer->SetCsIElossSigma(0);
185
  qtelescopeDigitizer->SetCsITimeSigma(0);
186
  run->AddTask(qtelescopeDigitizer);
187
  // ------  Gadast Digitizer -----------------------------------------------
188
  ERGadastDigitizer* gadastDigitizer = new ERGadastDigitizer(verbose);
189
  run->AddTask(gadastDigitizer);
190
  // -----  BeamDet Digitizer ----------------------------------------------
191
  ERBeamDetDigitizer* beamDetDigitizer = new ERBeamDetDigitizer(verbose);
192
  // beamDetDigitizer->SetMWPCElossThreshold(0.006);
193
  // beamDetDigitizer->SetToFElossThreshold(0.006);
194
  // beamDetDigitizer->SetToFElossSigmaOverEloss(0);
195
  // beamDetDigitizer->SetToFTimeSigma(1e-10);
196
  run->AddTask(beamDetDigitizer);
197
  // ------- BeamDet TrackFinder -------------------------------------------
198
  ERBeamDetTrackFinder* trackFinder = new ERBeamDetTrackFinder(verbose);
199
  run->AddTask(trackFinder);
200
  // -----------------------BeamDetTrackPID----------------------------------
201
  ERBeamDetPID* pid = new ERBeamDetPID(verbose);
202
  pid->SetIonMassNumber(A);
203
  pid->SetBoxPID(0., 1000., 0., 1000.);
204
  pid->SetOffsetToF(0.);
205
  pid->SetProbabilityThreshold(0);
206
  run->AddTask(pid);  
207
  // ------- QTelescope TrackFinder -------------------------------------------
208
  ERQTelescopeTrackFinder* qtelescopeTrackFinder = new ERQTelescopeTrackFinder(verbose);
209
  qtelescopeTrackFinder->SetHitStation("DoubleSi_SD2_XY_1");
210
  qtelescopeTrackFinder->SetHitStation("DoubleSi_SD2_XY_3");
211
  qtelescopeTrackFinder->SetStripEdepRange(0., 100.);          // [GeV]
212
  qtelescopeTrackFinder->SetTargetPoint(0., 0., 0.);
213
  // qtelescopeTrackFinder->SetStripEdepRange(0.0097, 100.);   // [GeV]
214
  // qtelescopeTrackFinder->SetEdepDiffXY(5.);                 // [GeV]
215
  qtelescopeTrackFinder->SetEdepMaxDiffXY(0.5); 
216
  run->AddTask(qtelescopeTrackFinder); 
217
  //-------Set visualisation flag to true------------------------------------
218
  run->SetStoreTraj(kTRUE);
219
  //-------Set LOG verbosity  ----------------------------------------------- 
220
  FairLogger::GetLogger()->SetLogScreenLevel("INFO");
221
  // -----   Initialize simulation run   ------------------------------------
222
  run->Init();
223
  Int_t nSteps = -15000;
224
  // -----   Runtime database   ---------------------------------------------
225
  Bool_t kParameterMerged = kTRUE;
226
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
227
  parOut->open(parFile.Data());
228
  rtdb->setOutput(parOut);
229
  rtdb->saveOutput();
230
  rtdb->print();
231
  //gMC->SetMaxNStep(nSteps);
232
  // -----   Run simulation  ------------------------------------------------
233
  run->Run(nEvents);
234
  
235
  // -----   Finish   -------------------------------------------------------
236
  timer.Stop();
237
  Double_t rtime = timer.RealTime();
238
  Double_t ctime = timer.CpuTime();
239
  cout << endl << endl;
240
  cout << "Macro finished succesfully." << endl;
241
  cout << "Output file is sim.root" << endl;
242
  cout << "Parameter file is par.root" << endl;
243
  cout << "Real time " << rtime << " s, CPU time " << ctime
244
          << "s" << endl << endl;
245
}