Hello everyone,
Now I write a program that can select some signal to fill histogarm, TH1, TH2, and TH3, but this program can’t normally work when TH3 is filled. TH1 and TH2 are filled successfully, but when TH3 is filled, an error will be reported. I add some input message to confirm my viewpoint.
I will show a part of code and the error sended from runing program in the below of help post. You can see completed code and a simple data file in Github
_ROOT Version:6.28/06
_Platform:WSL2 Ubuntu22.04
_Compiler:g++
// tips
// typedef TH1F YTH1;
// typedef TH2F YTH2;
// typedef TH3I YTH3;
bool YMatrix::CreateHistogram(YTH1 *phistogram, const TString &pshname)
{
phistogram = new YTH1(("h1" + pshname).Data(), (pshname + "_projection").Data(), EBINNUMBER, EMIN, EMAX);
if (phistogram != nullptr)
{
cout << "Create h1: " << phistogram << "\t" << phistogram->GetName() << endl;
phistogram->Fill(0.0);
return true;
}
else
{
cerr << "Can't create " << phistogram->Class_Name() << "named " << pshname << " histogram!" << endl;
return false;
}
}
bool YMatrix::CreateHistogram(YTH2 *phistogram, const TString &pshname)
{
phistogram = new YTH2(("h2" + pshname).Data(), (pshname + "_2matrix").Data(), EBINNUMBER, EMIN, EMAX, EBINNUMBER, EMIN, EMAX);
if (phistogram != nullptr)
{
cout << "Create h2: " << phistogram << "\t" << phistogram->GetName() << endl;
phistogram->Fill(0.0, 0.0);
return true;
}
else
{
cerr << "Can't create " << phistogram->Class_Name() << "named " << pshname << " histogram!" << endl;
return false;
}
}
bool YMatrix::CreateHistogram(YTH3 *phistogram, const TString &pshname)
{
phistogram = new YTH3(("h3" + pshname).Data(), (pshname + "_3matrix").Data(), EBINNUMBER, EMIN, EMAX, EBINNUMBER, EMIN, EMAX, EBINNUMBER, EMIN, EMAX);
if (phistogram != nullptr)
{
cout << "Create h3: " << phistogram << "\t" << phistogram->GetName() << endl;
phistogram->Fill(0.0, 0.0, 0.0);
return true;
}
else
{
cerr << "Can't create " << phistogram->Class_Name() << "named " << pshname << " histogram!" << endl;
return false;
}
}
Process file from begining file to end file!
run file number from 1081 to 1081
Read file: /mnt/g/GC_event/event_hit_W1000_1081_addback_doppler.root
Output file: /mnt/g/GC_matrix/matrix_2PAM_2PM_3PAM_1081_1081_CSIW40_GECSIWminus70_200_GEW70_AMWminus150_minus100_100_150.root:/
Create h1: 0x558f8a272630 h1alpha0_proton0_total4PAM
Create h1: 0x558f8b4cd120 h1alpha0_proton0_total4AM
Create h1: 0x558f8b521cb0 h1alpha0_proton0_total4PM
Create h2: 0x558f8b69a3a0 h2alpha0_proton0_total4PAM
Create h2: 0x558f8b3ef330 h2alpha0_proton0_total4AM
Create h2: 0x558f8b6a0030 h2alpha0_proton0_total4PM
Create h3: 0x558f8b528710 h3alpha0_proton0_total4PAM
*** Break *** segmentation violation
Generating stack trace...
0x0000558f87cd2e8d in YMatrix::CreateHistogram(TH3I*, TString const&) + 0x19d from ./YMATRIX
0x0000558f87cd3d23 in YMatrix::CreateHistogram() + 0xcc3 from ./YMATRIX
0x0000558f87cd9a41 in YMatrix::Init() + 0x5a1 from ./YMATRIX
0x0000558f87cd9ccc in YMatrix::Process() + 0x2c from ./YMATRIX
0x0000558f87cd1d40 in main + 0x110 from ./YMATRIX
0x00007fbb7b718d90 in <unknown> from /lib/x86_64-linux-gnu/libc.so.6
0x00007fbb7b718e40 in __libc_start_main + 0x80 from /lib/x86_64-linux-gnu/libc.so.6
0x0000558f87cd1e95 in _start + 0x25 from ./YMATRIX
Best Regard
Mala