ROOT/Jason erro

When I run my code on Mac I receive this erro:


[/usr/lib/system/libdyld.dylib] start (no debug info)
Error in : Trying to access a pointer that points to an invalid memory address…
Execution of your code was aborted.
In module ‘ROOTEve’:
/usr/local/Cellar/root/6.24.06_2/include/root/nlohmann/json.hpp:15497:103: warning: invalid memory pointer passed to a callee:
…== nullptr ? ‘\0’ : std::char_traits::to_char_type(* (loc->thousands_sep)))
^~~~~~~~~~~~~~~~~~~~
root [1]


I believe the last lines from Writer_SF.C had some kind of problem.


#include “TBufferJSON.h”
#include <string.h>
#include
#include
#include
#include
#include

//#include “Math/LorentzVector.h”
#include “TMath.h”
#include “TVector2.h”
#include “TTree.h”
#include “TLorentzVector.h”
#include “TFile.h”
#include “TEfficiency.h”
#include “TH2F.h”
#include “TObject.h”
#include “TObjArray.h”

#include “Utils.h”

#include “json.hpp”
using json = nlohmann::json;

void Writer_SF() {

TFile *f = new TFile("JetPrefiringMapsperIOV_EOY.root","READ");
TH2F* h_sf = (TH2F*) f->Get("L1prefiring_jetpt_2016BCD");
//L1prefiring_jetpt_2016BCD->FillRandom("gaus",10000);

//TString json = TBufferJSON::ToJSON(L1prefiring_jetpt_2016BCD);

//Criando a ESTRUTURA do JSON
json jsin;

double ratio = 0;
double err = 0;
double bin_x_low = 0;
double bin_x_up = 0;
double bin_y_low = 0;
double bin_y_up = 0;

// TH2F* h_sf = (TH2F*) L1prefiring_jetpt_2016BCD->Clone();
//TString json = TBufferJSON::ToJSON(L1prefiring_jetpt_2016BCD);
for (int i =1; i < h_sf->GetNbinsX()+1; i++){
for (int j =1; j < h_sf->GetNbinsY()+1; j++){
ratio = h_sf->GetBinContent(i,j);
err = h_sf->GetBinError(i,j);
bin_x_low = h_sf->GetXaxis()->GetBinLowEdge(i);
bin_y_low = h_sf->GetYaxis()->GetBinLowEdge(j);
bin_x_up = h_sf->GetXaxis()->GetBinUpEdge(i);
bin_y_up = h_sf->GetYaxis()->GetBinUpEdge(j);
//std::cout<<“Devemos no intervalo de Lep0_pt: “<<bin_x_low<<”-”<<bin_x_up<<" e Lep1_pt: “<<bin_y_low<<”-"<<bin_y_up<<endl;
jsin[“DoubleEl”].push_back( {{“lep0_pt_min”,bin_x_low},{“lep0_pt_max”,bin_x_up},{“lep1_pt_min”,bin_y_low},{“lep1_pt_max”,bin_y_up},{“SF”,ratio},{“SF_err”,err}} );
}
}

std::cout << jsin.dump(4) << '\n';
std::ofstream file("output/JetPrefiringMapsperIOV_EOY_2.root");
file << jsin.dump(4);

}

Hi and welcome to forum,

Where you get “json.hpp” include?
ROOT uses nlohmann/json internally.

You should exactly the same version, which is provided in builtins/nlohmann directory.

Or install that package system-wide and compile ROOT again - normally ROOT should find and recognize it.

Regards,
Sergey

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