Files
geant4/source/analysis/root/include/G4RootMainNtupleManager.hh
T
2020-12-04 12:30:43 +01:00

108 lines
3.9 KiB
C++

//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Class for Root main ntuple management.
//
// Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
#ifndef G4RootMainNtupleManager_h
#define G4RootMainNtupleManager_h 1
#include "G4BaseAnalysisManager.hh"
#include "G4NtupleBookingManager.hh"
#include "G4TNtupleDescription.hh"
#include "G4RootNtupleManager.hh"
#include "G4RootFileDef.hh"
#include "globals.hh"
#include <vector>
class G4RootFileManager;
class G4RootNtupleManager;
class G4NtupleBookingManager;
namespace tools {
namespace wroot {
class ntuple;
}
}
// Types alias
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
class G4RootMainNtupleManager : public G4BaseAnalysisManager
{
friend class G4RootPNtupleManager;
friend class G4RootNtupleManager;
public:
explicit G4RootMainNtupleManager(
G4RootNtupleManager* ntupleBuilder,
G4NtupleBookingManager* bookingManager,
G4bool rowWise, G4int fileNumber,
const G4AnalysisManagerState& state);
~G4RootMainNtupleManager();
protected:
// Methods to manipulate ntuples
void CreateNtuple(RootNtupleDescription* ntupleDescription, G4bool warn = true);
G4bool Merge();
G4bool Reset(G4bool deleteNtuple);
// Set/get methods
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
void SetRowWise(G4bool rowWise);
std::shared_ptr<G4RootFile> GetNtupleFile(RootNtupleDescription* ntupleDescription) const;
// Access functions
const std::vector<tools::wroot::ntuple*>& GetNtupleVector()
{ return fNtupleVector; }
unsigned int GetBasketEntries() const;
private:
// Data members
G4RootNtupleManager* fNtupleBuilder;
G4NtupleBookingManager* fBookingManager;
std::shared_ptr<G4RootFileManager> fFileManager;
G4bool fRowWise;
G4int fFileNumber;
std::vector<tools::wroot::ntuple*> fNtupleVector;
std::vector<RootNtupleDescription*> fNtupleDescriptionVector;
};
inline void G4RootMainNtupleManager::SetFileManager(
std::shared_ptr<G4RootFileManager> fileManager)
{ fFileManager = fileManager; }
inline void G4RootMainNtupleManager::SetRowWise(G4bool rowWise)
{ fRowWise = rowWise; }
inline unsigned int G4RootMainNtupleManager::GetBasketEntries() const
{ return fNtupleBuilder->GetBasketEntries(); }
#endif