Back to home page

EIC code displayed by LXR

 
 

    


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

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, 26/08/2021 (ivana@ipno.in2p3.fr)
0028 
0029 #include "G4AnalysisUtilities.hh"
0030 
0031 //_____________________________________________________________________________
0032 template <typename HT>
0033 inline
0034 tools::raxml_out* G4XmlRFileManager::GetHandler(
0035   const G4String& fileName, const G4String& objectName,
0036   std::string_view inFunction)
0037 {
0038 // Get buffer for reading object specified by objectName and objectType
0039 // for a file specified by fileName;
0040 // open the file if it was not yet open
0041 
0042   // Histograms and profiles are not saved per thread
0043   // and ntuple file name is already updated
0044   auto rfile = GetRFile(fileName);
0045   if ( ! rfile ) {
0046     if ( ! OpenRFile(fileName) ) return nullptr;
0047     rfile = GetRFile(fileName);
0048   }
0049 
0050   tools::raxml_out* handler = nullptr;
0051   if ( rfile ) {
0052     std::vector<tools::raxml_out>& objects = rfile->objects();
0053     std::vector<tools::raxml_out>::iterator it;
0054     for (it = objects.begin(); it!=objects.end(); ++it) {
0055       tools::raxml_out& object = *it;
0056       if ((object.cls() == HT::s_class()) && (object.name() == objectName)) {
0057         handler = &object;
0058         handler->disown();
0059         break;
0060       }
0061     }
0062   }
0063 
0064   if ( ! handler ) {
0065     G4Analysis::Warn(
0066       "Cannot get " + objectName + " in file " + fileName,
0067       fkClass, inFunction);
0068     return nullptr;
0069   }
0070 
0071   return handler;
0072 }