13 #ifndef MUONGEOMODEL_DBREADER_H
14 #define MUONGEOMODEL_DBREADER_H
19 #include "GaudiKernel/SystemOfUnits.h"
104 #define verbose_posmap false
105 #define verbose_alimap false
106 #define RPCprint false
111 class MuonDetectorManager;
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};
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);
162 for (
unsigned int i = 0;
i < dhwmdt->size();
i++) {
164 mdt->numOfLayers = wmdt[
i].laymdt;
168 mdt->thickness = mdt->totalThickness;
169 mdt->tubeDeadLength = 0;
176 for (
unsigned int k = 0;
k < 4;
k++)
178 for (
unsigned int j = 0; j < 4; j++)
184 template <
class TYPEdhwrpc,
class TYPEwrpc,
class TYPEdhwrpcall,
class TYPEwrpcall>
185 static void ProcessRPC(MYSQL& mysql,
const TYPEdhwrpc dhwrpc,
const TYPEwrpc *wrpc,
const TYPEdhwrpcall ,
const TYPEwrpcall *wrpcall,
const std::string&
s) {
188 const Technology *
t = mysql.GetTechnology(
s);
198 log << MSG::INFO <<
"ProcessRPC:: RPC central sup panel: tot & Al " << rpc->centralSupPanelThickness <<
" " << rpc->centralAlSupPanelThickness <<
endmsg;
206 rpc->GasGapThickness = 2. * rpc->bakeliteThickness + rpc->gasThickness + 2. * rpc->bakelitePetThickness + rpc->totalAirThickness;
208 log << MSG::INFO <<
"ProcessRPC:: Total GasGapThickness " << rpc->GasGapThickness <<
endmsg;
210 log << MSG::INFO <<
"ProcessRPC:: comes from 2*bak, gas, 2*bakpet " << rpc->bakeliteThickness <<
" " << rpc->gasThickness <<
" " << rpc->bakelitePetThickness <<
endmsg;
213 rpc->bakeliteThickness = rpc->bakeliteThickness + rpc->bakelitePetThickness;
215 log << MSG::INFO <<
"ProcessRPC::WARNING redefining RPC::bakeliteThickness to include pet " << rpc->bakeliteThickness <<
endmsg;
219 rpc->MidChamberDeadRegion_in_s = 2. * rpc->bakeliteframesize;
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;
229 log << MSG::INFO <<
"ProcessRPC:: defining RPC::petfoilThickness = " << rpc->petFoilThickness <<
endmsg;
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
243 rpc->stripPanelThickness =
244 rpc->stripPanelFoamThickness + 2. * rpc->stripPanelCopperSkinThickness + rpc->stripPanelStripSidePetThickness + rpc->stripPanelGroundSidePetThickness;
246 log << MSG::INFO <<
"ProcessRPC:: stripPanelThickness= " << rpc->stripPanelThickness <<
endmsg;
248 rpc->stripPanelFoamThickness = rpc->stripPanelFoamThickness + rpc->stripPanelStripSidePetThickness + rpc->stripPanelGroundSidePetThickness;
250 log << MSG::INFO <<
"ProcessRPC::WARNING redefining RPC::stripPanelFoamThickness to include pet on both sides " << rpc->stripPanelFoamThickness <<
endmsg;
254 double rpcLayerComputedTck = rpc->GasGapThickness + 2 * rpc->stripPanelThickness + rpc->petFoilThickness;
256 log << MSG::INFO <<
"ProcessRPC:: rpcLayerComputedTck = " << rpcLayerComputedTck <<
" while rpcLayerThickness in Nova = " << rpc->rpcLayerThickness <<
endmsg;
260 int nStruct = dhwrpc->size();
262 for (
unsigned int i = 0; (
i < dhwrpc->size() && !done);
i++) {
265 log << MSG::INFO <<
" ProcessRPC " <<
s <<
" index " <<
i <<
" jsta =" << wrpc[
i].jsta <<
" strings comparison:: <" <<
s.substr(3,
s.size() - 3) <<
">=<"
274 log << MSG::INFO <<
"ProcessRPC:: RPC external sup panel: tot & Al " << rpc->centralSupPanelThickness <<
" " << rpc->centralAlSupPanelThickness <<
endmsg;
276 rpc->lowerSupPanelThickness = 0;
277 rpc->lowerAlSupPanelThickness = 0;
278 rpc->upperSupPanelThickness = 0;
279 rpc->upperAlSupPanelThickness = 0;
281 rpc->TotalThickness = 2 * rpc->rpcLayerThickness + rpc->centralSupPanelThickness + rpc->externalSupPanelThickness;
283 log << MSG::INFO <<
"ProcessRPC:: (computed) Total RPC thickness = " << rpc->TotalThickness <<
endmsg;
286 rpc->thickness = rpc->maxThickness;
288 log << MSG::INFO <<
"ProcessRPC:: RPC max thickness " << rpc->maxThickness <<
endmsg;
296 log << MSG::INFO <<
"ProcessRPC:: s_pitch, z_pitch " << rpc->stripPitchS <<
" " << rpc->stripPitchZ <<
endmsg;
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;
305 log << MSG::INFO <<
"ProcessRPC:: ngg, nsp, nzp " << rpc->NGasGaps_in_s <<
" " << rpc->NstripPanels_in_s <<
" " << rpc->NstripPanels_in_z <<
endmsg;
309 log << MSG::INFO <<
" index = " <<
i <<
" nstruct " << nStruct <<
" " << dhwrpc->size() <<
endmsg;
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);
323 std::string
v[] = {
"muo::TGCGas",
"std::G10",
"muo::Honeycomb",
"std::Copper"};
327 for (
unsigned int i = 0;
i < dhwtgcall->size();
i++) {
329 tgc->nlayers = wtgcall[
i].nbevol;
337 for (
unsigned int j = firstj; j < dhwtgc->size(); j++) {
338 if (wtgc[j].jsta != wtgcall[
i].jsta)
341 mat = (
int)wtgc[j].icovol;
344 tgc->materials.push_back(
v[
mat - 1]);
345 tgc->positions.push_back(
p);
346 tgc->tck.push_back(
t);
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.;
357 tgc->radiusButton = 0.;
358 for (
int idir = 0; idir < 2; idir++) {
359 tgc->pitchButton[idir] = 0.;
361 tgc->angleButton = 0.;
368 template <
class TYPEdhwcsc,
class TYPEwcsc>
369 static void ProcessCSC(MYSQL& mysql,
const TYPEdhwcsc dhwcsc,
const TYPEwcsc *wcsc,
const std::string&
s) {
373 const Technology *
t = mysql.GetTechnology(
s);
378 csc->numOfLayers = 0;
381 std::string tname =
s;
382 while (tname !=
"XXXXX") {
383 for (
unsigned int i = 0;
i < dhwcsc->size();
i++) {
385 csc->numOfLayers = wcsc[
i].laycsc;
387 csc->thickness = csc->totalThickness;
408 if (csc->phireadoutpitch == 0.) {
409 log << MSG::WARNING <<
" csc->phireadoutpitch == 0 in layout " << mysql.getGeometryVersion() <<
endmsg;
413 csc->nEtastrips = 192;
414 csc->nPhistrips = 48;
419 csc->floatingstripswidth = 0.;
437 if (csc->numOfLayers == 0) {
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;
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;
457 csc->floatingstripswidth = 0;
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);
471 SPA *spa =
new SPA(mysql,
s);
474 for (
unsigned int i = 0;
i < dhwspa->size();
i++) {
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);
487 SUP *sup =
new SUP(mysql,
s);
490 for (
unsigned int i = 0;
i < dhwsup->size();
i++) {
494 if (
s.compare(3,
s.size() - 3,
"03") == 0) {
502 sup->xAMDB0 = -sup->largeVerClearance - sup->alHorProfileThickness / 2.;
504 sup->zAMDB0 = -sup->alVerProfileThickness - (sup->HorClearance - sup->alVerProfileThickness) / 2.;
505 sup->bottomsizewrtAMDB0 = sup->alVerFlangeLength + sup->alFlangeThickness;
508 sup->alVerFlangeLength = 0.;
510 sup->alHorProfileThickness = 0.;
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;
520 sup->zAMDB0 = -sup->zAMDB0;
521 sup->bottomsizewrtAMDB0 = sup->alFlangeThickness;
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;
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);
536 DED *ded =
new DED(mysql,
s);
539 for (
unsigned int i = 0;
i < dhwded->size();
i++) {
544 ded->HoneyCombThickness = ded->thickness - 2. * ded->AlThickness;
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);
557 int nStruct = dhwchv->size();
558 CHV *chv =
new CHV(mysql,
s);
561 for (
int i = 0;
i < nStruct;
i++) {
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);
576 int nStruct = dhwcro->size();
577 CRO *cro =
new CRO(mysql,
s);
580 for (
int i = 0;
i < nStruct;
i++) {
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);
596 int nStruct = dhwcmi->size();
597 CMI *cmi =
new CMI(mysql,
s);
600 for (
int i = 0;
i < nStruct;
i++) {
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);
616 int nStruct = dhwlbi->size();
617 LBI *lbi =
new LBI(mysql,
s);
620 for (
int i = 0;
i < nStruct;
i++) {
630 template <
class TYPEdnaptp,
class TYPEaptp>
631 static void ProcessPositions(MYSQL& mysql,
const TYPEdnaptp dnaptp,
const TYPEaptp *aptp) {
634 const MDT *mdtobj =
dynamic_cast<const MDT*
>(mysql.GetATechnology(
"MDT0"));
635 double default_halfpitch = 0.5 * (mdtobj->pitch);
636 double halfpitch = default_halfpitch;
639 std::string oldnamejtyp =
"XXX";
647 std::vector<std::string> jtypvec;
648 std::vector<std::string> jtypstvec;
650 for (
unsigned int ipos = 0; ipos < dnaptp->size(); ipos++) {
654 int subType = aptp[ipos].i;
655 int iCut = aptp[ipos].icut;
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;
662 for (
auto it = jtypstvec.begin();
it != jtypstvec.end(); ++
it) {
664 already_there =
true;
667 if (!already_there) {
668 jtypstvec.push_back(
name);
671 log <<
MSG::VERBOSE <<
" Building position map for station " <<
name <<
" # of stat.s positioned up to now " << nswithpos <<
endmsg;
681 std::string namejtyp = std::string(aptp[ipos].
type, 0, 3);
682 already_there =
false;
684 if (namejtyp != oldnamejtyp) {
685 for (
auto it = jtypvec.begin();
it != jtypvec.end(); ++
it) {
686 if (namejtyp == (*
it))
687 already_there =
true;
689 if (!already_there) {
691 jtypvec.push_back(std::string(aptp[ipos].
type, 0, 3));
693 oldnamejtyp = namejtyp;
696 Station *
stat = mysql.GetStation(
name);
698 log << MSG::ERROR <<
" station " <<
name <<
" not found; no " <<
name <<
" element will be located at iz " << aptp[ipos].iz <<
endmsg;
701 bool hasMdts =
stat->hasMdts();
704 halfpitch = default_halfpitch;
705 for (
int icomp = 0; icomp <
stat->GetNrOfComponents(); ++icomp) {
707 if (
c->name.compare(0, 3,
"MDT") != 0)
709 const MDT *mdtobj =
dynamic_cast<const MDT*
>(mysql.GetATechnology(
c->name));
711 log << MSG::ERROR <<
"Cannot find MDT definition for component " <<
c->name <<
endmsg;
714 halfpitch = 0.5 * (mdtobj->pitch);
721 p.zindex = aptp[ipos].iz;
722 for (
int phiindex = 0; phiindex < 8; ++phiindex) {
723 if (aptp[ipos].iphi[phiindex] == 0)
725 p.phitype = aptp[ipos].iphi[phiindex];
728 p.phiindex = phiindex;
729 p.phi = aptp[ipos].dphi +
double(phiindex) * 45.;
732 if (
p.zindex < 0 &&
name.compare(0, 1,
"B") == 0 && hasMdts)
733 p.z =
p.z - halfpitch;
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;
753 stat->SetPosition(
p);
755 mysql.addallocPos(
name.substr(0, 3),
p.phiindex,
p.zindex, subType, iCut);
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;
764 for (
const auto& [
name,
stat] : mysql.stationMap()) {
768 log <<
MSG::VERBOSE <<
" Symmetrizing position map for station " <<
name <<
" with " <<
np <<
" not mirrored positions " <<
endmsg;
772 int iz = ((*ip).second).zindex;
773 int iphi = ((*ip).second).phiindex;
774 int phitype = ((*ip).second).phitype;
776 std::string skey =
" ";
777 if (iz > 0 && phitype != 2) {
778 skey = mysql.allocPosBuildKey(
name.substr(0, 3), iphi, -iz);
782 if (mysql.allocPosFind(skey) == mysql.allocPosEnd()) {
784 newp.isMirrored =
true;
785 newp.phitype = ((*ip).second).phitype;
786 newp.subtype = ((*ip).second).
subtype;
787 newp.icut = ((*ip).second).icut;
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();
796 newp.z = -((*ip).second).
z -
stat->GetThickness(mysql);
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;
805 stat->SetPosition(newp);
808 log <<
MSG::VERBOSE <<
" symmetric pos. created at iz,iphi, z " << newp.zindex <<
" " << newp.phiindex <<
" " << newp.z <<
endmsg;
810 mysql.addallocPos(
name.substr(0, 3), newp.phiindex, newp.zindex, newp.subtype, newp.icut);
813 log <<
MSG::VERBOSE <<
" position already allocated by subtype/cutout " << mysql.allocPosFindSubtype(skey) <<
"/" << mysql.allocPosFindCutout(skey)
822 nnodes +=
stat->Npositions();
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;
829 template <
class TYPEaptp>
static bool isBarrelLike(
const TYPEaptp * ,
int ,
int ) {
834 template <
class TYPEdnaszt,
class TYPEaszt>
835 static void ProcessAlignements(MYSQL& mysql,
const TYPEdnaszt dnaszt,
const TYPEaszt *aszt) {
840 log <<
MSG::VERBOSE <<
" ProcessAlignements:: how many stations there are ? " << mysql.NStations() <<
endmsg;
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;
852 std::string
key = mysql.allocPosBuildKey(
name,
fi, zi);
854 int cutout = mysql.allocPosFindCutout(
key);
862 Station *
stat = mysql.GetStation(stname);
869 pit =
stat->FindPosition(zi,
fi);
870 if (pit !=
stat->end()) {
871 if ((*pit).second.zindex == zi && (*pit).second.phiindex ==
fi) {
884 ap.rots = aszt[ipos].rots;
885 ap.rotz = aszt[ipos].rotz;
886 ap.rott = aszt[ipos].rott;
889 log <<
MSG::VERBOSE <<
"A-line: " <<
ap.tras <<
" " <<
ap.traz <<
" " <<
ap.trat <<
" " <<
ap.rots <<
" " <<
ap.rotz <<
" " <<
ap.rott
893 ap.phiindex = aszt[ipos].jff - 1;
894 ap.jobindex = aszt[ipos].job;
895 ap.zindex = aszt[ipos].jzz;
898 if (
name.compare(0, 1,
"B") == 0 ||
name.compare(0, 1,
"R") == 0) {
900 ap.isTrapezoid =
false;
903 ap.isTrapezoid =
true;
907 if ((*pit).second.isBarrelLike) {
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) {
929 log << MSG::INFO <<
" Processing Stations and Components" <<
endmsg;
932 Station *
stat = NULL, *previous_stat = NULL, *previous_stored = NULL;
935 int previous_jtyp = 0;
936 int previous_subt = 0;
938 std::string
name =
"XXX0", type_name =
"XXX";
943 double halfpitch = default_halfpitch;
946 for (
unsigned int icomp = 0; icomp < dnalmn->size(); ++icomp) {
947 if (almn[icomp].jtyp != previous_jtyp || almn[icomp].indx != previous_subt) {
949 if (previous_stat != NULL && previous_stat != previous_stored) {
951 previous_stored = previous_stat;
955 unsigned int type_ind = 0;
957 for (type_ind = 0; type_ind < dnatyp->size(); ++type_ind) {
958 if (almn[icomp].jtyp == atyp[type_ind].jtyp)
962 if (strcmp(atyp[type_ind].
type.c_str(),
"!") != 0) {
963 type_name = std::string(atyp[type_ind].
type, 0, 3);
966 log << MSG::ERROR <<
" ProcessStations station-name not well defined " << atyp[type_ind].type <<
endmsg;
973 previous_stat =
stat;
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)
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"
997 bool known_comp =
true;
998 int jtech = almn[icomp].iw;
999 cartec = std::string(almn[icomp].tec, 0, 3);
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;
1017 c =
new StandardComponent;
1024 c->index = almn[icomp].job;
1026 c->iswap = almn[icomp].ishape;
1035 if (cartec ==
"CSC") {
1036 CscComponent *derc = (CscComponent *)
c;
1038 log << MSG::WARNING <<
" There is a problem" <<
endmsg;
1040 if (
name[2] ==
'L') {
1046 derc->maxwdy =
c->dy;
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) {
1054 }
else if (cartec ==
"MDT") {
1055 MdtComponent *derc = (MdtComponent *)
c;
1057 derc->tubelenStepSize = derc->dead3;
1060 derc->dx2 = derc->dx2 + (derc->tubelenStepSize + halfpitch) * (derc->dx2 - derc->dx1) / (derc->dy - derc->tubelenStepSize);
1063 derc->dy = derc->dy + halfpitch;
1064 }
else if (cartec ==
"RPC") {
1065 RpcComponent *derc = (RpcComponent *)
c;
1069 }
else if (cartec ==
"DED") {
1071 }
else if (cartec ==
"SUP" || cartec ==
"TGC" || cartec ==
"CHV" || cartec ==
"CRO" || cartec ==
"CMI" || cartec.compare(0, 2,
"LB") == 0) {
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") {
1078 log <<
MSG::DEBUG <<
"In this layout Station" <<
name <<
" has LB of type = " << derc->name <<
" ---- A problem in primary NUMBERS ? ---- resetting to LB01"
1080 derc->name =
"LB01";
1086 log << MSG::WARNING <<
" Unknown technology - component " <<
c->name <<
" will not be added to station " <<
stat->GetName() <<
endmsg;
1089 if (known_comp &&
stat != NULL)
1090 stat->SetComponent(
c);
1095 if (cartec ==
"MDT" &&
stat != NULL)
1096 stat->setHasMdts(
true);
1098 previous_jtyp = almn[icomp].jtyp;
1099 previous_subt = almn[icomp].indx;
1100 previous_stat =
stat;
1102 log << MSG::INFO <<
" Processing Stations and Components DONE" <<
endmsg;
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) {
1110 log << MSG::INFO <<
" Processing Cutouts for geometry layout " << mysql.getLayoutName() <<
endmsg;
1112 std::string
name =
"XXX0", type_name =
"XXX";
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;
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();
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;
1141 c->dead1 = alin[ialin].dead1;
1145 c->ijob = alin[ialin].i;
1146 c->subtype = alin[ialin].indx;
1147 c->icut = alin[ialin].icut;
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)
1156 if (strcmp(atyp[type_ind].
type.c_str(),
"!") != 0) {
1157 type_name = std::string(atyp[type_ind].
type, 0, 3);
1159 Station *
stat = mysql.GetStation(
name);
1163 log << MSG::ERROR <<
" station " <<
name <<
" not found! " <<
endmsg;
1168 log <<
MSG::VERBOSE <<
" adding a new cut-line to station " <<
stat->GetName() <<
" cutindex/Stsubtype/component " <<
c->icut <<
"/" <<
c->subtype <<
"/"
1174 log << MSG::ERROR <<
" ProcessCutouts station-name not well defined " << atyp[type_ind].type <<
endmsg;
1181 countalin = countalin + acut[icomp].n;
1184 log << MSG::INFO <<
" Processing Cutouts DONE" <<
endmsg;
1190 #endif // MUONGEOMODEL_DBREADER_H