void BuildHybrid(AMSgvolume *mvol, int tkid) { // Build hybrid geometry TkLadder *lad = TkDBc::Head->FindTkId(tkid); if (!lad) return; int layer = std::abs(tkid)/100; int plane= TkDBc::Head->_plane_layer[layer-1]; int sign = (tkid > 0) ? 1 : -1; char name[5]; std::ostrstream ost(name,sizeof(name)); ost << ((tkid < 0) ? "ELL" : "ELR") << layer << std::ends; geant par[3]; if(layer==1 ||layer==8||layer==9){ par[0] = TkDBc::Head->_zelec[2]/2.; par[1] = TkDBc::Head->_zelec[1]/2.; par[2] = TkDBc::Head->_zelec[0]/2.; }else{ par[0] = TkDBc::Head->_zelec[0]/2.; par[1] = TkDBc::Head->_zelec[1]/2.; par[2] = TkDBc::Head->_zelec[2]/2.; } double hlen = TkCoo::GetLadderLength(tkid)/2 -(TkDBc::Head->_ssize_inactive[0]-TkDBc::Head->_ssize_active[0])/2; double hwid = TkDBc::Head->_ssize_active[1]/2; AMSRotMat rot0 = lad->GetRotMatT(); AMSRotMat rot = rot0*lad->GetRotMat(); AMSPoint pos = lad->GetPos()+lad->GetPosT(); AMSPoint loc(hlen, hwid, 0); AMSPoint oo = rot*loc+pos; // Get coordinate w.r.t. the mother layer geant coo[3]; coo[0] = oo.x() +sign*(TkCoo::GetLadderLength(tkid)/2+par[0]+0.003); coo[1] = oo.y(); coo[2] = (std::abs(oo.z())/oo.z())*(TkDBc::Head->_sup_hc_w[plane-1]/2.+par[2]+0.1); if(layer==1) coo[2] -= TkDBc::Head->_dz[0]; if(layer==8) coo[2] -= TkDBc::Head->_dz[4]; if(layer==9) coo[2] -= TkDBc::Head->_dz[5]; number nrm[3][3]; VZERO(nrm,9*sizeof(nrm[0][0])/4); nrm[0][0] = nrm[1][1] = nrm[2][2] = 1; int gid = tkid+1000; mvol->add(new AMSgvolume("ELECTRONICS", _nrot++, name, "BOX", par, 3, coo, nrm, "ONLY", 1, gid, 1)); }
Int_t GausBF::Find(AMSPoint pt1, AMSPoint pt2) { AMSDir d = pt2-pt1; AMSPoint p1 = pt1+d*(TkDBc()->GetZlayerAJ(1)-pt1.z())/d.z(); AMSPoint p9 = pt1+d*(TkDBc()->GetZlayerAJ(9)-pt1.z())/d.z(); if (p1.x() < 0) { p1[0] *= -1; p9[0] *= -1; } if (p1.y() < 0) { p1[1] *= -1; p9[1] *= -1; } Int_t l1 = TMath::Floor(p1.y()/TkDBc()->_ladder_Ypitch+0.5); Int_t l9 = TMath::Floor(p9.y()/TkDBc()->_ladder_Ypitch); Int_t s1 = TMath::Floor(p1.x()/TkDBc()->_SensorPitchK); Int_t s9 = TMath::Floor(p9.x()/TkDBc()->_SensorPitchK); if (l1 < 0 || l1 > 5 || s1 < 0 || s1 >= Nsen1[l1] || l9 < -4 || l9 > 3 || s9 < -11 || s9 >= 11) return -1; Int_t is1 = s1; for (Int_t l = 0; l < l1; l++) is1 += Nsen1[l]; if (s9 >= 0) l9 = 11-l9; else { l9 += 4; s9 = -s9-1; } Int_t is9 = l9*11+s9; if ((is1 == 59 && is9 == 98) || (is1 == 59 && is9 == 109) || (is1 == 73 && is9 == 98) || (is1 == 86 && is9 == 97) || (is1 == 86 && is9 == 98) || (is1 == 97 && is9 == 98)) return -1; return is9*100+is1; }
bool TofGeometry::IsInsidePlane(AMSPoint x[3], AMSPoint point) { float x0 = x[0].x(); float y0 = x[0].y(); float z0 = x[0].z(); float x1 = x[1].x(); float y1 = x[1].y(); float z1 = x[1].z(); float x2 = x[2].x(); float y2 = x[2].y(); float z2 = x[2].z(); float a = (y2 - y0)*(z1 - z0) - (z2 - z0)*(y1 - y0); float b = (z2 - z0)*(x1 - x0) - (x2 - x0)*(z1 - z0); float c = (x2 - x0)*(y1 - y0) - (y2 - y0)*(x1 - x0); float d = - a*x0 - b*y0 - c*z0; float result = a*point.x() + b*point.y() + c*point.z() + d; return (fabs(result)<0.01); // .1 mm }
int TofGeometry::GetTofPaddleIndex(AMSPoint point, float delta) { int index = -1; int nfound = 0; for (int ilayer=0; ilayer<4; ilayer++) { for (int ibar=0; ibar<GetNBars(ilayer); ibar++) { // z check if (fabs(point.z()-GetZPaddle(ilayer,ibar))>0.5) continue; // xy check if (HitCounter(point.x(),point.y(),ilayer,ibar,delta)) { index = ilayer*10 + ibar; nfound++; } } } if (nfound>1) return -nfound; return index; }
AMSPoint TofGeometry::GetIntersection(AMSPoint x[3], AMSPoint point, AMSDir dir) { // plane equation, ax + by + cz + d = 0 float x0 = x[0].x(); float y0 = x[0].y(); float z0 = x[0].z(); float x1 = x[1].x(); float y1 = x[1].y(); float z1 = x[1].z(); float x2 = x[2].x(); float y2 = x[2].y(); float z2 = x[2].z(); float a = (y2 - y0)*(z1 - z0) - (z2 - z0)*(y1 - y0); float b = (z2 - z0)*(x1 - x0) - (x2 - x0)*(z1 - z0); float c = (x2 - x0)*(y1 - y0) - (y2 - y0)*(x1 - x0); float d = - a*x0 - b*y0 - c*z0; // parametric line (x,y,z) = (A,B,C)*t + (X,Y,Z) float A = dir.x(); float B = dir.y(); float C = dir.z(); float X = point.x(); float Y = point.y(); float Z = point.z(); // intersection if (fabs(a*A + b*B + c*C)<1e-6) return AMSPoint(-300,-300,-300); float t = - (a*X + b*Y + c*Z + d) / (a*A + b*B + c*C); return AMSPoint(A*t + X, B*t + Y, C*t + Z); }
float TofGeometry::PathLengthInAPaddle(int il, int ib, AMSPoint point, AMSDir dir) { if ( (il<0)||(il>3)||(ib<0)||(ib>9) ) return false; // check intersection with every surface AMSPoint points[6]; int npoints = 0; for (int isurface=0; isurface<6; isurface++) { AMSPoint x[4] = { TofGeometry::GetPaddleSurfaceCorner(il,ib,isurface,0), TofGeometry::GetPaddleSurfaceCorner(il,ib,isurface,1), TofGeometry::GetPaddleSurfaceCorner(il,ib,isurface,2), TofGeometry::GetPaddleSurfaceCorner(il,ib,isurface,3) }; AMSPoint intersection = GetIntersection(x,point,dir); if (!IsInsideRectangle(x,intersection)) continue; points[npoints].setp(intersection.x(),intersection.y(),intersection.z()); npoints++; } // in the case of 2 intersection the particle is entering and exiting if (npoints!=2) return 0.; return (points[1] - points[0]).norm(); }
TF1 *GausBF::GetPr(Int_t is1, Int_t is9, Double_t rgt) const { AMSPoint p1 = GetP1(is1); AMSPoint p9 = GetP9(is9); AMSPoint pnt = p1; AMSDir dir = p9-p1; TF1 *fdr = GetDf(is1, is9, rgt); Double_t dy0 = fdr->Eval(p1.z())-dir.y()/dir.z(); Int_t ip = 11; TString str = Form("[0]+[1]*(x-%.4f)-(%f)*(x-27)-[3]", p1.z(), dy0); str += SE(5)+SE(8); str += "+[4]*[2]*TMath::C()/1e12*(0"; for (Int_t i = 0; i < 7; i++) str += SE(i*3+ip); str += ")"; static TF1 *func = 0; if (!func) func = new TF1("fpr", str); func->SetParameter(0, pnt.y()); func->SetParameter(1, dir.y()/dir.z()); func->SetParameter(2, 1/rgt); func->SetParameter(3, 0); func->FixParameter(4, TMath::Sqrt(1.+(dir[0]*dir[0] +dir[1]*dir[1])/dir[2]/dir[2])* (1.+dir[1]*dir[1] /dir[2]/dir[2])); func->SetParameter(5, 0); func->SetParameter( 8, 0); func->FixParameter(6, 65); func->FixParameter( 9, -65); func->FixParameter(7, 0.1); func->FixParameter(10, 0.1); for (Int_t i = 0; i < 21; i++) func->FixParameter(i+ip, GetPar(is1, is9, i)); func->FixParameter(3, func->Eval(pnt.z())-p1.y()); return func; }
void SWLadder::drawInfobar(QPainter *pnt) { pnt->fillRect(0, 0, wWid-2, tHei, QColor(0, 0, 0, 200)); drawClose(pnt); drawMore (pnt); pnt->setPen(Qt::white); drawText(pnt, 28, 10, "Ladder"); drawText(pnt, 80, 10, Form(" TkID: %d", tkID)); drawText(pnt, 170, 10, Form("nClsX: %d", nClsX)); drawText(pnt, 240, 10, Form("nClsY: %d", nClsY)); drawText(pnt, 78, 30, Form(" nSen: %d", nSen )); drawText(pnt, 175, 30, Form(" nHit: %d", nHit )); drawText(pnt, 241, 30, Form("nHitT: %d", nHitT)); drawText(pnt, 310, 30, Form("nHitG: %d", nHitG)); if (focusStatus & FOCUS_DOBJ) { DrawObj dobj = drawObj.at(focusStatus/FOCUS_DOBJ/2-1); if ((dobj.atrb & ATR_CLSX) || (dobj.atrb & ATR_CLSY)) { TrClusterR *cls = rEvent->pTrCluster(dobj.idx); double sig = cls->GetTotSignal(TrClusterR::kAsym); drawText(pnt, 27, 50, Form("Cluster Side: %d", cls->GetSide())); drawText(pnt, 140, 50, Form("Seed: %d", cls->GetAddress() +cls->GetSeedIndex())); drawText(pnt, 220, 50, Form("Len: %d", cls->GetLength())); drawText(pnt, 270, 50, Form("Signal: %.0f", sig)); if (dobj.atrb & ATR_CLSX) drawText(pnt, 350, 50, Form("Mult: %d", dobj.mult)); } else if (dobj.atrb & ATR_HIT) { TrRecHitR *hit = rEvent->pTrRecHit(dobj.idx); char cf1 = (hit->OnlyY()) ? 'G' : '_'; char cf2 = (hit->checkstatus(AMSDBc::USED)) ? 'T' : '_'; AMSPoint coo = hit->GetCoord(dobj.mult); drawText(pnt, 48, 50, Form("Hit Flag: %c%c", cf1, cf2)); drawText(pnt, 150, 50, Form("Coo: (%.2f, %.2f, %.2f)", coo.x(), coo.y(), coo.z())); drawText(pnt, 350, 50, Form("Mult: %d", dobj.mult)); } else if (dobj.atrb & ATR_TRK) { TrTrackR *trk = rEvent->pTrTrack(dobj.idx); int fpat[8]; for (int i = 0; i < 8; i++) fpat[i] = 0; TString hpat; for (int i = 0; i < trk->GetNhits(); i++) { TrRecHitR *hit = trk->GetHit(i); int ily = hit->GetLayer()-1; fpat[ily] = (hit->OnlyY()) ? 1 : 2; } for (int i = 0; i < 8; i++) { if (fpat[i] == 1) hpat += "Y"; else if (fpat[i] == 2) hpat += "O"; else hpat += "_"; } drawText(pnt, 48, 50, "Track"); drawText(pnt, 100, 50, Form("nHit: %d", trk->GetNhits())); drawText(pnt, 170, 50, Form("nHitXY: %d", trk->GetNhitsXY())); drawText(pnt, 270, 50, Form("fPat: %s", hpat.Data())); } } }
void BuildSupport(AMSgvolume *mvol, int tkid) { // Build ladder support geometry TkLadder *lad = TkDBc::Head->FindTkId(tkid); if (!lad) return; int layer = std::abs(tkid)/100; char name[5]; std::ostrstream ost(name,sizeof(name)); ost << "FOA" << layer << std::ends; geant par[3]; par[0] = TkCoo::GetLadderLength(tkid)/2; par[1] = TkDBc::Head->_ssize_inactive[1]/2; par[2] = sup_foam_w/2; double hlen = TkCoo::GetLadderLength(tkid)/2 -(TkDBc::Head->_ssize_inactive[0]-TkDBc::Head->_ssize_active[0])/2; double hwid = TkDBc::Head->_ssize_active[1]/2; AMSRotMat rot0 = lad->GetRotMatT(); AMSRotMat rot = rot0*lad->GetRotMat(); AMSPoint pos = lad->GetPos()+lad->GetPosT(); AMSPoint loc(hlen, hwid, 0); AMSPoint oo = rot*loc+pos; // Get coordinate w.r.t. the mother layer geant coo[3]; coo[0] = oo.x(); coo[1] = oo.y(); coo[2] = (std::abs(oo.z())/oo.z())*(std::abs(oo.z())-TkDBc::Head->_silicon_z/2-par[2]-sup_foam_tol); if(layer==1) coo[2] -= TkDBc::Head->_dz[0]; if(layer==8) coo[2] -= TkDBc::Head->_dz[4]; if(layer==9) coo[2] -= TkDBc::Head->_dz[5]; number nrm[3][3]; VZERO(nrm,9*sizeof(nrm[0][0])/4); nrm[0][0] = nrm[1][1] = nrm[2][2] = 1; int gid = tkid+1000; mvol->add(new AMSgvolume("Tr_Foam", _nrot++, name, "BOX", par, 3, coo, nrm, "ONLY", 1, gid, 1)); if(TRMCFFKEY.ActivateShielding){ //shielding par[0] = TkCoo::GetLadderLength(tkid)/2; par[1] = TkDBc::Head->_ssize_inactive[1]/2; par[2] = 0.01/2.; // 100 um coo[0] = oo.x(); coo[1] = oo.y(); coo[2] = (std::abs(oo.z())/oo.z())*(std::abs(oo.z())+TkDBc::Head->_silicon_z/2+par[2]+0.1); if(layer==1) coo[2] -= TkDBc::Head->_dz[0]; if(layer==8) coo[2] -= TkDBc::Head->_dz[4]; if(layer==9) coo[2] -= TkDBc::Head->_dz[5]; VZERO(nrm,9*sizeof(nrm[0][0])/4); nrm[0][0] = nrm[1][1] = nrm[2][2] = 1; char name2[5]; std::ostrstream ost2(name2,sizeof(name2)); ost2 << "SHD" << layer << std::ends; gid = tkid+1000; mvol->add(new AMSgvolume("TrShield-M", _nrot++, name2, "BOX", par, 3, coo, nrm, "ONLY", 1, gid, 1)); } }
AMSgvolume *BuildLadder(AMSgvolume *mvol, int tkid) { // Build ladder geometry TkLadder *lad = TkDBc::Head->FindTkId(tkid); if (!lad) return 0; int layer = std::abs(tkid)/100; int islot = (tkid > 0) ? tkid%100 : -tkid%100+20; int iname = layer*100+islot; char name[5]; std::ostrstream ost(name,sizeof(name)); ost << "L" << iname << std::ends; geant par[3]; par[0] = TkCoo::GetLadderLength(tkid)/2; par[1] = TkDBc::Head->_ssize_inactive[1]/2; par[2] = TkDBc::Head->_silicon_z/2; double hlen = TkCoo::GetLadderLength(tkid)/2 -(TkDBc::Head->_ssize_inactive[0]-TkDBc::Head->_ssize_active[0])/2; double hwid = TkDBc::Head->_ssize_active[1]/2; AMSRotMat rot0 = lad->GetRotMatT(); AMSRotMat rot = rot0*lad->GetRotMat(); AMSPoint pos = lad->GetPos()+lad->GetPosT(); AMSPoint loc(hlen, hwid, 0); AMSPoint oo = rot*loc+pos; // Get coordinate w.r.t. the mother layer geant coo[3]; coo[0] = oo.x(); coo[1] = oo.y(); coo[2] = oo.z(); if(layer==1) coo[2] -= TkDBc::Head->_dz[0]; if(layer==8) coo[2] -= TkDBc::Head->_dz[4]; if(layer==9) coo[2] -= TkDBc::Head->_dz[5]; AMSRotMat lrm0 = lad->GetRotMatT(); AMSRotMat lrm = lrm0*lad->GetRotMat(); number nrm[3][3]; for (int ii = 0; ii < 9; ii++) nrm[ii/3][ii%3] = lrm.GetEl(ii/3,ii%3); int gid =abs(tkid)/tkid* (abs(tkid)+1000); // printf("Sensor name %s %+03d %+9d %f %f %f\n",name,tkid,gid,coo[0],coo[1],coo[2]); AMSgvolume* ladd=(AMSgvolume*)mvol ->add(new AMSgvolume("NONACTIVE_SILICON", _nrot++, name, "BOX", par, 3, coo, nrm, "ONLY", 1, gid, 1)); // printf("Ladder name %s\n",name); // Build sensors for (int sensor = 0; sensor < lad->GetNSensors(); sensor++){ char nameS[5]; std::ostrstream ost2(nameS,sizeof(nameS)); ost2 << "S" << iname << std::ends; geant par[3]; par[0] = TkDBc::Head->_ssize_active[0]/2; par[1] = TkDBc::Head->_ssize_active[1]/2; par[2] = TkDBc::Head->_silicon_z/2; // Get coordinate w.r.t. the mother ladder geant coo[3]; coo[0] = -TkCoo::GetLadderLength(tkid)/2+ TkDBc::Head->_ssize_inactive[0]/2.+ sensor * TkDBc::Head->_SensorPitchK; coo[1] = coo[2] = 0; number nrm[3][3]; VZERO(nrm, 9*sizeof(nrm[0][0])/4); nrm[0][0] = nrm[1][1] = nrm[2][2] = 1; int lside= (tkid>0)? 1:0; int gid = abs(tkid)+1000*(lside)+10000*(sensor+1); // printf("Sensor name %s %+03d %+9d %f %f %f\n",nameS,tkid,gid,coo[0],coo[1],coo[2]); ladd->add(new AMSgvolume("ACTIVE_SILICON", _nrot++, nameS, "BOX", par, 3, coo, nrm, "ONLY", 1, gid, 1)); } return ladd; }