8 #include <AthLinks/ElementLink.h>
26 void 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()) {
83 EgammaFactory::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"));
119 std::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) {
135 EgammaFactory::~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{
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) {
209 m_clusters->push_back(cluster);
215 return create_photon(
eta,
phi,
e, 0., 0.);
220 assert(m_histo_rconv);
221 assert(m_histo_zconv);
222 const int bin = m_histo_rconv->FindBin(
e / cosh(
eta), std::abs(
eta));
223 if (m_histo_rconv->IsBinOverflow(
bin)) {
224 return create_photon(
eta,
phi,
e, 0, 0);
226 const double rconv = m_histo_rconv->GetBinContent(
bin);
227 const double zconv = m_histo_zconv->GetBinContent(
228 m_histo_zconv->FindBin(
e / cosh(
eta), std::abs(
eta)));
230 return create_photon(
eta,
phi,
e, rconv, zconv);
235 float rconv,
float zconv) {
236 const bool isconv = (rconv > 0 and rconv < 800);
237 const auto l = get_layers_fraction(isconv ? m_histos_conv : m_histos_unconv,
239 return create_photon(
eta,
phi,
l[0] *
e,
l[1] *
e,
l[2] *
e,
l[3] *
e,
e,
244 const auto l = get_layers_fraction(m_histos_electron,
eta,
e / cosh(
eta));
245 return create_electron(
eta,
phi,
l[0] *
e,
l[1] *
e,
l[2] *
e,
l[3] *
e,
e);
249 float e1,
float e2,
float e3,
250 float e,
float rconv,
float zconv) {
254 if (rconv > 0 and rconv < 800) {
257 vertex->makePrivateStore();
262 vertex->auxdata<
float>(
"pt1") =
e / cosh(
eta) * 0.7;
263 vertex->auxdata<
float>(
"pt2") =
e / cosh(
eta) * 0.3;
264 m_vertexes->push_back(
vertex);
270 m_photons->push_back(ph);
274 std::vector<ElementLink<xAOD::CaloClusterContainer>> links_clusters;
276 links_clusters.push_back(
284 std::vector<ElementLink<xAOD::VertexContainer>> links_vertexes;
285 links_vertexes.push_back(
303 float e1,
float e2,
float e3,
310 track->makePrivateStore();
312 m_tracks->push_back(
track);
316 el->makePrivateStore();
317 m_electrons->push_back(
el);
320 std::vector<ElementLink<xAOD::TrackParticleContainer>> links_tracks;
321 links_tracks.push_back(
323 el->setTrackParticleLinks(links_tracks);
326 std::vector<ElementLink<xAOD::CaloClusterContainer>> links_clusters;
328 links_clusters.push_back(
331 el->setCaloClusterLinks(links_clusters);