I tried running this macro named MyAutoFit.C on the rootfile named 6_000.root however I am getting errors related to the char variables which I could not solve. Please help me out. I am attaching the root file, the macro and the error message that I am getting.
Hi,
the error messages are correct, there are some mistakes in the code:
âinitializer string for char array is too longâ: Char_t E[2] is an array of two characters, but you are filling it with two strings. Probably you want a std::array<std::string, 2> or a std::vector<std::string> instead of a Char_t[2]
"calling a private constructor of class TChain: TChain ch = TChain("h101") constructs a TChain on the right side of the assignment and then assigns it to a new TChain (the one on the left side of the assignment), but copy-constructing TChains is not allowed. You probably want to do TChain ch("h101")
âuse of undeclare identifier âh101ââ
My guess is that you donât have any variable named h101, you maybe mean to use your chain ch there
C++ compilation errors are not the most friendly but usually all the information is there!
Cheers,
Enrico
After making the changes I am getting these errors
root [3] .L MyAutoFit.C
In file included from input_line_82:1:
/home/user/javi/calib (copy)/MyAutoFit.C:79:5: error: member reference type
âTChainâ is not a pointer; maybe you meant to use â.â?
ch->Draw(E[k],strip);
~~^~
.
/home/user/javi/calib (copy)/MyAutoFit.C:79:7: error: no matching member
function for call to âDrawâ
ch->Draw(E[k],strip);
~~^~
/home/user/root-6.06.08/include/TChain.h:87:22: note: candidate function not
viable: no known conversion from âvalue_typeâ (aka
âstd::__cxx11::basic_stringâ) to 'const char â for 1st argument
virtual Long64_t Draw(const char varexp, const char* selection, OptâŚ
^
/home/user/root-6.06.08/include/TChain.h:86:22: note: candidate function not
viable: no known conversion from âvalue_typeâ (aka
âstd::__cxx11::basic_stringâ) to 'const char â for 1st argument
virtual Long64_t Draw(const char varexp, const TCut& selection, OptâŚ
^
/home/user/root-6.06.08/include/TChain.h:88:22: note: candidate function not
viable: requires single argument âoptâ, but 2 arguments were provided
virtual void Draw(Option_t* opt) { Draw(opt, ââ, ââ, kMaxEntries, 0); }
^
well I am sorry if its too obvious but replacing -> with . doesnât do much help either.
In file included from input_line_50:1:
/home/user/javi/calib (copy)/MyAutoFit.C:79:6: error: no matching member
function for call to âDrawâ
ch.Draw(E[k],strip);
~^~
/home/user/root-6.06.08/include/TChain.h:87:22: note: candidate function not
viable: no known conversion from âvalue_typeâ (aka
âstd::__cxx11::basic_stringâ) to 'const char â for 1st argument
virtual Long64_t Draw(const char varexp, const char* selection, OptâŚ
^
/home/user/root-6.06.08/include/TChain.h:86:22: note: candidate function not
viable: no known conversion from âvalue_typeâ (aka
âstd::__cxx11::basic_stringâ) to 'const char â for 1st argument
virtual Long64_t Draw(const char varexp, const TCut& selection, OptâŚ
^
/home/user/root-6.06.08/include/TChain.h:88:22: note: candidate function not
viable: requires single argument âoptâ, but 2 arguments were provided
virtual void Draw(Option_t* opt) { Draw(opt, ââ, ââ, kMaxEntries, 0); }
^
Well it got rid of an error message!
These other error messages are saying that you are passing a std::string (std::__cxx11::basic_string is a std::string) where the function expects a const char *.
You can convert the former to the latter:
In file included from input_line_50:1:
/home/user/javi/calib (copy)/MyAutoFit.C:152:1: error: control reaches end of
non-void function [-Werror,-Wreturn-type]
}
^