Trouble plotting signal

Hello,

I’ve been trying to plot the signal induced on a readout strip within a Micromegas detector due to an avalanche. I’m able to plot the drift lines, however when I begin to plot the signal the debugging section continuously builds up to and repeats with
“Sensor::AddSignal: Bin -2147483648 out of range.”

The debugger does seem to print statements about each strip and their induced current, however this repeats at the end.

I’ve attached a snippet of my code

Thanks

// Begin signal plotting
    ViewSignal* signalView = nullptr;
    TCanvas* cSignal = nullptr;
    cSignal = new TCanvas("cSignal", "", 600, 600);
    signalView = new ViewSignal();
    signalView -> SetCanvas(cSignal);
    signalView -> SetSensor(&sensor);
    sensor.EnableDebugging();

    const unsigned int nTimeBins = 500;
    const double tmin = 0;
    const double tmax = 130;
    const double tstep = (tmax - tmin) / nTimeBins;
    sensor.SetTimeWindow(tmin, tstep, nTimeBins);

aval.AvalancheElectron(xi, yi, zi, ti, ei, 0, 0, -1);
        // The above is with the initial electron travelling down (direction given by last 3 coordinates)
        aval.GetAvalancheSize(ne, ni);
        std::cout << "ne = " << ne << " ni = " << ni << "\n";

        // Loop over all electrons in avalanche
        for (const auto& electron : aval.GetElectrons()) {
            // Simulate an ion drift line from the starting point of the electron
            const auto& p0 = electron.path[0];
            drift.DriftIon(p0.x, p0.y, p0.z, p0.t);

// Plotting signal 
        signalView -> PlotSignal("x3");

Hi,

Thanks for the post and welcome to the ROOT Community!

I am adding @hschindl in the loop.

Cheers,
D

Dear @Crush

I presume x3 is a readout electrode added to the sensor? From the snippet I cannot spot something obviously wrong. Can you post your full code?
Thanks a lot
Kind regards
Piet Verwilligen

Hi,
Yes it is, here is the full code.

Thanks,
Connor

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <random>

#include <TCanvas.h>
#include <TROOT.h>
#include <TApplication.h>
#include <TH1D.h>
#include <TGraph.h>
#include <TTree.h>
#include <TFile.h>
#include <TSystem.h>

#include "Garfield/ComponentFieldMap.hh"
#include "Garfield/ComponentGrid.hh"

#include "Garfield/MediumMagboltz.hh"
#include "Garfield/Medium.hh"
#include "Garfield/MediumConductor.hh"

#include "Garfield/Sensor.hh"
#include "Garfield/AvalancheMicroscopic.hh"
#include "Garfield/AvalancheMC.hh"
#include "Garfield/DriftLineRKF.hh"

#include "Garfield/ViewSignal.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/ViewDrift.hh"

#include "Garfield/Random.hh"

#include "Garfield/ComponentComsol.hh"

using namespace Garfield;

int main(int argc, char * argv[]) {


    //Directory of COMSOL field files
    std::string fileloc = "fields_smaller/";

    // Specific field files
    std::string meshfile = "mesh_smaller_new.mphtxt";
    std::string field = "field_smaller_new.txt";
    std::string materials = "materials1.dat";
    std::string gas_file = "build/Ar_90_co2_10_0.0T_293.15K.gas";

    // Directory of output CSV file
    std::string out_file = "Output/MicromegasMain.csv";

    // Specify number of readout strips in single axis
    int numReadoutstrips = 5;


    // Assign directories 
    meshfile = fileloc + meshfile;
    field = fileloc + field;
    materials = fileloc + materials;

    TApplication app("app", &argc, argv);

    // Import field map

    std::cout<<"Beginning to read COMSOL"<<"\n";

    ComponentComsol fm(meshfile, materials, field, "cm");
    fm.EnableConvergenceWarnings(false);

    std::cout<<"Done reading COMSOL"<<"\n";

    // Number of events
    int numEvents = 1;

    // Begin to implement weighting fields
    // Create vector with labels of each weighting fields 
    std::vector<std::string> w_labels;
    // Define x weighting fields
    for (int i = 0; i < numReadoutstrips; ++i) {
        w_labels.push_back("x" + std::to_string(i+1));
        continue;
    }
    // Define y weighting fields
    for (int i = 0; i < numReadoutstrips; ++i) {
        w_labels.push_back("y" + std::to_string(i+1));
        continue;

    }
    std::cout << "Done loading weighting fields, testing weighting field vector labels \n";

    for (int i = 0; i < w_labels.size(); ++i ) {
        std::cout << "Index: " << i << " is weighting label: " << w_labels[i] << "\n"; 
    }


	for (int i = 0; i < w_labels.size(); ++i) {
		std::cout<<"Reading weighting field "<<w_labels[i]<<"... \n";
        // Indicate name of file containing weighting field
		std::string w_field = fileloc+"field-"+w_labels[i]+".txt";
		
		fm.SetWeightingField(w_field, w_labels[i]);
	}





    // Import gas medium
    MediumMagboltz gas;
    gas.LoadGasFile(gas_file);
    const std::string path = std::getenv("GARFIELD_INSTALL");
  	gas.LoadIonMobility(path + "/share/Garfield/Data/IonMobility_Ar+_Ar.txt");
  	gas.LoadIonMobility(path + "/share/Garfield/Data/IonMobility_CO2+_CO2.txt");
    gas.EnableDrift();

    gas.Initialise(true);

    //assign materials to their respective domains
	const unsigned int nMaterials = fm.GetNumberOfMaterials();
  	for (unsigned int i = 0; i < nMaterials; ++i) {
    	const double eps = fm.GetPermittivity(i);
    	if (eps == 1.) fm.SetMedium(i, &gas);
    }

    // Create sensors for each electrode
    Sensor sensor;
    sensor.AddComponent(&fm);
    // Add electrodes to sensor
    for (int i = 0; i < w_labels.size(); ++i) {
        sensor.AddElectrode(&fm, w_labels[i]);
    }

    // Setup other stuff for signals
    // Want to avalanche ions
    AvalancheMC drift;
    drift.SetSensor(&sensor);
    drift.SetDistanceSteps(2.e-4);

 

    // Calculating Avalanches
    AvalancheMicroscopic aval;
    aval.SetSensor(&sensor);
    aval.UseWeightingPotential(true);

    // Begin plotting drift lines
    // ViewDrift driftView;
    // TCanvas* cDrift = new TCanvas("cDrift", "", 600, 600);
    // driftView.SetCanvas(cDrift);
    // aval.EnablePlotting(&driftView);


    // Begin drift line plotting
    ViewDrift* driftView = nullptr;
	TCanvas* cDrift = nullptr;
	cDrift = new TCanvas("cDrift", "", 600, 600);
	driftView = new ViewDrift();
	driftView->SetCanvas(cDrift);
	aval.EnablePlotting(driftView);
    drift.EnablePlotting(driftView);

    // Begin signal plotting
    ViewSignal* signalView = nullptr;
    TCanvas* cSignal = nullptr;
    cSignal = new TCanvas("cSignal", "", 600, 600);
    signalView = new ViewSignal();
    signalView -> SetCanvas(cSignal);
    signalView -> SetSensor(&sensor);
    sensor.EnableDebugging();


    // Set time binning for signal

    const unsigned int nTimeBins = 100;
    const double tmin = 0;
    const double tmax = 100;
    const double tstep = (tmax - tmin) / nTimeBins;
    sensor.SetTimeWindow(tmin, tstep, nTimeBins);

    Begin plotting signal
    ViewSignal signalView;
    TCanvas* cSignal = new TCanvas("cSignal", "", 600, 600);
    signalView.SetCanvas(cSignal);
    signalView.SetSensor(&sensor);


    // Assign values types
    int ne, ni;


    // Assign range to randomly generate numbers
    double range_from = 0.15;
    double range_to = 0.25;

    // Create a random number generator for generating large sample sizes
    std::default_random_engine generator;
    std::uniform_real_distribution<double> distribution(range_from, range_to);

    // Produce csv file to write data to
    std::ofstream ava_file(out_file);

    // Build header for csv file
    ava_file << "Testing csv file \n";


    // Begin processing events

    for (int eventInter = 0; eventInter < numEvents; ++eventInter) {
        sensor.ClearSignal(); // reset signal to 0 after each event


        std::cout << "------------ Processing Event: " << eventInter << "/" << numEvents - 1 << " ----------------\n";

        ava_file << eventInter << ",";


        // Assign initial values

        // If random values


        // If specific point
        // double xi = distribution(generator);
        double xi = 0.22;
        // double yi = distribution(generator);
        double yi = 0.22;
        double zi = 0.25;
        double ti = 0;
        double ei = 0;

        ava_file << "xi: " << xi << "," << "yi: " << yi << "," << "zi: " << zi << ",";

        // Send the electron on an avalanche 

        // std::cout << "xi = " << xi << " yi = " << yi << "\n";
        aval.AvalancheElectron(xi, yi, zi, ti, ei, 0, 0, -1);
        // The above is with the initial electron travelling down (direction given by last 3 coordinates)
        aval.GetAvalancheSize(ne, ni);
        std::cout << "ne = " << ne << " ni = " << ni << "\n";

        // Loop over all electrons in avalanche
        for (const auto& electron : aval.GetElectrons()) {
            // Simulate an ion drift line from the starting point of the electron
            const auto& p0 = electron.path[0];
            drift.DriftIon(p0.x, p0.y, p0.z, p0.t);

        }

        ava_file << "ne: " << ne << "," << "ni: " << ni << "\n";


        // Plot
        driftView.SetPlaneXZ();
        driftView.SetArea(0.15, 0.14, 0.3, 0.3);
        driftView.Plot();
        driftView -> SetPlaneXZ();
	    driftView -> SetArea(0.12, 0.14, 0.14, 0.28, 0.26, 0.2);
		driftView -> Plot(true);



        // Plotting signal related tings
        signalView -> PlotSignal("x3");


    }
    ava_file.close();

    app.Run(true);

}

Hmm… strange… I’ll try to do some debugging later today. Could you provide a minimal working example (including the field map files if needed) that reproduces the issue?
Thanks a lot!

Hello,

Do you mean just a file with the code that replicates the issue, the field files themselves are quite large (3gb each) so I’m not sure if I’ll be able to send them as well.

Thanks,
Connor

Ideally both: a piece of code that compiles and is trimmed down to the minimum that is needed to reproduce the problem; and the input files (field maps) needed to run the program. Maybe you can put them on some file sharing platform?

The fields are stored on a cluster computer and there’s about 12 of them so I may not be able to download and send them (download speed is very slow). I can however upload a txt file containing the terminal output (about 1GB), do you have an email I could send a drive link to?

I’ve attached some screenshots of some of the output, it seems to read the weighting fields alright and produce a current.
I’ve been looking through the output and I noticed that at some point the time at which the signal switches from measuring electrons to ions is the first instance of when this occurs (below is a snippet of the terminal output)

Sensor::AddSignal:   Time: 27.5455
  Step: 0.000926045
  Charge: -1
  Velocity: (-0.00824187, 0.0112089, -0.0554526)
  Electrode x1:
    Weighting potentials: 2.02459e-08, 1.15704e-12
    Induced charge: 2.02448e-08
  Electrode x2:
    Weighting potentials: 5.97177e-06, 3.41301e-10
    Induced charge: 5.97143e-06
  Electrode x3:
    Weighting potentials: 2.5941e-05, 1.48311e-09
    Induced charge: 2.59395e-05
  Electrode x4:
    Weighting potentials: 2.41109e-07, 1.37859e-11
    Induced charge: 2.41095e-07
  Electrode x5:
    Weighting potentials: 7.5441e-10, 4.31323e-14
    Induced charge: 7.54367e-10
  Electrode y1:
    Weighting potentials: 8.62015e-09, 4.92751e-13
    Induced charge: 8.61965e-09
  Electrode y2:
    Weighting potentials: 5.73714e-07, 3.2794e-11
    Induced charge: 5.73681e-07
  Electrode y3:
    Weighting potentials: 1.96683e-06, 1.12424e-10
    Induced charge: 1.96672e-06
  Electrode y4:
    Weighting potentials: 1.70683e-07, 9.75637e-12
    Induced charge: 1.70674e-07
  Electrode y5:
    Weighting potentials: 1.67947e-09, 9.60013e-14
    Induced charge: 1.67937e-09
ne = 1405 ni = 1407
Sensor::AddSignal:   Time: 0
  Step: 363.774
  Charge: 1
  Velocity: (-9.77579e-08, -4.17869e-07, 7.76268e-07)
  Electrode x1:
    Weighting potentials: 9.92987e-07, 9.95055e-07
    Induced charge: 2.0681e-09
  Electrode x2:
    Weighting potentials: 2.11202e-06, 2.11047e-06
    Induced charge: -1.54975e-09
  Electrode x3:
    Weighting potentials: 2.69709e-06, 2.69122e-06
    Induced charge: -5.86675e-09
  Electrode x4:
    Weighting potentials: 1.22747e-06, 1.22803e-06
    Induced charge: 5.56443e-10
  Electrode x5:
    Weighting potentials: 6.31085e-07, 6.32461e-07
    Induced charge: 1.37669e-09
  Electrode y1:
    Weighting potentials: 8.24469e-08, 8.26819e-08
    Induced charge: 2.35075e-10
  Electrode y2:
    Weighting potentials: 1.69569e-07, 1.6956e-07
    Induced charge: -9.03796e-12
  Electrode y3:
    Weighting potentials: 1.99414e-07, 1.98938e-07
    Induced charge: -4.76068e-10
  Electrode y4:
    Weighting potentials: 1.00941e-07, 1.00836e-07
    Induced charge: -1.04372e-10
  Electrode y5:
    Weighting potentials: 5.26492e-08, 5.27084e-08
    Induced charge: 5.92114e-11
Sensor::AddSignal: Bin 363 out of range.
Sensor::AddSignal: Bin 727 out of range.
Sensor::AddSignal: Bin 1091 out of range.
Sensor::AddSignal: Bin 1455 out of range.
Sensor::AddSignal: Bin 1818 out of range.
Sensor::AddSignal: Bin 2182 out of range.
Sensor::AddSignal: Bin 2546 out of range.
Sensor::AddSignal: Bin 2910 out of range.
Sensor::AddSignal: Bin 3273 out of range.
Sensor::AddSignal: Bin 3637 out of range.
Sensor::AddSignal: Bin 4001 out of range.
Sensor::AddSignal: Bin 4365 out of range.
Sensor::AddSignal: Bin 4729 out of range.
Sensor::AddSignal: Bin 5092 out of range.
Sensor::AddSignal: Bin 5456 out of range.
Sensor::AddSignal: Bin 5820 out of range.
Sensor::AddSignal: Bin 6184 out of range.
Sensor::AddSignal: Bin 6547 out of range.
Sensor::AddSignal: Bin 6911 out of range.
Sensor::AddSignal: Bin 7275 out of range.
Sensor::AddSignal: Bin 7639 out of range.
Sensor::AddSignal: Bin 8003 out of range.
Sensor::AddSignal: Bin 8366 out of range.
Sensor::AddSignal: Bin 8730 out of range.

This repeats for a while and eventually beings calculating the current induced by the ions (picking back up at time=27),

Sensor::AddSignal: Bin 1676124 out of range.
Sensor::AddSignal: Bin 1676488 out of range.
Sensor::AddSignal: Bin 1676852 out of range.
Sensor::AddSignal:   Time: 27.0474
  Step: 3.41903
  Charge: 1
  Velocity: (6.70946e-06, 1.1264e-05, 6.14738e-05)
  Electrode x1:
    Weighting potentials: 2.97272e-07, 2.69105e-07
    Induced charge: -2.81674e-08
  Electrode x2:
    Weighting potentials: 8.51881e-05, 7.70178e-05
    Induced charge: -8.17027e-06
  Electrode x3:
    Weighting potentials: 0.000315061, 0.00028483
    Induced charge: -3.02312e-05
  Electrode x4:
    Weighting potentials: 2.74391e-06, 2.48303e-06
    Induced charge: -2.60875e-07
  Electrode x5:
    Weighting potentials: 9.60332e-09, 8.85547e-09
    Induced charge: -7.47849e-10
  Electrode y1:
    Weighting potentials: 1.13672e-07, 1.02779e-07
    Induced charge: -1.08924e-08
  Electrode y2:
    Weighting potentials: 7.67201e-06, 6.93497e-06
    Induced charge: -7.37039e-07
  Electrode y3:
    Weighting potentials: 2.65197e-05, 2.39717e-05
    Induced charge: -2.54806e-06
  Electrode y4:
    Weighting potentials: 2.28262e-06, 2.06342e-06
    Induced charge: -2.19205e-07
  Electrode y5:
    Weighting potentials: 2.23262e-08, 2.01984e-08
    Induced charge: -2.12776e-09
Sensor::AddSignal:   Time: 30.4665
  Step: 3.51096
  Charge: 1
  Velocity: (6.93347e-06, 1.06632e-05, 4.78015e-05)
  Electrode x1:
    Weighting potentials: 2.69105e-07, 2.46817e-07
    Induced charge: -2.22876e-08
  Electrode x2:
    Weighting potentials: 7.70178e-05, 7.05616e-05
    Induced charge: -6.45621e-06
  Electrode x3:
    Weighting potentials: 0.00028483, 0.000261081
    Induced charge: -2.37493e-05
  Electrode x4:
    Weighting potentials: 2.48303e-06, 2.27845e-06
    Induced charge: -2.04584e-07
  Electrode x5:
    Weighting potentials: 8.85547e-09, 8.26508e-09
    Induced charge: -5.9039e-10
  Electrode y1:
    Weighting potentials: 1.02779e-07, 9.4196e-08
    Induced charge: -8.58325e-09
  Electrode y2:
    Weighting potentials: 6.93497e-06, 6.35395e-06
    Induced charge: -5.81012e-07
  Electrode y3:
    Weighting potentials: 2.39717e-05, 2.19626e-05
    Induced charge: -2.00907e-06
  Electrode y4:
    Weighting potentials: 2.06342e-06, 1.89063e-06
    Induced charge: -1.72782e-07
  Electrode y5:
    Weighting potentials: 2.01984e-08, 1.85214e-08
    Induced charge: -1.67699e-09
Sensor::AddSignal:   Time: 33.9774
  Step: 3.50055
  Charge: 1
  Velocity: (8.84722e-06, 8.29882e-06, 5.30424e-05)
  Electrode x1:
    Weighting potentials: 2.46817e-07, 2.22834e-07
    Induced charge: -2.39835e-08
  Electrode x2:
    Weighting potentials: 7.05616e-05, 6.3611e-05
    Induced charge: -6.95061e-06
  Electrode x3:
    Weighting potentials: 0.000261081, 0.000235425
    Induced charge: -2.56561e-05
  Electrode x4:
    Weighting potentials: 2.27845e-06, 2.05656e-06
    Induced charge: -2.21885e-07
  Electrode x5:
    Weighting potentials: 8.26508e-09, 7.6293e-09
    Induced charge: -6.35784e-10
  Electrode y1:
    Weighting potentials: 9.4196e-08, 8.49458e-08
    Induced charge: -9.25021e-09
  Electrode y2:
    Weighting potentials: 6.35395e-06, 5.72797e-06
    Induced charge: -6.25987e-07
  Electrode y3:
    Weighting potentials: 2.19626e-05, 1.97982e-05
    Induced charge: -2.16444e-06
  Electrode y4:
    Weighting potentials: 1.89063e-06, 1.70442e-06
    Induced charge: -1.8621e-07
  Electrode y5:
    Weighting potentials: 1.85214e-08, 1.6714e-08
    Induced charge: -1.80744e-09
Sensor::AddSignal:   Time: 37.478
  Step: 3.61082
  Charge: 1
  Velocity: (7.2503e-07, 1.54701e-05, 4.76024e-05)
  Electrode x1:
    Weighting potentials: 2.22834e-07, 2.01962e-07
    Induced charge: -2.08715e-08
  Electrode x2:
    Weighting potentials: 6.3611e-05, 5.75496e-05
    Induced charge: -6.06145e-06
  Electrode x3:
    Weighting potentials: 0.000235425, 0.000212695
    Induced charge: -2.27297e-05
  Electrode x4:
    Weighting potentials: 2.05656e-06, 1.85768e-06
    Induced charge: -1.98888e-07
  Electrode x5:
    Weighting potentials: 7.6293e-09, 7.06445e-09
    Induced charge: -5.64842e-10
  Electrode y1:
    Weighting potentials: 8.49458e-08, 7.68246e-08
    Induced charge: -8.12123e-09
  Electrode y2:
    Weighting potentials: 5.72797e-06, 5.17918e-06
    Induced charge: -5.48788e-07
  Electrode y3:
    Weighting potentials: 1.97982e-05, 1.79019e-05
    Induced charge: -1.89628e-06
  Electrode y4:
    Weighting potentials: 1.70442e-06, 1.54111e-06
    Induced charge: -1.63316e-07
  Electrode y5:
    Weighting potentials: 1.6714e-08, 1.51276e-08
    Induced charge: -1.58642e-09
Sensor::AddSignal:   Time: 41.0888
  Step: 3.73424
  Charge: 1
  Velocity: (5.37812e-06, 1.35388e-05, 5.31912e-05)
  Electrode x1:
    Weighting potentials: 2.01962e-07, 1.78696e-07
    Induced charge: -2.32664e-08
  Electrode x2:
    Weighting potentials: 5.75496e-05, 5.07934e-05
    Induced charge: -6.75612e-06
  Electrode x3:
    Weighting potentials: 0.000212695, 0.000187591
    Induced charge: -2.51043e-05
  Electrode x4:
    Weighting potentials: 1.85768e-06, 1.63931e-06
    Induced charge: -2.1837e-07
  Electrode x5:
    Weighting potentials: 7.06445e-09, 6.45789e-09
    Induced charge: -6.06561e-10
  Electrode y1:
    Weighting potentials: 7.68246e-08, 6.78119e-08
    Induced charge: -9.01262e-09
  Electrode y2:
    Weighting potentials: 5.17918e-06, 4.56951e-06
    Induced charge: -6.09667e-07
  Electrode y3:
    Weighting potentials: 1.79019e-05, 1.57944e-05
    Induced charge: -2.10747e-06
  Electrode y4:
    Weighting potentials: 1.54111e-06, 1.35971e-06
    Induced charge: -1.81396e-07
  Electrode y5:
    Weighting potentials: 1.51276e-08, 1.33678e-08
    Induced charge: -1.75975e-09
Sensor::AddSignal:   Time: 44.823
  Step: 3.8685
  Charge: 1
  Velocity: (1.1089e-05, 1.99654e-05, 5.01661e-05)
  Electrode x1:
    Weighting potentials: 1.78696e-07, 1.55703e-07
    Induced charge: -2.29924e-08
  Electrode x2:
    Weighting potentials: 5.07934e-05, 4.41428e-05
    Induced charge: -6.6506e-06
  Electrode x3:
    Weighting potentials: 0.000187591, 0.000163132
    Induced charge: -2.44588e-05
  Electrode x4:
    Weighting potentials: 1.63931e-06, 1.42754e-06
    Induced charge: -2.11763e-07
  Electrode x5:
    Weighting potentials: 6.45789e-09, 5.84109e-09
    Induced charge: -6.16802e-10
  Electrode y1:
    Weighting potentials: 6.78119e-08, 5.89774e-08
    Induced charge: -8.83452e-09
  Electrode y2:
    Weighting potentials: 4.56951e-06, 3.9717e-06
    Induced charge: -5.97813e-07
  Electrode y3:
    Weighting potentials: 1.57944e-05, 1.37274e-05
    Induced charge: -2.06707e-06
  Electrode y4:
    Weighting potentials: 1.35971e-06, 1.18191e-06
    Induced charge: -1.77806e-07
  Electrode y5:
    Weighting potentials: 1.33678e-08, 1.16412e-08
    Induced charge: -1.72656e-09
Sensor::AddSignal:   Time: 48.6915
  Step: 3.9463
  Charge: 1
  Velocity: (5.39726e-06, 1.56328e-05, 5.13843e-05)
  Electrode x1:
    Weighting potentials: 1.55703e-07, 1.33324e-07
    Induced charge: -2.23792e-08
  Electrode x2:
    Weighting potentials: 4.41428e-05, 3.76508e-05
    Induced charge: -6.49207e-06
  Electrode x3:
    Weighting potentials: 0.000163132, 0.000139033
    Induced charge: -2.4099e-05
  Electrode x4:
    Weighting potentials: 1.42754e-06, 1.21754e-06
    Induced charge: -2.10001e-07
  Electrode x5:
    Weighting potentials: 5.84109e-09, 5.25259e-09
    Induced charge: -5.88496e-10
  Electrode y1:
    Weighting potentials: 5.89774e-08, 5.03236e-08
    Induced charge: -8.65379e-09
  Electrode y2:
    Weighting potentials: 3.9717e-06, 3.38636e-06
    Induced charge: -5.85337e-07
  Electrode y3:
    Weighting potentials: 1.37274e-05, 1.17039e-05
    Induced charge: -2.02347e-06
  Electrode y4:
    Weighting potentials: 1.18191e-06, 1.00773e-06
    Induced charge: -1.74178e-07
  Electrode y5:
    Weighting potentials: 1.16412e-08, 9.95097e-09
    Induced charge: -1.69028e-09
Sensor::AddSignal:   Time: 52.6378
  Step: 4.01337
  Charge: 1
  Velocity: (1.52732e-05, 1.97703e-05, 4.16206e-05)
  Electrode x1:
    Weighting potentials: 1.33324e-07, 1.14014e-07
    Induced charge: -1.93095e-08
  Electrode x2:
    Weighting potentials: 3.76508e-05, 3.20823e-05
    Induced charge: -5.56852e-06
  Electrode x3:
    Weighting potentials: 0.000139033, 0.000118657
    Induced charge: -2.03762e-05
  Electrode x4:
    Weighting potentials: 1.21754e-06, 1.04137e-06
    Induced charge: -1.76172e-07
  Electrode x5:
    Weighting potentials: 5.25259e-09, 4.7178e-09
    Induced charge: -5.34798e-10
  Electrode y1:
    Weighting potentials: 5.03236e-08, 4.29416e-08
    Induced charge: -7.38206e-09
  Electrode y2:
    Weighting potentials: 3.38636e-06, 2.88687e-06
    Induced charge: -4.99495e-07
  Electrode y3:
    Weighting potentials: 1.17039e-05, 9.97646e-06
    Induced charge: -1.72742e-06
  Electrode y4:
    Weighting potentials: 1.00773e-06, 8.5917e-07
    Induced charge: -1.48559e-07
  Electrode y5:
    Weighting potentials: 9.95097e-09, 8.50676e-09
    Induced charge: -1.44421e-09
Sensor::AddSignal:   Time: 56.6512
  Step: 4.26886
  Charge: 1
  Velocity: (3.49398e-06, 1.81889e-05, 4.34766e-05)
  Electrode x1:
    Weighting potentials: 1.14014e-07, 9.56843e-08
    Induced charge: -1.83302e-08
  Electrode x2:
    Weighting potentials: 3.20823e-05, 2.67717e-05
    Induced charge: -5.31052e-06
  Electrode x3:
    Weighting potentials: 0.000118657, 9.88838e-05
    Induced charge: -1.97731e-05
  Electrode x4:
    Weighting potentials: 1.04137e-06, 8.6841e-07
    Induced charge: -1.72959e-07
  Electrode x5:
    Weighting potentials: 4.7178e-09, 4.21935e-09
    Induced charge: -4.98448e-10
  Electrode y1:
    Weighting potentials: 4.29416e-08, 3.58525e-08
    Induced charge: -7.08905e-09
  Electrode y2:
    Weighting potentials: 2.88687e-06, 2.40769e-06
    Induced charge: -4.79175e-07
  Electrode y3:
    Weighting potentials: 9.97646e-06, 8.32026e-06
    Induced charge: -1.6562e-06
  Electrode y4:
    Weighting potentials: 8.5917e-07, 7.16567e-07
    Induced charge: -1.42603e-07
  Electrode y5:
    Weighting potentials: 8.50676e-09, 7.12129e-09
    Induced charge: -1.38547e-09
Sensor::AddSignal:   Time: 60.9201
  Step: 4.57617
  Charge: 1
  Velocity: (2.70049e-06, 2.52396e-05, 4.50418e-05)
  Electrode x1:
    Weighting potentials: 9.56843e-08, 7.61109e-08
    Induced charge: -1.95734e-08
  Electrode x2:
    Weighting potentials: 2.67717e-05, 2.11257e-05
    Induced charge: -5.64604e-06
  Electrode x3:
    Weighting potentials: 9.88838e-05, 7.78664e-05
    Induced charge: -2.10174e-05
  Electrode x4:
    Weighting potentials: 8.6841e-07, 6.8422e-07
    Induced charge: -1.8419e-07
  Electrode x5:
    Weighting potentials: 4.21935e-09, 3.64516e-09
    Induced charge: -5.74187e-10
  Electrode y1:
    Weighting potentials: 3.58525e-08, 2.83109e-08
    Induced charge: -7.54162e-09
  Electrode y2:
    Weighting potentials: 2.40769e-06, 1.8984e-06
    Induced charge: -5.0929e-07
  Electrode y3:
    Weighting potentials: 8.32026e-06, 6.56014e-06
    Induced charge: -1.76012e-06
  Electrode y4:
    Weighting potentials: 7.16567e-07, 5.65003e-07
    Induced charge: -1.51564e-07
  Electrode y5:
    Weighting potentials: 7.12129e-09, 5.64463e-09
    Induced charge: -1.47667e-09
Sensor::AddSignal:   Time: 65.4962
  Step: 4.90378
  Charge: 1
  Velocity: (9.2593e-06, 2.75891e-05, 3.58187e-05)
  Electrode x1:
    Weighting potentials: 7.61109e-08, 5.78174e-08
    Induced charge: -1.82935e-08
  Electrode x2:
    Weighting potentials: 2.11257e-05, 1.58933e-05
    Induced charge: -5.23236e-06
  Electrode x3:
    Weighting potentials: 7.78664e-05, 5.85075e-05
    Induced charge: -1.93589e-05
  Electrode x4:
    Weighting potentials: 6.8422e-07, 5.14854e-07
    Induced charge: -1.69365e-07
  Electrode x5:
    Weighting potentials: 3.64516e-09, 3.04265e-09
    Induced charge: -6.02507e-10
  Electrode y1:
    Weighting potentials: 2.83109e-08, 2.13305e-08
    Induced charge: -6.98042e-09
  Electrode y2:
    Weighting potentials: 1.8984e-06, 1.42752e-06
    Induced charge: -4.70886e-07
  Electrode y3:
    Weighting potentials: 6.56014e-06, 4.93254e-06
    Induced charge: -1.6276e-06
  Electrode y4:
    Weighting potentials: 5.65003e-07, 4.24883e-07
    Induced charge: -1.4012e-07
  Electrode y5:
    Weighting potentials: 5.64463e-09, 4.27298e-09
    Induced charge: -1.37165e-09
Sensor::AddSignal:   Time: 70.4
  Step: 5.0092
  Charge: 1
  Velocity: (6.68791e-06, 2.88135e-05, 2.73478e-05)
  Electrode x1:
    Weighting potentials: 5.78174e-08, 4.24315e-08
    Induced charge: -1.53859e-08
  Electrode x2:
    Weighting potentials: 1.58933e-05, 1.15609e-05
    Induced charge: -4.33239e-06
  Electrode x3:
    Weighting potentials: 5.85075e-05, 4.25336e-05
    Induced charge: -1.59739e-05
  Electrode x4:
    Weighting potentials: 5.14854e-07, 3.74916e-07
    Induced charge: -1.39939e-07
  Electrode x5:
    Weighting potentials: 3.04265e-09, 2.41776e-09
    Induced charge: -6.24889e-10
  Electrode y1:
    Weighting potentials: 2.13305e-08, 1.55412e-08
    Induced charge: -5.7893e-09
  Electrode y2:
    Weighting potentials: 1.42752e-06, 1.03813e-06
    Induced charge: -3.8939e-07
  Electrode y3:
    Weighting potentials: 4.93254e-06, 3.58674e-06
    Induced charge: -1.3458e-06
  Electrode y4:
    Weighting potentials: 4.24883e-07, 3.0901e-07
    Induced charge: -1.15873e-07
  Electrode y5:
    Weighting potentials: 4.27298e-09, 3.12694e-09
    Induced charge: -1.14604e-09
Sensor::AddSignal:   Time: 75.4092
  Step: 5.36053
  Charge: 1
  Velocity: (-1.24287e-06, 2.19313e-05, 2.76907e-05)
  Electrode x1:
    Weighting potentials: 4.24315e-08, 2.96825e-08
    Induced charge: -1.27489e-08
  Electrode x2:
    Weighting potentials: 1.15609e-05, 7.98078e-06
    Induced charge: -3.58016e-06
  Electrode x3:
    Weighting potentials: 4.25336e-05, 2.92848e-05
    Induced charge: -1.32487e-05
  Electrode x4:
    Weighting potentials: 3.74916e-07, 2.58514e-07
    Induced charge: -1.16401e-07
  Electrode x5:
    Weighting potentials: 2.41776e-09, 1.87601e-09
    Induced charge: -5.41756e-10
  Electrode y1:
    Weighting potentials: 1.55412e-08, 1.07462e-08
    Induced charge: -4.79503e-09
  Electrode y2:
    Weighting potentials: 1.03813e-06, 7.15928e-07
    Induced charge: -3.22198e-07
  Electrode y3:
    Weighting potentials: 3.58674e-06, 2.47333e-06
    Induced charge: -1.11341e-06
  Electrode y4:
    Weighting potentials: 3.0901e-07, 2.13114e-07
    Induced charge: -9.58963e-08
  Electrode y5:
    Weighting potentials: 3.12694e-09, 2.1761e-09
    Induced charge: -9.50836e-10
Sensor::AddSignal:   Time: 80.7697
  Step: 6.09939
  Charge: 1
  Velocity: (7.69949e-06, 3.09372e-05, 1.39417e-05)
  Electrode x1:
    Weighting potentials: 2.96825e-08, 1.5068e-08
    Induced charge: -1.46146e-08
  Electrode x2:
    Weighting potentials: 7.98078e-06, 4.03747e-06
    Induced charge: -3.94331e-06
  Electrode x3:
    Weighting potentials: 2.92848e-05, 1.48409e-05
    Induced charge: -1.44439e-05
  Electrode x4:
    Weighting potentials: 2.58514e-07, 1.31259e-07
    Induced charge: -1.27255e-07
  Electrode x5:
    Weighting potentials: 1.87601e-09, 9.80217e-10
    Induced charge: -8.95791e-10
  Electrode y1:
    Weighting potentials: 1.07462e-08, 5.44468e-09
    Induced charge: -5.30147e-09
  Electrode y2:
    Weighting potentials: 7.15928e-07, 3.62397e-07
    Induced charge: -3.53531e-07
  Electrode y3:
    Weighting potentials: 2.47333e-06, 1.25187e-06
    Induced charge: -1.22146e-06
  Electrode y4:
    Weighting potentials: 2.13114e-07, 1.07891e-07
    Induced charge: -1.05223e-07
  Electrode y5:
    Weighting potentials: 2.1761e-09, 1.10462e-09
    Induced charge: -1.07149e-09
Sensor::AddSignal:   Time: 86.8691
  Step: 5.62026
  Charge: 1
  Velocity: (9.93988e-06, 2.525e-05, 1.16393e-05)
  Electrode x1:
    Weighting potentials: 1.5068e-08, 3.50735e-09
    Induced charge: -1.15606e-08
  Electrode x2:
    Weighting potentials: 4.03747e-06, 9.38805e-07
    Induced charge: -3.09866e-06
  Electrode x3:
    Weighting potentials: 1.48409e-05, 3.46054e-06
    Induced charge: -1.13804e-05
  Electrode x4:
    Weighting potentials: 1.31259e-07, 3.06675e-08
    Induced charge: -1.00591e-07
  Electrode x5:
    Weighting potentials: 9.80217e-10, 2.3099e-10
    Induced charge: -7.49227e-10
  Electrode y1:
    Weighting potentials: 5.44468e-09, 1.2679e-09
    Induced charge: -4.17678e-09
  Electrode y2:
    Weighting potentials: 3.62397e-07, 8.43475e-08
    Induced charge: -2.7805e-07
  Electrode y3:
    Weighting potentials: 1.25187e-06, 2.91344e-07
    Induced charge: -9.60527e-07
  Electrode y4:
    Weighting potentials: 1.07891e-07, 2.51153e-08
    Induced charge: -8.2776e-08
  Electrode y5:
    Weighting potentials: 1.10462e-09, 2.57423e-10
    Induced charge: -8.47192e-10
Sensor::AddSignal:   Time: 92.4894
  Step: 5.09033
  Charge: 1
  Velocity: (2.30661e-06, 3.8369e-05, 9.37174e-06)
  Electrode x1:
    Weighting potentials: 3.50735e-09, 0
    Induced charge: -3.50735e-09
  Electrode x2:
    Weighting potentials: 9.38805e-07, 0
    Induced charge: -9.38805e-07
  Electrode x3:
    Weighting potentials: 3.46054e-06, 0
    Induced charge: -3.46054e-06
  Electrode x4:
    Weighting potentials: 3.06675e-08, 0
    Induced charge: -3.06675e-08
  Electrode x5:
    Weighting potentials: 2.3099e-10, 0
    Induced charge: -2.3099e-10
  Electrode y1:
    Weighting potentials: 1.2679e-09, 0
    Induced charge: -1.2679e-09
  Electrode y2:
    Weighting potentials: 8.43475e-08, 0
    Induced charge: -8.43475e-08
  Electrode y3:
    Weighting potentials: 2.91344e-07, 0
    Induced charge: -2.91344e-07
  Electrode y4:
    Weighting potentials: 2.51153e-08, 0
    Induced charge: -2.51153e-08
  Electrode y5:
    Weighting potentials: 2.57423e-10, 0
    Induced charge: -2.57423e-10
Sensor::AddSignal:   Time: 97.5797
  Step: 585.474
  Charge: 1
  Velocity: (-5.44921e-07, 1.71457e-07, 2.10692e-07)
  Electrode x1:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode x2:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode x3:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode x4:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode x5:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode y1:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode y2:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode y3:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode y4:
    Weighting potentials: 0, 0
    Induced charge: 0
  Electrode y5:
    Weighting potentials: 0, 0
    Induced charge: 0
Sensor::AddSignal: Bin 683 out of range.
Sensor::AddSignal: Bin 1268 out of range.
Sensor::AddSignal: Bin 1854 out of range.
Sensor::AddSignal: Bin 1859 out of range.
Sensor::AddSignal: Bin 2445 out of range.
Sensor::AddSignal: Bin 2455 out of range.
Sensor::AddSignal: Bin 2464 out of range.
Sensor::AddSignal: Bin 3050 out of range.
Sensor::AddSignal: Bin 3635 out of range.
Sensor::AddSignal: Bin 4221 out of range.
Sensor::AddSignal: Bin 4806 out of range.
Sensor::AddSignal: Bin 5392 out of range.
Sensor::AddSignal: Bin 5977 out of range.
Sensor::AddSignal: Bin 6563 out of range.
Sensor::AddSignal: Bin 7148 out of range.
Sensor::AddSignal: Bin 7734 out of range.
Sensor::AddSignal: Bin 8319 out of range.
Sensor::AddSignal: Bin 8905 out of range.
Sensor::AddSignal: Bin 9490 out of range.
Sensor::AddSignal: Bin 9513 out of range.
Sensor::AddSignal: Bin 10099 out of range.
Sensor::AddSignal: Bin 10684 out of range.
Sensor::AddSignal: Bin 11270 out of range.
Sensor::AddSignal: Bin 11855 out of range.
Sensor::AddSignal: Bin 12441 out of range.

At which point it repeats endlessly again. This was with a total of 100 bins between 0 and 100 (1 bin per ns I assume) could this be the issue?

Thanks,

Connor
MicromegasMain.cpp (8.2 KB)

I also just ran the code and excluded the ion drift (plotting only the signal contributed by the electrons) and I seem to get a decent looking graph with none of these bin out of range errors.

Maybe I need to change something with the ion signal?

Dear @Crush

For sure for the ion signal you would need a much longer time window to record something meaningful. I do not know your geometry and your (drift) fields, but you should consider as a rule of thumb about 1000x the time for electrondrift. Can you do a test with a time window of about 10 or 100us and see if the problem repeats when you have the ion signal included. I believe you can also make separate plots for electron signal and ion signal, so that would be useful to do as you would like to have a higher precision zoom on the electron signal in the [0-100ns] range.

Moreover I notice you load both Ar+ in Ar and CO2+ in CO2. Only the latter is effectively loaded (you overwrite the first one), which is ok, because in Ar:CO2 mixtures we have mostly CO2+ drifting in the Ar:CO2 mixture. The CO2+ in (100%) CO2 comes pretty close to the reality:

greets
Piet

Hi Piet,

I didn’t know that, I’ll make the adjustments and give it another test.

Thankyou very much!

Hi Piet,

Increasing the maximum did the trick, thankyou very much for the help.

As a side note, I noticed the signal itself included a slight drop in to the negatives, I assumed the positive ions drifting away from the readout strips would induce a positive signal?

Thanks,

Connor

Positive ions drifting away from a readout electrode will typically induce a negative signal. Suppose you have an unsegmented parallel-plate chamber. Then the electron-collecting electrode will see a negative induced current from the electrons drifting towards it and the positive ions drifting away from it (and the opposite on the other electrode).

Thankyou for your response,

In my case the anode structure is placed above the readout strips, so from the perspective of the readout strips there are both electrons moving towards and ions drifting away ( in the z direction). Would this mean I would expect the same polarity of signal induced by both? From the graph it seems I have a positive signal from the electrons and negative from the ions. These readout strips are also connected to ground.

I was just thinking that if initially all of the electrons are drifting towards the anode (in the -z direction) would this not induce a negative signal on the readout strips, and that this signal would have the same polarity as those ions drifting in the +z direction.

Dear @Crush

I was a bit puzzled by the polarity of your signal and the negative fluke in your ion tail, I was also not quite understanding your structure. In a “typical” micromegas, the electrons moving toward the readout pads/strips and the positive ions moving away from the readout pad/strips create a signal with negative polarity, see here the figure below from [1]:

You can see a very quick (3ns) peak due to fast moving electrons and a slower (120ns) peak due to slower moving ions.

If I assume now that your “anode structure” is the mesh which you read out to obtain this signal:

then this signal should be nearly identical and opposite to the signal one can see from the readout pads/strips. I can interpret this fast positive peak due to the negative electrons moving away from the mesh, and the slow positive peak due to positive ions moving towards the mesh. The small negative fluke can then be explained as a certain fraction of positive ions that are not “collected” on the mesh, but pass through the mesh and continue to drift away (and now they are positive charges moving away instead of moving towards your mesh) towards the drift electrode and those would induce a negative signal on the mesh.

greets
Piet

[1] A. Utrobicic et al. Single channel PICOSEC Micromegas detector with
improved time resolution, https://arxiv.org/pdf/2406.05657

Hi Piet,

After reading other sorts of literature I had expected a signal similar to what you have posted, but am left completely puzzled by my results.

The readout structure is actually a pattern of segmented copper strips below the anode strips, I’ve attached an image to better explain what I mean, as well as an example of one of the weighting fields (Anode resistive strips are at z=0.15 cm and x readout strips at z=0.1 cm).


I figured the electrons drifting down towards the anode strips and the ions drifting up towards the mesh would produce the same polarity on the readout strips. But maybe as the readout strips are below the anode strips that’s what’s causing the positive polarity?

I’ve also attached an image of the induced current and integrated charge, the charge looks familiar to the picture you attached.


As another note, these tables were generated for a gain of ~60,000, but I feel like this signal is very small for what I would expect, does this seem right?

Thanks,
Connor