GFlashHitMaker.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 // $Id: GFlashHitMaker.cc 69796 2013-05-15 13:26:12Z gcosmo $
00027 //
00028 //
00029 // ------------------------------------------------------------
00030 // GEANT 4 class implementation
00031 //
00032 //      ---------------- GFlashHitMaker ----------------
00033 //
00034 // Authors: E.Barberio & Joanna Weng 
00035 // ------------------------------------------------------------
00036 
00037 #include "G4ios.hh"
00038 #include "G4TransportationManager.hh"
00039 #include "G4VSensitiveDetector.hh"
00040 #include "G4TouchableHandle.hh"
00041 #include "G4VGFlashSensitiveDetector.hh"
00042 
00043 #include "GFlashHitMaker.hh"
00044 #include "G4GFlashSpot.hh"
00045 
00046 GFlashHitMaker::GFlashHitMaker()
00047 {
00048   fTouchableHandle   = new G4TouchableHistory(); // talk to ?@@@
00049   fpNavigator        = new G4Navigator();
00050   fNaviSetup         = false;
00051 }
00052 
00053 GFlashHitMaker::~GFlashHitMaker()
00054 {
00055   delete fpNavigator;
00056 }
00057 
00058 void GFlashHitMaker::make(GFlashEnergySpot * aSpot, const G4FastTrack * aT)
00059 {
00060   // Locate the spot
00061   if (!fNaviSetup)
00062   {
00063     fpNavigator->
00064       SetWorldVolume(G4TransportationManager::GetTransportationManager()->
00065                      GetNavigatorForTracking()->GetWorldVolume() );
00066     fpNavigator->
00067       LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(),
00068                                           fTouchableHandle(), false);
00069     fNaviSetup = true;
00070   }
00071   else
00072   {
00073     fpNavigator->
00074       LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(),
00075                                           fTouchableHandle());
00076   }
00077   
00078   //--------------------------------------
00079   // Fills attribute of the G4Step needed
00080   // by our sensitive detector:
00081   //-------------------------------------
00082   // set spot information:
00083   G4GFlashSpot theSpot(aSpot, aT, fTouchableHandle);
00085   //--------------------------------------
00086   // Produce Hits
00087   // call sensitive part: taken/adapted from the stepping:
00088   // Send G4Step information to Hit/Dig if the volume is sensitive
00089   //--------------G4TouchableHistory----------------------------------------
00090   
00091   G4VPhysicalVolume* pCurrentVolume = fTouchableHandle()->GetVolume();    
00092   G4VSensitiveDetector* pSensitive;
00093   if( pCurrentVolume != 0 )
00094   {
00095     pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector();
00096     G4VGFlashSensitiveDetector * gflashSensitive = 
00097                    dynamic_cast<G4VGFlashSensitiveDetector * > (pSensitive);
00098     if( gflashSensitive )
00099     {
00100       gflashSensitive->Hit(&theSpot);
00101     }
00102     else if ( (!gflashSensitive ) && 
00103              ( pSensitive ) && 
00104              ( pCurrentVolume->GetLogicalVolume()->GetFastSimulationManager() )
00105             ) // Using gflash without implementing the 
00106               // gflashSensitive detector interface -> not allowed!
00107     
00108     {    
00109       G4cerr << "ERROR - GFlashHitMaker::make()" << G4endl
00110              << "        It is required to implement the "<< G4endl
00111              << "        G4VGFlashSensitiveDetector interface in "<< G4endl
00112              << "        addition to the usual SensitiveDetector class."
00113              << G4endl;
00114       G4Exception("GFlashHitMaker::make()", "InvalidSetup", FatalException, 
00115                   "G4VGFlashSensitiveDetector interface not implemented.");
00116     }
00117   }
00118   else
00119   {     
00120     #ifdef GFLASH_DEBUG
00121     G4cout << "GFlashHitMaker::Out of volume  "<< G4endl;
00122     #endif
00123   }
00124 }

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