CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CheckOverlap Class Reference

#include <CheckOverlap.h>

Inheritance diagram for CheckOverlap:
SimWatcher Observer< const BeginOfRun * >

List of all members.

Public Member Functions

 CheckOverlap (edm::ParameterSet const &p)
 ~CheckOverlap ()

Private Member Functions

void checkHierarchyLeafPVLV (G4LogicalVolume *lv, unsigned int leafDepth)
void checkPV (G4VPhysicalVolume *pv, unsigned int leafDepth)
void dumpLV (G4LogicalVolume *lv, std::string str)
G4VPhysicalVolume * getTopPV ()
void update (const BeginOfRun *run)
 This routine will be called when the appropriate signal arrives.

Private Attributes

std::vector< std::string > nodeNames
int nPoints
std::vector< G4LogicalVolume * > topLV

Detailed Description

Definition at line 19 of file CheckOverlap.h.


Constructor & Destructor Documentation

CheckOverlap::CheckOverlap ( edm::ParameterSet const &  p)

Definition at line 21 of file CheckOverlap.cc.

References edm::ParameterSet::getUntrackedParameter(), cuy::ii, nodeNames, and nPoints.

                                                   : topLV(0) {
  std::vector<std::string> defNames;
  nodeNames = p.getUntrackedParameter<std::vector<std::string> >("NodeNames", defNames);
  nPoints   = p.getUntrackedParameter<int>("Resolution", 1000);
  edm::LogInfo("G4cout") << "CheckOverlap:: initialised with " 
                         << nodeNames.size() << " Node Names and Resolution " 
                         << nPoints << " the names are:"; 
  for (unsigned int ii=0; ii<nodeNames.size(); ii++)
    edm::LogInfo("G4cout") << "CheckOverlap:: Node[" << ii << "] : " << nodeNames[ii]; 
}
CheckOverlap::~CheckOverlap ( )

Definition at line 32 of file CheckOverlap.cc.

{}

Member Function Documentation

void CheckOverlap::checkHierarchyLeafPVLV ( G4LogicalVolume *  lv,
unsigned int  leafDepth 
) [private]

Definition at line 66 of file CheckOverlap.cc.

References checkPV().

Referenced by update().

                                                                  {

  //----- Get LV daughters from list of PV daughters
  mmlvpv lvpvDaughters;
  std::set< G4LogicalVolume * > lvDaughters;
  int NoDaughters = lv->GetNoDaughters();
  while ((NoDaughters--)>0) {
    G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
    lvpvDaughters.insert(mmlvpv::value_type(pvD->GetLogicalVolume(), pvD));
    lvDaughters.insert(pvD->GetLogicalVolume());
  }
 
  std::set< G4LogicalVolume * >::const_iterator scite;
  mmlvpv::const_iterator mmcite;

  //----- Check daughters of LV
  for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
    std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);    
    //----- Check daughters PV of this LV
    for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++) 
      checkPV((*mmcite).second, leafDepth+1);
    //----- Check daughters LV
    checkHierarchyLeafPVLV(*scite, leafDepth+1);
  }
}
void CheckOverlap::checkPV ( G4VPhysicalVolume *  pv,
unsigned int  leafDepth 
) [private]

Definition at line 93 of file CheckOverlap.cc.

References dumpLV(), nPoints, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by checkHierarchyLeafPVLV().

                                                                         {

  //----- PV info
#ifndef G4V7
  std::string mother = "World";
  if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
  if (!pv->IsReplicated()) {
    G4PVPlacement* pvplace = dynamic_cast<G4PVPlacement* >(pv);
    G4bool ok = pvplace->CheckOverlaps(nPoints);
    edm::LogInfo("G4cout") << "Placed PV " << pvplace->GetName() 
                           << " Number " << pvplace->GetCopyNo() 
                           << " in mother " << mother << " at depth " 
                           << leafDepth << " Status " << ok;
    if (ok) {
      if(pv->GetRotation() == 0) {
        edm::LogInfo("G4cout") << "Translation " << pv->GetTranslation()
                               << " and with no rotation";
      } else {
        edm::LogInfo("G4cout") << "Translation " << pv->GetTranslation()
                               << " and with rotation "<< *(pv->GetRotation());
      }
      G4LogicalVolume* lv = pv->GetLogicalVolume();
      dumpLV(lv, "Self");
      if (pv->GetMotherLogical()) {
        lv = pv->GetMotherLogical();
        dumpLV (lv, "Mother");
      }
    }
  } else {
    if (pv->GetParameterisation() != 0) {
      G4PVParameterised* pvparam = dynamic_cast<G4PVParameterised* >(pv);
      G4bool ok = pvparam->CheckOverlaps(nPoints);
      edm::LogInfo("G4cout") << "Parametrized PV " << pvparam->GetName()
                             << " in mother " << mother << " at depth "
                             << leafDepth << " Status " << ok;
    }
  }
#endif
}
void CheckOverlap::dumpLV ( G4LogicalVolume *  lv,
std::string  str 
) [private]

Definition at line 138 of file CheckOverlap.cc.

Referenced by checkPV().

                                                            {
  edm::LogInfo("G4cout") << "Dump of " << str << " Logical Volume " 
                         << lv->GetName() << "  Solid: " 
                         << lv->GetSolid()->GetName() << "  Material: "
                         << lv->GetMaterial()->GetName();
  edm::LogInfo("G4cout") << *(lv->GetSolid());
}
G4VPhysicalVolume * CheckOverlap::getTopPV ( ) [private]

Definition at line 133 of file CheckOverlap.cc.

Referenced by update().

                                           {
  return G4TransportationManager::GetTransportationManager()
    ->GetNavigatorForTracking()->GetWorldVolume();
}
void CheckOverlap::update ( const BeginOfRun ) [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 34 of file CheckOverlap.cc.

References checkHierarchyLeafPVLV(), getTopPV(), i, cuy::ii, nodeNames, and topLV.

                                                {
  
  if (nodeNames.size() > 0) {
    const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
    std::vector<G4LogicalVolume *>::const_iterator lvcite;
    int i = 0;
    for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
      for (unsigned int ii=0; ii<nodeNames.size(); ii++) {
        if ((*lvcite)->GetName() == (G4String)(nodeNames[ii])) {
          topLV.push_back((*lvcite));
          break;
        }
      }
      edm::LogInfo("G4cout") << "Name of node " << (++i) << " : " 
                             << (*lvcite)->GetName();
      if (topLV.size() == nodeNames.size()) break;
    }
  } else {
    G4VPhysicalVolume * theTopPV = getTopPV();
    topLV.push_back(theTopPV->GetLogicalVolume());
  }

  if (topLV.size() == 0) {
    edm::LogInfo("G4cout") << "No Top LV Found";
  } else {
    for (unsigned int ii=0; ii<topLV.size(); ii++) {
      edm::LogInfo("G4cout") << "Top LV Name " << topLV[ii]->GetName();
      checkHierarchyLeafPVLV(topLV[ii], 0);
    }
  }
}

Member Data Documentation

std::vector<std::string> CheckOverlap::nodeNames [private]

Definition at line 37 of file CheckOverlap.h.

Referenced by CheckOverlap(), and update().

int CheckOverlap::nPoints [private]

Definition at line 38 of file CheckOverlap.h.

Referenced by CheckOverlap(), and checkPV().

std::vector<G4LogicalVolume*> CheckOverlap::topLV [private]

Definition at line 39 of file CheckOverlap.h.

Referenced by update().