Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:26

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 
0029 #ifndef G4VPrimitiveScorer_h
0030 #define G4VPrimitiveScorer_h 1
0031 
0032 class G4Step;
0033 class G4HCofThisEvent;
0034 class G4TouchableHistory;
0035 #include "G4MultiFunctionalDetector.hh"
0036 #include "G4VSDFilter.hh"
0037 #include "globals.hh"
0038 
0039 // class description:
0040 //
0041 //  This is the base class of the sensitive detector which owns
0042 // only one hits collection.
0043 //  A concrete class object derived from this base class can be
0044 // used either as a sensitive detector or to be registered to
0045 // G4MultiFunctionalDetector to define multiple functionalities.
0046 //
0047 //
0048 
0049 class G4VPrimitiveScorer
0050 {
0051   friend class G4MultiFunctionalDetector;
0052 
0053  public:
0054   G4VPrimitiveScorer(G4String name, G4int depth = 0);
0055   virtual ~G4VPrimitiveScorer() = default;
0056 
0057   // This method returns the ID of its hitsCollection. This mehod
0058   // gives valid value only after it is registered to G4MultiFunctionalDetector
0059   // and the G4MultiFunctionalDetector is registered to G4SDManager.
0060   G4int GetCollectionID(G4int);
0061 
0062   // These five methods are exactly identical to those in G4VSensitiveDetector.
0063   // These methods are invoked by G4SDManager through G4MultiFunctionalDetector.
0064   virtual void Initialize(G4HCofThisEvent*);
0065   virtual void EndOfEvent(G4HCofThisEvent*);
0066   virtual void clear();
0067   virtual void DrawAll();
0068   virtual void PrintAll();
0069 
0070   void SetUnit(const G4String& unit) { unitName = unit; }
0071   const G4String& GetUnit() const { return unitName; }
0072   G4double GetUnitValue() const { return unitValue; }
0073 
0074   // Set/Get methods
0075   inline void SetMultiFunctionalDetector(G4MultiFunctionalDetector* d) { detector = d; }
0076   inline G4MultiFunctionalDetector* GetMultiFunctionalDetector() const { return detector; }
0077   inline G4String GetName() const { return primitiveName; }
0078   inline void SetFilter(G4VSDFilter* f) { filter = f; }
0079   inline G4VSDFilter* GetFilter() const { return filter; }
0080   inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
0081   inline G4int GetVerboseLevel() const { return verboseLevel; }
0082 
0083   inline void SetNijk(G4int i, G4int j, G4int k)
0084   {
0085     fNi = i;
0086     fNj = j;
0087     fNk = k;
0088   }
0089 
0090  protected:
0091   // Get the solid at current depth, ensuring it's correct by
0092   //   calling a parameterisation is called if it's that volume type
0093   G4VSolid* ComputeSolid(G4Step* aStep, G4int replicaIdx);
0094 
0095   // Same as above -- using stored replica number
0096   G4VSolid* ComputeCurrentSolid(G4Step* aStep);
0097 
0098   // This is the method must be implemented in each concrete class.
0099   virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*) = 0;
0100 
0101   // This is a function mapping from copy number(s) to an index of
0102   // the hit collection. In the default implementation, just the
0103   // copy number of the physical volume is taken.
0104   virtual G4int GetIndex(G4Step*);
0105 
0106   void CheckAndSetUnit(const G4String& unit, const G4String& category);
0107 
0108  protected:
0109   G4String primitiveName;
0110   G4MultiFunctionalDetector* detector{nullptr};
0111   G4VSDFilter* filter{nullptr};
0112   G4int verboseLevel{0};
0113   G4int indexDepth;
0114   G4String unitName{"NoUnit"};
0115   G4double unitValue{1.0};
0116   G4int fNi{0}, fNj{0}, fNk{0};  // used for 3D scorers
0117 
0118  private:
0119   inline G4bool HitPrimitive(G4Step* aStep, G4TouchableHistory* ROhis)
0120   {
0121     if (filter != nullptr) {
0122       if (! (filter->Accept(aStep))) return false;
0123     }
0124     return ProcessHits(aStep, ROhis);
0125   }
0126 };
0127 
0128 #endif