Skip to content

pedestal leveling #182

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

pedestal leveling #182

wants to merge 20 commits into from

Conversation

tomeichlersmith
Copy link
Member

@tomeichlersmith tomeichlersmith commented Jul 15, 2025

To Do

  • code cleanup and documentation, move task to own file with header
  • add another iteration to level even more? going to leave further dev of the algorithm for the future, this is just a first draft and it already works great
  • replace copy of DecodeAndBuffer with one in main, move calculation of medians to utility

Functionality Test

I ran this new task after a hard reset to check how it does. The pftool log of what I did is 180-commands.log
I then ran

$ python ana/pedestal/violinplot.py data/pedestal-2025-07-15-180927.csv -o default.png
$ python ana/pedestal/violinplot.py data/pedestal-2025-07-15-181017.csv -o leveled.png

to produce the following. The calib channels do not move (as expected, we don't bother leveling them).

default leveled

@tomeichlersmith tomeichlersmith linked an issue Jul 15, 2025 that may be closed by this pull request
@tomeichlersmith tomeichlersmith force-pushed the 180-pedestal-leveling branch from a7871c0 to e379cdf Compare July 16, 2025 16:32
@tomeichlersmith
Copy link
Member Author

This does change the median (slightly) while significantly tightening the distribution of pedestal values across all channels.

image

@tomeichlersmith
Copy link
Member Author

After my code cleanup, I re-ran the checks

# on zcu
./pftool -z -s 180-check.pftool | tee 180-check.log
# on local computer
python ana/pedestal/violinplot.py data/pedestal-2025-07-17-default.csv -o default.png
python ana/pedestal/violinplot.py data/pedestal-2025-07-17-leveled.csv -o leveld.png
# other histogram in jupyter notebook

180-check.log
default
leveled

image

@tomeichlersmith tomeichlersmith marked this pull request as ready for review July 17, 2025 14:41
@tomeichlersmith
Copy link
Member Author

@erik-wallin @taylorjcolaizzi I am requesting your reviews to see how this functions on the HGCROCs you have. I want to make sure that it runs successfully. If you see results similar to mine that is an extra win.

I've been testing it by doing a roc.hardreset in order to see the default-parameter pedestals and then running tasks.level_pedestals in order to see the leveled pedestals. Note: after a roc.hardreset you will need to daq.setup.standard.
The 180-check.log shows exactly what I did.

# on zcu
cd pflib
git switch 180-pedestal-leveling
cd build
make -j

@taylorjcolaizzi
Copy link
Contributor

@erik-wallin @taylorjcolaizzi I am requesting your reviews to see how this functions on the HGCROCs you have. I want to make sure that it runs successfully. If you see results similar to mine that is an extra win.

I've been testing it by doing a roc.hardreset in order to see the default-parameter pedestals and then running tasks.level_pedestals in order to see the leveled pedestals. Note: after a roc.hardreset you will need to daq.setup.standard. The 180-check.log shows exactly what I did.

# on zcu
cd pflib
git switch 180-pedestal-leveling
cd build
make -j

Sure thing! I followed your steps and share my output here. I'm attaching a zip file of my yaml file, since Github won't let me upload .yaml here.

level-pedestals-roc-0-settings_20250717_183223.yaml.zip

One thing I noticed is that CH_42.TRIM_INV = 2147483647, which might be a little high.

@taylorjcolaizzi
Copy link
Contributor

And here's a pedestal run I took afterward!
pedestals_leveled.csv
Hopefully they are level :)

@OwenCole04
Copy link
Contributor

OwenCole04 commented Jul 17, 2025

Ran this on the ROC at UVA; This is what I got from a pedestal run after:
image

@tomeichlersmith
Copy link
Member Author

tomeichlersmith commented Jul 17, 2025

Thank you both! I now have two more things to look into.

  • fix ultra-high TRIM_INV issue. I'm guessing this is because the algo is accidentally finding a negative TRIM_INV which is then being converted to a super-high value when it is static cast into a unsigned int.
  • fix upper limit of TRIM_INV. two of the channels that are far below the link median (70 and 34) have a TRIM_INV bigger than 63 mean which is then cropped to only 6 bits and thus are not shifted close to the median at all.

@taylorjcolaizzi
Copy link
Contributor

taylorjcolaizzi commented Jul 18, 2025 via email

this has been a lurking issue and now that we're trying to write code
that algorithmically sets parameters, these checks will be nice
fixed merge conflict in app/tool/tasks.cxx where multiple commands
were added at once
@tomeichlersmith
Copy link
Member Author

Alright, I added some checks in both the compiler and in the level pedestals algorithm.

violinplot

@taylorjcolaizzi @OwenCole04 @verenamh Please give it a try again, I would appreciate the results in terms of the violin plot that this branch can make.

# on zcu
git switch 180-pedestal-leveling
git pull
cd build
make
./pftool -z
# roc.hardreset
# daq.setup.standard
# daq.pedestal -> call this default.csv
# tasks.level_pedestals
# daq.pedestal -> call this leveled.csv

# on local computer to make plots
cd pflib
git fetch
git switch 180-pedestal-leveling
python ana/pedestal/violinplot.py default.csv leveled.csv
# upload violinplot.png created

@taylorjcolaizzi
Copy link
Contributor

Nice work! Looks quite nice! The leveling script printed an error for me during runtime, saying that channels 42 and 70 are so far below target that TRIM_INV had to be set to its maximum.

violinplot

@verenamh
Copy link
Contributor

I got the same error as Taylor, just for channel 0 and 2! Here is the plot I got:

violinplot

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

Successfully merging this pull request may close these issues.

pedestal leveling
4 participants