@@ -489,7 +489,7 @@ void WriteTestTree(const std::string &tname, const std::string &fname)
489489 t.Write ();
490490}
491491
492- TEST (RDFSnapshotRNTuple, FromTTree )
492+ void TestFromTTree ( bool vector2RVec = false )
493493{
494494 const auto treename = " tree" ;
495495 FileRAII fileGuard{" RDFSnapshotRNTuple_from_ttree.root" };
@@ -498,10 +498,11 @@ TEST(RDFSnapshotRNTuple, FromTTree)
498498
499499 auto df = ROOT::RDataFrame (treename, fileGuard.GetPath ());
500500
501- RSnapshotOptions opts;
502- opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
503-
504501 {
502+ RSnapshotOptions opts;
503+ opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
504+ opts.fVector2RVec = vector2RVec;
505+
505506 // FIXME(fdegeus): snapshotting leaflist branches as-is (i.e. without explicitly providing their leafs) is not
506507 // supported, because we have no way of reconstructing the memory layout of the branch itself from only the
507508 // TTree's on-disk information without JITting. For RNTuple, we would be able to do this using anonymous record
@@ -544,6 +545,34 @@ TEST(RDFSnapshotRNTuple, FromTTree)
544545
545546 auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
546547
548+ auto &descriptor = reader->GetDescriptor ();
549+
550+ int nTopLevelFields = 0 ;
551+ for (const auto &_ : descriptor.GetTopLevelFields ()) {
552+ nTopLevelFields++;
553+ }
554+ EXPECT_EQ (9 , nTopLevelFields);
555+ EXPECT_EQ (" std::int32_t" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" x" )).GetTypeName ());
556+ EXPECT_EQ (" float" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" pt" )).GetTypeName ());
557+ if (vector2RVec) {
558+ EXPECT_EQ (" ROOT::VecOps::RVec<float>" ,
559+ descriptor.GetFieldDescriptor (descriptor.FindFieldId (" photons" )).GetTypeName ());
560+ } else {
561+ EXPECT_EQ (" std::vector<float>" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" photons" )).GetTypeName ());
562+ }
563+ EXPECT_EQ (" Electron" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" electron" )).GetTypeName ());
564+ auto jetsId = descriptor.FindFieldId (" jets" );
565+ EXPECT_EQ (" Jet" , descriptor.GetFieldDescriptor (jetsId).GetTypeName ());
566+ auto electronsId = descriptor.FindFieldId (" electrons" , jetsId);
567+ EXPECT_EQ (" std::vector<Electron>" , descriptor.GetFieldDescriptor (electronsId).GetTypeName ());
568+ EXPECT_EQ (" std::int32_t" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" nmuons" )).GetTypeName ());
569+ EXPECT_EQ (" ROOT::VecOps::RVec<float>" ,
570+ descriptor.GetFieldDescriptor (descriptor.FindFieldId (" muon_pt" )).GetTypeName ());
571+ EXPECT_EQ (" std::int32_t" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" point_x" )).GetTypeName ());
572+ EXPECT_EQ (" std::int32_t" , descriptor.GetFieldDescriptor (descriptor.FindFieldId (" point_y" )).GetTypeName ());
573+ // sanity check to make sure we don't snapshot the internal RDF size columns
574+ EXPECT_EQ (ROOT::kInvalidDescriptorId , descriptor.FindFieldId (" R_rdf_sizeof_photons" ));
575+
547576 auto x = reader->GetView <int >(" x" );
548577 auto pt = reader->GetView <float >(" pt" );
549578 auto photons = reader->GetView <ROOT::RVec<float >>(" photons" );
@@ -565,6 +594,16 @@ TEST(RDFSnapshotRNTuple, FromTTree)
565594 EXPECT_EQ (2 , pointY (0 ));
566595}
567596
597+ TEST (RDFSnapshotRNTuple, FromTTree)
598+ {
599+ TestFromTTree ();
600+ }
601+
602+ TEST (RDFSnapshotRNTuple, FromTTreeNoVector2RVec)
603+ {
604+ TestFromTTree (/* vector2RVec=*/ false );
605+ }
606+
568607#ifdef R__USE_IMT
569608struct TIMTEnabler {
570609 TIMTEnabler (unsigned int nSlots) { ROOT::EnableImplicitMT (nSlots); }
0 commit comments