Commit d7446a8a authored by Stewart Martin-Haugh's avatar Stewart Martin-Haugh Committed by Johannes Elmsheuser
Browse files

Migration L1Calo tools to JSON (ATR-21865)

parent 40b26589
......@@ -220,8 +220,6 @@ def getL1ConfigSvc( flags ):
l1ConfigSvc.BGSK = cfg["BGSK"]
log.info( "For run 3 style menu access configured LVL1ConfigSvc with InputType='DB', SMK %d, and BGSK %d", cfg['SMK'], cfg['BGSK'] )
from AthenaCommon.AppMgr import theApp
theApp.CreateSvc += [ "TrigConf::LVL1ConfigSvc/LVL1ConfigSvc" ]
return l1ConfigSvc
......@@ -252,22 +250,21 @@ def getHLTConfigSvc( flags ):
hltConfigSvc.SMK = cfg["SMK"]
log.info( "For run 3 style menu access configured HLTConfigSvc with InputType='DB' and SMK %d", cfg['SMK'] )
from AthenaCommon.AppMgr import theApp
theApp.CreateSvc += [ "TrigConf::HLTConfigSvc/HLTConfigSvc" ]
return hltConfigSvc
# provide L1 config service in new JO
def L1ConfigSvcCfg( flags ):
acc = ComponentAccumulator()
acc.addService( getL1ConfigSvc( flags ) )
l1ConfigSvc = getL1ConfigSvc( flags )
acc.addService( l1ConfigSvc, create=True )
return acc
# provide HLT config service in new JO
def HLTConfigSvcCfg( flags ):
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
acc = ComponentAccumulator()
acc.addService( getHLTConfigSvc( flags ) )
acc.addService( getHLTConfigSvc( flags ), create=True )
return acc
# provide both services in new JO
......
......@@ -25,7 +25,6 @@
#include "TrigT1Interfaces/TrigT1Interfaces_ClassDEF.h"
#include "xAODTrigL1Calo/JetElementContainer.h"
#include "TrigT1CaloEvent/JEMEtSums_ClassDEF.h"
#include "TrigT1CaloEvent/EnergyCMXData_ClassDEF.h"
#include "TrigT1CaloUtils/ModuleEnergy.h"
......
......@@ -24,11 +24,11 @@
#include "AthContainers/DataVector.h"
// Athena/Gaudi includes
#include "GaudiKernel/DataSvc.h"
#include "StoreGate/WriteHandleKey.h"
// LVL1 Calo Trigger
#include "TrigT1CaloToolInterfaces/IL1EtTools.h"
#include "TrigT1CaloEvent/JEMEtSums_ClassDEF.h"
#include "TrigT1CaloToolInterfaces/IL1EtTools.h"
#include "TrigT1Interfaces/TrigT1CaloDefs.h"
......
This diff is collapsed.
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
Tester.h - description
-------------------
begin : Wed Dec 13 2000
email : moyse@heppch.ph.qmw.ac.uk
***************************************************************************/
#ifndef _TESTER_H_
#define _TESTER_H_
// STL
#include <string>
#include <vector>
// Athena/Gaudi
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/DataObject.h"
#include "AthContainers/DataVector.h"
//#include "StoreGate/DataHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/SmartDataPtr.h"
#include "GaudiKernel/SmartRefVector.h"
#include "GaudiKernel/ServiceHandle.h"
//TrigT1Calo includes
#include "TrigT1CaloEvent/TriggerTower.h"
#include "TrigT1CaloEvent/EmTauROI.h"
#include "TrigT1CaloEvent/JetROI.h"
#include "TrigT1CaloEvent/JEMHits.h"
#include "TrigT1CaloEvent/JEMEtSums.h"
#include "TrigT1Interfaces/TrigT1CaloDefs.h"
#include "TrigT1Interfaces/SlinkWord.h"
#include "TrigT1CaloUtils/TriggerTowerKey.h"
#include "TrigT1CaloUtils/JetEnergyModuleKey.h"
#include "TrigT1CaloUtils/CPAlgorithm.h"
#include "TrigT1CaloUtils/JetAlgorithm.h"
#include "TrigT1CaloToolInterfaces/IL1EmTauTools.h"
#include "TrigT1CaloToolInterfaces/IL1JetTools.h"
#include "TrigT1CaloToolInterfaces/IL1EtTools.h"
//Default for parameters of this algorithm
//These can be overridden by job options.
//Descriptions are given in the class declaration
#define DEFAULT_TriggerTowerLocation "/Event/LVL1TriggerTowers"
#define DEFAULT_EmTauROILocation "/Event/EmTauROIs"
#define DEFAULT_actualROIWordLocation "TestVectors/RoI_elnew.dat"
/**LVL1 namespace.
This belongs to the TrigT1Calo atrig simulation.
*/
namespace LVL1 {
/**
The Tester algorithm checks the performance of the LVL1 em simulation.
*/
class Tester : public AthAlgorithm
{
public:
//-------------------------
// Constructors/Destructors
//
// Athena requires that the constructor takes certain arguments
// (and passes them directly to the constructor of the base class)
//-------------------------
Tester( const std::string& name, ISvcLocator* pSvcLocator ) ;
//------------------------------------------------------
// Methods used by Athena to run the algorithm
//------------------------------------------------------
StatusCode initialize() ;
StatusCode execute() ;
StatusCode finalize() ;
private:
/**this is a TriggerTower container*/
typedef DataVector<EmTauROI> t_EmTauROICollection ;
typedef DataVector<JetROI> t_JetROICollection ;
typedef DataVector<JEMHits> JEMHitsCollection;
typedef DataVector<JEMEtSums> JEMEtSumsCollection;
private: // Private methods
/** loads the Trigger Towers from the TES.*/
void loadTriggerTowers();
void loadEmTauROIs();
void loadActualROIWord();
void compareROIWords();
void printTriggerTowerValues();
void printEmTauROIValues();
/** load and lookat SlinkObject. Form lost of EmTauRoIwords from them and check coordinates. */
void examineSlinkObjects();
/** Compare RoI coords reconstructed from RoI words with coords from original RoI objects */
void compareRoIWordCoords();
/** returns a vector of RoIwords extracted from the Slink fragment. Very much a cludge at the moment */
std::vector<unsigned int>* extractRoIWords();
/** dump the cells belonging to an RoI. */
void dumpROICells();
void dumpJEMResults();
/** dump the whole collection of EDM objects */
void dumpEDM();
private: // Private attributes
std::string m_TriggerTowerLocation ;
std::string m_JetElementLocation ;
std::string m_jemHitsLocation ;
std::string m_jemEtSumsLocation ;
std::string m_CPMTobRoILocation ;
std::string m_emCMXDataLocation ;
std::string m_tauCMXDataLocation ;
std::string m_JEMTobRoILocation ;
std::string m_JetCMXDataLocation ;
std::string m_CPMCMXDataLocation ;
std::string m_CPCMXTopoDataLocation ;
std::string m_JetCMXTopoDataLocation ;
std::string m_EnergyTopoDataLocation ;
std::string m_EmTauCTPLocation ;
std::string m_JetCTPLocation ;
std::string m_EnergyCTPLocation ;
/** contains the external ROIs that will be saved
to the TES */
DataVector<EmTauROI>* m_VectorOfEmTauROIs;
/** locations within the TES to store collections of EmTauROIs*/
std::string m_EmTauROILocation ;
std::string m_actualROIWordLocation ;
std::string m_JetROILocation ;
std::vector<int> m_actualROIWords;
std::vector<int> m_generatedROIWords;
std::vector<int> m_eventsWithErrors;
int m_numberOfErrors;
int m_numberOfEvents;
int m_eventNumber;
int m_mode;
std::string m_EmTauSlinkLocation ;
ToolHandle<LVL1::IL1EmTauTools> m_EmTauTool;
ToolHandle<LVL1::IL1JetTools> m_JetTool;
ToolHandle<LVL1::IL1EtTools> m_EtTool;
/** there are 4 CP RoI RODs which have a Slink cable connected to the RoIB. This array holds pointers to 4
DataVectors containing the Slink words*/
const DataVector<LVL1CTP::SlinkWord >* m_emTauSlink[TrigT1CaloDefs::numOfCPRoIRODs];
static const unsigned int m_dumpTTs =1;//00001
static const unsigned int m_dumpEmTauRoIs =2;//00010
static const unsigned int m_compareEmTauRoIs =4;//00100
static const unsigned int m_compRoIWrdCoords =8;//01000
static const unsigned int m_dumpRoICells =16;//10000
static const unsigned int m_dumpJEMResults =32;//100000
static const unsigned int m_testEtTool =64;//100000
static const unsigned int m_testJetTool =128;//100000
static const unsigned int m_dumpEDM =256;
};
} // end of namespace bracket
#endif
#include "../Run2TriggerTowerMaker.h"
#include "../Run2CPMTowerMaker.h"
#include "../Run2JetElementMaker.h"
#include "../Tester.h"
#include "../CPMSim.h"
#include "../JEMJetSim.h"
#include "../JEMEnergySim.h"
......@@ -20,7 +19,6 @@ using namespace LVL1;
DECLARE_COMPONENT( Run2TriggerTowerMaker )
DECLARE_COMPONENT( Run2CPMTowerMaker )
DECLARE_COMPONENT( Run2JetElementMaker )
DECLARE_COMPONENT( Tester )
DECLARE_COMPONENT( CPMSim )
DECLARE_COMPONENT( JEMJetSim )
DECLARE_COMPONENT( JEMEnergySim )
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// IL1JetTools.h,
///////////////////////////////////////////////////////////////////
#ifndef ILVL1L1JETTOOLS_H
#define ILVL1L1JETTOOLS_H
#include "GaudiKernel/IAlgTool.h"
#include "TrigT1CaloEvent/JetInput.h"
#include "TrigT1CaloEvent/JetElement.h"
//#include "TrigT1CaloUtils/JetAlgorithm.h"
namespace LVL1
{
class JetAlgorithm;
/**
Interface definition for L1JetTools
*/
static const InterfaceID IID_IL1JetTools("LVL1::IL1JetTools", 1, 0);
class IL1JetTools : virtual public IAlgTool {
public:
static const InterfaceID& interfaceID( ) ;
// enter declaration of your interface-defining member functions here
virtual void findRoIs(const std::map<int, JetInput*>* elements, DataVector<JetAlgorithm>* rois) = 0;
virtual void findRoIs(const DataVector<JetElement>* jes, DataVector<JetAlgorithm>* rois, int slice = -1) = 0;
virtual void mapJetInputs(const DataVector<JetElement>* jes, std::map<int, JetInput*>* elements, int slice = -1) = 0;
virtual JetAlgorithm findRoI(double RoIeta, double RoIphi, const std::map<int, JetInput*>* elements) = 0;
virtual void formSums(double RoIeta, double RoIphi, const std::map<int, JetInput*>* elements) = 0;
virtual void formSums(uint32_t roiWord, const std::map<int, JetInput*>* elements) = 0;
virtual int ET4x4() const = 0;
virtual int ET6x6() const = 0;
virtual int ET8x8() const = 0;
virtual bool isEtMax() const = 0;
virtual unsigned int Hits() const = 0;
virtual unsigned int RoIWord() const = 0;
};
inline const InterfaceID& LVL1::IL1JetTools::interfaceID()
{
return IID_IL1JetTools;
}
} // end of namespace
#endif
......@@ -13,7 +13,7 @@ atlas_add_component( TrigT1CaloTools
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthContainers AthenaBaseComps CaloIdentifier
CaloTriggerToolLib CxxUtils EventInfo GaudiKernel PathResolver StoreGateLib LumiBlockData
CaloTriggerToolLib CxxUtils GaudiKernel PathResolver StoreGateLib LumiBlockData
TrigConfInterfaces TrigConfData TrigConfL1Data TrigT1CaloCalibConditions
TrigT1CaloCalibToolInterfaces TrigT1CaloCondSvcLib TrigT1CaloEventLib TrigT1CaloToolInterfaces
TrigT1CaloUtilsLib TrigT1Interfaces xAODEventInfo xAODTrigL1Calo )
......
......@@ -18,7 +18,6 @@
#include "TrigT1CaloUtils/CPMTobAlgorithm.h"
#include "TrigT1CaloEvent/CPMTobRoI.h"
#include "TrigT1Interfaces/CPRoIDecoder.h"
#include "TrigConfInterfaces/ILVL1ConfigSvc.h"
class AtlasDetectorID;
class Identifier;
......
......@@ -17,7 +17,6 @@
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "AthContainers/DataVector.h"
#include "TrigConfInterfaces/ILVL1ConfigSvc.h"
#include "TrigT1CaloToolInterfaces/IL1EtTools.h"
#include "TrigT1CaloToolInterfaces/IL1EnergyCMXTools.h"
#include "TrigT1CaloToolInterfaces/IL1JetElementTools.h"
......
......@@ -19,7 +19,6 @@
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "AthContainers/DataVector.h"
#include "TrigConfInterfaces/ILVL1ConfigSvc.h"
#include "TrigT1CaloToolInterfaces/IL1EtTools.h"
#include "TrigT1CaloToolInterfaces/IL1JEPEtSumsTools.h"
#include "TrigT1CaloToolInterfaces/IL1JetElementTools.h"
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// L1JetTools.cxx,
///////////////////////////////////////////////////////////////////
#include "L1JetTools.h"
#include "TrigT1Interfaces/TrigT1CaloDefs.h"
#include "TrigT1Interfaces/CoordinateRange.h"
#include "TrigT1CaloEvent/JetInput.h"
#include "TrigT1CaloEvent/JetInput_ClassDEF.h"
namespace LVL1 {
//================ Constructor =================================================
L1JetTools::L1JetTools(const std::string& t,
const std::string& n,
const IInterface* p )
:
AthAlgTool(t,n,p),
m_configSvc("TrigConf::LVL1ConfigSvc/LVL1ConfigSvc", n),
m_RoI(0)
{
declareInterface<IL1JetTools>(this);
declareProperty( "LVL1ConfigSvc", m_configSvc, "LVL1 Config Service");
}
//================ Destructor =================================================
L1JetTools::~L1JetTools()
{
if (m_RoI != 0) delete m_RoI;
}
//================ Initialisation =================================================
StatusCode L1JetTools::initialize()
{
return StatusCode::SUCCESS;
}
//================ Finalisation =================================================
StatusCode L1JetTools::finalize()
{
return StatusCode::SUCCESS;
}
//================ Need to load JetInputs into map before can form clusters =======
void L1JetTools::mapJetInputs(const DataVector<JetElement>* jes, std::map<int, JetInput*>* elements, int slice){
// Clear map before filling
elements->clear();
// Step over JEs, form JIs, and put into map
JECollection::const_iterator it ;
JetInputKey testKey(0.0, 0.0);
/** Fill map from DataVector */
JetInput* jetInput;
for( it = jes->begin(); it != jes->end(); ++it ){
double jetElementPhi=(*it)->phi();
double jetElementEta=(*it)->eta();
int jetElementET = 0;
if (slice < 0) { // Default to using peak slice
jetElementET = (*it)->energy();
}
else { // Use user-specified slice
jetElementET = (*it)->sliceEnergy(slice);
}
// Don't waste time & fill the JetInput map with empty elements
if (jetElementET == 0) continue;
if (!testKey.isFCAL(jetElementEta)) { // 1-to-1 JE->JI outside FCAL
int key = testKey.jeKey(jetElementPhi,jetElementEta);
std::map<int, JetInput*>::iterator test=elements->find( key );
if (test == elements->end()){
// no JI yet. Create it!
ATH_MSG_DEBUG( "Creating JetInput at ("
<< jetElementPhi << " , " << jetElementEta << ")" );
jetInput=new JetInput(jetElementPhi,jetElementEta, jetElementET, key);
elements->insert(std::map<int, JetInput*>::value_type(key,jetInput)); //and put it in the map.
}
else{
ATH_MSG_ERROR( "JetInput already exists (shouldn't happen!) " );
}
}
else { // FCAL JEs are divided into 2 JIs
// Each gets half of the ET. If value is odd, remainder added to lower JI
int jetInputET = (jetElementET>>1);
int underflow = jetElementET&0x1;
// Modifier: if JetElement is saturated, both "halves" should saturate
if ((*it)->isSaturated()) {
jetInputET = jetElementET; // don't divide saturated ET
underflow = 0; // want both halves set to same value
}
// Phi coordinates of the two elements
double phiOffset = testKey.dPhi(jetElementPhi,jetElementEta)/2.;
std::vector<double> phiValues;
std::vector<int> etValues;
phiValues.push_back(jetElementPhi - phiOffset);
etValues.push_back(jetInputET+underflow);
phiValues.push_back(jetElementPhi + phiOffset);
etValues.push_back(jetInputET);
// Calculate keys, create JI, and add (halved) ET to each
for (size_t iphi = 0; iphi < phiValues.size(); ++iphi) {
int key = testKey.jeKey(phiValues[iphi],jetElementEta);
std::map<int, JetInput*>::iterator test=elements->find( key );
JetInput* jetInput=0;
if (test == elements->end()){
// no JI yet. Create it!
ATH_MSG_DEBUG( "Creating JetInput at ("
<< phiValues[iphi] << " , " << jetElementEta << ")" );
jetInput=new JetInput(phiValues[iphi],jetElementEta, etValues[iphi], key);
elements->insert(std::map<int, JetInput*>::value_type(key,jetInput)); //and put it in the map.
}
else{
ATH_MSG_ERROR( "FCAL JetInput already exists (shouldn't happen!) " );
}
} // end loop over parts of the JE
} // end handling of FCAL JEs
}//endfor
}
/** Find list of RoIs passing at least 1 threshold */
void L1JetTools::findRoIs(const std::map<int, JetInput*>* elements, DataVector<JetAlgorithm>* rois){
// Start with an empty DataVector
rois->clear();
/** Now step through JetInput map <br>
Each element could be reference element of 4 RoIs <br>
But need to ensure we don't double count, so we use <br>
a std::map to keep track of which RoIs already exist <br>
We also use KeyUtilities to find neighbours (to allow <br>
for the variable sizes of JetInputs) */
JetInputKey testKey(0.0, 0.0);
std::map<int, int> analysed;
std::map<int, JetInput*>::const_iterator input = elements->begin();
for ( ; input != elements->end(); ++input) {
double eta = (*input).second->eta();
double startPhi = (*input).second->phi();
for (int etaOffset = 0; etaOffset >= -1; etaOffset--) {
Coordinate tempCoord(startPhi, eta);
for (int phiOffset = 0; phiOffset >= -1; phiOffset--) {
int key = testKey.jeKey(tempCoord);
std::map<int, int>::iterator test = analysed.find(key);
if (test == analysed.end()) {
analysed.insert(std::map<int, int>::value_type(key,1));
double tempEta = tempCoord.eta();
double tempPhi = tempCoord.phi();
JetAlgorithm* roi = new JetAlgorithm(tempEta, tempPhi, elements, m_configSvc);
if (roi->Hits() != 0) {
rois->push_back(roi);
}
else {
delete roi;
}
}
tempCoord = testKey.downPhi(tempCoord); // decrement phi
} // phi offset loop
tempCoord = testKey.leftEta(tempCoord); // decrement eta
eta = tempCoord.eta();
if (eta == TrigT1CaloDefs::RegionERROREtaCentre) break; // gone outside detector
} // eta offset loop
} // loop over JetInput map
}
/** Find list of RoIs passing at least 1 threshold */
void L1JetTools::findRoIs(const DataVector<JetElement>* jes, DataVector<JetAlgorithm>* rois, int slice){
/** Need a map of JetInputs as input */
std::map<int, JetInput*>* inputs = new std::map<int, JetInput*>;
mapJetInputs(jes, inputs, slice);
/** Now find the RoIs in this map */
findRoIs(inputs, rois);
/** Clean up JetInputs */
for (std::map<int, JetInput*>::iterator it = inputs->begin(); it != inputs->end(); ++it) {
delete (*it).second;
}
delete inputs;
}
/** Form RoI object for specified coordinate */
JetAlgorithm L1JetTools::findRoI(double RoIeta, double RoIphi, const std::map<int, JetInput*>* elements){
JetAlgorithm roi(RoIeta, RoIphi, elements, m_configSvc);
return roi;
}
///=====================Form clusters for given coordinates ====================
void L1JetTools::formSums(double RoIeta, double RoIphi, const std::map<int, JetInput*>* elements) {
// Initialise
if (m_RoI != 0) delete m_RoI;
// Performs all processing for this location
m_RoI = new JetAlgorithm(RoIeta, RoIphi, elements, m_configSvc);
}
///=====================Form clusters for given RoI ====================
void L1JetTools::formSums(uint32_t roiWord, const std::map<int, JetInput*>* elements) {
// Initialise
if (m_RoI != 0) delete m_RoI;
// Find RoI coordinate
CoordinateRange coord = m_conv.coordinate(roiWord);
float RoIphi = coord.phi();
float RoIeta = coord.eta();
// For this purpose we need to resolve the 2 possible FJ coordinates at end C
// This is necessary here due to the large size of FCAL JetElements
if (RoIeta > 3.1 && m_conv.column(roiWord) != 3) RoIeta = 3.15;
// Performs all processing for this location
m_RoI = new JetAlgorithm(RoIeta, RoIphi, elements, m_configSvc);