CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/SimDataFormats/ValidationFormats/src/MaterialAccountingTrack.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00004 #include "G4VPhysicalVolume.hh"
00005 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingTrack.h"
00006 
00007 void MaterialAccountingTrack::enterDetector( const G4VPhysicalVolume* volume, const GlobalPoint& position, double cosTheta ) {
00008   if (m_current_volume != 0) {
00009     // error: entering a volume while inside an other (or the same) one !
00010     if (m_current_volume != volume)
00011       std::cerr << "MaterialAccountingTrack::leaveDetector(...): ERROR: entering volume (" << volume << ") while inside volume (" << m_current_volume << ")" << std::endl;
00012     else
00013       std::cerr << "MaterialAccountingTrack::leaveDetector(...): ERROR: entering volume (" << volume << ") twice" << std::endl;
00014     m_detector.clear();
00015     return;
00016   } 
00017 
00018   m_current_volume            = volume;
00019   m_detector.m_position       = position;
00020   m_detector.m_curvilinearIn  = m_total.length();
00021   m_detector.m_cosThetaIn     = cosTheta;
00022 }
00023 
00024 void MaterialAccountingTrack::leaveDetector( const G4VPhysicalVolume* volume, double cosTheta ) {
00025   if (m_current_volume != volume) {
00026     // error: leaving the wrong (or no) volume !
00027     if (m_current_volume)
00028       std::cerr << "MaterialAccountingTrack::leaveDetector(...): ERROR: leaving volume (" << volume << ") while inside volume (" << m_current_volume << ")" << std::endl;
00029     else
00030       std::cerr << "MaterialAccountingTrack::leaveDetector(...): ERROR: leaving volume (" << volume << ") while not inside any volume" << std::endl;
00031     m_detector.clear();
00032     return;
00033   } 
00034 
00035   m_current_volume = 0;
00036   m_detector.m_curvilinearOut = m_total.length();
00037   m_detector.m_cosThetaOut    = cosTheta;
00038   m_detectors.push_back( m_detector );
00039   m_detector.clear();
00040 }