diff --git a/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1JetCMXTools.h b/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1JetCMXTools.h index f3a9d85180a2fde4025ec0f292c91b2c65397cfd..22a23e6db8b16aae86d6f51b08a5213ed0fb085b 100644 --- a/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1JetCMXTools.h +++ b/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1JetCMXTools.h @@ -1,12 +1,12 @@ - /*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ #ifndef LVL1L1JETCMXTOOLS_H #define LVL1L1JETCMXTOOLS_H @@ -21,112 +21,105 @@ #include "TrigConfInterfaces/ITrigConfigSvc.h" #include "TrigT1CaloToolInterfaces/IL1JetCMXTools.h" - -namespace LVL1 -{ - - /** @class L1JetCMXTools - - This is a tool to reconstruct the L1 JEM and CMX-Jet hits - from RoIs. - Used for offline monitoring and trigger reconstruction. - - Useage: L1JetCMXTools->formJEMTobRoI() // convert to JEMTobRoI from - // other RoI classes - L1JetCMXTools->formCMXJetTob() // form CMX-Jet TOBs from - // JEMTobRoIs - L1JetCMXTools->formCMXJetHits() // form CMX-Jet hits from - // CMXJetTobs - - @author Peter Faulkner - */ - -class L1JetCMXTools : virtual public IL1JetCMXTools, public AthAlgTool -{ - public: - - L1JetCMXTools(const std::string& type, const std::string& name, - const IInterface* parent); - - /** default destructor */ - virtual ~L1JetCMXTools (); - - /** standard Athena-Algorithm method */ - virtual StatusCode initialize(); - /** standard Athena-Algorithm method */ - virtual StatusCode finalize (); - - - /** form CMX-Jet TOBs from RoIs - single slice */ - virtual void formCMXJetTob(const xAOD::JEMTobRoIContainer* jemRoiVec, - xAOD::CMXJetTobContainer* cmxTobVec) const; - - /** form CMX-Jet TOBs from RoIs - multiple slices */ - virtual void formCMXJetTob( - const std::vector<const xAOD::JEMTobRoIContainer*>& jemRoiColls, - xAOD::CMXJetTobContainer* cmxTobVec, int peak) const; - - /** form complete CMX-Jet hits from CMX-Jet TOBs */ - virtual void formCMXJetHits(const xAOD::CMXJetTobContainer* cmxTobVec, - xAOD::CMXJetHitsContainer* cmxHitsVec) const; - - /** form partial CMX-Jet hits (crate) from CMX-Jet TOBs */ - virtual void formCMXJetHitsCrate(const xAOD::CMXJetTobContainer* cmxTobVec, - xAOD::CMXJetHitsContainer* cmxHitsCrate) const; - - /** form partial CMX-Jet hits (system) from crate CMX-Jet hits */ - virtual void formCMXJetHitsSystem( - const xAOD::CMXJetHitsContainer* cmxHitsCrate, - xAOD::CMXJetHitsContainer* cmxHitsSys) const; - /** form partial CMX-Jet hits (topo) from system CMX-Jet TOBs */ - virtual void formCMXJetHitsTopo(const xAOD::CMXJetTobContainer* cmxTobVec, - xAOD::CMXJetHitsContainer* cmxHitsTopo) const; - - private: - - enum HitsType { MAIN_HITS, FORWARD_HITS }; - - typedef std::vector<uint32_t> HitsVector; - typedef std::vector<uint32_t> ErrorVector; - - - /** Get hit map */ - void getHits(const xAOD::CMXJetTob* tob, HitsVector& hit0, - HitsVector& hit1) const; - - /** Add overflow bit */ - void addOverflow(ErrorVector& hitErr, const ErrorVector& tobErr) const; - /** Add hits from second vector to first */ - void addCMXJetHits(HitsVector& vec1, const HitsVector& vec2, - HitsType type) const; - /** Increment JEM/CMX hit word */ - unsigned int addHits(unsigned int hitMult, unsigned int hitVec, - int multBits, int vecBits, int nthresh) const; - - /** Merge CMX-Jet hits vectors */ - void mergeCMXJetHits(xAOD::CMXJetHitsContainer* cmxHitsVec1, - xAOD::CMXJetHitsContainer* cmxHitsVec2) const; - - void saveCMXJetHits(xAOD::CMXJetHitsContainer* cmxHitsVec, - const HitsVector& hits0, const HitsVector& hits1, - const ErrorVector& err0, const ErrorVector& err1, - int crate, int source, int peak) const; - - /** Trigger configuration service */ - ServiceHandle<TrigConf::ITrigConfigSvc> m_configSvc; - /** Number of crates */ - int m_crates; - /** Number of JEM modules per crate */ - int m_modules; - /** Maximum number of TOBs per module to CMXs */ - int m_maxTobs; - /** System crate number */ - int m_sysCrate; - /** Debug flag */ - bool m_debug; - +namespace LVL1 { + +/** @class L1JetCMXTools + + This is a tool to reconstruct the L1 JEM and CMX-Jet hits + from RoIs. + Used for offline monitoring and trigger reconstruction. + + Useage: L1JetCMXTools->formJEMTobRoI() // convert to JEMTobRoI from + // other RoI classes + L1JetCMXTools->formCMXJetTob() // form CMX-Jet TOBs from + // JEMTobRoIs + L1JetCMXTools->formCMXJetHits() // form CMX-Jet hits from + // CMXJetTobs + + @author Peter Faulkner +*/ + +class L1JetCMXTools : virtual public IL1JetCMXTools, public AthAlgTool { + public: + L1JetCMXTools(const std::string& type, const std::string& name, + const IInterface* parent); + + /** default destructor */ + virtual ~L1JetCMXTools(); + + /** standard Athena-Algorithm method */ + virtual StatusCode initialize(); + /** standard Athena-Algorithm method */ + virtual StatusCode finalize(); + + /** form CMX-Jet TOBs from RoIs - single slice */ + virtual void formCMXJetTob(const xAOD::JEMTobRoIContainer* jemRoiVec, + xAOD::CMXJetTobContainer* cmxTobVec) const; + + /** form CMX-Jet TOBs from RoIs - multiple slices */ + virtual void formCMXJetTob( + const std::vector<const xAOD::JEMTobRoIContainer*>& jemRoiColls, + xAOD::CMXJetTobContainer* cmxTobVec, int peak) const; + + /** form complete CMX-Jet hits from CMX-Jet TOBs */ + virtual void formCMXJetHits(const xAOD::CMXJetTobContainer* cmxTobVec, + xAOD::CMXJetHitsContainer* cmxHitsVec) const; + + /** form partial CMX-Jet hits (crate) from CMX-Jet TOBs */ + virtual void formCMXJetHitsCrate( + const xAOD::CMXJetTobContainer* cmxTobVec, + xAOD::CMXJetHitsContainer* cmxHitsCrate) const; + + /** form partial CMX-Jet hits (system) from crate CMX-Jet hits */ + virtual void formCMXJetHitsSystem( + const xAOD::CMXJetHitsContainer* cmxHitsCrate, + xAOD::CMXJetHitsContainer* cmxHitsSys) const; + /** form partial CMX-Jet hits (topo) from system CMX-Jet TOBs */ + virtual void formCMXJetHitsTopo(const xAOD::CMXJetTobContainer* cmxTobVec, + xAOD::CMXJetHitsContainer* cmxHitsTopo) const; + + private: + enum HitsType { MAIN_HITS, FORWARD_HITS }; + + typedef std::vector<uint32_t> HitsVector; + typedef std::vector<uint32_t> ErrorVector; + + /** Get hit map */ + void getHits(const xAOD::CMXJetTob* tob, HitsVector& hit10, HitsVector& hit11, + HitsVector& hit20, HitsVector& hit21) const; + + /** Add overflow bit */ + void addOverflow(ErrorVector& hitErr, const ErrorVector& tobErr) const; + /** Add hits from second vector to first */ + void addCMXJetHits(HitsVector& vec1, const HitsVector& vec2, + HitsType type) const; + /** Increment JEM/CMX hit word */ + unsigned int addHits(unsigned int hitMult, unsigned int hitVec, int multBits, + int vecBits, int nthresh) const; + + /** Merge CMX-Jet hits vectors */ + void mergeCMXJetHits(xAOD::CMXJetHitsContainer* cmxHitsVec1, + xAOD::CMXJetHitsContainer* cmxHitsVec2) const; + + void saveCMXJetHits(xAOD::CMXJetHitsContainer* cmxHitsVec, + const HitsVector& hits0, const HitsVector& hits1, + const ErrorVector& err0, const ErrorVector& err1, + int crate, int source, int peak) const; + + /** Trigger configuration service */ + ServiceHandle<TrigConf::ITrigConfigSvc> m_configSvc; + /** Number of crates */ + int m_crates; + /** Number of JEM modules per crate */ + int m_modules; + /** Maximum number of TOBs per module to CMXs */ + int m_maxTobs; + /** System crate number */ + int m_sysCrate; + /** Debug flag */ + bool m_debug; }; -} // end of namespace +} // end of namespace -#endif +#endif diff --git a/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1TriggerTowerTool.h b/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1TriggerTowerTool.h index 09f9e80bddb241140874cf12e4ccaf1d98b509b0..3310b5ff102ce42892f34e57d6071ebecc7e9ef2 100644 --- a/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1TriggerTowerTool.h +++ b/Trigger/TrigT1/TrigT1CaloTools/TrigT1CaloTools/L1TriggerTowerTool.h @@ -133,7 +133,7 @@ namespace LVL1 bool disabledChannel(const L1CaloCoolChannelId& channelId, unsigned int& noiseCut); bool m_debug; - + /// Id managers const CaloIdManager* m_caloMgr; @@ -149,6 +149,9 @@ namespace LVL1 /// L1Calo conditions ServiceHandle<L1CaloCondSvc> m_l1CondSvc; + /// Trig configurations + ServiceHandle<TrigConf::ILVL1ConfigSvc> m_configSvc; + // one of L1CaloPprConditionsContainer{,Run2}* bool m_isRun2; boost::any m_conditionsContainer; diff --git a/Trigger/TrigT1/TrigT1CaloTools/src/L1JetCMXTools.cxx b/Trigger/TrigT1/TrigT1CaloTools/src/L1JetCMXTools.cxx index 88d1e6dc157fd763a65eb2acc67649c7bfacb229..5ac6157ccd10f2b855326bfa33d9fdd02818ca6f 100644 --- a/Trigger/TrigT1/TrigT1CaloTools/src/L1JetCMXTools.cxx +++ b/Trigger/TrigT1/TrigT1CaloTools/src/L1JetCMXTools.cxx @@ -185,27 +185,25 @@ void L1JetCMXTools::formCMXJetHitsCrate( std::vector<HitsVector> hitVecF(2 * m_crates); std::vector<ErrorVector> errVecM(2 * m_crates); // Need overflow std::vector<ErrorVector> errVecF(2 * m_crates); - HitsVector hit0; - HitsVector hit1; + HitsVector hit10, hit20; + HitsVector hit11, hit21; xAOD::CMXJetTobContainer::const_iterator pos = cmxTobVec->begin(); xAOD::CMXJetTobContainer::const_iterator pose = cmxTobVec->end(); for (; pos != pose; ++pos) { const xAOD::CMXJetTob* tob = *pos; const int index = 2 * tob->crate(); - const int jem = tob->jem(); - const bool forward = (jem == 0 || jem == 7 || jem == 8 || jem == 15); - const HitsType type = (forward) ? FORWARD_HITS : MAIN_HITS; const std::vector<uint32_t> error(tob->errorVec()); - hit0.clear(); - hit1.clear(); - getHits(tob, hit0, hit1); - if (forward) { - addCMXJetHits(hitVecF[index], hit0, type); - addCMXJetHits(hitVecF[index + 1], hit1, type); - } else { - addCMXJetHits(hitVecM[index], hit0, type); - addCMXJetHits(hitVecM[index + 1], hit1, type); - } + hit10.clear(); + hit11.clear(); + hit20.clear(); + hit21.clear(); + getHits(tob, hit10, hit11, hit20, hit21); + + addCMXJetHits(hitVecM[index], hit10, MAIN_HITS); + addCMXJetHits(hitVecM[index + 1], hit11, MAIN_HITS); + addCMXJetHits(hitVecF[index], hit20, FORWARD_HITS); + addCMXJetHits(hitVecF[index + 1], hit21, FORWARD_HITS); + addOverflow(errVecF[index], error); addOverflow(errVecF[index + 1], error); addOverflow(errVecM[index], error); @@ -342,14 +340,17 @@ void L1JetCMXTools::formCMXJetHitsTopo( /** Temporary for testing, mostly lifted from JetAlgorithm */ -void L1JetCMXTools::getHits(const xAOD::CMXJetTob* tob, HitsVector& hit0, - HitsVector& hit1) const { +void L1JetCMXTools::getHits(const xAOD::CMXJetTob* tob, HitsVector& hit10, + HitsVector& hit11, HitsVector& hit20, + HitsVector& hit21) const { using namespace TrigConf; const std::vector<uint16_t>& energyLg(tob->energyLargeVec()); const std::vector<uint16_t>& energySm(tob->energySmallVec()); const int timeslices = energyLg.size(); - hit0.assign(timeslices, 0); - hit1.assign(timeslices, 0); + hit10.assign(timeslices, 0); + hit11.assign(timeslices, 0); + hit20.assign(timeslices, 0); + hit21.assign(timeslices, 0); std::vector<TrigConf::TriggerThreshold*> thresholds = m_configSvc->ctpConfig()->menu().thresholdVector(); @@ -363,84 +364,28 @@ void L1JetCMXTools::getHits(const xAOD::CMXJetTob* tob, HitsVector& hit0, energyLg[slice], energySm[slice]); LVL1::RecJetRoI roi(tobRoi.roiWord(), &thresholds); - int numThresholdsHalf = roi.isForwardJet() ? 8 : 5; - int numBitsPerCounter = roi.isForwardJet() ? 2 : 3; + int numThresholdsHalf = 5; + int numBitsPerCounter = 3; + + for (int i = 0; i < numThresholdsHalf * 2; ++i) { + if (roi.passedThreshold(i)) { + HitsVector& hit = i < numThresholdsHalf ? hit10 : hit11; + int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf; + hit[slice] |= (1 << (ibit * numBitsPerCounter)); + } + } + + numThresholdsHalf = 8; + numBitsPerCounter = 2; - auto passedThreshold = roi.isForwardJet() - ? std::bind(&LVL1::RecJetRoI::passedFwdThreshold, - &roi, std::placeholders::_1) - : std::bind(&LVL1::RecJetRoI::passedThreshold, - &roi, std::placeholders::_1); for (int i = 0; i < numThresholdsHalf * 2; ++i) { - if (passedThreshold(i)) { - HitsVector& hit = i < numThresholdsHalf ? hit0 : hit1; + if (roi.passedThreshold(10 + i)) { + HitsVector& hit = i < numThresholdsHalf ? hit20 : hit21; int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf; hit[slice] |= (1 << (ibit * numBitsPerCounter)); } } - // auto pattern = roi.thresholdPattern(); - - // for (it = thresholds.begin(); it != itE; ++it) { - // if ((*it)->type() == jetTriggerType) { //only use Jet Thresholds - // int threshNum = (*it)->thresholdNumber(); - // if (threshNum >= 0 && threshNum < - // (int)TrigT1CaloDefs::numOfJetThresholds) { - // int size = 0; - // int value = 1023; // Set impossible default in case no threshold - // found - // TriggerThresholdValue* tv = (*it)->triggerThresholdValue(ieta, - // iphi); - // if (tv != 0) { - // JetThresholdValue* jtv; - // jtv = dynamic_cast<JetThresholdValue*> (tv); - // if (jtv) { - // size = jtv->window(); - // value = jtv->thresholdValueCount(); - // } - // } - // if (m_debug) { - // msg(MSG::DEBUG) << "JetAlgorithm: Test jet threshold " << - // threshNum - // << " with type = " << jetTriggerType << ", - // threshold = " - // << value << " and window = " << size << endreq; - // } - // bool passes = false; - // switch (size) { - // case 4 : - // passes = (energySm[slice] > value); //<<== CHECK - // break; - // case 6 : - // //passes = (ET6x6() > value); - // break; - // case 8 : - // passes = (energyLg[slice] > value); - // break; - // default : - // if (m_debug) { - // msg(MSG::DEBUG) << "ERROR IN JetAlgorithm WITH COORDS " - // << phi << ", " << eta << ". WINDOW SIZE OF " - // << size << " NOT RECOGNISED" << endreq; - // } - // }//end switch - - // /** Set bit if passed */ - // if (passes) { - // if (forward) { - // if (threshNum < 8) hit0[slice] |= (1 << (threshNum * 2)); - // else if (TrigT1CaloDefs::numOfJetThresholds < 8) hit1[slice] - // |= (1 << ((threshNum - 8) * 2)); // for coverity issue # - // 29171 - // } else { - // if (threshNum < 5) hit0[slice] |= (1 << (threshNum * 3)); - // else hit1[slice] |= (1 << ((threshNum - 5) * - // 3)); - // } - // } - // } // end if valid threshold - // }//endif - is jet threshold - // }//end thresh for-loop } // end slice for-loop } diff --git a/Trigger/TrigT1/TrigT1CaloTools/src/L1TriggerTowerTool.cxx b/Trigger/TrigT1/TrigT1CaloTools/src/L1TriggerTowerTool.cxx index ac7aadc3ab6f292ed977a4062b0310624f406f65..3ce766d4730d29a459694f54587ab78d878f62c2 100644 --- a/Trigger/TrigT1/TrigT1CaloTools/src/L1TriggerTowerTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloTools/src/L1TriggerTowerTool.cxx @@ -58,6 +58,7 @@ L1TriggerTowerTool::L1TriggerTowerTool(const std::string& t, m_ttSvc("CaloTriggerTowerService/CaloTriggerTowerService"), m_mappingTool("LVL1::PpmCoolOrBuiltinMappingTool/PpmCoolOrBuiltinMappingTool"), m_l1CondSvc("L1CaloCondSvc", n), + m_configSvc("TrigConf::TrigConfigSvc/TrigConfigSvc", n), m_isRun2(false), m_dbFineTimeRefsTowers(0), m_correctFir(false) @@ -66,6 +67,7 @@ L1TriggerTowerTool::L1TriggerTowerTool(const std::string& t, declareProperty( "BaselineCorrection", m_correctFir ); declareProperty( "L1DynamicPedestalProvider", m_dynamicPedestalProvider ); + declareProperty("LVL1ConfigSvc", m_configSvc, "LVL1 Config Service"); } //================ Destructor ================================================= @@ -82,6 +84,7 @@ StatusCode L1TriggerTowerTool::initialize() CHECK(m_l1CondSvc.retrieve()); + CHECK(m_configSvc.retrieve()); CHECK(m_l1CaloTTIdTools.retrieve()); if(!m_ttSvc.retrieve().isSuccess()) { @@ -842,7 +845,7 @@ void L1TriggerTowerTool::jepLut(const std::vector<int> &fir, const L1CaloCoolCha offset = settings->lutJepOffset(); slope = settings->lutJepSlope(); cut = settings->lutJepNoiseCut(); - scale = settings->lutJepScale(); + scale = m_configSvc->thresholdConfig()->caloInfo().globalScale(); // Retrieve scale param from menu instead of coolDB ped = settings->pedValue(); } else ATH_MSG_WARNING( "::jepLut: No L1CaloPprConditions found" ); } else ATH_MSG_WARNING( "::jepLut: No Conditions Container retrieved" );