Uhm a segmentation violation seems like an overreaction on the part of the script
What ROOT version are you on? Here’s what I get with v6.22:
$ python read_cols.py (cern-root)
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisEventDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisCaloTPDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisL1CaloTowerDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisBMTFInputsDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisL1UpgradeDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class GlobalAlgBlk is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisL1HODataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisL1CaloClusterDataFormat is available
TClass::Init:0: RuntimeWarning: no dictionary for class L1Analysis::L1AnalysisGeneratorDataFormat is available
Error in <TChain::LoadTree>: Cannot find tree with name l1CaloTowerTree in file ZToMuMu_mc_off_MET_PU_mit_392SF.root
Traceback (most recent call last):
File "read_cols.py", line 5, in <module>
d.GetColumnNames()
cppyy.gbl.std.runtime_error: vector<string> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::GetColumnNames() =>
runtime_error: GetBranchNames: error in opening the tree l1CaloTowerTree
So I inspected the file and indeed, like your screenshot above shows, l1CaloTowerTree
is not a TTree but a directory (with a TTree called L1CaloTowerTree
– with a capital L! – inside).
This works:
import ROOT
fileName = "ZToMuMu_mc_off_MET_PU_mit_392SF.root"
treeName = "l1CaloTowerTree/L1CaloTowerTree"
print(ROOT.RDataFrame(treeName, fileName).GetColumnNames())
and prints
{ "CaloTP.nHCALTP", "CaloTP.hcalTPieta", "CaloTP.hcalTPiphi", "CaloTP.hcalTPCaliphi", "CaloTP.hcalTPet", "CaloTP.hcalTPcompEt", "CaloTP.hcalTPfineGrain", "CaloTP.nECALTP", "C
aloTP.ecalTPieta", "CaloTP.ecalTPiphi", "CaloTP.ecalTPCaliphi", "CaloTP.ecalTPet", "CaloTP.ecalTPcompEt", "CaloTP.ecalTPfineGrain", "CaloTP", "L1CaloTower.nTower", "L1CaloTow
er.ieta", "L1CaloTower.iphi", "L1CaloTower.iet", "L1CaloTower.iem", "L1CaloTower.ihad", "L1CaloTower.iratio", "L1CaloTower.iqual", "L1CaloTower.et", "L1CaloTower.eta", "L1Cal
oTower.phi", "L1CaloTower" }
I tried to plot CaloTP.hcalTPieta
. This also works:
import ROOT
fileName = "ZToMuMu_mc_off_MET_PU_mit_392SF.root"
treeName = "l1CaloTowerTree/L1CaloTowerTree"
df = ROOT.RDataFrame(treeName, fileName)
df.Histo1D("CaloTP.hcalTPieta").Draw()
input() // to keep the process alive while the canvas is displayed
Cheers,
Enrico