ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonDigitization
MM_Digitization
src
MM_ElectronicsResponseSimulation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
10
#include "
MM_Digitization/MM_ElectronicsResponseSimulation.h
"
11
12
#include <numeric>
13
14
#include "
AthenaKernel/getMessageSvc.h
"
15
#include "GaudiKernel/MsgStream.h"
16
#include "TF1.h"
17
18
#include "CLHEP/Random/RandGaussZiggurat.h"
19
20
/*******************************************************************************/
21
MM_ElectronicsResponseSimulation::MM_ElectronicsResponseSimulation
(
ConfigModule
&& module):
22
m_cfg
{
std
::move(module)} {
23
// let the VMM peak search run in a wider window in order to simulate the dead time and to avoid a bug at the upper limit of the time
24
// window
25
m_vmmShaper
=
26
std::make_unique<VMM_Shaper>(
m_cfg
.peakTime,
m_cfg
.timeWindowLowerOffset -
m_cfg
.vmmDeadtime,
m_cfg
.timeWindowUpperOffset +
m_cfg
.vmmUpperGrazeWindow);
27
m_vmmShaper
->initialize();
28
}
29
/*******************************************************************************/
30
MM_DigitToolOutput
MM_ElectronicsResponseSimulation::getPeakResponseFrom
(
const
MM_ElectronicsToolInput
& digiInput)
const
{
31
DataCache
cache{};
32
vmmPeakResponseFunction
(cache, digiInput);
33
35
// MM_DigitToolOutput(bool hitWasEff, std::vector <int> strpos, std::vector<float> time, std::vector<int> charge, std::vector<float>
36
// threshold, int strTrig, float strTimeTrig ):
37
MM_DigitToolOutput
to_ret{
true
, std::move(cache.nStripElectronics),
38
std::move(cache.tStripElectronicsAbThr),
39
std::move(cache.qStripElectronics), 5, 0.3};
40
41
return
to_ret;
42
}
43
/*******************************************************************************/
44
MM_DigitToolOutput
MM_ElectronicsResponseSimulation::getThresholdResponseFrom
(
const
MM_ElectronicsToolInput
& digiInput)
const
{
45
DataCache
cache{};
46
vmmThresholdResponseFunction
(cache, digiInput);
47
MM_DigitToolOutput
to_ret{
true
, std::move(cache.nStripElectronics),
48
std::move(cache.tStripElectronicsAbThr),
49
std::move(cache.qStripElectronics), 5, 0.3};
50
return
to_ret;
51
}
52
/*******************************************************************************/
53
void
MM_ElectronicsResponseSimulation::vmmPeakResponseFunction
(
DataCache
& cache,
const
MM_ElectronicsToolInput
& digiInput)
const
{
54
55
56
const
std::vector<int>& numberofStrip = digiInput.
NumberOfStripsPos
();
57
const
std::vector<std::vector<float>>& qStrip = digiInput.
chipCharge
();
58
const
std::vector<std::vector<float>>& tStrip = digiInput.
chipTime
();
59
const
std::vector<float>& stripsElectronicsThreshold = digiInput.
stripThreshold
();
60
61
for
(
unsigned
int
ii = 0; ii < numberofStrip.size(); ii++) {
62
// find min and max times for each strip:
63
bool
thisStripFired{
false
};
64
double
leftStripFired =
false
;
65
double
rightStripFired =
false
;
66
67
// find the maximum charge:
68
if
(
m_cfg
.useNeighborLogic) {
// only check neighbor strips if VMM neighbor logic is enabled
69
if
(ii > 0) {
70
leftStripFired =
71
m_vmmShaper
->hasChargeAboveThreshold(qStrip.at(ii - 1), tStrip.at(ii - 1), stripsElectronicsThreshold.at(ii - 1));
72
}
73
74
if
(ii + 1 < numberofStrip.size()) {
75
rightStripFired =
76
m_vmmShaper
->hasChargeAboveThreshold(qStrip.at(ii + 1), tStrip.at(ii + 1), stripsElectronicsThreshold.at(ii + 1));
77
}
78
}
79
80
thisStripFired =
m_vmmShaper
->hasChargeAboveThreshold(qStrip.at(ii), tStrip.at(ii), stripsElectronicsThreshold.at(ii));
81
82
// check if neighbor strip was above threshold
83
bool
neighborFired = leftStripFired || rightStripFired;
84
85
// Look at strip if it or its neighbor was above threshold and if neighbor logic of the VMM is enabled:
86
if
(thisStripFired || (
m_cfg
.useNeighborLogic && neighborFired)) {
87
double
charge
{FLT_MAX}, time{FLT_MAX};
88
89
// if strip is below threshold but read through NL reduce threshold to low value of 1e to still find the peak
90
float
tmpScaledThreshold = (thisStripFired ? stripsElectronicsThreshold.at(ii) : 1);
91
92
bool
foundPeak =
m_vmmShaper
->vmmPeakResponse(qStrip.at(ii), tStrip.at(ii), tmpScaledThreshold,
charge
, time);
93
if
(!foundPeak)
continue
;
// if no peak was found within the enlarged time window the strip is skipped and no digit is created.
94
if
(time < m_cfg.timeWindowLowerOffset || time >
m_cfg
.timeWindowUpperOffset)
95
continue
;
// only accept strips in the correct time window
96
97
cache.nStripElectronics.push_back(numberofStrip.at(ii));
98
cache.tStripElectronicsAbThr.push_back(time);
99
cache.qStripElectronics.push_back(
charge
);
100
}
101
}
102
}
103
104
void
MM_ElectronicsResponseSimulation::vmmThresholdResponseFunction
(
DataCache
& cache,
const
MM_ElectronicsToolInput
& digiInput)
const
{
105
106
const
std::vector<int>& numberofStrip = digiInput.
NumberOfStripsPos
();
107
const
std::vector<std::vector<float>>& qStrip = digiInput.
chipCharge
();
108
const
std::vector<std::vector<float>>& tStrip = digiInput.
chipTime
();
109
const
std::vector<float>& electronicsThreshold = digiInput.
stripThreshold
();
110
111
for
(
unsigned
int
ii = 0; ii < numberofStrip.size(); ii++) {
112
double
localThresholdt{FLT_MAX}, localThresholdq{FLT_MAX};
113
114
bool
crossedThreshold =
115
m_vmmShaper
->vmmThresholdResponse(qStrip.at(ii), tStrip.at(ii), electronicsThreshold.at(ii), localThresholdq, localThresholdt);
116
if
(!crossedThreshold)
117
continue
;
// if no threshold crossing was found within the time window the strip is skipped and no digits are created.
118
if
(localThresholdt < m_cfg.timeWindowLowerOffset || localThresholdt >
m_cfg
.timeWindowUpperOffset)
119
continue
;
// only accept strips in the correct time window
120
121
cache.nStripElectronics.push_back(numberofStrip.at(ii));
122
cache.tStripElectronicsAbThr.push_back(localThresholdt);
123
cache.qStripElectronics.push_back(localThresholdq);
124
}
125
}
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
MM_ElectronicsResponseSimulation.h
MM_DigitToolOutput
Definition
MM_DigitToolOutput.h:25
MM_ElectronicsResponseSimulation::m_cfg
const ConfigModule m_cfg
Definition
MM_ElectronicsResponseSimulation.h:65
MM_ElectronicsResponseSimulation::MM_ElectronicsResponseSimulation
MM_ElectronicsResponseSimulation(ConfigModule &&module)
MM_ElectronicsResponseSimulation.cxx MC for micromegas athena integration.
Definition
MM_ElectronicsResponseSimulation.cxx:21
MM_ElectronicsResponseSimulation::vmmPeakResponseFunction
void vmmPeakResponseFunction(DataCache &cache, const MM_ElectronicsToolInput &digiInput) const
Definition
MM_ElectronicsResponseSimulation.cxx:53
MM_ElectronicsResponseSimulation::getThresholdResponseFrom
MM_DigitToolOutput getThresholdResponseFrom(const MM_ElectronicsToolInput &digiInput) const
Definition
MM_ElectronicsResponseSimulation.cxx:44
MM_ElectronicsResponseSimulation::m_vmmShaper
std::unique_ptr< VMM_Shaper > m_vmmShaper
Definition
MM_ElectronicsResponseSimulation.h:74
MM_ElectronicsResponseSimulation::getPeakResponseFrom
MM_DigitToolOutput getPeakResponseFrom(const MM_ElectronicsToolInput &digiInput) const
Definition
MM_ElectronicsResponseSimulation.cxx:30
MM_ElectronicsResponseSimulation::vmmThresholdResponseFunction
void vmmThresholdResponseFunction(DataCache &cache, const MM_ElectronicsToolInput &digiInput) const
Definition
MM_ElectronicsResponseSimulation.cxx:104
MM_ElectronicsToolInput
Definition
MM_ElectronicsToolInput.h:9
MM_ElectronicsToolInput::chipTime
const std::vector< std::vector< float > > & chipTime() const
Definition
MM_ElectronicsToolInput.h:33
MM_ElectronicsToolInput::NumberOfStripsPos
const std::vector< int > & NumberOfStripsPos() const
Definition
MM_ElectronicsToolInput.h:31
MM_ElectronicsToolInput::chipCharge
const std::vector< std::vector< float > > & chipCharge() const
Definition
MM_ElectronicsToolInput.h:32
MM_ElectronicsToolInput::stripThreshold
const std::vector< float > & stripThreshold() const
Definition
MM_ElectronicsToolInput.h:34
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
std
STL namespace.
MM_ElectronicsResponseSimulation::ConfigModule
Definition
MM_ElectronicsResponseSimulation.h:34
MM_ElectronicsResponseSimulation::DataCache
Definition
MM_ElectronicsResponseSimulation.h:67
Generated on
for ATLAS Offline Software by
1.17.0