CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimG4CMS/Muon/src/MuonG4Numbering.cc

Go to the documentation of this file.
00001 #include "SimG4CMS/Muon/interface/MuonG4Numbering.h"
00002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00003 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 
00006 #include "G4VPhysicalVolume.hh"
00007 #include "G4VTouchable.hh"
00008 #include "G4Step.hh"
00009 
00010 #include <iostream>
00011 
00012 MuonG4Numbering::MuonG4Numbering(const DDCompactView& cpv){
00013   MuonDDDConstants muonConstants(cpv);
00014   theLevelPart=muonConstants.getValue("level");
00015   theSuperPart=muonConstants.getValue("super");
00016   theBasePart=muonConstants.getValue("base");
00017   theStartCopyNo=muonConstants.getValue("xml_starts_with_copyno");
00018 
00019   // some consistency checks
00020 
00021   if (theBasePart!=1) {
00022     std::cout << "MuonDDDNumbering finds unusual base constant:"
00023          <<theBasePart<<std::endl;
00024   }
00025   if (theSuperPart<100) {
00026     std::cout << "MuonDDDNumbering finds unusual super constant:"
00027          <<theSuperPart<<std::endl;
00028   }
00029   if (theLevelPart<10*theSuperPart) {
00030     std::cout << "MuonDDDNumbering finds unusual level constant:"
00031          <<theLevelPart<<std::endl;
00032   }
00033   if ((theStartCopyNo!=0)&&(theStartCopyNo!=1)) {
00034     std::cout << "MuonDDDNumbering finds unusual start value for copy numbers:"
00035          <<theStartCopyNo<<std::endl;
00036   }
00037 
00038   LogDebug("MuonSimDebug") << "MuonG4Numbering configured with"<<std::endl;
00039   LogDebug("MuonSimDebug") << "Level = "<<theLevelPart<<" ";
00040   LogDebug("MuonSimDebug") << "Super = "<<theSuperPart<<" ";
00041   LogDebug("MuonSimDebug") << "Base = "<<theBasePart<<" ";
00042   LogDebug("MuonSimDebug") << "StartCopyNo = "<<theStartCopyNo<<std::endl;
00043 
00044 }
00045 
00046 MuonBaseNumber MuonG4Numbering::PhysicalVolumeToBaseNumber(const G4Step* aStep)
00047 {
00048 
00049   MuonBaseNumber num;
00050   const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
00051 
00052   for( int ii = 0; ii < touch->GetHistoryDepth(); ii++ ){
00053     G4VPhysicalVolume* vol = touch->GetVolume(ii);
00054     int copyno=vol->GetCopyNo();
00055     LogDebug("MuonSimDebug") << "MuonG4Numbering: " << vol->GetName()<<" "<<copyno<<std::endl;
00056     if (copyNoRelevant(copyno)) {
00057       num.addBase(getCopyNoLevel(copyno),
00058                   getCopyNoSuperNo(copyno),
00059                   getCopyNoBaseNo(copyno)-theStartCopyNo);
00060     }
00061   }
00062 
00063   return num;
00064 }
00065 
00066 const int MuonG4Numbering::getCopyNoLevel(const int copyno){
00067   return copyno/theLevelPart;
00068 }
00069 
00070 const int MuonG4Numbering::getCopyNoSuperNo(const int copyno){
00071   return (copyno%theLevelPart)/theSuperPart;
00072 }
00073 
00074 const int MuonG4Numbering::getCopyNoBaseNo(const int copyno){
00075   return copyno%theSuperPart;
00076 }
00077 
00078 const bool MuonG4Numbering::copyNoRelevant(const int copyno){
00079   return (copyno/theLevelPart)>0;
00080 }
00081