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) {
123 TProfile2D*
p = prof[
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) {
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();
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(
288 std::vector<ElementLink<xAOD::VertexContainer>> links_vertexes;
289 links_vertexes.push_back(
307 float e1,
float e2,
float e3,
314 track->makePrivateStore();
316 m_tracks->push_back(
track);
320 el->makePrivateStore();
321 m_electrons->push_back(
el);
324 std::vector<ElementLink<xAOD::TrackParticleContainer>> links_tracks;
325 links_tracks.push_back(
327 el->setTrackParticleLinks(links_tracks);
330 std::vector<ElementLink<xAOD::CaloClusterContainer>> links_clusters;
332 links_clusters.push_back(
335 el->setCaloClusterLinks(links_clusters);