Hello, I need a macro to filter events and write the counts in a txt file.
In particular the macro should:
Open the Sim.root file
Read how much events have Edep>0(Edep is a branch and it is a vector). Write the total number of Edep>0 in the txt file
3.Read how much events have Edep[0]>0 (As I said, Edep is a branch and it is a vector. Edep[0] is the first detector). Write the total number of Edep[0]>0 in the txt file
4.Read how much events have Edep[1]>0 (As I said, Edep is a branch and it is a vector. Edep[1] is the second detector). Write the total number of Edep[1]>0 in the txt file
Read how much events have Ep>0 (Ep is other branch) and write the total number of Ep>0 in txt file
Read the total gamma (i.e. the entries of Eg[0] (Eg is a branch and it is a vector).
Read how much Events have Eg[0]>value1 && Eg[0]<value 2, Eg[0]>value3 && Eg[0]<value 3 etc and write these counts in the txt file (Eg is a branch. It is a vectore, but I need Eg[0]).
Copy the Tree in a new file just for Edep>value entries.
Launching the command on my laboratory machine, I get two files (Tree1.h and Tree1.C). What should I do now to get the information that I need (counts of the branches as written in first post) and to get the new TTree for Edep>1000 ?
BTW: @bellenote I got the two files by laboratory machine, but on my windows I get
c:\my>root -l -q -b Sim.root -e 'Tree1->MakeClass();'
ROOT_cli_1:1:1: warning: multi-character character constant [-Wmultichar]
'Tree1-;'
^
ROOT_cli_1:1:1: warning: character constant too long for its type
c:\my>
and similarly for the other energies of gammas (4028keV, 5014keV, etc.)
but as you can see in the txt file, the results are not correct, because, if I look the histograms, I know that, for the small file that I uploaded yesterday:
a. Edep[0]>0 , 1894 entries
b. Edep[1]>0 , 679 entries
c. 1820<Egammacascade[0]<1828 , 226 entries
d. Ep>0 , 23665 entries
The “(Edep_size > 0 ? Edep->at(1) : 0.)” is wrong.
If you want to access the vector’s element “n”, you must make sure that the vector’s size is at least “n + 1”, e.g.: (Edep_size > n ? Edep->at(n) : 0.)
Sorry @Wile_E_Coyote but I don’t understand one thing. I know that Egammacascade[0] exists, because when I plot, I can plot Egammacascade[0] and, as I shown in my previous message, I could make the Tcuts on it!
Therefore, how can I get the number entries of Egammacascade[0] and the number satisfying some cuts?