9 #include "TGeoManager.h" 
   25  os <<
'('<<v3.X()<<
", "<<v3.Y()<<
", "<<v3.Z()<<
')';
 
   37   : TNamed(
"PndMdtIGeometry", 
"parameterized simulation of MDT")
 
   69       cout<<
"========================================================================="<<endl;
 
   70       cout<<
"PndMdtIGeometry::Init(), information of MDT geometry version, \n" 
   75       cout<<
"ROOT Geometry, top volume name#"<<fTopVol->GetName()<<
", top node name#"<<fTopNode->GetName()<<endl;
 
   78       cout<<
"========================================================================="<<endl;
 
   94   static std::list<TString> stackPath;
 
   96   stackPath.push_back(
name);
 
   98   if(node->GetNdaughters() > 0)
 
  100     Int_t nd = node->GetNdaughters();
 
  101     for (Int_t 
i=0; 
i<nd; 
i++) {
 
  102       TGeoNode* theNode = node->GetDaughter(
i);
 
  113       fFullPath.Remove(fFullPath.Length()-1);
 
  117   stackPath.pop_back();
 
  123   TVector3 pos1 = pos - lwh;
 
  124   TVector3 pos2 = pos + lwh;
 
  128     aLayerBound.
minX = pos1.X();
 
  129     aLayerBound.
minY = pos1.Y();
 
  130     aLayerBound.
minZ = pos1.Z();
 
  131     aLayerBound.
maxX = pos2.X(); 
 
  132     aLayerBound.
maxY = pos2.Y(); 
 
  133     aLayerBound.
maxZ = pos2.Z(); 
 
  137     if(pos1.X() < aLayerBound.
minX) aLayerBound.
minX = pos1.X();
 
  138     if(pos1.Y() < aLayerBound.
minY) aLayerBound.
minY = pos1.Y();
 
  139     if(pos1.Z() < aLayerBound.
minZ) aLayerBound.
minZ = pos1.Z();
 
  140     if(pos2.X() > aLayerBound.
maxX) aLayerBound.
maxX = pos2.X(); 
 
  141     if(pos2.Y() > aLayerBound.
maxY) aLayerBound.
maxY = pos2.Y(); 
 
  142     if(pos2.Z() > aLayerBound.
maxZ) aLayerBound.
maxZ = pos2.Z(); 
 
  147   static const Double_t cGAPOFBOXANDSTRIP = 0.1;
 
  148   static const Double_t cSTRIPWIDTH = 1.; 
 
  149   static const Double_t cSTRIPTHICKNESS = 0.20;
 
  150   static const Double_t cGAPOFSTRIPS = 0.0;
 
  152   fStateTip = 
" GetStripInfo:: place strips on "; 
 
  164   for(; it != end; ++it)
 
  167     Int_t layerID = it->first;
 
  176       while( zPos < theBoundary.
maxZ)
 
  178         mStripZPos= zPos + 0.5*cSTRIPWIDTH;
 
  179         zPos += (cSTRIPWIDTH + cGAPOFSTRIPS);
 
  180         mDiffY = theBoundary.
maxY - theBoundary.
minY;
 
  181         mDiffX = theBoundary.
maxX - theBoundary.
minX;
 
  188         if(!isSucc) 
return kFALSE;
 
  195         while( xPos < theBoundary.
maxY)
 
  197           mStripXPos= xPos + 0.5*cSTRIPWIDTH;
 
  198           xPos += (cSTRIPWIDTH + cGAPOFSTRIPS);
 
  199           mStripLen = theBoundary.
maxX - theBoundary.
minX;
 
  202           Double_t dz = (cGAPOFBOXANDSTRIP + 0.5*cSTRIPTHICKNESS + 0.5);
 
  204           if(!isSucc) 
return kFALSE;
 
  209         while( xPos < theBoundary.
maxX)
 
  211           mStripXPos= xPos + 0.5*cSTRIPWIDTH;
 
  212           xPos += (cSTRIPWIDTH + cGAPOFSTRIPS);
 
  213           mStripLen = theBoundary.
maxY - theBoundary.
minY;
 
  216           Double_t dz = (cGAPOFBOXANDSTRIP + 0.5*cSTRIPTHICKNESS + 0.5);
 
  218           if(!isSucc) 
return kFALSE;
 
  226       while( xPos < theBoundary.
maxX)
 
  228         mStripXPos= xPos + 0.5*cSTRIPWIDTH;
 
  229         xPos += (cSTRIPWIDTH + cGAPOFSTRIPS);
 
  230         mStripLen = theBoundary.
maxY - theBoundary.
minY;
 
  233         Double_t dz = (cGAPOFBOXANDSTRIP + 0.5*cSTRIPTHICKNESS + 0.5);
 
  235         if(!isSucc) 
return kFALSE;
 
  240       cout<<
"layer ID #"<<layerID<<
", mod#"<<mod<<
", sec#"<<sec<<
", layer#"<<layer
 
  241         <<
", X#"<<theBoundary.
minX<<
", "<<theBoundary.
maxX 
  242         <<
", Y#"<<theBoundary.
minY<<
", "<<theBoundary.
maxY 
  243         <<
", Z#"<<theBoundary.
minZ<<
", "<<theBoundary.
maxZ<<
", "<<stripNO<<
" strips."<<endl;
 
  262     if(fFullPath.BeginsWith(
"cave_1/Mdt_1/")){
 
  264       sscanf(Name.Data(),
"MDT%is%il%ib%iw%i_%i", &iMod, &iSec, &iLayer, &iBox, &iWire, &iWire);
 
  266     else if(fFullPath.BeginsWith(
"cave_1/Mdt")){
 
  267       if(fFullPath.Contains(
"MdtBarrel")){
 
  269         sscanf(fFullPath.Data(),
"cave_1/MdtBarrel_0/MdtBarrelOct%i_%i/MdtBarrelOct%iLayer%i_%i/BP%is%il%ib%iw%i_%i/BA%i_%i/MDT%is%il%ib%iw%i_%i" 
  270             , &iSec1, &iSec, &iholder
 
  272             , &iMod, &iholder, &iholder, &iBox, &iholder, &iholder
 
  274             , &iholder, &iholder, &iholder, &iholder, &iholder, &iWire);
 
  275       }
else if(fFullPath.Contains(
"MdtEndcap")){
 
  277         sscanf(fFullPath.Data(),
"cave_1/MdtEndcap_0/MdtEndcapLayer%i_%i/BP%is%il%ib%iw%i_%i/BA%i_%i/MDT%is%il%ib%iw%i_%i" 
  279             , &iMod, &iSec, &iholder, &iholder, &iholder, &iBox
 
  281             , &iholder, &iholder, &iholder, &iholder, &iholder, &iWire);
 
  282       }
else if(fFullPath.Contains(
"MdtMF")){
 
  284         sscanf(fFullPath.Data(),
"cave_1/MdtMF_0/MdtMFLayer%i_%i/BP%is%il%ib%iw%i_%i/BA%i_%i/MDT%is%il%ib%iw%i_%i" 
  286             , &iMod, &iSec, &iholder, &iBox, &iholder, &iholder
 
  288             , &iholder, &iholder, &iholder, &iholder, &iholder, &iWire);
 
  289       }
else if(fFullPath.Contains(
"MdtForward")){
 
  291         sscanf(fFullPath.Data(),
"cave_1/MdtForward_0/MdtForwardLayer%i_%i/BP%is%il%ib%iw%i_%i/BA%i_%i/MDT%is%il%ib%iw%i_%i" 
  293             , &iMod, &iSec, &iholder, &iBox, &iholder, &iholder
 
  295             , &iholder, &iholder, &iholder, &iholder, &iholder, &iWire);
 
  297         cout<<
"PndMdtIGeometry::GetGeometryInfoV2, Unknown geometry pattern."<<endl;
 
  300     else if(fFullPath.BeginsWith(
"cave_1/Mdt")){
 
  302       sscanf(Name.Data(),
"MDT%is%il%ib%iw%i_%i", &iMod, &iSec, &iLayer, &iBox, &iWire, &iWire);
 
  304       cout<<
"PndMdtIGeometry::GetGeometryInfoV2, Unknown geometry pattern."<<endl;
 
  306     TVector3 itsPos(0,0,0);
 
  307     TGeoBBox* theShape = (TGeoBBox*)
gGeoManager->GetCurrentVolume()->GetShape();
 
  308     TVector3 itsOrigin(theShape->GetOrigin());
 
  309     gGeoManager->LocalToMaster(&itsOrigin[0], &itsPos[0]);
 
  310     TVector3 itsLWH(theShape->GetDX(), theShape->GetDY(), theShape->GetDZ());
 
  312     if( iMod == 1 ) wirelen = 2.*itsLWH.Z() ;
 
  313     else if(iMod == 2 && iLayer < 2) wirelen = 2.*itsLWH.X();
 
  314     else wirelen = 2.*itsLWH.Y();
 
  317       cout<<fFullPath<<endl;
 
  318       cout<<
"("<<iMod<<
", "<<iSec<<
", "<<iLayer<<
", "<<iBox<<
", "<<iWire<<
")"   <<itsPos<<
", "<<itsLWH<<endl;
 
  321     TGeoMatrix* matrix = 
gGeoManager->GetCurrentMatrix()->MakeClone();
 
  323     isSucc = 
AddTubeInfo(detID, itsPos, wirelen, matrix);
 
  330     fStateTip = 
"gGeoManager:: nonexisted path";
 
  331     cerr<< 
"PndMdtIGeometry::GetGeometryInfoV2, "<<
fStateTip<<endl;;
 
  339       cout <<
"PndMdtIGeometry::AddMatrix(), MDT layer ID#"<<layerID<<
" insert"<<endl;
 
  340     fMatrixMap.insert(std::pair<Int_t, TGeoMatrix*>(layerID, matrix));
 
  347     fStateTip = 
"AddTubeInfo:: detID not unique";
 
  348     cout << 
"PndMdtIGeometry::"<<
fStateTip<<
", "<<detID<<endl;;
 
  359       cout <<
"PndMdtIGeometry::AddTubeInfo(), MDT detector ID#"<<detID<<
" insert"<<endl;
 
  360     fGeoMap.insert(std::pair<Int_t, InfoType>(detID, _info));
 
  367     fStateTip = 
"AddStripInfo:: detID not unique";
 
  368     cout << 
"PndMdtIGeometry::"<<
fStateTip<<
", "<<detID<<endl;;
 
  376       cout <<
"PndMdtIGeometry::AddStripInfo(), MDT detector ID#"<<detID<<
" insert"<<endl;
 
  377     fGeoMap.insert(std::pair<Int_t, InfoType>(detID, _info));
 
  383   std::map<Int_t, InfoType>::const_iterator cit =  
fGeoMap.begin();;
 
  384   std::map<Int_t, InfoType>::const_iterator cend =  
fGeoMap.end();;
 
  387   ofs1<<
"============================================================"<<endl;
 
  388   ofs1<<
"==>Tube Placement"<<endl;
 
  389   ofs1<<
"============================================================"<<endl;
 
  390   ofs1<<
"Mod\t"<<
"Sec\t"<<
"Layer\t"<<
"Box\t"<<
"NO.\t"<<
"X\t"<<
"Y\t"<<
"Z\t"<<endl;
 
  391   for(; cit != cend; ++cit){
 
  399         <<cit->second.Position.X()<<
"\t" 
  400         <<cit->second.Position.Y()<<
"\t" 
  401         <<cit->second.Position.Z()<<
"\t"<<endl;
 
  406   ofs2<<
"============================================================"<<endl;
 
  407   ofs2<<
"==>Strip Placement"<<endl;
 
  408   ofs2<<
"============================================================"<<endl;
 
  409   ofs2<<
"Mod\t"<<
"Sec\t"<<
"Layer\t"<<
"NO.\t"<<
"X\t"<<
"Y\t"<<
"Z\t"<<endl;
 
  411   for(; cit != cend; ++cit){
 
  418         <<cit->second.Position.X()<<
"\t" 
  419         <<cit->second.Position.Y()<<
"\t" 
  420         <<cit->second.Position.Z()<<
"\t"<<endl;
 
static Short_t Box(Int_t detID)
static Bool_t isWire(Int_t detID)
static Short_t Module(Int_t detID)
void operator()(TString aStr)
static Short_t Layer(Int_t detID)
std::map< Int_t, InfoType > fGeoMap
Bool_t AddStripInfo(Int_t detID, TVector3 stripPos, Double_t stripLen, TGeoMatrix *matrix=0)
std::ostream & operator<<(std::ostream &o, const PndEventInfo &a)
static Int_t LayerID(Int_t iMod, Int_t iOct, Int_t iLayer)
TGeoManager * gGeoManager
static PndMdtIGeometry * fInstance
Bool_t AddTubeInfo(Int_t detID, const TVector3 ¢er, Double_t wirelen, TGeoMatrix *matrix)
static Int_t Identifier(Int_t iMod, Int_t iOct, Int_t iLayer, Int_t iBox, Int_t iWire)
static Short_t Sector(Int_t detID)
FullPathConverter(TString &str)
basic_ostream< char, char_traits< char > > ostream
void LoadGeometry(TGeoNode *node)
Bool_t FindSensorinPath(TString path)
static Short_t Strip(Int_t detID)
void InsertLayerInfo(Int_t layerID, const TVector3 &pos, const TVector3 &lwh)
std::pair< Int_t, LayerBoundary > LayerInfoMapValue
static Bool_t isStrip(Int_t detID)
static PndMdtIGeometry * Instance()
std::map< Int_t, LayerBoundary >::iterator LayerInfoMapIter
static Short_t Wire(Int_t detID)
std::map< Int_t, TGeoMatrix * > fMatrixMap
Bool_t AddMatrix(Int_t layerID, TGeoMatrix *matrix)
std::map< Int_t, LayerBoundary > fLayerInfoMap
Bool_t GetGeometryInfoV2(const TString &fFullPath, const TString &Name)