ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12#include <numeric>
13
15#include "GaudiKernel/MsgStream.h"
16#include "TF1.h"
17
18#include "CLHEP/Random/RandGaussZiggurat.h"
19
20/*******************************************************************************/
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
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/*******************************************************************************/
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/*******************************************************************************/
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/*******************************************************************************/
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
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}
double charge(const T &p)
Definition AtlasPID.h:997
MM_ElectronicsResponseSimulation(ConfigModule &&module)
MM_ElectronicsResponseSimulation.cxx MC for micromegas athena integration.
void vmmPeakResponseFunction(DataCache &cache, const MM_ElectronicsToolInput &digiInput) const
MM_DigitToolOutput getThresholdResponseFrom(const MM_ElectronicsToolInput &digiInput) const
MM_DigitToolOutput getPeakResponseFrom(const MM_ElectronicsToolInput &digiInput) const
void vmmThresholdResponseFunction(DataCache &cache, const MM_ElectronicsToolInput &digiInput) const
const std::vector< std::vector< float > > & chipTime() const
const std::vector< int > & NumberOfStripsPos() const
const std::vector< std::vector< float > > & chipCharge() const
const std::vector< float > & stripThreshold() const
singleton-like access to IMessageSvc via open function and helper
STL namespace.