17#include <TStopwatch.h>
29GEMAmplification::GEMAmplification()
38 const float sigmaOverMu = mGasParam->SigmaOverMu;
39 const float kappa = 1 / (sigmaOverMu * sigmaOverMu);
40 boost::format polya(
"1/(TMath::Gamma(%1%)*%2%) * TMath::Power(x/%3%, %4%) * TMath::Exp(-x/%5%)");
42 const char* polyaFileName =
"tpc_polya.root";
44 auto cacheexists = std::filesystem::exists(polyaFileName);
46 LOG(info) <<
"TPC: GEM setup from existing cache";
47 outfile = TFile::Open(polyaFileName);
49 LOG(info) <<
"TPC: GEM setup - initialization from scratch";
50 outfile = TFile::Open(polyaFileName,
"CREATE");
54 for (
int i = 0;
i < 4; ++
i) {
55 float s = mGEMParam->AbsoluteGain[
i] / kappa;
56 polya % kappa %
s %
s % (kappa - 1) %
s;
57 std::string
name = polya.str();
63 polyaDistribution->SetNpx(100000);
68 mGain[
i].initialize(*polyaDistribution);
71 outfile->WriteTObject(polyaDistribution, TString::Format(
"func%d",
i).Data());
73 delete polyaDistribution;
77 const float gainStack = mGEMParam->TotalGainStack;
78 const float kappaStack = mGEMParam->KappaStack;
79 const float effStack = mGEMParam->EfficiencyStack;
81 const float sStack = gainStack / (kappaStack * effStack);
82 polya % kappaStack % sStack % sStack % (kappaStack - 1) % sStack;
83 std::string
name = polya.str();
87 polyaDistribution->SetNpx(50000);
91 mGainFullStack.initialize(*polyaDistribution);
94 outfile->WriteTObject(polyaDistribution,
"polyaStack");
96 delete polyaDistribution;
102 LOG(info) <<
"TPC: GEM setup (polya) took " << watch.CpuTime();
110 mGainMap = &(cdb.getGainMap());
122 return nElectronsGEM4;
130 int nElectronsGEM = 0;
131 for (
int i = 0;
i < nElectrons; ++
i) {
137 return nElectronsGEM;
152 return extractionGEM;
159 if (nElectrons < 1) {
162 }
else if (nElectrons > 500) {
166 return ((mRandomGaus.
getNextValue() * std::sqrt(
static_cast<float>(nElectrons)) *
173 int electronsOut = 0;
174 for (
int i = 0;
i < nElectrons; ++
i) {
175 electronsOut += mGain[GEM].getNextValue();
184 float electronsFloat =
static_cast<float>(nElectrons);
185 if (nElectrons < 1 || probability < 0.00001) {
188 }
else if (probability > 0.99999) {
191 }
else if (electronsFloat * probability >= 5.f && electronsFloat * (1.f - probability) >= 5.f) {
194 return (mRandomGaus.
getNextValue() * std::sqrt(electronsFloat * probability * (1 - probability))) +
195 electronsFloat * probability + 0.5;
198 int nElectronsOut = 0;
199 for (
int i = 0;
i < nElectrons; ++
i) {
204 return nElectronsOut;
Simple interface to the CDB manager.
Definition of the GEM amplification.
static const ParameterGEM & Instance()
static CDBInterface & instance()
void updateParameters()
Update the OCDB parameters cached in the class. To be called once per event.
int getElectronLosses(int nElectrons, float probability)
int getEffectiveStackAmplification(int nElectrons=1)
int getStackAmplification(int nElectrons=1)
int getSingleGEMAmplification(int nElectrons, int GEM)
int getGEMMultiplication(int nElectrons, int GEM)
GLuint const GLchar * name
Global TPC definitions and constants.
float AbsoluteGain[4]
Absolute gain.
float CollectionEfficiency[4]
Collection efficiency.
float EfficiencyStack
Variable steering the single electron efficiency of the full stack for the EffectiveMode.
float ExtractionEfficiency[4]
Extraction efficiency.
float SigmaOverMu
Sigma over mu, gives deviation from exponential gain fluctuations.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"