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[ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/parameterisation/include/G4VFastSimSensitiveDetector.hh (Version 11.3.0) and /processes/parameterisation/include/G4VFastSimSensitiveDetector.hh (Version 11.1.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26                                                    26 
 27 #ifndef G4VFASTSIMSENSITIVEDETECTOR_HH             27 #ifndef G4VFASTSIMSENSITIVEDETECTOR_HH
 28 #define G4VFASTSIMSENSITIVEDETECTOR_HH             28 #define G4VFASTSIMSENSITIVEDETECTOR_HH
 29                                                    29 
 30 #include "G4FastHit.hh"                        << 
 31 #include "G4FastTrack.hh"                      << 
 32 #include "G4TouchableHistory.hh"               << 
 33 #include "G4VReadOutGeometry.hh"                   30 #include "G4VReadOutGeometry.hh"
                                                   >>  31 #include "G4TouchableHistory.hh"
 34 #include "G4VSensitiveDetector.hh"                 32 #include "G4VSensitiveDetector.hh"
                                                   >>  33 #include "G4FastHit.hh"
                                                   >>  34 #include "G4FastTrack.hh"
 35                                                    35 
 36 /**                                                36 /**
 37  * @brief Base class for the sensitive detecto     37  * @brief Base class for the sensitive detector used within the fast simulation
 38  *                                                 38  *
 39  * Base class for a sensitive detector that al     39  * Base class for a sensitive detector that allows to store hits created in the
 40  * fast simulation models. It must me used in      40  * fast simulation models. It must me used in addition to inheritance from the
 41  * usual base class `G4VSensitiveDetector` for     41  * usual base class `G4VSensitiveDetector` for processing of energy deposited
 42  * in G4Step.                                      42  * in G4Step.
 43  * ProcessHits(...) method must be implemented     43  * ProcessHits(...) method must be implemented and describe how hits should be
 44  * saved in the hit collections. It is invoked     44  * saved in the hit collections. It is invoked by Hit method which is public and
 45  * can be called directly in the fast simulati     45  * can be called directly in the fast simulation model (if sensitive detector is
 46  * known to the model), or via the helper clas     46  * known to the model), or via the helper class G4FastSimHitMaker that will
 47  * locate appropriate volume and retrieve its      47  * locate appropriate volume and retrieve its sensitive detector.
 48  * An extended example extended/parameterisati     48  * An extended example extended/parameterisations/Par03 demonstrates how to use
 49  * G4VFastSimSensitiveDetector to deposit ener     49  * G4VFastSimSensitiveDetector to deposit energy from fast simulation and
 50  * compare it to the detailed simulation.          50  * compare it to the detailed simulation.
 51  *                                                 51  *
 52  */                                                52  */
 53                                                    53 
 54 class G4VFastSimSensitiveDetector                  54 class G4VFastSimSensitiveDetector
 55 {                                                  55 {
 56   public:                                      <<  56  public:
 57     virtual ~G4VFastSimSensitiveDetector() = d <<  57   virtual ~G4VFastSimSensitiveDetector() = default;
 58                                                <<  58   /// Create a hit.
 59     /// Create a hit.                          <<  59   ///
 60     ///                                        <<  60   /// It checks if G4VSensitiveDetector is also used as a base class,
 61     /// It checks if G4VSensitiveDetector is a <<  61   /// and takes into account the readout geometry, if it is defined.
 62     /// and takes into account the readout geo <<  62   /// User instruction on how to deposit energy needs to be implemented in
 63     /// User instruction on how to deposit ene <<  63   /// ProcessHits method.
 64     /// ProcessHits method.                    <<  64   /// @param[in] aHit Created hit (energy and position)
 65     /// @param[in] aHit Created hit (energy an <<  65   /// @param[in] aTrack Fast track with access to particle's track and
 66     /// @param[in] aTrack Fast track with acce <<  66   /// properties in envelope's local coordinates
 67     /// properties in envelope's local coordin <<  67   /// @param[in] aTouchable Touchable with relevant transformations
 68     /// @param[in] aTouchable Touchable with r <<  68   inline G4bool Hit(const G4FastHit* aHit, const G4FastTrack* aTrack,
 69     inline G4bool Hit(const G4FastHit* aHit, c <<  69                     G4TouchableHandle* aTouchable)
 70                       G4TouchableHandle* aTouc <<  70   {
                                                   >>  71     G4bool result                 = true;
                                                   >>  72     G4VSensitiveDetector* sensDet = dynamic_cast<G4VSensitiveDetector*>(this);
                                                   >>  73     if(sensDet == nullptr)
 71     {                                              74     {
 72       G4bool result = true;                    <<  75       G4Exception("G4VFastSimSensitiveDetector::Hit()", "InvalidSetup",
 73       auto sensDet = dynamic_cast<G4VSensitive <<  76                   FatalException,
 74       if (sensDet == nullptr) {                <<  77                   "Sensitive detector needs also to inherit also from "
 75         G4Exception("G4VFastSimSensitiveDetect <<  78                   "G4VSensitiveDetector if full "
 76                     "Sensitive detector needs  <<  79                   "simulation is used instead!");
 77                     "G4VSensitiveDetector if f <<  80     }
 78                     "simulation is used instea <<  81     if(sensDet->isActive())
 79       }                                        <<  82     {
 80       if (sensDet->isActive()) {               <<  83       G4VReadOutGeometry* ROgeometry = sensDet->GetROgeometry();
 81         G4VReadOutGeometry* ROgeometry = sensD <<  84       G4TouchableHistory* ROhistory  = 0;
 82         G4TouchableHistory* ROhistory = nullpt << 
 83                                                    85 
 84         if (ROgeometry != nullptr) {           <<  86       if(ROgeometry)
 85           // create fake pre-step point updati <<  87       {
 86           // geometry.                         <<  88         // create fake pre-step point updating the touchable from read-out
 87           G4Step fakeStep;                     <<  89         // geometry.
 88           const G4Track* currentTrack = aTrack <<  90         G4Step fakeStep;
 89           G4StepPoint* tmpPoint = fakeStep.Get <<  91         const G4Track* currentTrack = aTrack->GetPrimaryTrack();
 90           tmpPoint->SetTouchableHandle(*aTouch <<  92         G4StepPoint* tmpPoint       = fakeStep.GetPreStepPoint();
 91           tmpPoint->SetPosition(aHit->GetPosit <<  93         tmpPoint->SetTouchableHandle(*aTouchable);
 92           tmpPoint->SetMomentumDirection(curre <<  94         tmpPoint->SetPosition(aHit->GetPosition());
 93           result = ROgeometry->CheckROVolume(& <<  95         tmpPoint->SetMomentumDirection(currentTrack->GetMomentumDirection());
 94         }                                      <<  96         result = ROgeometry->CheckROVolume(&fakeStep, ROhistory);
 95         else {                                 <<  97       } else {
 96           ROhistory = static_cast<G4TouchableH <<  98         ROhistory = static_cast<G4TouchableHistory*>((*aTouchable)());
 97         }                                      << 
 98         if (result) result = ProcessHits(aHit, << 
 99       }                                            99       }
100       else {                                   << 100       if(result)
101         result = false;                        << 101         result = ProcessHits(aHit, aTrack, ROhistory);
102       }                                        << 102     }
103       return result;                           << 103     else
                                                   >> 104     {
                                                   >> 105       result = false;
104     }                                             106     }
                                                   >> 107     return result;
                                                   >> 108   }
105                                                   109 
106   private:                                     << 110  private:
107     /// Describes how energy and position of d << 111   /// Describes how energy and position of deposits are inserted into the hits
108     /// collection. It is a private method and << 112   /// collection. It is a private method and it will be invoked by Hit() method
109     /// of the base class once the readout geo << 113   /// of the base class once the readout geometry that may be associated to the
110     /// corresponding G4VSensitiveDetector is  << 114   /// corresponding G4VSensitiveDetector is taken into account.
111     /// It needs to be implemented in the deri << 115   /// It needs to be implemented in the derived class.
112     /// @param[in] aHit Created hit (energy an << 116   /// @param[in] aHit Created hit (energy and position)
113     /// @param[in] aTrack Fast track with acce << 117   /// @param[in] aTrack Fast track with access to particle's track and
114     /// properties in envelope's local coordin << 118   /// properties in envelope's local coordinates
115     /// @param[in] aROHistory Touchable histor << 119   /// @param[in] aROHistory Touchable history with relevant transformations
116     virtual G4bool ProcessHits(const G4FastHit << 120   virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
117                                G4TouchableHist << 121                              G4TouchableHistory* aROHistory) = 0;
118 };                                                122 };
119 #endif /* G4VFASTSIMSENSITIVEDETECTOR_HH */       123 #endif /* G4VFASTSIMSENSITIVEDETECTOR_HH */
120                                                   124