Geant4-11
G4XmlRFileManager.icc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// Author: Ivana Hrivnacova, 26/08/2021 (ivana@ipno.in2p3.fr)
28
29#include "G4AnalysisUtilities.hh"
30
31//_____________________________________________________________________________
32template <typename HT>
33inline
34tools::raxml_out* G4XmlRFileManager::GetHandler(
35 const G4String& fileName, const G4String& objectName,
36 std::string_view inFunction)
37{
38// Get buffer for reading object specified by objectName and objectType
39// for a file specified by fileName;
40// open the file if it was not yet open
41
42 // Histograms and profiles are not saved per thread
43 // and ntuple file name is already updated
44 auto rfile = GetRFile(fileName);
45 if ( ! rfile ) {
46 if ( ! OpenRFile(fileName) ) return nullptr;
47 rfile = GetRFile(fileName);
48 }
49
50 tools::raxml_out* handler = nullptr;
51 if ( rfile ) {
52 std::vector<tools::raxml_out>& objects = rfile->objects();
53 std::vector<tools::raxml_out>::iterator it;
54 for (it = objects.begin(); it!=objects.end(); ++it) {
55 tools::raxml_out& object = *it;
56 if ( (object.cls().compare(HT::s_class()) == 0) &&
57 (object.name().compare(objectName) == 0) ) {
58 handler = &object;
59 handler->disown();
60 break;
61 }
62 }
63 }
64
65 if ( ! handler ) {
66 G4Analysis::Warn(
67 "Cannot get " + objectName + " in file " + fileName,
68 fkClass, inFunction);
69 return nullptr;
70 }
71
72 return handler;
73}