I am working on a project involving a beam irradiate a reference sample. The goal is to study the resulting fluorescence detected by a detector located perpendicular to the beam. I want to observe the X-ray lines of the chemical element in the sample, similar to the ones shown in the following image.
But i am not sure how to extract the energy spectrum from a data.root file produced by Allpix squared to obtain such X-ray spectra? I have tried some methods such as:
TH1D* spectrum = new TH1D("spectrum", "PixelHit signal spectrum; signal; hits", 20000, 0, 10000);
for(auto& hit : input_hits) spectrum->Fill(hit->getSignal());
I would say you’re on the right track. There’s a few remarks I would make …
The question whether to use the PixelHit signal or the PixelCharge charge results in the question of what you’re interested in. The PixelHit information has one more step in between, which is the front end simulation, including noise and threshold effects. So if you’d like to get a realistic detector response, the PixelHit signal is the better observable, and if you’re more interested in a MC truth information, you could even go further back and sum deposited charges.
Depending on the beam properties, you could in addition browse the hits/charges per event and combine hits in adjacent pixels (clustering). This prevents from artefacts in the spectrum from charge sharing.
What’s still missing to the X-ray spectrum is the conversion from “signal” or charge to actual deposited energy. For the charge->energy conversion the charge creation energy is the relevant parameter, for a signal->energy conversion you’d need to have a closer look to the digitisation parameters.