Conversation
tomeichlersmith
left a comment
There was a problem hiding this comment.
This looks good! Thank you
I have a lot of nit-picky updates, but nothing too serious that changes the overall logic or intention.
| bins = np.arange(min_adc - 0.5, max_adc + 1.5, 1) | ||
|
|
||
| counts, edges = np.histogram(data_hist, bins) | ||
| errors = np.sqrt(counts) | ||
| centers = (edges[:-1] + edges[1:]) / 2 | ||
| hep.histplot((counts, edges), ax=ax, histtype='step', density=False, label=labels) | ||
| ax.errorbar(centers, counts, yerr=errors, fmt='.', capsize=2, markersize=3) |
There was a problem hiding this comment.
This mechanic of filling histograms and plotting them with error bars is also accomplished by the hist package https://hist.readthedocs.io/en/latest/
I would suggest using it because it makes your code simpler and it has sensible defaults for error calculations and plotting styles.
| auto hcalbp = dynamic_cast<pflib::HcalTarget*>(tgt); | ||
| if (!hcalbp) { | ||
| PFEXCEPTION_RAISE("BadTarget", | ||
| "led_bias_scan only available for Hcal targets"); | ||
| } |
There was a problem hiding this comment.
Move this to the beginning of the function so nothing is run if its the wrong target type.
| ->line("LED_BIAS_SCAN", "Sweeps SiPM and LED DACs", led_bias_scan) | ||
| ->line("SPS_READOUT", | ||
| "Take data of a photospectrum on one bunch crossing", | ||
| sps_readout); |
There was a problem hiding this comment.
we can also prevent SPS_READOUT from being display for non-Hcal targets
| sps_readout); | |
| sps_readout, ONLY_HCAL); |
which we should probably add to the LED_BIAS_SCAN as well
| * Used to scan different SiPM or LED DAC values/biases. | ||
| * Both can either be varied over a range, or kept constant if the same value is | ||
| * entered for the start and stop value. One can choose how many ports have CMBs | ||
| * connected An LED flash on one CMB flashes into four HGCROC channels | ||
| * simultaneously, thus the pulses of all four respective channels are recorded | ||
| * in the csv file. |
There was a problem hiding this comment.
This is just a copy of led_bias_scan's description? Please update
| nlohmann::ordered_json header; | ||
| f << std::boolalpha << "# " << header << '\n' |
There was a problem hiding this comment.
This JSON header is useful for including extra metadata about the run.
Things I would suggest including:
- ROC/Channel that is being studied
- target bx
- other parameters that are constant for the run but different from the defaults
| .add(calib_page, "INPUTDAC", | ||
| 32) // No idea what this should be (MAXES out at 63) |
There was a problem hiding this comment.
Please add more comments describing what these parameters are trying to do. This is more than just "turning on charge injections" as stated in your comment above.
Add comments in the line above the parameter just to make the formatting easier
| .add(calib_page, "INPUTDAC", | |
| 32) // No idea what this should be (MAXES out at 63) | |
| // No idea what this should be (maxes out at 63) | |
| .add(calib_page, "INPUTDAC", 32) |
| tgt->fc().fc_setup_led(tgt_bx); | ||
| pflib_log(info) << " Target BX = " << tgt_bx << "\n"; |
There was a problem hiding this comment.
So, you change the led bx offset here but do not revert it back to the value it had before. Please add the "revert" mechanic so the led bx offset is only ever permanently updated when the user intends to update it.
| int tgt_bx = | ||
| pftool::readline_int("Target BX? (~22 should be BX = 4) ", start_led); | ||
| int len_bx = pftool::readline_int("Number of BX to scan over? ", 2); | ||
| tgt->fc().setL1AperROR(len_bx); |
There was a problem hiding this comment.
Besides sending a burst of extra L1A per ROR, we also need to inform the data collection side that it should expect multiple samples.
Lines 112 to 114 in f856638
It might be easier to just not allow users to change the number of BX being collected here and instruct them to use daq.setup.config if they want to use multi-sampling.
| // auto data = buffer.get_buffer(); | ||
| // auto mapping = tgt->getRocErxMapping(); | ||
| // auto [i_erx, i_ch] = mapping.toErxChannel(i_roc, 17); | ||
| // for (std::size_t i{0}; i < data.size(); i++) { | ||
| // for (int j = 0; j < nr_bx; j++) { | ||
| // adcs[j].push_back(data[i].samples.at(j).channel(i_erx, i_ch).adc()); | ||
| //} | ||
| //} |
There was a problem hiding this comment.
Please remove code that is now commented-out and not in use.
| // auto data = buffer.get_buffer(); | |
| // auto mapping = tgt->getRocErxMapping(); | |
| // auto [i_erx, i_ch] = mapping.toErxChannel(i_roc, 17); | |
| // for (std::size_t i{0}; i < data.size(); i++) { | |
| // for (int j = 0; j < nr_bx; j++) { | |
| // adcs[j].push_back(data[i].samples.at(j).channel(i_erx, i_ch).adc()); | |
| //} | |
| //} |
|
just adding my updates to the SPS script and plotting (more for Cristina's use); they are untested so Tom you don't really need to look at them right now, will merge again once tested |
|
|
||
| auto test_param_handle = test_param_builder.apply(); | ||
|
|
||
| <<<<<<< Updated upstream |
There was a problem hiding this comment.
These merge conflicts arose because
- You opened this PR which triggered an auto-formatting commit to be pushed
- You also edited those same files
The good news is that the auto-formatting can be re-run pretty easily, so if you want to avoid these merge conflicts in the future you can force push your commits and delete the auto-formatting commit. You can also do formatting locally or just remember to git pull before you make more changes on the branch.
This has been our attempt at UVA to make a scan that is able to take data from a large amount of LED daq_runs (measuring over multiple bunch crossings and phase_ck values).