Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 26 27 #include "G4AnalysisManagerState.hh" 27 #include "G4AnalysisManagerState.hh" 28 #include "G4AnalysisUtilities.hh" 28 #include "G4AnalysisUtilities.hh" 29 29 30 // 30 // 31 // private functions 31 // private functions 32 // 32 // 33 33 34 //____________________________________________ 34 //_____________________________________________________________________________ 35 template <typename T> 35 template <typename T> 36 G4int G4NtupleBookingManager::CreateNtupleTCol 36 G4int G4NtupleBookingManager::CreateNtupleTColumn( 37 G4int ntupleId, const G4String& name, std::v 37 G4int ntupleId, const G4String& name, std::vector<T>* vector) 38 { 38 { 39 if (! CheckName(name, "NtupleColumn")) retur 39 if (! CheckName(name, "NtupleColumn")) return G4Analysis::kInvalidId; 40 40 41 Message(G4Analysis::kVL4, "create", "ntuple 41 Message(G4Analysis::kVL4, "create", "ntuple T column", 42 " ntupleId " + std::to_string(ntupleId)); 42 " ntupleId " + std::to_string(ntupleId)); 43 43 44 auto g4NtupleBooking 44 auto g4NtupleBooking 45 = GetNtupleBookingInFunction(ntupleId, "Cr 45 = GetNtupleBookingInFunction(ntupleId, "CreateNtupleTColumn"); 46 if ( ! g4NtupleBooking ) return G4Analysis: 46 if ( ! g4NtupleBooking ) return G4Analysis::kInvalidId; 47 47 48 // Save column info in booking 48 // Save column info in booking 49 auto& ntupleBooking = g4NtupleBooking->fNtup 49 auto& ntupleBooking = g4NtupleBooking->fNtupleBooking; 50 auto index = ntupleBooking.columns().size(); 50 auto index = ntupleBooking.columns().size(); 51 if (! vector) { 51 if (! vector) { 52 ntupleBooking.template add_column<T>(name) 52 ntupleBooking.template add_column<T>(name); 53 } 53 } 54 else { 54 else { 55 ntupleBooking.template add_column<T>(name, 55 ntupleBooking.template add_column<T>(name, *vector); 56 } 56 } 57 57 58 // Create column if ntuple already exists 58 // Create column if ntuple already exists 59 // CreateTColumnInNtuple<T>(ntupleBooking, n 59 // CreateTColumnInNtuple<T>(ntupleBooking, name, vector); 60 fLockFirstNtupleColumnId = true; 60 fLockFirstNtupleColumnId = true; 61 61 62 Message(G4Analysis::kVL2, "create", "ntuple 62 Message(G4Analysis::kVL2, "create", "ntuple T column", 63 name + " ntupleId " + std::to_string(ntupl 63 name + " ntupleId " + std::to_string(ntupleId)); 64 64 65 return G4int(index + fFirstNtupleColumnId); 65 return G4int(index + fFirstNtupleColumnId); 66 } 66 } 67 67 68 //____________________________________________ 68 //_____________________________________________________________________________ 69 inline G4int G4NtupleBookingManager::GetNofNtu << 69 inline G4int G4NtupleBookingManager::GetNofNtupleBookings() const 70 { 70 { 71 return (onlyIfExist) ? G4int(fNtupleBookingV << 71 return G4int(fNtupleBookingVector.size()); 72 : G4int(fNtupleBookingV << 73 } 72 } 74 73 75 //____________________________________________ 74 //_____________________________________________________________________________ 76 inline G4int G4NtupleBookingManager::GetCurre 75 inline G4int G4NtupleBookingManager::GetCurrentNtupleId() const 77 { 76 { 78 return fCurrentNtupleId; << 77 return GetNofNtupleBookings() + fFirstId - 1; 79 } 78 } 80 79 81 // 80 // 82 // public functions 81 // public functions 83 // 82 // 84 83 85 //____________________________________________ 84 //_____________________________________________________________________________ 86 inline const std::vector<G4NtupleBooking*>& 85 inline const std::vector<G4NtupleBooking*>& 87 G4NtupleBookingManager::GetNtupleBookingVector 86 G4NtupleBookingManager::GetNtupleBookingVector() const 88 { 87 { 89 return fNtupleBookingVector; 88 return fNtupleBookingVector; 90 } 89 } 91 90 92 //____________________________________________ 91 //_____________________________________________________________________________ 93 inline G4int G4NtupleBookingManager::GetFirstN 92 inline G4int G4NtupleBookingManager::GetFirstNtupleColumnId() const { 94 return fFirstNtupleColumnId; 93 return fFirstNtupleColumnId; 95 } 94 } 96 95 97 //____________________________________________ 96 //_____________________________________________________________________________ 98 inline G4String G4NtupleBookingManager::GetFil 97 inline G4String G4NtupleBookingManager::GetFileType() const 99 { 98 { 100 return fFileType; 99 return fFileType; 101 } 100 } 102 101