ATLAS Offline Software
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>
11 #include "xAODJet/JetContainer.h"
13 
16 
17 #ifndef XAOD_STANDALONE
18 // allows to test EL
19 #include "AthLinks/ElementLink.h"
20 #include "SGTools/TestStore.h"
21 using namespace SGTest;
22 #else
23 #include "xAODRootAccess/Init.h"
24 #include "xAODRootAccess/TEvent.h"
25 #include "xAODRootAccess/TStore.h"
27 #endif
28 
29 
30 namespace 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 
SGTest::store
TestStore store
Definition: TestStore.cxx:23
SGTest
Definition: TestStore.h:26
SETCLUSTERRAWMOM
#define SETCLUSTERRAWMOM(E, eta, phi)
xAOD::JetAuxContainer
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
Definition: JetAuxContainer.h:22
xAOD::TActiveStore::store
static TStore * store()
Access the currently active TStore object.
Definition: TActiveStore.cxx:16
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
CaloClusterAuxContainer.h
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::JetConstitScaleMomentum
@ JetConstitScaleMomentum
Definition: JetTypes.h:29
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::JetAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: JetAuxContainer_v1.h:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::getDataSourcePointerFunc
getDataSourcePointerFunc_t * getDataSourcePointerFunc
TEvent.h
Init.h
DataVector::back
const T * back() const
Access the last element in the collection as an rvalue.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::JetEMScaleMomentum
@ JetEMScaleMomentum
Definition: JetTypes.h:28
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
xAOD::JetTests::fillStandardTestJets
void fillStandardTestJets(JetContainer &jetCont)
Fill input JetContainer with a list of test jets.
Definition: JetFactory.h:104
TestStore.h
Dummy event store, for regression tests.
SGTest::ATLAS_NOT_THREAD_SAFE
void initTestStore ATLAS_NOT_THREAD_SAFE()
Definition: TestStore.cxx:247
xAOD::CaloClusterAuxContainer_v2
Auxiliary container for calorimeter cluster containers.
Definition: CaloClusterAuxContainer_v2.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::CaloClusterAuxContainer
CaloClusterAuxContainer_v2 CaloClusterAuxContainer
Define the latest version of the calorimeter cluster auxiliary container.
Definition: CaloClusterAuxContainer.h:16
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SGTest::TestStore::record
void record(const T *p, const std::string &key)
Definition: TestStore.h:81
gErrorIgnoreLevel
int gErrorIgnoreLevel
CaloClusterContainer
CaloClusterContainer
Definition: CaloTPCnv.cxx:21
python.PyAthena.v
v
Definition: PyAthena.py:154
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
xAOD::TStore::record
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
JetContainer.h
CaloClusterContainer.h
SETCLUSTERMOM
#define SETCLUSTERMOM(E, eta, phi)
JetAuxContainer.h
xAOD::JetTests::fillJets
void fillJets(JetContainer &jetCont, const std::vector< xAOD::JetFourMom_t > &jet4moms, const std::map< std::string, std::vector< float >> jetAttMap)
Fill input JetContainer with new jets which 4-momentum are given by jet4moms and with attributes as g...
Definition: JetFactory.h:88
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
TActiveStore.h
TStore.h
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31