ATLAS Offline Software
Loading...
Searching...
No Matches
JetFactory.h
Go to the documentation of this file.
1// this file is -*- C++ -*-
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
5
6#ifndef XAODJET_TEST_JETFACTORY_H
7#define XAODJET_TEST_JETFACTORY_H
8
9#include <map>
10#include <vector>
13
16
17#ifndef XAOD_STANDALONE
18// allows to test EL
19#include "AthLinks/ElementLink.h"
20#include "SGTools/TestStore.h"
21using namespace SGTest;
22#else
23#include "xAODRootAccess/Init.h"
27#endif
28
29
30namespace xAOD {
31 namespace JetTests {
32
33
34 template<typename T>
35 void record ATLAS_NOT_THREAD_SAFE (T* cont, const std::string & name) {
36#ifndef XAOD_STANDALONE
37 // *********************** init in Athena
38 initTestStore();
39 store.record(cont, name);
40 store.record((xAOD::IParticleContainer*)cont, name); // also store the container as an IParticleContainer
41#else
42 // *********************** init in standalone
43
44 gErrorIgnoreLevel = kWarning;
45 assert( xAOD::Init() );
46 // Create a TEvent object:
48
49 xAOD::TStore tds;
50 xAOD::TStore* transDataStore = xAOD::TActiveStore::store();
51
52 assert( transDataStore != 0 );
53
54 tds.record(cont, name).ignore();
55
56#endif
57
58 }
59
60
61
63 JetContainer * createEmptyJetContainer ATLAS_NOT_THREAD_SAFE (const std::string & name) {
64 JetContainer * jetCont = new JetContainer();
66 jetCont->setStore(aux);
67 record(jetCont, name);
68 return jetCont;
69 }
70
71
72
74 void fillJets(JetContainer & jetCont, const std::vector<xAOD::JetFourMom_t>& jet4moms ){
75 for( const xAOD::JetFourMom_t &v : jet4moms ){
76 jetCont.push_back(new xAOD::Jet());
77 xAOD::Jet *jet = jetCont.back();
78 jet->setJetP4( v ); // set the P4 of the last inserted jet
79 }
80
81 }
82
84 void fillJets(JetContainer & jetCont, const std::vector<xAOD::JetFourMom_t>& jet4moms,
85 const std::map<std::string, std::vector<float>> jetAttMap
86 ){
87 int i=0;
88 for( const xAOD::JetFourMom_t &v : jet4moms ){
89 jetCont.push_back(new xAOD::Jet());
90 xAOD::Jet *jet = jetCont.back();
91 jet->setJetP4( v ); // set the P4 of the last inserted jet
92 for( const auto& attpair : jetAttMap) { jet->setAttribute<float>(attpair.first, attpair.second[i]);}
93 i++;
94 }
95
96 }
97
98
101 static const std::vector<xAOD::JetFourMom_t> jet4moms =
102 {
103 xAOD::JetFourMom_t(40000, 0, 1, 10000 ),
104 xAOD::JetFourMom_t(40000, 0.01, 2, 10000 ),
105 xAOD::JetFourMom_t(40000, 0.01, 2, 0.),
106 xAOD::JetFourMom_t(40000, 0.2, 2, 10000.),
107 xAOD::JetFourMom_t(40000, 1.0, 2, 10000.),
108 xAOD::JetFourMom_t(40000, 1.001, 2, 10000.),
109 xAOD::JetFourMom_t(40000, 2., 2, 10000.),
110 xAOD::JetFourMom_t(40000, 3., 2, 10000.),
111 xAOD::JetFourMom_t(40000, 3.22, 2, 10000.),
112 xAOD::JetFourMom_t(40000, 4., 2, 10000.),
113 xAOD::JetFourMom_t(40000, 5., 2, 10000.),
114 xAOD::JetFourMom_t(40000, 5.5, 2, 10000.),
115
116 xAOD::JetFourMom_t(0.1, 1.0, 2, 10000.),
117 xAOD::JetFourMom_t(100000, 1.0, 2, 10000.),
118 xAOD::JetFourMom_t(500000, 1.0, 2, 10000.),
119 xAOD::JetFourMom_t(1000000, 1.0, 2, 10000.),
120 xAOD::JetFourMom_t(10000000, 1.0, 2, 10000.),
121
122 xAOD::JetFourMom_t(100000, 1.0, 2, 100000.),
123 xAOD::JetFourMom_t(100000, 1.0, 2, 1000000.)
124 };
125
126 std::map< std::string, std::vector<float> > jetAttMap =
127 { { "Width", std::vector<float>(jet4moms.size(), 0.123 )} };
128 fillJets(jetCont, jet4moms, jetAttMap);
129
130 // also set scales :
131 for(Jet* jet: jetCont){
132 jet->setJetP4(xAOD::JetScale::JetConstitScaleMomentum, 0.9*jet->jetP4());
133 jet->setJetP4(xAOD::JetScale::JetEMScaleMomentum, 0.7*jet->jetP4());
134 }
135 }
136
137
138
140 CaloClusterContainer * createEmptyCaloClusterContainer ATLAS_NOT_THREAD_SAFE (const std::string & name) {
141 CaloClusterContainer * clustCont = new CaloClusterContainer();
143 clustCont->setStore(aux);
144 record(clustCont, name);
145 return clustCont;
146 }
147
148
150 void fillStandardTestClusters ATLAS_NOT_THREAD_SAFE (CaloClusterContainer & clustCont){
151
152 for(int i=0; i<10; i++){
154 clustCont.push_back(cl);
155
156#define SETCLUSTERMOM( E, eta, phi ) cl->setE(E);cl->setEta(eta);cl->setPhi(phi);cl->setM(0)
157#define SETCLUSTERRAWMOM( E, eta, phi ) cl->setRawE(E);cl->setRawEta(eta);cl->setRawPhi(phi);cl->setRawM(0)
158 SETCLUSTERMOM( 1000+i*1.1, -5+i*0.1, 0);
159 SETCLUSTERRAWMOM( 500+i*2.2, -5+i*0.1, 0);
160
161 }
162 }
163
164
165 }
166}
167
168#endif
169
#define SETCLUSTERRAWMOM(E, eta, phi)
#define SETCLUSTERMOM(E, eta, phi)
Dummy event store, for regression tests.
const T * back() const
Access the last element in the collection as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
static TStore * store()
Access the currently active TStore object.
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
TestStore store
Definition TestStore.cxx:22
void fillJets(JetContainer &jetCont, const std::vector< xAOD::JetFourMom_t > &jet4moms)
Fill input JetContainer with new jets which 4-momentum are given by jet4moms.
Definition JetFactory.h:74
void fillStandardTestJets(JetContainer &jetCont)
Fill input JetContainer with a list of test jets.
Definition JetFactory.h:100
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
@ JetEMScaleMomentum
Definition JetTypes.h:28
@ JetConstitScaleMomentum
Definition JetTypes.h:29
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
void ClearTransientTrees ATLAS_NOT_THREAD_SAFE()
Function cleaning up the managed memory.
CaloClusterAuxContainer_v2 CaloClusterAuxContainer
Define the latest version of the calorimeter cluster auxiliary container.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17