Back to home page

EIC code displayed by LXR

 
 

    


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

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, 18/06/2013  (ivana@ipno.in2p3.fr)
0028 
0029 #include "G4AnalysisUtilities.hh"
0030 
0031 using std::to_string;
0032 
0033 //_____________________________________________________________________________
0034 inline void G4RootNtupleManager::SetNtupleFile(std::shared_ptr<G4RootFile> file)
0035 {
0036   fNtupleFile = std::move(file);
0037 }
0038 
0039 //_____________________________________________________________________________
0040 inline const
0041 std::vector<G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>* >&
0042 G4RootNtupleManager::GetNtupleDescriptionVector() const
0043 {
0044   return fNtupleDescriptionVector;
0045 }
0046 
0047 //_____________________________________________________________________________
0048 template <>
0049 template <>
0050 inline G4bool G4TNtupleManager<tools::wroot::ntuple, G4RootFile>::FillNtupleTColumn(
0051   G4int ntupleId, G4int columnId, const std::string& value)
0052 {
0053   if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
0054     //G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
0055     return false;
0056   }
0057 
0058   auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
0059   if (ntuple == nullptr) return false;
0060 
0061   auto index = columnId - fFirstNtupleColumnId;
0062   if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
0063     G4Analysis::Warn(
0064       "ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
0065       " does not exist.",
0066       fkClass, "FillNtupleTColumn");
0067     return false;
0068   }
0069 
0070   auto icolumn =  ntuple->columns()[index];
0071   auto column = dynamic_cast<tools::wroot::ntuple::column_string* >(icolumn);
0072   if (column == nullptr) {
0073     G4Analysis::Warn(
0074       "Column type does not match: ntupleId " + to_string(ntupleId) +
0075       " columnId " + to_string(columnId) + " value " + value,
0076       fkClass, "FillNtupleTColumn");
0077     return false;
0078   }
0079 
0080   column->fill(value);
0081 
0082   if ( IsVerbose(G4Analysis::kVL4) ) {
0083     Message(G4Analysis::kVL4, "fill", "ntuple T column",
0084        " ntupleId " + to_string(ntupleId) + " columnId " + to_string(columnId) +
0085        " value " + value);
0086   }
0087   return true;
0088 }