Take the “smallFile.root
” and try:
Events->Scan("nElectron:Electron_pt", "", "", 10);
Events->Scan("nElectron:Electron_pt", "(nElectron<1) || (nElectron>0)", "", 10);
Events->Scan("nElectron:Electron_pt", "(nElectron<1) || (nElectron>0 && Electron_pt>0)", "", 10);
Events->Scan("nElectron:Electron_pt", "(nElectron<1) || (nElectron>0 && Alt$(Electron_pt,0)>0)", "", 10);
@couet Well, there may be two problems. One related to the usage of “Electron_pt
” in the cut (without “Alt$
”, it unconditionally requires that at least one electron is present, so it disregards the “nElectron<1
” condition) and another one related to the “UInt_t
” type of the “nElectron
”.
@Alkass I do not know if the result will always be correct, but instead of:
"(Muon_pt>29 || Electron_pt>37)"
try to use:
"(Alt$(Muon_pt,0)>29 || Alt$(Electron_pt,0)>37)"
couet
March 14, 2022, 1:25pm
23
Wile_E_Coyote:
@couet Well, there may be two problems. One related to the usage of “Electron_pt
” in the cut (without “Alt$
”, it unconditionally requires that at least one electron is present, so it disregards the “nElectron<1
” condition) and another one related to the “UInt_t
” type of the “nElectron
”.
This is really under the expertise of @pcanal
system
Closed
March 28, 2022, 1:26pm
24
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
pcanal
May 12, 2022, 1:46pm
27
Wile_E_Coyote:
Well, there may be two problems. One related to the usage of “Electron_pt
” in the cut (without “Alt$
”, it unconditionally requires that at least one electron is present, so it disregards the “nElectron<1
” condition) and another one related to the “UInt_t
” type of the “nElectron
”.
This is, for better or worse, the TTreeFormula
semantic. When writing:
(Muon_pt>29 || Electron_pt>37)
TTreeFormula
expands it to:
for(Int_t index = 0; index < min( num_of_elements(Muon_pt), num_of_elements(Electron_pt))
use `(Muon_pt[index]>29 || Electron_pt[index]>37)
The Alt$
function was introduced to work around this limitation.
pcanal
May 12, 2022, 1:57pm
28
So implicitly,
(Muon_pt>29 || Electron_pt>37)
is equivalent to
(Muon_pt>29 || Electron_pt>37) && (nMuon > 0 && nElectron > 0 && Instance$ < nMuon && Instance$ < nElectron)
pcanal
May 12, 2022, 2:25pm
29
cut=(Muon_pt>29 || Electron_pt>37) || ( HLT_IsoMu24 || HLT_IsoMu27 || HLT_Ele35_WPTight_Gsf)
so naively, you should get events when either muon (electrons) have pt> 29 (37) and also when some HLT triggers exist in the event.
Actually this is more complex. Technically the cut is applied “per element” rather than “per event”, so it
used as:
(Muon_pt[index]>29 || Electron_pt[index]>37) || ( HLT_IsoMu24 || HLT_IsoMu27 || HLT_Ele35_WPTight_Gsf)
to get the “per event” filtering you can use:
( Sum$(Muon_pt>29) || Sum$(Electron_pt>37)) || ( HLT_IsoMu24 || HLT_IsoMu27 || HLT_Ele35_W
PTight_Gsf)
(assuming the last 4 are not arrays, if they are array they also need the Sum$
)