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-2019 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# ifdef SGTOOLS_CURRENTEVENTSTORE_H
39 initTestStore();
40# else
41 SG::getDataSourcePointerFunc = getTestDataSourcePointer;
42# endif
43 store.record(cont, name);
44 store.record((xAOD::IParticleContainer*)cont, name); // also store the container as an IParticleContainer
45#else
46 // *********************** init in standalone
47
48 gErrorIgnoreLevel = kWarning;
49 assert( xAOD::Init() );
50 // Create a TEvent object:
52
53 xAOD::TStore tds;
54 xAOD::TStore* transDataStore = xAOD::TActiveStore::store();
55
56 assert( transDataStore != 0 );
57
58 tds.record(cont, name).ignore();
59
60#endif
61
62 }
63
64
65
67 JetContainer * createEmptyJetContainer ATLAS_NOT_THREAD_SAFE (const std::string & name) {
68 JetContainer * jetCont = new JetContainer();
70 jetCont->setStore(aux);
71 record(jetCont, name);
72 return jetCont;
73 }
74
75
76
78 void fillJets(JetContainer & jetCont, const std::vector<xAOD::JetFourMom_t>& jet4moms ){
79 for( const xAOD::JetFourMom_t &v : jet4moms ){
80 jetCont.push_back(new xAOD::Jet());
81 xAOD::Jet *jet = jetCont.back();
82 jet->setJetP4( v ); // set the P4 of the last inserted jet
83 }
84
85 }
86
88 void fillJets(JetContainer & jetCont, const std::vector<xAOD::JetFourMom_t>& jet4moms,
89 const std::map<std::string, std::vector<float>> jetAttMap
90 ){
91 int i=0;
92 for( const xAOD::JetFourMom_t &v : jet4moms ){
93 jetCont.push_back(new xAOD::Jet());
94 xAOD::Jet *jet = jetCont.back();
95 jet->setJetP4( v ); // set the P4 of the last inserted jet
96 for( const auto& attpair : jetAttMap) { jet->setAttribute<float>(attpair.first, attpair.second[i]);}
97 i++;
98 }
99
100 }
101
102
105 static const std::vector<xAOD::JetFourMom_t> jet4moms =
106 {
107 xAOD::JetFourMom_t(40000, 0, 1, 10000 ),
108 xAOD::JetFourMom_t(40000, 0.01, 2, 10000 ),
109 xAOD::JetFourMom_t(40000, 0.01, 2, 0.),
110 xAOD::JetFourMom_t(40000, 0.2, 2, 10000.),
111 xAOD::JetFourMom_t(40000, 1.0, 2, 10000.),
112 xAOD::JetFourMom_t(40000, 1.001, 2, 10000.),
113 xAOD::JetFourMom_t(40000, 2., 2, 10000.),
114 xAOD::JetFourMom_t(40000, 3., 2, 10000.),
115 xAOD::JetFourMom_t(40000, 3.22, 2, 10000.),
116 xAOD::JetFourMom_t(40000, 4., 2, 10000.),
117 xAOD::JetFourMom_t(40000, 5., 2, 10000.),
118 xAOD::JetFourMom_t(40000, 5.5, 2, 10000.),
119
120 xAOD::JetFourMom_t(0.1, 1.0, 2, 10000.),
121 xAOD::JetFourMom_t(100000, 1.0, 2, 10000.),
122 xAOD::JetFourMom_t(500000, 1.0, 2, 10000.),
123 xAOD::JetFourMom_t(1000000, 1.0, 2, 10000.),
124 xAOD::JetFourMom_t(10000000, 1.0, 2, 10000.),
125
126 xAOD::JetFourMom_t(100000, 1.0, 2, 100000.),
127 xAOD::JetFourMom_t(100000, 1.0, 2, 1000000.)
128 };
129
130 std::map< std::string, std::vector<float> > jetAttMap =
131 { { "Width", std::vector<float>(jet4moms.size(), 0.123 )} };
132 fillJets(jetCont, jet4moms, jetAttMap);
133
134 // also set scales :
135 for(Jet* jet: jetCont){
136 jet->setJetP4(xAOD::JetScale::JetConstitScaleMomentum, 0.9*jet->jetP4());
137 jet->setJetP4(xAOD::JetScale::JetEMScaleMomentum, 0.7*jet->jetP4());
138 }
139 }
140
141
142
144 CaloClusterContainer * createEmptyCaloClusterContainer ATLAS_NOT_THREAD_SAFE (const std::string & name) {
145 CaloClusterContainer * clustCont = new CaloClusterContainer();
147 clustCont->setStore(aux);
148 record(clustCont, name);
149 return clustCont;
150 }
151
152
154 void fillStandardTestClusters ATLAS_NOT_THREAD_SAFE (CaloClusterContainer & clustCont){
155
156 for(int i=0; i<10; i++){
158 clustCont.push_back(cl);
159
160#define SETCLUSTERMOM( E, eta, phi ) cl->setE(E);cl->setEta(eta);cl->setPhi(phi);cl->setM(0)
161#define SETCLUSTERRAWMOM( E, eta, phi ) cl->setRawE(E);cl->setRawEta(eta);cl->setRawPhi(phi);cl->setRawM(0)
162 SETCLUSTERMOM( 1000+i*1.1, -5+i*0.1, 0);
163 SETCLUSTERRAWMOM( 500+i*2.2, -5+i*0.1, 0);
164
165 }
166 }
167
168
169 }
170}
171
172#endif
173
#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:23
getDataSourcePointerFunc_t * getDataSourcePointerFunc
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:78
void fillStandardTestJets(JetContainer &jetCont)
Fill input JetContainer with a list of test jets.
Definition JetFactory.h:104
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