lawrenceleejr / DVMuReint

2 stars 1 forks source link

Implement Acceptance Calculations #12

Open lawrenceleejr opened 2 years ago

lawrenceleejr commented 2 years ago

@taylorsussmane will implement calculations of acceptance definitions (page 1 of https://atlas.web.cern.ch/Atlas/GROUPS/PHYSICS/PAPERS/SUSY-2018-33/hepdata_info.pdf)

Aiming for end of this week.

taylorsussmane commented 2 years ago

I uploaded some cleaned up code. However, I get this error on line 57 that I'm not really understanding because I did basically the same thing in the if statement for neutrinos

Traceback (most recent call last):
  File "/Users/taylorsussmane/CMSresearch/DVMuReint/hepmcFiles/./DVMuEfficiencies.py", line 57, in <module>
    rx = iparticle.end_vertex.position[0]
AttributeError: 'NoneType' object has no attribute 'position'
lawrenceleejr commented 2 years ago

Very good. So if you try to print out each individual component of that, you’d probably find that iparticle.end_vertex doesn’t actually exist. Maybe for particles that don’t decay. So you’ll have to check if it decays before running that line. Or the more “pythonic” way of handling it is to use exceptions but I’ll let you look that up or we can discuss next time we chat. Does that make sense?

taylorsussmane commented 2 years ago

I've committed my changes to the vertex level acceptance. I changed the get_reconstructable function to be recursive and added some comments. Could you take a look and let me know if I need to change anything? The function is 35-45 and vertex level acceptance is 76-94

lawrenceleejr commented 2 years ago

For future reference, you can copy a "permalink" directly to those lines and makes it really easy to go back and forth between the comment and the code. e.g.

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L35-L45

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L76-L94

First comment

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L44 Since get_reconstructable_children returns a list, you have to do something with that list. So you want to receive it and append it to the ongoing reconstructables list on this line. So that line could be:

reconstructables.append( get_reconstructable_children(child, refPos) )

Second

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L41

Let's have this be 10 cm instead of 10 m.

The rest of it looks good at a quick glance. Can you start plotting some of these quantities to see if they make any sense? So for example, it would be good to make a plot of the number of reconstructable decay products. And maybe another with the number of selected decay products.

taylorsussmane commented 2 years ago

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L69-L94 On line 69, I added the not iparticle.end_vertex.position part because I was getting a NoneType has no attribute position error later on, but I figured out that this doesn't allow anything to pass the if statement.

So then, I tried to do

iparticle.end_vertex is not None

But, I still get the same Nonetype error, so I am confused

taylorsussmane commented 2 years ago

https://github.com/lawrenceleejr/DVMuReint/blob/3d0649b3efc5fef2aedf66089f2873bbc3558732/hepmcFiles/DVMuEfficiencies.py#L96-L105 For the muon event level acceptance, none of the events are passing the cuts. I printed all the values and I think it's because d_0 is always very small, but I'm not really understanding why. r_decay is in mm.

Also, I changed the pT to 62000 MeV, but I haven't committed that change.

lawrenceleejr commented 2 years ago

We expect there to be muons that are produced with d0 of basically 0. We also expect some muons to sometimes occur with a larger d0, but that will depend on the lifetime of the neutralino. So it might be that you don't see anything for as long as we have these buggy samples with incorrect lifetimes. So this might be expected.

taylorsussmane commented 2 years ago
Traceback (most recent call last):
  File "/Users/taylorsussmane/CMSresearch/DVMuReint/hepmcFiles/./DVMuEfficiencies.py", line 124, in <module>
    if isCharged(ipart) != 0 and ipart.momentum.pt()/abs(getCharge(ipart)) > 1000:
  File "/Users/taylorsussmane/CMSresearch/DVMuReint/hepmcFiles/./DVMuEfficiencies.py", line 48, in isCharged
    part = Particle.from_pdgid(particle.pid)
  File "/Users/taylorsussmane/opt/anaconda3/envs/test/lib/python3.10/site-packages/particle/particle/particle.py", line 1001, in from_pdgid
    raise ParticleNotFound(f"Could not find PDGID {value}") from None
particle.particle.particle.ParticleNotFound: Could not find PDGID 1000022

I'm getting this error from the Particle class I used to get the charge, so I assume it doesn't have the susy particles?

This is the link to the class I used: https://pypi.org/project/particle/

lawrenceleejr commented 2 years ago

Ooooo great catch. You could "teach" the particle package what you mean by importing a custom data table... See https://pypi.org/project/particle/ under "Advanced: Loading custom tables" and appending to its internal list.

Or.. you could just manually do it in your code by checking some particular PDGIDs manually and then otherwise looking at the particle module for the answer. 1000022 is neutral.