159 lines
6.0 KiB
Plaintext
159 lines
6.0 KiB
Plaintext
//
|
|
// ********************************************************************
|
|
// * License and Disclaimer *
|
|
// * *
|
|
// * The Geant4 software is copyright of the Copyright Holders of *
|
|
// * the Geant4 Collaboration. It is provided under the terms and *
|
|
// * conditions of the Geant4 Software License, included in the file *
|
|
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
|
// * include a list of copyright holders. *
|
|
// * *
|
|
// * Neither the authors of this software system, nor their employing *
|
|
// * institutes,nor the agencies providing financial support for this *
|
|
// * work make any representation or warranty, express or implied, *
|
|
// * regarding this software system or assume any liability for its *
|
|
// * use. Please see the license in the file LICENSE and URL above *
|
|
// * for the full disclaimer and the limitation of liability. *
|
|
// * *
|
|
// * This code implementation is the result of the scientific and *
|
|
// * technical work of the GEANT4 collaboration. *
|
|
// * By using, copying, modifying or distributing the software (or *
|
|
// * any work based on the software) you agree to acknowledge its *
|
|
// * use in resulting scientific publications, and indicate your *
|
|
// * acceptance of all terms of the Geant4 Software license. *
|
|
// ********************************************************************
|
|
//
|
|
|
|
// Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
|
|
|
|
//_____________________________________________________________________________
|
|
template <>
|
|
inline G4bool G4RootPNtupleManager::FillNtupleTColumn(
|
|
G4int ntupleId, G4int columnId, const std::string& value)
|
|
{
|
|
if (fCreateNtuples) {
|
|
CreateNtuplesFromMain();
|
|
}
|
|
|
|
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
|
|
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
|
|
return false;
|
|
}
|
|
|
|
#ifdef G4VERBOSE
|
|
if ( fState.GetVerboseL4() ) {
|
|
G4ExceptionDescription description;
|
|
description << " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
|
|
}
|
|
#endif
|
|
|
|
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
|
|
if ( ! ntuple ) return false;
|
|
|
|
auto index = columnId - fFirstNtupleColumnId;
|
|
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
|
|
G4ExceptionDescription description;
|
|
description << " " << "ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " does not exist.";
|
|
G4Exception("G4RootNtupleManager::FillNtupleTColumn()",
|
|
"Analysis_W011", JustWarning, description);
|
|
return false;
|
|
}
|
|
|
|
auto icolumn = ntuple->columns()[index];
|
|
auto column = dynamic_cast<tools::wroot::base_pntuple::column_string* >(icolumn);
|
|
if ( ! column ) {
|
|
G4ExceptionDescription description;
|
|
description << " Column type does not match: "
|
|
<< " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
G4Exception("G4RootNtupleManager:FillNtupleColumn",
|
|
"Analysis_W011", JustWarning, description);
|
|
return false;
|
|
}
|
|
|
|
column->fill(value);
|
|
|
|
#ifdef G4VERBOSE
|
|
if ( fState.GetVerboseL4() ) {
|
|
G4ExceptionDescription description;
|
|
description << " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
fState.GetVerboseL4()->Message("done fill", "pntuple T column", description);
|
|
}
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
template <typename T>
|
|
G4bool G4RootPNtupleManager::FillNtupleTColumn(
|
|
G4int ntupleId, G4int columnId, const T& value)
|
|
{
|
|
if (fCreateNtuples) {
|
|
CreateNtuplesFromMain();
|
|
}
|
|
|
|
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
|
|
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
|
|
return false;
|
|
}
|
|
|
|
#ifdef G4VERBOSE
|
|
if ( fState.GetVerboseL4() ) {
|
|
G4ExceptionDescription description;
|
|
description << " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
|
|
}
|
|
#endif
|
|
|
|
// get ntuple
|
|
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
|
|
if ( ! ntuple ) return false;
|
|
|
|
// get generic column
|
|
auto index = columnId - fFirstNtupleColumnId;
|
|
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
|
|
G4ExceptionDescription description;
|
|
description << " " << "ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " does not exist.";
|
|
G4Exception("G4TNtupleManager::FillNtupleTColumn()",
|
|
"Analysis_W011", JustWarning, description);
|
|
return false;
|
|
}
|
|
auto icolumn = ntuple->columns()[index];
|
|
|
|
// get column and check its type
|
|
auto column = dynamic_cast<tools::wroot::base_pntuple::column<T>* >(icolumn);
|
|
if ( ! column ) {
|
|
G4ExceptionDescription description;
|
|
description << " Column type does not match: "
|
|
<< " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
G4Exception("G4TNtupleManager:FillNtupleTColumn",
|
|
"Analysis_W011", JustWarning, description);
|
|
return false;
|
|
}
|
|
|
|
column->fill(value);
|
|
|
|
#ifdef G4VERBOSE
|
|
if ( fState.GetVerboseL4() ) {
|
|
G4ExceptionDescription description;
|
|
description << " ntupleId " << ntupleId
|
|
<< " columnId " << columnId << " value " << value;
|
|
fState.GetVerboseL4()->Message("done fill", "pntuple T column", description);
|
|
}
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
template <typename T>
|
|
G4bool G4RootPNtupleManager::FillNtupleTColumn(G4int columnId, const T& value) {
|
|
return FillNtupleTColumn(0, columnId, value);
|
|
}
|