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

CSADigitizer: use TFormula directly instead of TF1

parent 1b28e423
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#include "core/utils/unit.h"
#include "tools/ROOT.h"

#include <TF1.h>
#include <TFile.h>
#include <TGraph.h>
#include <TH1D.h>
@@ -84,8 +83,8 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        auto capacitance_feedback = config_.get<double>("feedback_capacitance");
        auto resistance_feedback = tauF / capacitance_feedback;

        calculate_impulse_response_ = std::make_unique<TF1>(
            "response_function", "[0]*(TMath::Exp(-x/[1])-TMath::Exp(-x/[2]))/([1]-[2])", 0., integration_time_);
        calculate_impulse_response_ =
            std::make_unique<TFormula>("response_function", "[0]*(TMath::Exp(-x/[1])-TMath::Exp(-x/[2]))/([1]-[2])");
        calculate_impulse_response_->SetParameters(resistance_feedback, tauF, tauR);

        LOG(DEBUG) << "Parameters: cf = " << Units::display(capacitance_feedback, {"C/V", "fC/mV"})
@@ -114,8 +113,8 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        auto tauF = resistance_feedback * capacitance_feedback;
        auto tauR = (capacitance_detector * capacitance_output) / (gm * capacitance_feedback);

        calculate_impulse_response_ = std::make_unique<TF1>(
            "response_function", "[0]*(TMath::Exp(-x/[1])-TMath::Exp(-x/[2]))/([1]-[2])", 0., integration_time_);
        calculate_impulse_response_ =
            std::make_unique<TFormula>("response_function", "[0]*(TMath::Exp(-x/[1])-TMath::Exp(-x/[2]))/([1]-[2])");
        calculate_impulse_response_->SetParameters(resistance_feedback, tauF, tauR);

        LOG(DEBUG) << "Parameters: rf = " << Units::display(resistance_feedback, "V*s/C")
@@ -127,8 +126,8 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
                   << ", tauR = " << Units::display(tauR, {"ns", "us", "ms", "s"})
                   << ", temperature = " << Units::display(config_.get<double>("temperature"), "K");
    } else if(model_ == DigitizerType::CUSTOM) {
        calculate_impulse_response_ = std::make_unique<TF1>(
            "response_function", (config_.get<std::string>("response_function")).c_str(), 0., integration_time_);
        calculate_impulse_response_ =
            std::make_unique<TFormula>("response_function", (config_.get<std::string>("response_function")).c_str());

        if(!calculate_impulse_response_->IsValid()) {
            throw InvalidValueError(
@@ -138,7 +137,7 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        auto parameters = config_.getArray<double>("response_parameters");

        // check if number of parameters match up
        if(static_cast<size_t>(calculate_impulse_response_->GetNumberFreeParameters()) != parameters.size()) {
        if(static_cast<size_t>(calculate_impulse_response_->GetNpar()) != parameters.size()) {
            throw InvalidValueError(
                config_,
                "response_parameters",
@@ -152,6 +151,9 @@ CSADigitizerModule::CSADigitizerModule(Configuration& config, Messenger* messeng
        LOG(DEBUG) << "Response function successfully initialized with " << parameters.size() << " parameters";
    }

    // Compile Lambda expression using Cling:
    calculate_impulse_response_->Compile();

    output_plots_ = config_.get<bool>("output_plots");
    output_pulsegraphs_ = config_.get<bool>("output_pulsegraphs");

+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@

#include "objects/PixelCharge.hpp"

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

@@ -77,7 +77,7 @@ namespace allpix {
        DigitizerType model_;

        // Function to calculate impulse response
        std::unique_ptr<TF1> calculate_impulse_response_;
        std::unique_ptr<TFormula> calculate_impulse_response_;

        // Parameters of the electronics: Noise, time-over-threshold logic
        double sigmaNoise_{}, clockToT_{}, clockToA_{}, threshold_{};