G4VReadOutGeometry.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #include "G4VReadOutGeometry.hh"
00031 #include "G4Navigator.hh"
00032 
00033 
00034 G4VReadOutGeometry::G4VReadOutGeometry()
00035   :ROworld(0),fincludeList(0),
00036    fexcludeList(0),touchableHistory(0)
00037 {
00038   name = "unknown";
00039   ROnavigator = new G4Navigator();
00040 }
00041 
00042 G4VReadOutGeometry::G4VReadOutGeometry(const G4VReadOutGeometry &right)
00043 {
00044   fincludeList = 0;
00045   fexcludeList = 0;
00046   name = right.name;
00047   ROworld = right.ROworld;
00048   touchableHistory = 0;
00049   ROnavigator = new G4Navigator();
00050   // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory
00051   // VALUE, same for navigator and same for the World+Geom hierachy
00052 }
00053 
00054 G4VReadOutGeometry::G4VReadOutGeometry(G4String n) 
00055   :ROworld(0),fincludeList(0),
00056    fexcludeList(0),name(n),touchableHistory(0)
00057 {
00058   ROnavigator = new G4Navigator();
00059 }
00060 
00061 G4VReadOutGeometry::~G4VReadOutGeometry()
00062 { 
00063   //if(ROworld) delete ROworld; //should we do ? will it delete the goem tree also ?
00064   if(fincludeList)     delete fincludeList;
00065   if(fexcludeList)     delete fexcludeList;
00066   if(touchableHistory) delete touchableHistory;
00067   if(ROnavigator)      delete ROnavigator;
00068 }
00069 
00070 const G4VReadOutGeometry & G4VReadOutGeometry::operator=(const G4VReadOutGeometry &right)
00071 {
00072   delete fincludeList; fincludeList     = 0;
00073   delete fexcludeList; fexcludeList     = 0;
00074   name             = right.name;
00075   ROworld          = right.ROworld;
00076   delete touchableHistory; touchableHistory = 0;
00077   delete ROnavigator; ROnavigator = new G4Navigator();
00078   return *this;
00079 }
00080 
00081 G4int G4VReadOutGeometry::operator==(const G4VReadOutGeometry &right) const
00082 { return (this == (G4VReadOutGeometry *) &right); }
00083 
00084 G4int G4VReadOutGeometry::operator!=(const G4VReadOutGeometry &right) const
00085 { return (this != (G4VReadOutGeometry *) &right); }
00086 
00087 void G4VReadOutGeometry::BuildROGeometry()
00088 {
00089   ROworld = Build();
00090   ROnavigator->SetWorldVolume(ROworld);
00091 }
00092 
00093 G4bool G4VReadOutGeometry::CheckROVolume(G4Step*currentStep,G4TouchableHistory*& ROhist)
00094 {
00095   ROhist = 0;
00096   G4bool incFlg = true;
00097   G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
00098   if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
00099     { incFlg = false; }
00100   else if ((fincludeList)&&(fincludeList->CheckPV(PV)))
00101     { incFlg = true; }
00102   else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume())))
00103     { incFlg = false; }
00104   else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume())))
00105     { incFlg = true; }
00106   if(!incFlg) return false;
00107   
00108   if(ROworld)
00109     { incFlg = FindROTouchable(currentStep); }
00110   if(incFlg)
00111     { ROhist = touchableHistory; }
00112   return incFlg;
00113 }
00114 
00115 G4bool G4VReadOutGeometry::FindROTouchable(G4Step*currentStep)
00116 {
00117   // Update G4TouchableHistory object (touchableHistory)
00118   // using the parallel readout world (ROworld)
00119   // Return false in case the current Step is outside of the
00120   // sensitive volume of the readout world.
00121 
00122   // At first invokation, creates the touchable history. Note
00123   // that default value (false) of Locate method is used.
00124   //  ---------> But the default Value is TRUE <-------------------- J.A. 
00125   if(!touchableHistory)
00126     {
00127       touchableHistory = new G4TouchableHistory();
00128       ROnavigator->LocateGlobalPointAndUpdateTouchable(
00129                          currentStep->GetPreStepPoint()->GetPosition(),
00130                          currentStep->GetPreStepPoint()->GetMomentumDirection(),
00131                          touchableHistory);
00132     }
00133   else
00134     {
00135       ROnavigator->LocateGlobalPointAndUpdateTouchable(
00136                          currentStep->GetPreStepPoint()->GetPosition(),
00137                          currentStep->GetPreStepPoint()->GetMomentumDirection(),
00138                          touchableHistory,
00139                          true);
00140     }
00141   // Can the above be improved by the use of an isotropic safety
00142   // in order to avoid LocateGlobalPointAndUpdateTouchable
00143   // at each Step ?
00144   // Should require that an RO geometry is notified at the
00145   // starting of a track to avoid possible confusion looking
00146   // at the safety value only.
00147   
00148   // checks if volume is sensitive:
00149   G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume();
00150   // checks first if a physical volume exists here:
00151   if ( currentVolume )
00152     {
00153       return currentVolume->GetLogicalVolume()->
00154         GetSensitiveDetector() != 0;
00155     }
00156   // no sensitive volume found: returns false
00157   return false;
00158 }
00159 

Generated on Mon May 27 17:50:20 2013 for Geant4 by  doxygen 1.4.7