Commit ea552ad4 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'digi' into 'master'

Digi

See merge request allpix-squared/allpix-squared!1158
parents a8e92b25 e18b866b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ The following authors, in alphabetical order, have developed or contributed to A
* Sebastian Schmidt, FAU Erlangen, [schmidtseb](https://github.com/schmidtseb)
* Sanchit Sharma, Kansas State University, [SanchitKratos](https://github.com/SanchitKratos)
* Xin Shi, Institute of High Energy Physics Beijing, [xshi](https://gitlab.cern.ch/xshi)
* Petja Skomina, Nikhef, [pskomina](https://gitlab.cern.ch/pskomina)
* Petr Smolyanskiy, Czech Technical Univbersity Prague, [psmolyan](https://gitlab.cern.ch/psmolyan)
* Viktor Sonesten, GSOC2018 Student, [tmplt](https://github.com/tmplt)
* Reem Taibah, Université de Paris, [retaibah](https://gitlab.cern.ch/retaibah)
+17 −2
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        config_.setDefault<double>("transconductance", Units::get(50e-6, "C/s/V"));
        config_.setDefault<double>("weak_inversion_slope", 1.5);
        config_.setDefault<double>("temperature", 293.15);
    } else if(model_ == DigitizerType::GRAPH) {
        config_.setDefault<double>("graph_time_unit_", Units::get(1, "s"));
    }

    // Copy some variables from configuration to avoid lookups:
@@ -167,6 +169,10 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        }

        LOG(DEBUG) << "Response function successfully initialized with " << parameters.size() << " parameters";
    } else if(model_ == DigitizerType::GRAPH) {
        const auto graph_path = config_.getPath("graph_file", true);
        graph_impulse_response_ = std::make_unique<TGraph>(graph_path.c_str(), "%lg,%lg");
        graph_time_unit_ = config_.get<double>("graph_time_unit");
    }

    output_plots_ = config_.get<bool>("output_plots");
@@ -247,8 +253,16 @@ void CSADigitizerModule::run(Event* event) {
            // initialize impulse response function - assume all time bins are equal
            impulse_response_function_.reserve(ntimepoints);
            for(size_t itimepoint = 0; itimepoint < ntimepoints; ++itimepoint) {
                if(model_ != DigitizerType::GRAPH) {
                    impulse_response_function_.push_back(
                        calculate_impulse_response_->Eval(timestep * static_cast<double>(itimepoint)));
                } else {
                    LOG(TRACE) << timestep * static_cast<double>(itimepoint) << ", "
                               << graph_impulse_response_->Eval(timestep * static_cast<double>(itimepoint) /
                                                                graph_time_unit_);
                    impulse_response_function_.push_back(
                        graph_impulse_response_->Eval(timestep * static_cast<double>(itimepoint) / graph_time_unit_));
                }
            }

            if(output_plots_) {
@@ -264,6 +278,7 @@ void CSADigitizerModule::run(Event* event) {
                response_graph->GetYaxis()->SetTitle("amp. response");
                response_graph->SetTitle("Amplifier response function");
                getROOTDirectory()->WriteTObject(response_graph, "response_function");
                getROOTDirectory()->WriteTObject(graph_impulse_response_.get(), "graph_impulse_response");
            }

            LOG(INFO) << "Initialized impulse response with timestep " << Units::display(timestep, {"ps", "ns", "us"})
+6 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "objects/PixelCharge.hpp"

#include <TFormula.h>
#include <TGraph.h>
#include <TH1D.h>
#include <TH2D.h>

@@ -44,6 +45,7 @@ namespace allpix {
            SIMPLE, ///< Simplified parametrisation
            CSA,    ///< Enter all contributions to the transfer function as parameters
            CUSTOM, ///< Custom impulse response function using a ROOT::TFormula expression
            GRAPH,  ///< External graph in .csv format
        };

    public:
@@ -79,6 +81,10 @@ namespace allpix {

        // Function to calculate impulse response
        std::unique_ptr<TFormula> calculate_impulse_response_;
        // Graph to store interpolated data points as response function
        std::unique_ptr<TGraph> graph_impulse_response_;
        // Time unit on the response function graph
        double graph_time_unit_;

        // Parameters of the electronics: Noise, time-over-threshold logic
        double sigmaNoise_{}, clockToT_{}, clockToA_{}, threshold_{};
+15 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ If this behavior is not desired, the `ignore_polarity` parameter can be set to c

## Parameters

* `model`: Choice between different CSA models. Currently implemented are two parametrizations of the circuit from \[[@kleczek]\], `simple` and `csa`, and the `custom` model for a custom impulse response.
* `model`: Choice between different CSA models. Currently implemented are two parametrizations of the circuit from \[[@kleczek]\], `simple` and `csa`, the `custom` model for a custom impulse response, and the `graph` model, which takes a .csv file as input and reads out the graph of the transfer function.
* `integration_time`: The length of time the amplifier output is registered. Defaults to 500 ns.
* `sigma_noise`: Standard deviation of the Gaussian-distributed noise added to the output signal. Defaults to 0.1 mV.
* `threshold`: Threshold for TOT/TOA logic, for considering the output signal as a hit. Defaults to 10mV.
@@ -79,6 +79,12 @@ If this behavior is not desired, the `ignore_polarity` parameter can be set to c
* `response_function`: A 1-dimensional `ROOT::TFormula` \[[@rootformula]\] expression for the impulse response function.
* `response_parameters`: Array of the parameters in the response function. The number of parameters given need to match up with the number of parameters in the formula.

### Parameters for the graph model

* `graph_file`: The path to the .csv file containing the graph of the response function.
* The file should be written in the following format: `x,y` (comma separated values), where x is the time and y the amplitude of the response function at that time point. Each pair of values should be written in a new line.
* `graph_time_unit`: Time unit in which the time on the response function graph is expressed. Should be a double.

### Plotting parameters

* `output_plots`: Enables simple output histograms to be generated from the data in every step (slows down simulation considerably). Disabled by default.
@@ -132,6 +138,14 @@ clock_bin_toa = 8ns
clock_bin_tot = 8ns
```

Example for the `graph` model:
```ini
[CSADigitizer]
model = "graph"
graph_file = /path/to/response_function.csv
integration_time = 10ns
graph_time_unit = 1s
```

[@kleczek]: https://doi.org/10.1109/MIXDES.2015.7208529
[@binkley]: https://doi.org/10.1002/9780470033715