EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Micromegas.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Micromegas.C
1 #ifndef MACRO_G4MICROMEGAS_C
2 #define MACRO_G4MICROMEGAS_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_Intt.C>
7 #include <G4_Mvtx.C>
8 #include <G4_TPC.C>
9 
13 
14 #include <g4main/PHG4Reco.h>
15 
17 #include <qa_modules/QAG4SimulationMicromegas.h>
18 
19 #include <fun4all/Fun4AllServer.h>
20 
21 R__LOAD_LIBRARY(libmicromegas.so)
22 R__LOAD_LIBRARY(libg4micromegas.so)
23 
24 namespace Enable
25 {
26  bool MICROMEGAS = false;
27  bool MICROMEGAS_CELL = false;
28  bool MICROMEGAS_CLUSTER = false;
29  bool MICROMEGAS_QA = false;
30 } // namespace Enable
31 
32 namespace G4MICROMEGAS
33 {
35  enum Config
36  {
42  };
43 
45 
46  // radius at which micromegas layers are installed
47  double mm_radius = 85;
48 
49 } // namespace G4MICROMEGAS
50 
52 {
53  if (!Enable::MVTX)
54  {
56  }
57  // same for the INTT
58  if (!Enable::INTT)
59  {
61  }
62  if (!Enable::TPC)
63  {
65  }
69 }
70 
71 void Micromegas(PHG4Reco* g4Reco)
72 {
74  auto mm = new PHG4MicromegasSubsystem("MICROMEGAS", mm_layer);
75  mm->OverlapCheck( Enable::OVERLAPCHECK );
76  mm->SetActive();
77  mm->set_double_param("mm_length", 220);
78  mm->set_double_param("mm_radius", G4MICROMEGAS::mm_radius);
79  g4Reco->registerSubsystem(mm);
80 }
81 
83 {
84  auto se = Fun4AllServer::instance();
85  // micromegas
86  auto reco = new PHG4MicromegasHitReco;
87  reco->Verbosity(0);
88 
89  static constexpr double length = 210;
90  static constexpr int nsectors = 12;
91  static constexpr double tile_length = 50;
92  static constexpr double tile_width = 25;
93 
94  switch (G4MICROMEGAS::CONFIG)
95  {
97  {
98  // one tile at mid rapidity in front of TPC sector
99  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_MINIMAL" << std::endl;
100  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
101  reco->set_tiles({{{phi0, 0, tile_width/CylinderGeomMicromegas::reference_radius, tile_length}}});
102  break;
103  }
104 
106  {
107  // 12 tiles at mid rapidity, one in front of each TPC sector
108  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_PHI_ONE_RING" << std::endl;
109  MicromegasTile::List tiles;
110  for (int i = 0; i < nsectors; ++i)
111  {
112  tiles.emplace_back(2. * M_PI * (0.5 + i) / nsectors, 0, tile_width/CylinderGeomMicromegas::reference_radius, tile_length);
113  }
114  reco->set_tiles(tiles);
115  break;
116  }
117 
119  {
120  // 4 tiles with full z coverage in front of one TPC sector
121  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_Z_ONE_SECTOR" << std::endl;
122  MicromegasTile::List tiles;
123  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
124  static constexpr int ntiles = 4;
125  for (int i = 0; i < ntiles; ++i)
126  {
127  tiles.emplace_back(phi0, length * ((0.5 + i) / ntiles - 0.5), tile_width/CylinderGeomMicromegas::reference_radius, tile_length);
128  }
129  reco->set_tiles(tiles);
130  break;
131  }
132 
134  {
135  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_BASELINE" << std::endl;
136  MicromegasTile::List tiles;
137 
138  // for the first sector we put 4 tiles with full z coverage
139  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
140  static constexpr int ntiles_z = 4;
141  for (int i = 0; i < ntiles_z; ++i)
142  {
143  tiles.emplace_back(phi0, length * ((0.5 + i) / ntiles_z - 0.5), tile_width/CylinderGeomMicromegas::reference_radius, tile_length);
144  }
145 
146  // for the other sectors we put two tiles on either side of the central membrane
147  static constexpr double zoffset = 7;
148  for (int i = 1; i < nsectors; ++i)
149  {
150  const double phi = phi0 + 2.*M_PI*i/nsectors;
151  tiles.emplace_back( phi, length*(1.5/4-0.5) - zoffset, tile_width/CylinderGeomMicromegas::reference_radius, tile_length );
152  tiles.emplace_back( phi, length*(2.5/4-0.5) + zoffset, tile_width/CylinderGeomMicromegas::reference_radius, tile_length );
153  }
154  reco->set_tiles(tiles);
155  break;
156  }
157 
159  {
160  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_MAXIMAL" << std::endl;
161  MicromegasTile::List tiles;
162 
163  // 4 tiles with full z coverage in front of each TPC sector
164  static constexpr int ntiles_z = 4;
165  for (int iphi = 0; iphi < nsectors; ++iphi)
166  {
167  const double phi = 2. * M_PI * (0.5 + iphi) / nsectors;
168  for (int iz = 0; iz < ntiles_z; ++iz)
169  {
170  tiles.emplace_back(phi, length * ((0.5 + iz) / ntiles_z - 0.5), tile_width/CylinderGeomMicromegas::reference_radius, tile_length);
171  }
172  }
173  reco->set_tiles(tiles);
174  break;
175  }
176  }
177 
178  se->registerSubsystem(reco);
179 
180  se->registerSubsystem(new PHG4MicromegasDigitizer);
181 }
182 
184 {
185  auto se = Fun4AllServer::instance();
186  se->registerSubsystem(new MicromegasClusterizer);
187 }
188 
190 {
191  auto se = Fun4AllServer::instance();
192  auto qa = new QAG4SimulationMicromegas;
194  se->registerSubsystem(qa);
195 }
196 
197 #endif