Problem about "ROOT::GlobalScopePlaceHolder"

I tried to load a C++ macro inside PyROOT. String arguments are passed to a class initializer. Somthing like this:

The Macro:

class FnBKGChannelData : public TObject {
public:
  TChain  *T; // Raw data tree
  
  const char   *sc_id;    // channel id
  const char   *st_name;  // tree name
  const char   *st_title; // tree title
  ParaPulse_t  *para;     // parameters for analysising pulses
  Bool_t        bExtP;    // if calculating extended portrait or not
  Bool_t        bPSD;     // if calculating PSD or not
  ParaPSD_QR_t *para_psd; // parameters for PSD

  FnBKGChannelData( TChain *tc, const char *sid,
                    const char *name, const char *title,
                    ParaPulse_t *pq, ParaPSD_QR_t *pp,
                    Bool_t be=kTRUE, Bool_t bp=kFALSE )
    : T(tc), sc_id(sid), st_name(name), st_title(title),
      para(pq), para_psd(pp), bExtP(be), bPSD(bp)
  { };

  ClassDef(FnBKGChannelData, 1)
};

ClassImp(FnBKGChannelData)

// other processing code ...

Parameters passed in Python:

import ROOT
ROOT.gROOT.LoadMacro("fnbkg_raw_loop.cpp++g")
...
raw = ROOT.TList()
t_ch1 = ROOT.TChain("wdPulse")
t_ch1.Add("../root/DBDET-20150422-PuC-wave0.root")
raw.Add( ROOT.FnBKGChannelData( t_ch1,
        "PuC_ch1", "PuC_LS0011", "Channel data for LS0011",
        para_p, para_psd, ROOT.kTRUE, ROOT.kTRUE ) )
...

What I wanted is something like this:

...
Processing:PuC_LS0012 T[0]=wdPulse;PuC_ch2 T[1]=wdPulse;
Creating tree: PuC_LS0011 -- Channel data for LS0011
Creating tree: PuC_LS0012 -- Channel data for LS0012
...

But, the first FnBKGChannelData object cannot be created correctly. What I got is:

...
Processing data: PuC ...
Processing:PuC_LS0012 T[0]=wdPulse;PuC_ch2 T[1]=wdPulse;
Creating tree: �*� -- ROOT::GlobalScopePlaceHolder
Creating tree: PuC_LS0012 -- Channel data for LS0012
...

Where the “ROOT::GlobalScopePlaceHolder” has been generated?

Hi,

there could be an ownership issue with the C strings in your class.
Is the memory associated to the const char* correctly allocated when you use the class instance? If not you could use std::strings to store the actual string in the object.

Cheers,
Danilo

Thanks!

I tried “TString” instead of “const char*”. It seems to work now. Still feel a little wired. :slight_smile:

[quote=“dpiparo”]Hi,

there could be an ownership issue with the C strings in your class.
Is the memory associated to the const char* correctly allocated when you use the class instance? If not you could use std::strings to store the actual string in the object.

Cheers,
Danilo[/quote]