Back to home page

EIC code displayed by LXR

 
 

    


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

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 // class description:
0027 //
0028 // This class implements filling histogram
0029 // In order to avoid introducing dependency on the analysis category,
0030 // the analysis manager type is defined via template.
0031 //
0032 // Created : M. Asai (Sept. 2020)
0033 //
0034 //
0035 
0036 template <typename T>
0037 void G4TScoreHistFiller<T>::CreateAnalysisManager()
0038 {
0039   // get/create analysis manager
0040   fAnalysisManager = T::Instance();
0041 
0042   fAnalysisManager->SetVerboseLevel(fVerboseLevel);
0043 }
0044 
0045 template <typename T>
0046 G4VScoreHistFiller* G4TScoreHistFiller<T>::CreateInstance() const
0047 {
0048   auto instance = new G4TScoreHistFiller();
0049   instance->SetVerboseLevel(fVerboseLevel);
0050 
0051   return instance;
0052 }
0053 
0054 template <typename T>
0055 void G4TScoreHistFiller<T>::SetVerboseLevel(G4int value)
0056 {
0057   fVerboseLevel = value;
0058   if (fAnalysisManager) {
0059     fAnalysisManager->SetVerboseLevel(value);
0060   }
0061 }
0062 
0063 template <typename T>
0064 void G4TScoreHistFiller<T>::FillH1(G4int id, G4double value, G4double weight)
0065 {
0066   if (! fAnalysisManager) {
0067     CreateAnalysisManager();
0068   }
0069 
0070   if (! CheckH1(id)) {
0071     G4ExceptionDescription description;
0072     description << "      "
0073                 << "Cannot fill histogram id=" << id << ". Histogram is not defined.";
0074     G4Exception("G4TScoreHistFiller<T>::FillH1", "Digits_hits_utils_001", JustWarning, description);
0075 
0076     return;
0077   }
0078 
0079   fAnalysisManager->FillH1(id, value, weight);
0080 
0081 #ifdef G4VERBOSE
0082   if (fVerboseLevel > 1) {
0083     G4cout << "--- done G4TScoreHistFiller<T>::FillH1 : id = " << id << G4endl;
0084   }
0085 #endif
0086 }
0087 
0088 template <typename T>
0089 void G4TScoreHistFiller<T>::FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight)
0090 {
0091   if (! fAnalysisManager) {
0092     CreateAnalysisManager();
0093   }
0094 
0095   if (! CheckH2(id)) {
0096     G4ExceptionDescription description;
0097     description << "      "
0098                 << "Cannot fill histogram id=" << id << ". Histogram is not defined.";
0099     G4Exception("G4TScoreHistFiller<T>::FillH2", "Digits_hits_utils_001", JustWarning, description);
0100 
0101     return;
0102   }
0103 
0104   fAnalysisManager->FillH2(id, xvalue, yvalue, weight);
0105 
0106 #ifdef G4VERBOSE
0107   if (fVerboseLevel > 1) {
0108     G4cout << "--- done G4TScoreHistFiller<T>::FillH2 : id = " << id << G4endl;
0109   }
0110 #endif
0111 }
0112 
0113 template <typename T>
0114 void G4TScoreHistFiller<T>::FillH3(
0115   G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight)
0116 {
0117   if (! fAnalysisManager) {
0118     CreateAnalysisManager();
0119   }
0120 
0121   if (! CheckH3(id)) {
0122     G4ExceptionDescription description;
0123     description << "      "
0124                 << "Cannot fill histogram id=" << id << ". Histogram is not defined.";
0125     G4Exception("G4TScoreHistFiller<T>::FillH3", "Digits_hits_utils_001", JustWarning, description);
0126 
0127     return;
0128   }
0129 
0130   fAnalysisManager->FillH3(id, xvalue, yvalue, zvalue, weight);
0131 
0132 #ifdef G4VERBOSE
0133   if (fVerboseLevel > 1) {
0134     G4cout << "--- done G4TScoreHistFiller<T>::FillH3 : id = " << id << G4endl;
0135   }
0136 #endif
0137 }
0138 
0139 template <typename T>
0140 void G4TScoreHistFiller<T>::FillP1(G4int id, G4double xvalue, G4double yvalue, G4double weight)
0141 {
0142   if (! fAnalysisManager) {
0143     CreateAnalysisManager();
0144   }
0145 
0146   if (! CheckP1(id)) {
0147     G4ExceptionDescription description;
0148     description << "      "
0149                 << "Cannot fill histogram id=" << id << ". Histogram is not defined.";
0150     G4Exception("G4TScoreHistFiller<T>::FillP1", "Digits_hits_utils_001", JustWarning, description);
0151 
0152     return;
0153   }
0154 
0155   fAnalysisManager->FillP1(id, xvalue, yvalue, weight);
0156 
0157 #ifdef G4VERBOSE
0158   if (fVerboseLevel > 1) {
0159     G4cout << "--- done G4TScoreHistFiller<T>::FillP1 : id = " << id << G4endl;
0160   }
0161 #endif
0162 }
0163 
0164 template <typename T>
0165 void G4TScoreHistFiller<T>::FillP2(
0166   G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight)
0167 {
0168   if (! fAnalysisManager) {
0169     CreateAnalysisManager();
0170   }
0171 
0172   if (! CheckP2(id)) {
0173     G4ExceptionDescription description;
0174     description << "      "
0175                 << "Cannot fill histogram id=" << id << ". Histogram is not defined.";
0176     G4Exception("G4TScoreHistFiller<T>::FillP2", "Digits_hits_utils_001", JustWarning, description);
0177 
0178     return;
0179   }
0180 
0181   fAnalysisManager->FillP2(id, xvalue, yvalue, zvalue, weight);
0182 
0183 #ifdef G4VERBOSE
0184   if (fVerboseLevel > 1) {
0185     G4cout << "--- done G4TScoreHistFiller<T>::FillP2 : id = " << id << G4endl;
0186   }
0187 #endif
0188 }
0189 
0190 template <typename T>
0191 G4bool G4TScoreHistFiller<T>::CheckH1(G4int id)
0192 {
0193   return (fAnalysisManager->GetH1(id) != nullptr);
0194 }
0195 
0196 template <typename T>
0197 G4bool G4TScoreHistFiller<T>::CheckH2(G4int id)
0198 {
0199   return (fAnalysisManager->GetH2(id) != nullptr);
0200 }
0201 
0202 template <typename T>
0203 G4bool G4TScoreHistFiller<T>::CheckH3(G4int id)
0204 {
0205   return (fAnalysisManager->GetH3(id) != nullptr);
0206 }
0207 
0208 template <typename T>
0209 G4bool G4TScoreHistFiller<T>::CheckP1(G4int id)
0210 {
0211   return (fAnalysisManager->GetP1(id) != nullptr);
0212 }
0213 
0214 template <typename T>
0215 G4bool G4TScoreHistFiller<T>::CheckP2(G4int id)
0216 {
0217   return (fAnalysisManager->GetP2(id) != nullptr);
0218 }