ECCE @ 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 
18 #include <fun4all/Fun4AllServer.h>
19 
20 R__LOAD_LIBRARY(libmicromegas.so)
21 R__LOAD_LIBRARY(libg4micromegas.so)
22 
23 namespace Enable
24 {
25  bool MICROMEGAS = false;
26  bool MICROMEGAS_CELL = false;
27  bool MICROMEGAS_CLUSTER = false;
28 } // namespace Enable
29 
30 namespace G4MICROMEGAS
31 {
33  enum Config
34  {
40  };
41 
43 } // namespace G4MICROMEGAS
44 
46 {
47  if (!Enable::MVTX)
48  {
50  }
51  // same for the INTT
52  if (!Enable::INTT)
53  {
54  G4INTT::n_intt_layer = 0;
55  }
56  if (!Enable::TPC)
57  {
58  G4TPC::n_gas_layer = 0;
59  }
63 }
64 
65 void Micromegas(PHG4Reco* g4Reco)
66 {
67  const int mm_layer = G4MVTX::n_maps_layer + G4INTT::n_intt_layer + G4TPC::n_gas_layer;
68  auto mm = new PHG4MicromegasSubsystem("MICROMEGAS", mm_layer);
69  mm->SetActive();
70  mm->set_double_param("mm_length", 220);
71 // mm->set_double_param("mm_radius", 82);
72  g4Reco->registerSubsystem(mm);
73 }
74 
76 {
77  auto se = Fun4AllServer::instance();
78  // micromegas
79  auto reco = new PHG4MicromegasHitReco;
80  reco->Verbosity(0);
81 
82  static constexpr double radius = 82;
83  static constexpr double length = 210;
84  static constexpr int nsectors = 12;
85  static constexpr double tile_length = 50;
86  static constexpr double tile_width = 25;
87 
88  switch (G4MICROMEGAS::CONFIG)
89  {
91  {
92  // one tile at mid rapidity in front of TPC sector
93  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_MINIMAL" << std::endl;
94  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
95  reco->set_tiles({{{phi0, 0, tile_width / radius, tile_length}}});
96  break;
97  }
98 
100  {
101  // 12 tiles at mid rapidity, one in front of each TPC sector
102  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_PHI_ONE_RING" << std::endl;
103  MicromegasTile::List tiles;
104  for (int i = 0; i < nsectors; ++i)
105  {
106  tiles.emplace_back(2. * M_PI * (0.5 + i) / nsectors, 0, tile_width / radius, tile_length);
107  }
108  reco->set_tiles(tiles);
109  break;
110  }
111 
113  {
114  // 4 tiles with full z coverage in front of one TPC sector
115  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_Z_ONE_SECTOR" << std::endl;
116  MicromegasTile::List tiles;
117  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
118  static constexpr int ntiles = 4;
119  for (int i = 0; i < ntiles; ++i)
120  {
121  tiles.emplace_back(phi0, length * ((0.5 + i) / ntiles - 0.5), tile_width / radius, tile_length);
122  }
123  reco->set_tiles(tiles);
124  break;
125  }
126 
128  {
129  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_BASELINE" << std::endl;
130  MicromegasTile::List tiles;
131 
132  // for the first sector we put 4 tiles with full z coverage
133  static constexpr double phi0 = M_PI * (0.5 + 1. / nsectors);
134  static constexpr int ntiles_z = 4;
135  for (int i = 0; i < ntiles_z; ++i)
136  {
137  tiles.emplace_back(phi0, length * ((0.5 + i) / ntiles_z - 0.5), tile_width / radius, tile_length);
138  }
139 
140  // for the other sectors we put two tiles on either side of the central membrane
141  static constexpr double zoffset = 7;
142  for (int i = 1; i < nsectors; ++i)
143  {
144  const double phi = phi0 + 2.*M_PI*i/nsectors;
145  tiles.emplace_back( phi, length*(1.5/4-0.5) - zoffset, tile_width/radius, tile_length );
146  tiles.emplace_back( phi, length*(2.5/4-0.5) + zoffset, tile_width/radius, tile_length );
147  }
148  reco->set_tiles(tiles);
149  break;
150  }
151 
153  {
154  std::cout << "Micromegas_Cells - Tiles configuration: CONFIG_MAXIMAL" << std::endl;
155  MicromegasTile::List tiles;
156 
157  // 4 tiles with full z coverage in front of each TPC sector
158  static constexpr int ntiles_z = 4;
159  for (int iphi = 0; iphi < nsectors; ++iphi)
160  {
161  const double phi = 2. * M_PI * (0.5 + iphi) / nsectors;
162  for (int iz = 0; iz < ntiles_z; ++iz)
163  {
164  tiles.emplace_back(phi, length * ((0.5 + iz) / ntiles_z - 0.5), tile_width / radius, tile_length);
165  }
166  }
167  reco->set_tiles(tiles);
168  break;
169  }
170  }
171 
172  se->registerSubsystem(reco);
173 
174  se->registerSubsystem(new PHG4MicromegasDigitizer);
175 }
176 
178 {
179  auto se = Fun4AllServer::instance();
180  se->registerSubsystem(new MicromegasClusterizer);
181 }
182 #endif