Commit e46680fc authored by Riccardo Longo's avatar Riccardo Longo
Browse files

Merge branch 'hongboz_2021TBGenerator' into 'master'

Added the 2021 test-beam automatic configuration settings

See merge request !8
parents 2c9e2040 09f3c961
...@@ -92,6 +92,12 @@ class Alignment { ...@@ -92,6 +92,12 @@ class Alignment {
double x_table; double x_table;
/** Y position of the Desy Table **/ /** Y position of the Desy Table **/
double y_table; double y_table;
/** Energy of the beam **/
double beam_energy;
/** Scan name of the beam **/
std::string beam_scan;
/** Type of the beam **/
std::string beam_type;
/** First detector met by the beam **/ /** First detector met by the beam **/
std::string upstream_Det; std::string upstream_Det;
/** Second detector met by the beam **/ /** Second detector met by the beam **/
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
# Descriptions of commands can be found in the UI command tree # Descriptions of commands can be found in the UI command tree
################################# #################################
/beam/type lhc /beam/type TB2021
/beam/pos 0. 0. -140. /beam/pos 0. 0. -140.
/beam/projectBeam -80. mm /beam/projectBeam -80. mm
/beam/nPrimaries 1 /beam/nPrimaries 1
......
...@@ -549,7 +549,7 @@ if(isTrigger){ ...@@ -549,7 +549,7 @@ if(isTrigger){
void DetectorConstruction::LoadConfigurationFile( G4String _inFile ){ void DetectorConstruction::LoadConfigurationFile( G4String _inFile ){
if(_inFile = ""){ if(_inFile == ""){
_inFile = std::getenv("JZCaPA"); _inFile = std::getenv("JZCaPA");
_inFile += "/Utils/Survey_2018.xml"; _inFile += "/Utils/Survey_2018.xml";
} }
...@@ -603,7 +603,7 @@ void DetectorConstruction::LoadConfigurationFile( G4String _inFile ){ ...@@ -603,7 +603,7 @@ void DetectorConstruction::LoadConfigurationFile( G4String _inFile ){
void DetectorConstruction::LoadAlignmentFile( G4String _inFile ){ void DetectorConstruction::LoadAlignmentFile( G4String _inFile ){
bool debug = false; bool debug = false;
if( _inFile = ""){ if( _inFile == ""){
_inFile = std::getenv("JZCaPA"); _inFile = std::getenv("JZCaPA");
_inFile += "/Utils/Alignment_2018.xml"; _inFile += "/Utils/Alignment_2018.xml";
} }
...@@ -633,6 +633,9 @@ void DetectorConstruction::LoadAlignmentFile( G4String _inFile ){ ...@@ -633,6 +633,9 @@ void DetectorConstruction::LoadAlignmentFile( G4String _inFile ){
if(debug){ if(debug){
std::cout << "Found Run Entry in Alignment file for run " << m_runNumber << std::endl; std::cout << "Found Run Entry in Alignment file for run " << m_runNumber << std::endl;
} }
m_XMLparser->getChildValue("Alignment",i,"beam_scan",m_alignment->beam_scan);
m_XMLparser->getChildValue("Alignment",i,"beam_type",m_alignment->beam_type);
m_XMLparser->getChildValue("Alignment",i,"beam_energy",m_alignment->beam_energy);
m_XMLparser->getChildValue("Alignment",i,"x_table",m_alignment->x_table); m_XMLparser->getChildValue("Alignment",i,"x_table",m_alignment->x_table);
m_XMLparser->getChildValue("Alignment",i,"y_table",m_alignment->y_table); m_XMLparser->getChildValue("Alignment",i,"y_table",m_alignment->y_table);
m_XMLparser->getChildValue("Alignment",i,"upstream_Det",m_alignment->upstream_Det); m_XMLparser->getChildValue("Alignment",i,"upstream_Det",m_alignment->upstream_Det);
......
...@@ -64,35 +64,50 @@ void TestBeam2021PrimaryGenerator::GeneratePrimaryVertex(G4Event* event) ...@@ -64,35 +64,50 @@ void TestBeam2021PrimaryGenerator::GeneratePrimaryVertex(G4Event* event)
DetectorConstruction* dC DetectorConstruction* dC
= (DetectorConstruction*)G4RunManager::GetRunManager()->GetUserDetectorConstruction(); = (DetectorConstruction*)G4RunManager::GetRunManager()->GetUserDetectorConstruction();
if(event->GetEventID() == 0){ if(event->GetEventID() == 0){
G4String _inFile = (std::string)std::getenv("JZCaPA") + "/Utils/Survey_2021.xml"; G4String _inFile = (std::string)std::getenv("JZCaPA") + "/Utils/Alignment_2021.xml"; // I added corresponding scan name in each run
dC->LoadAlignmentFile( _inFile.c_str() ); dC->LoadAlignmentFile( _inFile.c_str() );
m_alignment = dC->GetAlignment(); m_alignment = dC->GetAlignment();
} }
G4cout << "This doesn't do anything yet" << G4endl; // Define the position of the particle
G4String _profile = (std::string)std::getenv("JZCaPA") + "/Utils/2021testbeam_scan/" + m_alignment.beam_scan + ".txt"; //Select the corresponding scan file according to run number
if (m_alignment.beam_scan == ""){
G4cout << " ==== This Run does not belong to any processed Scan ==== " << G4endl; // You can check ("JZCaPA")/Utils/2021testbeam_scan/README.md
}
const int WireChamberSize = 101;
G4double probListX[WireChamberSize],
probListY[WireChamberSize];
// Put the X and Y beam profile into two arrays
std::ifstream _scanfile(_profile);
for(int j = 0; j < 2; ++j){
for(int i = 0; i < WireChamberSize; ++i){
if (!j){
_scanfile >> probListX[i];
}
_scanfile >> probListY[i];
}
}
_scanfile.close();
// // Define the position of the particle G4RandGeneral RandX(probListX, WireChamberSize); //Generate the random number, range (0, 1)
// G4double x = yourRandomDistributionX; //x position G4RandGeneral RandY(probListY, WireChamberSize);
// G4double y = yourRandomDistributionY; //y position G4double x = RandX.shoot()*(WireChamberSize-1)-(WireChamberSize-1)/2; //Map (0, 1) to (-50, 50), RandNum * 100 - 50
// G4ThreeVector position(x,y,0); //Insert x and y into a vector. Beam will be at zero G4double y = RandY.shoot()*(WireChamberSize-1)-(WireChamberSize-1)/2;
// G4double time = 0*s; //Time is always zero for us G4ThreeVector position(x, y, 0);
// // G4double time = 0*s;
// G4PrimaryVertex* vertex = new G4PrimaryVertex(position, time); //Insert the position and time into a primary vertex G4PrimaryVertex* vertex = new G4PrimaryVertex(position, time);
//
// G4cout << "Beam scan & type & energy ==> (" << m_alignment.beam_scan << m_alignment.beam_type << ", " << m_alignment.beam_energy << ")" << G4endl;
// // A note for Hongbo: G4cout << "Particle Position ==> (" << position.x() << ", " << position.y() << ", " << position.z() << ")" << G4endl;
// // I think for now we can use the particle type as defined by the .xml file
// // but for future work it might be good for us to simulate an impure beam. G4ParticleDefinition* particleDefinition
// // What I've written below should work fine. You just need to worry about x and y above = G4ParticleTable::GetParticleTable()->FindParticle(m_alignment.beam_type.c_str()); // about the definition of the ParticleTable, I changed the Alignment_2021.xml file, "e" to "e-", "p" to "proton"
// G4PrimaryParticle* particle = new G4PrimaryParticle(particleDefinition);
// G4ParticleDefinition* particleDefinition particle->SetMomentumDirection(G4ThreeVector(0,0,1));
// = G4ParticleTable::GetParticleTable()->FindParticle(alignment.beam_type.c_str()); //get the particle definition for this beam particle->SetKineticEnergy(m_alignment.beam_energy*GeV); //I'm not sure if I need units here
// G4PrimaryParticle* particle = new G4PrimaryParticle(particleDefinition); //create a particle with the given definition vertex->SetPrimary(particle);
// particle->SetMomentumDirection(G4ThreeVector(0,0,1)); //set the momentum to be purely in Z
// particle->SetKineticEnergy(alignment.beam_energy); //get the beam energy from the alignment file event->AddPrimaryVertex(vertex);
// vertex->SetPrimary(particle); //add the particle to the vertex created above
//
// event->AddPrimaryVertex(vertex); //add the vertex to this event for geant to simulate
} }
......
# Each processed scan data of 2021 test beam has two column,
# First column is the profile of X, the second is Y
# The relation between Scans and Runs are as follows:
scan1: run12-15
scan2: run54-98
scan3: run117-136
scan4: run139-157
scan5: run161-178
scan6: run180-197
scan7: run203-220
scan8: run268-326
scan9: run337-364
scan10: run490-600
scan11: run601-638
scan12: run639-682
scan13: run689-761
(Scan up to 757, 758-761 additional statistics in the center (5,5))
\ No newline at end of file
0 0
0 0
0 0
0 0
1 1
1 1
1 1
1 1
2 1
3 1
4 2
6 2
7 3
8 3
10 4
11 4
11 6
12 8
12 10
12 11
16 16
15 20
19 27
21 28
26 40
29 48
39 65
43 61
54 87
63 88
83 102
98 85
116 110
147 103
202 119
248 106
296 147
393 176
498 247
581 291
623 472
768 618
882 828
961 886
972 1193
1098 1283
1173 1414
1138 1281
1028 1436
1031 1301
931 1196
790 948
659 872
604 649
512 498
401 356
322 302
284 215
235 171
170 131
140 120
117 98
94 84
71 70
61 63
56 50
48 42
40 37
35 33
31 29
25 25
24 20
26 17
17 13
20 10
18 8
8 7
7 5
5 4
5 3
4 3
4 2
3 2
4 1
3 2
2 1
2 1
2 1
1 1
2 1
2 1
2 1
1 1
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 1
1 1
1 1
2 2
2 2
2 3
3 3
5 4
7 4
9 5
12 5
15 7
16 8
18 10
20 11
21 15
23 18
26 23
27 24
33 36
32 43
40 59
44 59
54 86
61 103
82 139
91 131
107 187
130 190
172 218
208 186
244 238
314 226
428 262
525 236
626 329
827 394
1046 557
1213 658
1305 1058
1599 1365
1835 1797
1993 1894
2006 2512
2262 2662
2392 2905
2317 2614
2110 2911
2114 2631
1922 2413
1638 1904
1367 1755
1250 1306
1062 1013
847 729
681 626
599 453
498 366
364 283
303 263
252 214
206 184
156 154
135 140
122 113
106 95
84 85
74 78
67 67
56 59
47 47
43 42
38 32
29 26
25 20
18 17
16 13
15 11
12 9
11 8
10 7
10 6
10 5
8 5
6 4
6 4
6 4
6 4
7 3
5 3
4 2
3 2
2 2
1 1
1 1
1 1
0 1
0 1
0 0
0 0
0 1
0 0
0 1
1 1
1 1
2 2
2 2
3 3
4 4
5 4
7 5
9 5
12 6
12 7
16 8
19 8
24 11
20 13
21 16
20 16
25 24
23 28
29 37
30 38
38 54
43 64
58 87
62 82
74 117
87 118
115 137
138 115
159 149
202 141
274 164
334 147
398 203
525 240
662 336
770 396
822 633
1005 817
1153 1081
1248 1142
1248 1526
1408 1628
1492 1787
1439 1619
1301 1815
1301 1651
1183 1519
1002 1210
837 1118
768 834
649 650
519 470
417 402
371 292
309 237
227 183
189 171
158 140
128 119
97 100
85 91
78 73
67 62
55 55
48 51
45 44
38 40
34 33
34 29
30 22
23 19
20 15
14 14
14 11
13 10
12 8
10 8
10 7
11 6
10 5
8 6
6 5
6 5
7 4
7 4
9 3
7 3
5 3
3 2
2 2
1 1
1 1
0 1
0 1
0 1
0 0
0 0
1 2
1 1
1 1
1 1
2 2
3 2
3 3
4 3
6 5
8 5
10 6
14 6
17 8
18 9
22 11
24 11
30 16
28 18
31 24
30 24
37 35
35 43
45 58
48 58
59 83
65 100
88 136
95 128
113 182
134 185
178 215
216 181
252 234
320 221
438 257
537 230
640 320
847 382
1064 539
1235 634
1315 1015
1611 1313
1844 1732
1990 1826
1990 2436
2240 2597
2364 2843
2272 2569
2049 2880
2048 2617
1859 2404
1569 1907
1307 1761
1195 1308
1012 1015
809 733
649 628
576 453
480 368
354 285
294 263
246 215
201 185
154 155
133 141
121 113
105 96
86 84
76 78
71 67
59 59
51 48
48 43
44 33
34 27
29 21
21 19
21 15
19 13
17 10
14 10
14 8
14 7
14 6
12 6
9 6
9 5
9 5
10 4
11 4
10 4
7 3
4 3
3 2
2 2
1 1
1 1
0 1
0 1
0 1
0 1
0 1
0 0
0 1
1 1
1 1
2 2
2 2
3 2
4 3
4 3
4 4
5 4
6 5
6 5
11 6
12 5
16 6
14 7
14 8
13 8
16 10
15 11
17 14
17 15
21 18
24 20
34 25
33 24
37 31
38 33
46 39
49 36
49 48
51 50
59 63
63 63
69 100
80 190
90 551
101 1044
109 2077
137 2568
202 2940
313 2573
455 2999
764 2924
1214 3051
1695 2699
2226 3132
3246 3016
4205 2976
4702 2504