Warning in <TSelectorDraw::ProcessFillObject>: Not implemented for vector<int>

ROOT Version (e.g. 6.10/08):
MacOSX 10.11.6, clang 8.0.0

I get this error when calling TTree::Draw on a member function.

Warning in <TSelectorDraw::ProcessFillObject>: Not implemented for vector<int>

The member function looks like:
std::vector<int> Charge();

I generate a dictionary using rootcint. Other members are std::vector - such as pdgID and they work no problem.

I call this as EventTree->Draw("d1.Charge() >> hnew")

The function exists and works no problem. If I load the shared library, open the file, set branch address etc etc and then GetEntry(event number) and call that function, I get back a vector with the right data. I just can’t use it in Draw.
BDSOutputROOTEventSamplerLinkDef.hh (1.5 KB)
BDSOutputROOTEventSampler.hh (2.4 KB)
BDSOutputROOTEventSampler.cc (5.1 KB)

I’ll attach the classes.

The ‘expression’ version of TTree::Draw only support function takes and return simple numerical values (i.e. not a vector).

You can work around the limitation by either using TDF or the ‘MakeProxy’ version of TTree::Draw (search for MakeProxy)

Hello! Thanks for that. TDataFrame looks really good but we’d have to change a lot for this to work. I had a look at makeproxy but the help doesn’t show something similar.

I think for now we’ll call quits on this.Thanks for the pointers!

I had a look at makeproxy but the help doesn’t show something similar.

humm … what about

// file plot.C
double plot() {
   auto v( d1->Chage() );
   bool skip = false;
   for(double d : v) {
       if (!skip) {
         skip = true;
         htemp->Fill( d );
   }
   return * v.begin();
}
EventTree->Draw("plot.C");

Many thanks for trying again but I’m afraid this doesn’t work for me. It complains about not knowing the type of the class. I’ve added the included path to the ROOT_INCLUDE_PATH environmental variable and I’ve loaded the shared library and am able to even instantiate the class no problem in the interpreter.

arning in <TTreeProxyGenerator>: The branch name "Primary." is duplicated. Only the first instance 
	will be available directly. The other instance(s) might be available via their complete name
	(including the name of their mother branche's name).
Warning in <TTreePlayer::DrawScript>: TTreeProxy does not work in interpreted mode yet. The script will be compiled.
Info in <TTreePlayer::DrawScript>: Will process tree/chain using generatedSel.h+
Info in <TMacOSXSystem::ACLiC>: creating shared library /Users/nevay/rigiditytest/./generatedSel_h.so
In file included from input_line_11:9:
././generatedSel.h:186:13: error: unknown type name 'BDSOutputROOTEventSampler'
      const BDSOutputROOTEventSampler<float>* operator->() { return obj.GetPtr(); }
            ^
././generatedSel.h:186:38: error: expected member name or ';' after declaration specifiers
      const BDSOutputROOTEventSampler<float>* operator->() { return obj.GetPtr(); }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
././generatedSel.h:837:13: error: unknown type name 'BDSOutputROOTEventSampler'
      const BDSOutputROOTEventSampler<float>* operator->() { return obj.GetPtr(); }
            ^
././generatedSel.h:837:38: error: expected member name or ';' after declaration specifiers
      const BDSOutputROOTEventSampler<float>* operator->() { return obj.GetPtr(); }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
././generatedSel.h:931:22: error: extra qualification on member '~generatedSel'
inline generatedSel::~generatedSel() {
       ~~~~~~~~~~~~~~^
././generatedSel.h:931:22: error: destructor cannot be redeclared
././generatedSel.h:886:4: note: previous declaration is here
   ~generatedSel();
   ^
././generatedSel.h:936:27: error: extra qualification on member 'Init'
inline void generatedSel::Init(TTree *tree)
            ~~~~~~~~~~~~~~^
././generatedSel.h:936:27: error: class member cannot be redeclared
././generatedSel.h:890:12: note: previous declaration is here
   void    Init(::TTree *tree);
           ^
././generatedSel.h:949:22: error: extra qualification on member 'Notify'
Bool_t generatedSel::Notify()
       ~~~~~~~~~~~~~~^
././generatedSel.h:949:22: error: class member cannot be redeclared
././generatedSel.h:891:12: note: previous declaration is here
   Bool_t  Notify();

etc

I’m not sure this would work though as I want to dynamically draw against other variables in the tree based on user input. Ie branch.x:branch.calculatedvariable where both are vectors.

Even still I still have the problem that no functions even for basic types (ie returning a double) are ignored in the dictionary generation and cannot be used by ttree draw. You can see they are only available in the compile code despite adding them to the link def - we’ve tried many iterations but no functions ever appear in the dictionary.

root [5] .class BDSOutputROOTEventSampler<float>
===========================================================================
class BDSOutputROOTEventSampler<float>
SIZE: 360 FILE: BDSOutputROOTEventSamplerDict dictionary payload LINE: 50
Base classes: --------------------------------------------------------
0x0        public TObject
List of member variables --------------------------------------------------
BDSOutputROOTEventSamplerDict dictionary payload  53 0x10       public: std::string samplerName, size = 24
string           -1   0x0        private: __compressed_pair<struct std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::__rep, allocator_type> __r_, size = 24
string           -1   0x0      private: enum std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::(anonymous at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:1296:5) __short_mask
string           -1   0x0      private: enum std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::(anonymous at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:1297:5) __long_mask
string           -1   0x0      private: enum std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::(anonymous at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:1300:5) __min_cap
string           -1   0x0      private: enum std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::(anonymous at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:1317:5) __n_words
string           -1   0x0      public: static const size_type npos
string           -1   0x0      private: enum std::__1::basic_string<char, struct std::__1::char_traits<char>, class std::__1::allocator<char> >::(anonymous at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:1805:5) __alignment
BDSOutputROOTEventSamplerDict dictionary payload  55 0x28       public: int n
BDSOutputROOTEventSamplerDict dictionary payload  56 0x30       public: std::vector<float> energy, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  57 0x48       public: std::vector<float> x, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  58 0x60       public: std::vector<float> y, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  59 0x78       public: float z
BDSOutputROOTEventSamplerDict dictionary payload  60 0x80       public: std::vector<float> xp, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  61 0x98       public: std::vector<float> yp, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  62 0xb0       public: std::vector<float> zp, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  63 0xc8       public: std::vector<float> t, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  65 0xe0       public: std::vector<float> weight, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  66 0xf8       public: std::vector<int> partID, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  67 0x110      public: std::vector<int> parentID, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  68 0x128      public: std::vector<int> trackID, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  69 0x140      public: int modelID
BDSOutputROOTEventSamplerDict dictionary payload  70 0x148      public: std::vector<int> turnNumber, size = 24
BDSOutputROOTEventSamplerDict dictionary payload  72 0x160      public: float S
BDSOutputROOTEventSamplerDict dictionary payload  99 0x0      public: static class BDSOutputROOTGeant4Data *particleTable
BDSOutputROOTEventSamplerDict dictionary payload 101 0x0      private: static atomic_TClass_ptr fgIsA, size = 8
List of member functions :---------------------------------------------------
filename     line:size busy function type and name
(compiled)     (NA):(NA) 0 public: BDSOutputROOTEventSampler();
(compiled)     (NA):(NA) 0 public: explicit BDSOutputROOTEventSampler(std::string samplerNameIn);
(compiled)     (NA):(NA) 0 public: std::vector<int> charge();
(compiled)     (NA):(NA) 0 public: std::vector<double> mass();
(compiled)     (NA):(NA) 0 public: std::vector<double> rigidity();
(compiled)     (NA):(NA) 0 public: double charge2();
(compiled)     (NA):(NA) 0 public: virtual ~BDSOutputROOTEventSampler<float>() noexcept;
(compiled)     (NA):(NA) 0 public: void SetBranchAddress(class TTree *);
(compiled)     (NA):(NA) 0 public: void Flush();
(compiled)     (NA):(NA) 0 public: static Version_t Class_Version();
(compiled)     (NA):(NA) 0 public: virtual class TClass *IsA() const;
(compiled)     (NA):(NA) 0 public: virtual void ShowMembers(class TMemberInspector &insp) const;
(compiled)     (NA):(NA) 0 public: void StreamerNVirtual(class TBuffer &ClassDef_StreamerNVirtual_b);
(compiled)     (NA):(NA) 0 public: static const char *DeclFileName();
(compiled)     (NA):(NA) 0 public: static int ImplFileLine();
(compiled)     (NA):(NA) 0 public: static const char *ImplFileName();
(compiled)     (NA):(NA) 0 public: static const char *Class_Name();
(compiled)     (NA):(NA) 0 public: static class TClass *Dictionary();
(compiled)     (NA):(NA) 0 public: static class TClass *Class();
(compiled)     (NA):(NA) 0 public: virtual void Streamer(class TBuffer &);
(compiled)     (NA):(NA) 0 public: static int DeclFileLine();

Link def:

#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link off all namespaces;
#pragma link C++ class std::vector<double>+;
#pragma link C++ class std::vector<int>+;
#pragma link C++ class BDSOutputROOTEventSampler+;
#pragma link C++ class BDSOutputROOTEventSampler<float>+;
#pragma link C++ class BDSOutputROOTEventSampler<double>+;
#pragma link C++ namespace BDSOutputROOTEventSampler<float>;
#pragma link C++ function BDSOutputROOTEventSampler<float>::charge;
#pragma link C++ function BDSOutputROOTEventSampler<double>::charge;
#pragma link C++ function BDSOutputROOTEventSampler<float>::charge2;
#pragma link C++ function BDSOutputROOTEventSampler<double>::charge2;
#pragma link C++ function mass;
#pragma link C++ function rigidity;

#endif

Any advice would be greatly appreciated! But as you say we won’t be able to use root for vectors.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.