Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with (Char_t) seediEtaOriX in Nanov11 onwards #43699

Closed
a-kapoor opened this issue Jan 11, 2024 · 22 comments
Closed

Issues with (Char_t) seediEtaOriX in Nanov11 onwards #43699

a-kapoor opened this issue Jan 11, 2024 · 22 comments

Comments

@a-kapoor
Copy link
Contributor

The PR #40327 added iEta,iPhi (for barrel) and iX,iY(for endcaps) to NanoAOD for photons and electrons. These are useful to veto the EE+ leak region at analysis level.

These variables were added as int8, it is not clear why _seediEtaOriX ends of as Char_t in the NanoAOD.
See docs
image
Same issue for electrons too.

The consequence is that when one reads these values, the _seediEtaOriX dumps some junk values:
image

Happens for both photons and electrons. The reason might be that ROOT interprets int8 as char. Although it is not clear why it only happens for _seediEtaOriX and not _seediPhiOriY

A workaround for analyzers might be to force ROOT to tree it as an integer, like this:
image

Note how I forced the type conversion by adding a zero.

Yet a permanent solution for future versions could be to change the type of this variable from int8 to int16.

This is not an isolated issue, and my student has seen other issues in new NanoAODs with these kind of datatypes:
https://cms-talk.web.cern.ch/t/uchar-short-and-char-variables-in-nanoaod-v12-inconsistent-results-using-root/33208

Will target a fix for EGM variable in Nano v14.

@RSalvatico @swagata87 @Prasant1993

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 11, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

A new Issue was created by @a-kapoor Anshul Kapoor.

@Dr15Jones, @makortel, @smuzaffar, @antoniovilela, @rappoccio, @sextonkennedy can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@a-kapoor
Copy link
Contributor Author

type egamma, root

@a-kapoor
Copy link
Contributor Author

assign egamma-pog, xpog

@cmsbuild
Copy link
Contributor

New categories assigned: egamma-pog,xpog

@vlimant,@hqucms,@a-kapoor,@RSalvatico you have been requested to review this Pull request/Issue and eventually sign? Thanks

@makortel
Copy link
Contributor

The definitions (as added by #40327)

seediEtaOriX = Var("superCluster().seedCrysIEtaOrIx","int8",doc="iEta or iX of seed crystal. iEta is barrel-only, iX is endcap-only. iEta runs from -85 to +85, with no crystal at iEta=0. iX runs from 1 to 100."),
seediPhiOriY = Var("superCluster().seedCrysIPhiOrIy",int,doc="iPhi or iY of seed crystal. iPhi is barrel-only, iY is endcap-only. iPhi runs from 1 to 360. iY runs from 1 to 100."),

have

  • seediEtaOriX with type "int8"
  • seediPhiOriY with type int

that seems explain why the first one is stored as Char_t and the second as Int_t.

@vlimant
Copy link
Contributor

vlimant commented Jan 11, 2024

indeed, the new types were introduced with #40478 and this end up with leaves of questionable type in ROOT
root [27] Events->GetLeaf("Photon_seediEtaOriX")->GetTypeName() (const char *) "Char_t" root [28] Events->GetLeaf("Photon_seediPhiOriY")->GetTypeName() (const char *) "Int_t"

so int8 (and uint8) are messed up when transferred to plain ROOT, as was already noticed by @swertz (not CMS anymore).

@makortel
Copy link
Contributor

Otherwise the behavior looks like expected. int8_t is (likely) a type alias to signed char, and out of the box that gets interpreted as a character (rather than integer) when printing out.

@makortel
Copy link
Contributor

type -root

I don't think this is an issue to be addressed by ROOT.

@cmsbuild cmsbuild removed the root label Jan 11, 2024
@vlimant
Copy link
Contributor

vlimant commented Jan 11, 2024

@makortel : where do I find the real meaning of "int8_t" and can we change this to what it means ?

@makortel
Copy link
Contributor

where do I find the real meaning of "int8_t" and can we change this to what it means ?

The int8_t is defined in the standard library, in our case libstdc++, which seems to take them directly from system glibc stdint.h, that on EL8 defines it as

// in /usr/include/bits/types.h
typedef signed char __int8_t;

// in /usr/include/bits/stdint-intn.h
typedef __int8_t int8_t;

We can not change its meaning. (What would you change it to? signed char is the fundamental "at least 8-bit" type, that on 64-bit Linux is exactly 8 bits)

@a-kapoor
Copy link
Contributor Author

@vlimant Shall I change the "int8" to int as done for seediPhiOriY if there are no central nano issues with this? It will solve the problem for these variables at least. What do you think?

@swertz
Copy link
Contributor

swertz commented Jan 11, 2024

Hi there, if you want to avoid that pesky ROOT formatting issue with int8, just change it to int16 (see indeed description in #40478).

uint8 should be fine but that is not what you want here.

@vlimant
Copy link
Contributor

vlimant commented Jan 11, 2024

because of the fundamental type and how it ends up stored in root, I think we need to centrally roll back and ban usage of int8, unit8, and maybe others from the nano table code to avoid dubious interpretation in root.
unless there is a smarter way to tell root to interpret signed char as integer number automatically

@swertz
Copy link
Contributor

swertz commented Jan 11, 2024

See the discussion here: https://root-forum.cern.ch/t/draw-short-integers-as-numbers-not-characters/52530/24

int8 should be fine, it's really only uint8 that's making a mess.

@a-kapoor
Copy link
Contributor Author

a-kapoor commented Jan 11, 2024

Hi @swertz as you can see in my description, in this specific case, it is "int8" that's making the mess

seediEtaOriX = Var("superCluster().seedCrysIEtaOrIx","int8",doc="iEta or iX of seed crystal. iEta is barrel-only, iX is endcap-only. iEta runs from -85 to +85, with no crystal at iEta=0. iX runs from 1 to 100."),
seediPhiOriY = Var("superCluster().seedCrysIPhiOrIy",int,doc="iPhi or iY of seed crystal. iPhi is barrel-only, iY is endcap-only. iPhi runs from 1 to 360. iY runs from 1 to 100."),

@swertz
Copy link
Contributor

swertz commented Jan 11, 2024

Sorry that was a typo, I meant to say that uint8 should be fine but int8 should be avoided and int16 used instead.

@vlimant
Copy link
Contributor

vlimant commented Jan 11, 2024

uint8 (used for PV_npvs for example) give issues with pyroot https://cms-talk.web.cern.ch/t/issues-with-uint8-t-variables-in-nanoaodv12/31598

@vlimant
Copy link
Contributor

vlimant commented Jan 16, 2024

parallel to rolling back int8 in nano (and then uint8), how do we go about having this "fixed" at the ROOT level ?

@vlimant
Copy link
Contributor

vlimant commented Jan 16, 2024

root-project/root#14361 for reference

@vlimant
Copy link
Contributor

vlimant commented Jan 26, 2024

+1

@vlimant
Copy link
Contributor

vlimant commented Mar 27, 2024

please close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants