00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 using namespace std;
00013
00014 #include <fstream>
00015 #include <iostream>
00016 #include <strstream>
00017 #include <vector>
00018
00019
00020
00021 #include <TGeoManager.h>
00022
00023 #include "MucGeomSvc/MucGeoGeneral.h"
00024 #include "ROOTGeo/MucROOTGeo.h"
00025
00026
00027
00028
00029 int
00030 MucGeoGeneral::m_gGeometryInit = 0;
00031
00032 MucGeoGeneral*
00033 MucGeoGeneral::m_gpMucGeoGeneral = 0L;
00034
00035 map<Identifier, MucGeoGap*>
00036 MucGeoGeneral::m_gpMucGeoGap = map<Identifier, MucGeoGap*>();
00037
00038 map<Identifier, MucGeoStrip*>
00039 MucGeoGeneral::m_gpMucGeoStrip = map<Identifier, MucGeoStrip*>();
00040
00041 MucGeoGeneral::MucGeoGeneral()
00042 {
00043
00044 }
00045
00046 MucGeoGeneral::~MucGeoGeneral()
00047 {
00048
00049 MucGeoGap* pGap = 0;
00050 while(m_gpMucGeoGap.size() > 0){
00051 map<Identifier, MucGeoGap*>::iterator iter = m_gpMucGeoGap.end();
00052 pGap = (*iter).second;
00053 delete pGap;
00054 m_gpMucGeoGap.erase(iter);
00055 }
00056
00057 MucGeoStrip* pStrip = 0;
00058 while(m_gpMucGeoStrip.size() > 0){
00059 map<Identifier, MucGeoStrip*>::iterator iter = m_gpMucGeoStrip.end();
00060 pStrip = (*iter).second;
00061 delete pStrip;
00062 m_gpMucGeoStrip.erase(iter);
00063 }
00064 }
00065
00066 MucGeoGeneral&
00067 MucGeoGeneral::operator=(const MucGeoGeneral& orig)
00068 {
00069
00070 if ( this != &orig ) {
00071 m_gpMucGeoGeneral = orig.m_gpMucGeoGeneral;
00072 m_gpMucGeoGap = orig.m_gpMucGeoGap;
00073 m_gpMucGeoStrip = orig.m_gpMucGeoStrip;
00074 }
00075 return *this;
00076 }
00077
00078
00079 void
00080 MucGeoGeneral::Init()
00081 {
00082 for(unsigned int part = 0; part < MucID::getPartNum(); part++) {
00083 for(unsigned int seg = 0; seg < MucID::getSegMax(); seg++) {
00084 for(unsigned int gap = 0; gap < MucID::getGapMax(); gap++) {
00085 m_StripNumInGap[part][seg][gap] = 0;
00086 }
00087 }
00088 }
00089 }
00090
00091 void
00092 MucGeoGeneral::InitFromXML()
00093 {
00094
00095
00096
00097 bool geomanager = true;
00098 if (!gGeoManager) {
00099 gGeoManager = new TGeoManager("BesGeo", "Bes geometry");
00100 geomanager = false;
00101 }
00102
00103
00104
00105 MucROOTGeo *m_MucROOTGeo = new MucROOTGeo();
00106
00107 TGeoVolume *volMuc = m_MucROOTGeo->GetVolumeMuc();
00108 if(volMuc) std::cout << "Construct Muc from Muc.gdml" << std::endl;
00109 else std::cout << "volume Muc not found " << std::endl;
00110
00111 float m_BesR = 5200;
00112 float m_BesZ = 5680;
00113 TGeoIdentity *identity = new TGeoIdentity();
00114
00115 TGeoMaterial *mat = new TGeoMaterial("VOID",0,0,0);
00116 TGeoMedium *med = new TGeoMedium("MED",1,mat);
00117 TGeoVolume *m_Bes = gGeoManager->MakeBox("volBes", med, 0.5*m_BesR, 0.5*m_BesR, 0.5*m_BesZ);
00118 gGeoManager->SetTopVolume(m_Bes);
00119 m_Bes->AddNode(volMuc, 0, identity);
00120 m_MucROOTGeo->SetChildNo(m_Bes->GetNdaughters()-1);
00121
00122 gGeoManager->SetDrawExtraPaths();
00123 if(!geomanager)gGeoManager->CloseGeometry();
00124 gGeoManager->SetNsegments(20);
00125
00126 m_MucROOTGeo->SetPhysicalNode();
00127
00128 for (int part = 0; part < m_MucROOTGeo->GetPartNum(); part++) {
00129 for (int seg = 0; seg < m_MucROOTGeo->GetSegNum(part); seg++) {
00130 for (int gap = 0; gap < m_MucROOTGeo->GetGapNum(part); gap++) {
00131 Identifier gapID = MucID::channel_id(part,seg,gap,0);
00132
00133 float ironThickness = 0.0;
00134 if (part == 1) {
00135 if (gap > 0) ironThickness = m_MucROOTGeo->GetAbsorberThickness(part, seg, gap-1);
00136 }
00137 else {
00138 ironThickness = m_MucROOTGeo->GetAbsorberThickness(part, seg, gap);
00139 }
00140
00141
00142 int orient = 0;
00143 if ( (part == 1 && gap % 2 == 0) || (part != 1 && gap % 2 == 1) ) orient = 1;
00144 MucGeoGap *pGap = new MucGeoGap(part, seg, gap, orient, 0, m_MucROOTGeo->GetPhysicalGap(part, seg, gap), ironThickness);
00145 m_gpMucGeoGap[gapID] = pGap;
00146
00147 for (int strip = 0; strip < m_MucROOTGeo->GetStripNum(part, seg, gap); strip++) {
00148 Identifier stripID = MucID::channel_id(part,seg,gap,strip);
00149
00150 MucGeoStrip* pStrip = m_gpMucGeoGap[gapID]->AddStrip(strip);
00151 pStrip->SetStrip(m_MucROOTGeo->GetPhysicalStrip(part, seg, gap, strip));
00152 m_gpMucGeoStrip[stripID] = pStrip;
00153 }
00154 }
00155 }
00156 }
00157
00158 m_gGeometryInit = 1;
00159 }
00160
00161 void
00162 MucGeoGeneral::InitFromASCII()
00163 {
00164
00165 string gapSizeFile = "muc-gap-size.dat";
00166 string gapGeomFile = "muc-gap-geom.dat";
00167 string stripSizeFile = "muc-strip-size.dat";
00168 string stripGeomFile = "muc-strip-geom.dat";
00169
00170 static const int bufSize=512;
00171 char lineBuf[bufSize];
00172
00173
00174
00175
00176
00177 ifstream ifGapSize(gapSizeFile.c_str());
00178 if(!ifGapSize) {
00179 cout << "error opening gap size data file : "
00180 << gapSizeFile
00181 << endl;
00182 return;
00183 }
00184
00185 int part, seg, gap, strip, orient, panel;
00186 float xGapTemp, yGapTemp, zGapTemp;
00187 float xGapSize[m_kPartNum][m_kSegMax][m_kGapMax];
00188 float yGapSize[m_kPartNum][m_kSegMax][m_kGapMax];
00189 float zGapSize[m_kPartNum][m_kSegMax][m_kGapMax];;
00190
00191
00192
00193 while ( ifGapSize.getline(lineBuf,bufSize,'\n')) {
00194 if (ifGapSize.gcount() > bufSize) {
00195 cout << "input buffer too small! gcount = " << ifGapSize.gcount()
00196 << endl;
00197 return;
00198 }
00199
00200 istrstream stringBuf(lineBuf,strlen(lineBuf));
00201
00202 if (stringBuf >> part >> seg >> gap >> xGapTemp >> yGapTemp >> zGapTemp) {
00203 xGapSize[part][seg][gap] = xGapTemp;
00204 yGapSize[part][seg][gap] = yGapTemp;
00205 zGapSize[part][seg][gap] = zGapTemp;
00206
00207
00208
00209
00210
00211
00212 }
00213 else {
00214
00215
00216 }
00217 }
00218
00219 ifGapSize.close();
00220
00221
00222
00223
00224
00225 ifstream ifStripSize(stripSizeFile.c_str());
00226 if (!ifStripSize) {
00227 cout << "error opening strip size data file : "
00228 << stripSizeFile
00229 << endl;
00230 return;
00231 }
00232
00233 float xStripTemp, yStripTemp, zStripTemp;
00234 float xStripSize[m_kPartNum][m_kSegMax][m_kGapMax][m_kStripMax];
00235 float yStripSize[m_kPartNum][m_kSegMax][m_kGapMax][m_kStripMax];
00236 float zStripSize[m_kPartNum][m_kSegMax][m_kGapMax][m_kStripMax];
00237
00238
00239
00240 while (ifStripSize.getline(lineBuf,bufSize,'\n')) {
00241
00242 if (ifStripSize.gcount() > bufSize) {
00243 cout << "input buffer too small! gcount = " << ifStripSize.gcount()
00244 << endl;
00245 return;
00246 }
00247
00248 istrstream stringBuf(lineBuf,strlen(lineBuf));
00249
00250 if (stringBuf >> part >> seg >> gap >> strip >> xStripTemp >> yStripTemp >> zStripTemp) {
00251 xStripSize[part][seg][gap][strip] = xStripTemp;
00252 yStripSize[part][seg][gap][strip] = yStripTemp;
00253 zStripSize[part][seg][gap][strip] = zStripTemp;
00254
00255 m_StripNumInGap[part][seg][gap]++;
00256
00257
00258
00259
00260
00261
00262 }
00263 else {
00264
00265
00266 }
00267 }
00268
00269 ifStripSize.close();
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 ifstream ifGapGeom(gapGeomFile.c_str());
00285 if (!ifGapGeom) {
00286 cout << "error opening gap geometry data file : "
00287 << gapGeomFile
00288 << endl;
00289 return;
00290 }
00291
00292 float xGapTarg1, yGapTarg1, zGapTarg1;
00293 float xGapTarg2, yGapTarg2, zGapTarg2;
00294 float xGapTarg3, yGapTarg3, zGapTarg3;
00295 float dzHighEdge;
00296
00297 float dzFarFrontGas, dzNearFrontGas;
00298 float dzFarBackGas, dzNearBackGas;
00299
00300 float dxTarget1ToFiducial, dyTarget1ToFiducial;
00301 float dxFiducialToCenter, dyFiducialToCenter;
00302
00303 Identifier gapID = MucID::channel_id(0,0,0,0);
00304 Identifier stripID = MucID::channel_id(0,0,0,0);
00305
00306
00307
00308 while (ifGapGeom.getline(lineBuf,bufSize,'\n')) {
00309
00310 if ( ifGapGeom.gcount() > bufSize ) {
00311 cout << "input buffer too small! gcount = " << ifGapGeom.gcount()
00312 << endl;
00313 return;
00314 }
00315
00316 istrstream stringBuf(lineBuf,strlen(lineBuf));
00317
00318 if ( stringBuf >> part >> seg >> gap >> orient
00319 >> xGapTarg1 >> yGapTarg1 >> zGapTarg1
00320 >> xGapTarg2 >> yGapTarg2 >> zGapTarg2
00321 >> xGapTarg3 >> yGapTarg3 >> zGapTarg3
00322 >> dzHighEdge
00323 >> dzFarFrontGas >> dzNearFrontGas
00324 >> dzNearBackGas >> dzFarBackGas
00325 >> dxTarget1ToFiducial
00326 >> dyTarget1ToFiducial
00327 >> dxFiducialToCenter
00328 >> dyFiducialToCenter ) {
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 gapID = MucID::channel_id(part,seg,gap,0);
00342
00343 MucGeoGap *pGap = new MucGeoGap(part, seg, gap,
00344 orient, 0,
00345 xGapSize[part][seg][gap],
00346 yGapSize[part][seg][gap],
00347 zGapSize[part][seg][gap],
00348 xGapTarg1, yGapTarg1, zGapTarg1,
00349 xGapTarg2, yGapTarg2, zGapTarg2,
00350 xGapTarg3, yGapTarg3, zGapTarg3,
00351 dzHighEdge,
00352 dzFarFrontGas, dzNearFrontGas,
00353 dzNearBackGas, dzFarBackGas,
00354 dxTarget1ToFiducial,
00355 dyTarget1ToFiducial,
00356 dxFiducialToCenter,
00357 dyFiducialToCenter);
00358 m_gpMucGeoGap[gapID] = pGap;
00359 }
00360 else {
00361
00362
00363 }
00364
00365 }
00366
00367 ifGapGeom.close();
00368
00369
00370
00371
00372
00373 ifstream ifStripGeom(stripGeomFile.c_str());
00374 if (!ifStripGeom) {
00375 cout << "error opening strip geometry data file"
00376 << stripGeomFile
00377 << endl;
00378 return;
00379 }
00380
00381
00382
00383 float xStripTarg1, yStripTarg1, xStripTarg2, yStripTarg2;
00384
00385 while (ifStripGeom.getline(lineBuf,bufSize,'\n')) {
00386
00387 if (ifStripGeom.gcount() > bufSize) {
00388 cout << "input buffer too small! gcount = " << ifStripGeom.gcount()
00389 << endl;
00390 return;
00391 }
00392
00393 istrstream stringBuf(lineBuf,strlen(lineBuf));
00394
00395 if (stringBuf >> part >> seg >> gap >> strip >> panel
00396 >> xStripTarg1 >> xStripTarg2
00397 >> yStripTarg1 >> yStripTarg2) {
00398
00399
00400
00401
00402
00403
00404
00405 MucGeoStrip* pStrip = 0;
00406 stripID = MucID::channel_id(part,seg,gap,strip);
00407 gapID = MucID::channel_id(part,seg,gap,0);
00408
00409 if (!m_gpMucGeoStrip[stripID]) {
00410 if (m_gpMucGeoGap[gapID]) {
00411 pStrip = m_gpMucGeoGap[gapID]->AddStrip(strip);
00412 pStrip->SetStrip(xStripTarg1, xStripTarg2,
00413 yStripTarg1, yStripTarg2,
00414 xStripSize[part][seg][gap][strip],
00415 yStripSize[part][seg][gap][strip],
00416 zStripSize[part][seg][gap][strip]);
00417 m_gpMucGeoStrip[stripID] = pStrip;
00418 }
00419 else {
00420 cout << "missing gap" << gapID << endl;
00421 continue;
00422 }
00423 }
00424
00425 }
00426 else {
00427
00428
00429 }
00430
00431 }
00432
00433 ifStripGeom.close();
00434
00435 m_gGeometryInit = 1;
00436 }
00437
00438 MucGeoGeneral*
00439 MucGeoGeneral::Instance()
00440 {
00441
00442 if(!m_gpMucGeoGeneral) {
00443 m_gpMucGeoGeneral = new MucGeoGeneral;
00444 }
00445
00446 return m_gpMucGeoGeneral;
00447 }
00448
00449 MucGeoGap*
00450 MucGeoGeneral::GetGap(const int part,
00451 const int seg,
00452 const int gap) const
00453 {
00454
00455 Identifier gapID = MucID::channel_id(part, seg, gap, 0);
00456
00457 return m_gpMucGeoGap[gapID];
00458 }
00459
00460 MucGeoGap*
00461 MucGeoGeneral::GetGap(const Identifier id) const
00462 {
00463
00464 Identifier gapID = MucID::channel_id(MucID::part(id),
00465 MucID::seg(id),
00466 MucID::gap(id),
00467 0);
00468
00469 return m_gpMucGeoGap[gapID];
00470 }
00471
00472 MucGeoStrip*
00473 MucGeoGeneral::GetStrip(const int part,
00474 const int seg,
00475 const int gap,
00476 const int strip) const
00477 {
00478
00479 Identifier id = MucID::channel_id(part, seg, gap, strip);
00480
00481 return m_gpMucGeoStrip[id];
00482 }
00483
00484 MucGeoStrip*
00485 MucGeoGeneral::GetStrip(const Identifier id) const
00486 {
00487
00488 return m_gpMucGeoStrip[id];
00489 }
00490
00491 int
00492 MucGeoGeneral::GetStripNumTotal()
00493 {
00494 int nStripTotal = 0;
00495 for(unsigned int part = 0; part < MucID::getPartNum(); part++) {
00496 for(unsigned int seg = 0; seg < MucID::getSegNum(part); seg++) {
00497 for(unsigned int gap = 0; gap < MucID::getGapNum(part); gap++) {
00498 nStripTotal += GetStripNumInGap(part, seg, gap);
00499 }
00500 }
00501 }
00502
00503 return nStripTotal;
00504 }
00505
00506 vector<Identifier>
00507 MucGeoGeneral::FindIntersectGaps(const int part,
00508 const int gap,
00509 const HepPoint3D gPoint,
00510 const Hep3Vector gDirection)
00511 {
00512
00513
00514 vector<Identifier> gapList;
00515
00516 MucGeoGap *pGap = 0;
00517 Identifier id = MucID::channel_id(0,0,0,0);
00518 HepPoint3D intersection, localIntersection;
00519 Hep3Vector intersectionDir;
00520 double cos = -1;
00521
00522 for(unsigned int seg = 0; seg < MucID::getSegNum(part); seg++) {
00523 id = MucID::channel_id(part, seg, gap, 0);
00524 pGap = GetGap(id);
00525 if( pGap ) {
00526 intersection = pGap->ProjectToGap(gPoint, gDirection);
00527 localIntersection = pGap->TransformToGap(intersection);
00528
00529 intersectionDir = ((CLHEP::Hep3Vector)intersection) - ((CLHEP::Hep3Vector)gPoint);
00530 if( intersectionDir.mag() == 0 ) {
00531 cos = 0.0;
00532 }
00533 else {
00534 cos = intersectionDir.dot(gDirection) /
00535 ( intersectionDir.mag() * gDirection.mag() );
00536 }
00537
00538 if( ( cos >= 0.0 ) &&
00539 ( pGap->IsInGap(localIntersection.x(),
00540 localIntersection.y(),
00541 localIntersection.z()) ) ) {
00542 id = MucID::channel_id(part, seg, gap, 0);
00543 gapList.push_back(id);
00544 }
00545 else {
00546 }
00547
00548 }
00549 else{
00550 std::cout << "MucGeoGeneral::FindIntersectGaps(), Bad gap Pointer"
00551 << " part " << part
00552 << " seg " << seg
00553 << " gap " << gap
00554 << std::endl;
00555 }
00556 }
00557
00558 return gapList;
00559 }
00560
00561 vector<Identifier>
00562 MucGeoGeneral::FindIntersectStrips(const int part,
00563 const int gap,
00564 const HepPoint3D gPoint,
00565 const Hep3Vector gDirection)
00566 {
00567
00568
00569 vector<Identifier> gapList;
00570 vector<Identifier> stripList;
00571
00572 MucGeoGap *pGap;
00573 MucGeoStrip *pStrip;
00574
00575 int seg, iStripGuess, nStripMax;
00576 Identifier id;
00577 HepPoint3D intersection, localIntersection;
00578 Hep3Vector localDirection;
00579
00580 gapList = FindIntersectGaps(part, gap, gPoint, gDirection);
00581
00582 for(unsigned int i = 0; i < gapList.size(); i++) {
00583
00584 seg = MucID::seg(gapList[i]);
00585 pGap = GetGap(part, seg, gap);
00586 if(!pGap) {
00587 cout << "FindIntersectStrips : bad gap pointer!" << endl;
00588 return stripList;
00589 }
00590
00591 intersection = pGap->ProjectToGap(gPoint, gDirection);
00592 localIntersection = pGap->TransformToGap(intersection);
00593 localDirection = pGap->RotateToGap(gDirection);
00594
00595
00596 nStripMax = pGap->GetStripNum() - 1;
00597 iStripGuess = pGap->GuessStrip(localIntersection.x(),
00598 localIntersection.y(),
00599 localIntersection.z());
00600
00601
00602 int iStripLow = iStripGuess - 2;
00603 int iStripHigh = iStripGuess + 2;
00604 iStripLow = max(0, iStripLow);
00605 iStripHigh = min(nStripMax, iStripHigh);
00606
00607 iStripLow = 0;
00608 iStripHigh = nStripMax;
00609
00610
00611
00612
00613
00614 for(int j = iStripLow; j < iStripHigh; j++) {
00615 pStrip = pGap->GetStrip(j);
00616
00617 if(pStrip->CrossGasChamber(localIntersection, localDirection)) {
00618 id = MucID::channel_id(part, seg, gap, j);
00619 stripList.push_back(id);
00620 }
00621 }
00622
00623 }
00624
00625 return stripList;
00626 }
00627
00628
00629
00630 vector<Identifier>
00631 MucGeoGeneral::FindIntersectStrips(const int part,
00632 const int gap,
00633 const HepPoint3D gPoint,
00634 const Hep3Vector gDirection,
00635 vector<int> &padID, vector<float> &intersection_x,
00636 vector<float> &intersection_y,vector<float> &intersection_z)
00637 {
00638
00639
00640 vector<Identifier> gapList;
00641 vector<Identifier> stripList;
00642
00643 MucGeoGap *pGap;
00644 MucGeoStrip *pStrip;
00645
00646 int seg, iStripGuess, nStripMax;
00647 Identifier id;
00648 HepPoint3D intersection, localIntersection;
00649 Hep3Vector localDirection;
00650
00651 gapList = FindIntersectGaps(part, gap, gPoint, gDirection);
00652
00653 for(unsigned int i = 0; i < gapList.size(); i++) {
00654
00655 seg = MucID::seg(gapList[i]);
00656 pGap = GetGap(part, seg, gap);
00657 if(!pGap) {
00658 cout << "FindIntersectStrips : bad gap pointer!" << endl;
00659 return stripList;
00660 }
00661
00662 intersection = pGap->ProjectToGap(gPoint, gDirection);
00663 localIntersection = pGap->TransformToGap(intersection);
00664 localDirection = pGap->RotateToGap(gDirection);
00665
00666
00667 nStripMax = pGap->GetStripNum() - 1;
00668 iStripGuess = pGap->GuessStrip(localIntersection.x(),
00669 localIntersection.y(),
00670 localIntersection.z());
00671
00672
00673 int iStripLow = iStripGuess - 2;
00674 int iStripHigh = iStripGuess + 2;
00675 iStripLow = max(0, iStripLow);
00676 iStripHigh = min(nStripMax, iStripHigh);
00677
00678 iStripLow = 0;
00679 iStripHigh = nStripMax;
00680
00681
00682
00683
00684
00685 for(int j = iStripLow; j < iStripHigh; j++) {
00686 pStrip = pGap->GetStrip(j);
00687
00688 if(pStrip->CrossGasChamber(localIntersection, localDirection)) {
00689
00690
00691
00692
00693
00694
00695
00696 float posx,posy,posz;
00697 pStrip->GetCenterPos(posx,posy,posz);
00698
00699
00700
00701
00702
00703 int padid = -1;
00704 if(pGap->Orient() == 1)
00705 padid = (localIntersection.y() - pStrip->GetYmin())/(pStrip->GetXmax() - pStrip->GetXmin());
00706 else
00707 padid = (localIntersection.x() - pStrip->GetXmin())/(pStrip->GetYmax() - pStrip->GetYmin());
00708
00709
00710 padID.push_back(padid);
00711 intersection_x.push_back(localIntersection.x());
00712 intersection_y.push_back(localIntersection.y());
00713 intersection_z.push_back(localIntersection.z());
00714
00715 id = MucID::channel_id(part, seg, gap, j);
00716 stripList.push_back(id);
00717 }
00718 }
00719
00720 }
00721
00722 return stripList;
00723 }
00724
00725
00726
00727
00728
00729
00730 vector<HepPoint3D>
00731 MucGeoGeneral::FindIntersections(const int part,
00732 const int gap,
00733 const HepPoint3D gPoint,
00734 const Hep3Vector gDirection)
00735 {
00736
00737
00738 vector<HepPoint3D> intersectionList;
00739 MucGeoGap* pGap;
00740
00741 HepPoint3D intersection, localIntersection;
00742 Hep3Vector intersectionDir;
00743 double cos = -1;
00744
00745 for(unsigned int seg = 0; seg < MucID::getSegNum(part); seg++ ) {
00746 pGap = GetGap(part, seg, gap);
00747 if( pGap ) {
00748 intersection = pGap->ProjectToGap(gPoint, gDirection);
00749 localIntersection = pGap->TransformToGap(intersection);
00750
00751
00752 intersectionDir = ((CLHEP::Hep3Vector)intersection) - ((CLHEP::Hep3Vector)gPoint);
00753 if( intersectionDir.mag() == 0 ) {
00754 cos = 0.0;
00755 }
00756 else {
00757 cos = intersectionDir.dot(gDirection) /
00758 ( intersectionDir.mag() * gDirection.mag() );
00759 }
00760
00761 if( ( cos >= 0.0 ) &&
00762 ( pGap->IsInGap(localIntersection.x(),
00763 localIntersection.y(),
00764 localIntersection.z()) ) ) {
00765 intersectionList.push_back(intersection);
00766 }
00767 else {
00768 }
00769 }
00770 else{
00771 }
00772 }
00773
00774 return intersectionList;
00775 }
00776
00777
00778
00779
00780
00781
00782 void
00783 MucGeoGeneral::FindIntersection(const int part,
00784 const int seg,
00785 const int gap,
00786 const float vx,
00787 const float vy,
00788 const float vz,
00789 const float x0,
00790 const float y0,
00791 const float z0,
00792 const float sigmaVx,
00793 const float sigmaVy,
00794 const float sigmaVz,
00795 const float sigmaX0,
00796 const float sigmaY0,
00797 const float sigmaZ0,
00798 float& x,
00799 float& y,
00800 float& z,
00801 float& sigmaX,
00802 float& sigmaY,
00803 float& sigmaZ)
00804 {
00805 x = 0.0; sigmaX = 0.0;
00806 y = 0.0; sigmaY = 0.0;
00807 z = 0.0; sigmaZ = 0.0;
00808
00809 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
00810 cout << "MucGeoGeneral::FindIntersection-E101 invalid part = "
00811 << part << endl;
00812 return;
00813 }
00814
00815 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
00816
00817
00818 return;
00819 }
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829 float distance = 1e30;
00830
00831 MucGeoGap *p = GetGap(part, seg, gap);
00832 if (p) {
00833
00834 Hep3Vector v(vx, vy, vz);
00835 HepPoint3D r0(x0, y0, z0);
00836
00837
00838
00839
00840
00841
00842
00843
00844 HepPoint3D r = p->ProjectToGap(r0, v);
00845 HepPoint3D localIntersection = p->TransformToGap(r);
00846
00847
00848
00849 distance = r.distance(r0);
00850
00851 x = r.x();
00852 y = r.y();
00853 z = r.z();
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874 }
00875
00876 else {
00877 cout << "FindIntersection-E103 bad panel pointer!"
00878 << " Part" << part << " Seg" << seg << " Gap" << gap << endl;
00879 }
00880
00881
00882
00883 return;
00884 }
00885
00886 void
00887 MucGeoGeneral::FindIntersectionQuadLocal(const int part,
00888 const int seg,
00889 const int gap,
00890 const float a,
00891 const float b,
00892 const float c,
00893 const int whichhalf,
00894 float& x1,
00895 float& y1,
00896 float& z1,
00897 float& x2,
00898 float& y2,
00899 float& z2,
00900 float& sigmaX,
00901 float& sigmaY,
00902 float& sigmaZ)
00903 {
00904 x1 = 0.0; sigmaX = 0.0; x2 = 0.0;
00905 y1 = 0.0; sigmaY = 0.0; y2 = 0.0;
00906 z1 = 0.0; sigmaZ = 0.0; z2 = 0.0;
00907
00908 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
00909 cout << "MucGeoGeneral::FindIntersection-E101 invalid part = "
00910 << part << endl;
00911 return;
00912 }
00913
00914 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
00915
00916
00917 return;
00918 }
00919
00920
00921 float distance = 1e30;
00922
00923 MucGeoGap *p = GetGap(part, seg, gap);
00924 if (p) {
00925
00926 int orient = 0;
00927 if(part == 1 && gap%2 == 0) orient = 1;
00928 if(part != 1 && gap%2 == 1) orient = 1;
00929
00930 HepPoint3D cross1(0,0,0), cross2(0,0,0);
00931
00932 HepPoint3D r = p->ProjectToGapQuadLocal(part, orient, a, b, c,whichhalf, cross1, cross2);
00933
00934 HepPoint3D localIntersection = p->TransformToGap(r);
00935
00936
00937
00938 x1 = cross1.x();
00939 y1 = cross1.y();
00940 z1 = cross1.z();
00941
00942 x2 = cross2.x();
00943 y2 = cross2.y();
00944 z2 = cross2.z();
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958 }
00959
00960 else {
00961 cout << "FindIntersection-E103 bad panel pointer!"
00962 << " Part" << part << " Seg" << seg << " Gap" << gap << endl;
00963 }
00964
00965 return;
00966
00967 }
00968
00969
00970
00971
00972
00973
00974
00975
00976 void
00977 MucGeoGeneral::FindIntersection(const int part,
00978 const int seg,
00979 const int gap,
00980 const float vy,
00981 const float x0,
00982 const float y0,
00983 const float z0,
00984 const float a,
00985 const float b,
00986 const float c,
00987 const int whichhalf,
00988 const float,
00989 const float,
00990 const float,
00991 const float,
00992 const float,
00993 const float,
00994 float& x1,
00995 float& y1,
00996 float& z1,
00997 float& x2,
00998 float& y2,
00999 float& z2,
01000 float& sigmaX,
01001 float& sigmaY,
01002 float& sigmaZ)
01003 {
01004 x1 = 0.0; sigmaX = 0.0; x2 = 0.0;
01005 y1 = 0.0; sigmaY = 0.0; y2 = 0.0;
01006 z1 = 0.0; sigmaZ = 0.0; z2 = 0.0;
01007
01008 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
01009 cout << "MucGeoGeneral::FindIntersection-E101 invalid part = "
01010 << part << endl;
01011 return;
01012 }
01013
01014 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
01015
01016
01017 return;
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 float distance = 1e30;
01029
01030 MucGeoGap *p = GetGap(part, seg, gap);
01031 if (p) {
01032
01033 HepPoint3D r0(x0, y0, z0);
01034
01035
01036
01037 HepPoint3D cross1(0,0,0), cross2(0,0,0);
01038
01039 HepPoint3D r = p->ProjectToGap(r0, vy, y0, a, b, c,whichhalf, cross1, cross2);
01040
01041 HepPoint3D localIntersection = p->TransformToGap(r);
01042
01043
01044 distance = r.distance(r0);
01045
01046 x1 = cross1.x();
01047 y1 = cross1.y();
01048 z1 = cross1.z();
01049
01050 x2 = cross2.x();
01051 y2 = cross2.y();
01052 z2 = cross2.z();
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066 }
01067
01068 else {
01069 cout << "FindIntersection-E103 bad panel pointer!"
01070 << " Part" << part << " Seg" << seg << " Gap" << gap << endl;
01071 }
01072
01073
01074
01075 return;
01076 }
01077
01078
01079
01080
01081
01082
01083
01084 void
01085 MucGeoGeneral::FindIntersectionSurface(const int part,
01086 const int seg,
01087 const int gap,
01088 const float vx,
01089 const float vy,
01090 const float vz,
01091 const float x0,
01092 const float y0,
01093 const float z0,
01094 const float,
01095 const float,
01096 const float,
01097 const float,
01098 const float,
01099 const float,
01100 float& x1,
01101 float& y1,
01102 float& z1,
01103 float& x2,
01104 float& y2,
01105 float& z2,
01106 float& sigmaX1,
01107 float& sigmaY1,
01108 float& sigmaZ1,
01109 float& sigmaX2,
01110 float& sigmaY2,
01111 float& sigmaZ2)
01112 {
01113 x1 = 0.0; sigmaX1 = 0.0;
01114 y1 = 0.0; sigmaY1 = 0.0;
01115 z1 = 0.0; sigmaZ1 = 0.0;
01116 x2 = 0.0; sigmaX2 = 0.0;
01117 y2 = 0.0; sigmaY2 = 0.0;
01118 z2 = 0.0; sigmaZ2 = 0.0;
01119
01120 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
01121 cout << "MucGeoGeneral::FindIntersection-E101 invalid part = "
01122 << part << endl;
01123 return;
01124 }
01125
01126 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
01127
01128
01129 return;
01130 }
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 float distance = 1e30;
01141
01142 MucGeoGap *p = GetGap(part, seg, gap);
01143 if (p) {
01144
01145 Hep3Vector v(vx, vy, vz);
01146 HepPoint3D r0(x0, y0, z0);
01147
01148
01149
01150
01151 HepPoint3D cross1, cross2;
01152 p->ProjectToGapSurface(r0, v, cross1, cross2);
01153
01154 x1 = cross1.x();
01155 y1 = cross1.y();
01156 z1 = cross1.z();
01157 x2 = cross2.x();
01158 y2 = cross2.y();
01159 z2 = cross2.z();
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173 }
01174
01175 else {
01176 cout << "FindIntersection-E103 bad panel pointer!"
01177 << " Part" << part << " Seg" << seg << " Gap" << gap << endl;
01178 }
01179
01180
01181
01182 return;
01183 }
01184
01185
01186
01187 void
01188 MucGeoGeneral::FindIntersectionSurface(const int part,
01189 const int seg,
01190 const int gap,
01191 const float vy,
01192 const float x0,
01193 const float y0,
01194 const float z0,
01195 const float a,
01196 const float b,
01197 const float c,
01198 const int whichhalf,
01199 const float,
01200 const float,
01201 const float,
01202 const float,
01203 const float,
01204 const float,
01205 float& x1,
01206 float& y1,
01207 float& z1,
01208 float& x2,
01209 float& y2,
01210 float& z2,
01211 float& sigmaX,
01212 float& sigmaY,
01213 float& sigmaZ)
01214 {
01215 x1 = 0.0; sigmaX = 0.0; x2 = 0.0;
01216 y1 = 0.0; sigmaY = 0.0; y2 = 0.0;
01217 z1 = 0.0; sigmaZ = 0.0; z2 = 0.0;
01218
01219 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
01220 cout << "MucGeoGeneral::FindIntersection-E101 invalid part = "
01221 << part << endl;
01222 return;
01223 }
01224
01225 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
01226
01227
01228 return;
01229 }
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239 float distance = 1e30;
01240
01241 MucGeoGap *p = GetGap(part, seg, gap);
01242 if (p) {
01243
01244 HepPoint3D r0(x0, y0, z0);
01245
01246
01247
01248 HepPoint3D cross1(0,0,0), cross2(0,0,0);
01249 p->ProjectToGapSurface(r0, vy, y0, a, b, c,whichhalf, cross1, cross2);
01250
01251
01252 x1 = cross1.x();
01253 y1 = cross1.y();
01254 z1 = cross1.z();
01255
01256 x2 = cross2.x();
01257 y2 = cross2.y();
01258 z2 = cross2.z();
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272 }
01273
01274 else {
01275 cout << "FindIntersection-E103 bad panel pointer!"
01276 << " Part" << part << " Seg" << seg << " Gap" << gap << endl;
01277 }
01278
01279
01280
01281 return;
01282 }