Macro to count

Hello, i wrote this macro to count the counts of TH1F (I write them by other root macro in txt files)

I’ve primary 1010keV, 2228keV, 3939keV photons defined in the vector

std::vector<int> PrimGamma={1010,2228,3939};

the 1010keV has 2 secondaries: 583keV and 5400keV
the 2228 keV has 5 secondaries 74keV,583keV,1294keV,1368keV,28218keV
the 3939keV has 6 secondaries 74keV,583keV,1107keV,1294keV,1368keV,2476keV
that I defined here

std::vector<int> Sec1010={583,5400};
std::vector<int> Sec2228={74,583,1294,1368,2818};
std::vector<int> Sec3939={74,583,1107,1294,1368,2476};

For each primary photons that is detected in de first detector (PD), I must write the counts of all its secondaries in the second detector (DD) and viceversa

For each secondary, I defined a range to sum the counts, for example, I defined that the total counts of 583keV for the 1010keV primary photon is give by the sum from bin 581 up to bin 586. Similarly, the total counts of 5400keV secondary for the 1010keV primary photon is given by the sum from bin 5399 up to bin 5406

if (PrimGammai==1010){
		Nsec=Sec1010.size();
		SecXXXX=Sec1010;
		Secondary[0]={581,582,583,584,585,586};
		Secondary[1]={5399,5400,5401,5402,5403,5404,5405,5406};
		}

This is the result file

CountsSecondariesCoincidences.txt (557 Bytes)

Unfortunately, the counts are not correct. For example, in the result file I read that the counts of 5400keV secondary for 1010keV in PD detector are 217. This is not correct, because if you sum the counts, they are only 24.
I guess that 217 is given by 24 (Real counts of 5400keV) + 193 (counts of 583keV)…but I clear my variable:

vecprocess.clear();

Here the macro, the sh file to launch it as a loop just using the command

source seccount_script.sh

, and data files WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free

I might be wrong but your problem does not seem to be a ROOT one?

Hi @couet, actually, it is a root macro (I use it by root)…neverthless, don’t worry. I’ve just solved my self!

At the end for cycle,

for (int is=0; is<Nsec; is++){

I had just to set

totcountsPD=0;
			totcountsDD=0;
			errtotcountsPD=0;
			errtotcountsDD=0;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.