I had another look at the attached script, and I’m wondering about the TChain, why it’s cloned, and filled with values. If I see this correctly, you want to use some variables from the TChain in the crossvalidation, and in addition you want to set the eventID, which is not in the tree.
The easiest way I see would be to open the TChain, connect the branches that you want to read, and just set the eventID manually:
for (Long64_t ievt = 0; ievt < nevents_sig; ievt++) {
eventID = ievt;
in this way, you avoid all complications with cloning the tree and adding a new branch to it.
I also noticed that you are reading arrays of floats. Those arrays cannot be bound to a single float
, so that’s probably why the reading crashes. What you need instead:
74 constexpr unsigned int maxLength = 100;
75 int shwrI;
76 float ergShwr[maxLength];
80 std::cout << track->SetBranchAddress("shwrI", &shwrI) << " ";
81 std::cout << track->SetBranchAddress("ergShwr", &ergShwr) << " ";
and when you read:
123 track->GetEntry(ievt);
124 uservar13 = ievt;
125 if (ievt < 10) {
126 std::cout << "shwrI: " << shwrI << ", ergShwr:";
127 for (int j = 0; j < shwrI; ++j) std::cout << ergShwr[j] << " ";
128 std::cout << "\n";
129 }
I attach a minimal example based on your macro, where only two branches are read. Using the attached macro and your input file, I manage to print the first 10 events:
shwrI: 1, ergShwr:0.229374
Evaluating MVA: Processing event... 0
shwrI: 1, ergShwr:0.0484161
shwrI: 2, ergShwr:0.235631 0.21835
shwrI: 3, ergShwr:0.620256 0.432888 0.0262622
shwrI: 7, ergShwr:1.14561 1.12485 0.170409 0.156405 0.125159 0.0469457 0.0455204
shwrI: 2, ergShwr:0.11881 0.109571
shwrI: 1, ergShwr:1.63838
shwrI: 0, ergShwr:
shwrI: 2, ergShwr:0.386776 0.0551964
shwrI: 2, ergShwr:0.0784447 0.0305489
TMVACrossValidationApplication.C (7.3 KB)