Hi, "E" is an array of doubles but you are filtering it as if it was a double, could that be the problem?
Otherwise, thanks to you providing reproducer and sample data I can run the macro locally: what is the expected result and what is the result you get?
Finally, what version of ROOT are you on?
Cheers,
Enrico
EDIT: the problem is definitely that you are reading "E" as a double rather than an array of doubles. What happens is that you filter only on its first value. Give me a bit of time and I’ll post a corrected version of your macro.
Hi Andre,
here’s a version of your macro that properly filters each pt value according to the corresponding E value (I assume this is what you wanted). Now you can also compile this file, for extra speed :
#include <ROOT/TDataFrame.hxx>
#include <TCanvas.h>
#include <TApplication.h>
using namespace ROOT::Experimental;
using namespace ROOT::Experimental::VecOps;
void Analysis_EPOS_LHC()
{
TDataFrame d("Particle", "crmc_eposlhc_112108849_p_C_130000.root");
// TVec supports per-element operations (a-la numpy) and simple filtering with v[v > 3]
using doubles = TVec<double>;
auto cutPt = [](doubles &pxs, doubles &pys, doubles &Es) {
auto all_pts = sqrt(pxs * pxs + pys * pys);
auto good_pts = all_pts[Es > 200.];
return good_pts;
};
auto hpt = d.Define("pt", cutPt, {"px", "py", "E"}).Histo1D({"hpt", "p_{T} distribution", 100, 0, 15}, "pt");
// drawing
auto c1 = new TCanvas("c1", "c1", 10, 10, 700, 500);
c1->SetGrid(1, 1);
c1->SetLogx(0); // 0 == scale without Log, 1 == scale with Log
c1->SetLogy(1);
hpt->GetYaxis()->SetTitle("dN/dp_{T} [GeV^{-1}]");
hpt->GetXaxis()->SetTitle("p_{T} [GeV]");
hpt->DrawClone();
}
int main()
{
TApplication app("app", nullptr, nullptr);
Analysis_EPOS_LHC();
app.Run();
return 0;
}
I will investigate why we were not erroring out when you were reading E as a single double (we should at least print a warning).
#0 0x00007fae6d83907a in __GI___waitpid (pid=5022, stat_loc=stat_loc
entry=0x7ffe7f681b30, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007fae6d7b1fbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007fae6e555dce in TUnixSystem::Exec(char const*) () from /opt/root6/lib/libCore.so
#3 0x00007fae6e55668e in TUnixSystem::StackTrace() () from /opt/root6/lib/libCore.so
#4 0x00007fae68b0b39d in TCling__PrintStackTrace () from /opt/root6/lib/libCling.so
#5 0x00007fae68c10867 in TClingCallbacks::PrintStackTrace() () from /opt/root6/lib/libCling.so
#6 0x00007fae68c46ad5 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /opt/root6/lib/libCling.so
#7 0x00007fae68c465ed in cling_runtime_internal_throwIfInvalidPointer () from /opt/root6/lib/libCling.so
#8 0x00007fae6eb5a328 in ?? ()
#9 0xfffffffffffffff8 in ?? ()
#10 0x0000000000000001 in ?? ()
#11 0x00007fae68c46550 in ?? () from /opt/root6/lib/libCling.so
#12 0x00007ffe7f683f58 in ?? ()
#13 0x00007ffe7f683f70 in ?? ()
#14 0x00007fae6eb6a7e9 in ?? ()
#15 0x00007ffe7f683f58 in ?? ()
#16 0x0000000000000001 in ?? ()
#17 0x00007ffe7f683f60 in ?? ()
#18 0xfffffffffffffff8 in ?? ()
#19 0x0000000000000000 in ?? ()
terminate called after throwing an instance of 'cling::InvalidDerefException'
what(): Trying to access a pointer that points to an invalid memory address.
Hi,
I don’t understand, is that an error you get when executing my version of the macro? I can execute it correctly, but admittedly I’m on a more recent version of master than you.
Maybe can you try to compile the version I sent you? e.g. with g++ -g Analysis_EPOS_LHC.cpp $(root-config --libs --cflags); ./a.out
Yes, When I’m running the macro that you suggestion, this
error describe above.
I try compile using g++ -g Analysis_EPOS_LHC.cpp:
executable ./a.out, but I don’t work, ,
error:
*** Break *** segmentation violation
===========================================================
There was a crash (#5 0x00007fbb9750ebf4 in SigHandler(ESignals) () from /opt/root6/lib/libCore.so).
This is the entire stack trace of all threads:
===========================================================
#0 0x00007fbb9553f07a in __GI___waitpid (pid=10085, stat_loc=stat_loc
entry=0x7ffefab97b30, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007fbb954b7fbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007fbb97512dce in TUnixSystem::Exec(char const*) () from /opt/root6/lib/libCore.so
#3 0x00007fbb9751368e in TUnixSystem::StackTrace() () from /opt/root6/lib/libCore.so
#4 0x00007fbb9751728b in TUnixSystem::DispatchSignals(ESignals) () from /opt/root6/lib/libCore.so
#5 0x00007fbb9750ebf4 in SigHandler(ESignals) () from /opt/root6/lib/libCore.so
#6 0x00007fbb975171dd in sighandler(int) () from /opt/root6/lib/libCore.so
#7 <signal handler called>
#8 0x000000000044b66c in std::unique_ptr<TTreeReaderArray<double>, std::default_delete<TTreeReaderArray<double> > >::get (this=0xfffffffffffffff8) at /usr/include/c++/6/bits/unique_ptr.h:308
#9 0x000000000044a65a in std::unique_ptr<TTreeReaderArray<double>, std::default_delete<TTreeReaderArray<double> > >::operator* (this=0xfffffffffffffff8) at /usr/include/c++/6/bits/unique_ptr.h:294
#10 0x0000000000449d0a in ROOT::Internal::TDF::TColumnValue<ROOT::Experimental::VecOps::TVec<double>, true>::Get<ROOT::Experimental::VecOps::TVec<double>, 0> (this=0x62f4620) at /opt/root6/include/ROOT/TDFNodes.hxx:290
#11 0x00007fbb879f8d16 in ?? ()
#12 0x0000000000000000 in ?? ()
Maybe one way to solve this is change the version of master,
by the way, I did the upgrade recently: ROOT 6.13/01heads/master@v6-11-02-2018-g01472a0, Mar 09 2018
To be forgiven for my incoherent set of commits, I distilled from this thread a new pair of tutorials, simple enough to be understood immediately but sophisticated enough to show the advantages of TVec and TDataFrame: https://github.com/root-project/root/pull/1795