ATLAS Offline Software
MM_StripsResponseSimulation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MM_DIGITIZATION_STRIPRESPONSESIMULATION_H
6 #define MM_DIGITIZATION_STRIPRESPONSESIMULATION_H
7 
22 
27 #include <TFile.h>
29 #include <TH1F.h>
30 #include <TH2F.h>
31 
34 #include "GaudiKernel/IToolSvc.h"
35 #include "GaudiKernel/Service.h"
36 #include "GaudiKernel/StatusCode.h"
42 #include <sys/stat.h>
43 
44 #include <algorithm>
45 #include <cmath>
46 #include <iomanip>
47 #include <iostream>
48 #include <sstream>
49 #include <string>
50 #include <utility>
51 
52 class MM_DigitToolInput;
53 class MM_StripToolOutput;
54 
55 namespace CLHEP {
56  class HepRandomEngine;
57  class HepRandom;
58  class RandGeneral;
59 } // namespace CLHEP
60 
62 public:
63 
65  ConfigModule() = default;
67  float qThreshold{0.};
68 
70  float crossTalk1{0.}; // 0.10; //
72  float crossTalk2{0.}; // 0.03;
73 
74  float driftGapWidth{0.};
75 
76  // Avalanche gain
77  float avalancheGain{0.};
78  int maxPrimaryIons{300};
79 
80  bool writeOutputFile{false};
81  bool writeEventDisplays{false};
82 
83  };
84  MM_StripsResponseSimulation(ConfigModule&& cfg);
85 
87  MM_StripToolOutput GetResponseFrom(const MM_DigitToolInput& digiInput, double gainFraction, double stripPitch,
88  CLHEP::HepRandomEngine* rndmEngine) const;
89 
90 
91  float getQThreshold() const { return m_cfg.qThreshold; };
92  float getDriftGapWidth() const { return m_cfg.driftGapWidth; };
93  double getDriftVelocity() const { return m_cfg.driftVelocity; };
98 
99 private:
100  void initHistos();
101  void writeHistos();
103 
104  struct DataCache {
105  std::vector<std::unique_ptr<MM_IonizationCluster>> IonizationClusters{};
106  std::vector<int> finalNumberofStrip{};
107  std::vector<std::vector<float>> finalqStrip{};
108  std::vector<std::vector<float>> finaltStrip{};
109  std::vector<float> tStripElectronicsAbThr{};
110  std::vector<float> qStripElectronics{};
111  };
112 
113  void whichStrips(DataCache& cache,
114  const MM_DigitToolInput& digiInput,
115  double gainFraction,
116  double stripPitch, CLHEP::HepRandomEngine* rndmEngine) const;
117 
118 
119  std::map<std::string, std::unique_ptr<TH1F>> m_mapOfHistograms{};
120  std::map<std::string, std::unique_ptr<TH2F>> m_mapOf2DHistograms{};
121 
122  std::unique_ptr<CLHEP::RandGeneral> m_randNelectrons{};
123 
124  static constexpr unsigned int s_NelectronPropBins{300};
125 
126 
127  std::unique_ptr<TFile> m_outputFile{nullptr};
128 
129 protected:
130  // seperate random number generation for performance monitoring
131  float generateTransverseDiffusion(float posY, CLHEP::HepRandomEngine* rndmEngine) const;
132  float getTransverseDiffusion(float posY, CLHEP::HepRandomEngine* rndmEngine) const;
133  float getLongitudinalDiffusion(float posY, CLHEP::HepRandomEngine* rndmEngine) const;
134  float getEffectiveCharge(CLHEP::HepRandomEngine* rndmEngine) const;
135  float getPathLengthTraveled(CLHEP::HepRandomEngine* rndmEngine) const;
136 };
137 #endif
MM_StripsResponseSimulation::getTransversDiffusionSigma
float getTransversDiffusionSigma() const
Definition: MM_StripsResponseSimulation.h:97
NSWCalib::MicroMegaGas::longitudinalDiffusionSigma
float longitudinalDiffusionSigma
// 0.350/10 diffusSigma=transverse diffusion (350 microm per 1cm ) for 93:7 @ 600 V/cm,...
Definition: INSWCalibTool.h:36
MM_StripsResponseSimulation::ConfigModule::writeEventDisplays
bool writeEventDisplays
Definition: MM_StripsResponseSimulation.h:81
NSWCalib::MicroMegaGas::interactionDensityMean
float interactionDensityMean
Definition: INSWCalibTool.h:38
MM_StripsResponseSimulation::writeHistos
void writeHistos()
Definition: MM_StripsResponseSimulation.cxx:88
MM_StripsResponseSimulation::DataCache::finalqStrip
std::vector< std::vector< float > > finalqStrip
Definition: MM_StripsResponseSimulation.h:107
MM_StripsResponseSimulation::m_cfg
const ConfigModule m_cfg
Definition: MM_StripsResponseSimulation.h:102
MM_StripsResponseSimulation::ConfigModule::crossTalk1
float crossTalk1
crosstalk of neighbor strips, it's 15%
Definition: MM_StripsResponseSimulation.h:70
INSWCalibTool.h
MM_IonizationCluster.h
MM_StripsResponseSimulation::whichStrips
void whichStrips(DataCache &cache, const MM_DigitToolInput &digiInput, double gainFraction, double stripPitch, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:122
MM_StripsResponseSimulation::~MM_StripsResponseSimulation
virtual ~MM_StripsResponseSimulation()
Definition: MM_StripsResponseSimulation.cxx:348
MM_StripsResponseSimulation::getDriftVelocity
double getDriftVelocity() const
Definition: MM_StripsResponseSimulation.h:93
MM_StripsResponseSimulation::ConfigModule
Definition: MM_StripsResponseSimulation.h:64
MM_DigitToolInput.h
MM_StripsResponseSimulation::DataCache::tStripElectronicsAbThr
std::vector< float > tStripElectronicsAbThr
Definition: MM_StripsResponseSimulation.h:109
MM_StripsResponseSimulation
Definition: MM_StripsResponseSimulation.h:61
NSWCalib::MicroMegaGas::driftVelocity
float driftVelocity
//0.050 drift velocity in [mm/ns], driftGap=5 mm +0.128 mm (the amplification gap)
Definition: INSWCalibTool.h:34
MM_DigitToolInput
Definition: MM_DigitToolInput.h:25
MM_StripsResponseSimulation::m_outputFile
std::unique_ptr< TFile > m_outputFile
Definition: MM_StripsResponseSimulation.h:127
MM_StripsResponseSimulation::ConfigModule::maxPrimaryIons
int maxPrimaryIons
Definition: MM_StripsResponseSimulation.h:78
MM_StripsResponseSimulation::ConfigModule::driftGapWidth
float driftGapWidth
Definition: MM_StripsResponseSimulation.h:74
MM_StripsResponseSimulation::getDriftGapWidth
float getDriftGapWidth() const
Definition: MM_StripsResponseSimulation.h:92
NSWCalib::MicroMegaGas::interactionDensitySigma
float interactionDensitySigma
Definition: INSWCalibTool.h:39
MM_StripsResponseSimulation::m_randNelectrons
std::unique_ptr< CLHEP::RandGeneral > m_randNelectrons
Definition: MM_StripsResponseSimulation.h:122
MM_StripsResponseSimulation::GetResponseFrom
MM_StripToolOutput GetResponseFrom(const MM_DigitToolInput &digiInput, double gainFraction, double stripPitch, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:102
MM_StripsResponseSimulation::getQThreshold
float getQThreshold() const
Definition: MM_StripsResponseSimulation.h:91
MM_StripsResponseSimulation::s_NelectronPropBins
static constexpr unsigned int s_NelectronPropBins
Definition: MM_StripsResponseSimulation.h:124
MM_StripsResponseSimulation::getInteractionDensityMean
float getInteractionDensityMean() const
Definition: MM_StripsResponseSimulation.h:94
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MM_StripsResponseSimulation::getLongitudinalDiffusion
float getLongitudinalDiffusion(float posY, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:317
MM_StripsResponseSimulation::ConfigModule::qThreshold
float qThreshold
qThreshold=2e, we accept a good strip if the charge is >=2e
Definition: MM_StripsResponseSimulation.h:67
MM_StripsResponseSimulation::DataCache::finalNumberofStrip
std::vector< int > finalNumberofStrip
Definition: MM_StripsResponseSimulation.h:106
MM_StripsResponseSimulation::getEffectiveCharge
float getEffectiveCharge(CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:327
MM_StripsResponseSimulation::getLongitudinalDiffusionSigma
float getLongitudinalDiffusionSigma() const
Definition: MM_StripsResponseSimulation.h:96
MM_StripsResponseSimulation::getTransverseDiffusion
float getTransverseDiffusion(float posY, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:291
MM_StripsResponseSimulation::MM_StripsResponseSimulation
MM_StripsResponseSimulation(ConfigModule &&cfg)
Definition: MM_StripsResponseSimulation.cxx:40
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
MM_StripToolOutput
Definition: MM_StripToolOutput.h:9
MM_StripsResponseSimulation::ConfigModule::ConfigModule
ConfigModule()=default
beamspotman.posY
posY
Definition: beamspotman.py:1624
MM_StripsResponseSimulation::ConfigModule::writeOutputFile
bool writeOutputFile
Definition: MM_StripsResponseSimulation.h:80
NSWCalib::MicroMegaGas::transverseDiffusionSigma
float transverseDiffusionSigma
Definition: INSWCalibTool.h:37
MM_StripsResponseSimulation::ConfigModule::avalancheGain
float avalancheGain
Definition: MM_StripsResponseSimulation.h:77
MM_StripToolOutput.h
MM_StripsResponseSimulation::ConfigModule::crossTalk2
float crossTalk2
// crosstalk of second neighbor strips, it's 6%
Definition: MM_StripsResponseSimulation.h:72
AthMessaging.h
MM_StripsResponseSimulation::DataCache::qStripElectronics
std::vector< float > qStripElectronics
Definition: MM_StripsResponseSimulation.h:110
MM_StripsResponseSimulation::initHistos
void initHistos()
Definition: MM_StripsResponseSimulation.cxx:59
MM_StripsResponseSimulation::m_mapOfHistograms
std::map< std::string, std::unique_ptr< TH1F > > m_mapOfHistograms
Definition: MM_StripsResponseSimulation.h:119
MM_StripsResponseSimulation::m_mapOf2DHistograms
std::map< std::string, std::unique_ptr< TH2F > > m_mapOf2DHistograms
Definition: MM_StripsResponseSimulation.h:120
MM_StripsResponseSimulation::getPathLengthTraveled
float getPathLengthTraveled(CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:334
MM_StripsResponseSimulation::DataCache::finaltStrip
std::vector< std::vector< float > > finaltStrip
Definition: MM_StripsResponseSimulation.h:108
MM_StripsResponseSimulation::DataCache::IonizationClusters
std::vector< std::unique_ptr< MM_IonizationCluster > > IonizationClusters
Definition: MM_StripsResponseSimulation.h:105
MM_StripsResponseSimulation::getInteractionDensitySigma
float getInteractionDensitySigma() const
Definition: MM_StripsResponseSimulation.h:95
MM_StripsResponseSimulation::DataCache
Definition: MM_StripsResponseSimulation.h:104
NSWCalib::MicroMegaGas
Definition: INSWCalibTool.h:32
MM_StripsResponseSimulation::generateTransverseDiffusion
float generateTransverseDiffusion(float posY, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MM_StripsResponseSimulation.cxx:276