Commit 19da96b4 authored by Florian Urs Bernlochner's avatar Florian Urs Bernlochner Committed by Graeme Stewart
Browse files

fixed another bug in ETy component (xAODTrigMissingET-00-00-09)

parent 5e3b55f6
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "xAODTrigMissingET/versions/TrigMissingETAuxContainer_v1.h"
namespace xAOD {
TrigMissingETAuxContainer_v1::TrigMissingETAuxContainer_v1 ()
: AuxContainerBase() {
AUX_VARIABLE ( ex );
AUX_VARIABLE ( ey );
AUX_VARIABLE ( ez );
AUX_VARIABLE ( sumEt );
AUX_VARIABLE ( sumE );
AUX_VARIABLE ( flag );
AUX_VARIABLE ( roiWord );
AUX_VARIABLE ( nameOfComponent );
AUX_VARIABLE ( exComponent );
AUX_VARIABLE ( eyComponent );
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigMissingET_v1.cxx 615412 2014-09-06 12:55:36Z florianb $
// Implement the MissingET trigger object.
// System include(s):
#include <vector>
#include <string>
#include <stdexcept>
// EDM include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTrigMissingET/versions/TrigMissingET_v1.h"
namespace xAOD {
// Default ctor
TrigMissingET_v1::TrigMissingET_v1()
: SG::AuxElement() {
}
// Simple accessor functions for the "default variable" access pattern
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, float, ex, setEx)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, float, ey, setEy)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, float, ez, setEz)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, float, sumEt,
setSumEt)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, float, sumE, setSumE)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, int, flag, setFlag)
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER (TrigMissingET_v1, uint32_t, roiWord,
setRoiWord)
//
// Accessors used by multiple functions:
//
static SG::AuxElement::Accessor< std::vector< std::string > >
nameAcc( "nameOfComponent" );
static SG::AuxElement::Accessor< std::vector< float > >
exAcc( "exComponent" );
static SG::AuxElement::Accessor< std::vector< float > >
eyAcc( "eyComponent" );
// Define a component name
void TrigMissingET_v1::
defineComponents( const std::vector< std::string >& componentNames ) {
// Make sure that we aren't killing off something that already exists
if( nameAcc( *this ).size() > 0) {
throw std::runtime_error( "Attempt to redefine component list for "
"xAOD::TrigMissingET object" );
}
// Assign the component names:
nameAcc( *this ) = componentNames;
// Initialise all the variables:
exAcc( *this ).resize( componentNames.size(), 0.0 );
eyAcc( *this ).resize( componentNames.size(), 0.0 );
return;
}
// Store the name of the component
void TrigMissingET_v1::setNameOfComponent( unsigned int index,
const std::string& str ) {
nameAcc( *this ).at( index ) = str;
return;
}
// Give back the number of components
unsigned int TrigMissingET_v1::getNumberOfComponents() const {
return nameAcc( *this ).size();
}
const std::string&
TrigMissingET_v1::nameOfComponent( unsigned int index ) const {
return nameAcc( *this ).at( index );
}
void TrigMissingET_v1::setExComponent( unsigned int index, float val ) {
exAcc( *this ).at( index ) = val;
return;
}
float TrigMissingET_v1::exComponent( unsigned int index ) const {
return exAcc( *this ).at( index );
}
void TrigMissingET_v1::setEyComponent( unsigned int index, float val ) {
eyAcc( *this ).at( index ) = val;
return;
}
float TrigMissingET_v1::eyComponent( unsigned int index ) const {
return eyAcc( *this ).at( index );
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ContainerProxies.cxx 592495 2014-04-11 08:47:29Z krasznaa $
// EDM include(s):
#include "xAODCore/AddDVProxy.h"
// Local include(s):
#include "xAODTrigMissingET/versions/TrigMissingETContainer_v1.h"
// Set up the collection proxies:
ADD_NS_DV_PROXY( xAOD, TrigMissingETContainer_v1 );
# this makefile also gets parsed by shell scripts
# therefore it does not support full make syntax and features
# edit with care
# for full documentation check:
# https://twiki.cern.ch/twiki/bin/viewauth/Atlas/RootCore#Package_Makefile
PACKAGE = xAODTrigMissingET
PACKAGE_PRELOAD =
PACKAGE_CXXFLAGS =
PACKAGE_OBJFLAGS =
PACKAGE_LDFLAGS =
PACKAGE_BINFLAGS =
PACKAGE_LIBFLAGS =
PACKAGE_DEP = AthContainers AthLinks xAODCore
PACKAGE_TRYDEP =
PACKAGE_CLEAN =
PACKAGE_NOGRID =
PACKAGE_PEDANTIC = 0
PACKAGE_NOOPT = 0
PACKAGE_NOCC = 0
PACKAGE_REFLEX = 1
include $(ROOTCOREDIR)/Makefile-common
package xAODTrigMissingET
author Gordon Watts <gwatts@uw.edu>
public
use AtlasPolicy AtlasPolicy-*
use AthContainers AthContainers-* Control
use SGTools SGTools-* Control
use xAODCore xAODCore-* Event/xAOD
library xAODTrigMissingET ../Root/*.cxx
apply_pattern installed_library
# Local things
private
# Use reflex for dict generation...
use AtlasReflex AtlasReflex-* External
use AtlasROOT AtlasROOT-* External
use AthLinks AthLinks-* Control
apply_pattern lcgdict dict=xAODTrigMissingET selectionfile=selection.xml \
headerfiles="../xAODTrigMissingET/xAODTrigMissingETDict.h" \
extralibfiles=../Root/dict/*.cxx
#
# Use "make CppUnit" to run the unit tests for this package.
#
#use TestPolicy TestPolicy-*
#use TestTools TestTools-* AtlasTest
#apply_pattern CppUnit name=xAODTrigMissingET files="-s=../test TrigMissingETTest_CppUnit.cxx"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
This package contains the EDM classes for the missing ET in the trigger, in particular, TrigMissingET.
@mainpage
@htmlinclude used_packages.html
@include requirements
*/
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//
// Code to test some of the methods in the MissingET object. Especially
// where the code in the TrigMissingET object is anything more than very
// simple.
//
#ifdef ROOTCORE
int main() { return 0; }
#else
#include "xAODTrigMissingET/TrigMissingET.h"
#include "xAODTrigMissingET/TrigMissingETAuxContainer.h"
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/Exception.h>
using namespace std;
using namespace xAOD;
///
/// The object that contains all the tests for the TrigMissingET functionality.
///
class TrigMissingETTest : public CppUnit::TestFixture
{
/////////////
// Define the tests that are going to be run.
//
CPPUNIT_TEST_SUITE (TrigMissingETTest);
CPPUNIT_TEST (testSimpleCreation);
CPPUNIT_TEST_EXCEPTION (testSetComponentNotAllocated, std::out_of_range);
CPPUNIT_TEST (setPreallocatedComponent);
CPPUNIT_TEST (preallocatedComponentHasNameSet);
CPPUNIT_TEST (setPreallocatedComponentSetZero);
CPPUNIT_TEST_EXCEPTION (cantPreallocateTwice, std::runtime_error);
CPPUNIT_TEST_SUITE_END();
// End of the test suite definition.
////////////
// Make sure we can create and save a simple variable (non-component).
void testSimpleCreation()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
t->setEx(10.0);
t->setFlag(5);
CPPUNIT_ASSERT_EQUAL (5, t->flag());
CPPUNIT_ASSERT_DOUBLES_EQUAL (10.0, t->ex(), 0.001);
}
// Make sure we fail if we try to set the value of a component that we've
// not yet defined.
void testSetComponentNotAllocated()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
// Should cause failure since we've not pre-allocated the component
t->setNameOfComponent(4, "hi");
}
// Make sure we can set a preallocated component value, as expected.
void setPreallocatedComponent()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
// Allocate the components
vector<string> names;
names.push_back("hi");
names.push_back("there");
t->defineComponents(names);
// Should cause failure since we've not pre-allocated the component
t->setExComponent(1, 5.4);
CPPUNIT_ASSERT_DOUBLES_EQUAL (5.4, t->exComponent(1), 0.0001);
}
// Make sure names are being saved in the pre allocated components
void preallocatedComponentHasNameSet()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
// Allocate the components
vector<string> names;
names.push_back("hi");
names.push_back("there");
t->defineComponents(names);
// Should cause failure since we've not pre-allocated the component
CPPUNIT_ASSERT_EQUAL (string("there"), t->nameOfComponent(1));
}
// Make sure that component variables are initialized to zero when allocated.
void setPreallocatedComponentSetZero()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
// Allocate the components
vector<string> names;
names.push_back("hi");
names.push_back("there");
t->defineComponents(names);
// Should cause failure since we've not pre-allocated the component
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, t->exComponent(1), 0.0001);
}
// It is not legal to allocate a set of components twice. This should throw
// an exception.
void cantPreallocateTwice()
{
TrigMissingETAuxContainer *tc = new TrigMissingETAuxContainer();
TrigMissingET *t = new TrigMissingET();
t->setStore(tc);
// Allocate the components
vector<string> names;
names.push_back("hi");
names.push_back("there");
t->defineComponents(names);
t->defineComponents(names);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION (TrigMissingETTest);
#include <TestPolicy/CppUnit_testdriver.cxx>
#endif // ROOTCORE
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef xAODTrigMissingET_TrigMissingET_H
#define xAODTrigMissingET_TrigMissingET_H
#include "xAODTrigMissingET/versions/TrigMissingET_v1.h"
namespace xAOD {
/// Define the most recent version of the TrigMissingET class.
typedef TrigMissingET_v1 TrigMissingET;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef xAODTrigMissingET_TrigMissingETAUXCONTAINER_H
#define xAODTrigMissingET_TrigMissingETAUXCONTAINER_H
#include "xAODTrigMissingET/versions/TrigMissingETAuxContainer_v1.h"
namespace xAOD {
/// Define the most recent version of the AuxContainer for the TrigMissingET object(s).
typedef TrigMissingETAuxContainer_v1 TrigMissingETAuxContainer;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef xAODTrigMissingET_TrigMissingETCONTAINER_H
#define xAODTrigMissingET_TrigMissingETCONTAINER_H
#include "xAODTrigMissingET/versions/TrigMissingETContainer_v1.h"
#include "xAODTrigMissingET/TrigMissingET.h"
namespace xAOD {
/// DataVector of TrigMissingET - the current version
typedef TrigMissingETContainer_v1 TrigMissingETContainer;
}
#endif
<lcgdict>
<class name="xAOD::TrigMissingET_v1" />
<class name="xAOD::TrigMissingETContainer_v1" id="3EA0678D-5DCA-4BA8-BB29-775CB9A246AC" />
<class name="xAOD::TrigMissingETAuxContainer_v1" id="E8C1613E-5E47-4B7F-8ED7-B30A8FE21DB4" />
<class name="DataLink<xAOD::TrigMissingETContainer_v1>" />
<class name="std::vector<DataLink<xAOD::TrigMissingETContainer_v1> >" />
<class name="ElementLink<xAOD::TrigMissingETContainer_v1>" />
<class name="std::vector<ElementLink<xAOD::TrigMissingETContainer_v1> >" />
<class name="std::vector<std::vector<ElementLink<xAOD::TrigMissingETContainer_v1> > >" />
<!-- Suppress the unwanted classes found by ROOT 6. -->
<!-- Hopefully we can remove these extra lines at one point... -->
<exclusion>
<class name="SG::IConstAuxStore" />
<class name="DataLink<SG::IConstAuxStore>" />
</exclusion>
</lcgdict>
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigMissingETAuxContainer_v1.h 606381 2014-07-14 18:01:32Z florianb $
#ifndef xAODTrigMissingET_TrigMissingETAUXCONTAINTER_V1_H
#define xAODTrigMissingET_TrigMissingETAUXCONTAINTER_V1_H
// System include(s):
#include <vector>
extern "C" {
# include <stdint.h>
}
// EDM include(s):
#include "xAODCore/AuxContainerBase.h"
namespace xAOD {
/// AuxContainer for TrigMissingET classes.
///
/// Storage of all items in the TrigMissingET classes. Includes vectors to hold onto
/// an arbitrary list of TrigMissingET Components.
///
/// @author Gordon Watts <gwatts@uw.edu>
///
/// $Revision: 606381 $
/// $Date: 2014-07-14 20:01:32 +0200 (Mon, 14 Jul 2014) $
///
class TrigMissingETAuxContainer_v1 : public AuxContainerBase {
public:
/// Default constructor
TrigMissingETAuxContainer_v1();
private:
/// @name Storage for basic kinematic properties
/// @{
std::vector<float> ex;
std::vector<float> ey;
std::vector<float> ez;
std::vector<float> sumEt;
std::vector<float> sumE;
/// @}
/// @name Storage for status words
/// @{
std::vector<int> flag;
std::vector<uint32_t> roiWord;
/// @}
/// @name Storage for Component data
/// @{
std::vector<std::vector<std::string> > nameOfComponent;
std::vector<std::vector<float> > exComponent;
std::vector<std::vector<float> > eyComponent;
/// @}
};
}
// SET UP A CLID AND STOREGATE INHERITANCE FOR THE CLASS:
#ifndef XAOD_STANDALONE
#include "SGTools/CLASS_DEF.h"
CLASS_DEF( xAOD::TrigMissingETAuxContainer_v1, 1292357238, 1 )
#include "SGTools/BaseInfo.h"
SG_BASE( xAOD::TrigMissingETAuxContainer_v1, xAOD::AuxContainerBase );
#endif // not XAOD_STANDALONE
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef xAODTrigMissingET_TrigMissingETCONTAINER_V1_H
#define xAODTrigMissingET_TrigMissingETCONTAINER_V1_H
#include "AthContainers/DataVector.h"
#include "xAODTrigMissingET/versions/TrigMissingET_v1.h"
namespace xAOD {
/// Datavector of all trig missing et objects.
///
/// Even though there is only a single TrigMissingET object per
/// event in the trigger software, the architecture of the trigger means
/// that one needs to save it in a vector.
typedef DataVector<xAOD::TrigMissingET_v1> TrigMissingETContainer_v1;
}
// Setup a CLID for the container... not sure what this is for.
#ifndef XAOD_STANDALONE
#include "SGTools/CLASS_DEF.h"
CLASS_DEF (xAOD::TrigMissingETContainer_v1, 1134334, 1)
#endif
#endif
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigMissingET_v1.h 615398 2014-09-06 06:37:02Z florianb $
#ifndef xAODTrigMissingET_TrigMissingET_V1_H
#define xAODTrigMissingET_TrigMissingET_V1_H
// STL include(s):
#include <string>
extern "C" {
# include <stdint.h>
}
// EDM include(s):
#include "AthContainers/AuxElement.h"
namespace xAOD {
/// Class holding the Missing ET trigger fex results.
///
/// A class that holds the missing ET vector for the trigger. It further contains a
/// list of components.
///
/// @author Gordon Watts <gwatts@uw.edu>
///
/// $Revision: 615398 $
/// $Date: 2014-09-06 08:37:02 +0200 (Sat, 06 Sep 2014) $
///
class TrigMissingET_v1 : public SG::AuxElement {
public:
/// Defaut constructor
TrigMissingET_v1();
/// @name Basic Kinematic Property accessors
/// @{
/// Get the x component of the missing energy
float ex() const;