ATLAS Offline Software
Loading...
Searching...
No Matches
PunchThroughTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ISF_PUNCHTHROUGHTOOLS_SRC_PUNCHTHROUGHTOOL_H
6#define ISF_PUNCHTHROUGHTOOLS_SRC_PUNCHTHROUGHTOOL_H 1
7
9#include <string>
10
12
13// Athena Base
15
16//Geometry
18
20
21// Gaudi & StoreGate
22#include "GaudiKernel/IPartPropSvc.h"
23
25
27
29
30//libXML
31#include <libxml/xmlmemory.h>
32#include <libxml/parser.h>
33#include <libxml/tree.h>
34#include <libxml/xmlreader.h>
35#include <libxml/xpath.h>
36#include <libxml/xpathInternals.h>
37
38/*-------------------------------------------------------------------------
39 * Forward declarations
40 *-------------------------------------------------------------------------*/
41
42class TFile;
43
44namespace HepPDT {
45 class ParticleDataTable;
46}
47
48namespace ISF {
50 class PDFcreator;
51}
52
53namespace ISF {
54
55 class PunchThroughTool : public extends<AthAlgTool, IPunchThroughTool>
56 {
57 public:
59 PunchThroughTool(const std::string&,const std::string&,const IInterface*);
60
62 virtual ~PunchThroughTool () = default;
63
65 virtual StatusCode initialize();
67 virtual StatusCode finalize ();
69 const ISF::ISFParticleVector* computePunchThroughParticles(const ISF::ISFParticle &isfp, const TFCSSimulationState& simulstate, CLHEP::HepRandomEngine* rndmEngine) const;
70
71 private:
72 /*---------------------------------------------------------------------
73 * Private member functions
74 *---------------------------------------------------------------------*/
76 StatusCode registerParticle(int pdgID, bool doAntiparticle = false,
77 double minEnergy = 0., int maxNumParticles = -1,
78 double numParticlesFactor = 1., double energyFactor = 1.,
79 double posAngleFactor = 1.,
80 double momAngleFactor = 1.);
83 StatusCode registerCorrelation(int pdgID1, int pdgID2,double minCorrEnergy = 0., double fullCorrEnergy = 0.);
84
86 std::unique_ptr<ISF::PDFcreator> readLookuptablePDF(int pdgID, const std::string& folderName);
87
93 int getAllParticles(const ISF::ISFParticle &isfp, ISFParticleVector& isfpCont, CLHEP::HepRandomEngine* rndmEngine, int pdg, double interpEnergy, double interpEta, int numParticles = -1) const;
94
98 int getCorrelatedParticles(const ISF::ISFParticle &isfp, ISFParticleVector& isfpCont, int doPdg, int corrParticles, CLHEP::HepRandomEngine* rndmEngine, double interpEnergy, double interpEta) const;
99
101 ISF::ISFParticle *getOneParticle(const ISF::ISFParticle &isfp, int pdg, CLHEP::HepRandomEngine* rndmEngine, double interpEnergy, double interpEta) const;
102
104 ISF::ISFParticle *createExitPs(const ISF::ISFParticle &isfp, int PDGcode, double energy, double theta, double phi, double momTheta, double momPhi) const;
105
107 double getFloatAfterPatternInStr(const char *str, const char *pattern);
109 Amg::Vector3D propagator(double theta, double phi) const;
110
111 //apply the inverse PCA transform
112 std::vector<double> inversePCA(int pcaCdfIterator, std::vector<double> &variables) const;
113
114 //apply the inverse CDF trainsform
115 static double inverseCdfTransform(double variable, const std::map<double, double>& inverse_cdf_map) ;
116
117 //dot product between matrix and vector, used to inverse PCA
118 static std::vector<double> dotProduct(const std::vector<std::vector<double>> &m, const std::vector<double> &v) ;
119
120 //returns normal cdf based on normal gaussian value
121 static double normal_cdf(double x) ;
122
123 //apply energy interpolation
124 double interpolateEnergy(const double &energy, CLHEP::HepRandomEngine* rndmEngine) const;
125
126 //apply eta interpolation
127 double interpolateEta(const double &eta, CLHEP::HepRandomEngine* rndmEngine) const;
128
129 //get the infoMap from xml file based on the xmlpathname and also name of mainNode
130 std::vector<std::map<std::string,std::string>> getInfoMap(const std::string& mainNode, const std::string &xmlFilePath);
131
132 //decide the pca / cdf part to read based on pdgId and eta
133 int passedParamIterator(int pid, double eta, const std::vector<std::map<std::string,std::string>> &mapvect) const;
134
135 //load inverse quantile transformer from XML
136 StatusCode initializeInverseCDF(const std::string & quantileTransformerConfigFile);
137
138 //get CDF mapping for individual XML node
139 static std::map<double, double> getVariableCDFmappings(xmlNodePtr& nodeParent);
140
141 //load inverse PCA from XML
142 StatusCode initializeInversePCA(const std::string & inversePCAConfigFile);
143
144
145 /*---------------------------------------------------------------------
146 * Private members
147 *---------------------------------------------------------------------*/
148
150 std::vector<double> m_energyPoints;
151 std::vector<double> m_etaPoints;
152
154 double m_R1{0.};
155 double m_R2{0.};
156 double m_z1{0.};
157 double m_z2{0.};
158
160 const HepPDT::ParticleDataTable* m_particleDataTable{nullptr};
161
163 TFile* m_fileLookupTable{nullptr};
164
166 std::map<int, PunchThroughParticle*> m_particles;
167
168 /*---------------------------------------------------------------------
169 * Properties
170 *---------------------------------------------------------------------*/
171
173 StringProperty m_filenameLookupTable{this, "FilenameLookupTable", "CaloPunchThroughParametrisation.root", "holds the filename of the lookup table"};
174 StringProperty m_filenameInverseCDF{this, "FilenameInverseCdf", "", "holds the filename of inverse quantile transformer config"};
175 StringProperty m_filenameInversePCA{this, "FilenameInversePca", "", "holds the filename of inverse PCA config"};
176
177 PublicToolHandle<IPunchThroughClassifier> m_punchThroughClassifier{this, "PunchThroughClassifier", "ISF_PunchThroughClassifier", ""};
178 IntegerArrayProperty m_pdgInitiators{this, "PunchThroughInitiators", {}, "vector of punch-through initiator pgds"};
179 IntegerArrayProperty m_initiatorsMinEnergy{this, "InitiatorsMinEnergy", {}, "vector of punch-through initiator min energies to create punch through"};
180 DoubleArrayProperty m_initiatorsEtaRange{this, "InitiatorsEtaRange", {}, "vector of min and max abs eta range to allow punch through initiators"};
181 IntegerArrayProperty m_punchThroughParticles{this, "PunchThroughParticles", {}, "vector of pdgs of the particles produced in punch-throughs"};
182 BooleanArrayProperty m_doAntiParticles{this, "DoAntiParticles", {}, "vector of bools to determine if anti-particles are created for each punch-through particle type"};
183 IntegerArrayProperty m_correlatedParticle{this, "CorrelatedParticle", {}, "holds the pdg of the correlated particle for each given pdg"};
184 DoubleArrayProperty m_minCorrEnergy{this, "MinCorrelationEnergy", {}, "holds the energy threshold below which no particle correlation is computed"};
185 DoubleArrayProperty m_fullCorrEnergy{this, "FullCorrelationEnergy", {}, "holds the energy threshold above which a particle correlation is fully developed"};
186 DoubleArrayProperty m_posAngleFactor{this, "ScalePosDeflectionAngles", {}, "tuning parameter to scale the position deflection angles"};
187 DoubleArrayProperty m_momAngleFactor{this, "ScaleMomDeflectionAngles", {}, "tuning parameter to scale the momentum deflection angles"};
188 DoubleArrayProperty m_minEnergy{this, "MinEnergy", {}, "punch-through particles minimum energies"};
189 IntegerArrayProperty m_maxNumParticles{this, "MaxNumParticles", {}, "maximum number of punch-through particles for each particle type"};
190 DoubleArrayProperty m_numParticlesFactor{this, "NumParticlesFactor", {}, "scale the number of punch-through particles"};
191 DoubleArrayProperty m_energyFactor{this, "EnergyFactor", {}, "scale the energy of the punch-through particles"};
192
193
194
195 /*---------------------------------------------------------------------
196 * ServiceHandles
197 *---------------------------------------------------------------------*/
198 ServiceHandle<IPartPropSvc> m_particlePropSvc{this, "PartPropSvc", "PartPropSvc", "particle properties svc"};
199 ServiceHandle<IGeoIDSvc> m_geoIDSvc{this, "GeoIDSvc", "ISF::GeoIDSvc"};
200 ServiceHandle<IEnvelopeDefSvc> m_envDefSvc{this, "EnvelopeDefSvc", "AtlasGeometry_EnvelopeDefSvc"};
201
203 DoubleProperty m_beamPipe{this, "BeamPipeRadius", 500.};
204
206 std::vector<std::vector<std::vector<double>>> m_inverse_PCA_matrix;
207 std::vector<std::vector<double>> m_PCA_means;
208
210 std::vector<std::map<std::string, std::string>> m_xml_info_pca;
211 std::vector<std::map<std::string, std::string>> m_xml_info_cdf;
212
214 std::vector<std::map<double, double>> m_variable0_inverse_cdf;
215 std::vector<std::map<double, double>> m_variable1_inverse_cdf;
216 std::vector<std::map<double, double>> m_variable2_inverse_cdf;
217 std::vector<std::map<double, double>> m_variable3_inverse_cdf;
218 std::vector<std::map<double, double>> m_variable4_inverse_cdf;
219 };
220}
221
222#endif
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define x
The generic ISF particle definition,.
Definition ISFParticle.h:42
Creates random numbers with a distribution given as ROOT TF1.
Definition PDFcreator.h:37
This class holds information for different properties of a punch-through particle (energy,...
std::vector< double > inversePCA(int pcaCdfIterator, std::vector< double > &variables) const
std::vector< std::vector< std::vector< double > > > m_inverse_PCA_matrix
pca vectors
const ISF::ISFParticleVector * computePunchThroughParticles(const ISF::ISFParticle &isfp, const TFCSSimulationState &simulstate, CLHEP::HepRandomEngine *rndmEngine) const
interface function: fill a vector with the punch-through particles
static std::vector< double > dotProduct(const std::vector< std::vector< double > > &m, const std::vector< double > &v)
StringProperty m_filenameInverseCDF
IntegerArrayProperty m_correlatedParticle
DoubleArrayProperty m_minCorrEnergy
std::vector< std::map< std::string, std::string > > getInfoMap(const std::string &mainNode, const std::string &xmlFilePath)
std::vector< std::map< double, double > > m_variable1_inverse_cdf
std::unique_ptr< ISF::PDFcreator > readLookuptablePDF(int pdgID, const std::string &folderName)
reads out the lookuptable for the given type of particle
static double inverseCdfTransform(double variable, const std::map< double, double > &inverse_cdf_map)
ServiceHandle< IPartPropSvc > m_particlePropSvc
StringProperty m_filenameLookupTable
Properties.
StringProperty m_filenameInversePCA
std::vector< std::map< std::string, std::string > > m_xml_info_cdf
std::vector< std::map< double, double > > m_variable3_inverse_cdf
PublicToolHandle< IPunchThroughClassifier > m_punchThroughClassifier
BooleanArrayProperty m_doAntiParticles
double getFloatAfterPatternInStr(const char *str, const char *pattern)
get the floating point number in a string, after the given pattern
int getAllParticles(const ISF::ISFParticle &isfp, ISFParticleVector &isfpCont, CLHEP::HepRandomEngine *rndmEngine, int pdg, double interpEnergy, double interpEta, int numParticles=-1) const
create the right number of punch-through particles for the given pdg and return the number of particl...
DoubleArrayProperty m_energyFactor
StatusCode registerCorrelation(int pdgID1, int pdgID2, double minCorrEnergy=0., double fullCorrEnergy=0.)
register a correlation for the two given types of punch-through particles with a given energy thresho...
Amg::Vector3D propagator(double theta, double phi) const
get particle through the calorimeter
DoubleProperty m_beamPipe
beam pipe radius
DoubleArrayProperty m_momAngleFactor
static double normal_cdf(double x)
DoubleArrayProperty m_initiatorsEtaRange
DoubleArrayProperty m_fullCorrEnergy
std::map< int, PunchThroughParticle * > m_particles
needed to create punch-through particles with the right distributions
const HepPDT::ParticleDataTable * m_particleDataTable
ParticleDataTable needed to get connection pdg_code <-> charge.
StatusCode registerParticle(int pdgID, bool doAntiparticle=false, double minEnergy=0., int maxNumParticles=-1, double numParticlesFactor=1., double energyFactor=1., double posAngleFactor=1., double momAngleFactor=1.)
registers a type of punch-through particles which will be simulated
std::vector< std::vector< double > > m_PCA_means
DoubleArrayProperty m_numParticlesFactor
PunchThroughTool(const std::string &, const std::string &, const IInterface *)
Constructor.
ISF::ISFParticle * getOneParticle(const ISF::ISFParticle &isfp, int pdg, CLHEP::HepRandomEngine *rndmEngine, double interpEnergy, double interpEta) const
create exactly one punch-through particle with the given pdg and the given max energy
std::vector< std::map< double, double > > m_variable2_inverse_cdf
IntegerArrayProperty m_initiatorsMinEnergy
StatusCode initializeInverseCDF(const std::string &quantileTransformerConfigFile)
static std::map< double, double > getVariableCDFmappings(xmlNodePtr &nodeParent)
std::vector< std::map< double, double > > m_variable0_inverse_cdf
(vector of map) for CDF mappings
virtual StatusCode initialize()
AlgTool initialize method.
std::vector< double > m_energyPoints
energy and eta points in param
ServiceHandle< IGeoIDSvc > m_geoIDSvc
int getCorrelatedParticles(const ISF::ISFParticle &isfp, ISFParticleVector &isfpCont, int doPdg, int corrParticles, CLHEP::HepRandomEngine *rndmEngine, double interpEnergy, double interpEta) const
get the right number of particles for the given pdg while considering the correlation to an other par...
IntegerArrayProperty m_pdgInitiators
DoubleArrayProperty m_minEnergy
IntegerArrayProperty m_maxNumParticles
double m_R1
calo-MS borders
std::vector< std::map< double, double > > m_variable4_inverse_cdf
StatusCode initializeInversePCA(const std::string &inversePCAConfigFile)
double interpolateEta(const double &eta, CLHEP::HepRandomEngine *rndmEngine) const
TFile * m_fileLookupTable
ROOT objects.
virtual StatusCode finalize()
AlgTool finalize method.
ISF::ISFParticle * createExitPs(const ISF::ISFParticle &isfp, int PDGcode, double energy, double theta, double phi, double momTheta, double momPhi) const
create a ISF Particle state at the MS entrace containing a particle with the given properties
ServiceHandle< IEnvelopeDefSvc > m_envDefSvc
int passedParamIterator(int pid, double eta, const std::vector< std::map< std::string, std::string > > &mapvect) const
std::vector< std::map< std::string, std::string > > m_xml_info_pca
infoMaps
virtual ~PunchThroughTool()=default
Destructor.
DoubleArrayProperty m_posAngleFactor
double interpolateEnergy(const double &energy, CLHEP::HepRandomEngine *rndmEngine) const
IntegerArrayProperty m_punchThroughParticles
std::vector< double > m_etaPoints
Eigen::Matrix< double, 3, 1 > Vector3D
ISFParticleOrderedQueue.
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.