ATLAS Offline Software
DBReader.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  Dummy AmdbReader - selecting the appropriate version depending on Layout
7  ------------------------------------------------------------------------
8  ***************************************************************************/
9 
10 //<doc><file> $Id: DBReader.h,v 1.62 2009-02-24 17:47:42 dwright Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 #ifndef MUONGEOMODEL_DBREADER_H
14 #define MUONGEOMODEL_DBREADER_H
15 
17 //<<<<<< INCLUDES >>>>>>
19 #include "GaudiKernel/SystemOfUnits.h"
20 #include "StoreGate/StoreGateSvc.h"
21 
22 #include <atomic>
23 #include <iostream>
24 #include <string>
25 
26 // WMDT - Mdt inner structure
28 
29 // WCSC - Csc inner structure
31 
32 // WRPC and AWLN - Rpc inner structure
35 
36 // WTGC and ATLN - Tgc inner structure
39 
40 // WDED - Wded inner structure
42 
43 // WSPA - Spa inner structure
45 
46 // WSUP - Sup inner structure
48 
49 // WCHV - Chv inner structure
51 
52 // WCRO - Cro inner structure
54 
55 // WCMI - Cmi inner structure
57 
58 // WLBI - Lbi inner structure
60 
61 // getting layout, and db versions
63 
64 // Asmp(not used), Atyp, Almn - stations and components
68 
69 // Aptp Positions
71 // Aszt Alignements
73 
74 // Acut & Alin cutouts:
77 
78 // Service header files
85 #include "MuonGeoModel/Cutout.h"
90 #include "MuonGeoModel/MYSQL.h"
92 #include "MuonGeoModel/Position.h"
99 #include "MuonGeoModel/Station.h"
101 #include "MuonGeoModel/Technology.h"
103 
104 #define verbose_posmap false
105 #define verbose_alimap false
106 #define RPCprint false
107 
108 class StatusCode;
109 class IMessageSvc;
110 namespace MuonGM {
111  class MuonDetectorManager;
112 }
113 
114 namespace MuonGM {
115 
116  class DBReader {
117  public:
118  virtual StatusCode ProcessDB(MYSQL& /*mysql*/) { return StatusCode::SUCCESS; };
119  void setGeometryVersion(std::string s);
120  const std::string& getGeometryVersion() const;
121  void setManager(MuonDetectorManager *detmgr) { m_mgr = detmgr; };
122 
123  virtual ~DBReader(){};
124 
125  protected:
127  //
129  std::string TGCreadoutName(int ichtyp);
130  // tgc readout stuff
131  std::vector<std::string> m_tgcReadoutMapping;
133 
134  private:
135  // data
136  IMessageSvc *m_msgSvc;
137  std::string m_version;
138  }; // end of class DBReader
139 
140  static std::atomic<int> nmdt{0};
141  static std::atomic<int> nrpc{0};
142  static std::atomic<int> ntgc{0};
143  static std::atomic<int> ncsc{0};
144  static std::atomic<int> nspa{0};
145  static std::atomic<int> nded{0};
146  static std::atomic<int> nsup{0};
147  static std::atomic<int> nchv{0};
148  static std::atomic<int> ncro{0};
149  static std::atomic<int> ncmi{0};
150  static std::atomic<int> nlbi{0};
151 
152  // here the template functions used by the specialised versions of ProcessFile
153  template <class TYPEdhwmdt, class TYPEwmdt>
154  static void ProcessMDT(MYSQL& mysql, const TYPEdhwmdt dhwmdt, const TYPEwmdt *wmdt, const std::string& s) {
155  const Technology *t = mysql.GetTechnology(s);
156  if (t != NULL)
157  return;
158 
159  MDT *mdt = new MDT(mysql, s);
160  nmdt++;
161 
162  for (unsigned int i = 0; i < dhwmdt->size(); i++) {
163  if (s.compare(3, s.size() - 3, MuonGM::buildString(wmdt[i].iw, 2)) == 0) {
164  mdt->numOfLayers = wmdt[i].laymdt;
165  mdt->innerRadius = wmdt[i].tubrad * Gaudi::Units::cm;
166  mdt->totalThickness = wmdt[i].tubsta * Gaudi::Units::cm;
167  mdt->pitch = wmdt[i].tubpit * Gaudi::Units::cm;
168  mdt->thickness = mdt->totalThickness;
169  mdt->tubeDeadLength = 0; // cannot be defined here (it depends on chamber size)
170  // mdt->endPlugLength is not OK in p03
171  // mdt->endPlugLength = wmdt[i].tubdea*Gaudi::Units::cm;
172  mdt->tubeEndPlugLength = wmdt[i].tubdea * Gaudi::Units::cm;
173 
174  mdt->tubeWallThickness = wmdt[i].tubwal * Gaudi::Units::cm;
175 
176  for (unsigned int k = 0; k < 4; k++)
177  mdt->y[k] = wmdt[i].tubyco[k] * Gaudi::Units::cm;
178  for (unsigned int j = 0; j < 4; j++)
179  mdt->x[j] = wmdt[i].tubxco[j] * Gaudi::Units::cm;
180  }
181  }
182  } // end of ProcessMDT
183 
184  template <class TYPEdhwrpc, class TYPEwrpc, class TYPEdhwrpcall, class TYPEwrpcall>
185  static void ProcessRPC(MYSQL& mysql, const TYPEdhwrpc dhwrpc, const TYPEwrpc *wrpc, const TYPEdhwrpcall /*dhwrpcall*/, const TYPEwrpcall *wrpcall, const std::string& s) {
186  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcessRPC");
187 
188  const Technology *t = mysql.GetTechnology(s);
189  if (t != NULL)
190  return;
191 
192  RPC *rpc = new RPC(mysql, s); // this will enter a new record in the MYSQL technology map
193  nrpc++;
194 
195  rpc->centralSupPanelThickness = (wrpcall->tckfsp) * Gaudi::Units::cm;
196  rpc->centralAlSupPanelThickness = (wrpcall->ackfsp) * Gaudi::Units::cm;
197  if (RPCprint) {
198  log << MSG::INFO << "ProcessRPC:: RPC central sup panel: tot & Al " << rpc->centralSupPanelThickness << " " << rpc->centralAlSupPanelThickness << endmsg;
199  }
200 
201  rpc->bakeliteThickness = (wrpcall->tckbak) * Gaudi::Units::cm;
202  rpc->bakeliteframesize = 0.5 * (wrpcall->sdedmi) * Gaudi::Units::cm;
203  rpc->gasThickness = (wrpcall->tckgas) * Gaudi::Units::cm;
204  rpc->bakelitePetThickness = 0.190 * Gaudi::Units::mm; // TBM same as Amdb, why hardwired? Not in DblQ00Wrpc!
205  rpc->totalAirThickness = 0.52 * Gaudi::Units::mm; // TBM added
206  rpc->GasGapThickness = 2. * rpc->bakeliteThickness + rpc->gasThickness + 2. * rpc->bakelitePetThickness + rpc->totalAirThickness; // TBM added air thickness;
207  if (RPCprint) {
208  log << MSG::INFO << "ProcessRPC:: Total GasGapThickness " << rpc->GasGapThickness << endmsg;
209 
210  log << MSG::INFO << "ProcessRPC:: comes from 2*bak, gas, 2*bakpet " << rpc->bakeliteThickness << " " << rpc->gasThickness << " " << rpc->bakelitePetThickness << endmsg;
211  }
212 
213  rpc->bakeliteThickness = rpc->bakeliteThickness + rpc->bakelitePetThickness;
214  if (RPCprint) {
215  log << MSG::INFO << "ProcessRPC::WARNING redefining RPC::bakeliteThickness to include pet " << rpc->bakeliteThickness << endmsg;
216  }
217  rpc->spacerDiameter = (wrpcall->spdiam) * Gaudi::Units::cm;
218  rpc->spacerPitch = (wrpcall->sppitc) * Gaudi::Units::cm;
219  rpc->MidChamberDeadRegion_in_s = 2. * rpc->bakeliteframesize;
220  rpc->MidChamberDeadRegion_in_z = (wrpcall->zdedmi) * Gaudi::Units::cm;
221 
222  if (RPCprint) {
223  log << MSG::INFO << " ProcessRPC:: spacerDiam, pitch, MidChamberDeadRegion_in_s, MidChamberDeadRegion_in_z " << rpc->spacerDiameter << " " << rpc->spacerPitch << " "
224  << rpc->MidChamberDeadRegion_in_s << " " << rpc->MidChamberDeadRegion_in_z << endmsg;
225  }
226 
227  rpc->petFoilThickness = 0.190 * Gaudi::Units::mm; // TBM this is the same as bakelite PET thickness?
228  if (RPCprint) {
229  log << MSG::INFO << "ProcessRPC:: defining RPC::petfoilThickness = " << rpc->petFoilThickness << endmsg;
230  }
231 
232  rpc->stripPanelFoamThickness = (wrpcall->tckssu) * Gaudi::Units::cm;
233  rpc->stripPanelCopperSkinThickness = (wrpcall->tckstr) * Gaudi::Units::cm;
234  rpc->stripPanelStripSidePetThickness = 0.25 * Gaudi::Units::mm; // missing in AmdbNova
235  rpc->stripPanelGroundSidePetThickness = 0.07 * Gaudi::Units::mm; // missing in AmdbNova
236  rpc->frontendBoardWidth = 36. * Gaudi::Units::mm;
237  rpc->backendBoardWidth = 21. * Gaudi::Units::mm;
238  if (RPCprint) {
239  log << MSG::INFO << "ProcessRPC:: stp panel: foam, 2*copper, petg, pets, fe, be " << rpc->stripPanelFoamThickness << " " << rpc->stripPanelCopperSkinThickness << " "
240  << rpc->stripPanelStripSidePetThickness << " " << rpc->stripPanelGroundSidePetThickness << " " << rpc->frontendBoardWidth << " " << rpc->backendBoardWidth
241  << endmsg;
242  }
243  rpc->stripPanelThickness =
244  rpc->stripPanelFoamThickness + 2. * rpc->stripPanelCopperSkinThickness + rpc->stripPanelStripSidePetThickness + rpc->stripPanelGroundSidePetThickness;
245  if (RPCprint) {
246  log << MSG::INFO << "ProcessRPC:: stripPanelThickness= " << rpc->stripPanelThickness << endmsg;
247  }
248  rpc->stripPanelFoamThickness = rpc->stripPanelFoamThickness + rpc->stripPanelStripSidePetThickness + rpc->stripPanelGroundSidePetThickness;
249  if (RPCprint) {
250  log << MSG::INFO << "ProcessRPC::WARNING redefining RPC::stripPanelFoamThickness to include pet on both sides " << rpc->stripPanelFoamThickness << endmsg;
251  }
252 
253  rpc->rpcLayerThickness = (wrpcall->tckrla) * Gaudi::Units::cm;
254  double rpcLayerComputedTck = rpc->GasGapThickness + 2 * rpc->stripPanelThickness + rpc->petFoilThickness;
255  if (RPCprint) {
256  log << MSG::INFO << "ProcessRPC:: rpcLayerComputedTck = " << rpcLayerComputedTck << " while rpcLayerThickness in Nova = " << rpc->rpcLayerThickness << endmsg;
257  }
258 
259  // until now parameters common to all RPCs
260  int nStruct = dhwrpc->size();
261  bool done = false;
262  for (unsigned int i = 0; (i < dhwrpc->size() && !done); i++) {
263  if (s.compare(3, s.size() - 3, MuonGM::buildString(wrpc[i].jsta, 2)) == 0) {
264  if (RPCprint) {
265  log << MSG::INFO << " ProcessRPC " << s << " index " << i << " jsta =" << wrpc[i].jsta << " strings comparison:: <" << s.substr(3, s.size() - 3) << ">=<"
266  << MuonGM::buildString(wrpc[i].jsta, 2) << ">" << endmsg;
267  }
268 
269  done = true;
270 
271  rpc->externalSupPanelThickness = (wrpcall->tlohcb) * Gaudi::Units::cm; // TBM
272  rpc->externalAlSupPanelThickness = (wrpcall->alohcb) * Gaudi::Units::cm; // TBM
273  if (RPCprint) {
274  log << MSG::INFO << "ProcessRPC:: RPC external sup panel: tot & Al " << rpc->centralSupPanelThickness << " " << rpc->centralAlSupPanelThickness << endmsg;
275  }
276  rpc->lowerSupPanelThickness = 0;
277  rpc->lowerAlSupPanelThickness = 0;
278  rpc->upperSupPanelThickness = 0;
279  rpc->upperAlSupPanelThickness = 0;
280 
281  rpc->TotalThickness = 2 * rpc->rpcLayerThickness + rpc->centralSupPanelThickness + rpc->externalSupPanelThickness;
282  if (RPCprint) {
283  log << MSG::INFO << "ProcessRPC:: (computed) Total RPC thickness = " << rpc->TotalThickness << endmsg;
284  }
285  rpc->maxThickness = 46. * Gaudi::Units::mm; // TBM same as (wrpcall->tottck)*Gaudi::Units::cm;
286  rpc->thickness = rpc->maxThickness;
287  if (RPCprint) {
288  log << MSG::INFO << "ProcessRPC:: RPC max thickness " << rpc->maxThickness << endmsg;
289  }
290 
291  rpc->stripPitchS = (wrpc[i].spitch) * Gaudi::Units::cm;
292  rpc->stripPitchZ = (wrpc[i].zpitch) * Gaudi::Units::cm;
293  rpc->stripSeparation = (wrpc[i].dedstr) * Gaudi::Units::cm;
294 
295  if (RPCprint) {
296  log << MSG::INFO << "ProcessRPC:: s_pitch, z_pitch " << rpc->stripPitchS << " " << rpc->stripPitchZ << endmsg;
297  }
298 
299  rpc->NstripPanels_in_s = wrpc[i].nsrest;
300  rpc->NstripPanels_in_z = 1;
301  rpc->NGasGaps_in_s = wrpc[i].nzrest;
302  rpc->NGasGaps_in_z = 1;
303 
304  if (RPCprint) {
305  log << MSG::INFO << "ProcessRPC:: ngg, nsp, nzp " << rpc->NGasGaps_in_s << " " << rpc->NstripPanels_in_s << " " << rpc->NstripPanels_in_z << endmsg;
306  }
307  }
308  if (RPCprint) {
309  log << MSG::INFO << " index = " << i << " nstruct " << nStruct << " " << dhwrpc->size() << endmsg;
310  }
311  }
312  } // end of ProcessRPC
313 
314  template <class TYPEdhwtgc, class TYPEwtgc, class TYPEdhwtgcall, class TYPEwtgcall>
315  static void ProcessTGC(MYSQL& mysql,
316  const TYPEdhwtgc dhwtgc, const TYPEwtgc *wtgc, const TYPEdhwtgcall dhwtgcall, const TYPEwtgcall *wtgcall, const std::string& s) {
317  const Technology *tech = mysql.GetTechnology(s);
318  if (tech != NULL)
319  return;
320 
321  TGC *tgc = new TGC(mysql, s);
322  ntgc++;
323  std::string v[] = {"muo::TGCGas", "std::G10", "muo::Honeycomb", "std::Copper"};
324  int mat;
325  double p, t;
326 
327  for (unsigned int i = 0; i < dhwtgcall->size(); i++) {
328  if (s.compare(3, s.size() - 3,MuonGM::buildString(wtgcall[i].jsta, 2)) ==0 ) {
329  tgc->nlayers = wtgcall[i].nbevol;
330  tgc->thickness = wtgcall[i].widchb * Gaudi::Units::cm;
331  tgc->frame_h = wtgcall[i].fwirch * Gaudi::Units::cm;
332  tgc->frame_ab = wtgcall[i].fwixch * Gaudi::Units::cm;
333 
334  int firstj;
335  firstj = 0;
336 
337  for (unsigned int j = firstj; j < dhwtgc->size(); j++) {
338  if (wtgc[j].jsta != wtgcall[i].jsta)
339  continue;
340 
341  mat = (int)wtgc[j].icovol;
342  p = wtgc[j].zpovol * Gaudi::Units::cm;
343  t = wtgc[j].widvol * Gaudi::Units::cm;
344  tgc->materials.push_back(v[mat - 1]);
345  tgc->positions.push_back(p);
346  tgc->tck.push_back(t);
347  }
348  // parameters for inner structure of TGC,
349  // filled by RDBReaderAtlas::TgcReadoutParameter if available
350  tgc->widthWireSupport = 0.;
351  tgc->widthGasChannel = 0.;
352  tgc->distanceWireSupport = 0.;
353  for (int ilyr = 0; ilyr < 3; ilyr++) {
354  tgc->offsetWireSupport[ilyr] = 0.;
355  }
356  tgc->angleTilt = 0.;
357  tgc->radiusButton = 0.;
358  for (int idir = 0; idir < 2; idir++) {
359  tgc->pitchButton[idir] = 0.;
360  }
361  tgc->angleButton = 0.;
362 
363  break;
364  }
365  }
366  } // end of ProcessTGC
367 
368  template <class TYPEdhwcsc, class TYPEwcsc>
369  static void ProcessCSC(MYSQL& mysql, const TYPEdhwcsc dhwcsc, const TYPEwcsc *wcsc, const std::string& s) {
370  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcessCSC");
371  log << MSG::DEBUG << " Enter in ProcessCSC" << endmsg;
372 
373  const Technology *t = mysql.GetTechnology(s);
374  if (t != NULL)
375  return;
376 
377  CSC *csc = new CSC(mysql, s);
378  csc->numOfLayers = 0;
379  ncsc++;
380 
381  std::string tname = s;
382  while (tname != "XXXXX") {
383  for (unsigned int i = 0; i < dhwcsc->size(); i++) {
384  if (tname.compare(3, s.size() - 3, MuonGM::buildString(wcsc[i].jsta, 2)) == 0) {
385  csc->numOfLayers = wcsc[i].laycsc;
386  csc->totalThickness = wcsc[i].ttotal * Gaudi::Units::cm;
387  csc->thickness = csc->totalThickness;
388  csc->honeycombthick = wcsc[i].tnomex * Gaudi::Units::cm;
389 
390  csc->g10thick = wcsc[i].tlag10 * Gaudi::Units::cm; // csc->g10thick = 0.0820*Gaudi::Units::cm;
391 
392  // wire spacing
393  csc->wirespacing = wcsc[i].wispa * Gaudi::Units::cm;
394  // anode-cathode distance
395  csc->anocathodist = wcsc[i].dancat * Gaudi::Units::cm;
396  // gapbetwcathstrips
397  csc->gapbetwcathstrips = wcsc[i].gstrip * Gaudi::Units::cm;
398 
399  // precision (Radial) strip pitch
400  csc->cathreadoutpitch = wcsc[i].pcatre * Gaudi::Units::cm; // it was not used before but set by hand in CscReadoutEl.
401  // Azimuthal strip pitch
402 
403  // csc->phireadoutpitch = wcsc[i].psndco*Gaudi::Units::cm;
404  csc->phireadoutpitch = wcsc[i].azcat * Gaudi::Units::cm;
405  // std::cerr << " do we come here ??? csc->phireadoutpitch = " << csc->phireadoutpitch << std::endl;
406 
407  // std::cerr << " csc->phireadoutpitch = " << csc->phireadoutpitch << " csc->cathreadoutpitch "<< csc->cathreadoutpitch << std::endl;
408  if (csc->phireadoutpitch == 0.) {
409  log << MSG::WARNING << " csc->phireadoutpitch == 0 in layout " << mysql.getGeometryVersion() << endmsg;
410  }
411  // number of strips / layer / view
412 
413  csc->nEtastrips = 192;
414  csc->nPhistrips = 48;
415 
416  // precision (Radial) strip width
417  csc->readoutstripswidth = wcsc[i].wrestr * Gaudi::Units::cm;
418  // Azimuthal strip width
419  csc->floatingstripswidth = 0.;
420  csc->phistripwidth = wcsc[i].wflstr * Gaudi::Units::cm; // CTB and layout Q interpretation
421 
422  // dead materials
423  csc->rectwasherthick = wcsc[i].trrwas * Gaudi::Units::cm;
424  csc->roxacellwith = 54.96 * Gaudi::Units::mm; // CTB, layout Q, R, etc: must be computed
425  csc->roxwirebargap = wcsc[i].groxwi * Gaudi::Units::cm;
426  csc->fullgasgapwirewidth = wcsc[i].wgasba * Gaudi::Units::cm;
427  csc->fullwirefixbarwidth = wcsc[i].wfixwi * Gaudi::Units::cm;
428  csc->wirebarposx = wcsc[i].pba1wi * Gaudi::Units::cm;
429  csc->wirebarposy = wcsc[i].pba2wi * Gaudi::Units::cm;
430  csc->wirebarposz = wcsc[i].pba3wi * Gaudi::Units::cm;
431 
432  if (tname == s)
433  return;
434  }
435  }
436 
437  if (csc->numOfLayers == 0) {
438  // no entry has been found with the current technology sub-type
439  tname = "CSC" + MuonGM::buildString(MuonGM::strtoint(s, 4, 2) - 1, 2);
440  log << MSG::WARNING << " No DB entry found for the current technology sub-type " << s << "\n using previous sub-type " << tname
441  << " // Layout = " << mysql.getGeometryVersion() << endmsg;
442  } else {
443 
444  if (tname == s)
445  return;
446  // update by hand number not available in the DB
447 
448  log << MSG::WARNING << " update by hand a few numbers for the current technology sub-type " << s << " // Layout = " << mysql.getGeometryVersion()
449  << " OK if layout is Q02, Q02_initial" << endmsg;
450  // precision (Radial) strip pitch
451  csc->cathreadoutpitch = 5.31 * Gaudi::Units::mm;
452  // Azimuthal strip pitch
453  csc->phireadoutpitch = 21.0 * Gaudi::Units::mm;
454  // precision (Radial) strip width
455  csc->readoutstripswidth = 1.52 * Gaudi::Units::mm;
456  // Azimuthal strip width
457  csc->floatingstripswidth = 0; // layout P interpretation
458  csc->phistripwidth = 20.60 * Gaudi::Units::mm;
459  return;
460  }
461  }
462  }
463 
464  template <class TYPEdhwspa, class TYPEwspa>
465  static void ProcessSPA(MYSQL& mysql,
466  const TYPEdhwspa dhwspa, const TYPEwspa *wspa, const std::string& s) {
467  const Technology *t = mysql.GetTechnology(s);
468  if (t != NULL)
469  return;
470 
471  SPA *spa = new SPA(mysql, s);
472  nspa++;
473 
474  for (unsigned int i = 0; i < dhwspa->size(); i++) {
475  if (s.compare(3, s.size() - 3, MuonGM::buildString(wspa[i].jsta, 2)) == 0) {
476  spa->thickness = wspa[i].tckspa * Gaudi::Units::cm;
477  }
478  }
479  } // end of ProcessSPA
480 
481  template <class TYPEdhwsup, class TYPEwsup>
482  static void ProcessSUP(MYSQL& mysql, const TYPEdhwsup dhwsup, const TYPEwsup *wsup, const std::string& s) {
483  const Technology *t = mysql.GetTechnology(s);
484  if (t != NULL)
485  return;
486 
487  SUP *sup = new SUP(mysql, s);
488  nsup++;
489 
490  for (unsigned int i = 0; i < dhwsup->size(); i++) {
491  if (s.compare(3, s.size() - 3, MuonGM::buildString(wsup[i].jsta, 2)) == 0) {
492  sup->alFlangeThickness = wsup[i].xxsup[0] * Gaudi::Units::cm;
493 
494  if (s.compare(3, s.size() - 3, "03") == 0) {
495  sup->alHorFlangeLength = (fabs)(wsup[i].zzsup[1]) * Gaudi::Units::cm;
496  sup->alVerFlangeLength = wsup[i].xxsup[1] * Gaudi::Units::cm - wsup[i].xxsup[0] * Gaudi::Units::cm;
497  sup->alVerProfileThickness = wsup[i].zzsup[3] * Gaudi::Units::cm;
498  sup->alHorProfileThickness = wsup[i].xxsup[3] * Gaudi::Units::cm - wsup[i].xxsup[2] * Gaudi::Units::cm;
499  sup->largeVerClearance = wsup[i].xxsup[3] * Gaudi::Units::cm;
500  sup->smallVerClearance = wsup[i].xxsup[2] * Gaudi::Units::cm;
501  sup->HorClearance = wsup[i].zzsup[2] * Gaudi::Units::cm;
502  sup->xAMDB0 = -sup->largeVerClearance - sup->alHorProfileThickness / 2.;
503  sup->yAMDB0 = 0.;
504  sup->zAMDB0 = -sup->alVerProfileThickness - (sup->HorClearance - sup->alVerProfileThickness) / 2.;
505  sup->bottomsizewrtAMDB0 = sup->alVerFlangeLength + sup->alFlangeThickness;
506  } else { // SUP1 and SUP2
507  sup->alHorFlangeLength = wsup[i].zzsup[0] * Gaudi::Units::cm;
508  sup->alVerFlangeLength = 0.;
509  sup->alVerProfileThickness = wsup[i].xxsup[0] * Gaudi::Units::cm;
510  sup->alHorProfileThickness = 0.;
511  sup->largeVerClearance = wsup[i].xxsup[1] * Gaudi::Units::cm;
512  sup->smallVerClearance = 0.;
513  sup->HorClearance = 0.;
514  double totzgm = 2. * sup->alHorFlangeLength + sup->alVerProfileThickness + sup->HorClearance;
515  double totxgm = 2. * sup->alFlangeThickness + 2. * sup->alVerFlangeLength + sup->largeVerClearance + sup->smallVerClearance;
516  sup->zAMDB0 = -totzgm / 2. + sup->alVerProfileThickness;
517  sup->xAMDB0 = -totxgm / 2. + sup->alFlangeThickness;
518  sup->yAMDB0 = 0.;
519  if (s[3] == '2') // SUP2
520  sup->zAMDB0 = -sup->zAMDB0;
521  sup->bottomsizewrtAMDB0 = sup->alFlangeThickness;
522  }
523  sup->totalThickness = 2. * sup->alFlangeThickness + 2. * sup->alVerFlangeLength + sup->largeVerClearance + sup->smallVerClearance;
524  sup->topsizewrtAMDB0 = sup->totalThickness - sup->bottomsizewrtAMDB0;
525  sup->thickness = sup->totalThickness;
526  }
527  }
528  } // end of ProcessSUP
529 
530  template <class TYPEdhwded, class TYPEwded>
531  static void ProcessDED(MYSQL& mysql, const TYPEdhwded dhwded, const TYPEwded *wded, const std::string& s) {
532  const Technology *t = mysql.GetTechnology(s);
533  if (t != NULL)
534  return;
535 
536  DED *ded = new DED(mysql, s);
537  nded++;
538 
539  for (unsigned int i = 0; i < dhwded->size(); i++) {
540  if (s.compare(3, s.size() - 3, MuonGM::buildString(wded[i].jsta, 2)) == 0) {
541  // a lot of confusion in the various versions of the geometry in nova
542  ded->AlThickness = 0.3 * Gaudi::Units::mm;
543  ded->thickness = (wded[i].auphcb) * Gaudi::Units::cm;
544  ded->HoneyCombThickness = ded->thickness - 2. * ded->AlThickness;
545  break;
546  }
547  }
548  } // end of ProcessDED
549 
550  template <class TYPEdhwchv, class TYPEwchv>
551  static void ProcessCHV(MYSQL& mysql,
552  const TYPEdhwchv dhwchv, const TYPEwchv *wchv, const std::string& s) {
553  const Technology *t = mysql.GetTechnology(s);
554  if (t != NULL)
555  return;
556 
557  int nStruct = dhwchv->size();
558  CHV *chv = new CHV(mysql, s);
559  nchv++;
560 
561  for (int i = 0; i < nStruct; i++) {
562  if (s.compare(3, s.size() - 3, MuonGM::buildString(wchv[i].jsta, 2)) == 0) {
563  chv->thickness = wchv[i].thickness * Gaudi::Units::cm;
564  chv->largeness = wchv[i].largeness * Gaudi::Units::cm;
565  chv->height = wchv[i].heightness * Gaudi::Units::cm;
566  }
567  }
568  } // end of ProcessCHV
569 
570  template <class TYPEdhwcro, class TYPEwcro>
571  static void ProcessCRO(MYSQL& mysql, const TYPEdhwcro dhwcro, const TYPEwcro *wcro, const std::string& s) {
572  const Technology *t = mysql.GetTechnology(s);
573  if (t != NULL)
574  return;
575 
576  int nStruct = dhwcro->size();
577  CRO *cro = new CRO(mysql, s);
578  ncro++;
579 
580  for (int i = 0; i < nStruct; i++) {
581  if (s.compare(3, s.size() - 3, MuonGM::buildString(wcro[i].jsta, 2)) == 0) {
582  cro->thickness = wcro[i].thickness * Gaudi::Units::cm;
583  cro->largeness = wcro[i].largeness * Gaudi::Units::cm;
584  cro->height = wcro[i].heightness * Gaudi::Units::cm;
585  }
586  }
587  } // end of ProcessCRO
588 
589  template <class TYPEdhwcmi, class TYPEwcmi>
590  static void ProcessCMI(MYSQL& mysql,
591  const TYPEdhwcmi dhwcmi, const TYPEwcmi *wcmi, const std::string& s) {
592  const Technology *t = mysql.GetTechnology(s);
593  if (t != NULL)
594  return;
595 
596  int nStruct = dhwcmi->size();
597  CMI *cmi = new CMI(mysql, s);
598  ncmi++;
599 
600  for (int i = 0; i < nStruct; i++) {
601  if (s.compare(3, s.size() - 3, MuonGM::buildString(wcmi[i].jsta, 2)) == 0) {
602  cmi->thickness = wcmi[i].thickness * Gaudi::Units::cm;
603  cmi->largeness = wcmi[i].largeness * Gaudi::Units::cm;
604  cmi->height = wcmi[i].heightness * Gaudi::Units::cm;
605  }
606  }
607  } // end of ProcessCMI
608 
609  template <class TYPEdhwlbi, class TYPEwlbi>
610  static void ProcessLBI(MYSQL& mysql,
611  const TYPEdhwlbi dhwlbi, const TYPEwlbi *wlbi, const std::string& s) {
612  const Technology *t = mysql.GetTechnology(s);
613  if (t != NULL)
614  return;
615 
616  int nStruct = dhwlbi->size();
617  LBI *lbi = new LBI(mysql, s);
618  nlbi++;
619 
620  for (int i = 0; i < nStruct; i++) {
621  if (s.compare(2, s.size() - 2, MuonGM::buildString(wlbi[i].jsta, 2)) == 0) {
622  lbi->thickness = wlbi[i].thickness * Gaudi::Units::cm;
623  lbi->height = wlbi[i].height * Gaudi::Units::cm;
624  lbi->lowerThickness = wlbi[i].lowerThickness * Gaudi::Units::cm;
625  lbi->yShift = wlbi[i].yShift * Gaudi::Units::cm;
626  }
627  }
628  } // end of ProcessLBI
629 
630  template <class TYPEdnaptp, class TYPEaptp>
631  static void ProcessPositions(MYSQL& mysql, const TYPEdnaptp dnaptp, const TYPEaptp *aptp) {
632  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcPosition");
633 
634  const MDT *mdtobj = dynamic_cast<const MDT*>(mysql.GetATechnology("MDT0"));
635  double default_halfpitch = 0.5 * (mdtobj->pitch);
636  double halfpitch = default_halfpitch;
637 
638  std::string oldname = "XXX0";
639  std::string oldnamejtyp = "XXX";
640 
641  // np counter for station elements in space
642  int np = 0;
643  // nswithpos counter for stations (BML1) with >= element positioned
644  int nswithpos = 0;
645  // njtyp counter for station types (BML) with >= element positioned
646  int njtyp = 0;
647  std::vector<std::string> jtypvec;
648  std::vector<std::string> jtypstvec;
649 
650  for (unsigned int ipos = 0; ipos < dnaptp->size(); ipos++) {
651  char stype_name[3];
652  // type is aptp[ipos].type
653  // subtype is aptp[ipos].i
654  int subType = aptp[ipos].i;
655  int iCut = aptp[ipos].icut;
656 
657  sprintf(stype_name, "%i", aptp[ipos].i);
658  std::string name = std::string(aptp[ipos].type, 0, 3) + stype_name;
659  bool already_there = false;
660 
661  if (name != oldname) {
662  for (auto it = jtypstvec.begin(); it != jtypstvec.end(); ++it) {
663  if (name == (*it))
664  already_there = true;
665  }
666 
667  if (!already_there) {
668  jtypstvec.push_back(name);
669  nswithpos++;
670  if (verbose_posmap) {
671  log << MSG::VERBOSE << " Building position map for station " << name << " # of stat.s positioned up to now " << nswithpos << endmsg;
672  }
673  } else {
674  if (verbose_posmap) {
675  log << MSG::VERBOSE << " ... it is an update (!) of the map for " << name << endmsg;
676  }
677  }
678  oldname = name;
679  }
680 
681  std::string namejtyp = std::string(aptp[ipos].type, 0, 3);
682  already_there = false;
683 
684  if (namejtyp != oldnamejtyp) {
685  for (auto it = jtypvec.begin(); it != jtypvec.end(); ++it) {
686  if (namejtyp == (*it))
687  already_there = true;
688  }
689  if (!already_there) {
690  njtyp++;
691  jtypvec.push_back(std::string(aptp[ipos].type, 0, 3));
692  }
693  oldnamejtyp = namejtyp;
694  }
695 
696  Station *stat = mysql.GetStation(name);
697  if (stat == NULL) {
698  log << MSG::ERROR << " station " << name << " not found; no " << name << " element will be located at iz " << aptp[ipos].iz << endmsg;
699  continue;
700  }
701  bool hasMdts = stat->hasMdts();
702 
703  if (hasMdts) {
704  halfpitch = default_halfpitch;
705  for (int icomp = 0; icomp < stat->GetNrOfComponents(); ++icomp) {
706  const Component *c = stat->GetComponent(icomp);
707  if (c->name.compare(0, 3,"MDT") != 0)
708  continue;
709  const MDT *mdtobj = dynamic_cast<const MDT*>(mysql.GetATechnology(c->name));
710  if (!mdtobj) {
711  log << MSG::ERROR << "Cannot find MDT definition for component " << c->name << endmsg;
712  continue;
713  }
714  halfpitch = 0.5 * (mdtobj->pitch);
715  log << MSG::DEBUG << "Setting halfpitch " << halfpitch << " for station " << name << endmsg;
716  break;
717  }
718  }
719 
720  Position p;
721  p.zindex = aptp[ipos].iz;
722  for (int phiindex = 0; phiindex < 8; ++phiindex) {
723  if (aptp[ipos].iphi[phiindex] == 0)
724  continue;
725  p.phitype = aptp[ipos].iphi[phiindex];
726  p.subtype = subType;
727  p.icut = iCut;
728  p.phiindex = phiindex;
729  p.phi = aptp[ipos].dphi + double(phiindex) * 45.;
730  p.radius = aptp[ipos].r * Gaudi::Units::cm;
731  p.z = aptp[ipos].z * Gaudi::Units::cm;
732  if (p.zindex < 0 && name.compare(0, 1,"B") == 0 && hasMdts)
733  p.z = p.z - halfpitch;
734  p.shift = aptp[ipos].s * Gaudi::Units::cm;
735  if (verbose_posmap) {
736  log << MSG::VERBOSE << "p.zindex,p.phi " << p.zindex << " " << p.phiindex << " shift is " << p.shift << endmsg;
737  }
738  // amdb seems to follow the opposite convention about the sign
739  // of rotation around the azimuthal axis (foro them it is a rotation
740  // around their local x axis)
741  // p.inclination = -aptp[ipos].gamma;
742  // p.gamma = -aptp[ipos].gamma;
743  p.inclination = aptp[ipos].gamma;
744  p.gamma = aptp[ipos].gamma;
745  p.alpha = aptp[ipos].alfa;
746  p.beta = aptp[ipos].beta;
747  p.isMirrored = false;
748  p.isBarrelLike = false;
749  if (isBarrelLike(aptp, ipos, phiindex))
750  p.isBarrelLike = true;
751 
752  np++;
753  stat->SetPosition(p);
754 
755  mysql.addallocPos(name.substr(0, 3), p.phiindex, p.zindex, subType, iCut);
756  }
757  }
758  log << MSG::INFO << " *** N. of stations positioned in the setup " << nswithpos << endmsg;
759  log << MSG::INFO << " *** N. of stations described in mysql " << mysql.NStations() << endmsg;
760  log << MSG::INFO << " *** N. of types " << njtyp << " size of jtypvec " << jtypvec.size() << endmsg;
761 
762  int nstat = 0;
763  int nnodes = 0;
764  for (const auto& [name, stat] : mysql.stationMap()) {
765  nstat++;
766  np = stat->Npositions();
767  if (verbose_posmap) {
768  log << MSG::VERBOSE << " Symmetrizing position map for station " << name << " with " << np << " not mirrored positions " << endmsg;
769  }
770 
771  for (PositionIterator ip = stat->begin(); ip != stat->end(); ++ip) {
772  int iz = ((*ip).second).zindex;
773  int iphi = ((*ip).second).phiindex;
774  int phitype = ((*ip).second).phitype;
775 
776  std::string skey = " ";
777  if (iz > 0 && phitype != 2) {
778  skey = mysql.allocPosBuildKey(name.substr(0, 3), iphi, -iz);
779  if (verbose_posmap) {
780  log << MSG::VERBOSE << " Looking for skey = " << skey << endmsg;
781  }
782  if (mysql.allocPosFind(skey) == mysql.allocPosEnd()) {
783  Position newp;
784  newp.isMirrored = true;
785  newp.phitype = ((*ip).second).phitype;
786  newp.subtype = ((*ip).second).subtype;
787  newp.icut = ((*ip).second).icut;
788 
789  newp.zindex = -iz;
790  newp.phiindex = iphi;
791  newp.phi = ((*ip).second).phi;
792  newp.radius = ((*ip).second).radius;
793  if (name[0] == 'B') {
794  newp.z = -((*ip).second).z - stat->GetLength();
795  } else {
796  newp.z = -((*ip).second).z - stat->GetThickness(mysql);
797  }
798 
799  newp.shift = ((*ip).second).shift;
800  newp.inclination = ((*ip).second).inclination;
801  newp.alpha = ((*ip).second).alpha;
802  newp.beta = ((*ip).second).beta;
803  newp.gamma = ((*ip).second).gamma;
804  np++;
805  stat->SetPosition(newp);
806 
807  if (verbose_posmap) {
808  log << MSG::VERBOSE << " symmetric pos. created at iz,iphi, z " << newp.zindex << " " << newp.phiindex << " " << newp.z << endmsg;
809  }
810  mysql.addallocPos(name.substr(0, 3), newp.phiindex, newp.zindex, newp.subtype, newp.icut);
811  } else {
812  if (verbose_posmap) {
813  log << MSG::VERBOSE << " position already allocated by subtype/cutout " << mysql.allocPosFindSubtype(skey) << "/" << mysql.allocPosFindCutout(skey)
814  << endmsg;
815  }
816  }
817  }
818  }
819  if (verbose_posmap) {
820  log << MSG::VERBOSE << " *** Position map for station " << name << " has " << stat->Npositions() << " entries" << endmsg;
821  }
822  nnodes += stat->Npositions();
823  }
824 
825  log << MSG::INFO << " *** : " << nstat << " kinds of stations (type*sub_type) " << endmsg;
826  log << MSG::INFO << " *** : " << nnodes << " physical stations in space - according to the MuonDD DataBase" << endmsg;
827  }
828 
829  template <class TYPEaptp> static bool isBarrelLike(const TYPEaptp * /*aptp*/, int /*ipos*/, int /*phiindex*/) {
830  // this must be specialised
831  return false;
832  }
833 
834  template <class TYPEdnaszt, class TYPEaszt>
835  static void ProcessAlignements(MYSQL& mysql, const TYPEdnaszt dnaszt, const TYPEaszt *aszt) {
836  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcessAlignements");
837 
838 
839  if (verbose_alimap) {
840  log << MSG::VERBOSE << " ProcessAlignements:: how many stations there are ? " << mysql.NStations() << endmsg;
841  }
842  int fi = 0;
843  int zi = 0;
844  PositionIterator pit;
845  for (unsigned int ipos = 0; ipos < dnaszt->size(); ipos++) {
846  std::string name = std::string(aszt[ipos].type, 0, 3);
847  fi = aszt[ipos].jff - 1; // jff 1-8; we want 0-7
848  zi = aszt[ipos].jzz;
849  if (verbose_alimap) {
850  log << MSG::VERBOSE << " ProcessAlignements:: --- Alignment for " << name << endmsg;
851  }
852  std::string key = mysql.allocPosBuildKey(name, fi, zi);
853  int subtype = mysql.allocPosFindSubtype(key);
854  int cutout = mysql.allocPosFindCutout(key);
855 
856  if (subtype != 0) {
857  if (verbose_alimap) {
858  log << MSG::VERBOSE << " corresponding subtype/cutout are " << subtype << "/" << cutout << endmsg;
859  }
860  std::string stname = name + MuonGM::buildString(subtype, 1);
861 
862  Station *stat = mysql.GetStation(stname);
863  if (stat == NULL) {
864  if (verbose_alimap) {
865  log << MSG::VERBOSE << " Station named " << stname << " not found " << endmsg;
866  }
867  continue;
868  } else { // search for the correct position entries in this station:
869  pit = stat->FindPosition(zi, fi);
870  if (pit != stat->end()) {
871  if ((*pit).second.zindex == zi && (*pit).second.phiindex == fi) {
872  AlignPos ap;
873  ap.tras = 0. * Gaudi::Units::cm; // in cm from NOVA...
874  ap.traz = 0. * Gaudi::Units::cm; // in cm
875  ap.trat = 0. * Gaudi::Units::cm; // in cm
876  ap.rots = 0.; // in radians
877  ap.rotz = 0.; // in radians
878  ap.rott = 0.; // in radians
879 
880 
881  ap.tras = aszt[ipos].tras * Gaudi::Units::cm; // in cm from NOVA...
882  ap.traz = aszt[ipos].traz * Gaudi::Units::cm; // in cm
883  ap.trat = aszt[ipos].trat * Gaudi::Units::cm; // in cm
884  ap.rots = aszt[ipos].rots; // in radians
885  ap.rotz = aszt[ipos].rotz; // in radians
886  ap.rott = aszt[ipos].rott; // in radians
887 
888  if (verbose_alimap) {
889  log << MSG::VERBOSE << "A-line: " << ap.tras << " " << ap.traz << " " << ap.trat << " " << ap.rots << " " << ap.rotz << " " << ap.rott
890  << endmsg;
891  }
892 
893  ap.phiindex = aszt[ipos].jff - 1; // jff 1-8, not 0-7?
894  ap.jobindex = aszt[ipos].job; // jff 1-8, not 0-7?
895  ap.zindex = aszt[ipos].jzz;
896  ap.tectype = stname;
897  // is this a barrel station? E/T/C = ec, B/R = barrel:
898  if (name.compare(0, 1, "B") == 0 || name.compare(0, 1, "R") == 0) {
899  ap.isBarrel = true;
900  ap.isTrapezoid = false; // Barrel MDTs, RPCs.
901  } else {
902  ap.isBarrel = false;
903  ap.isTrapezoid = true; // EC MDTs, CSCs ?all TGCs?
904  }
905 
906  // Deal with Pb-positioner possibility:
907  if ((*pit).second.isBarrelLike) {
908  // std::cout << "Probably a Pb ?" << stname << std::endl;
909  ap.isBarrel = true;
910  }
911  if (verbose_alimap) {
912  log << MSG::VERBOSE << " Setting aligned position for station " << stname << " with key " << key << endmsg;
913  }
914  stat->SetAlignPos(ap);
915  }
916  }
917  }
918  } else {
919  if (verbose_alimap) {
920  log << MSG::VERBOSE << " No Position allocated for key " << key << endmsg;
921  }
922  }
923  }
924  } // end ProcessAlignements
925 
926  template <class TYPEdnalmn, class TYPEalmn, class TYPEdnatyp, class TYPEatyp, class TYPEdhwmdt, class TYPEwmdt>
927  static void ProcessStations(MYSQL& mysql, const TYPEdnalmn dnalmn, const TYPEalmn *almn, const TYPEdnatyp dnatyp, const TYPEatyp *atyp, const TYPEdhwmdt dhwmdt, const TYPEwmdt *wmdt) {
928  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcStations");
929  log << MSG::INFO << " Processing Stations and Components" << endmsg;
930 
931  std::string cartec;
932  Station *stat = NULL, *previous_stat = NULL, *previous_stored = NULL;
933 
934  // control on new stations/subtypes
935  int previous_jtyp = 0;
936  int previous_subt = 0;
937  int nstat = 0;
938  std::string name = "XXX0", type_name = "XXX";
939 
940  // that doesn't seem right for BME/BMG chambers - no idea if has an impact at the end
941  // in any case it was wrong since every and would have been wrong also in previous code
942  double default_halfpitch = 15.0175 * Gaudi::Units::mm;
943  double halfpitch = default_halfpitch;
944 
945  // loop over the banks of station components: ALMN
946  for (unsigned int icomp = 0; icomp < dnalmn->size(); ++icomp) {
947  if (almn[icomp].jtyp != previous_jtyp || almn[icomp].indx != previous_subt) {
948  // a new jtyp and subtyp = almn.indx; then a new station starts here
949  if (previous_stat != NULL && previous_stat != previous_stored) {
950  // define positions of the previous station
951  previous_stored = previous_stat;
952  }
953  // here define a new station
954  // std::cout << "A new station " << std::endl;
955  unsigned int type_ind = 0;
956  // log << MSG::DEBUG << " Look for the index of the type " << endmsg;
957  for (type_ind = 0; type_ind < dnatyp->size(); ++type_ind) {
958  if (almn[icomp].jtyp == atyp[type_ind].jtyp)
959  break;
960  }
961  // name is the station name (type+subtype) BML2, BIS1, EOL2, T1F1, etc
962  if (strcmp(atyp[type_ind].type.c_str(), "!") != 0) {
963  type_name = std::string(atyp[type_ind].type, 0, 3);
964  name = type_name + MuonGM::buildString(almn[icomp].indx, -1);
965  } else {
966  log << MSG::ERROR << " ProcessStations station-name not well defined " << atyp[type_ind].type << endmsg;
967  assert(0);
968  type_name = "XXX"; // just to take care of funny stuff
969  name = type_name + MuonGM::buildString(0, -1);
970  }
971 
972  stat = new Station(mysql, name);
973  previous_stat = stat;
974  nstat++;
975  log << MSG::DEBUG << " a new station has been built with name " << name << " nstat = " << nstat << endmsg;
976 
977  // ahead loop to determine halfpitch
978  halfpitch = default_halfpitch;
979  for (unsigned int ic = icomp; ic < dnalmn->size(); ++ic) {
980  if (almn[icomp].jtyp != almn[ic].jtyp || almn[icomp].indx != almn[ic].indx)
981  break;
982  int jtech = almn[ic].iw;
983  cartec = std::string(almn[ic].tec, 0, 3);
984  if (cartec == "MDT") {
985  if (((unsigned int)(jtech - 1)) > dhwmdt->size()) {
986  log << MSG::ERROR << "MDT jtech index not found in W MDT table, cannot determine half pitch"
987  << " for " << name << endmsg;
988  continue;
989  }
990  halfpitch = 0.5 * wmdt[jtech - 1].tubpit * Gaudi::Units::cm;
991  log << MSG::DEBUG << "Found new halfpitch: " << halfpitch << " for " << name << endmsg;
992  break;
993  }
994  }
995  }
996 
997  bool known_comp = true;
998  int jtech = almn[icomp].iw;
999  cartec = std::string(almn[icomp].tec, 0, 3);
1000 
1001  StandardComponent *c = NULL;
1002  if (cartec == "CSC") {
1003  c = new CscComponent;
1004  } else if (cartec == "SPA") {
1005  c = new SpaComponent;
1006  } else if (cartec == "MDT") {
1007  c = new MdtComponent;
1008  } else if (cartec == "RPC") {
1009  c = new RpcComponent;
1010  } else if (cartec == "TGC") {
1011  c = new TgcComponent;
1012  } else if (cartec == "CRO" || cartec == "CMI" || cartec == "CHV") {
1013  c = new CbmComponent;
1014  } else if (cartec.compare(0, 2, "LB") == 0) {
1015  c = new LbiComponent;
1016  } else {
1017  c = new StandardComponent;
1018  }
1019 
1020  // define here common properties
1021  c->posx = almn[icomp].dx * Gaudi::Units::cm;
1022  c->posy = almn[icomp].dy * Gaudi::Units::cm;
1023  c->posz = almn[icomp].dz * Gaudi::Units::cm;
1024  c->index = almn[icomp].job;
1025  c->name = cartec + MuonGM::buildString(almn[icomp].iw, 2);
1026  c->iswap = almn[icomp].ishape;
1027  c->dx1 = almn[icomp].width_xs * Gaudi::Units::cm;
1028  c->dx2 = almn[icomp].width_xl * Gaudi::Units::cm;
1029  c->dy = almn[icomp].length_y * Gaudi::Units::cm;
1030  c->excent = almn[icomp].excent * Gaudi::Units::cm;
1031  c->deadx = almn[icomp].dead1 * Gaudi::Units::cm;
1032  c->deady = almn[icomp].dead2 * Gaudi::Units::cm;
1033  c->dead3 = almn[icomp].dead3 * Gaudi::Units::cm;
1034 
1035  if (cartec == "CSC") {
1036  CscComponent *derc = (CscComponent *)c;
1037  if (derc == NULL) {
1038  log << MSG::WARNING << " There is a problem" << endmsg;
1039  }
1040  if (name[2] == 'L') {
1041  derc->dy = 1129.20 * Gaudi::Units::mm; // AMDB-Q and CTB
1042  // DHW: fix values from AMDB
1043  // else derc->dy = 1111.5*Gaudi::Units::mm;
1044  derc->maxwdy = almn[icomp].length_y * Gaudi::Units::cm;
1045  } else {
1046  derc->maxwdy = c->dy;
1047  }
1048  } else if (cartec == "SPA") {
1049  SpaComponent *derc = (SpaComponent *)c;
1050  derc->maxwdy = derc->dy;
1051  if (jtech == 6 && name.compare(0, 3, "CSL") == 0) {
1052  derc->dy = 1129.20 * Gaudi::Units::mm; // AMDB-Q and CTB
1053  }
1054  } else if (cartec == "MDT") {
1055  MdtComponent *derc = (MdtComponent *)c;
1056  // relevant only for endcap MDTs
1057  derc->tubelenStepSize = derc->dead3;
1058  // long width for MDTs is the length of the longest tubes
1059  // long width of a trapezoid enclosing everything must be larger ( derc->dx2 )
1060  derc->dx2 = derc->dx2 + (derc->tubelenStepSize + halfpitch) * (derc->dx2 - derc->dx1) / (derc->dy - derc->tubelenStepSize);
1061  // length for MDTs is the length of a tube layer;
1062  // length of a trapezoid enclosing the multilayer must be larger by halfpitch
1063  derc->dy = derc->dy + halfpitch;
1064  } else if (cartec == "RPC") {
1065  RpcComponent *derc = (RpcComponent *)c;
1066  derc->ndivy = 1;
1067  derc->ndivz = 1;
1068  // DHW 4 Feb 09 : no longer needed, read in above: derc->iswap = 1;
1069  } else if (cartec == "DED") {
1070 
1071  } else if (cartec == "SUP" || cartec == "TGC" || cartec == "CHV" || cartec == "CRO" || cartec == "CMI" || cartec.compare(0, 2, "LB") == 0) {
1072 
1073  if (cartec.compare(0, 2, "LB") == 0) {
1074  LbiComponent *derc = (LbiComponent *)c;
1075  derc->associated_CMIsubtype = "";
1076  if ((name == "BMF1" || name == "BMF2" || name == "BMF3" || name == "BMF4" || name == "BMF5" || name == "BMF6") && derc->name == "LB02") {
1077 
1078  log << MSG::DEBUG << "In this layout Station" << name << " has LB of type = " << derc->name << " ---- A problem in primary NUMBERS ? ---- resetting to LB01"
1079  << endmsg;
1080  derc->name = "LB01";
1081  }
1082  }
1083  // these are standard components: do nothing
1084  } else {
1085  known_comp = false;
1086  log << MSG::WARNING << " Unknown technology - component " << c->name << " will not be added to station " << stat->GetName() << endmsg;
1087  }
1088 
1089  if (known_comp && stat != NULL)
1090  stat->SetComponent(c);
1091  else {
1092  delete c;
1093  c = NULL;
1094  }
1095  if (cartec == "MDT" && stat != NULL)
1096  stat->setHasMdts(true);
1097  // here is the end - define the previous stuff
1098  previous_jtyp = almn[icomp].jtyp;
1099  previous_subt = almn[icomp].indx;
1100  previous_stat = stat;
1101  }
1102  log << MSG::INFO << " Processing Stations and Components DONE" << endmsg;
1103 
1104  } // end of ProcessStations
1105 
1106  template <class TYPEdnacut, class TYPEacut, class TYPEdnalin, class TYPEalin, class TYPEdnatyp, class TYPEatyp>
1107  static void ProcessCutouts(MYSQL& mysql, const TYPEdnacut dnacut, const TYPEacut *acut, const TYPEdnalin dnalin, const TYPEalin *alin, const TYPEdnatyp dnatyp, const TYPEatyp *atyp) {
1108  MsgStream log(Athena::getMessageSvc(), "MuGM:ProcCutouts");
1109 
1110  log << MSG::INFO << " Processing Cutouts for geometry layout " << mysql.getLayoutName() << endmsg;
1111 
1112  std::string name = "XXX0", type_name = "XXX";
1113 
1114  int countalin = 0;
1115 
1116  // loop over the banks of station components with cutouts: ACUT
1117  for (unsigned int icomp = 0; icomp < dnacut->size(); ++icomp) {
1118  log << MSG::VERBOSE << " ------------- this is ACUT = " << icomp + 1 << " out of " << dnacut->size() << " station type index = " << acut[icomp].i
1119  << " cutout index: " << acut[icomp].icut << " there are " << acut[icomp].n << " cutouts in this station" << endmsg;
1120 
1121  // loop over the banks of cutouts: ALIN
1122  if (countalin + acut[icomp].n <= (int)dnalin->size()) {
1123  for (int ialin = countalin; ialin < countalin + acut[icomp].n; ++ialin) {
1124  log << MSG::VERBOSE << " this is ALIN = " << ialin + 1 << " out of " << dnalin->size() << " Station type =" << alin[ialin].jtyp << " Index/Cutout-index: ("
1125  << alin[ialin].indx << "," << alin[ialin].icut << ") should match (" << acut[icomp].i << "," << acut[icomp].icut << ")"
1126  << " component with subcut i = " << alin[ialin].i << endmsg;
1127  Cutout *c = new Cutout();
1128  c->dx = alin[ialin].dx * Gaudi::Units::cm;
1129  c->dy = alin[ialin].dy * Gaudi::Units::cm;
1130  c->widthXs = alin[ialin].width_xs * Gaudi::Units::cm;
1131  c->widthXl = alin[ialin].width_xl * Gaudi::Units::cm;
1132 
1133  if (alin[ialin].jtyp == 11 && (c->dy > 0.0001 && c->dy < 1.)) {
1134  log << MSG::VERBOSE << "DBREADER redefining dy of the cutout from " << c->dy;
1135  c->dy = 0.000 * Gaudi::Units::mm;
1136  log << " to " << c->dy << endmsg;
1137  }
1138 
1139  c->lengthY = alin[ialin].length_y * Gaudi::Units::cm;
1140  c->excent = alin[ialin].excent * Gaudi::Units::cm;
1141  c->dead1 = alin[ialin].dead1;
1142 
1143  // temporary fix for bug in Nova/Oracle: 18/05/2006 I don't think this is needed anymore
1144  // c->dead1 = 10.*alin[ialin].dead1;
1145  c->ijob = alin[ialin].i;
1146  c->subtype = alin[ialin].indx;
1147  c->icut = alin[ialin].icut;
1148 
1149  // name is the station name (type+subtype) BML2, BIS1,etc.
1150  unsigned int type_ind;
1151  for (type_ind = 0; type_ind < dnatyp->size(); ++type_ind) {
1152  if (alin[ialin].jtyp == atyp[type_ind].jtyp)
1153  break;
1154  }
1155 
1156  if (strcmp(atyp[type_ind].type.c_str(), "!") != 0) {
1157  type_name = std::string(atyp[type_ind].type, 0, 3);
1158  name = type_name + MuonGM::buildString(alin[ialin].indx, -1);
1159  Station *stat = mysql.GetStation(name);
1160  if (stat == NULL) {
1161  delete c;
1162  c = NULL;
1163  log << MSG::ERROR << " station " << name << " not found! " << endmsg;
1164  continue;
1165  }
1166 
1167  stat->SetCutout(c);
1168  log << MSG::VERBOSE << " adding a new cut-line to station " << stat->GetName() << " cutindex/Stsubtype/component " << c->icut << "/" << c->subtype << "/"
1169  << c->ijob << endmsg;
1170  log << MSG::VERBOSE << " There are now " << stat->GetNrOfCutouts() << " cutouts in station " << stat->GetName() << endmsg;
1171  } else {
1172  delete c;
1173  c = NULL;
1174  log << MSG::ERROR << " ProcessCutouts station-name not well defined " << atyp[type_ind].type << endmsg;
1175  assert(0);
1176  type_name = "XXX"; // just to take care of funny stuff
1177  name = type_name + MuonGM::buildString(0, -1);
1178  }
1179  } // for (int ialin = countalin; ialin<countalin+acut[icomp].n; ++ialin)
1180  } // if (countalin+acut[icomp].n <= (int)dnalin->size())
1181  countalin = countalin + acut[icomp].n;
1182  } // for (unsigned int icomp = 0; icomp<dnacut->size(); ++icomp)
1183 
1184  log << MSG::INFO << " Processing Cutouts DONE" << endmsg;
1185 
1186  } // end of ProcessCutouts
1187 
1188 } // namespace MuonGM
1189 
1190 #endif // MUONGEOMODEL_DBREADER_H
TGC
@ TGC
Definition: RegSelEnums.h:33
DblQ00Dbam.h
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MuonGM::DBReader::setGeometryVersion
void setGeometryVersion(std::string s)
Definition: DBReader.cxx:20
MuonGM::DBReader
Definition: DBReader.h:116
MuonGM::DBReader::m_version
std::string m_version
Definition: DBReader.h:137
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
MuonGM::DBReader::m_SCdbaccess
StatusCode m_SCdbaccess
Definition: DBReader.h:128
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
CscComponent.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
DblQ00Alin.h
DblQ00Atln.h
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:53
SUP_Technology.h
CHV_Technology.h
LB_AnalMapSplitter.lbi
lbi
Definition: LB_AnalMapSplitter.py:22
skel.it
it
Definition: skel.GENtoEVGEN.py:423
MuonGM::MYSQL
Definition: MYSQL.h:43
verbose_posmap
#define verbose_posmap
Definition: DBReader.h:104
DblQ00Wtgc.h
DblQ00Acut.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DblQ00Atyp.h
MuonGM::DBReader::DBReader
DBReader(StoreGateSvc *)
Definition: DBReader.cxx:13
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
DblQ00Almn.h
python.AtlRunQueryParser.ap
ap
Definition: AtlRunQueryParser.py:826
RPCprint
#define RPCprint
Definition: DBReader.h:106
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
DblQ00Wchv.h
DblQ00Aptp.h
Station.h
DblQ00Wspa.h
TgcComponent.h
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
MuonGM::DBReader::setManager
void setManager(MuonDetectorManager *detmgr)
Definition: DBReader.h:121
SpaComponent.h
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:26
StandardComponent.h
CbmComponent.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
TGC
Definition: TgcBase.h:6
CRO_Technology.h
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonGM::PositionIterator
std::map< int, Position, std::less< int > >::const_iterator PositionIterator
Definition: Station.h:37
Cutout.h
RPC_Technology.h
MuonGM::DBReader::TGCreadoutName
std::string TGCreadoutName(int ichtyp)
Definition: DBReader.cxx:24
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
DblQ00Asmp.h
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
CSC_Technology.h
MuonGM::DBReader::m_mgr
MuonDetectorManager * m_mgr
Definition: DBReader.h:132
DblQ00Wlbi.h
beamspotman.stat
stat
Definition: beamspotman.py:266
DblQ00Awln.h
GlobalUtilities.h
SPA_Technology.h
grepfile.ic
int ic
Definition: grepfile.py:33
LBI_Technology.h
MYSQL.h
MuonGM::DBReader::m_tgcReadoutMapping
std::vector< std::string > m_tgcReadoutMapping
Definition: DBReader.h:131
RPC
@ RPC
Definition: RegSelEnums.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DED_Technology.h
DblQ00Wcsc.h
LbiComponent.h
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MDT_Technology.h
verbose_alimap
#define verbose_alimap
Definition: DBReader.h:105
MuonGM::strtoint
int strtoint(std::string_view str, unsigned int istart, unsigned int length)
Definition: GlobalUtilities.cxx:37
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
Position.h
MuonGM::DBReader::~DBReader
virtual ~DBReader()
Definition: DBReader.h:123
python.PyAthena.v
v
Definition: PyAthena.py:157
DblQ00Wrpc.h
DblQ00Wded.h
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
lwtDev::Component
Component
Definition: NNLayerConfig.h:25
DblQ00Wmdt.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
DblQ00Aszt.h
checkFileSG.fi
fi
Definition: checkFileSG.py:65
MuonGM::DBReader::m_msgSvc
IMessageSvc * m_msgSvc
Definition: DBReader.h:136
DblQ00Wsup.h
RpcComponent.h
DblQ00Wcmi.h
CSC
@ CSC
Definition: RegSelEnums.h:34
TGC_Technology.h
MuonGM::DBReader::ProcessDB
virtual StatusCode ProcessDB(MYSQL &)
Definition: DBReader.h:118
MdtComponent.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
MuonGM::DBReader::getGeometryVersion
const std::string & getGeometryVersion() const
Definition: DBReader.cxx:22
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
MuonGM::buildString
std::string buildString(int i, int ncha)
Definition: GlobalUtilities.cxx:23
StoreGateSvc.h
python.compressB64.c
def c
Definition: compressB64.py:93
Technology.h
subproc.subtype
string subtype
Definition: subproc.py:19
DblQ00Wcro.h
CMI_Technology.h
MDT
@ MDT
Definition: RegSelEnums.h:31
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
createCoolChannelIdFile.oldname
oldname
Definition: createCoolChannelIdFile.py:105