# Convert data from a software to root

**URL:** <https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304>\
**Category:** Newbie\
**Tags:** root\
**Created:** [September 4, 2020, 11:40pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304 "2020-09-04T23:40:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 4, 2020, 11:40pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/1 "2020-09-04T23:40:48Z")

</div>

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](https://root-forum.cern.ch/uploads/short-url/935hIFy4YIaPflcbGOLdHTincwk.C) (858 Bytes) [Candle2root\_v1.cpp](https://root-forum.cern.ch/uploads/short-url/uuv0r88HzXi5zGhrH4C7ae6dbAh.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:

```auto
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

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 7, 2020, 7:33am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/2 "2020-09-07T07:33:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 7, 2020, 6:35pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/3 "2020-09-07T18:35:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 8, 2020, 7:31am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/4 "2020-09-08T07:31:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 8, 2020, 9:18am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/5 "2020-09-08T09:18:41Z")

</div>

@couet

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 8, 2020, 11:17am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/6 "2020-09-08T11:17:50Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 8, 2020, 11:37am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/7 "2020-09-08T11:37:22Z")

</div>

@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)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 8, 2020, 11:45am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/8 "2020-09-08T11:45:06Z")

</div>

```auto
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"
         ^ ~~~~~~~~~

```

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 8, 2020, 12:50pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/9 "2020-09-08T12:50:16Z")

</div>

Sorry @couet  
I forgot to give you

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 8, 2020, 2:48pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/10 "2020-09-08T14:48:38Z")

</div>

It is ok for me:

```auto
% 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

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 9, 2020, 8:52am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/12 "2020-09-09T08:52:52Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 9, 2020, 9:17am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/13 "2020-09-09T09:17:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 9, 2020, 9:23am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/14 "2020-09-09T09:23:45Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 9, 2020, 9:29am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/15 "2020-09-09T09:29:59Z")

</div>

I also get:

```auto
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).

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 9, 2020, 9:32am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/16 "2020-09-09T09:32:12Z")

</div>

and you file contains:

```auto
% 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.

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 9, 2020, 9:41am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/17 "2020-09-09T09:41:50Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 9, 2020, 11:41am UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/18 "2020-09-09T11:41:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 9, 2020, 12:50pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/19 "2020-09-09T12:50:15Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 9, 2020, 1:23pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/20 "2020-09-09T13:23:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 9, 2020, 1:27pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/21 "2020-09-09T13:27:44Z")

</div>

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

```auto
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?

[Next page](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304.md?page=2)
