Error while filling a TH2D from TTree branch

Hi all

So I’m using a macro(attached below) to make a TH2D with x-coordinate v/s y-coordinate of tracks. I already have the X,Y track information in a separate root file TTree. Now I wrote a macro (attached below) to extract the information from the branches of the TTree and plot it as a separate histogram. However while filling the TH2D I get these errors :

In file included from input_line_27:1:
/uboone/app/users/abhat/larsoft_mydev/srcs/chris/readTTree.cpp:93:25: error: no matching member function for call to 'Fill'
        h_track_start1->Fill(b_mctrack_startX,b_mctrack_startY);
        ~~~~~~~~~~~~~~~~^~~~
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:64:13: note: candidate function not viable: no known conversion from 'TBranch *'
      to 'const char *' for 1st argument
   Int_t    Fill(const char*, Double_t) { return Fill(0);}  //MayNotUse
            ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:75:21: note: candidate function not viable: no known conversion from 'TBranch *'
      to 'Double_t' (aka 'double') for 1st argument
   virtual Int_t    Fill(Double_t x, Double_t y);
                    ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:63:13: note: candidate function not viable: requires 1 argument, but 2 were
      provided
   Int_t    Fill(Double_t); //MayNotUse
            ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:76:21: note: candidate function not viable: requires 3 arguments, but 2 were
      provided
   virtual Int_t    Fill(Double_t x, Double_t y, Double_t w);
                    ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:77:21: note: candidate function not viable: requires 3 arguments, but 2 were
      provided
   virtual Int_t    Fill(Double_t x, const char *namey, Double_t w);
                    ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:78:21: note: candidate function not viable: requires 3 arguments, but 2 were
      provided
   virtual Int_t    Fill(const char *namex, Double_t y, Double_t w);
                    ^
/grid/fermiapp/products/larsoft/root/v6_06_08/Linux64bit+2.6-2.12-e10-nu-prof/etc/../include/TH2.h:79:21: note: candidate function not viable: requires 3 arguments, but 2 were
      provided
   virtual Int_t    Fill(const char *namex, const char *namey, Double_t w);
                    ^

Any help is appreciated.

readTTree.cpp (3.1 KB)

h_track_start1->Fill(mctrack_startX, mctrack_startY);

thank you @Wile_E_Coyote

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