00001 #include "SimG4CMS/Muon/interface/MuonGemFrameRotation.h" 00002 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" 00003 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" 00004 00005 #include "G4StepPoint.hh" 00006 #include "G4TouchableHistory.hh" 00007 00008 //#define LOCAL_DEBUG 00009 00010 MuonGemFrameRotation::MuonGemFrameRotation(const DDCompactView& cpv) : MuonFrameRotation::MuonFrameRotation(cpv) { 00011 g4numbering = new MuonG4Numbering(cpv); 00012 MuonDDDConstants muonConstants(cpv); 00013 int theLevelPart= muonConstants.getValue("level"); 00014 theSectorLevel = muonConstants.getValue("mg_sector")/theLevelPart; 00015 #ifdef LOCAL_DEBUG 00016 std::cout << "MuonGemFrameRotation: theSectorLevel " << theSectorLevel 00017 << std::endl; 00018 #endif 00019 } 00020 00021 MuonGemFrameRotation::~MuonGemFrameRotation() { 00022 delete g4numbering; 00023 } 00024 00025 Local3DPoint MuonGemFrameRotation::transformPoint(const Local3DPoint & point,const G4Step * aStep=0) const { 00026 if (!aStep) return Local3DPoint(0.,0.,0.); 00027 00028 //check if it is rotated 00029 #ifdef LOCAL_DEBUG 00030 std::cout << "Position " << aStep->GetPreStepPoint()->GetPosition() << std::endl; 00031 #endif 00032 MuonBaseNumber num = g4numbering->PhysicalVolumeToBaseNumber(aStep); 00033 bool rotated = (num.getBaseNo(theSectorLevel)>=50); 00034 #ifdef LOCAL_DEBUG 00035 std::cout << "MuonGemFrameRotation num " << num.getBaseNo(theSectorLevel) 00036 << " Rotation " << rotated << std::endl; 00037 #endif 00038 if (rotated) { 00039 return Local3DPoint(-point.x(),point.z(),point.y()); 00040 } else { 00041 return Local3DPoint(point.x(),point.z(),-point.y()); 00042 } 00043 }