Home | News | Documentation | Download

Convert data from a software to root

Hi !
I got a script which converts the data in a rarely popular software to root format. But there is some kind of mistakes in this script and I am getting error while converting into root format.
Could you please help me in correcting the error?
Candle2root_drawAll.C (858 Bytes) Candle2root_v1.cpp (7.5 KB)
and one more file is remaining which I am unable to upload here. Is there any other way to share it?

Also when I am running the following command I am getting the error as follows:

g++ -Wall -std=c++11 -o candle2root candle2root_v1.cpp `root-config --cflags --glibs` -lSpectrum

candle2root_v1.cpp: In function ‘void expand(datapackptr, datapackptr)’:
candle2root_v1.cpp:255:11: warning: variable ‘dstart’ set but not used [-Wunused-but-set-variable]
 int16ptr  dstart,wrtptr,rdptr,patptr;
           ^~~~~~

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


It seems that’s more C++ issues than ROOT ones.

Ok @couet
I am trying to convert the .001 file into root format. But I don’t know how to do this. Could you please look at the above script so that you could suggest me something out of it. I am looking and thinking for it for the last 4 days but unable to get anything.
Even I try to ask from my colleagues but didn’t got anything.
If possible, Can you please help me.
One more thing is if you need .001 file (because I am unable to share it here) You can suggest me alternatives to share it with you.

Yes we would need the data file. Why does it refuses to be uploaded here ? may be change its name extension or use some external file system repo from where we can download.

@couet

Processing Candle2root_drawAll.C...
Error in <TFile::Init>: IITR_Eu152_10Jul16_2.001.root not a ROOT file

@couet
Yes the file that I attached is not in the root format. But I want to convert into root for which I have the scripts.
Could you please run the other file.
(attached above)

root [0] 
Processing Candle2root_v1.cpp...
In file included from input_line_12:1:
/Users/couet/Downloads/Candle2root_v1.cpp:21:10: fatal error: 'COMMON.h' file not found
#include "COMMON.h"
         ^~~~~~~~~~

Sorry @couet
I forgot to give you

It is ok for me:

% g++ -Wall -std=c++11 -o candle2root candle2root_v1.cpp `root-config --cflags --glibs` -lSpectrum

% ./candle2root IITR_Eu152_10Jul16_2.001                                                          

-------BEGIN READING FILE IITR_Eu152_10Jul16_2.001.root ---------------

--- USER BLOCK BEGIN ---
Single Fold Data 215 216 Francium
IIT Roorkee
57 MeV 11B on 208Pb
--- USER BLOCK END ---

--- NAMES BLOCK BEGIN ---
READ 88
CONTROL 10

....

I am on Mac with ROOT 6.23/01

@couet
Thanks for helping me.
But when I am running another file then it is not showing all the spectrum in TBrowser. The files are

I am getting the following warning of memory leak. Could you please help me in resolving this issue?
I have seen post similar to this warning but the problem still persists.

It is because you are using the same name several time to name your histograms.

@couet
I am not sure.
Could you please run this file once?
Because what is happening in TBrowser it is showing only upto CL16_E4 histogram but the .001 file contains upto CL24_E4 and also other files.
May be due to the memory leakage error at CL16_E4, it is not showing all the histograms in the TBrowser.

I also get:

Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).
Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).
Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).
Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).
Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).
Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).

and you file contains:

% rootls Eu_26Dec.001.root -l
TH1F   Sep 09 11:30 2020            ""
TTree  Sep 09 11:30 2020 CandleData  "All data from Candle"
TTree  Sep 09 11:30 2020 CandleData  "All data from Candle"

one unnamed histgram and 2 trees.

@couet
When I run the following root file.
root -l Eu_26Dec.001.root
root [0]
Attaching file Eu_26Dec.001.root as _file0…
(TFile *) 0x55fb4f324e40
root [1] new TBrowser
(TBrowser *) 0x55fb4f7c5860

The TBrowser shows

well… what you sent me give me what I said.

@couet
Well thanks so much for helping me but it contains more histograms than you are getting. I have to think about how should I get them.

Hi Robert,
The issue seems with whatever code is writing the file. You need to get that fixed; reading might not be able to recover the histograms simply because they are not in the file.
Cheers, Axel.

@Axel @couet
Actually the main issue is the following warning:

Warning in <TFile::Append>: Replacing existing TH1:  (Potential memory leak).

I am sure you must encounter with this warning earlier. I have working on this code for 2-3 weeks. If possible, Could you please try once?