exp1803_sim_digi_T1pos.C

макрос симмуляции - Vratislav Chudoba, 03/06/2018 10:42 PM

Download (8.85 KB)

 
1
void exp1803_sim_digi_T1pos(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
//        Double_t beamStartPosition = -150;
20
        // --------------- Target -------------------------------------------------
21
        Double_t targetH2Thickness = 0.4;  // [cm] this parameter should coincide with target H2 thickness in /macro/geo/create_target_h2_geo.C
22
        //---------------------Files-----------------------------------------------
23
        TString outFile= "sim_digi.root";
24
        TString parFile= "par.root";
25
        TString workDirPath = gSystem->Getenv("VMCWORKDIR");
26
        TString paramFileQTelescope = workDirPath
27
                        + "/db/QTelescope/QTelescopeParts.xml";
28
        TString paramFileBeamDet = workDirPath
29
                        + "/db/BeamDet/BeamDetParts.xml";
30
        TString targetGeoFileName = workDirPath + "/geometry/target.h2.geo.root";
31
        TString gadastGeoFileName = workDirPath + "/geometry/partOfGadast.v1.geo.root";
32
        TString ndGeoFileName = workDirPath + "/geometry/ND.geo.root";
33
        TString magnetGeoFileName = workDirPath + "/geometry/magnet.geo.root";
34
        // ------------------------------------------------------------------------
35

    
36
        // -----   Timer   --------------------------------------------------------
37
        TStopwatch timer;
38
        timer.Start();
39
        // ------------------------------------------------------------------------
40

    
41
        // -----   Create simulation run   ----------------------------------------
42
        ERRunSim* run = new ERRunSim();
43
        /** Select transport engine
44
         * TGeant3
45
         * TGeant4
46
         **/
47
        run->SetName("TGeant4");              // Transport engine
48
        run->SetOutputFile(outFile.Data());          // Output file
49
        // ------------------------------------------------------------------------
50
        // -----   Runtime database   ---------------------------------------------
51
        FairRuntimeDb* rtdb = run->GetRuntimeDb();
52
        //-------- Set MC event header --------------------------------------------
53
        ERDecayMCEventHeader* decayMCheader = new ERDecayMCEventHeader();
54
        run->SetMCEventHeader(decayMCheader);
55
        // -----   Create media   -------------------------------------------------
56
        run->SetMaterials("media.geo");       // Materials
57
        // -----   Create detectors  ----------------------------------------------
58
        FairModule* cave= new ERCave("CAVE");
59
        cave->SetGeometryFileName("cave.geo");
60
        run->AddModule(cave);
61

    
62
        Int_t verbose = 0;
63
        // -----  BeamDet Setup ---------------------------------------------------
64
        ERBeamDetSetup* setupBeamDet = ERBeamDetSetup::Instance();
65
        setupBeamDet->SetXmlParametersFile(paramFileBeamDet);
66

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

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

    
79
        // -----  QTelescope Setup ------------------------------------------------
80
        ERQTelescopeSetup* setupQTelescope = ERQTelescopeSetup::Instance();
81
        setupQTelescope->SetXmlParametersFile(paramFileQTelescope);
82

    
83
        // ----- T1 parameters ----------------------------------------------------
84
        TVector3 T1Rotation(0., 0., 0);
85
        Double_t xPos, yPos, zPos;
86
        TVector3* T1Translation;
87
        // ----- T1.1--------------------------------------------------------------
88
        setupQTelescope->AddSi("DoubleSi_SD1", TVector3(5, 2, T1PosZ   + T1D1Thick/2), T1Rotation,"X");
89
        setupQTelescope->AddSi("DoubleSi_SD2", TVector3(5, 2, T1PosZ + T1D1Thick +T1Dl + T1D2Thick/2), T1Rotation, "X");
90

    
91
        // ------QTelescope -------------------------------------------------------
92
        ERQTelescope* qtelescope= new ERQTelescope("ERQTelescope", kTRUE,verbose);
93
        run->AddModule(qtelescope);
94

    
95
        // ------BeamDet ----------------------------------------------------------
96
        ERBeamDet* beamdet= new ERBeamDet("ERBeamDet", kTRUE,verbose);
97
        run->AddModule(beamdet);
98

    
99
        FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
100

    
101
        Double_t  kinE_MevPerNucleon = 1.;
102
        Double_t  kinE_MevPerNucleonMax = 32.;
103
        Int_t Z = 2, A = 6, Q = 2;
104
        TString ionName = "6He";
105

    
106
        ERIonMixGenerator* generator = new ERIonMixGenerator(ionName, Z, A, Q, 1);
107

    
108
        generator->AddBackgroundIon("Triton", 1, 3, 1, 0.2 / 0.20);
109
        generator->AddBackgroundIon("Alpha", 1, 4, 1, 0.4 / 0.60);
110
        generator->AddBackgroundIon("HE3", 2, 3, 2, 0.2 / 0.20);
111
        generator->AddBackgroundIon("Deuteron", 1, 2, 1, 0.2 / 0.20);
112
        generator->AddBackgroundIon("proton", 1, 1, 1, 0.2 / 0.20);
113

    
114
        Double32_t kin_energy = kinE_MevPerNucleon * 1e-3 * A; //GeV
115
        Double32_t kin_energy_max = kinE_MevPerNucleonMax * 1e-3 * A; //GeV
116
        generator->SetKinERange(0.001, 0.02);
117
        Double32_t sigmaTheta = 0.004*TMath::RadToDeg();
118
        generator->SetThetaSigma(0, 0);
119
        generator->SetThetaRange(15, 18);
120
        generator->SetPhiRange(0, 270);
121
        generator->SetBoxXYZ(5, 2, 5, 2, 2.);
122

    
123

    
124
        primGen->AddGenerator(generator);
125
        run->SetGenerator(primGen);
126
        // ------- Decayer --------------------------------------------------------
127
        Double_t massH5 = (2*939.565 + 2809.431)*0.001;  // [GeV]
128

    
129
        ERDecayer* decayer = new ERDecayer();
130
        ERDecayEXP1803* targetDecay = new ERDecayEXP1803();
131
        targetDecay->SetTargetVolumeName("tubeH2");
132
        targetDecay->SetTargetThickness(targetH2Thickness);
133
        decayer->AddDecay(targetDecay);
134
        run->SetDecayer(decayer);
135

    
136
        // ------- QTelescope Digitizer -------------------------------------------
137
        ERQTelescopeDigitizer* qtelescopeDigitizer = new ERQTelescopeDigitizer(verbose);
138
        qtelescopeDigitizer->SetSiElossThreshold(0);
139
        qtelescopeDigitizer->SetSiElossSigma(0);
140
        qtelescopeDigitizer->SetSiTimeSigma(0);
141

    
142
        qtelescopeDigitizer->SetCsIElossThreshold(0);
143
        qtelescopeDigitizer->SetCsIElossSigma(0);
144
        qtelescopeDigitizer->SetCsITimeSigma(0);
145
        run->AddTask(qtelescopeDigitizer);
146

    
147
        // -----  BeamDet Digitizer ----------------------------------------------
148
        ERBeamDetDigitizer* beamDetDigitizer = new ERBeamDetDigitizer(verbose);
149
        beamDetDigitizer->SetMWPCElossThreshold(0.0000012);
150
        beamDetDigitizer->SetToFTimeSigma(0.4/2.35);
151
        run->AddTask(beamDetDigitizer);
152

    
153
        // ------- BeamDet TrackFinder -------------------------------------------
154
        ERBeamDetTrackFinder* trackFinder = new ERBeamDetTrackFinder(verbose);
155
        run->AddTask(trackFinder);
156

    
157
        // ------- QTelescope TrackFinder -------------------------------------------
158
        ERQTelescopeTrackFinder* qtelescopeTrackFinder = new ERQTelescopeTrackFinder(verbose);
159
        qtelescopeTrackFinder->SetHitStation("DoubleSi_SD2_XY_1");
160
        qtelescopeTrackFinder->SetStripEdepRange(0., 100.);          // [GeV]
161
        qtelescopeTrackFinder->SetTargetPoint(0., 0., 0.);
162
//        qtelescopeTrackFinder->SetStripEdepRange(0.016, 100.);   // [GeV]
163
        qtelescopeTrackFinder->SetEdepMaxDiffXY(0.5);
164
        run->AddTask(qtelescopeTrackFinder);
165
        //-------Set visualisation flag to true------------------------------------
166
        run->SetStoreTraj(kTRUE);
167
        //-------Set LOG verbosity  -----------------------------------------------
168
        FairLogger::GetLogger()->SetLogScreenLevel("INFO");
169
        // -----   Initialize simulation run   ------------------------------------
170
        run->Init();
171
        Int_t nSteps = -15000;
172
        // -----   Runtime database   ---------------------------------------------
173
        Bool_t kParameterMerged = kTRUE;
174
        FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
175
        parOut->open(parFile.Data());
176
        rtdb->setOutput(parOut);
177
        rtdb->saveOutput();
178
        rtdb->print();
179
        //gMC->SetMaxNStep(nSteps);
180
        // -----   Run simulation  ------------------------------------------------
181
        run->Run(nEvents);
182

    
183
        // -----   Finish   -------------------------------------------------------
184
        timer.Stop();
185
        Double_t rtime = timer.RealTime();
186
        Double_t ctime = timer.CpuTime();
187
        std::cout << std::endl << std::endl;
188
        std::cout << "Macro finished succesfully." << std::endl;
189
        std::cout << "Output file is sim.root" << std::endl;
190
        std::cout << "Parameter file is par.root" << std::endl;
191
        std::cout << "Real time " << rtime << " s, CPU time " << ctime
192
                        << "s" << std::endl << std::endl;
193
}