CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/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 //#define LOCAL_DEBUG
00013 
00014 MuonG4Numbering::MuonG4Numbering(const DDCompactView& cpv){
00015   MuonDDDConstants muonConstants(cpv);
00016   theLevelPart=muonConstants.getValue("level");
00017   theSuperPart=muonConstants.getValue("super");
00018   theBasePart=muonConstants.getValue("base");
00019   theStartCopyNo=muonConstants.getValue("xml_starts_with_copyno");
00020 
00021   // some consistency checks
00022 
00023   if (theBasePart!=1) {
00024     std::cout << "MuonDDDNumbering finds unusual base constant:"
00025          <<theBasePart<<std::endl;
00026   }
00027   if (theSuperPart<100) {
00028     std::cout << "MuonDDDNumbering finds unusual super constant:"
00029          <<theSuperPart<<std::endl;
00030   }
00031   if (theLevelPart<10*theSuperPart) {
00032     std::cout << "MuonDDDNumbering finds unusual level constant:"
00033          <<theLevelPart<<std::endl;
00034   }
00035   if ((theStartCopyNo!=0)&&(theStartCopyNo!=1)) {
00036     std::cout << "MuonDDDNumbering finds unusual start value for copy numbers:"
00037          <<theStartCopyNo<<std::endl;
00038   }
00039 
00040 #ifdef LOCAL_DEBUG
00041   std::cout << "StartCopyNo = "<<theStartCopyNo<<std::endl;
00042   std::cout << "MuonG4Numbering configured with"<<std::endl;
00043   std::cout << "Level = "<<theLevelPart<<" ";
00044   std::cout << "Super = "<<theSuperPart<<" ";
00045   std::cout << "Base = "<<theBasePart<<" ";
00046   std::cout << "StartCopyNo = "<<theStartCopyNo<<std::endl;
00047 #endif
00048 }
00049 
00050 MuonBaseNumber MuonG4Numbering::PhysicalVolumeToBaseNumber(const G4Step* aStep)
00051 {
00052 
00053   MuonBaseNumber num;
00054   const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
00055 
00056   for( int ii = 0; ii < touch->GetHistoryDepth(); ii++ ){
00057     G4VPhysicalVolume* vol = touch->GetVolume(ii);
00058     int copyno=vol->GetCopyNo();
00059 #ifdef LOCAL_DEBUG
00060     std::cout << "MuonG4Numbering: " << vol->GetName()<<" "<<copyno<<std::endl;
00061     std::cout << "Split " << copyNoRelevant(copyno);
00062 #endif
00063     if (copyNoRelevant(copyno)) {
00064       num.addBase(getCopyNoLevel(copyno),
00065                   getCopyNoSuperNo(copyno),
00066                   getCopyNoBaseNo(copyno)-theStartCopyNo);
00067 #ifdef LOCAL_DEBUG
00068       std::cout << " NoLevel " << getCopyNoLevel(copyno) << " Super " 
00069                 << getCopyNoSuperNo(copyno) << " Base " 
00070                 << getCopyNoBaseNo(copyno) << " Start " << theStartCopyNo;
00071 #endif
00072     }
00073 #ifdef LOCAL_DEBUG
00074     std::cout << std::endl;
00075 #endif
00076   }
00077 
00078   return num;
00079 }
00080 
00081 const int MuonG4Numbering::getCopyNoLevel(const int copyno){
00082   return copyno/theLevelPart;
00083 }
00084 
00085 const int MuonG4Numbering::getCopyNoSuperNo(const int copyno){
00086   return (copyno%theLevelPart)/theSuperPart;
00087 }
00088 
00089 const int MuonG4Numbering::getCopyNoBaseNo(const int copyno){
00090   return copyno%theSuperPart;
00091 }
00092 
00093 const bool MuonG4Numbering::copyNoRelevant(const int copyno){
00094   return (copyno/theLevelPart)>0;
00095 }
00096