Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4RootPNtupleManager.icc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // Author: Ivana Hrivnacova, 04/10/2016  (ivana@ipno.in2p3.fr)
0028 
0029 using std::to_string;
0030 
0031 //_____________________________________________________________________________
0032 template <>
0033 inline G4bool G4RootPNtupleManager::FillNtupleTColumn(
0034   G4int ntupleId, G4int columnId, const std::string& value)
0035 {
0036   if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
0037     G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
0038     return false;
0039   }
0040 
0041   if ( IsVerbose(G4Analysis::kVL4) ) {
0042     Message(G4Analysis::kVL4, "fill", "pntuple T column",
0043        " ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
0044        " value " + G4Analysis::ToString(value));
0045   }
0046 
0047   // Creating ntuples on workers is triggered with the first FillColumn
0048   // or AddRow (in only columns of vector type call)
0049   CreateNtuplesIfNeeded();
0050 
0051   auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
0052   if (ntuple == nullptr) return false;
0053 
0054   auto index = columnId - fFirstNtupleColumnId;
0055   if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
0056     G4Analysis::Warn(
0057       "ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
0058       " does not exist.",
0059       fkClass, "FillNtupleTColumn");
0060     return false;
0061   }
0062 
0063   auto icolumn =  ntuple->columns()[index];
0064   auto column = dynamic_cast<tools::wroot::base_pntuple::column_string* >(icolumn);
0065   if (column == nullptr) {
0066     G4Analysis::Warn(
0067       " Column type does not match: ntupleId " + to_string(ntupleId) +
0068       " columnId " + to_string(columnId) + " value " + value,
0069       fkClass, "FillNtupleTColumn");
0070     return false;
0071   }
0072 
0073   column->fill(value);
0074 
0075   if ( IsVerbose(G4Analysis::kVL4) ) {
0076     Message(G4Analysis::kVL4, "done fill", "pntuple T column",
0077        " ntupleId " + to_string(ntupleId) +
0078        " columnId " + to_string(columnId) +
0079        " value " + value);
0080   }
0081 
0082   return true;
0083 }
0084 
0085 //_____________________________________________________________________________
0086 template <typename T>
0087 G4bool G4RootPNtupleManager::FillNtupleTColumn(
0088   G4int ntupleId, G4int columnId, const T& value)
0089 {
0090   // Creating ntuples on workers is triggered with the first FillColumn
0091   // or AddRow (in only columns of vector type call)
0092   CreateNtuplesIfNeeded();
0093 
0094   if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
0095     G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
0096     return false;
0097   }
0098 
0099   if ( IsVerbose(G4Analysis::kVL4) ) {
0100     Message(G4Analysis::kVL4, "fill", "pntuple T column",
0101        " ntupleId " + to_string(ntupleId) +
0102        " columnId " + to_string(columnId) +
0103        " value " + G4Analysis::ToString(value));
0104   }
0105 
0106   // get ntuple
0107   auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
0108   if ( ! ntuple ) return false;
0109 
0110   // get generic column
0111   auto index = columnId - fFirstNtupleColumnId;
0112   if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
0113     G4Analysis::Warn(
0114       "ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
0115       " does not exist.",
0116       fkClass, "FillNtupleTColumn");
0117     return false;
0118   }
0119   auto icolumn =  ntuple->columns()[index];
0120 
0121   // get column and check its type
0122   auto column = dynamic_cast<tools::wroot::base_pntuple::column<T>* >(icolumn);
0123   if ( ! column ) {
0124     G4Analysis::Warn(
0125       " Column type does not match: ntupleId " + to_string(ntupleId) +
0126       " columnId " + to_string(columnId) + " value " + G4Analysis::ToString(value),
0127       fkClass, "FillNtupleTColumn");
0128     return false;
0129   }
0130 
0131   column->fill(value);
0132 
0133   if ( IsVerbose(G4Analysis::kVL4) ) {
0134     Message(G4Analysis::kVL4, "done fill", "pntuple T column",
0135        " ntupleId " + to_string(ntupleId) +
0136        " columnId " + to_string(columnId) +
0137        " value " + G4Analysis::ToString(value));
0138   }
0139 
0140   return true;
0141 }
0142 
0143 //_____________________________________________________________________________
0144 template <typename T>
0145 G4bool G4RootPNtupleManager::FillNtupleTColumn(G4int columnId, const T& value) {
0146   return FillNtupleTColumn(0, columnId, value);
0147 }