8#include <AthLinks/ElementLink.h>
26void EgammaFactory::create_structure() {
30 m_clusters->setStore(m_clAux);
31 if (!m_store.record(m_clusters,
"Clusters").isSuccess()) {
34 if (!m_store.record(m_clAux,
"ClustersAux.").isSuccess()) {
41 m_vertexes->setStore(m_vxAux);
42 if (!m_store.record(m_vertexes,
"Vertexes").isSuccess()) {
45 if (!m_store.record(m_vxAux,
"VertexesAux.").isSuccess()) {
52 m_tracks->setStore(m_tracksAux);
53 if (!m_store.record(m_tracks,
"Tracks").isSuccess()) {
56 if (!m_store.record(m_tracksAux,
"TracksAux.").isSuccess()) {
63 m_photons->setStore(m_photonsAux);
64 if (!m_store.record(m_photons,
"Photons").isSuccess()) {
67 if (!m_store.record(m_photonsAux,
"PhotonsAux.").isSuccess()) {
74 m_electrons->setStore(m_electronsAux);
75 if (!m_store.record(m_electrons,
"Electrons").isSuccess()) {
78 if (!m_store.record(m_electronsAux,
"ElectronsAux.").isSuccess()) {
83EgammaFactory::EgammaFactory() :
asg::AsgMessaging(
"EgammaFactory") {
86 TFile*
f = TFile::Open(
88 "ElectronPhotonFourMomentumCorrection/v8/average_layers.root")
95 "ElectronPhotonFourMomentumCorrection/v8/average_layers.root")
100 m_histos_electron = std::array<TProfile2D*, 4>{
101 static_cast<TProfile2D*
>(m_fave->Get(
"histo_electron_ratio_Es0_true_E")),
102 static_cast<TProfile2D*
>(m_fave->Get(
"histo_electron_ratio_Es1_true_E")),
103 static_cast<TProfile2D*
>(m_fave->Get(
"histo_electron_ratio_Es2_true_E")),
104 static_cast<TProfile2D*
>(m_fave->Get(
"histo_electron_ratio_Es3_true_E"))};
105 m_histos_conv = std::array<TProfile2D*, 4>{
106 static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ratio_Es0_true_E")),
107 static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ratio_Es1_true_E")),
108 static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ratio_Es2_true_E")),
109 static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ratio_Es3_true_E"))};
110 m_histos_unconv = std::array<TProfile2D*, 4>{
111 static_cast<TProfile2D*
>(m_fave->Get(
"histo_unconv_ratio_Es0_true_E")),
112 static_cast<TProfile2D*
>(m_fave->Get(
"histo_unconv_ratio_Es1_true_E")),
113 static_cast<TProfile2D*
>(m_fave->Get(
"histo_unconv_ratio_Es2_true_E")),
114 static_cast<TProfile2D*
>(m_fave->Get(
"histo_unconv_ratio_Es3_true_E"))};
115 m_histo_rconv =
static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ph_Rconv"));
116 m_histo_zconv =
static_cast<TProfile2D*
>(m_fave->Get(
"histo_conv_ph_zconv"));
119std::array<double, 4> EgammaFactory::get_layers_fraction(
120 const std::array<TProfile2D*, 4>& prof,
double eta,
double pt)
const {
121 std::array<double, 4>
result;
122 for (
int i = 0;
i != 4; ++
i) {
123 TProfile2D*
p = prof[
i];
125 result[
i] =
p->GetBinContent(
p->FindBin(pt, std::abs(
eta)));
130void EgammaFactory::clear() {
135EgammaFactory::~EgammaFactory() {
140 bool simulation,
int runnumber,
int eventnumber,
141 int average_interaction_per_crossing) {
152 float e1,
float e2,
float e3,
164 const std::set<CaloSampling::CaloSample> samplings{
165 CaloSampling::PreSamplerB, CaloSampling::EMB1,
166 CaloSampling::EMB2, CaloSampling::EMB3,
167 CaloSampling::PreSamplerE, CaloSampling::EME1,
168 CaloSampling::EME2, CaloSampling::EME3};
169 unsigned sampling_pattern = 0;
170 for (
auto sample : samplings) {
171 sampling_pattern |= 0x1U <<
sample;
176 for (
auto sample : samplings) {
184 if (std::abs(
eta) < 1.45) {
185 cluster->
setEnergy(CaloSampling::PreSamplerB, e0);
186 cluster->
setEnergy(CaloSampling::EMB1, e1);
187 cluster->
setEnergy(CaloSampling::EMB2, e2);
188 cluster->
setEnergy(CaloSampling::EMB3, e3);
190 cluster->
setEnergy(CaloSampling::PreSamplerE, e0);
191 cluster->
setEnergy(CaloSampling::EME1, e1);
192 cluster->
setEnergy(CaloSampling::EME2, e2);
193 cluster->
setEnergy(CaloSampling::EME3, e3);
196 cluster->
setE(e > 0 ? e : e0 + e1 + e2 + e3);
202 static const SG::Decorator<float> etaCaloDecor(
"etaCalo");
203 static const SG::Decorator<float> phiCaloDecor(
"phiCalo");
204 etaCaloDecor(*cluster) =
eta;
205 phiCaloDecor(*cluster) =
phi;
211 m_clusters->push_back(cluster);
217 return create_photon(
eta,
phi, e, 0., 0.);
222 assert(m_histo_rconv);
223 assert(m_histo_zconv);
224 const int bin = m_histo_rconv->FindBin(e / cosh(
eta), std::abs(
eta));
225 if (m_histo_rconv->IsBinOverflow(bin)) {
226 return create_photon(
eta,
phi, e, 0, 0);
228 const double rconv = m_histo_rconv->GetBinContent(bin);
229 const double zconv = m_histo_zconv->GetBinContent(
230 m_histo_zconv->FindBin(e / cosh(
eta), std::abs(
eta)));
232 return create_photon(
eta,
phi, e, rconv, zconv);
237 float rconv,
float zconv) {
238 const bool isconv = (rconv > 0 and rconv < 800);
239 const auto l = get_layers_fraction(isconv ? m_histos_conv : m_histos_unconv,
241 return create_photon(
eta,
phi, l[0] * e, l[1] * e, l[2] * e, l[3] * e, e,
246 const auto l = get_layers_fraction(m_histos_electron,
eta, e / cosh(
eta));
247 return create_electron(
eta,
phi, l[0] * e, l[1] * e, l[2] * e, l[3] * e, e);
251 float e1,
float e2,
float e3,
252 float e,
float rconv,
float zconv) {
256 if (rconv > 0 and rconv < 800) {
259 vertex->makePrivateStore();
264 SG::Decorator<float> pt1Decor(
"pt1");
265 SG::Decorator<float> pt2Decor(
"pt2");
266 pt1Decor(*vertex) =
e / cosh(
eta) * 0.7;
267 pt2Decor(*vertex) =
e / cosh(
eta) * 0.3;
268 m_vertexes->push_back(vertex);
274 m_photons->push_back(ph);
278 std::vector<ElementLink<xAOD::CaloClusterContainer>> links_clusters;
280 links_clusters.push_back(
281 ElementLink<xAOD::CaloClusterContainer>(cluster, *m_clusters));
288 std::vector<ElementLink<xAOD::VertexContainer>> links_vertexes;
289 links_vertexes.push_back(
290 ElementLink<xAOD::VertexContainer>(vertex, *m_vertexes));
306 float e1,
float e2,
float e3,
313 track->makePrivateStore();
315 m_tracks->push_back(track);
319 el->makePrivateStore();
320 m_electrons->push_back(el);
323 std::vector<ElementLink<xAOD::TrackParticleContainer>> links_tracks;
324 links_tracks.push_back(
325 ElementLink<xAOD::TrackParticleContainer>(track, *m_tracks));
326 el->setTrackParticleLinks(links_tracks);
329 std::vector<ElementLink<xAOD::CaloClusterContainer>> links_clusters;
331 links_clusters.push_back(
332 ElementLink<xAOD::CaloClusterContainer>(cluster, *m_clusters));
334 el->setCaloClusterLinks(links_clusters);
340 el->setPt(e / cosh(
eta));
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void makePrivateStore()
Create a new (empty) private store for this object.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
void insertMoment(MomentType type, double value)
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
@ ETACALOFRAME
Eta in the calo frame (for egamma)
@ PHICALOFRAME
Phi in the calo frame (for egamma)
unsigned nSamples() const
void setCaloClusterLinks(const CLELVec_t &links)
set Pointer to the xAOD::CaloCluster
void setEta(float eta)
set the eta
void setPhi(float phi)
set the phi
void setPt(float pt)
set the Pt
void setAverageInteractionsPerCrossing(float value)
Set average interactions per crossing for all BCIDs.
void setEventNumber(uint64_t value)
Set the current event's event number.
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
void setRunNumber(uint32_t value)
Set the current event's run number.
void setVertexLinks(const VxELVec_t &links)
set Pointer to the xAOD::vertex/vertices that match the photon candidate
static std::vector< uint32_t > runnumber
l
Printing final latex table to .tex output file.
PhotonAuxContainer_v3 PhotonAuxContainer
Definition of the current photon auxiliary container.
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Photon_v1 Photon
Definition of the current "egamma version".
TrackParticleAuxContainer_v5 TrackParticleAuxContainer
Definition of the current TrackParticle auxiliary container.
ElectronAuxContainer_v3 ElectronAuxContainer
Definition of the current electron auxiliary container.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Electron_v1 Electron
Definition of the current "egamma version".
CaloClusterAuxContainer_v2 CaloClusterAuxContainer
Define the latest version of the calorimeter cluster auxiliary container.