Split branch

Hello, in a Geant4 simulation, a produce a TTree where branches are double.
Here the file WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free

The first branch is Edep where Edep[0] is the deposited energy in the first detector, Edep[1] the deposite energy in the second one.

A collegue needs the root file of the simulation (only the deposited energy). He usually works with TH1F, then to simplify his life, I should create a new root file just storing the deposited energy, but splitting the Edep vector in two branches, ie.:

Edep[0] will be filled in EdepGePD
Edep[1] will be filled in EdepGeDD.

I wrote the macro and it looks like working (i.e. a produce the new root file with 2 branches), but I see different number of entries. For example, when using the original file (Sim.root) I plot

Tree1->Draw("Edep[0]>>htemp0(5100,0.,5100)", "Edep[0]>0");

I get

on the contrary, when using the new splitted file, by the command

Tree1->Draw("EdepGePD>>htemp0(5100,0.,5100)", "EdepGePD>0");

I get

As you can see, in the new file I get a number of entries larger then in the old one, but I don’t understand the reason. Here the macro and the new file

edepsplit.cpp (1.5 KB)

Think carefully about what you are asking ROOT to draw; you are not necessarily asking the same here. There might be other issues but check this first.

    		if (Edep->size() > 1 && (Edep->at(0) > 0. || Edep->at(1) > 0.)) {
    			Edep0[0] = Edep->at(0);
				Edep1[0] = Edep->at(1); 
				hOut->Fill(); 
    		}

Hi @dastudillo,
.[quote=“dastudillo, post:2, topic:53153, full:true”]
Think carefully about what you are asking ROOT to draw; you are not necessarily asking the same here.
[/quote]

Edep[0] of the original root file is the EdepGePD in the new file, then

Tree1->Draw("Edep[0]>>htemp0(5100,0.,5100)", "Edep[0]>0");

should be the same request than

Tree1->Draw("EdepGePD>>htemp0(5100,0.,5100)", "EdepGePD>0");

then probably, there is some issue in the macro (but I don’t understand which one).
I’ve just uploaded the root files…could you check please?

Thank you @Wile_E_Coyote
That was the issue! Now the entries are the same!

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