# 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:** 10\
**Page:** 2

<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:50pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/22 "2020-09-09T13:50:49Z")

</div>

Ah - you have the writing code attached. Good!

`char sig_name[n_signals][6];` is one character too short: you write `sprintf(sig_name[i],"SIG%03d",i);` into it and that’s 6 characters plus a trailing `\0` char. Does that fix it already?

---

<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:52pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/23 "2020-09-09T13:52:48Z")

</div>

Also, in the file `..._v1.cpp`, check the histogram names, e.g. `his[br_loop]=new TH1F(nm,nm,16384,0.,16384.);` is `nm` non-empty?

---

<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, 2:14pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/24 "2020-09-09T14:14:38Z")

</div>

@Axel  
Yeah. That is fixed already. It is written inside the for loop.  
and nm is defined as char nm[30];

---

<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, 2:18pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/25 "2020-09-09T14:18:08Z")

</div>

Thanks @Axel  
I have two files uploaded here.  
One is running correctly attached below:

other one which shows the above warning

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

```

is attached below:

If you try to run the two attached files one by one you could be able to understand the error and can probably suggest me something out of it.

---

<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, 3:04pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/26 "2020-09-09T15:04:36Z")

</div>

Well, I still have the same error that @couet had: missing `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 9, 2020, 3:15pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/27 "2020-09-09T15:15:00Z")

</div>

@Axel

---

<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, 3:50pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/28 "2020-09-09T15:50:11Z")

</div>

I don’t have the file called `Names.dat`, and you’re not checking whether the reading into nm succeeds, so I get garbage names. Please fix your code to verify that `infile>>nm` actually worked, e.g. `if (!infile>>nm) { printf("CANNOT READ NAME\n"); exit(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 9, 2020, 4:06pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/29 "2020-09-09T16:06:47Z")

</div>

Sorry @Axel

and I think you’re right. infile\>\>nm is not responding correctly as it is only showing histograms upto CL16E4.  
How could I resolve this part so that it shows all the histograms.

---

<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, 4:09pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/30 "2020-09-09T16:09:19Z")

</div>

That I don’t know - that’s not a ROOT question 🙂 I don’t know what those names are, where they come from, what you’re trying to do here. Maybe ask whoever provided you with Names.dat?

---

<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, 4:12pm UTC](https://root-forum.cern.ch/t/convert-data-from-a-software-to-root/41304/31 "2020-09-09T16:12:18Z")

</div>

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

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