Root / Jason erro

I’d like to compile this code on Mac, but I receive this error:

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:**

, thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
#include "TBufferJSON.h"
#include <string.h>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <set>
#include <cmath>


//#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 "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 @msoeiro,

First of all, welcome to the ROOT forum!

Regarding your post, you have not attached JetPrefiringMapsperIOV_EOY.root. Other than that, I am not able to reproduce the issue by slightly modifying your sources; could you please attach the aforementioned file?

Cheers,
J.

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