faca87
March 13, 2022, 3:02pm
21
I get this
root [1] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
OBJ: TBranch ScintOutParticleTrackEventID B1ScintOutparticles : 0 at: 0x2b44950
->ScintOutParticleTrackEventID<-
->B1ScintOutparticles<-
->ScintOutParticleTrackEventID<-
OBJ: TLeafD ScintOutParticleTrackEventID ScintOutParticleTrackEventID : 0 at: 0x24fdef0
->ScintOutParticleTrackEventID<-
->ScintOutParticleTrackEventID<-
->ScintOutParticleTrackEventID.ScintOutParticleTrackEventID<-
Error in <TTreeFormula::Compile>: Bad numerical expression : "ScintOutParticleTrackEventID.ScintOutParticleTrackEventID"
Error in <TTreeFormula::Compile>: Bad numerical expression : "ScintOutParticleParentID.ScintOutParticleParentID"
Info in <TCanvas::Print>: png file DeltaKinEne.png has been created
root [2]
Maybe another question. Has your main tree “B1Scintparticles” ("t") also the same two branches which are used for the index ("ScintOutParticleTrackEventID" and “ScintOutParticleParentID”) as the “B1ScintOutparticles” ("te") tree?
faca87
March 13, 2022, 3:29pm
23
The similar branch of ScintOutParticleTrackEventID " and “ScintOutParticleParentID of the friend B1ScintOutparticles TTree in the main TTree B1Scintparticles are called ScintParticleTrackEventID " and “ScintParticleParentID
as you can see in the print
root [0] TFile *fin = TFile::Open("B1/B1-build/B1.root");
root [1] fin->ls ();
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
root [2] TTree *t=0;
root [3] fin->GetObject("B1Scintparticles",t);
root [4] t->Print();
******************************************************************************
*Tree :B1Scintparticles: Ent_scint *
*Entries : 151534 : Total = 38301077 bytes File Size = 24149373 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :ScintParticleID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823678 bytes File Size = 283464 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 6.43 *
*............................................................................*
*Br 1 :ScintParticleKinEn : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1178067 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.55 *
*............................................................................*
*Br 2 :ScintParticleMomDir.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1359001 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 3 :ScintParticleMomDir.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1361133 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 4 :ScintParticleMomDir.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1337352 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.36 *
*............................................................................*
*Br 5 :ScintParticleVert.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1363451 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 6 :ScintParticleVert.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1363795 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 7 :ScintParticleVert.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1364034 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 8 :ScintParticleTotMom : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1179858 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.54 *
*............................................................................*
*Br 9 :ScintDirection.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1345436 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.35 *
*............................................................................*
*Br 10 :ScintDirection.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1362038 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 11 :ScintDirection.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1300233 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.40 *
*............................................................................*
*Br 12 :ScintParticleMom.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1360167 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 13 :ScintParticleMom.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1360313 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 14 :ScintParticleMom.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1361550 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 15 :ScintParticleAng.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1359965 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 16 :ScintParticleAng.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1361028 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 17 :ScintParticleTrackID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823888 bytes File Size = 425324 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 4.29 *
*............................................................................*
*Br 18 :ScintParticleEventID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823888 bytes File Size = 767963 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 2.37 *
*............................................................................*
*Br 19 :ScintParticleParentID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 429672 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 4.24 *
*............................................................................*
*Br 20 :ScintParticleTrackEvenID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1824056 bytes File Size = 917055 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.99 *
*............................................................................*
root [5]
I guess you need branches with exactly the same names.
Maybe this works:
te->BuildIndex("ScintOutParticleTrackEventID", "ScintOutParticleParentID");
t->SetAlias("ScintOutParticleTrackEventID", "ScintParticleTrackEventID");
t->SetAlias("ScintOutParticleParentID", "ScintParticleParentID");
t->AddFriend(te);
and / or this:
te->SetAlias("ScintParticleTrackEventID", "ScintOutParticleTrackEventID");
te->SetAlias("ScintParticleParentID", "ScintOutParticleParentID");
te->BuildIndex("ScintParticleTrackEventID", "ScintParticleParentID");
t->AddFriend(te);
faca87
March 13, 2022, 4:21pm
25
I made a new simulation (few events…just to try) calling the branches with the same names.
This is the macro:
deltakinene.cpp (3.3 KB)
This is the ROOT file WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free
but I still get error
root [0] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
OBJ: TBranch ScintParticleTrackEventID B1ScintOutparticles : 0 at: 0x33fec60
->ScintParticleTrackEventID<-
->B1ScintOutparticles<-
->ScintParticleTrackEventID<-
OBJ: TLeafD ScintParticleTrackEventID ScintParticleTrackEventID : 0 at: 0x33ff0a0
->ScintParticleTrackEventID<-
->ScintParticleTrackEventID<-
->ScintParticleTrackEventID.ScintParticleTrackEventID<-
Error in <TTreeFormula::Compile>: Bad numerical expression : "ScintParticleTrackEventID.ScintParticleTrackEventID"
Info in <TCanvas::Print>: png file DeltaKinEne.png has been created
root [1]
Wile_E_Coyote:
Maybe this works:
te->BuildIndex("ScintOutParticleTrackEventID", "ScintOutParticleParentID");
t->SetAlias("ScintOutParticleTrackEventID", "ScintParticleTrackEventID");
t->SetAlias("ScintOutParticleParentID", "ScintParticleParentID");
t->AddFriend(te);
Then I tried this with the file with differents branches
This is the macro
deltakinene.cpp (3.1 KB)
but I get this
root [0] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
Error in <TTreeFormula::Compile>: Bad numerical expression : "ScintParticleTrackEventID"
Error in <TTreeFormula::DefinedVariable>: The substitution of the alias "ScintOutParticleTrackEventID" by "ScintParticleTrackEventID" failed.
Error in <TTreeFormula::Compile>: Bad numerical expression : "B1ScintOutparticles.ScintParticleKinEn"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintParticleKinEn,}
Info in <TCanvas::Print>: png file DeltaKinEne.png has been created
root [1]
Wile_E_Coyote:
and / or this:
```cpp
te->SetAlias("ScintParticleTrackEventID", "ScintOutParticleTrackEventID");
te->SetAlias("ScintParticleParentID", "ScintOutParticleParentID");
te->BuildIndex("ScintParticleTrackEventID", "ScintParticleParentID");
t->AddFriend(te);
Lastly I tried this
Here the macro
deltakinene.cpp (3.0 KB)
but I get this
root [0] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
Error in <TTreeFormula::Compile>: Bad numerical expression : "ScintParticleTrackEventID"
Error in <TTreeFormula::Compile>: Bad numerical expression : "B1ScintOutparticles.ScintParticleKinEn"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintParticleKinEn,}
Info in <TCanvas::Print>: png file DeltaKinEne.png has been created
In one tree you have “ScintParticleTrackEvenID” but in the other one “ScintParticleTrackEventID”.
If branch names are equal, you do not need to use TTree::SetAlias at all. Use simpy:
te->BuildIndex("ScintParticleTrackEventID", "ScintParticleParentID");
t->AddFriend(te);
According to
https://root.cern/doc/master/classTTreeIndex.html#a02300b69681c45b9e20503ad1d86d8c8
the “major” and “minor” in BuildIndex (i.e. “ScintParticleTrackEventID”, “ScintParticleParentID” in your case) must be integer. But at least in the last root file you uploaded these leaves are Double_t.
@dastudillo Read the description again (branch values will be “converted to an integer”).
faca87
March 13, 2022, 5:24pm
29
You are right…I didn’t notice the typo!
Then, using the file with different branches I wrote
te->SetAlias("ScintParticleTrackEvenID", "ScintOutParticleTrackEventID");
te->SetAlias("ScintParticleParentID", "ScintOutParticleParentID");
te->BuildIndex("ScintParticleTrackEvenID", "ScintParticleParentID");
t->AddFriend(te);
TString henestring = TString::Format("B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintOutParticleKinEn>> hene");
I don’t get errors, but I still get values <0
deltakinene.cpp (2.8 KB)
Are you sure that you always get a unique ("Long64_t") “index” value from (both parameters, “major” and “minor”, can be “expressions” using original tree variables): “index = major * 2^32 + minor”
In principle, you should have “0 <= major < 2^31” and “0 <= minor < 2^31” (note: 2^31 is about 2.1e9).
faca87
March 13, 2022, 6:35pm
31
The ScintParticleTrackEventID is filled by
double trackeventID = trackID+(k*evtID);
where k=100;
in GEANT4 each particle is defined by a specific trackID, eventID, parentID value.
then each trackeventID should be a specific value, unless there aren’t different trackID and eventID such that they have same trackID+(k*evtID)…but I thick that the probability is very low…
faca87
March 15, 2022, 6:18pm
32
Hello @Wile_E_Coyote and @pcanal to avoid the probability that the ScintParticleTrackEventID isn’t unique, I wanted to use ScintOutParticleEventID, ScintOutParticleParentID and ScintOutParticleTrackEventID
Then I wrote:
te->SetAlias("ScintParticleParentID", "ScintOutParticleParentID");
te->SetAlias("ScintParticleTrackID", "ScintOutParticleTrackID");
te->SetAlias("ScintParticleEventID", "ScintOutParticleEventID");
//te->BuildIndex("ScintParticleTrackEvenID", "ScintParticleParentID");
te->BuildIndex("ScintParticleParentID","ScintParticleTrackID","ScintParticleEventID");
but it says that the BuildIndex can’t have more than 2 branches
root [1] .x deltakinene.cpp
In file included from input_line_9:1:
/data_collamaf/DataFausto/Muon_Collider/III_anno/Tesi/Simulazioni_per_tesi/MAINZ_R=x_gaussian10um_13keV_1urad/Particles_scintillator/W_r=1cm_s=1mm_steel_R=30cm_s=1mm_edep_scint/deltakinene.cpp:42:66: error: too many arguments to function call, expected at most 2, have 3
te->BuildIndex("ScintParticleParentID","ScintParticleTrackID","ScintParticleEventID");
~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/include/TTree.h:416:4: note: 'BuildIndex' declared here
virtual Int_t BuildIndex(const char* majorname, const char* minorname = "0");
^
root [2]
is there a way to use more than two branches?
deltakinene.cpp (3.2 KB)
You can try something like this (both parameters can be “expressions” using original tree variables):
te->BuildIndex("ScintParticleTrackEventID", "ScintParticleParentID + 1000 * ScintParticleTrackID");
faca87
March 15, 2022, 6:43pm
34
Thank you @Wile_E_Coyote
Unfortunately, I still get some negative values…
Try to inspect entries which return negative values. e.g.:
t->Scan("*", "B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintOutParticleKinEn < -0.5");
BTW. @pcanal I do not know what happens if the friend tree does not have an entry corresponding to some main tree entry.
@faca87 Try to add some additional protection:
t->Draw("B1Scintparticles.ScintParticleKinEn - B1ScintOutparticles.ScintOutParticleKinEn",
"(B1Scintparticles.ScintParticleTrackEventID == B1ScintOutparticles.ScintParticleTrackEventID) && (B1Scintparticles.ScintParticleParentID == B1ScintOutparticles.ScintParticleParentID) && (B1Scintparticles.ScintParticleTrackID == B1ScintOutparticles.ScintParticleTrackID)");
faca87
March 17, 2022, 6:24pm
36
Wile_E_Coyote:
t->Draw("B1Scintparticles.ScintParticleKinEn - B1ScintOutparticles.ScintOutParticleKinEn",
"(B1Scintparticles.ScintParticleTrackEventID == B1ScintOutparticles.ScintParticleTrackEventID) && (B1Scintparticles.ScintParticleParentID == B1ScintOutparticles.ScintParticleParentID) && (B1Scintparticles.ScintParticleTrackID == B1ScintOutparticles.ScintParticleTrackID)");
Hello @Wile_E_Coyote adding these lines, I get
root [0] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
Error in <TTreeFormula::Compile>: Bad numerical expression : "B1ScintOutparticles.ScintOutParticleKinEn"
Error in <TTreeFormula::Compile>: Bad numerical expression : "B1Scintparticles.ScintParticleTrackEventID"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {B1Scintparticles.ScintParticleKinEn - B1ScintOutparticles.ScintOutParticleKinEn,(B1Scintparticles.ScintParticleTrackEventID == B1ScintOutparticles.ScintParticleTrackEventID) && (B1Scintparticles.ScintParticleParentID == B1ScintOutparticles.ScintParticleParentID) && (B1Scintparticles.ScintParticleTrackID == B1ScintOutparticles.ScintParticleTrackID)}
#0 0x00007f3484d9646c in waitpid () from /lib64/libc.so.6
#1 0x00007f3484d13f62 in do_system () from /lib64/libc.so.6
#2 0x00007f3485e29654 in TUnixSystem::StackTrace() () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCore.so.6.24
#3 0x00007f34804e4958 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCling.so
#4 0x00007f34804dd083 in cling_runtime_internal_throwIfInvalidPointer () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCling.so
#5 0x00007f347dda4f8a in ?? ()
#6 0x0000000000000038 in ?? ()
#7 0x0000000001faecd0 in ?? ()
#8 0x00007f3486474000 in ?? ()
#9 0x00007f3481328414 in llvm::RuntimeDyldELF::resolveRelocation(llvm::RelocationEntry const&, unsigned long) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCling.so
#10 0x51316e555f676e69 in ?? ()
#11 0x0000000000000000 in ?? ()
Error in <HandleInterpreterException>: Trying to access a pointer that points to an invalid memory address..
Execution of your code was aborted.
In file included from input_line_8:1:
/data_collamaf/DataFausto/Muon_Collider/III_anno/Tesi/Simulazioni_per_tesi/MAINZ_R=x_gaussian10um_13keV_1urad/Particles_scintillator/W_r=1cm_s=1mm_steel_R=30cm_s=1mm_edep_scint/deltakinene.cpp:79:13: warning: invalid memory pointer passed to a callee:
stats->SetTextColor(kBlue);
^~~~~
root [1]
Check tree and variable names (which you use in the “Draw” call). It looks like some of them are misspelled.
faca87
March 18, 2022, 5:45pm
38
Hello @Wile_E_Coyote the only misspelled that I noticed was
ScintParticleTrackEventID instead of ScintParticleTrackEvenID
becuase these are the branches of B1Scintparticles
root [6] t->Print();
******************************************************************************
*Tree :B1Scintparticles: Ent_scint *
*Entries : 151534 : Total = 38301077 bytes File Size = 24149373 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :ScintParticleID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823678 bytes File Size = 283464 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 6.43 *
*............................................................................*
*Br 1 :ScintParticleKinEn : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1178067 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.55 *
*............................................................................*
*Br 2 :ScintParticleMomDir.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1359001 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 3 :ScintParticleMomDir.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1361133 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 4 :ScintParticleMomDir.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 1337352 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.36 *
*............................................................................*
*Br 5 :ScintParticleVert.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1363451 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 6 :ScintParticleVert.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1363795 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 7 :ScintParticleVert.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1364034 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 8 :ScintParticleTotMom : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823846 bytes File Size = 1179858 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.54 *
*............................................................................*
*Br 9 :ScintDirection.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1345436 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.35 *
*............................................................................*
*Br 10 :ScintDirection.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1362038 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 11 :ScintDirection.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823720 bytes File Size = 1300233 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.40 *
*............................................................................*
*Br 12 :ScintParticleMom.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1360167 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 13 :ScintParticleMom.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1360313 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 14 :ScintParticleMom.z : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1361550 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 15 :ScintParticleAng.x : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1359965 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 16 :ScintParticleAng.y : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823804 bytes File Size = 1361028 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 17 :ScintParticleTrackID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823888 bytes File Size = 425324 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 4.29 *
*............................................................................*
*Br 18 :ScintParticleEventID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823888 bytes File Size = 767963 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 2.37 *
*............................................................................*
*Br 19 :ScintParticleParentID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1823930 bytes File Size = 429672 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 4.24 *
*............................................................................*
*Br 20 :ScintParticleTrackEvenID : Double_t B1Scintparticles *
*Entries : 151534 : Total Size= 1824056 bytes File Size = 917055 *
*Baskets : 39 : Basket Size= 32000 bytes Compression= 1.99 *
*............................................................................*
and these are the branches of B1ScintOutparticles
root [7] te->Print();
******************************************************************************
*Tree :B1ScintOutparticles: Ent_scint *
*Entries : 142172 : Total = 35941361 bytes File Size = 22539116 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :ScintOutParticleID : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711316 bytes File Size = 239221 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 7.15 *
*............................................................................*
*Br 1 :ScintOutParticleKinEn : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1083011 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.58 *
*............................................................................*
*Br 2 :ScintOutParticleMomDir.x : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711556 bytes File Size = 1273158 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 3 :ScintOutParticleMomDir.y : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711556 bytes File Size = 1274020 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 4 :ScintOutParticleMomDir.z : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711556 bytes File Size = 1255171 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.36 *
*............................................................................*
*Br 5 :ScintOutParticleVert.x : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711476 bytes File Size = 1274744 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 6 :ScintOutParticleVert.y : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711476 bytes File Size = 1275058 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 7 :ScintOutParticleVert.z : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711476 bytes File Size = 1275749 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 8 :ScintOutParticleTotMom : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711476 bytes File Size = 1083958 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.58 *
*............................................................................*
*Br 9 :ScintOutDirection.x : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711356 bytes File Size = 1262360 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.35 *
*............................................................................*
*Br 10 :ScintOutDirection.y : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711356 bytes File Size = 1268005 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.35 *
*............................................................................*
*Br 11 :ScintOutDirection.z : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711356 bytes File Size = 1221249 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.40 *
*............................................................................*
*Br 12 :ScintOutParticleMom.x : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1272806 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 13 :ScintOutParticleMom.y : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1272439 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 14 :ScintOutParticleMom.z : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1274358 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 15 :ScintOutParticleAng.x : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1271534 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 16 :ScintOutParticleAng.y : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711436 bytes File Size = 1272534 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.34 *
*............................................................................*
*Br 17 :ScintOutParticleTrackID : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711516 bytes File Size = 398949 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 4.29 *
*............................................................................*
*Br 18 :ScintOutParticleEventID : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711516 bytes File Size = 719175 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 2.38 *
*............................................................................*
*Br 19 :ScintOutParticleParentID : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711556 bytes File Size = 405317 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 4.22 *
*............................................................................*
*Br 20 :ScintOutParticleTrackEventID : Double_t B1ScintOutparticles *
*Entries : 142172 : Total Size= 1711716 bytes File Size = 858084 *
*Baskets : 37 : Basket Size= 32000 bytes Compression= 1.99 *
*............................................................................*
root [8]
then I fixed the mispelled
but I get this
root [8] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
Error in <TTreeFormula::Compile>: Bad numerical expression : "B1ScintOutparticles.ScintOutParticleKinEn"
#0 0x00007f021d82146c in waitpid () from /lib64/libc.so.6
#1 0x00007f021d79ef62 in do_system () from /lib64/libc.so.6
#2 0x00007f021e8b4654 in TUnixSystem::StackTrace() () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCore.so.6.24
#3 0x00007f0218f6f958 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCling.so
#4 0x00007f0218f68083 in cling_runtime_internal_throwIfInvalidPointer () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.00/x86_64-centos7-gcc48-opt/lib/libCling.so
#5 0x00007f0216809f8a in ?? ()
#6 0x000000770000006e in ?? ()
#7 0x0000000000000000 in ?? ()
Error in <HandleInterpreterException>: Trying to access a pointer that points to an invalid memory address..
Execution of your code was aborted.
In file included from input_line_39:1:
/data_collamaf/DataFausto/Muon_Collider/III_anno/Tesi/Simulazioni_per_tesi/MAINZ_R=x_gaussian10um_13keV_1urad/Particles_scintillator/W_r=1cm_s=1mm_steel_R=30cm_s=1mm_edep_scint/deltakinene.cpp:79:13: warning: invalid memory pointer passed to a callee:
stats->SetTextColor(kBlue);
^~~~~
root [9]
It says that B1ScintOutparticles.ScintOutParticleKinEn it’s bad…but the branche exist…for example, I used it in the line
TString henestring = TString::Format("B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintOutParticleKinEn>> hene");
deltakinene.cpp (3.8 KB)
The “t->Scan(...);” should go AFTER “t->AddFriend(te);”.
Protect “stats” usage:
TPaveStats *stats = ...;
if (stats) {
stats->SetTextColor(kBlue);
...
}
faca87
March 18, 2022, 6:11pm
40
Thank you! now it works it prints:
root [9] .x deltakinene.cpp
TFile** B1/B1-build/B1.root
TFile* B1/B1-build/B1.root
KEY: TTree B1EventVariables;1 Relesed_energy
KEY: TTree B1Exitparticles;1 Exit_targets
KEY: TTree B1Enteringparticles;1 Entering_targets
KEY: TTree B1Enterinregengparticles;1 Entering_regen
KEY: TTree B1EnterinPhotonregengparticles;1 Entering_photon_regen
KEY: TTree B1Exitregengparticles;1 Exit_regen
KEY: TTree B1Scintparticles;1 Ent_scint
KEY: TTree B1Dummyparticles;1 Ent_Dummy
KEY: TTree B1ParticleNotInteracting;1 Part_not_inter
KEY: TTree B1ScintSecCreated;1 Sec_crated
KEY: TTree B1ScintOutparticles;1 Ent_scint
************************************************************************************************************************************************************************************************************************************************************************
* Row * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintDire * ScintDire * ScintDire * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart * ScintPart *
************************************************************************************************************************************************************************************************************************************************************************
* 58282 * -11 * 0.2168374 * -0.497504 * -0.818652 * -0.286874 * 0.0803287 * -0.046046 * 0.1277309 * 0.5182913 * -96.62228 * -11.81035 * -292.8133 * -0.257852 * -0.424300 * -0.148684 * 1.0477402 * 1.2337446 * 6 * 233462618 * 2 * 1.534e+09 *
* 75258 * 11 * 0.5303339 * -0.364324 * 0.5221898 * -0.771093 * -0.212416 * -0.168336 * 0.4262683 * 0.9073335 * -118.7749 * -3.204063 * -283.6374 * -0.330563 * 0.4738003 * -0.699639 * 0.4413877 * -0.595264 * 5 * 314832492 * 2 * 1.299e+09 *
* 129681 * 11 * 0.2277688 * -0.145147 * 0.6590383 * -0.737970 * 0.1472122 * 0.0978483 * 0.1308536 * 0.5335334 * -117.6213 * 9.5662456 * -284.1152 * -0.077440 * 0.3516190 * -0.393732 * 0.1942052 * -0.728957 * 2 * 536567457 * 1 * -30345499 *
* 134897 * 11 * 0.1320172 * -0.331957 * 0.4768878 * -0.813868 * 0.1476853 * 0.0608789 * -0.300019 * 0.3903201 * -142.6222 * -19.92751 * -278.9924 * -0.129569 * 0.1861389 * -0.317669 * 0.3872769 * -0.530025 * 2 * 560809324 * 1 * -1.83e+09 *
* 142955 * 11 * 0.3659767 * -0.056925 * 0.7544665 * -0.653865 * -0.003181 * 0.0015342 * -299.1784 * 0.7127176 * -102.2086 * 9.7672174 * -290.4993 * -0.040571 * 0.5377216 * -0.466021 * 0.0868410 * -0.856709 * 2 * 596205684 * 1 * -79477014 *
************************************************************************************************************************************************************************************************************************************************************************
==> 5 selected entries
Warning in <TCanvas::Constructor>: Deleting canvas with same name: c01
Info in <TCanvas::Print>: png file DeltaKinEne.png has been created
root [10]