# Get the track ids from primary mcparticles

**URL:** <https://allpix-squared-forum.web.cern.ch/t/get-the-track-ids-from-primary-mcparticles/232>\
**Category:** Uncategorized\
**Created:** [November 24, 2021, 9:56am UTC](https://allpix-squared-forum.web.cern.ch/t/get-the-track-ids-from-primary-mcparticles/232 "2021-11-24T09:56:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![asantra](https://allpix-squared-forum.web.cern.ch/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@asantra](https://allpix-squared-forum.web.cern.ch/u/asantra)\
**Post date:** [November 25, 2021, 4:23pm UTC](https://allpix-squared-forum.web.cern.ch/t/get-the-track-ids-from-primary-mcparticles/232/6 "2021-11-25T16:23:27Z")

</div>

Hi @simonspa ,  
Thank you for the tip. I tried to implement this:

A. In **MCParticle** class:

1. I have [added](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/objects/MCParticle.hpp#L157) the `track_id_` variable to the `MCParticle` class.
2. The constructor of `MCParticle` class now contains `track_id`. [This](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/objects/MCParticle.hpp#L35-42) is in the header file and [this](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/objects/MCParticle.cpp#L17-27) is in the cpp file.
3. Added a [getter](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/objects/MCParticle.hpp#L83) for `track_id` in the MCParticle class.

B. In **DepositionReader** module:

1. Opened a [map](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/modules/DepositionReader/DepositionReaderModule.cpp#L214) to store mcparticle track id.
2. [Here](https://gitlab.cern.ch/asantra/allpix-squared/-/blob/arka-dev/src/modules/DepositionReader/DepositionReaderModule.cpp#L331-335) mcparticle track\_ids are stored.

The setup is compiling and running fine. But when I get the track id from `MCParticle::getParticleTrackID`, I see garbage values. For example, this is the input track ids:

![Screen Shot 2021-11-25 at 17.52.17](https://allpix-squared-forum.web.cern.ch/uploads/default/original/1X/370f3a92717328168478a65ce9c2adfd3ed2613b.png)

and this is what I get from the processed output (x-axis is multiplied by 1e6):

 ![Screen Shot 2021-11-25 at 17.52.32](https://allpix-squared-forum.web.cern.ch/uploads/default/original/1X/555b01319e9715e63fa421db00d1b707deb5c0d5.png)

I am not sure why this is happening. Is there any other place where I am supposed to add `track_id`? I did not change anything in `DatabaseWriter` module, but my understanding is that this is not needed because I am not writing to SQL database. Any heads up will be greatly appreciated.

Thanks once again!  
Arka

---

_[View the full topic](https://allpix-squared-forum.web.cern.ch/t/get-the-track-ids-from-primary-mcparticles/232)._
