exp1803_sim_digi.C

Ivan Muzalevsky, 03/20/2018 06:10 PM

Download (12.7 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 = -4;  // [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_digi.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
  // ----- T1 parameters ----------------------------------------------------
97
  TVector3 SD1Rotation(0., 27., 0.);
98
  TVector3 SD2Rotation(0., -27., 0.);
99
  Double_t xPos, yPos, zPos;
100
  TVector3* T1Translation;
101
  // ----- T1.1--------------------------------------------------------------
102
  setupQTelescope->AddSi("DoubleSi_SD1", TVector3( 9.07981,0., 17.8201), SD1Rotation,"X");
103
  setupQTelescope->AddSi("DoubleSi_SD2", TVector3( -9.07981,0., 17.8201), SD2Rotation,"X");
104
  // // ----- T1.2--------------------------------------------------------------
105
  // setupQTelescope->AddSi("DoubleSi_SD1", TVector3( T1Side/2 - T1Aperture/2, 
106
  //                                                 -T1Side/2 - T1Aperture/2,  
107
  //                                                  T1PosZ + T1D1Thick/2), T1Rotation, "X");
108
  // setupQTelescope->AddSi("DoubleSi_SD2", TVector3( T1Side/2 - T1Aperture/2, 
109
  //                                                 -T1Side/2 - T1Aperture/2,  
110
  //                                                  T1PosZ   + T1D1Thick +T1Dl + T1D2Thick/2), T1Rotation, "X");
111
  // // ----- T1.3 -------------------------------------------------------------
112
  // setupQTelescope->AddSi("DoubleSi_SD1", TVector3(-T1Side/2 - T1Aperture/2, 
113
  //                                                 -T1Side/2 + T1Aperture/2,  
114
  //                                                  T1PosZ   + T1D1Thick/2), T1Rotation, "X");
115
  // setupQTelescope->AddSi("DoubleSi_SD2", TVector3(-T1Side/2 - T1Aperture/2, 
116
  //                                                 -T1Side/2 + T1Aperture/2,  
117
  //                                                  T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), T1Rotation, "X");
118
  // // ----- T1.4--------------------------------------------------------------
119
  // setupQTelescope->AddSi("DoubleSi_SD1", TVector3(-T1Side/2 + T1Aperture/2, 
120
  //                                                  T1Side/2 + T1Aperture/2,  
121
  //                                                  T1PosZ + T1D1Thick/2), T1Rotation, "X");
122
  // setupQTelescope->AddSi("DoubleSi_SD2", TVector3(-T1Side/2 + T1Aperture/2, 
123
  //                                                  T1Side/2 + T1Aperture/2,  
124
  //                                                  T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), T1Rotation, "X");
125

    
126
  // ----- D1 parameters ----------------------------------------------------
127
  TVector3* D1Rotation = new TVector3(0., 5., 0);
128
  setupQTelescope->AddSi("DoubleSi_D1", TVector3( 0, 
129
                                                  0,  
130
                                                  D1PosZ + D1Thick/2), *D1Rotation, "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 = 40.;
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->SetKinERange(0,kin_energy);
153
  generator->SetThetaSigma(0, 0);
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

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

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

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

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

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