1 #ifndef __JROOT__JTREEWRITER__
2 #define __JROOT__JTREEWRITER__
4 #pragma GCC diagnostic push
5 #pragma GCC diagnostic ignored "-Wall"
8 #pragma GCC diagnostic pop
15 #include "TRealData.h"
18 namespace JPP {
using namespace JROOT; }
34 template<
class T,
bool flat = false>
88 using TTree::GetBranch;
115 TClass* t_class = TClass::GetClass<T>();
117 if (t_class ==
nullptr) {
121 TIter next(t_class->GetListOfRealData());
122 TRealData*
data{
nullptr};
125 auto* base =
reinterpret_cast<uint8_t*
>(&object);
127 while ((
data = dynamic_cast<TRealData*>(next())) !=
nullptr) {
131 auto* member =
data->GetDataMember();
132 auto*
address =
reinterpret_cast<uint8_t*
>(base + member->GetOffset());
133 std::string type_name =
data->GetDataMember()->GetTypeName();
135 if (member->GetArrayDim() > 0) {
141 if (type_code.empty()) {
145 std::string leaf =
data->GetName();
146 leaf +=
"/" + type_code;
149 branches_.push_back(
branch);
150 offsets_ .push_back(member->GetOffset());
163 auto* base =
const_cast<uint8_t*
>(
reinterpret_cast<const uint8_t*
>(&object));
165 for (
size_t i = 0;
i < branches_.size();
i++) {
166 branches_[
i]->SetAddress(reinterpret_cast<uint8_t*>(base + offsets_[
i]));
177 #if ROOT_VERSION_CODE <= ROOT_VERSION(6,26,0)
JTreeWriter(const JTreeParameters ¶meters=JROOT::getTreeParameters< T >())
Constructor.
const TString & getBranchName() const
Get TBranch name.
std::vector< TBranch * > branches_
JTreeWriter(const JTreeParameters ¶meters)
Constructor.
Auxiliary class for default template TTree writing.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Int_t Write(const T &object)
Data object output equivalent of TTree::Fill().
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
int getCompressionLevel() const
Get compression level.
int getSplitLevel() const
Get split level.
std::vector< Long_t > offsets_
static JTreeCopyWriter< T > & getInstance()
Get reference to unique instance of this class object.
const TString & getTreeTitle() const
Get TTree title.
Interface for template TTree writing and copying.
TBranch * branch
Pointer to unique branch belonging to this TTree.
JTreeCopyWriter(const JTreeParameters &tree)
Constructor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Interface for binary input.
then fatal The output file must have the wildcard in the name
Implementation for template TTree writing and copying.
static std::string getTypeCode(const std::string &type_name)
Return the type code (used to create primitive leaves in basic Root tree branches) corresponding to t...
int getBasketSize() const
Get basket size.
Data structure for TTree parameters.
const T * address
Pointer to unique object belonging to this TTree.
virtual Int_t copy(JReader &in)=0
Copy data.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Int_t Write(const T &object)
Data object output equivalent of TTree::Fill().
static bool is_tobject_member(const char *name)
Check if name is one of TObject own data members (fBits or fUniqueID, for Root <= 6...
const TString & getTreeName() const
Get TTree name.
JTreeCopyWriter< T > & getTreeCopyWriter()
Get the TTree writer and copy for this type of object.
const TBranch * GetBranch() const
Get the pointer to the unique TBranch belonging this TTree.
virtual Int_t copy(JReader &in) override
Copy data.