# Filling histograms after a a regular time interval

**URL:** <https://root-forum.cern.ch/t/filling-histograms-after-a-a-regular-time-interval/59351>\
**Category:** Newbie\
**Created:** [May 15, 2024, 7:42pm UTC](https://root-forum.cern.ch/t/filling-histograms-after-a-a-regular-time-interval/59351 "2024-05-15T19:42:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rana](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rana/32/36242_2.png) [@Rana](https://root-forum.cern.ch/u/Rana)\
**Post date:** [May 15, 2024, 7:42pm UTC](https://root-forum.cern.ch/t/filling-histograms-after-a-a-regular-time-interval/59351/1 "2024-05-15T19:42:14Z")

</div>

Hello Experts,

I wanted to know how should I fill in a 1D histogram for nhits after an interval of 1.2e9 secs. I am attaching the block of code for your ref along with the terminal result, What I am trying to do now is to get nhit distributions in each of these time intervals.

```auto
for (Long64_t iHit=0; iHit<nHits;iHit++)
		{ //##
         	   if (RecoHitPos[iHit][0] != -999) {
 
			double boundary = RecoHitPos[iHit][3];
			double t = 0.0;
			
     			   while (t < boundary || t == boundary) 
     			  
				{
				
          				t += 1.2e9;
          	
				}
				
				t_entry_count_map[t]++;
				total_entry_count++;
				
	   		}
	   		
		}//##
		
		

	} 
		
		std::cout << "Number of entries corresponding to each t value:" << std::endl;
 		for (const auto& entry : t_entry_count_map) 
 		
 		{
			cout << "t: " << entry.first << ",	Entry count: " << entry.second <<" ,	Occupancy per spill: "<<entry.second*100/19200<<"%"<< endl;
		}
  			
    }

```

![Screenshot from 2024-05-15 15-39-15](https://root-forum.cern.ch/uploads/default/original/3X/c/2/c2a64feee394c44ab6a4d924440244a7c353e77a.png) also attaching how the distribution looks like as a whole  
 ![Screenshot from 2024-05-15 15-40-28](https://root-forum.cern.ch/uploads/default/original/3X/5/0/50ba6a1a586257aa44ecb4b5807fa44c3c006934.png)

Kindly let me know hoe get the distribution.  
Best,  
R

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [May 15, 2024, 8:37pm UTC](https://root-forum.cern.ch/t/filling-histograms-after-a-a-regular-time-interval/59351/2 "2024-05-15T20:37:46Z")

</div>

Hi,

Thanks for the post.  
How can we help from the ROOT standpoint? If I understand correctly, this is not a technical question about ROOT, but more something relative to the study you are carrying out, right?

Best,  
D
