diff --git a/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py b/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py index 3b14da63b092d3415cb70472a1bac8f6f98948fb..531dae9a8b16850820252d504f27fd199ce39c53 100644 --- a/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py +++ b/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py @@ -14,12 +14,12 @@ topSequence = AlgSequence() conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/DX","/TRT/Calib/DX") # Dead/Noisy Straw Lists -if DetFlags.simulate.any_on() or hasattr(topSequence,"OutputConditionsAlg"): # revert to old style CondHandle in case of simulation or streaming to POOL +if hasattr(topSequence,"OutputConditionsAlg"): # revert to old style CondHandle in case streaming to POOL conddb.addFolderSplitOnline("TRT","/TRT/Onl/Cond/Status","/TRT/Cond/Status") else: conddb.addFolderSplitOnline("TRT","/TRT/Onl/Cond/Status","/TRT/Cond/Status",className='TRTCond::StrawStatusMultChanContainer') -if DetFlags.simulate.any_on() or hasattr(topSequence,"OutputConditionsAlg"): +if hasattr(topSequence,"OutputConditionsAlg"): conddb.addFolderSplitOnline("TRT","/TRT/Onl/Cond/StatusPermanent","/TRT/Cond/StatusPermanent") else: conddb.addFolderSplitOnline("TRT","/TRT/Onl/Cond/StatusPermanent","/TRT/Cond/StatusPermanent",className='TRTCond::StrawStatusMultChanContainer') @@ -79,8 +79,6 @@ if DetFlags.TRT_on() and ((not DetFlags.simulate.TRT_on()) or DetFlags.overlay.T import os if "AthSimulation_DIR" not in os.environ: # Protection for AthSimulation builds condSeq += TRTAlignCondAlg - - if DetFlags.SCT_on() and ((not DetFlags.simulate.SCT_on()) or DetFlags.overlay.SCT_on()): if not hasattr(condSeq, "SCT_AlignCondAlg"): diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/CMakeLists.txt b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/CMakeLists.txt index 1fd40d58fb4cb293c5cdec7138ce1bbfaca6cba0..b1945841b756c6d5e10f7cc3636e5a1d83e874a7 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/CMakeLists.txt +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/CMakeLists.txt @@ -10,20 +10,22 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps GaudiKernel InnerDetector/InDetConditions/TRT_ConditionsServices - PRIVATE InnerDetector/InDetConditions/TRT_ConditionsData + PRIVATE InnerDetector/InDetDetDescr/InDetIdentifier InnerDetector/InDetDetDescr/InDetReadoutGeometry Database/AthenaPOOL/AthenaPoolUtilities DetectorDescription/DetDescrCond/DetDescrConditions DetectorDescription/GeoModel/GeoModelUtilities ) - +# External dependencies: +find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) # Component(s) in the package: atlas_add_component( TRT_ConditionsAlgs src/*.cxx src/components/*.cxx + INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} LINK_LIBRARIES AthenaBaseComps GaudiKernel TRT_ConditionsServicesLib TRT_ConditionsData InDetIdentifier InDetReadoutGeometry AthenaPoolUtilities DetDescrConditions GeoModelUtilities ) diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..31335ca0136df3a6493d649b967c42024cf43c39 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx @@ -0,0 +1,225 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRTActiveCondAlg.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" + +TRTActiveCondAlg::TRTActiveCondAlg(const std::string& name + , ISvcLocator* pSvcLocator ) + : ::AthReentrantAlgorithm(name,pSvcLocator), + m_condSvc("CondSvc",name), + m_detManager(nullptr), + m_strawStatus("TRT_StrawStatusSummaryTool",this), + m_trtId(0) +{ declareProperty("TRTStrawStatusSummaryTool",m_strawStatus); } +TRTActiveCondAlg::~TRTActiveCondAlg(){} + +StatusCode TRTActiveCondAlg::initialize() +{ + + // CondSvc + ATH_CHECK( m_condSvc.retrieve() ); + + // Straw status + ATH_CHECK ( m_strawStatus.retrieve() ); + + // Read key + ATH_CHECK( m_strawReadKey.initialize() ); + + + // Register write handle + ATH_CHECK( m_strawWriteKey.initialize() ); + + if (m_condSvc->regHandle(this, m_strawWriteKey).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_strawWriteKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + // Detector manager + ATH_CHECK(detStore()->retrieve(m_detManager,"TRT")); + + // TRT ID helper + ATH_CHECK(detStore()->retrieve(m_trtId,"TRT_ID")); + + return StatusCode::SUCCESS; +} + +StatusCode TRTActiveCondAlg::execute(const EventContext& ctx) const +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + + SG::WriteCondHandle<TRTCond::ActiveFraction> writeHandle{m_strawWriteKey,ctx}; + + // Do we have a valid Write Cond Handle for current time? + if(writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + + return StatusCode::SUCCESS; + } + + + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<TRTCond::ActiveFraction> writeCdo{std::make_unique<TRTCond::ActiveFraction>()}; + + + // ____________ Compute number of alive straws for Write Cond object ____________ + + + + ATH_MSG_INFO(" Initialize TRTCond::ActiveFraction table with number of phi, eta bins: " + << writeCdo->getPhiBins().size() << ", " << writeCdo->getEtaBins().size() ); + + for (unsigned int i=0; i<writeCdo->getEtaBins().size(); i++) { + float etaMin = writeCdo->getEtaBins()[i].first; + float etaMax = writeCdo->getEtaBins()[i].second; + int bin = writeCdo->findEtaBin( (etaMin+etaMax)/2. ); + ATH_MSG_DEBUG("TRTCond::ActiveFraction: findEtaBin( " << etaMin << ", " << etaMax << " ] = " << bin ); + + for (unsigned int j=0; j<writeCdo->getPhiBins().size(); j++) { + float phiMin = writeCdo->getPhiBins()[j].first; + float phiMax = writeCdo->getPhiBins()[j].second; + int bin = writeCdo->findPhiBin( (phiMin+phiMax)/2. ); + ATH_MSG_DEBUG("TRTCond::ActiveFraction: findPhiBin( " << phiMin << ", " << phiMax << " ] = " << bin ); + } + } + + std::vector<int> dummyPhiVec( writeCdo->getPhiBins().size(), 0 ); + std::vector<std::vector<int> > dummyTableCountAll( writeCdo->getEtaBins().size(), dummyPhiVec ); + std::vector<std::vector<int> > dummyTableCountDead( writeCdo->getEtaBins().size(), dummyPhiVec ); + + + float rMinEndcap = 617.; + float rMaxEndcap = 1106.; + int countAll(0), countDead(0), countSaved(0), countPhiSkipped(0), countEtaSkipped(0), countInvalidEtaValues(0); + for (std::vector<Identifier>::const_iterator it = m_trtId->straw_layer_begin(); it != m_trtId->straw_layer_end(); it++ ) { + int nStrawsInLayer = m_trtId->straw_max(*it); + for (int i=0; i<=nStrawsInLayer; i++) { + + Identifier id = m_trtId->straw_id(*it, i); + bool status = m_strawStatus->get_status(id); + countAll++; if (status) countDead++; + + const Amg::Vector3D &strawPosition = m_detManager->getElement( id )->center( id ); + double phi = atan2( strawPosition.y(), strawPosition.x() ); + int phiBin = writeCdo->findPhiBin( phi ); + if (phiBin<0) { + ATH_MSG_DEBUG("TRTCond::ActiveFraction phiBin<0: " << phi << " " << phiBin); + countPhiSkipped++; + continue; + } + + // calculate etaMin, etaMax + int side = m_trtId->barrel_ec(id); + float z = fabs( strawPosition.z() ); + float thetaMin(0.), thetaMax(0.); + if (abs(side)==1) { // barrel + float zRange = 360.; // straw length / 2 + if ( m_trtId->layer_or_wheel(id) == 0 && m_trtId->straw_layer(id) < 9 ) zRange = 160.; // short straws + float r = sqrt( pow(strawPosition.x(), 2) + pow(strawPosition.y(), 2) ); + thetaMin = atan( r / (z+zRange) ); + thetaMax = ((z-zRange)>0.) ? atan( r / (z-zRange) ) : 1.57; // M_PI_2 - epsilon + } else { // endcap + thetaMin = atan( rMinEndcap / z ); + thetaMax = atan( rMaxEndcap / z ); + } + if (side<0) { // theta -> M_PI - theta + float thetaDummy = thetaMin; + thetaMin = M_PI - thetaMax; + thetaMax = M_PI - thetaDummy; + } + + float thetaCheck[] = {thetaMax, thetaMin}; + float etaCheck[] = {0., 0.}; + for (int ti=0; ti<2; ti++) { + if (thetaCheck[ti]<=0.||thetaCheck[ti]>=M_PI) ATH_MSG_DEBUG("TRTCond::ActiveFraction: theta " << ti << " " << thetaCheck[ti]); + float tanTheta = tan(thetaCheck[ti]/2.); + if (tanTheta<=0.) { + ATH_MSG_DEBUG("TRTCond::ActiveFraction: theta tan " << ti << " " << tanTheta ); + countInvalidEtaValues++; + continue; + } + etaCheck[ti] = -log( tanTheta ); + } + float etaMin = etaCheck[0]; + float etaMax = etaCheck[1]; + int etaMinBin = writeCdo->findEtaBin( etaMin ); + int etaMaxBin = writeCdo->findEtaBin( etaMax ); + if (etaMin>=etaMax) ATH_MSG_WARNING("TRTCond::ActiveFractionSvc: etaMaxBin<etaMinBin " << etaMin << " " << etaMax << " " << thetaMin << " " << thetaMax); + if (etaMinBin<0 && etaMaxBin<0) { + ATH_MSG_WARNING("TRTCond::ActiveFraction: etaMaxBin<etaMinBin " << thetaMin << " " << thetaMax + << " " << etaMin << " " << etaMax << " " << etaMinBin << " " << etaMaxBin << ", side: " << side); + countEtaSkipped++; + continue; + } + if (etaMinBin<0) etaMinBin = 0; + if (etaMaxBin<0) etaMaxBin = writeCdo->getEtaBins().size() - 1; + if (etaMaxBin<etaMinBin) ATH_MSG_WARNING( "TRTCond::ActiveFraction: etaMaxBin<etaMinBin " << etaMinBin << " " << etaMaxBin << ", side: " << side); + + countSaved++; // now save straw info for these bins + for (int iEta = etaMinBin; iEta <= etaMaxBin; iEta++) { + dummyTableCountAll[iEta][phiBin]++; + if (status) dummyTableCountDead[iEta][phiBin]++; + } + + } + } // end straw Identifier loop + + for (unsigned int i = 0; i < writeCdo->getEtaBins().size(); ++i) { // fill the table + for (unsigned int j = 0; j < writeCdo->getPhiBins().size(); ++j) { + float deadFraction = 1. * dummyTableCountDead[i][j]; + if (dummyTableCountAll[i][j]>0) deadFraction /= (1. * dummyTableCountAll[i][j]); + writeCdo->setActiveFraction(i, j, 1. - deadFraction); + ATH_MSG_DEBUG( "dummyTableCountDead: " << i << ", " << j << ", count " << dummyTableCountAll[i][j] << " dead " << deadFraction); + } + } + + float deadStrawFraction = (1.*countDead) / (1.*countAll); + ATH_MSG_INFO( " Initialize TRTCond::ActiveFraction table finished, count all TRT straws: " << countAll + << ", count dead straws: " << countDead << " (" << deadStrawFraction + << "%), straws skipped due to invalid phi, eta range: " << countPhiSkipped << " " << countEtaSkipped ); + + if (countInvalidEtaValues) ATH_MSG_WARNING("TRT_ActiveFractionSvc: found invalid eta range, check: " << countInvalidEtaValues); + + + + //__________ Assign range of writeCdo to that of the ReadHandle___________ + EventIDRange rangeW; + + SG::ReadCondHandle<StrawStatusContainer> strawReadHandle{m_strawReadKey,ctx}; + const StrawStatusContainer* strawContainer{*strawReadHandle}; + if(strawContainer==nullptr) { + ATH_MSG_ERROR("Null pointer to the straw status container"); + return StatusCode::FAILURE; + } + + // Get range + if(!strawReadHandle.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << strawReadHandle.key()); + return StatusCode::FAILURE; + } + + + // Record CDO + if(writeHandle.record(rangeW,std::move(writeCdo)).isFailure()) { + ATH_MSG_ERROR("Could not record ActiveFraction " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + + + return StatusCode::SUCCESS; +} + +StatusCode TRTActiveCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.h b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..9de4b93e758c9adc2b4911bd30ad8c47dee39e6c --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRTACTIVECONDALG_H +#define TRTACTIVECONDALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/WriteCondHandleKey.h" +#include "GaudiKernel/ToolHandle.h" +#include "TRT_ConditionsData/ActiveFraction.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" +namespace InDetDD { + class TRT_DetectorManager; +} +class TRT_ID; + +//* Fills a eta,phi binned map of the fraction of straws, and posts it on CondStore +class TRTActiveCondAlg : public AthReentrantAlgorithm +{ + public: + typedef TRTCond::StrawStatusMultChanContainer StrawStatusContainer ; + TRTActiveCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~TRTActiveCondAlg() override; + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + + private: + ServiceHandle<ICondSvc> m_condSvc; + SG::ReadCondHandleKey<StrawStatusContainer> m_strawReadKey{this,"StrawReadKey","/TRT/Cond/Status","Straw Status in-key"}; + SG::WriteCondHandleKey<TRTCond::ActiveFraction> m_strawWriteKey{this,"ActiveWriteKey","ActiveFraction","ActiveFraction out-key"}; + const InDetDD::TRT_DetectorManager* m_detManager; + ToolHandle<ITRT_StrawStatusSummaryTool> m_strawStatus; + const TRT_ID *m_trtId; + +}; +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c712cb762c7b7e8e923b23e53f6ca0d8264b8a9e --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRTHTCondAlg.h" + +TRTHTCondAlg::TRTHTCondAlg(const std::string& name + , ISvcLocator* pSvcLocator ) + : ::AthReentrantAlgorithm(name,pSvcLocator), + m_condSvc("CondSvc",name) +{} +TRTHTCondAlg::~TRTHTCondAlg(){} + +StatusCode TRTHTCondAlg::initialize() +{ + + // CondSvc + ATH_CHECK( m_condSvc.retrieve() ); + + // Read key + ATH_CHECK( m_ReadKey.initialize() ); + + // Register write handle + ATH_CHECK( m_WriteKey.initialize() ); + + if (m_condSvc->regHandle(this, m_WriteKey).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_WriteKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode TRTHTCondAlg::execute(const EventContext& ctx) const +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + + SG::WriteCondHandle<HTcalculator> writeHandle{m_WriteKey,ctx}; + + // Do we have a valid Write Cond Handle for current time? + if(writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + + return StatusCode::SUCCESS; + } + + + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<HTcalculator> writeCdo{std::make_unique<HTcalculator>()}; + + + // ____________ Compute the array structures for the HTcalculator object ____________ + SG::ReadCondHandle<CondAttrListVec> readHandle{m_ReadKey,ctx}; + const CondAttrListVec* channel_values{*readHandle}; + if(channel_values==nullptr) { + ATH_MSG_ERROR(" Problem reading TRT/Calib/PID_vector cond object"); + return StatusCode::FAILURE; + } + if(StatusCode::SUCCESS != writeCdo->ReadVectorDB( channel_values )) { + ATH_MSG_ERROR ("Problem filling HT Calculator."); + return StatusCode::FAILURE; + } + + + //__________ Assign range of writeCdo to that of the ReadHandle___________ + EventIDRange rangeW; + + if(!readHandle.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + + // Record CDO + if(writeHandle.record(rangeW,std::move(writeCdo)).isFailure()) { + ATH_MSG_ERROR("Could not record HTCalculator " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + + + return StatusCode::SUCCESS; +} + +StatusCode TRTHTCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.h b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..47b11cfc0f044b8e1bc454d7231772322c1ada30 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTHTCondAlg.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRTHTCONDALG_H +#define TRTHTCONDALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteCondHandleKey.h" +#include "TRT_ConditionsData/HTcalculator.h" +#include "AthenaPoolUtilities/CondAttrListVec.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" + + +class TRTHTCondAlg : public AthReentrantAlgorithm +{ + public: + TRTHTCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~TRTHTCondAlg() override; + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + + private: + ServiceHandle<ICondSvc> m_condSvc; + SG::ReadCondHandleKey<CondAttrListVec> m_ReadKey{this,"HTReadKey","/TRT/Calib/PID_vector","Pid in-key"}; + SG::WriteCondHandleKey<HTcalculator> m_WriteKey{this,"HTWriteKey","HTcalculator","HTcalcutor out-key"}; + +}; +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..03d75e50a31580019414f8adec0ace8d12a7e9cd --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.cxx @@ -0,0 +1,185 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRTStrawCondAlg.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" + +TRTStrawCondAlg::TRTStrawCondAlg(const std::string& name + , ISvcLocator* pSvcLocator ) + : ::AthReentrantAlgorithm(name,pSvcLocator), + m_condSvc("CondSvc",name), + m_detManager(nullptr), + m_strawStatus("TRT_StrawStatusSummaryTool",this), + m_trtId(0), + m_isGEANT4(true) +{ declareProperty("TRTStrawStatusSummaryTool",m_strawStatus); + declareProperty("isGEANT4",m_isGEANT4); +} +TRTStrawCondAlg::~TRTStrawCondAlg(){} + +StatusCode TRTStrawCondAlg::initialize() +{ + + // CondSvc + ATH_CHECK( m_condSvc.retrieve() ); + + // Straw status + ATH_CHECK ( m_strawStatus.retrieve() ); + + // Read key + ATH_CHECK( m_strawReadKey.initialize() ); + + + // Register write handle + ATH_CHECK( m_strawWriteKey.initialize() ); + + if (m_condSvc->regHandle(this, m_strawWriteKey).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_strawWriteKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + // Detector manager + ATH_CHECK(detStore()->retrieve(m_detManager,"TRT")); + + // TRT ID helper + ATH_CHECK(detStore()->retrieve(m_trtId,"TRT_ID")); + + return StatusCode::SUCCESS; +} + +StatusCode TRTStrawCondAlg::execute(const EventContext& ctx) const +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + + SG::WriteCondHandle<TRTCond::AliveStraws> writeHandle{m_strawWriteKey,ctx}; + + // Do we have a valid Write Cond Handle for current time? + if(writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + + return StatusCode::SUCCESS; + } + + + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<TRTCond::AliveStraws> writeCdo{std::make_unique<TRTCond::AliveStraws>()}; + + + // ____________ Compute number of alive straws for Write Cond object ____________ + + for (std::vector<Identifier>::const_iterator it = m_trtId->straw_layer_begin(); it != m_trtId->straw_layer_end(); it++ ) { + + unsigned int nstraws = 0; + if (m_detManager){ + const InDetDD::TRT_BaseElement *el = m_detManager->getElement(*it); + if( !el ) continue; + nstraws = el->nStraws(); + } + else{ + nstraws = m_trtId->straw_max( *it) + 1; // There is a difference of 1 between both methods.... + } + for (unsigned int i=0; i<nstraws ;i++) { + Identifier id = m_trtId->straw_id( *it, i); + int det = m_trtId->barrel_ec( id) ; + int lay = m_trtId->layer_or_wheel( id) ; + int phi = m_trtId->phi_module( id) ; + bool status = m_strawStatus->get_status( id ); + + if ( status ) { + ATH_MSG_VERBOSE(" The sector " << det << " " << lay << " " << phi << " has status " << status); + continue; + } + + int i_total = findArrayTotalIndex(det, lay); + int i_wheel = findArrayLocalWheelIndex(det, lay); + + writeCdo->update(i_total,i_wheel,phi); + + } + } + + //__________ Assign range of writeCdo to that of the ReadHandle___________ + EventIDRange rangeW; + + SG::ReadCondHandle<StrawStatusContainer> strawReadHandle{m_strawReadKey,ctx}; + const StrawStatusContainer* strawContainer{*strawReadHandle}; + if(strawContainer==nullptr) { + ATH_MSG_ERROR("Null pointer to the straw status container"); + return StatusCode::FAILURE; + } + + // Get range + if(!strawReadHandle.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << strawReadHandle.key()); + return StatusCode::FAILURE; + } + + + // Record CDO + if(writeHandle.record(rangeW,std::move(writeCdo)).isFailure()) { + ATH_MSG_ERROR("Could not record AliveStraws " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + + + return StatusCode::SUCCESS; +} + +StatusCode TRTStrawCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} + +int TRTStrawCondAlg::findArrayTotalIndex(const int det, const int lay) const{ + int arrayindex = 0; // to be reset below + // NOTE: Below, arrayindex starts at 1 + // because index 0 is filled with TOTAL value. + if (det == -1) arrayindex = 1; // barrel side C + else if (det == -2) { // endcap side C + if (lay < 6) arrayindex = 2; // wheel A + else arrayindex = 3; // wheel B + } + else if (det == 1) arrayindex = 4; // barrel side A + else if (det == 2) { // endcap side A + if (lay < 6) arrayindex = 5; // wheel A + else arrayindex = 6; // wheel B + } + else ATH_MSG_WARNING(" detector value is: " << det << ", out of range -2, -1, 1, 2, so THIS IS NOT TRT!!!"); + return arrayindex; + } + +int TRTStrawCondAlg::findArrayLocalWheelIndex(const int det, const int lay) const{ + int arrayindex = 9; // to be reset below + if (det == -1) { // barrel side C + if (lay == 0) arrayindex = 0; // layer 0 + else if (lay == 1) arrayindex = 1; // layer 1 + else if (lay == 2) arrayindex = 2; // layer 2 + } + else if (det == -2) { // endcap side C + for (int i=0; i<14; ++i){ + if (lay==i) arrayindex=i+3; + } + } + else if (det == 1) { // barrel side A + if (lay == 0) arrayindex = 17; // layer 0 + else if (lay == 1) arrayindex = 18; // layer 1 + else if (lay == 2) arrayindex = 19; // layer 2 + } + else if (det == 2) { // endcap side A + for (int i=0; i<14; ++i){ + if (lay==i) arrayindex=i+20; + } + } + else ATH_MSG_WARNING(" detector value is: " << det << ", out of range -2, -1, 1, 2, so THIS IS NOT TRT!!!"); + return arrayindex; + } + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.h b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..096bde0366c29d998a70c3fda56b8ab1bb8fe1f8 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTStrawCondAlg.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRTSTRAWCONDALG_H +#define TRTSTRAWCONDALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/WriteCondHandleKey.h" +#include "GaudiKernel/ToolHandle.h" +#include "TRT_ConditionsData/AliveStraws.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" +namespace InDetDD { + class TRT_DetectorManager; +} +class TRT_ID; + +class TRTStrawCondAlg : public AthReentrantAlgorithm +{ + public: + typedef TRTCond::StrawStatusMultChanContainer StrawStatusContainer ; + TRTStrawCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~TRTStrawCondAlg() override; + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + virtual int findArrayTotalIndex(const int det, const int lay) const; + virtual int findArrayLocalWheelIndex(const int det, const int lay) const; + + + private: + ServiceHandle<ICondSvc> m_condSvc; + SG::ReadCondHandleKey<StrawStatusContainer> m_strawReadKey{this,"StrawReadKey","/TRT/Cond/Status","Straw Status in-key"}; + SG::WriteCondHandleKey<TRTCond::AliveStraws> m_strawWriteKey{this,"StrawWriteKey","AliveStraws","AliveStraws out-key"}; + const InDetDD::TRT_DetectorManager* m_detManager; + ToolHandle<ITRT_StrawStatusSummaryTool> m_strawStatus; + const TRT_ID *m_trtId; + bool m_isGEANT4; + +}; +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7dffa8af699e9317a23b6a51e2e1bac2c554bd6e --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.cxx @@ -0,0 +1,564 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRTToTCondAlg.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/AttributeListSpecification.h" + + +TRTToTCondAlg::TRTToTCondAlg(const std::string& name + , ISvcLocator* pSvcLocator ) + : ::AthAlgorithm(name,pSvcLocator), + m_condSvc("CondSvc",name) +{} +TRTToTCondAlg::~TRTToTCondAlg(){} + +StatusCode TRTToTCondAlg::initialize() +{ + + // CondSvc + ATH_CHECK( m_condSvc.retrieve() ); + + // Read key + ATH_CHECK( m_VecReadKey.initialize() ); + ATH_CHECK( m_ValReadKey.initialize() ); + + // Register write handle + ATH_CHECK( m_WriteKey.initialize() ); + + if (m_condSvc->regHandle(this, m_WriteKey).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_WriteKey.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode TRTToTCondAlg::execute() +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + + SG::WriteCondHandle<TRTDedxcorrection> writeHandle{m_WriteKey}; + + // Do we have a valid Write Cond Handle for current time? + if(writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + + return StatusCode::SUCCESS; + } + + + + // // ____________ Construct new Write Cond Object ____________ + // std::unique_ptr<TRTDedxcorrection> Dedxcorrection{std::make_unique<TRTDedxcorrection>()}; + TRTDedxcorrection* Dedxcorrection = new TRTDedxcorrection; + + // ____________ Compute the Write Cond Object (Dedxcorrections) ____________ + SG::ReadCondHandle<CondAttrListVec> readVecHandle{m_VecReadKey}; + const CondAttrListVec* channel_values{*readVecHandle}; + if(channel_values==nullptr) { + ATH_MSG_ERROR(" Problem reading TRT/Calib/ToT/ToTVectors cond object"); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + if(StatusCode::SUCCESS != update1( *Dedxcorrection, channel_values )) { + ATH_MSG_ERROR ("Problem filling Dedxcorrection."); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + + SG::ReadCondHandle<CondAttrListCollection> readValHandle{m_ValReadKey}; + const CondAttrListCollection* attrListColl{*readValHandle}; + if(attrListColl==nullptr) { + ATH_MSG_ERROR(" Problem reading TRT/Calib/ToT/ToTValue cond object"); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + if(StatusCode::SUCCESS != update2( *Dedxcorrection, attrListColl )) { + ATH_MSG_ERROR ("Problem filling Dedxcorrection."); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + + + //__________ Assign range of Dedxcorrection to that of the ReadHandle___________ + EventIDRange rangeW; + + if(!readVecHandle.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readVecHandle.key()); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + + // Record CDO + if(writeHandle.record(rangeW,Dedxcorrection).isFailure()) { + ATH_MSG_ERROR("Could not record " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + delete Dedxcorrection; + return StatusCode::FAILURE; + } + + + return StatusCode::SUCCESS; +} + +StatusCode TRTToTCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} + +StatusCode TRTToTCondAlg::update1( TRTDedxcorrection& Dedxcorrection, const CondAttrListVec* channel_values){ + + std::vector<std::string> dict_names = {"para_end_corrRZLXe","para_end_corrRZ_Xe","para_end_mimicToXeXe", + "para_long_corrRZLXe","para_long_corrRZ_Xe","para_long_mimicToXeXe","para_short_corrRZLXe", + "para_short_corrRZ_Xe","para_short_mimicToXeXe","resolution_Xe","resolution_e_Xe","para_end_corrRZLAr", + "para_end_corrRZ_Ar","para_end_mimicToXeAr","para_long_corrRZLAr","para_long_corrRZ_Ar", + "para_long_mimicToXeAr","para_short_corrRZLAr","para_short_corrRZ_Ar","para_short_mimicToXeAr", + "resolution_Ar","resolution_e_Ar","para_end_corrRZLKr","para_end_corrRZ_Kr","para_end_mimicToXeKr", + "para_long_corrRZLKr","para_long_corrRZ_Kr","para_long_mimicToXeKr","para_short_corrRZLKr", + "para_short_corrRZ_Kr","para_short_mimicToXeKr","resolution_Kr","resolution_e_Kr"}; + + std::map<std::string,std::vector<float> > result_dict; + int dataBaseType = kNewDB; + ATH_MSG_DEBUG("update():: dict_names[]="<<dict_names.size()<<", channel_values[]="<<channel_values->size()<<""); + if(channel_values->size()<19695) dataBaseType = kOldDB; + + if(dataBaseType==kNewDB) { + + CondAttrListVec::const_iterator first_channel = channel_values->begin(); + CondAttrListVec::const_iterator last_channel = channel_values->end(); + + unsigned int current_channel = 0; + std::vector<float> current_array_values = {}; + + for (; first_channel != last_channel; ++first_channel) { + if (current_channel != first_channel->first){ + result_dict[dict_names[current_channel]] = current_array_values; + current_channel = first_channel->first; + current_array_values.clear(); + } + current_array_values.push_back(first_channel->second["array_value"].data<float>()); + } + + result_dict[dict_names[current_channel]] = current_array_values; + + update_New(Dedxcorrection, result_dict); + ATH_MSG_DEBUG ("update():: Reading new database is done!"); + + return StatusCode::SUCCESS; + + } else if(dataBaseType==kOldDB) { + ATH_MSG_WARNING ("update():: Old COOL database tag!"); + + std::vector<std::string> dict_names_old = {"resolution","resolution_e","para_long_corrRZ_MC", + "para_short_corrRZ_MC","para_end_corrRZ_MC","para_long_corrRZL_MC", + "para_short_corrRZL_MC","para_end_corrRZL_MC"}; + + CondAttrListVec::const_iterator first_channel = channel_values->begin(); + CondAttrListVec::const_iterator last_channel = channel_values->end(); + + unsigned int current_channel = 0; + std::vector<float> current_array_values = {}; + + for (; first_channel != last_channel; ++first_channel) { + if (current_channel != first_channel->first) { + result_dict[dict_names_old[current_channel]] = current_array_values; + current_channel = first_channel->first; + current_array_values.clear(); + } + current_array_values.push_back(first_channel->second["array_value"].data<float>()); + } + + result_dict[dict_names_old[current_channel]] = current_array_values; + + update_Old(Dedxcorrection, result_dict); + ATH_MSG_DEBUG ("update():: Reading old database is done!"); + + return StatusCode::SUCCESS; + } + return StatusCode::FAILURE; +} + +void TRTToTCondAlg::update_New(TRTDedxcorrection & Dedxcorrection, std::map<std::string,std::vector<float> > &result_dict) { + // fill Xenon +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution[0][ind]=result_dict["resolution_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution_e[0][ind]=result_dict["resolution_e_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ_MC[0][ind]=result_dict["para_long_corrRZ_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ_MC[0][ind]=result_dict["para_short_corrRZ_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_MC[0][ind]=result_dict["para_long_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_MC[0][ind]=result_dict["para_short_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_MC[0][ind]=result_dict["para_end_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ[0][ind]=result_dict["para_long_corrRZ_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ[0][ind]=result_dict["para_short_corrRZ_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_DATA[0][ind]=result_dict["para_long_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_DATA[0][ind]=result_dict["para_short_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_DATA[0][ind]=result_dict["para_end_corrRZLXe"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ[0][ind]=result_dict["para_end_corrRZ_Xe"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ_MC[0][ind]=result_dict["para_end_corrRZ_Xe"][ind]; + } + + + + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_DATA[0][ind]=result_dict["para_end_mimicToXeXe"][ind]; + } + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_MC[0][ind]=result_dict["para_end_mimicToXeXe"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_DATA[0][ind]=result_dict["para_short_mimicToXeXe"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_MC[0][ind]=result_dict["para_short_mimicToXeXe"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_DATA[0][ind]=result_dict["para_long_mimicToXeXe"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_MC[0][ind]=result_dict["para_long_mimicToXeXe"][ind]; + } + + // fill Argon +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution[1][ind]=result_dict["resolution_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution_e[1][ind]=result_dict["resolution_e_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ_MC[1][ind]=result_dict["para_long_corrRZ_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ_MC[1][ind]=result_dict["para_short_corrRZ_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_MC[1][ind]=result_dict["para_long_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_MC[1][ind]=result_dict["para_short_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_MC[1][ind]=result_dict["para_end_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ[1][ind]=result_dict["para_long_corrRZ_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ[1][ind]=result_dict["para_short_corrRZ_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_DATA[1][ind]=result_dict["para_long_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_DATA[1][ind]=result_dict["para_short_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_DATA[1][ind]=result_dict["para_end_corrRZLAr"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ[1][ind]=result_dict["para_end_corrRZ_Ar"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ_MC[1][ind]=result_dict["para_end_corrRZ_Ar"][ind]; + } + + + + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_DATA[1][ind]=result_dict["para_end_mimicToXeAr"][ind]; + } + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_MC[1][ind]=result_dict["para_end_mimicToXeAr"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_DATA[1][ind]=result_dict["para_short_mimicToXeAr"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_MC[1][ind]=result_dict["para_short_mimicToXeAr"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_DATA[1][ind]=result_dict["para_long_mimicToXeAr"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_MC[1][ind]=result_dict["para_long_mimicToXeAr"][ind]; + } + + // fill Krypton +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution[2][ind]=result_dict["resolution_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution_e[2][ind]=result_dict["resolution_e_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ_MC[2][ind]=result_dict["para_long_corrRZ_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ_MC[2][ind]=result_dict["para_short_corrRZ_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_MC[2][ind]=result_dict["para_long_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_MC[2][ind]=result_dict["para_short_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_MC[2][ind]=result_dict["para_end_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ[2][ind]=result_dict["para_long_corrRZ_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ[2][ind]=result_dict["para_short_corrRZ_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_DATA[2][ind]=result_dict["para_long_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_DATA[2][ind]=result_dict["para_short_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_DATA[2][ind]=result_dict["para_end_corrRZLKr"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ[2][ind]=result_dict["para_end_corrRZ_Kr"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ_MC[2][ind]=result_dict["para_end_corrRZ_Kr"][ind]; + } + + + + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_DATA[2][ind]=result_dict["para_end_mimicToXeKr"][ind]; + } + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_MC[2][ind]=result_dict["para_end_mimicToXeKr"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_DATA[2][ind]=result_dict["para_short_mimicToXeKr"][ind]; + } + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_MC[2][ind]=result_dict["para_short_mimicToXeKr"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_DATA[2][ind]=result_dict["para_long_mimicToXeKr"][ind]; + } + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_MC[2][ind]=result_dict["para_long_mimicToXeKr"][ind]; + } +} + + + +void TRTToTCondAlg::update_Old(TRTDedxcorrection & Dedxcorrection, std::map<std::string,std::vector<float> > &result_dict) { + for(int gasType = 0; gasType<3; gasType++) { // loop over gas types + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution[gasType][ind]=result_dict["resolution"][ind]; + } + + for (unsigned int ind=0; ind < 4; ++ind) { + Dedxcorrection.resolution_e[gasType][ind]=result_dict["resolution_e"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ_MC[gasType][ind]=result_dict["para_long_corrRZ_MC"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ_MC[gasType][ind]=result_dict["para_short_corrRZ_MC"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_MC[gasType][ind]=result_dict["para_long_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_MC[gasType][ind]=result_dict["para_short_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_MC[gasType][ind]=result_dict["para_end_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 3240; ++ind) { + Dedxcorrection.para_long_corrRZ[gasType][ind]=result_dict["para_long_corrRZ_MC"][ind]; + } + + for (unsigned int ind=0; ind < 216; ++ind) { + Dedxcorrection.para_short_corrRZ[gasType][ind]=result_dict["para_short_corrRZ_MC"][ind]; + } + + for (unsigned int ind=0; ind < 630; ++ind) { + Dedxcorrection.para_long_corrRZL_DATA[gasType][ind]=result_dict["para_long_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 63; ++ind) { + Dedxcorrection.para_short_corrRZL_DATA[gasType][ind]=result_dict["para_short_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 252; ++ind) { + Dedxcorrection.para_end_corrRZL_DATA[gasType][ind]=result_dict["para_end_corrRZL_MC"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ[gasType][ind]=result_dict["para_end_corrRZ_MC"][ind]; + } + + for (unsigned int ind=0; ind < 336; ++ind) { + Dedxcorrection.para_end_corrRZ_MC[gasType][ind]=result_dict["para_end_corrRZ_MC"][ind]; + } + + // Setting aditional corrections + for (unsigned int ind=0; ind < 560; ++ind) { + Dedxcorrection.para_end_mimicToXe_MC[gasType][ind] = 1.; + Dedxcorrection.para_end_mimicToXe_DATA[gasType][ind] = 1.; + } + + for (unsigned int ind=0; ind < 180; ++ind) { + Dedxcorrection.para_short_mimicToXe_MC[gasType][ind] = 1.; + Dedxcorrection.para_short_mimicToXe_DATA[gasType][ind] = 1.; + } + + for (unsigned int ind=0; ind < 1800; ++ind) { + Dedxcorrection.para_long_mimicToXe_MC[gasType][ind] = 1.; + Dedxcorrection.para_long_mimicToXe_DATA[gasType][ind] = 1.; + } + } +} + +StatusCode TRTToTCondAlg::update2(TRTDedxcorrection& Dedxcorrection, const CondAttrListCollection* attrListColl ){ + + int dataBaseType = kNewDB; + if(attrListColl->size() < 2) dataBaseType = kOldDB; + + CondAttrListCollection::const_iterator first = attrListColl->begin(); + CondAttrListCollection::const_iterator last = attrListColl->end(); + + if(dataBaseType==kNewDB) { + for (int index=0; first != last; ++first,++index) { + const coral::AttributeList& attrList = (*first).second; + Dedxcorrection.paraL_dEdx_p1[index] = attrList["paraL_dEdx_p1"].data<float>(); + Dedxcorrection.paraL_dEdx_p2[index] = attrList["paraL_dEdx_p2"].data<float>(); + Dedxcorrection.paraL_dEdx_p3[index] = attrList["paraL_dEdx_p3"].data<float>(); + Dedxcorrection.paraL_dEdx_p4[index] = attrList["paraL_dEdx_p4"].data<float>(); + Dedxcorrection.paraL_dEdx_p5[index] = attrList["paraL_dEdx_p5"].data<float>(); + + Dedxcorrection.para_dEdx_p1[index] = attrList["para_dEdx_p1"].data<float>(); + Dedxcorrection.para_dEdx_p2[index] = attrList["para_dEdx_p2"].data<float>(); + Dedxcorrection.para_dEdx_p3[index] = attrList["para_dEdx_p3"].data<float>(); + Dedxcorrection.para_dEdx_p4[index] = attrList["para_dEdx_p4"].data<float>(); + Dedxcorrection.para_dEdx_p5[index] = attrList["para_dEdx_p5"].data<float>(); + + Dedxcorrection.norm_offset_data[index] = attrList["norm_offset_data"].data<float>(); + Dedxcorrection.norm_slope_tot[index] = attrList["norm_slope_tot"].data<float>(); + Dedxcorrection.norm_slope_totl[index] = attrList["norm_slope_totl"].data<float>(); + Dedxcorrection.norm_offset_tot[index] = attrList["norm_offset_tot"].data<float>(); + Dedxcorrection.norm_offset_totl[index] = attrList["norm_offset_totl"].data<float>(); + Dedxcorrection.norm_nzero[index]=attrList["norm_nzero"].data<int>(); + } + } else { + ATH_MSG_WARNING ("update2():: Old COOL database tag!"); + // return update2_Old(); + for (; first != last; ++first) { + const coral::AttributeList& attrList = (*first).second; + for(int gasType=0; gasType<3; gasType++) { + Dedxcorrection.paraL_dEdx_p1[gasType] = attrList["paraL_dEdx_p1"].data<float>(); + Dedxcorrection.paraL_dEdx_p2[gasType] = attrList["paraL_dEdx_p2"].data<float>(); + Dedxcorrection.paraL_dEdx_p3[gasType] = attrList["paraL_dEdx_p3"].data<float>(); + Dedxcorrection.paraL_dEdx_p4[gasType] = attrList["paraL_dEdx_p4"].data<float>(); + Dedxcorrection.paraL_dEdx_p5[gasType] = attrList["paraL_dEdx_p5"].data<float>(); + + Dedxcorrection.para_dEdx_p1[gasType] = attrList["para_dEdx_p1"].data<float>(); + Dedxcorrection.para_dEdx_p2[gasType] = attrList["para_dEdx_p2"].data<float>(); + Dedxcorrection.para_dEdx_p3[gasType] = attrList["para_dEdx_p3"].data<float>(); + Dedxcorrection.para_dEdx_p4[gasType] = attrList["para_dEdx_p4"].data<float>(); + Dedxcorrection.para_dEdx_p5[gasType] = attrList["para_dEdx_p5"].data<float>(); + + Dedxcorrection.norm_offset_data[gasType] = attrList["norm_offset_data"].data<float>(); + Dedxcorrection.norm_slope_tot[gasType] = attrList["norm_slope_tot"].data<float>(); + Dedxcorrection.norm_slope_totl[gasType] = attrList["norm_slope_totl"].data<float>(); + Dedxcorrection.norm_offset_tot[gasType] = attrList["norm_offset_tot"].data<float>(); + Dedxcorrection.norm_offset_totl[gasType] = attrList["norm_offset_totl"].data<float>(); + Dedxcorrection.norm_nzero[gasType]=attrList["norm_nzero"].data<int>(); + } + } + } + + return StatusCode::SUCCESS; +} + + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.h b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..f20f5586e0ed862dbe02153fbc65f3dd90f27d4b --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTToTCondAlg.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRTTOTCONDALG_H +#define TRTTOTCONDALG_H + +#include <map> +#include <string> +#include <vector> + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "StoreGate/WriteCondHandleKey.h" +#include "AthenaPoolUtilities/CondAttrListVec.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/Property.h" +#include "TRT_ConditionsData/TRTDedxcorrection.h" + +class TRTToTCondAlg : public AthAlgorithm +{ + public: + TRTToTCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~TRTToTCondAlg() override; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + enum EDataBaseType {kOldDB,kNewDB}; + StatusCode update1( TRTDedxcorrection& Dedxcorrection, const CondAttrListVec* channel_values); + void update_New(TRTDedxcorrection& Dedxcorrection, std::map<std::string,std::vector<float> > &result_dict) ; + void update_Old(TRTDedxcorrection& Dedxcollection, std::map<std::string,std::vector<float> > &result_dict) ; + StatusCode update2(TRTDedxcorrection& Dedxcorrection, const CondAttrListCollection* attrListColl ); + + private: + ServiceHandle<ICondSvc> m_condSvc; + SG::ReadCondHandleKey<CondAttrListVec> m_VecReadKey{this,"ToTVecReadKey","/TRT/Calib/ToT/ToTVectors","ToTVec in-key"}; + SG::ReadCondHandleKey<CondAttrListCollection> m_ValReadKey{this,"ToTValReadKey","/TRT/Calib/ToT/ToTValue","ToTVal in-key"}; + SG::WriteCondHandleKey<TRTDedxcorrection> m_WriteKey{this,"ToTWriteKey","Dedxcorrection","Dedxcorrection out-key"}; + +}; +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/components/TRT_ConditionsAlgs_entries.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/components/TRT_ConditionsAlgs_entries.cxx index 059774c30e7eb33a42677613b0841099db9ad6d1..da65ad8321becac3ec7cca5c6c510012d9df04e1 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/components/TRT_ConditionsAlgs_entries.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/components/TRT_ConditionsAlgs_entries.cxx @@ -2,9 +2,17 @@ #include "TRT_ConditionsAlgs/TRTStrawAlign.h" #include "TRT_ConditionsAlgs/TRTStrawStatusWrite.h" #include "../TRTAlignCondAlg.h" +#include "../TRTStrawCondAlg.h" +#include "../TRTHTCondAlg.h" +#include "../TRTToTCondAlg.h" +#include "../TRTActiveCondAlg.h" DECLARE_COMPONENT( TRTCondWrite ) DECLARE_COMPONENT( TRTStrawAlign ) DECLARE_COMPONENT( TRTStrawStatusWrite ) DECLARE_COMPONENT( TRTAlignCondAlg ) +DECLARE_COMPONENT( TRTStrawCondAlg ) +DECLARE_COMPONENT( TRTHTCondAlg ) +DECLARE_COMPONENT( TRTToTCondAlg ) +DECLARE_COMPONENT( TRTActiveCondAlg ) diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/CMakeLists.txt b/InnerDetector/InDetConditions/TRT_ConditionsData/CMakeLists.txt index 4679576b69f319f21064b80ba97cc70bcd6c1d7d..8b620cc1aa28d6547c8c86a280269969afe85f21 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsData/CMakeLists.txt +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/CMakeLists.txt @@ -8,10 +8,15 @@ atlas_subdir( TRT_ConditionsData ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC Control/AthenaKernel + Control/AthToolSupport/AsgTools Database/AthenaPOOL/AthenaPoolUtilities DetectorDescription/DetDescrCond/DetDescrConditions DetectorDescription/Identifier - GaudiKernel ) + GaudiKernel + PRIVATE + Tracking/TrkEvent/TrkEventPrimitives) + + # External dependencies: find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) @@ -21,12 +26,12 @@ atlas_add_library( TRT_ConditionsData src/*.cxx PUBLIC_HEADERS TRT_ConditionsData PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions Identifier GaudiKernel + LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions Identifier GaudiKernel AsgTools TrkEventPrimitives PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) atlas_add_dictionary( TRT_ConditionsDataDict TRT_ConditionsData/TRT_ConditionsDataDict.h TRT_ConditionsData/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaPoolUtilities DetDescrConditions Identifier GaudiKernel TRT_ConditionsData ) + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaPoolUtilities DetDescrConditions Identifier GaudiKernel AsgTools TRT_ConditionsData ) diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ActiveFraction.h b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ActiveFraction.h new file mode 100644 index 0000000000000000000000000000000000000000..7c4a8bd6e6670012b6e6a5c4ac8cb4d3916386f7 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ActiveFraction.h @@ -0,0 +1,104 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ACTIVEFRACTION_H +#define ACTIVEFRACTION_H +#include <vector> +#include "AthenaKernel/CLASS_DEF.h" +#include "AthenaKernel/CondCont.h" +#ifndef M_PI +#define M_PI 3.141592653589793238462643383279502884197 +#endif +namespace TRTCond{ + // eta,phi binned map of the active straw fraction + class ActiveFraction{ + public: + ActiveFraction(); + virtual ~ActiveFraction(){}; + int findEtaBin( float eta ) const; + int findPhiBin( float phi ) const; + float getActiveFraction( float eta, float phi ) const; + std::vector<std::pair<float,float>> getEtaBins( ) const; + std::vector<std::pair<float,float>> getPhiBins( ) const; + void setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value); + + private: + int m_nBinsPhi; + std::vector<std::pair<float,float> > m_etaBins; + std::vector<std::pair<float,float> > m_phiBins; + std::vector<std::vector<float> > m_activeFracTable; // [etaBin,phiBin] + }; + inline ActiveFraction::ActiveFraction() { + m_nBinsPhi=96; + m_etaBins.push_back( std::make_pair(-2.1,-1.75) ); + m_etaBins.push_back( std::make_pair(-1.75,-1.3) ); + m_etaBins.push_back( std::make_pair(-1.3,-1.07) ); + m_etaBins.push_back( std::make_pair(-1.07,-0.65) ); + m_etaBins.push_back( std::make_pair(-0.65,-0.1) ); + m_etaBins.push_back( std::make_pair(-0.1,0.) ); + m_etaBins.push_back( std::make_pair(0.,0.1) ); + m_etaBins.push_back( std::make_pair(0.1,0.65) ); + m_etaBins.push_back( std::make_pair(0.65,1.07) ); + m_etaBins.push_back( std::make_pair(1.07,1.3) ); + m_etaBins.push_back( std::make_pair(1.3,1.75) ); + m_etaBins.push_back( std::make_pair(1.75,2.1) ); + float phiEdgeLow = -1. * M_PI; + float deltaPhi = 2. * M_PI / (1. * m_nBinsPhi) ; + for ( int i = 0; i < m_nBinsPhi; ++i ) { + m_phiBins.push_back( std::make_pair( phiEdgeLow + i*deltaPhi, phiEdgeLow + (i+1)*deltaPhi ) ); + } + // Initialize the table with 1.'s + std::vector<float> dummyPhiVec( m_phiBins.size(), 1. ); + std::vector<std::vector<float> > dummyTable( m_etaBins.size(), dummyPhiVec ); + m_activeFracTable = dummyTable; + } + + inline int ActiveFraction::findEtaBin( float eta) const { + int etaBin = 0; + for ( ; etaBin < (int)m_etaBins.size(); ++etaBin ) { + std::pair<float,float> theBin = m_etaBins.at(etaBin); + if ( eta > theBin.first && eta <= theBin.second ) break; + } + if ( etaBin == (int)m_etaBins.size() ) return -1; + + return etaBin; + } + + inline int ActiveFraction::findPhiBin( float phi) const { + int phiBin = 0; + for ( ; phiBin < (int)m_phiBins.size(); ++phiBin ) { + std::pair<float,float> theBin = m_phiBins.at(phiBin); + if ( phi > theBin.first && phi <= theBin.second ) break; + } + if ( phiBin == (int)m_phiBins.size() ) return-1; + return phiBin; + } + + inline float ActiveFraction::getActiveFraction( float eta, float phi ) const { + + + int etaBin = findEtaBin(eta); + if ( etaBin < 0 ) return 1.; + int phiBin = findPhiBin(phi); + if ( phiBin < 0 ) return 1.; + return m_activeFracTable[etaBin][phiBin]; + } + inline void ActiveFraction::setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value) { + + m_activeFracTable[etaBin][phiBin] = value; + } + + inline std::vector<std::pair<float,float>> ActiveFraction::getEtaBins( ) const { + return m_etaBins; + } + + inline std::vector<std::pair<float,float>> ActiveFraction::getPhiBins( ) const { + return m_phiBins; + } + +} + +CLASS_DEF(TRTCond::ActiveFraction,69272917,1) +CONDCONT_DEF(TRTCond::ActiveFraction,85974973); +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/AliveStraws.h b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/AliveStraws.h new file mode 100644 index 0000000000000000000000000000000000000000..ae21c9b65d71deccb8882089976227abf2883be5 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/AliveStraws.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ALIVESTRAWS_H +#define ALIVESTRAWS_H +#include "AthenaKernel/CLASS_DEF.h" +#include "AthenaKernel/CondCont.h" +namespace TRTCond{ + class AliveStraws{ + public: + AliveStraws() { + // Create arrays for alive straws + // These are moved to CondStore which takes care of their deletion + m_stw_total = new int[7](); + m_stw_local = new int*[6]; + m_stw_wheel = new int*[34]; + for (int i=0; i<6 ; ++i) m_stw_local[i] = new int[32](); + for (int i=0; i<34; ++i) m_stw_wheel[i] = new int[32](); + } + + virtual ~AliveStraws() {} + int *getStwTotal() const {return m_stw_total; } + int **getStwLocal() const {return m_stw_local; } + int **getStwWheel() const {return m_stw_wheel; } + void update(const int& i, const int& j, const int& phi) { + + m_stw_total[0] +=1; + m_stw_total[i] +=1; + m_stw_local[i-1][phi] +=1; + m_stw_wheel[j][phi] +=1; + } + + private: + int *m_stw_total; + int **m_stw_local; + int **m_stw_wheel; + }; +} +CLASS_DEF(TRTCond::AliveStraws,234870469,1) +CONDCONT_DEF(TRTCond::AliveStraws,110897079); +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/HTcalculator.h b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/HTcalculator.h new file mode 100644 index 0000000000000000000000000000000000000000..0df1195eca650314db7048475fc9b3ca605eee9c --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/HTcalculator.h @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef INDETTRT_HTCALCULATOR +#define INDETTRT_HTCALCULATOR + +/////////////////////////////////////////////////////////////////// +// HTcalculater.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +/****************************************************************************************\ + + This class is instantiated in TRTHTCondAlg and put on CondStore + + Original creator: Simon Heisterkamp (simon.heisterkamp@cern.ch) + Author: Troels Petersen (petersen@nbi.dk) + Peter Hansen (phansen@nbi.dk) + +\****************************************************************************************/ +#include "TRT_ConditionsData/StorePIDinfo.h" +#include "AthenaPoolUtilities/CondAttrListVec.h" +#include "TrkEventPrimitives/ParticleHypothesis.h" +#include "GaudiKernel/StatusCode.h" +#include "AthenaKernel/CLASS_DEF.h" +#include "AthenaKernel/CondCont.h" + + +class HTcalculator { + public: + + HTcalculator(); + virtual ~HTcalculator(); + + void checkInitialization(); + float Limit( float prob); + // set constants to hard coded defaults + void setDefaultCalibrationConstants(); + + StatusCode ReadVectorDB( const CondAttrListVec* channel_values ); + + float getProbHT( float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkAnode, float Occupancy, bool hasTrackPars) const; + + float pHTvsPGOG(int TrtPart, int GasType, float p, float mass, float occ) const; + + + + private: + + bool m_HasBeenInitialized; + + static const int N_GAS = 3; + static const int N_DET = 3; + static const int N_PAR2 = 10; + StorePIDinfo m_par_pHTvsPGOG_new [N_GAS][N_DET]; // New approach (useOccupancy = true) + + +// Store in a compact way all the corrections + StorePIDinfo m_CpHT_B_Zee_SL_new [N_GAS] [N_DET]; + StorePIDinfo m_CpHT_B_Zmm_SL_new [N_GAS] [N_DET]; + + StorePIDinfo m_CpHT_B_Zee_ZR_new [N_GAS] [N_DET]; + StorePIDinfo m_CpHT_B_Zmm_ZR_new [N_GAS] [N_DET]; + + StorePIDinfo m_CpHT_B_Zee_TW_new [N_GAS] [N_DET]; + StorePIDinfo m_CpHT_B_Zmm_TW_new [N_GAS] [N_DET]; + + StorePIDinfo m_CpHT_B_Zee_OR_new [N_GAS] [N_DET]; + StorePIDinfo m_CpHT_B_Zmm_OR_new [N_GAS] [N_DET]; + + + Trk::ParticleMasses m_particlemasses; + + static const int SIZE_OF_HEADER = sizeof(float) * 4; + static const int SIZE_OF_BLOB = sizeof(float) *( (N_PAR2*N_DET)); + + bool m_datainplace; + +}; + +CLASS_DEF(HTcalculator,241669896,1) +CONDCONT_DEF(HTcalculator,124823640); +#endif diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/StorePIDinfo.h b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/StorePIDinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..eefc1a47c86545fde7cb390e7842f02e46c99f5c --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/StorePIDinfo.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef INDETTRT_STOREPIDINFO +#define INDETTRT_STOREPIDINFO + +/////////////////////////////////////////////////////////////////// +// StorePIDinfo.h , (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +#include <vector> +#include "GaudiKernel/StatusCode.h" +class StorePIDinfo{ + public: + StorePIDinfo(); + StorePIDinfo(int nbins, float min, float max, std::vector<float> values); + ~StorePIDinfo(); + void update (int nbins, float min, float max, std::vector<float> values ); + void push_back ( float value ); + StatusCode check ( int gas, int detpart) const; + float GetValue ( float input ) const; + float GetBinValue ( int bin ) const; + int GetBin ( float input ) const; + private: + unsigned int m_nbins ; + float m_min ; + float m_max ; + std::vector<float> m_values; +}; +#endif + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/TRTDedxcorrection.h b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/TRTDedxcorrection.h new file mode 100644 index 0000000000000000000000000000000000000000..7084393ef3f5f893291d6aaf8b91f8aeaf6a2061 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/TRTDedxcorrection.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRTDEDXCORRECTION_H +#define TRTDEDXCORRECTION_H + + +struct TRTDedxcorrection { + + double paraL_dEdx_p1[3]; + double paraL_dEdx_p2[3]; + double paraL_dEdx_p3[3]; + double paraL_dEdx_p4[3]; + double paraL_dEdx_p5[3]; + + double para_dEdx_p1[3]; + double para_dEdx_p2[3]; + double para_dEdx_p3[3]; + double para_dEdx_p4[3]; + double para_dEdx_p5[3]; + + + // resolution depends on the number of hits (and is different for e) + double resolution[3][4]; + double resolution_e[3][4]; + + // corrections for pile-up (as a function of NVtx linear behavior observed) + // was in principle also done separately for different detector regions + // should be checked in more details when high pileup data available + + double norm_offset_data[3]; // offset in normalization between data and MC + double norm_slope_tot[3]; // nvtx dependence for ToT + double norm_slope_totl[3]; // nvtx dependence for ToT/L + double norm_offset_tot[3]; // nvtx dependence for ToT + double norm_offset_totl[3]; // nvtx dependence for ToT/L + int norm_nzero[3]; // for which average NVtx the fit parameters were determined + + double para_long_corrRZ[3][3240]; + double para_short_corrRZ[3][216]; + double para_end_corrRZ[3][336]; + + double para_long_corrRZ_MC[3][3240]; + double para_short_corrRZ_MC[3][216]; + double para_end_corrRZ_MC[3][336]; + double para_long_corrRZL_MC[3][630]; + double para_short_corrRZL_MC[3][144]; + double para_end_corrRZL_MC[3][252]; + + double para_long_corrRZL_DATA[3][630]; + double para_short_corrRZL_DATA[3][63]; + double para_end_corrRZL_DATA[3][252]; + + float para_end_mimicToXe_MC[3][560]; + float para_end_mimicToXe_DATA[3][560]; + + float para_short_mimicToXe_MC[3][180]; + float para_short_mimicToXe_DATA[3][180]; + float para_long_mimicToXe_MC[3][1800]; + float para_long_mimicToXe_DATA[3][1800]; + + //============================================================== + + +}; +CLASS_DEF(TRTDedxcorrection,105466510,1) +CONDCONT_DEF(TRTDedxcorrection,114226988); + +#endif /* TRTDEDXCORRECTION_H */ diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2_HTcalculation.cxx b/InnerDetector/InDetConditions/TRT_ConditionsData/src/HTcalculator.cxx similarity index 86% rename from InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2_HTcalculation.cxx rename to InnerDetector/InDetConditions/TRT_ConditionsData/src/HTcalculator.cxx index 7cc9426abed75256d4c0958b4694b5d1b99a13b3..e1327d298bb0075cb5735837bc1451b1e42b4dcf 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2_HTcalculation.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/src/HTcalculator.cxx @@ -1,760 +1,663 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ +#include "TRT_ConditionsData/HTcalculator.h" +#include "AsgTools/MsgStreamMacros.h" + +/*****************************************************************************\ +|*%%% Default Constructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +HTcalculator::HTcalculator() +{ + m_datainplace = false; + m_HasBeenInitialized=0; +} + +/*****************************************************************************\ +|*%%% Default Destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +HTcalculator::~HTcalculator(){ + //Nothing here yet +} + +void HTcalculator::checkInitialization(){ + if( not m_HasBeenInitialized ) { + //ATH_MSG_WARNING( "The HTcalculator is about to be used uninitialized - Loading default"); + setDefaultCalibrationConstants(); + m_HasBeenInitialized=1; + } +} + +float HTcalculator::Limit(float prob){ + if( prob > 1.0 ){ + return 1.0; + } + else if( prob < 0.0 ){ + return 0.0; + } + + return prob; +} + +/*****************************************************************************\ +|*%%% Get The Pobability of this hit being a Hight THreshold hit %%%%%%%%%%*| +\*****************************************************************************/ + +// TrtPart: 0 = Barrel, 1 = EndcapA, 2 = EndcapB +// GasType: 0 = Xenon, 1 = Argon, 2 = Krypton +float HTcalculator::getProbHT( + float pTrk, Trk::ParticleHypothesis hypothesis, + int TrtPart, int GasType, int StrawLayer, + float ZR, float rTrkWire, float Occupancy, bool hasTrackPars = true ) const { + + + //FIXME: This setup the Troels constants. THIS OVERRIDES CURRENT DB!!! + // setDefaultCalibrationConstants(); + + float pHT = 1.0; // Default/unit value, which ensures that unusable hits does not change probability product! + // Make sure that the information passed makes sense: + // -------------------------------------------------- + if (pTrk < 250.0 || pTrk > 7000000.0) return pHT; + + if (TrtPart < 0 || TrtPart > 2) return pHT; + if (GasType < 0 || GasType > 2) return pHT; + + if ((TrtPart == 0 && (StrawLayer < 0 || StrawLayer > 72)) || + (TrtPart == 1 && (StrawLayer < 0 || StrawLayer > 95)) || + (TrtPart == 2 && (StrawLayer < 0 || StrawLayer > 63))) return pHT; + + if ((TrtPart == 0 && (ZR > 720.0)) || + (TrtPart > 0 && (ZR < 630.0 || ZR > 1030.0))) return pHT; + + if (rTrkWire < 0.0 || rTrkWire > 2.2) return pHT; + + + // Calculate the High Threshold probability, pHT: + // ---------------------------------------------- + float correctionSL, correctionZR, correctionTW; + float mass = m_particlemasses.mass[hypothesis]; + float correctionPGOG=-999.; + if (GasType==1 && TrtPart==2) { + //estimate EB argon straws as follows: + // estimate pHT using EA argon straws (GasType=1, TrtPart=1) + // estimate correction factors using EB xenon straws (GasType=0, TrtPart=2) + correctionPGOG = pHTvsPGOG(1, GasType, pTrk, mass, Occupancy); + GasType = 0; + } else { + correctionPGOG = pHTvsPGOG(TrtPart, GasType, pTrk, mass, Occupancy); + } + + // Jared -- Change this ugly check, use hypothesis! + if (fabs(mass-0.511) < 0.1) { // Electron! OK, ugly way but works... + correctionSL = m_CpHT_B_Zee_SL_new[GasType][TrtPart].GetValue(StrawLayer); + correctionZR = m_CpHT_B_Zee_ZR_new[GasType][TrtPart].GetValue(ZR); + correctionTW = m_CpHT_B_Zee_TW_new[GasType][TrtPart].GetValue(rTrkWire); + } else { // Non-electron! + correctionSL = m_CpHT_B_Zmm_SL_new[GasType][TrtPart].GetValue(StrawLayer); + correctionZR = m_CpHT_B_Zmm_ZR_new[GasType][TrtPart].GetValue(ZR); + correctionTW = m_CpHT_B_Zmm_TW_new[GasType][TrtPart].GetValue(rTrkWire); + } + + // Jared - In absence of track pars, no ZR or TW information -- disable correction factors + if (not hasTrackPars) { correctionZR = 1.0; correctionTW = 1.0; } + + // Jared - Temporarily disable ZR corrections, reproducibility issues with calibration + //correctionZR = 1.0; + + /* + std::cout "check " + << " GammaOccupan: " << correctionPGOG + << " correctionSL: " << correctionSL + << " correctionZR: " << correctionZR + << " correctionTW: " << correctionTW << std::endl; + */ + + return correctionPGOG * correctionSL * correctionZR * correctionTW; +} + +// ------------------------------------------------------------------------------------------------------------ // +// PART, GAMMA, OCCUPANCY, and GAS dependence functions: +// ------------------------------------------------------------------------------------------------------------ // + +float HTcalculator::pHTvsPGOG(int TrtPart, int GasType, float p, float mass, float occ) const { + + float gamma = sqrt(p*p + mass*mass) / mass; + + // The position of the upper point of linearity varies with occupancy! + double par1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(1) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(6)*occ; + // The position of the onset varies with occupancy! + double par4 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(4) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(7)*occ; + + // TR onset part (main part): + double exp_term = exp(-(log10(gamma) - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); + double pHT_TR = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term); + + // dE/dx part (linear at low gamma): + double exp_term0 = exp(-(m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0) - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); + double alpha0 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term0); + double beta0 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3) / ((1.0 + exp_term0)*(1.0 + exp_term0)) * exp_term0 / m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5); + double pHT_dEdx = alpha0 + beta0*(log10(gamma) - m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0)); -/////////////////////////////////////////////////////////////////////////////// -// TRT_ElectronPidToolRun2_HTcalculation.cxx, (c) ATLAS Detector software // -/////////////////////////////////////////////////////////////////////////////// - -/*****************************************************************************\ - This file contains the implementation of the class HTcalculator. - - It is intended to contain all the code that is used for the calculation of - the likelihood of a TRT hit being from an electron based on the time over - threshold. - - Authors: Troels C. Petersen (petersen@nbi.dk), - Jared G. Vasquez (jared.vasquez@yale.edu), - -\*****************************************************************************/ - -#ifdef INDETTRT_ELECTRONPIDTOOLRUN2_H -#ifndef TRT_ELECTRONPIDRUN2_HTCALCULATION_CXX -#define TRT_ELECTRONPIDRUN2_HTCALCULATION_CXX - - -InDet::TRT_ElectronPidToolRun2::StorePIDinfo::StorePIDinfo(){ - m_nbins = 0; - m_min = -9999.9; - m_max = 10000000*2; - m_values.clear(); -} - -InDet::TRT_ElectronPidToolRun2::StorePIDinfo::StorePIDinfo(int nbins, float min, float max, std::vector<float> values){ - update (nbins, min, max, values); -} - -InDet::TRT_ElectronPidToolRun2::StorePIDinfo::~StorePIDinfo(){} - -void InDet::TRT_ElectronPidToolRun2::StorePIDinfo::update( int nbins, float min, float max, std::vector<float> values){ - m_nbins = nbins ; - m_min = min ; - m_max = max ; - if (values.size()!=m_nbins){ - printf(" ERROR: DIFFERENT Values of n_bins and vector size!!!\n"); - } - m_values.clear(); - for (unsigned int i = 0; i<values.size(); i++ ){ - m_values.push_back( values.at(i)); - } -} - -// THIS HAS TO BE CALLED in order!!! -void InDet::TRT_ElectronPidToolRun2::StorePIDinfo::push_back( float value ){ - // Just to read the DB - if (m_nbins==0) { - m_nbins = int(value) ; - m_min = -9999.9 ; - m_max = 10000000*2 ; - m_values.clear() ; - } - else if (m_min < -9999) m_min = value ; - else if (m_max > 10000000) m_max = value ; - else m_values.push_back(value); -} - -StatusCode InDet::TRT_ElectronPidToolRun2::StorePIDinfo::check( int gas, int detpart){ - if ( m_nbins == 0) - { - std::cout << "ERROR: PIDDB no bins in the DB!! Gas: " << gas << " detPart: " << detpart << std::endl; - return StatusCode::FAILURE; - } - else if ( m_nbins != m_values.size() ) - { - std::cout << "ERROR: PIDDB different number of numbers!!!!! " << gas << " detPart: " << detpart << std::endl; - return StatusCode::FAILURE; - } - else if ( (m_max < m_min) || (m_max == m_min) ) - { - std::cout << "ERROR: PIDDB Max is smaller or equal than min!!!" << gas << " detPart: " << detpart << std::endl; - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} - - -float InDet::TRT_ElectronPidToolRun2::StorePIDinfo::GetValue ( float input ){ - return m_values.at( GetBin( input ) ); -} - -float InDet::TRT_ElectronPidToolRun2::StorePIDinfo::GetBinValue ( int bin){ - return m_values.at( bin ); -} - -int InDet::TRT_ElectronPidToolRun2::StorePIDinfo::GetBin ( float input ){ - if (input < m_min) return 0; - else if (input >= m_max) return m_nbins-1; - else{ - float dr = (m_max-m_min)/m_nbins; - unsigned int bin = int ( (input - m_min)/dr ) ; - if (bin >= m_nbins) printf(" ERROR: Bin number is larger than number of bins!!!\n"); - return bin; - } - return 0; -} - -/*****************************************************************************\ -|*%%% Default Constructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -InDet::TRT_ElectronPidToolRun2::HTcalculator::HTcalculator(AthAlgTool & parent): - BaseTRTPIDCalculator(parent, (SIZE_OF_HEADER+SIZE_OF_BLOB),"HT") -{ - m_datainplace = false; - CurrentVersion = my_CurrentVersion; -} - -/*****************************************************************************\ -|*%%% Default Destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -InDet::TRT_ElectronPidToolRun2::HTcalculator::~HTcalculator(){ - //Nothing here yet -} - - -/*****************************************************************************\ -|*%%% Get The Pobability of this hit being a Hight THreshold hit %%%%%%%%%%*| -\*****************************************************************************/ - -// TrtPart: 0 = Barrel, 1 = EndcapA, 2 = EndcapB -// GasType: 0 = Xenon, 1 = Argon, 2 = Krypton -float InDet::TRT_ElectronPidToolRun2::HTcalculator::getProbHT( - float pTrk, Trk::ParticleHypothesis hypothesis, - int TrtPart, int GasType, int StrawLayer, - float ZR, float rTrkWire, float Occupancy, bool hasTrackPars = true ) { - - checkInitialization(); - - //FIXME: This setup the Troels constants. THIS OVERRIDES CURRENT DB!!! - // setDefaultCalibrationConstants(); - - float pHT = 1.0; // Default/unit value, which ensures that unusable hits does not change probability product! - // Make sure that the information passed makes sense: - // -------------------------------------------------- - if (pTrk < 250.0 || pTrk > 7000000.0) return pHT; - - if (TrtPart < 0 || TrtPart > 2) return pHT; - if (GasType < 0 || GasType > 2) return pHT; - - if ((TrtPart == 0 && (StrawLayer < 0 || StrawLayer > 72)) || - (TrtPart == 1 && (StrawLayer < 0 || StrawLayer > 95)) || - (TrtPart == 2 && (StrawLayer < 0 || StrawLayer > 63))) return pHT; - - if ((TrtPart == 0 && (ZR > 720.0)) || - (TrtPart > 0 && (ZR < 630.0 || ZR > 1030.0))) return pHT; - - if (rTrkWire < 0.0 || rTrkWire > 2.2) return pHT; - - - // Calculate the High Threshold probability, pHT: - // ---------------------------------------------- - float correctionSL, correctionZR, correctionTW; - float mass = m_particlemasses.mass[hypothesis]; - float correctionPGOG=-999.; - if (GasType==1 && TrtPart==2) { - //estimate EB argon straws as follows: - // estimate pHT using EA argon straws (GasType=1, TrtPart=1) - // estimate correction factors using EB xenon straws (GasType=0, TrtPart=2) - correctionPGOG = pHTvsPGOG(1, GasType, pTrk, mass, Occupancy); - GasType = 0; - } else { - correctionPGOG = pHTvsPGOG(TrtPart, GasType, pTrk, mass, Occupancy); - } - - // Jared -- Change this ugly check, use hypothesis! - if (fabs(mass-0.511) < 0.1) { // Electron! OK, ugly way but works... - correctionSL = m_CpHT_B_Zee_SL_new[GasType][TrtPart].GetValue(StrawLayer); - correctionZR = m_CpHT_B_Zee_ZR_new[GasType][TrtPart].GetValue(ZR); - correctionTW = m_CpHT_B_Zee_TW_new[GasType][TrtPart].GetValue(rTrkWire); - } else { // Non-electron! - correctionSL = m_CpHT_B_Zmm_SL_new[GasType][TrtPart].GetValue(StrawLayer); - correctionZR = m_CpHT_B_Zmm_ZR_new[GasType][TrtPart].GetValue(ZR); - correctionTW = m_CpHT_B_Zmm_TW_new[GasType][TrtPart].GetValue(rTrkWire); - } - - // Jared - In absence of track pars, no ZR or TW information -- disable correction factors - if (not hasTrackPars) { correctionZR = 1.0; correctionTW = 1.0; } - - // Jared - Temporarily disable ZR corrections, reproducibility issues with calibration - //correctionZR = 1.0; - - ATH_MSG_DEBUG( "check " - << " GammaOccupan: " << correctionPGOG - << " correctionSL: " << correctionSL - << " correctionZR: " << correctionZR - << " correctionTW: " << correctionTW - ); - - // Jared - Development output - //std::cout << "check " - // << " GammaOccupan: " << correctionPGOG - // << " correctionSL: " << correctionSL - // << " correctionZR: " << correctionZR - // << " correctionTW: " << correctionTW << std::endl; - - return correctionPGOG * correctionSL * correctionZR * correctionTW; -} - -// ------------------------------------------------------------------------------------------------------------ // -// PART, GAMMA, OCCUPANCY, and GAS dependence functions: -// ------------------------------------------------------------------------------------------------------------ // - -float InDet::TRT_ElectronPidToolRun2::HTcalculator::pHTvsPGOG(int TrtPart, int GasType, float p, float mass, float occ) { - - float gamma = sqrt(p*p + mass*mass) / mass; - - // The position of the upper point of linearity varies with occupancy! - double par1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(1) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(6)*occ; - // The position of the onset varies with occupancy! - double par4 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(4) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(7)*occ; - - // TR onset part (main part): - double exp_term = exp(-(log10(gamma) - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); - double pHT_TR = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term); - - // dE/dx part (linear at low gamma): - double exp_term0 = exp(-(m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0) - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); - double alpha0 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term0); - double beta0 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3) / sqr(1.0 + exp_term0) * exp_term0 / m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5); - double pHT_dEdx = alpha0 + beta0*(log10(gamma) - m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0)); - // High-gamma part (linear at high gamma): - double exp_term1 = exp(-(par1 - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); - double alpha1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term1); - double beta1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3) / sqr(1.0 + exp_term1) * exp_term1 / m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5); - double pHT_HG = alpha1 + beta1*(log10(gamma) - par1); - - double pHT_OccZero = pHT_TR; - if (log10(gamma) < m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0)) pHT_OccZero = pHT_dEdx; - else if (log10(gamma) > par1 ) pHT_OccZero = pHT_HG; - - - // The occupancy dependency is included through the Anatoli formula and a quadratic fit from the muon plateau: - // ------------------------------------------------------------------------------------------------------------------------ - double DeltaOcc = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(8)*occ + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(9)*occ*occ; - double pHT = pHT_OccZero + (1.0 - pHT_OccZero) * DeltaOcc; - - return pHT; -} - - - -StatusCode InDet::TRT_ElectronPidToolRun2::HTcalculator::ReadVectorDB( const DataHandle<CondAttrListVec> channel_values){ - ATH_MSG_INFO( "Set TRT HT PID Parameters from the Vector Database "); - if ( channel_values->size() < 1){ - ATH_MSG_ERROR( "There are no channels available!!"); - return StatusCode::FAILURE; - } - - CondAttrListVec::const_iterator first_channel = channel_values->begin(); - CondAttrListVec::const_iterator last_channel = channel_values->end(); - - ATH_MSG_DEBUG( "There are " << channel_values->size() << " Channels " ); - int inichan = 0; - for (; first_channel != last_channel; ++first_channel) { - switch(first_channel->first){ - case 0: // gamma_All_Xenon_All_Barrel - m_par_pHTvsPGOG_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 1 : // gamma_All_Xenon_All_EndcapA - m_par_pHTvsPGOG_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 2 : // gamma_All_Xenon_All_EndcapB - m_par_pHTvsPGOG_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 3 : // gamma_All_Argon_All_Barrel - m_par_pHTvsPGOG_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 4 : // gamma_All_Argon_All_EndcapA - m_par_pHTvsPGOG_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 5 : // gamma_All_Argon_All_EndcapB - m_par_pHTvsPGOG_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 6 : // gamma_All_Krypton_All_Barrel - m_par_pHTvsPGOG_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 7 : // gamma_All_Krypton_All_EndcapA - m_par_pHTvsPGOG_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 8 : // gamma_All_Krypton_All_EndcapB - m_par_pHTvsPGOG_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - - // Xenon Corrections: - case 9 : // SL_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_SL_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 10 : // SL_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_SL_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 11 : // SL_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_SL_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 12 : // ZR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_ZR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 13 : // ZR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_ZR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 14 : // ZR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_ZR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 15 : // TW_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_TW_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 16 : // TW_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_TW_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 17 : // TW_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_TW_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 18 : // OR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_OR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 19 : // OR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_OR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 20 : // OR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_OR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 21 : // SL_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_SL_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 22 : // SL_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_SL_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 23 : // SL_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_SL_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 24 : // ZR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_ZR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 25 : // ZR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_ZR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 26 : // ZR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_ZR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 27 : // TW_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_TW_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 28 : // TW_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_TW_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 29 : // TW_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_TW_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 30 : // OR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_OR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 31 : // OR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_OR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 32 : // OR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_OR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - - // Argon Corrections: - case 33 : // SL_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_SL_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 34 : // SL_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_SL_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 35 : // SL_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_SL_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 36 : // ZR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_ZR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 37 : // ZR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_ZR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 38 : // ZR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_ZR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 39 : // TW_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_TW_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 40 : // TW_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_TW_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 41 : // TW_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_TW_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 42 : // OR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_OR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 43 : // OR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_OR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 44 : // OR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_OR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 45 : // SL_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_SL_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 46 : // SL_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_SL_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 47 : // SL_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_SL_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 48 : // ZR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_ZR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 49 : // ZR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_ZR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 50 : // ZR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_ZR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 51 : // TW_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_TW_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 52 : // TW_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_TW_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 53 : // TW_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_TW_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 54 : // OR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_OR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 55 : // OR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_OR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 56 : // OR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_OR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - - - // Krypton Corrections: - case 57 : // SL_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_SL_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 58 : // SL_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_SL_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 59 : // SL_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_SL_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 60 : // ZR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_ZR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 61 : // ZR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_ZR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 62 : // ZR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_ZR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 63 : // TW_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_TW_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 64 : // TW_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_TW_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 65 : // TW_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_TW_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 66 : // OR_Zee_Xenon_Electrons_Barrel - m_CpHT_B_Zee_OR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 67 : // OR_Zee_Xenon_Electrons_EndcapA - m_CpHT_B_Zee_OR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 68 : // OR_Zee_Xenon_Electrons_EndcapB - m_CpHT_B_Zee_OR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 69 : // SL_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_SL_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 70 : // SL_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_SL_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 71 : // SL_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_SL_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 72 : // ZR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_ZR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 73 : // ZR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_ZR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 74 : // ZR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_ZR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 75 : // TW_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_TW_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 76 : // TW_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_TW_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 77 : // TW_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_TW_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 78 : // OR_Zmm_Xenon_NonElecs_Barrel - m_CpHT_B_Zmm_OR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 79 : // OR_Zmm_Xenon_NonElecs_EndcapA - m_CpHT_B_Zmm_OR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - case 80 : // OR_Zmm_Xenon_NonElecs_EndcapB - m_CpHT_B_Zmm_OR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); - inichan += 1; - break; - } - } - - ATH_MSG_DEBUG( "We have read " << inichan << " good channels" ); - ATH_MSG_DEBUG( m_par_pHTvsPGOG_new [0][0].GetBinValue(0) << "\t" << m_par_pHTvsPGOG_new [0][0].GetBinValue(1) << " " << m_par_pHTvsPGOG_new [0][0].GetBinValue(2) ); - - - for (int i = 0 ; i < N_DET; i++) { - for (int j = 0 ; j < N_GAS; j++) { - if (m_par_pHTvsPGOG_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zee_SL_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zmm_SL_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zee_ZR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zmm_ZR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zee_TW_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zmm_TW_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zee_OR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - if (m_CpHT_B_Zmm_OR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; - } - } - - HasBeenInitialized=1; - UpperLimit=1.0; - LowerLimit=0.0; - ATH_MSG_INFO( "TRT PID HT Vector DB loaded: "); - return StatusCode::SUCCESS; -} - - -/*****************************************************************************\ -|*%%% Hard-coded HT Calibration Constants %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -void InDet::TRT_ElectronPidToolRun2::HTcalculator::setDefaultCalibrationConstants(){ - /*****************************************************************************\ - - This code is never called in production. It is used to set all - constants in the positions in the HTBlob where they are needed, and - finally print out the blob as an array of numbers. This is far easier and - less error prone than having a separate setter-script which might itself - have a version mismatch with this code. - - PLEASE REMEMBER to increment the version number precisely when you change - the addresses of the various arrays inside the HTBlob, and NEVER otherwise! - - \*****************************************************************************/ - //FIXME - if (m_datainplace) return; // Just to load 1 time - ATH_MSG_ERROR( "Looks like HT PID DB is NOT available, so lets set hard-coded PID calibration constants. Derived from Run1 Data Zee and Zmumu 50 ns. FIXME!!"); - HasBeenInitialized=1; - - UpperLimit=1.0; - LowerLimit=0.0; - -// Expanding to a 2D fit (gamma,occupancy) for three types of gases: Xenon, Argon, Krypton: -// ---------------------------------------------------------------------------------------- - float par2[N_GAS][N_DET][N_PAR2] = { - // Xenon Gas Parameters - {{ 1.0000, 3.7204, 0.0260, 0.1445, 3.0461, 0.2206, 0.0000, 0.0078, 0.0918, 0.0744}, // Barrel Prob: 0.9992 - { 1.0000, 3.5836, 0.0468, 0.1475, 3.0943, 0.1303, 0.0000, 0.0089, 0.1054, 0.0472}, // EndcapA Prob: 1.0000 - { 1.0000, 3.4798, 0.0433, 0.1824, 3.0730, 0.1244, 0.0000, 0.0300, 0.1007, 0.1261}}, // EndcapB Prob: 0.8536 - // Argon Gas Parameters - {{ 1.0000, 2.8342, 0.0384, 0.0185, 2.7161, 0.0366, 0.0000, 0.0013, 0.1261, 0.1241}, // Barrel Prob: 1.0000 - { 1.0000, 3.2551, 0.0388, 0.0338, 2.9090, 0.1663, 0.0000, 0.1604, 0.1100, 0.0521}, // EndcapA Prob: 0.9970 - { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}}, // EndcapB ------------ - // Krypton Gas Parameters (Place Holder) - {{ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}, // Barrel ------------ - { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}, // EndcapA ------------ - { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}}}; // EndcapB ------------ - - for (int i = 0 ; i < N_GAS; i++) - for (int j = 0 ; j < N_DET; j++) - m_par_pHTvsPGOG_new[i][j] .update ( 10, 50, 1000000.0, std::vector<float> (par2[i][j] , par2[i][j] + sizeof par2[i][j] / sizeof par2[i][j][0]) ); - - - const int N_SL_B = 73; - const int N_SL_EA = 96; - const int N_SL_EB = 64; - const int N_ZR_B = 36; - const int N_ZR_EA = 40; - const int N_ZR_EB = 40; - const int N_TW_B = 44; - const int N_TW_EA = 44; - const int N_TW_EB = 44; - - // --------------------------------------- - // Electrons: - // --------------------------------------- - // Straw Layer (SL): - double CpHT_Zee_Barrel_SL[N_SL_B] = { 0.637, 0.887, 0.966, 1.034, 1.059, 1.009, 1.131, 1.073, 1.086, 0.925, 0.890, 0.987, 0.937, 0.964, 0.976, 0.929, 1.006, 0.979, 0.992, 0.812, 0.935, 0.950, 0.984, 0.994, 1.011, 0.952, 1.051, 0.997, 1.026, 1.018, 0.978, 1.066, 1.016, 1.039, 1.040, 0.979, 1.057, 1.018, 1.032, 1.052, 0.994, 1.055, 1.023, 0.823, 1.013, 0.977, 1.051, 1.031, 0.973, 1.077, 1.025, 1.056, 1.047, 0.992, 1.085, 1.032, 1.061, 1.054, 0.998, 1.093, 1.039, 1.058, 1.056, 0.988, 1.090, 1.057, 1.046, 1.053, 0.994, 1.081, 1.041, 1.040, 1.061}; - double CpHT_Zee_EndcapA_SL[N_SL_EA] = { 0.671, 0.802, 0.890, 0.918, 0.946, 0.963, 0.974, 0.979, 1.030, 1.023, 1.029, 1.004, 1.030, 1.037, 1.033, 1.013, 0.913, 0.968, 0.998, 0.994, 1.036, 1.032, 1.043, 1.044, 1.042, 1.009, 1.026, 1.007, 1.032, 1.046, 1.020, 1.032, 0.913, 0.955, 0.974, 0.995, 1.035, 1.042, 1.039, 1.047, 1.032, 1.036, 1.033, 1.010, 1.047, 1.049, 1.055, 1.046, 0.877, 0.938, 0.968, 0.983, 1.004, 1.010, 1.013, 1.014, 1.038, 1.031, 1.042, 1.018, 1.016, 1.049, 1.023, 1.025, 0.923, 0.978, 0.995, 1.001, 1.038, 1.042, 1.026, 1.037, 1.042, 1.062, 1.041, 1.039, 1.078, 1.058, 1.036, 1.049, 0.897, 0.965, 0.993, 0.985, 1.040, 1.068, 1.053, 1.049, 1.037, 1.050, 1.043, 1.065, 1.026, 1.058, 1.058, 1.070}; - double CpHT_Zee_EndcapB_SL[N_SL_EB] = { 0.494, 0.771, 0.887, 0.931, 0.939, 0.989, 0.994, 1.005, 0.866, 0.971, 1.027, 1.057, 1.021, 1.056, 1.046, 1.073, 0.901, 0.992, 1.043, 1.055, 1.034, 1.087, 1.094, 1.087, 0.920, 0.995, 1.048, 1.068, 1.042, 1.075, 1.086, 1.126, 0.920, 0.987, 1.062, 1.072, 1.059, 1.096, 1.070, 1.082, 0.927, 1.020, 1.068, 1.083, 1.054, 1.089, 1.078, 1.103, 0.961, 1.050, 1.100, 1.107, 1.098, 1.124, 1.101, 1.141, 0.988, 1.106, 1.127, 1.174, 1.109, 1.134, 1.134, 1.182}; - - // ZR-position (ZR - Z in Barrel, R in Endcaps): - double CpHT_Zee_Barrel_ZR[N_ZR_B] = { 0.861, 0.901, 0.909, 0.915, 0.919, 0.924, 0.922, 0.931, 0.928, 0.937, 0.945, 0.908, 0.921, 0.959, 0.970, 0.988, 0.986, 0.999, 1.010, 1.005, 0.996, 1.005, 1.018, 0.992, 1.042, 1.076, 1.101, 1.116, 1.134, 1.157, 1.170, 1.196, 1.208, 1.230, 1.230, 1.039}; - double CpHT_Zee_EndcapA_ZR[N_ZR_EA] = { 0.458, 0.621, 0.694, 0.758, 0.798, 0.838, 0.871, 0.900, 0.956, 0.980, 1.001, 1.006, 1.016, 1.027, 1.019, 1.038, 1.046, 1.045, 1.054, 1.064, 1.064, 1.077, 1.081, 1.089, 1.101, 1.113, 1.102, 1.113, 1.107, 1.113, 1.098, 1.105, 1.083, 1.054, 1.036, 0.994, 0.965, 0.887, 0.771, 0.575}; - double CpHT_Zee_EndcapB_ZR[N_ZR_EB] = { 1.000, 0.754, 0.926, 0.941, 1.001, 1.001, 0.987, 1.033, 1.054, 1.060, 1.057, 1.064, 1.061, 1.067, 1.052, 1.062, 1.045, 1.057, 1.053, 1.047, 1.053, 1.050, 1.042, 1.073, 1.050, 1.050, 1.028, 0.972, 0.928, 0.896, 0.881, 0.854, 0.828, 0.793, 0.755, 0.652, 0.511, 0.291, 0.481, 1.000}; - - // Track-to-Wire distance (TW): - double CpHT_Zee_Barrel_TW[44] = { 1.233, 1.261, 1.276, 1.296, 1.307, 1.338, 1.349, 1.386, 1.395, 1.434, 1.441, 1.448, 1.440, 1.439, 1.425, 1.406, 1.388, 1.363, 1.334, 1.320, 1.295, 1.269, 1.240, 1.212, 1.183, 1.144, 1.109, 1.073, 1.028, 0.981, 0.938, 0.879, 0.817, 0.752, 0.678, 0.606, 0.531, 0.465, 0.428, 0.443, 0.504, 0.553, 0.579, 0.766}; - double CpHT_Zee_EndcapA_TW[44] = { 1.236, 1.260, 1.291, 1.292, 1.304, 1.325, 1.354, 1.363, 1.387, 1.394, 1.409, 1.415, 1.407, 1.414, 1.405, 1.394, 1.385, 1.357, 1.345, 1.331, 1.309, 1.282, 1.252, 1.226, 1.197, 1.176, 1.135, 1.097, 1.047, 1.013, 0.946, 0.892, 0.834, 0.756, 0.696, 0.610, 0.547, 0.480, 0.444, 0.445, 0.469, 0.513, 0.584, 0.892}; - double CpHT_Zee_EndcapB_TW[44] = { 1.186, 1.202, 1.219, 1.246, 1.257, 1.270, 1.291, 1.297, 1.307, 1.319, 1.333, 1.338, 1.340, 1.326, 1.314, 1.327, 1.321, 1.310, 1.289, 1.279, 1.266, 1.240, 1.222, 1.194, 1.168, 1.153, 1.125, 1.091, 1.033, 1.009, 0.963, 0.917, 0.846, 0.802, 0.746, 0.690, 0.615, 0.560, 0.514, 0.485, 0.478, 0.473, 0.523, 0.726}; - - - // --------------------------------------- - // Non-Electrons (here muons): - // --------------------------------------- - - // Straw Layer (SL): - double CpHT_Zmm_Barrel_SL[N_SL_B] = { 1.100, 1.186, 1.209, 1.241, 1.199, 1.174, 1.209, 1.178, 1.150, 1.053, 1.033, 1.054, 1.033, 1.029, 1.041, 1.021, 1.027, 0.992, 0.988, 0.983, 0.998, 1.022, 1.043, 1.023, 1.027, 1.016, 1.034, 1.009, 1.014, 1.022, 1.001, 1.024, 1.003, 1.010, 1.004, 0.983, 0.992, 0.978, 0.981, 1.000, 0.984, 0.974, 0.953, 0.941, 0.982, 0.990, 1.005, 0.993, 0.966, 0.997, 1.000, 0.988, 0.992, 0.969, 1.003, 0.964, 0.989, 0.961, 0.956, 0.971, 0.948, 0.963, 0.951, 0.943, 0.964, 0.965, 0.925, 0.919, 0.918, 0.928, 0.919, 0.912, 0.906}; - double CpHT_Zmm_EndcapA_SL[N_SL_EA] = { 0.883, 0.898, 0.923, 0.899, 0.892, 0.909, 0.893, 0.925, 0.964, 0.964, 0.979, 0.949, 0.944, 0.998, 0.940, 0.937, 0.950, 0.976, 0.972, 0.950, 0.998, 1.005, 1.007, 1.028, 1.018, 0.995, 1.006, 0.998, 1.031, 1.047, 1.031, 1.015, 1.017, 0.983, 1.018, 1.018, 1.025, 1.033, 1.046, 1.069, 1.033, 1.027, 1.006, 0.982, 1.066, 1.080, 1.048, 1.058, 0.955, 0.971, 0.973, 0.992, 1.013, 1.046, 1.022, 1.029, 1.040, 1.016, 1.077, 1.024, 1.011, 1.095, 1.019, 1.045, 1.001, 1.057, 1.043, 1.022, 1.033, 1.108, 1.062, 1.110, 1.090, 1.058, 1.060, 1.099, 1.065, 1.120, 1.077, 1.060, 1.024, 1.006, 1.022, 1.007, 1.051, 1.118, 1.079, 1.118, 1.070, 1.064, 1.108, 1.127, 1.039, 1.107, 1.088, 1.154}; - double CpHT_Zmm_EndcapB_SL[N_SL_EB] = { 0.828, 0.961, 0.941, 0.991, 0.986, 1.015, 0.993, 0.957, 0.892, 1.005, 1.100, 1.054, 0.995, 1.042, 1.022, 1.007, 0.918, 1.019, 1.056, 1.034, 0.978, 0.981, 1.014, 1.026, 0.988, 0.978, 1.062, 1.085, 1.029, 0.989, 1.067, 1.054, 0.978, 0.971, 1.051, 1.114, 1.152, 1.172, 1.034, 1.170, 1.055, 0.990, 1.112, 1.047, 1.068, 1.013, 1.089, 1.141, 0.903, 0.960, 1.138, 1.218, 0.991, 1.087, 0.997, 1.028, 1.042, 1.155, 1.060, 1.130, 1.077, 1.186, 1.006, 1.054}; - - // ZR-position (ZR - Z in Barrel, R in Endcaps): - double CpHT_Zmm_Barrel_ZR[N_ZR_B] = { 0.846, 0.874, 0.880, 0.882, 0.876, 0.887, 0.901, 0.894, 0.894, 0.903, 0.902, 0.907, 0.918, 0.934, 0.941, 0.948, 0.963, 0.969, 0.990, 0.991, 1.012, 1.019, 1.029, 1.033, 1.072, 1.088, 1.111, 1.144, 1.164, 1.192, 1.225, 1.242, 1.271, 1.314, 1.309, 1.078}; - double CpHT_Zmm_EndcapA_ZR[N_ZR_EA] = { 0.613, 0.757, 0.783, 0.849, 0.866, 0.886, 0.915, 0.939, 0.930, 0.976, 0.969, 0.984, 0.992, 0.979, 1.006, 1.000, 1.005, 1.022, 1.020, 1.030, 1.031, 1.036, 1.053, 1.050, 1.050, 1.048, 1.065, 1.071, 1.060, 1.077, 1.067, 1.072, 1.070, 1.067, 1.090, 1.059, 1.032, 1.081, 1.011, 0.984}; - double CpHT_Zmm_EndcapB_ZR[N_ZR_EB] = { 1.000, 1.375, 0.962, 0.702, 0.869, 0.899, 0.953, 0.905, 1.052, 1.025, 1.016, 1.009, 1.033, 0.920, 1.056, 1.031, 1.070, 1.042, 1.052, 1.066, 1.024, 1.023, 1.046, 1.046, 1.007, 1.009, 1.009, 1.024, 1.007, 0.993, 0.968, 0.997, 0.911, 0.922, 0.938, 0.921, 0.883, 0.653, 0.917, 1.000}; - - // Track-to-Wire distance (TWdist): - double CpHT_Zmm_Barrel_TW[N_TW_B] = { 1.124, 1.058, 1.065, 1.079, 1.094, 1.124, 1.141, 1.173, 1.207, 1.226, 1.250, 1.250, 1.258, 1.249, 1.258, 1.243, 1.229, 1.211, 1.206, 1.180, 1.165, 1.138, 1.123, 1.100, 1.074, 1.052, 1.014, 0.981, 0.953, 0.896, 0.866, 0.809, 0.776, 0.736, 0.690, 0.644, 0.609, 0.615, 0.680, 0.854, 1.094, 1.274, 1.208, 1.219}; - double CpHT_Zmm_EndcapA_TW[N_TW_EA] = { 1.210, 1.161, 1.177, 1.201, 1.221, 1.244, 1.279, 1.300, 1.319, 1.341, 1.362, 1.372, 1.376, 1.378, 1.384, 1.361, 1.349, 1.334, 1.325, 1.284, 1.264, 1.250, 1.223, 1.183, 1.121, 1.104, 1.077, 1.016, 0.969, 0.912, 0.863, 0.815, 0.753, 0.662, 0.604, 0.555, 0.513, 0.490, 0.511, 0.627, 0.843, 1.019, 0.932, 0.922}; - double CpHT_Zmm_EndcapB_TW[N_TW_EB] = { 1.132, 1.150, 1.125, 1.174, 1.170, 1.282, 1.165, 1.244, 1.287, 1.293, 1.270, 1.366, 1.317, 1.285, 1.319, 1.291, 1.304, 1.239, 1.256, 1.279, 1.212, 1.221, 1.200, 1.174, 1.143, 1.120, 1.022, 0.983, 0.938, 0.895, 0.906, 0.826, 0.766, 0.765, 0.664, 0.566, 0.553, 0.556, 0.541, 0.626, 0.780, 0.964, 0.817, 0.542}; - - - // -------------------------------------------------------------- - - -// Same corrections for all gases: - - for (int j = 0 ; j < N_GAS; j++){ - m_CpHT_B_Zee_SL_new [j][0].update ( N_SL_B ,-0.5 ,72.5 , std::vector<float> (CpHT_Zee_Barrel_SL , CpHT_Zee_Barrel_SL + sizeof CpHT_Zee_Barrel_SL / sizeof CpHT_Zee_Barrel_SL[0]) ); - m_CpHT_B_Zee_SL_new [j][1].update ( N_SL_EA ,-0.5 ,95.5 , std::vector<float> (CpHT_Zee_EndcapA_SL, CpHT_Zee_EndcapA_SL + sizeof CpHT_Zee_EndcapA_SL/ sizeof CpHT_Zee_EndcapA_SL[0]) ); - m_CpHT_B_Zee_SL_new [j][2].update ( N_SL_EB ,-0.5 ,63.5 , std::vector<float> (CpHT_Zee_EndcapB_SL, CpHT_Zee_EndcapB_SL + sizeof CpHT_Zee_EndcapB_SL/ sizeof CpHT_Zee_EndcapB_SL[0]) ); - - m_CpHT_B_Zmm_SL_new [j][0].update ( N_SL_B ,-0.5 ,72.5 , std::vector<float> (CpHT_Zmm_Barrel_SL , CpHT_Zmm_Barrel_SL + sizeof CpHT_Zmm_Barrel_SL / sizeof CpHT_Zmm_Barrel_SL[0]) ); - m_CpHT_B_Zmm_SL_new [j][1].update ( N_SL_EA ,-0.5 ,95.5 , std::vector<float> (CpHT_Zmm_EndcapA_SL, CpHT_Zmm_EndcapA_SL + sizeof CpHT_Zmm_EndcapA_SL/ sizeof CpHT_Zmm_EndcapA_SL[0]) ); - m_CpHT_B_Zmm_SL_new [j][2].update ( N_SL_EB ,-0.5 ,63.5 , std::vector<float> (CpHT_Zmm_EndcapB_SL, CpHT_Zmm_EndcapB_SL + sizeof CpHT_Zmm_EndcapB_SL/ sizeof CpHT_Zmm_EndcapB_SL[0]) ); - - m_CpHT_B_Zee_ZR_new [j][0].update ( N_ZR_B , 0.0 , 720.0 , std::vector<float> (CpHT_Zee_Barrel_ZR , CpHT_Zee_Barrel_ZR + sizeof CpHT_Zee_Barrel_ZR / sizeof CpHT_Zee_Barrel_ZR[0]) ); - m_CpHT_B_Zee_ZR_new [j][1].update ( N_ZR_EA , 630.0, 1030.0 , std::vector<float> (CpHT_Zee_EndcapA_ZR, CpHT_Zee_EndcapA_ZR + sizeof CpHT_Zee_EndcapA_ZR/ sizeof CpHT_Zee_EndcapA_ZR[0]) ); - m_CpHT_B_Zee_ZR_new [j][2].update ( N_ZR_EB , 630.0, 1030.0 , std::vector<float> (CpHT_Zee_EndcapB_ZR, CpHT_Zee_EndcapB_ZR + sizeof CpHT_Zee_EndcapB_ZR/ sizeof CpHT_Zee_EndcapB_ZR[0]) ); - - - m_CpHT_B_Zmm_ZR_new [j][0].update ( N_ZR_B , 0.0 , 720.0 , std::vector<float> (CpHT_Zmm_Barrel_ZR , CpHT_Zmm_Barrel_ZR + sizeof CpHT_Zmm_Barrel_ZR / sizeof CpHT_Zmm_Barrel_ZR[0]) ); - m_CpHT_B_Zmm_ZR_new [j][1].update ( N_ZR_EA , 630.0, 1030.0 , std::vector<float> (CpHT_Zmm_EndcapA_ZR, CpHT_Zmm_EndcapA_ZR + sizeof CpHT_Zmm_EndcapA_ZR/ sizeof CpHT_Zmm_EndcapA_ZR[0]) ); - m_CpHT_B_Zmm_ZR_new [j][2].update ( N_ZR_EB , 630.0, 1030.0 , std::vector<float> (CpHT_Zmm_EndcapB_ZR, CpHT_Zmm_EndcapB_ZR + sizeof CpHT_Zmm_EndcapB_ZR/ sizeof CpHT_Zmm_EndcapB_ZR[0]) ); - - m_CpHT_B_Zee_TW_new [j][0].update ( N_TW_B , 0.0, 2.2, std::vector<float> (CpHT_Zee_Barrel_TW , CpHT_Zee_Barrel_TW + sizeof CpHT_Zee_Barrel_TW / sizeof CpHT_Zee_Barrel_TW[0]) ); - m_CpHT_B_Zee_TW_new [j][1].update ( N_TW_EA , 0.0, 2.2, std::vector<float> (CpHT_Zee_EndcapA_TW, CpHT_Zee_EndcapA_TW + sizeof CpHT_Zee_EndcapA_TW/ sizeof CpHT_Zee_EndcapA_TW[0]) ); - m_CpHT_B_Zee_TW_new [j][2].update ( N_TW_EB , 0.0, 2.2, std::vector<float> (CpHT_Zee_EndcapB_TW, CpHT_Zee_EndcapB_TW + sizeof CpHT_Zee_EndcapB_TW/ sizeof CpHT_Zee_EndcapB_TW[0]) ); - - m_CpHT_B_Zmm_TW_new [j][0].update ( N_TW_B , 0.0, 2.2, std::vector<float> (CpHT_Zmm_Barrel_TW , CpHT_Zmm_Barrel_TW + sizeof CpHT_Zmm_Barrel_TW / sizeof CpHT_Zmm_Barrel_TW[0]) ); - m_CpHT_B_Zmm_TW_new [j][1].update ( N_TW_EA , 0.0, 2.2, std::vector<float> (CpHT_Zmm_EndcapA_TW, CpHT_Zmm_EndcapA_TW + sizeof CpHT_Zmm_EndcapA_TW/ sizeof CpHT_Zmm_EndcapA_TW[0]) ); - m_CpHT_B_Zmm_TW_new [j][2].update ( N_TW_EB , 0.0, 2.2, std::vector<float> (CpHT_Zmm_EndcapB_TW, CpHT_Zmm_EndcapB_TW + sizeof CpHT_Zmm_EndcapB_TW/ sizeof CpHT_Zmm_EndcapB_TW[0]) ); - } - - - m_datainplace = true; - -} + double exp_term1 = exp(-(par1 - par4)/m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5)); + double alpha1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(2) + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3)/(1.0 + exp_term1); + double beta1 = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(3) / ((1.0 + exp_term1)*(1.0 + exp_term1)) * exp_term1 / m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(5); + double pHT_HG = alpha1 + beta1*(log10(gamma) - par1); + + double pHT_OccZero = pHT_TR; + if (log10(gamma) < m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(0)) pHT_OccZero = pHT_dEdx; + else if (log10(gamma) > par1 ) pHT_OccZero = pHT_HG; + + + // The occupancy dependency is included through the Anatoli formula and a quadratic fit from the muon plateau: + // ------------------------------------------------------------------------------------------------------------------------ + double DeltaOcc = m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(8)*occ + m_par_pHTvsPGOG_new[GasType][TrtPart].GetBinValue(9)*occ*occ; + double pHT = pHT_OccZero + (1.0 - pHT_OccZero) * DeltaOcc; + + return pHT; +} + + + +StatusCode HTcalculator::ReadVectorDB( const CondAttrListVec* channel_values){ + //std::cout << "Set TRT HT PID Parameters from the Vector Database << std::endl; + if ( channel_values->size() < 1){ + //ATH_MSG_ERROR(" There are no Pid channels available!!"); + return StatusCode::FAILURE; + } + + CondAttrListVec::const_iterator first_channel = channel_values->begin(); + CondAttrListVec::const_iterator last_channel = channel_values->end(); + + //std::cout << "There are " << channel_values->size() << " Channels " << std::endl; + int inichan = 0; + for (; first_channel != last_channel; ++first_channel) { + switch(first_channel->first){ + case 0: // gamma_All_Xenon_All_Barrel + m_par_pHTvsPGOG_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 1 : // gamma_All_Xenon_All_EndcapA + m_par_pHTvsPGOG_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 2 : // gamma_All_Xenon_All_EndcapB + m_par_pHTvsPGOG_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 3 : // gamma_All_Argon_All_Barrel + m_par_pHTvsPGOG_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 4 : // gamma_All_Argon_All_EndcapA + m_par_pHTvsPGOG_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 5 : // gamma_All_Argon_All_EndcapB + m_par_pHTvsPGOG_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 6 : // gamma_All_Krypton_All_Barrel + m_par_pHTvsPGOG_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 7 : // gamma_All_Krypton_All_EndcapA + m_par_pHTvsPGOG_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 8 : // gamma_All_Krypton_All_EndcapB + m_par_pHTvsPGOG_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + + // Xenon Corrections: + case 9 : // SL_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_SL_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 10 : // SL_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_SL_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 11 : // SL_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_SL_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 12 : // ZR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_ZR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 13 : // ZR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_ZR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 14 : // ZR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_ZR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 15 : // TW_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_TW_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 16 : // TW_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_TW_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 17 : // TW_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_TW_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 18 : // OR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_OR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 19 : // OR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_OR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 20 : // OR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_OR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 21 : // SL_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_SL_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 22 : // SL_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_SL_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 23 : // SL_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_SL_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 24 : // ZR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_ZR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 25 : // ZR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_ZR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 26 : // ZR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_ZR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 27 : // TW_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_TW_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 28 : // TW_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_TW_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 29 : // TW_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_TW_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 30 : // OR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_OR_new [0][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 31 : // OR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_OR_new [0][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 32 : // OR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_OR_new [0][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + + // Argon Corrections: + case 33 : // SL_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_SL_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 34 : // SL_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_SL_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 35 : // SL_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_SL_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 36 : // ZR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_ZR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 37 : // ZR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_ZR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 38 : // ZR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_ZR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 39 : // TW_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_TW_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 40 : // TW_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_TW_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 41 : // TW_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_TW_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 42 : // OR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_OR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 43 : // OR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_OR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 44 : // OR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_OR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 45 : // SL_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_SL_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 46 : // SL_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_SL_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 47 : // SL_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_SL_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 48 : // ZR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_ZR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 49 : // ZR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_ZR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 50 : // ZR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_ZR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 51 : // TW_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_TW_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 52 : // TW_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_TW_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 53 : // TW_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_TW_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 54 : // OR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_OR_new [1][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 55 : // OR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_OR_new [1][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 56 : // OR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_OR_new [1][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + + + // Krypton Corrections: + case 57 : // SL_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_SL_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 58 : // SL_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_SL_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 59 : // SL_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_SL_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 60 : // ZR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_ZR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 61 : // ZR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_ZR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 62 : // ZR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_ZR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 63 : // TW_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_TW_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 64 : // TW_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_TW_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 65 : // TW_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_TW_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 66 : // OR_Zee_Xenon_Electrons_Barrel + m_CpHT_B_Zee_OR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 67 : // OR_Zee_Xenon_Electrons_EndcapA + m_CpHT_B_Zee_OR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 68 : // OR_Zee_Xenon_Electrons_EndcapB + m_CpHT_B_Zee_OR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 69 : // SL_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_SL_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 70 : // SL_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_SL_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 71 : // SL_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_SL_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 72 : // ZR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_ZR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 73 : // ZR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_ZR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 74 : // ZR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_ZR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 75 : // TW_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_TW_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 76 : // TW_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_TW_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 77 : // TW_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_TW_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 78 : // OR_Zmm_Xenon_NonElecs_Barrel + m_CpHT_B_Zmm_OR_new [2][0].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 79 : // OR_Zmm_Xenon_NonElecs_EndcapA + m_CpHT_B_Zmm_OR_new [2][1].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + case 80 : // OR_Zmm_Xenon_NonElecs_EndcapB + m_CpHT_B_Zmm_OR_new [2][2].push_back(first_channel->second["array_value"].data<float>()); + inichan += 1; + break; + } + } + + //std::cout << "We have read " << inichan << " good channels" << std::endl; + //std::cout << m_par_pHTvsPGOG_new [0][0].GetBinValue(0) << "\t" << m_par_pHTvsPGOG_new [0][0].GetBinValue(1) << " " << m_par_pHTvsPGOG_new [0][0].GetBinValue(2) << std::endl; + + + for (int i = 0 ; i < N_DET; i++) { + for (int j = 0 ; j < N_GAS; j++) { + if (m_par_pHTvsPGOG_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zee_SL_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zmm_SL_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zee_ZR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zmm_ZR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zee_TW_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zmm_TW_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zee_OR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + if (m_CpHT_B_Zmm_OR_new[j][i].check(j,i) != StatusCode::SUCCESS) return StatusCode::FAILURE; + } + } + + m_HasBeenInitialized=1; + //ATH_MSG_INFO(" TRT PID HT Vector DB loaded: "); + return StatusCode::SUCCESS; +} + + +/*****************************************************************************\ +|*%%% Hard-coded HT Calibration Constants %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +void HTcalculator::setDefaultCalibrationConstants(){ + /*****************************************************************************\ + + This code is never called in production. It is used to set all + constants in the positions in the HTBlob where they are needed, and + finally print out the blob as an array of numbers. This is far easier and + less error prone than having a separate setter-script which might itself + have a version mismatch with this code. + + PLEASE REMEMBER to increment the version number precisely when you change + the addresses of the various arrays inside the HTBlob, and NEVER otherwise! + + \*****************************************************************************/ + //FIXME + if (m_datainplace) return; // Just to load 1 time + //std::cout << "Looks like HT PID DB is NOT available, so lets set hard-coded PID calibration constants. Derived from Run1 Data Zee and Zmumu 50 ns. FIXME!!" << std::endl; + m_HasBeenInitialized=1; + +// Expanding to a 2D fit (gamma,occupancy) for three types of gases: Xenon, Argon, Krypton: +// ---------------------------------------------------------------------------------------- + float par2[N_GAS][N_DET][N_PAR2] = { + // Xenon Gas Parameters + {{ 1.0000, 3.7204, 0.0260, 0.1445, 3.0461, 0.2206, 0.0000, 0.0078, 0.0918, 0.0744}, // Barrel Prob: 0.9992 + { 1.0000, 3.5836, 0.0468, 0.1475, 3.0943, 0.1303, 0.0000, 0.0089, 0.1054, 0.0472}, // EndcapA Prob: 1.0000 + { 1.0000, 3.4798, 0.0433, 0.1824, 3.0730, 0.1244, 0.0000, 0.0300, 0.1007, 0.1261}}, // EndcapB Prob: 0.8536 + // Argon Gas Parameters + {{ 1.0000, 2.8342, 0.0384, 0.0185, 2.7161, 0.0366, 0.0000, 0.0013, 0.1261, 0.1241}, // Barrel Prob: 1.0000 + { 1.0000, 3.2551, 0.0388, 0.0338, 2.9090, 0.1663, 0.0000, 0.1604, 0.1100, 0.0521}, // EndcapA Prob: 0.9970 + { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}}, // EndcapB ------------ + // Krypton Gas Parameters (Place Holder) + {{ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}, // Barrel ------------ + { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}, // EndcapA ------------ + { 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000}}}; // EndcapB ------------ + + for (int i = 0 ; i < N_GAS; i++) + for (int j = 0 ; j < N_DET; j++) + m_par_pHTvsPGOG_new[i][j] .update ( 10, 50, 1000000.0, std::vector<float> (par2[i][j] , par2[i][j] + sizeof par2[i][j] / sizeof par2[i][j][0]) ); + + + const int N_SL_B = 73; + const int N_SL_EA = 96; + const int N_SL_EB = 64; + const int N_ZR_B = 36; + const int N_ZR_EA = 40; + const int N_ZR_EB = 40; + const int N_TW_B = 44; + const int N_TW_EA = 44; + const int N_TW_EB = 44; + + // --------------------------------------- + // Electrons: + // --------------------------------------- + // Straw Layer (SL): + double CpHT_Zee_Barrel_SL[N_SL_B] = { 0.637, 0.887, 0.966, 1.034, 1.059, 1.009, 1.131, 1.073, 1.086, 0.925, 0.890, 0.987, 0.937, 0.964, 0.976, 0.929, 1.006, 0.979, 0.992, 0.812, 0.935, 0.950, 0.984, 0.994, 1.011, 0.952, 1.051, 0.997, 1.026, 1.018, 0.978, 1.066, 1.016, 1.039, 1.040, 0.979, 1.057, 1.018, 1.032, 1.052, 0.994, 1.055, 1.023, 0.823, 1.013, 0.977, 1.051, 1.031, 0.973, 1.077, 1.025, 1.056, 1.047, 0.992, 1.085, 1.032, 1.061, 1.054, 0.998, 1.093, 1.039, 1.058, 1.056, 0.988, 1.090, 1.057, 1.046, 1.053, 0.994, 1.081, 1.041, 1.040, 1.061}; + double CpHT_Zee_EndcapA_SL[N_SL_EA] = { 0.671, 0.802, 0.890, 0.918, 0.946, 0.963, 0.974, 0.979, 1.030, 1.023, 1.029, 1.004, 1.030, 1.037, 1.033, 1.013, 0.913, 0.968, 0.998, 0.994, 1.036, 1.032, 1.043, 1.044, 1.042, 1.009, 1.026, 1.007, 1.032, 1.046, 1.020, 1.032, 0.913, 0.955, 0.974, 0.995, 1.035, 1.042, 1.039, 1.047, 1.032, 1.036, 1.033, 1.010, 1.047, 1.049, 1.055, 1.046, 0.877, 0.938, 0.968, 0.983, 1.004, 1.010, 1.013, 1.014, 1.038, 1.031, 1.042, 1.018, 1.016, 1.049, 1.023, 1.025, 0.923, 0.978, 0.995, 1.001, 1.038, 1.042, 1.026, 1.037, 1.042, 1.062, 1.041, 1.039, 1.078, 1.058, 1.036, 1.049, 0.897, 0.965, 0.993, 0.985, 1.040, 1.068, 1.053, 1.049, 1.037, 1.050, 1.043, 1.065, 1.026, 1.058, 1.058, 1.070}; + double CpHT_Zee_EndcapB_SL[N_SL_EB] = { 0.494, 0.771, 0.887, 0.931, 0.939, 0.989, 0.994, 1.005, 0.866, 0.971, 1.027, 1.057, 1.021, 1.056, 1.046, 1.073, 0.901, 0.992, 1.043, 1.055, 1.034, 1.087, 1.094, 1.087, 0.920, 0.995, 1.048, 1.068, 1.042, 1.075, 1.086, 1.126, 0.920, 0.987, 1.062, 1.072, 1.059, 1.096, 1.070, 1.082, 0.927, 1.020, 1.068, 1.083, 1.054, 1.089, 1.078, 1.103, 0.961, 1.050, 1.100, 1.107, 1.098, 1.124, 1.101, 1.141, 0.988, 1.106, 1.127, 1.174, 1.109, 1.134, 1.134, 1.182}; + + // ZR-position (ZR - Z in Barrel, R in Endcaps): + double CpHT_Zee_Barrel_ZR[N_ZR_B] = { 0.861, 0.901, 0.909, 0.915, 0.919, 0.924, 0.922, 0.931, 0.928, 0.937, 0.945, 0.908, 0.921, 0.959, 0.970, 0.988, 0.986, 0.999, 1.010, 1.005, 0.996, 1.005, 1.018, 0.992, 1.042, 1.076, 1.101, 1.116, 1.134, 1.157, 1.170, 1.196, 1.208, 1.230, 1.230, 1.039}; + double CpHT_Zee_EndcapA_ZR[N_ZR_EA] = { 0.458, 0.621, 0.694, 0.758, 0.798, 0.838, 0.871, 0.900, 0.956, 0.980, 1.001, 1.006, 1.016, 1.027, 1.019, 1.038, 1.046, 1.045, 1.054, 1.064, 1.064, 1.077, 1.081, 1.089, 1.101, 1.113, 1.102, 1.113, 1.107, 1.113, 1.098, 1.105, 1.083, 1.054, 1.036, 0.994, 0.965, 0.887, 0.771, 0.575}; + double CpHT_Zee_EndcapB_ZR[N_ZR_EB] = { 1.000, 0.754, 0.926, 0.941, 1.001, 1.001, 0.987, 1.033, 1.054, 1.060, 1.057, 1.064, 1.061, 1.067, 1.052, 1.062, 1.045, 1.057, 1.053, 1.047, 1.053, 1.050, 1.042, 1.073, 1.050, 1.050, 1.028, 0.972, 0.928, 0.896, 0.881, 0.854, 0.828, 0.793, 0.755, 0.652, 0.511, 0.291, 0.481, 1.000}; + + // Track-to-Wire distance (TW): + double CpHT_Zee_Barrel_TW[44] = { 1.233, 1.261, 1.276, 1.296, 1.307, 1.338, 1.349, 1.386, 1.395, 1.434, 1.441, 1.448, 1.440, 1.439, 1.425, 1.406, 1.388, 1.363, 1.334, 1.320, 1.295, 1.269, 1.240, 1.212, 1.183, 1.144, 1.109, 1.073, 1.028, 0.981, 0.938, 0.879, 0.817, 0.752, 0.678, 0.606, 0.531, 0.465, 0.428, 0.443, 0.504, 0.553, 0.579, 0.766}; + double CpHT_Zee_EndcapA_TW[44] = { 1.236, 1.260, 1.291, 1.292, 1.304, 1.325, 1.354, 1.363, 1.387, 1.394, 1.409, 1.415, 1.407, 1.414, 1.405, 1.394, 1.385, 1.357, 1.345, 1.331, 1.309, 1.282, 1.252, 1.226, 1.197, 1.176, 1.135, 1.097, 1.047, 1.013, 0.946, 0.892, 0.834, 0.756, 0.696, 0.610, 0.547, 0.480, 0.444, 0.445, 0.469, 0.513, 0.584, 0.892}; + double CpHT_Zee_EndcapB_TW[44] = { 1.186, 1.202, 1.219, 1.246, 1.257, 1.270, 1.291, 1.297, 1.307, 1.319, 1.333, 1.338, 1.340, 1.326, 1.314, 1.327, 1.321, 1.310, 1.289, 1.279, 1.266, 1.240, 1.222, 1.194, 1.168, 1.153, 1.125, 1.091, 1.033, 1.009, 0.963, 0.917, 0.846, 0.802, 0.746, 0.690, 0.615, 0.560, 0.514, 0.485, 0.478, 0.473, 0.523, 0.726}; + + + // --------------------------------------- + // Non-Electrons (here muons): + // --------------------------------------- + + // Straw Layer (SL): + double CpHT_Zmm_Barrel_SL[N_SL_B] = { 1.100, 1.186, 1.209, 1.241, 1.199, 1.174, 1.209, 1.178, 1.150, 1.053, 1.033, 1.054, 1.033, 1.029, 1.041, 1.021, 1.027, 0.992, 0.988, 0.983, 0.998, 1.022, 1.043, 1.023, 1.027, 1.016, 1.034, 1.009, 1.014, 1.022, 1.001, 1.024, 1.003, 1.010, 1.004, 0.983, 0.992, 0.978, 0.981, 1.000, 0.984, 0.974, 0.953, 0.941, 0.982, 0.990, 1.005, 0.993, 0.966, 0.997, 1.000, 0.988, 0.992, 0.969, 1.003, 0.964, 0.989, 0.961, 0.956, 0.971, 0.948, 0.963, 0.951, 0.943, 0.964, 0.965, 0.925, 0.919, 0.918, 0.928, 0.919, 0.912, 0.906}; + double CpHT_Zmm_EndcapA_SL[N_SL_EA] = { 0.883, 0.898, 0.923, 0.899, 0.892, 0.909, 0.893, 0.925, 0.964, 0.964, 0.979, 0.949, 0.944, 0.998, 0.940, 0.937, 0.950, 0.976, 0.972, 0.950, 0.998, 1.005, 1.007, 1.028, 1.018, 0.995, 1.006, 0.998, 1.031, 1.047, 1.031, 1.015, 1.017, 0.983, 1.018, 1.018, 1.025, 1.033, 1.046, 1.069, 1.033, 1.027, 1.006, 0.982, 1.066, 1.080, 1.048, 1.058, 0.955, 0.971, 0.973, 0.992, 1.013, 1.046, 1.022, 1.029, 1.040, 1.016, 1.077, 1.024, 1.011, 1.095, 1.019, 1.045, 1.001, 1.057, 1.043, 1.022, 1.033, 1.108, 1.062, 1.110, 1.090, 1.058, 1.060, 1.099, 1.065, 1.120, 1.077, 1.060, 1.024, 1.006, 1.022, 1.007, 1.051, 1.118, 1.079, 1.118, 1.070, 1.064, 1.108, 1.127, 1.039, 1.107, 1.088, 1.154}; + double CpHT_Zmm_EndcapB_SL[N_SL_EB] = { 0.828, 0.961, 0.941, 0.991, 0.986, 1.015, 0.993, 0.957, 0.892, 1.005, 1.100, 1.054, 0.995, 1.042, 1.022, 1.007, 0.918, 1.019, 1.056, 1.034, 0.978, 0.981, 1.014, 1.026, 0.988, 0.978, 1.062, 1.085, 1.029, 0.989, 1.067, 1.054, 0.978, 0.971, 1.051, 1.114, 1.152, 1.172, 1.034, 1.170, 1.055, 0.990, 1.112, 1.047, 1.068, 1.013, 1.089, 1.141, 0.903, 0.960, 1.138, 1.218, 0.991, 1.087, 0.997, 1.028, 1.042, 1.155, 1.060, 1.130, 1.077, 1.186, 1.006, 1.054}; + + // ZR-position (ZR - Z in Barrel, R in Endcaps): + double CpHT_Zmm_Barrel_ZR[N_ZR_B] = { 0.846, 0.874, 0.880, 0.882, 0.876, 0.887, 0.901, 0.894, 0.894, 0.903, 0.902, 0.907, 0.918, 0.934, 0.941, 0.948, 0.963, 0.969, 0.990, 0.991, 1.012, 1.019, 1.029, 1.033, 1.072, 1.088, 1.111, 1.144, 1.164, 1.192, 1.225, 1.242, 1.271, 1.314, 1.309, 1.078}; + double CpHT_Zmm_EndcapA_ZR[N_ZR_EA] = { 0.613, 0.757, 0.783, 0.849, 0.866, 0.886, 0.915, 0.939, 0.930, 0.976, 0.969, 0.984, 0.992, 0.979, 1.006, 1.000, 1.005, 1.022, 1.020, 1.030, 1.031, 1.036, 1.053, 1.050, 1.050, 1.048, 1.065, 1.071, 1.060, 1.077, 1.067, 1.072, 1.070, 1.067, 1.090, 1.059, 1.032, 1.081, 1.011, 0.984}; + double CpHT_Zmm_EndcapB_ZR[N_ZR_EB] = { 1.000, 1.375, 0.962, 0.702, 0.869, 0.899, 0.953, 0.905, 1.052, 1.025, 1.016, 1.009, 1.033, 0.920, 1.056, 1.031, 1.070, 1.042, 1.052, 1.066, 1.024, 1.023, 1.046, 1.046, 1.007, 1.009, 1.009, 1.024, 1.007, 0.993, 0.968, 0.997, 0.911, 0.922, 0.938, 0.921, 0.883, 0.653, 0.917, 1.000}; + + // Track-to-Wire distance (TWdist): + double CpHT_Zmm_Barrel_TW[N_TW_B] = { 1.124, 1.058, 1.065, 1.079, 1.094, 1.124, 1.141, 1.173, 1.207, 1.226, 1.250, 1.250, 1.258, 1.249, 1.258, 1.243, 1.229, 1.211, 1.206, 1.180, 1.165, 1.138, 1.123, 1.100, 1.074, 1.052, 1.014, 0.981, 0.953, 0.896, 0.866, 0.809, 0.776, 0.736, 0.690, 0.644, 0.609, 0.615, 0.680, 0.854, 1.094, 1.274, 1.208, 1.219}; + double CpHT_Zmm_EndcapA_TW[N_TW_EA] = { 1.210, 1.161, 1.177, 1.201, 1.221, 1.244, 1.279, 1.300, 1.319, 1.341, 1.362, 1.372, 1.376, 1.378, 1.384, 1.361, 1.349, 1.334, 1.325, 1.284, 1.264, 1.250, 1.223, 1.183, 1.121, 1.104, 1.077, 1.016, 0.969, 0.912, 0.863, 0.815, 0.753, 0.662, 0.604, 0.555, 0.513, 0.490, 0.511, 0.627, 0.843, 1.019, 0.932, 0.922}; + double CpHT_Zmm_EndcapB_TW[N_TW_EB] = { 1.132, 1.150, 1.125, 1.174, 1.170, 1.282, 1.165, 1.244, 1.287, 1.293, 1.270, 1.366, 1.317, 1.285, 1.319, 1.291, 1.304, 1.239, 1.256, 1.279, 1.212, 1.221, 1.200, 1.174, 1.143, 1.120, 1.022, 0.983, 0.938, 0.895, 0.906, 0.826, 0.766, 0.765, 0.664, 0.566, 0.553, 0.556, 0.541, 0.626, 0.780, 0.964, 0.817, 0.542}; + + + // -------------------------------------------------------------- + + +// Same corrections for all gases: + + for (int j = 0 ; j < N_GAS; j++){ + m_CpHT_B_Zee_SL_new [j][0].update ( N_SL_B ,-0.5 ,72.5 , std::vector<float> (CpHT_Zee_Barrel_SL , CpHT_Zee_Barrel_SL + sizeof CpHT_Zee_Barrel_SL / sizeof CpHT_Zee_Barrel_SL[0]) ); + m_CpHT_B_Zee_SL_new [j][1].update ( N_SL_EA ,-0.5 ,95.5 , std::vector<float> (CpHT_Zee_EndcapA_SL, CpHT_Zee_EndcapA_SL + sizeof CpHT_Zee_EndcapA_SL/ sizeof CpHT_Zee_EndcapA_SL[0]) ); + m_CpHT_B_Zee_SL_new [j][2].update ( N_SL_EB ,-0.5 ,63.5 , std::vector<float> (CpHT_Zee_EndcapB_SL, CpHT_Zee_EndcapB_SL + sizeof CpHT_Zee_EndcapB_SL/ sizeof CpHT_Zee_EndcapB_SL[0]) ); + + m_CpHT_B_Zmm_SL_new [j][0].update ( N_SL_B ,-0.5 ,72.5 , std::vector<float> (CpHT_Zmm_Barrel_SL , CpHT_Zmm_Barrel_SL + sizeof CpHT_Zmm_Barrel_SL / sizeof CpHT_Zmm_Barrel_SL[0]) ); + m_CpHT_B_Zmm_SL_new [j][1].update ( N_SL_EA ,-0.5 ,95.5 , std::vector<float> (CpHT_Zmm_EndcapA_SL, CpHT_Zmm_EndcapA_SL + sizeof CpHT_Zmm_EndcapA_SL/ sizeof CpHT_Zmm_EndcapA_SL[0]) ); + m_CpHT_B_Zmm_SL_new [j][2].update ( N_SL_EB ,-0.5 ,63.5 , std::vector<float> (CpHT_Zmm_EndcapB_SL, CpHT_Zmm_EndcapB_SL + sizeof CpHT_Zmm_EndcapB_SL/ sizeof CpHT_Zmm_EndcapB_SL[0]) ); -#endif -#endif + m_CpHT_B_Zee_ZR_new [j][0].update ( N_ZR_B , 0.0 , 720.0 , std::vector<float> (CpHT_Zee_Barrel_ZR , CpHT_Zee_Barrel_ZR + sizeof CpHT_Zee_Barrel_ZR / sizeof CpHT_Zee_Barrel_ZR[0]) ); + m_CpHT_B_Zee_ZR_new [j][1].update ( N_ZR_EA , 630.0, 1030.0 , std::vector<float> (CpHT_Zee_EndcapA_ZR, CpHT_Zee_EndcapA_ZR + sizeof CpHT_Zee_EndcapA_ZR/ sizeof CpHT_Zee_EndcapA_ZR[0]) ); + m_CpHT_B_Zee_ZR_new [j][2].update ( N_ZR_EB , 630.0, 1030.0 , std::vector<float> (CpHT_Zee_EndcapB_ZR, CpHT_Zee_EndcapB_ZR + sizeof CpHT_Zee_EndcapB_ZR/ sizeof CpHT_Zee_EndcapB_ZR[0]) ); + + + m_CpHT_B_Zmm_ZR_new [j][0].update ( N_ZR_B , 0.0 , 720.0 , std::vector<float> (CpHT_Zmm_Barrel_ZR , CpHT_Zmm_Barrel_ZR + sizeof CpHT_Zmm_Barrel_ZR / sizeof CpHT_Zmm_Barrel_ZR[0]) ); + m_CpHT_B_Zmm_ZR_new [j][1].update ( N_ZR_EA , 630.0, 1030.0 , std::vector<float> (CpHT_Zmm_EndcapA_ZR, CpHT_Zmm_EndcapA_ZR + sizeof CpHT_Zmm_EndcapA_ZR/ sizeof CpHT_Zmm_EndcapA_ZR[0]) ); + m_CpHT_B_Zmm_ZR_new [j][2].update ( N_ZR_EB , 630.0, 1030.0 , std::vector<float> (CpHT_Zmm_EndcapB_ZR, CpHT_Zmm_EndcapB_ZR + sizeof CpHT_Zmm_EndcapB_ZR/ sizeof CpHT_Zmm_EndcapB_ZR[0]) ); + + m_CpHT_B_Zee_TW_new [j][0].update ( N_TW_B , 0.0, 2.2, std::vector<float> (CpHT_Zee_Barrel_TW , CpHT_Zee_Barrel_TW + sizeof CpHT_Zee_Barrel_TW / sizeof CpHT_Zee_Barrel_TW[0]) ); + m_CpHT_B_Zee_TW_new [j][1].update ( N_TW_EA , 0.0, 2.2, std::vector<float> (CpHT_Zee_EndcapA_TW, CpHT_Zee_EndcapA_TW + sizeof CpHT_Zee_EndcapA_TW/ sizeof CpHT_Zee_EndcapA_TW[0]) ); + m_CpHT_B_Zee_TW_new [j][2].update ( N_TW_EB , 0.0, 2.2, std::vector<float> (CpHT_Zee_EndcapB_TW, CpHT_Zee_EndcapB_TW + sizeof CpHT_Zee_EndcapB_TW/ sizeof CpHT_Zee_EndcapB_TW[0]) ); + + m_CpHT_B_Zmm_TW_new [j][0].update ( N_TW_B , 0.0, 2.2, std::vector<float> (CpHT_Zmm_Barrel_TW , CpHT_Zmm_Barrel_TW + sizeof CpHT_Zmm_Barrel_TW / sizeof CpHT_Zmm_Barrel_TW[0]) ); + m_CpHT_B_Zmm_TW_new [j][1].update ( N_TW_EA , 0.0, 2.2, std::vector<float> (CpHT_Zmm_EndcapA_TW, CpHT_Zmm_EndcapA_TW + sizeof CpHT_Zmm_EndcapA_TW/ sizeof CpHT_Zmm_EndcapA_TW[0]) ); + m_CpHT_B_Zmm_TW_new [j][2].update ( N_TW_EB , 0.0, 2.2, std::vector<float> (CpHT_Zmm_EndcapB_TW, CpHT_Zmm_EndcapB_TW + sizeof CpHT_Zmm_EndcapB_TW/ sizeof CpHT_Zmm_EndcapB_TW[0]) ); + } + + + m_datainplace = true; + +} diff --git a/InnerDetector/InDetConditions/TRT_ConditionsData/src/StorePIDinfo.cxx b/InnerDetector/InDetConditions/TRT_ConditionsData/src/StorePIDinfo.cxx new file mode 100644 index 0000000000000000000000000000000000000000..27b58316ae542961d05c4eea46deeadda2db452a --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsData/src/StorePIDinfo.cxx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#include <iostream> +#include "AsgTools/MsgStreamMacros.h" +#include "TRT_ConditionsData/StorePIDinfo.h" + +StorePIDinfo::StorePIDinfo(){ + m_nbins = 0; + m_min = -9999.9; + m_max = 10000000*2; + m_values.clear(); +} + +StorePIDinfo::StorePIDinfo(int nbins, float min, float max, std::vector<float> values){ + update (nbins, min, max, values); +} + +StorePIDinfo::~StorePIDinfo(){} + +void StorePIDinfo::update( int nbins, float min, float max, std::vector<float> values){ + m_nbins = nbins ; + m_min = min ; + m_max = max ; + if (values.size()!=m_nbins){ + //ATH_MSG_ERROR(" Different Values of n_bins and vector size!!!") + } + m_values.clear(); + for (unsigned int i = 0; i<values.size(); i++ ){ + m_values.push_back( values.at(i)); + } +} + +// THIS HAS TO BE CALLED in order!!! +void StorePIDinfo::push_back( float value ){ + // Just to read the DB + if (m_nbins==0) { + m_nbins = int(value) ; + m_min = -9999.9 ; + m_max = 10000000*2 ; + m_values.clear() ; + } + else if (m_min < -9999) m_min = value ; + else if (m_max > 10000000) m_max = value ; + else m_values.push_back(value); +} + +StatusCode StorePIDinfo::check( int gas, int detpart) const{ + if ( m_nbins == 0) + { + std::cout << " StorePIDinfo: No bins in the DB!! Gas: " << gas << " detPart: " << detpart << std::endl; + return StatusCode::FAILURE; + } + else if ( m_nbins != m_values.size() ) + { + std::cout << " Different number of PID numbers!!!!! " << gas << " detPart: " << detpart << std::endl; + return StatusCode::FAILURE; + } + else if ( (m_max < m_min) || (m_max == m_min) ) + { + std::cout << " Max is smaller or equal than min!!!" << gas << " detPart: " << detpart << std::endl; + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + + +float StorePIDinfo::GetValue ( float input ) const { + return m_values.at( GetBin( input ) ); +} + +float StorePIDinfo::GetBinValue ( int bin) const { + return m_values.at( bin ); +} + +int StorePIDinfo::GetBin ( float input ) const { + if (input < m_min) return 0; + else if (input >= m_max) return m_nbins-1; + else{ + float dr = (m_max-m_min)/m_nbins; + unsigned int bin = int ( (input - m_min)/dr ) ; + //if (bin >= m_nbins) ATH_MSG_ERROR" Bin number is larger than number of bins!"); + return bin; + } + return 0; +} diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_CalDbTool.h b/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_CalDbTool.h new file mode 100644 index 0000000000000000000000000000000000000000..a77615a98adc07a40ccbac71a221e20acffe63b5 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_CalDbTool.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ITRT_CALDBTOOL_H +#define ITRT_CALDBTOOL_H +/** @file ITRT_CalDbTool.h + * @brief abstract interface to TRT calibration constants + * @author Peter Hansen <phansen@nbi.dk>, Wouter hulsbergen + */ + +#include <string> +#include <iostream> +#include "GaudiKernel/IAlgTool.h" +#include "TRT_ConditionsData/ExpandedIdentifier.h" +#include "TRT_ConditionsData/RtRelationMultChanContainer.h" +#include "TRT_ConditionsData/StrawT0MultChanContainer.h" + + +class Identifier; +namespace TRTCond { + class RtRelation; +} + +/** @class ITRT_CalDbTool + * abstract interface to TRT calibration constants + */ +class ITRT_CalDbTool: virtual public IAlgTool +{ + public: + typedef TRTCond::RtRelationMultChanContainer RtRelationContainer ; + typedef TRTCond::StrawT0MultChanContainer StrawT0Container ; + + DeclareInterfaceID(ITRT_CalDbTool, 1, 0); + + virtual float getT0( const Identifier& , int level = TRTCond::ExpandedIdentifier::STRAW ) const = 0; + virtual const TRTCond::RtRelation* getRtRelation( const Identifier& , int level = TRTCond::ExpandedIdentifier::STRAW ) const = 0; + virtual const TRTCond::RtRelation* getErrors( const Identifier& , int level = TRTCond::ExpandedIdentifier::STRAW ) const = 0; + virtual const TRTCond::RtRelation* getSlopes( const Identifier& , int level = TRTCond::ExpandedIdentifier::STRAW ) const = 0; + virtual double driftRadius(const double&, float&, const Identifier&, bool&) const = 0; + virtual double driftError(const double&, const Identifier&, bool&) const = 0; + virtual double driftSlope(const double&, const Identifier&, bool&) const = 0; + virtual TRTCond::ExpandedIdentifier trtcondid( const Identifier&, int level = TRTCond::ExpandedIdentifier::STRAW ) const =0; + virtual const RtRelationContainer* getRtContainer() const = 0; + virtual const RtRelationContainer* getErrContainer() const = 0; + virtual const RtRelationContainer* getSlopeContainer() const = 0; + virtual const StrawT0Container* getT0Container() const = 0 ; + +}; + +#endif // ITRT_CALDBTOOL_H diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h b/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h new file mode 100755 index 0000000000000000000000000000000000000000..f7bb71f6ff3567ea8aa135668f09afe6e9a663b6 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ITRT_STRAWSTATUSSUMMARYTOOL_H +#define ITRT_STRAWSTATUSSUMMARYTOOL_H +/** @file ITRT_StrawStatusSummaryTool.h + * @brief abstract interface to TRT straw status constants + * @author Peter Hansen <phansen@nbi.dk> + */ + +#include <string> +#include "GaudiKernel/IAlgTool.h" +#include "TRT_ConditionsData/StrawStatusMultChanContainer.h" +#include "TRT_ConditionsData/TRTStrawStatusData.h" +#include "TRT_ConditionsData/StrawStatusContainer.h" + +class Identifier; +namespace TRTCOND { + class ExpandedIdentifier; +} + +/** @class ITRT_StrawStatusSummaryTool + abstract interface to TRT straw status constants +*/ +class ITRT_StrawStatusSummaryTool: virtual public IAlgTool +{ + public: + + typedef TRTCond::StrawStatusMultChanContainer StrawStatusContainer ; + + DeclareInterfaceID(ITRT_StrawStatusSummaryTool, 1, 0); + + virtual int getStatus(Identifier ) const =0; + virtual int getStatusPermanent(Identifier) const =0; + virtual int getStatusHT(Identifier) const =0; + virtual bool get_status(Identifier) const =0; + virtual bool get_statusHT(Identifier) const =0; + + virtual const StrawStatusContainer* getStrawStatusContainer() const =0; + virtual const StrawStatusContainer* getStrawStatusPermanentContainer() const =0; + virtual const StrawStatusContainer* getStrawStatusHTContainer() const =0; + +}; + +#endif // ITRT_STRAWSTATUSSUMMARYTOOL_H diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.cxx b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7ddea9aa5213bea0d97e73c3b27d9719e46cee2b --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.cxx @@ -0,0 +1,303 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** @file TRT_CalDbTool.cxx + * @brief Tool to manage TRT Conditions data during normal reconstruction + * @author Peter Hansen <phansen@nbi.dk>, Wouter Hulsberger <whulsber@cern.ch> + **/ + +#include "TRT_CalDbTool.h" + +#include <fstream> +#include <iostream> +#include <iomanip> +#include <sstream> + +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/ThreadLocalContext.h" +#include "StoreGate/ReadCondHandle.h" + + +TRT_CalDbTool::TRT_CalDbTool( const std::string& type, const std::string& name, const IInterface* parent) + : base_class(type, name, parent), + m_trtId(0), + m_detstore("DetectorStore",name), + m_mutex{}, + m_Rtcache{}, + m_T0cache{}, + m_Errcache{}, + m_Slopecache{}, + m_isGEANT4(true), + m_par_rtcontainerkey("/TRT/Calib/RT"), + m_par_errcontainerkey("/TRT/Calib/errors2d"), + m_par_slopecontainerkey("/TRT/Calib/slopes"), + m_par_t0containerkey("/TRT/Calib/T0"), + m_rtContainerG4(nullptr), + m_errContainerG4(nullptr), + m_slopeContainerG4(nullptr), + m_t0ContainerG4(nullptr) +{ + declareProperty("DetectorStore",m_detstore); + declareProperty("isGEANT4",m_isGEANT4); +} + + +StatusCode TRT_CalDbTool::initialize() +{ + ATH_MSG_DEBUG( " in initialize " ); + + // Get StoreGate access to DetectorStore + if (StatusCode::SUCCESS!=m_detstore.retrieve()) { + ATH_MSG_FATAL("Unable to retrieve " << m_detstore.name()); + return StatusCode::FAILURE; + } + + // Get the TRT ID helper + StatusCode sc = m_detstore->retrieve(m_trtId,"TRT_ID"); + if(sc.isFailure()) { + ATH_MSG_FATAL("Problem retrieving TRTID helper"); + return StatusCode::FAILURE; + } + + // Read keys + + ATH_CHECK( m_rtReadKey.initialize() ); + ATH_CHECK( m_errReadKey.initialize() ); + ATH_CHECK( m_slopeReadKey.initialize() ); + ATH_CHECK( m_t0ReadKey.initialize() ); + + if(m_isGEANT4) { + // processing GEANT4 simulation - revert to old non-MT style cond access + + ATH_MSG_INFO("TRT_CalDbTool::initialize for simulation"); + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_rtContainerG4,m_par_rtcontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_rtcontainerkey); + return StatusCode::FAILURE; + } + + + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_errContainerG4,m_par_errcontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_errcontainerkey); + return StatusCode::FAILURE; + } + + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_slopeContainerG4,m_par_slopecontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_slopecontainerkey); + return StatusCode::FAILURE; + } + + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_t0ContainerG4,m_par_t0containerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_t0containerkey); + return StatusCode::FAILURE; + } + + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_slopeContainerG4,m_par_slopecontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_slopecontainerkey); + return StatusCode::FAILURE; + } + + + if(StatusCode::SUCCESS!=m_detstore->retrieve(m_errContainerG4,m_par_errcontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_errcontainerkey); + return StatusCode::FAILURE; + } + + + } else { + + ATH_MSG_INFO(" TRT_CalDbTool::initialize for data "); + } + return StatusCode::SUCCESS; +} + + + +StatusCode TRT_CalDbTool::finalize() +{ + ATH_MSG_DEBUG("TRT_CalDbTool finalize method called"); + return StatusCode::SUCCESS; +} + + +const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getRtContainer() const { + + if(!m_isGEANT4) { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; + EventContext::ContextID_t slot{ctx.slot()}; + EventContext::ContextEvt_t evt{ctx.evt()}; + if (slot>=m_Rtcache.size()) { // new slot? + std::lock_guard<std::mutex> lock{m_mutex}; + m_Rtcache.resize(slot+1, invalidValue); // Store invalid event id in order to pass the next IF statement. + } + if (m_Rtcache[slot]!=evt) { // not same event as last call + std::lock_guard<std::mutex> lock{m_mutex}; + SG::ReadCondHandle<RtRelationContainer> rtc(m_rtReadKey); // find the right conditions + if (not rtc.isValid()) { + ATH_MSG_ERROR("Failed to retrieve " << m_rtReadKey.key()); + } + m_condRt.set(*rtc); // cache the pointer + m_Rtcache[slot] = evt; // store cached event id + } + return m_condRt.get(); + } else { + return m_rtContainerG4; + } +} + +const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getErrContainer() const { + + + if(!m_isGEANT4) { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; + EventContext::ContextID_t slot{ctx.slot()}; + EventContext::ContextEvt_t evt{ctx.evt()}; + if (slot>=m_Errcache.size()) { // new slot? + std::lock_guard<std::mutex> lock{m_mutex}; + m_Errcache.resize(slot+1, invalidValue); // Store invalid event id in order to pass the next IF statement. + } + if (m_Errcache[slot]!=evt) { // not same event as last call + std::lock_guard<std::mutex> lock{m_mutex}; + SG::ReadCondHandle<RtRelationContainer> rtc(m_errReadKey); // find the right conditions + if (not rtc.isValid()) { + ATH_MSG_ERROR("Failed to retrieve " << m_errReadKey.key()); + } + m_condErr.set(*rtc); // cache the pointer + m_Errcache[slot] = evt; // store cached event id + } + return m_condErr.get(); + } else { + + return m_errContainerG4; + } +} + +const TRT_CalDbTool::RtRelationContainer* TRT_CalDbTool::getSlopeContainer() const { + + if(!m_isGEANT4) { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; + EventContext::ContextID_t slot{ctx.slot()}; + EventContext::ContextEvt_t evt{ctx.evt()}; + if (slot>=m_Slopecache.size()) { // new slot? + std::lock_guard<std::mutex> lock{m_mutex}; + m_Slopecache.resize(slot+1, invalidValue); // Store invalid event id in order to pass the next IF statement. + } + if (m_Slopecache[slot]!=evt) { // not same event as last call + std::lock_guard<std::mutex> lock{m_mutex}; + SG::ReadCondHandle<RtRelationContainer> rtc(m_slopeReadKey); // find the right conditions + if (not rtc.isValid()) { + ATH_MSG_ERROR("Failed to retrieve " << m_slopeReadKey.key()); + } + m_condSlope.set(*rtc); // cache the pointer + m_Slopecache[slot] = evt; // store cached event id + } + return m_condSlope.get(); + } else { + + return m_slopeContainerG4; + } + +} + +const TRT_CalDbTool::StrawT0Container* TRT_CalDbTool::getT0Container() const { + + if(!m_isGEANT4) { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; + EventContext::ContextID_t slot{ctx.slot()}; + EventContext::ContextEvt_t evt{ctx.evt()}; + if (slot>=m_T0cache.size()) { // new slot? + std::lock_guard<std::mutex> lock{m_mutex}; + m_T0cache.resize(slot+1, invalidValue); // Store invalid event id in order to pass the next IF statement. + } + if (m_T0cache[slot]!=evt) { // not same event as last call + std::lock_guard<std::mutex> lock{m_mutex}; + SG::ReadCondHandle<StrawT0Container> rtc(m_t0ReadKey); // find the right conditions + if (not rtc.isValid()) { + ATH_MSG_ERROR("Failed to retrieve " << m_t0ReadKey.key()); + } + m_condT0.set(*rtc); // cache the pointer + m_T0cache[slot] = evt; // store cached event id + } + return m_condT0.get(); + } else { + return m_t0ContainerG4; + } + +} + + + +double TRT_CalDbTool::driftRadius(const double& time, float& t0, const Identifier& ident,bool& found) const +{ + // Returns a drift radius, a t0 and a success indicator, + // given an identifier and a time given by (leading_edge_bin+0.5)*3.125ns + found=true; + t0 = this->getT0(ident); + const TRTCond::RtRelation* rtr = getRtRelation(ident) ; + double radius = 0; + if (rtr != 0) + radius = rtr->radius( time - t0 ); + else + ATH_MSG_FATAL(" cannot find an rt-relation for TRT layer_or_wheel " << m_trtId->layer_or_wheel(ident) << " Please check IOV ranges "); + + ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " radius " << radius); + // + if( radius<0 ) radius=0 ; + else if( radius>2.) radius=2.; + + // add protection for the turnover: + if (time - t0 > 55){ + ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " > 55, check Rt derivative"); + // Check Second Derivative. + if (rtr != 0){ + if (rtr->drdt( time - t0 ) < 0 ){ + ATH_MSG_VERBOSE(" time " << time << " t0 " << t0 << " t " << time-t0 << " and rt derivative: " << rtr->drdt( time - t0 )); + radius=2.; + } + } + } + return radius; +} + +double TRT_CalDbTool::driftError( const double& time, const Identifier& ident,bool& found) const +{ + // Returns an error on drift radius and a success indicator, + // given an identifier and a drift-time in ns + found=true; + const TRTCond::RtRelation* rtr = getErrors(ident) ; + double error=0.; + if(rtr) { + error = rtr->radius( time ); + } else { + found=false; + return 0; + } + ATH_MSG_VERBOSE(" time " << time << " error on radius " << error); + return error; +} + +double TRT_CalDbTool::driftSlope( const double& time, const Identifier& ident,bool& found) const +{ + // Returns an error on drift radius and a success indicator, + // given an identifier and a drift-time in ns + found=true; + const TRTCond::RtRelation* rtr = getSlopes(ident) ; + double slope=0.; + if(rtr) { + slope = rtr->radius( time ); + } else { + found=false; + return 0; + } + ATH_MSG_VERBOSE(" time " << time << " slope on radius " << slope); + return slope; +} + + + + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.h b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.h new file mode 100644 index 0000000000000000000000000000000000000000..a4f2b273ed79f3431fcc06dc610caa0bb20768f7 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_CalDbTool.h @@ -0,0 +1,172 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_CALDBTOOL_H +#define TRT_CALDBTOOL_H +/** @file TRT_CalDbTool.h + * @brief interface to TRT calibration constants + * @author Peter Hansen <phansen@nbi.dk> + */ + +#include "TRT_ConditionsServices/ITRT_CalDbTool.h" +// STL +#include <mutex> +//Gaudi includes +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/EventContext.h" +#include "GaudiKernel/ContextSpecificPtr.h" +#include "GaudiKernel/ICondSvc.h" +#include "GaudiKernel/ServiceHandle.h" +// Storegate +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/DataHandle.h" +#include "StoreGate/StoreGateSvc.h" +//Athena +#include "AthenaBaseComps/AthAlgTool.h" +// TRT +#include "InDetIdentifier/TRT_ID.h" + + + +/** @class TRT_CalDbTool + * interface to TRT calibration constants + */ +class TRT_CalDbTool: public extends<AthAlgTool, ITRT_CalDbTool> +{ + public: + /// typedefs, enums etc + + + /// constructor + TRT_CalDbTool( const std::string& type, const std::string& name, const IInterface* parent); + + /// destructor + virtual ~TRT_CalDbTool() = default; + + /// tool initialize + virtual StatusCode initialize() override; + + /// tool finalize + virtual StatusCode finalize() override; + + + // methods to access calibration data + + /// get T0 for an identifier + float getT0( const Identifier& id, int level = TRTCond::ExpandedIdentifier::STRAW ) const; + + /// get an rtrelation for an identifier + const TRTCond::RtRelation* getRtRelation( const Identifier& id, int level = TRTCond::ExpandedIdentifier::STRAW ) const; + + /// get errors for an identifier + const TRTCond::RtRelation* getErrors( const Identifier& id, int level = TRTCond::ExpandedIdentifier::STRAW ) const; + + /// get errors for an identifier + const TRTCond::RtRelation* getSlopes( const Identifier& id, int level = TRTCond::ExpandedIdentifier::STRAW ) const; + + /// get a drift radius for a given leading edge time + virtual double driftRadius(const double& time, float& t0, const Identifier& ident, bool& found) const override; + + /// get a drift radius error for a given drifttime + virtual double driftError(const double& time, const Identifier& ident, bool& found) const override; + + /// get a drift radius error for a given drifttime + virtual double driftSlope(const double& time, const Identifier& ident, bool& found) const override; + + /// create an TRTCond::ExpandedIdentifier from a TRTID identifier + TRTCond::ExpandedIdentifier trtcondid( const Identifier& id, int level = TRTCond::ExpandedIdentifier::STRAW) const; + + + + /// access to calibration constant containers + virtual const RtRelationContainer* getRtContainer() const override; + virtual const RtRelationContainer* getErrContainer() const override; + virtual const RtRelationContainer* getSlopeContainer() const override; + virtual const StrawT0Container* getT0Container() const override; + + private: + const TRT_ID* m_trtId; //!< id helper + ServiceHandle<StoreGateSvc> m_detstore; + + /// mutex to protect cache updates + mutable std::mutex m_mutex; + /// Cache to store events for slots + mutable std::vector<EventContext::ContextEvt_t> m_Rtcache; + mutable std::vector<EventContext::ContextEvt_t> m_T0cache; + mutable std::vector<EventContext::ContextEvt_t> m_Errcache; + mutable std::vector<EventContext::ContextEvt_t> m_Slopecache; + /// Pointers to conditions data + mutable Gaudi::Hive::ContextSpecificPtr<const RtRelationContainer> m_condRt; + mutable Gaudi::Hive::ContextSpecificPtr<const StrawT0Container> m_condT0; + mutable Gaudi::Hive::ContextSpecificPtr<const RtRelationContainer> m_condErr; + mutable Gaudi::Hive::ContextSpecificPtr<const RtRelationContainer> m_condSlope; + + /// ReadHandle keys + SG::ReadCondHandleKey<RtRelationContainer> m_rtReadKey{this,"RtReadKeyName","/TRT/Calib/RT","r-t relation in-key"}; + SG::ReadCondHandleKey<RtRelationContainer> m_errReadKey{this,"ErrorReadKeyName","/TRT/Calib/errors2d","error on r in-key"}; + SG::ReadCondHandleKey<RtRelationContainer> m_slopeReadKey{this,"SlopeReadKeyName","/TRT/Calib/slopes","slope of error in-key"}; + SG::ReadCondHandleKey<StrawT0Container> m_t0ReadKey{this,"T0ReadKeyName","/TRT/Calib/T0","t0 in-key"}; + + /// Used in simulation jobs + bool m_isGEANT4; + + std::string m_par_rtcontainerkey; + std::string m_par_errcontainerkey; + std::string m_par_slopecontainerkey; + std::string m_par_t0containerkey; + + const DataHandle<RtRelationContainer> m_rtContainerG4; + const DataHandle<RtRelationContainer> m_errContainerG4; + const DataHandle<RtRelationContainer> m_slopeContainerG4; + const DataHandle<StrawT0Container> m_t0ContainerG4; + +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// inline methods +//////////////////////////////////////////////////////////////////////////////////////////// + +inline TRTCond::ExpandedIdentifier +TRT_CalDbTool::trtcondid( const Identifier& id, int level) const +{ + return TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(id),m_trtId->layer_or_wheel(id), + m_trtId->phi_module(id),m_trtId->straw_layer(id), + m_trtId->straw(id),level ) ; +} + +inline const TRTCond::RtRelation* +TRT_CalDbTool::getRtRelation( const Identifier& id, int level ) const +{ + const RtRelationContainer* rc = getRtContainer(); + if(!rc) return 0; + return rc->get(trtcondid(id,level)) ; +} + +inline const TRTCond::RtRelation* +TRT_CalDbTool::getErrors( const Identifier& id, int level ) const +{ + const RtRelationContainer* rc = getErrContainer(); + if(!rc) return 0; + return rc->get(trtcondid(id,level)) ; +} + +inline const TRTCond::RtRelation* +TRT_CalDbTool::getSlopes( const Identifier& id, int level ) const +{ + const RtRelationContainer* rc = getSlopeContainer(); + if(!rc) return 0; + return rc->get(trtcondid(id,level)) ; +} + +inline float +TRT_CalDbTool::getT0( const Identifier& id, int level ) const +{ + const StrawT0Container* rc = getT0Container(); + return rc->getT0(trtcondid(id,level)) ; +} + + + +#endif // TRT_CALDBTOOL_H diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_HWMappingSvc.cxx b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_HWMappingSvc.cxx index 6d97ce22ff00aa93be1a078294b6fc639a7ca370..29d85fd4945bffefe7f9553d206b7550fe2b9b17 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_HWMappingSvc.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_HWMappingSvc.cxx @@ -64,14 +64,14 @@ TRT_HWMappingSvc::~TRT_HWMappingSvc() {} /// Initialize ///// StatusCode TRT_HWMappingSvc::initialize() { - msg(MSG::INFO) << "TRT_HWMappingSvc::initialize." << endmsg; + ATH_MSG_INFO("TRT_HWMappingSvc::initialize."); StatusCode sc(StatusCode::SUCCESS); // Retrieve the DetectorStore sc = m_detStore.retrieve(); if ( sc.isFailure() ) { - msg(MSG::ERROR) << "Unable to retrieve " << m_detStore << endmsg; + ATH_MSG_ERROR("Unable to retrieve " << m_detStore); return sc; } @@ -85,7 +85,7 @@ StatusCode TRT_HWMappingSvc::initialize() { // Get the TRTStrawNeighbourSvc sc = m_TRTStrawNeighbourSvc.retrieve(); if ( sc.isFailure() ) { - msg(MSG::ERROR) << "Couldn't get " << m_TRTStrawNeighbourSvc << endmsg; + ATH_MSG_ERROR("Couldn't get " << m_TRTStrawNeighbourSvc); return sc; } @@ -93,7 +93,7 @@ StatusCode TRT_HWMappingSvc::initialize() { IIncidentSvc* incSvc; sc = service( "IncidentSvc", incSvc ); if ( sc.isFailure() ) { - msg(MSG::ERROR) << "Couldn't get the IncidentSvc." << endmsg; + ATH_MSG_ERROR("Couldn't get the IncidentSvc."); return sc; } incSvc->addListener( this, std::string("BeginRun") ); @@ -131,7 +131,7 @@ std::string TRT_HWMappingSvc::get_HV_CoolChanName( const Identifier ident ) { int hashedPad = hashThisBarrelPad( phi_module, layer_or_wheel, padNum ); if ( m_Barrel_HV_CoolChanNames ) { if ( hashedPad >= (int)m_Barrel_HV_CoolChanNames->size() || hashedPad<0) { - msg(MSG::WARNING) << "channel request for invalid barrel HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid barrel HV pad."); return ""; } else chanName = m_Barrel_HV_CoolChanNames->at(hashedPad); } @@ -142,7 +142,7 @@ std::string TRT_HWMappingSvc::get_HV_CoolChanName( const Identifier ident ) { int hashedCell = hashThisEndcapCell( phi_module, layer_or_wheel, fourPlaneNum, cellNum ); if ( m_EndcapA_HV_CoolChanNames ) { if ( hashedCell >= (int)m_EndcapA_HV_CoolChanNames->size() || hashedCell<0 ) { - msg(MSG::WARNING) << "channel request for invalid endcap A HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid endcap A HV pad."); return ""; } else chanName = m_EndcapA_HV_CoolChanNames->at(hashedCell); } @@ -153,12 +153,12 @@ std::string TRT_HWMappingSvc::get_HV_CoolChanName( const Identifier ident ) { int hashedCell = hashThisEndcapCell( phi_module, layer_or_wheel, fourPlaneNum, cellNum ); if ( m_EndcapC_HV_CoolChanNames ) { if ( hashedCell >= (int)m_EndcapC_HV_CoolChanNames->size() || hashedCell<0) { - msg(MSG::WARNING) << "channel request for invalid endcap C HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid endcap C HV pad."); return ""; } else chanName = m_EndcapC_HV_CoolChanNames->at(hashedCell); } } else { - msg(MSG::ERROR) << "Unknown Identifier (not barrel or endcap)!" << endmsg; + ATH_MSG_ERROR("Unknown Identifier (not barrel or endcap)!"); return ""; } @@ -185,7 +185,7 @@ int TRT_HWMappingSvc::get_HV_CoolChanNum( const Identifier ident ) { int hashedPad = hashThisBarrelPad( phi_module, layer_or_wheel, padNum ); if ( m_Barrel_HV_CoolChanNums ) { if ( hashedPad >= (int)m_Barrel_HV_CoolChanNums->size() || hashedPad<0 ) { - msg(MSG::WARNING) << "channel number request for invalid barrel HV pad." << endmsg; + ATH_MSG_WARNING("channel number request for invalid barrel HV pad."); return -1; } else chanNum = m_Barrel_HV_CoolChanNums->at(hashedPad); } @@ -196,7 +196,7 @@ int TRT_HWMappingSvc::get_HV_CoolChanNum( const Identifier ident ) { int hashedCell = hashThisEndcapCell( phi_module, layer_or_wheel, fourPlaneNum, cellNum ); if ( m_EndcapA_HV_CoolChanNums ) { if ( hashedCell >= (int)m_EndcapA_HV_CoolChanNums->size() || hashedCell<0) { - msg(MSG::WARNING) << "channel number request for invalid endcap A HV cell." << endmsg; + ATH_MSG_WARNING("channel number request for invalid endcap A HV cell."); return -1; } else chanNum = m_EndcapA_HV_CoolChanNums->at(hashedCell); } @@ -207,12 +207,12 @@ int TRT_HWMappingSvc::get_HV_CoolChanNum( const Identifier ident ) { int hashedCell = hashThisEndcapCell( phi_module, layer_or_wheel, fourPlaneNum, cellNum ); if ( m_EndcapC_HV_CoolChanNums ) { if ( hashedCell >= (int)m_EndcapC_HV_CoolChanNums->size() || hashedCell<0) { - msg(MSG::WARNING) << "channel number request for invalid endcap C HV cell." << endmsg; + ATH_MSG_WARNING("channel number request for invalid endcap C HV cell."); return -1; } else chanNum = m_EndcapC_HV_CoolChanNums->at(hashedCell); } } else { - msg(MSG::ERROR) << "Unknown Identifier (not barrel or endcap)!" << endmsg; + ATH_MSG_ERROR("Unknown Identifier (not barrel or endcap)!"); return -1; } @@ -253,8 +253,7 @@ int TRT_HWMappingSvc::hashThisBarrelPad( int sector, int module, int padNum ) { case 1: padOffset = 42; break; case 2: padOffset = 42+65; break; default: - msg(MSG::ERROR) << "Couldn't hash this pad: " - << sector << "," << module << "," << padNum << endmsg; + ATH_MSG_ERROR("Couldn't hash this pad: " << sector << "," << module << "," << padNum); return -1; } @@ -289,7 +288,7 @@ int TRT_HWMappingSvc::get_HV_EndcapCellNum( const Identifier ident ) { else if ( straw >= 8 && straw < 16 ) cellNum = 1; else if ( straw >=16 && straw < 24 ) cellNum = 2; else { - msg(MSG::WARNING) << "Straw number out of range for Endcap!" << endmsg; + ATH_MSG_WARNING("Straw number out of range for Endcap!"); cellNum = -1; } @@ -322,7 +321,7 @@ int TRT_HWMappingSvc::get_HV_Endcap4PlaneNum( const Identifier ident ) { else if ( straw_layer >= 8 && straw_layer < 12 ) fourPlaneWheelNum = 2; else if ( straw_layer >= 12 && straw_layer < 16 ) fourPlaneWheelNum = 3; else { - msg(MSG::WARNING) << "Straw layer number out of range for Endcap!" << endmsg; + ATH_MSG_WARNING("Straw layer number out of range for Endcap!"); fourPlaneWheelNum = -1; } @@ -382,7 +381,7 @@ int TRT_HWMappingSvc::hashThisEndcapCell( int sector, int wheel, int layer, int if ( wheel >= 0 && wheel < 6 ) wheelType = 0; // A wheel if ( wheel >= 6 && wheel < 14 ) wheelType = 1; // B wheel if ( wheelType == -1 ) { - msg(MSG::ERROR) << "Invalid wheel number." << endmsg; + ATH_MSG_ERROR("Invalid wheel number."); return -1; } @@ -414,7 +413,7 @@ StatusCode TRT_HWMappingSvc::build_BarrelHVLinePadMap() { std::map<std::string,std::string> rawMap; TRTcoralClient->get_BarrelHVLinePadMap( rawMap ); if ( rawMap.size() == 0 ) { - msg(MSG::WARNING) << "Retrieved and empty Barrel HV-line/pad map from database." << endmsg; + ATH_MSG_WARNING("Retrieved and empty Barrel HV-line/pad map from database."); delete TRTcoralClient; return StatusCode::FAILURE; } @@ -456,7 +455,7 @@ StatusCode TRT_HWMappingSvc::build_BarrelHVLinePadMap() { // Add this channel into the map vector at the appropriate position // (hashed pad gives index in map vector) if ( hashedPad >= (int)m_Barrel_HV_CoolChanNames->size() || hashedPad<0) { - msg(MSG::WARNING) << "channel request for invalid barrel HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid barrel HV pad."); }else{ m_Barrel_HV_CoolChanNames->at(hashedPad) = chanName; } @@ -622,7 +621,7 @@ StatusCode TRT_HWMappingSvc::build_BarrelHVLinePadMap() { for ( padItr = padVec->begin(); padItr != padVec->end(); ++padItr ) { int hashedPad = hashThisBarrelPad( sector, module, *padItr ); if ( hashedPad >= (int)m_Barrel_HV_CoolChanNames->size() || hashedPad<0) { - msg(MSG::WARNING) << "channel request for invalid barrel HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid barrel HV pad."); }else{ m_Barrel_HV_CoolChanNames->at(hashedPad) = chanName.str(); } @@ -631,21 +630,21 @@ StatusCode TRT_HWMappingSvc::build_BarrelHVLinePadMap() { } } - msg(MSG::INFO) << "TRT Barrel HV-line/pad map successfully built - " - << m_Barrel_HV_CoolChanNames->size() << " channels." << endmsg; + ATH_MSG_INFO("TRT Barrel HV-line/pad map successfully built - " + << m_Barrel_HV_CoolChanNames->size() << " channels."); if ( m_buildChanNumMaps ) { // Get the CondAttrListCollection for the barrel const CondAttrListCollection* DCScondFolder = 0; sc = m_detStore->retrieve( DCScondFolder, m_Barrel_HV_COOLFolderName ); if ( sc.isFailure() ) { - msg(MSG::WARNING) << "Couldn't retrieve folder " << m_Barrel_HV_COOLFolderName - << " from DetectorStore. Has it been loaded into IOVDbSvc?" << endmsg; + ATH_MSG_WARNING("Couldn't retrieve folder " << m_Barrel_HV_COOLFolderName + << " from DetectorStore. Has it been loaded into IOVDbSvc?"); return sc; } if ( DCScondFolder->name_size() == 0 ) { - msg(MSG::WARNING) << "CondAttrListCollection for folder " << m_Barrel_HV_COOLFolderName - << " has no channel names." << endmsg; + ATH_MSG_WARNING("CondAttrListCollection for folder " << m_Barrel_HV_COOLFolderName + << " has no channel names."); return StatusCode::FAILURE; } // Loop through the channel names. @@ -695,7 +694,7 @@ StatusCode TRT_HWMappingSvc::build_EndcapHVLinePadMaps() { } lineName << "S" << sectorLeft << "S" << sectorRight << "_"; if ( sectorLeft%2 == 0 ) { - msg(MSG::WARNING) << "Mistake in sector pairing!!!" << endmsg; + ATH_MSG_WARNING("Mistake in sector pairing!!!"); break; } // Wheel @@ -721,7 +720,7 @@ StatusCode TRT_HWMappingSvc::build_EndcapHVLinePadMaps() { for ( int cellNum = 0; cellNum < 3; ++cellNum ) { int hashedCell = hashThisEndcapCell( sector, wheel, layer, cellNum ); if ( hashedCell >= (int)m_EndcapA_HV_CoolChanNames->size() || hashedCell<0) { - msg(MSG::WARNING) << "channel request for invalid endcap HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid endcap HV pad."); }else{ m_EndcapA_HV_CoolChanNames->at(hashedCell) = lineNameA.str(); m_EndcapC_HV_CoolChanNames->at(hashedCell) = lineNameC.str(); @@ -734,13 +733,13 @@ StatusCode TRT_HWMappingSvc::build_EndcapHVLinePadMaps() { // Apply corrections to the map int hashedCellToFix = hashThisEndcapCell( 5, 12, 0, 2 ); if ( hashedCellToFix >= (int)m_EndcapA_HV_CoolChanNames->size() || hashedCellToFix<0) { - msg(MSG::WARNING) << "channel request for invalid endcap HV pad." << endmsg; + ATH_MSG_WARNING("channel request for invalid endcap HV pad."); }else{ - m_EndcapA_HV_CoolChanNames->at(hashedCellToFix) = "HVA_S7S8_WB7_B_OutputVoltage"; + m_EndcapA_HV_CoolChanNames->at(hashedCellToFix) = "HVA_S7S8_WB7_B_OutputVoltage"; } - msg(MSG::INFO) << "Endcap HV-line/pad maps successfully built - ECA: " + ATH_MSG_INFO("Endcap HV-line/pad maps successfully built - ECA: " << m_EndcapA_HV_CoolChanNames->size() << " channels; ECC: " - << m_EndcapC_HV_CoolChanNames->size() << " channels." << endmsg; + << m_EndcapC_HV_CoolChanNames->size() << " channels."); if ( m_buildChanNumMaps ) { @@ -750,13 +749,13 @@ StatusCode TRT_HWMappingSvc::build_EndcapHVLinePadMaps() { const CondAttrListCollection* DCScondFolder = 0; sc = m_detStore->retrieve( DCScondFolder, m_EndcapA_HV_COOLFolderName ); if ( sc.isFailure() ) { - msg(MSG::WARNING) << "Couldn't retrieve folder " << m_EndcapA_HV_COOLFolderName - << " from DetectorStore. Has it been loaded into IOVDbSvc?" << endmsg; + ATH_MSG_WARNING("Couldn't retrieve folder " << m_EndcapA_HV_COOLFolderName + << " from DetectorStore. Has it been loaded into IOVDbSvc?"); return sc; } if ( DCScondFolder->name_size() == 0 ) { - msg(MSG::WARNING) << "CondAttrListCollection for folder " << m_EndcapA_HV_COOLFolderName - << " has no channel names." << endmsg; + ATH_MSG_WARNING("CondAttrListCollection for folder " << m_EndcapA_HV_COOLFolderName + << " has no channel names."); return StatusCode::FAILURE; } // Loop through the channel names. @@ -777,13 +776,13 @@ StatusCode TRT_HWMappingSvc::build_EndcapHVLinePadMaps() { DCScondFolder = 0; sc = m_detStore->retrieve( DCScondFolder, m_EndcapC_HV_COOLFolderName ); if ( sc.isFailure() ) { - msg(MSG::WARNING) << "Couldn't retrieve folder " << m_EndcapC_HV_COOLFolderName - << " from DetectorStore. Has it been loaded into IOVDbSvc?" << endmsg; + ATH_MSG_WARNING("Couldn't retrieve folder " << m_EndcapC_HV_COOLFolderName + << " from DetectorStore. Has it been loaded into IOVDbSvc?"); return sc; } if ( DCScondFolder->name_size() == 0 ) { - msg(MSG::WARNING) << "CondAttrListCollection for folder " << m_EndcapC_HV_COOLFolderName - << " has no channel names." << endmsg; + ATH_MSG_WARNING("CondAttrListCollection for folder " << m_EndcapC_HV_COOLFolderName + << " has no channel names."); return StatusCode::FAILURE; } // Loop through the channel names. @@ -827,12 +826,12 @@ void TRT_HWMappingSvc::handle( const Incident& inc ) { sc = build_BarrelHVLinePadMap(); if ( sc.isFailure() ) { - msg(MSG::ERROR) << "Error in building Barrel HV-line/pad map." << endmsg; + ATH_MSG_ERROR("Error in building Barrel HV-line/pad map."); } sc = build_EndcapHVLinePadMaps(); if ( sc.isFailure() ) { - msg(MSG::ERROR) << "Error in building Endcap HV-line/pad maps." << endmsg; + ATH_MSG_ERROR("Error in building Endcap HV-line/pad maps."); } if ( m_DumpMaps ) DumpMaps(); @@ -848,39 +847,39 @@ void TRT_HWMappingSvc::handle( const Incident& inc ) { void TRT_HWMappingSvc::DumpMaps() { if ( m_Barrel_HV_CoolChanNames ) { - msg(MSG::INFO) << "Dumping TRT Barrel HV-line/pad map..." << endmsg; + ATH_MSG_INFO( "Dumping TRT Barrel HV-line/pad map..." ); for ( int mapItr = 0; mapItr < (int)m_Barrel_HV_CoolChanNames->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_Barrel_HV_CoolChanNames->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_Barrel_HV_CoolChanNames->at(mapItr) ); } } if ( m_EndcapA_HV_CoolChanNames ) { - msg(MSG::INFO) << "Dumping TRT EndcapA HV-line/pad map..." << endmsg; + ATH_MSG_INFO( "Dumping TRT EndcapA HV-line/pad map..." ); for ( int mapItr = 0; mapItr < (int)m_EndcapA_HV_CoolChanNames->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_EndcapA_HV_CoolChanNames->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_EndcapA_HV_CoolChanNames->at(mapItr) ); } } if ( m_EndcapC_HV_CoolChanNames ) { - msg(MSG::INFO) << "Dumping TRT EndcapC HV-line/pad map..." << endmsg; + ATH_MSG_INFO( "Dumping TRT EndcapC HV-line/pad map..." ); for ( int mapItr = 0; mapItr < (int)m_EndcapC_HV_CoolChanNames->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_EndcapC_HV_CoolChanNames->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_EndcapC_HV_CoolChanNames->at(mapItr) ); } } if ( m_Barrel_HV_CoolChanNums ) { - msg(MSG::INFO) << "Dumping TRT Barrel HV-line/pad COOL channel numbers..." << endmsg; + ATH_MSG_INFO( "Dumping TRT Barrel HV-line/pad COOL channel numbers..." ); for ( int mapItr = 0; mapItr < (int)m_Barrel_HV_CoolChanNums->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_Barrel_HV_CoolChanNums->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_Barrel_HV_CoolChanNums->at(mapItr) ); } } if ( m_EndcapA_HV_CoolChanNums ) { - msg(MSG::INFO) << "Dumping TRT EndcapA HV-line/pad COOL channel numbers..." << endmsg; + ATH_MSG_INFO( "Dumping TRT EndcapA HV-line/pad COOL channel numbers..." ); for ( int mapItr = 0; mapItr < (int)m_EndcapA_HV_CoolChanNums->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_EndcapA_HV_CoolChanNums->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_EndcapA_HV_CoolChanNums->at(mapItr) ); } } if ( m_EndcapC_HV_CoolChanNums ) { - msg(MSG::INFO) << "Dumping TRT EndcapC HV-line/pad COOL channel numbers..." << endmsg; + ATH_MSG_INFO( "Dumping TRT EndcapC HV-line/pad COOL channel numbers..." ); for ( int mapItr = 0; mapItr < (int)m_EndcapC_HV_CoolChanNums->size(); ++mapItr ) { - msg(MSG::INFO) << mapItr << " " << m_EndcapC_HV_CoolChanNums->at(mapItr) << endmsg; + ATH_MSG_INFO( mapItr << " " << m_EndcapC_HV_CoolChanNums->at(mapItr) ); } } diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.cxx b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ae77b2bcbfff5c4f645f0b1e75f78a85841cbeb4 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.cxx @@ -0,0 +1,223 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** @file TRT_StrawStatusSummaryTool.cxx + * @brief AthTool to manage TRT StrawStatus, LT/HT occupancy, PID and track data + * @author Peter Hansen <hansenph@nbi.dk> + **/ + + + +#include <fstream> +#include <iostream> +#include <iomanip> +#include <sstream> +#include <stdio.h> + +#include "GaudiKernel/IToolSvc.h" +#include "Identifier/Identifier.h" + +#include "TRT_ConditionsData/StrawStatusMultChanContainer.h" +#include "TRT_ConditionsData/ExpandedIdentifier.h" +#include "PathResolver/PathResolver.h" + +#include "TRT_StrawStatusSummaryTool.h" +#include "InDetIdentifier/TRT_ID.h" +#include "StoreGate/ReadCondHandle.h" + + + +TRT_StrawStatusSummaryTool::TRT_StrawStatusSummaryTool( const std::string& type, const std::string& name, const IInterface* parent) + : base_class(type, name, parent), + m_detStore("DetectorStore",name), + m_toolsvc("ToolSvc",name), + m_par_strawstatuscontainerkey("/TRT/Cond/Status"), + m_par_strawstatuspermanentcontainerkey("/TRT/Cond/StatusPermanent"), + m_par_strawstatusHTcontainerkey("/TRT/Cond/StatusHT"), + m_trtId(0), + m_condSvc("CondSvc",name), + m_statReadKey("/TRT/Cond/Status"), + m_permReadKey("/TRT/Cond/StatusPermanent"), + m_statHTReadKey("/TRT/Cond/StatusHT"), + m_isGEANT4(true), + m_strawstatusG4(nullptr), + m_strawstatuspermanentG4(nullptr), + m_strawstatusHTG4(nullptr) + +{ + declareProperty("ToolSvc",m_toolsvc); + declareProperty("isGEANT4",m_isGEANT4); + + // initialise event id cache + static const EventContext::ContextEvt_t invalidValue{EventContext::INVALID_CONTEXT_EVT}; + m_evtstat.push_back(invalidValue); + m_evtperm.push_back(invalidValue); + m_evtstatHT.push_back(invalidValue); + + m_strawstatuscontainer.push_back(nullptr); + m_strawstatuspermanentcontainer.push_back(nullptr); + m_strawstatusHTcontainer.push_back(nullptr); + + +} + + +StatusCode TRT_StrawStatusSummaryTool::initialize() +{ + ATH_MSG_INFO("TRT_StrawStatusSummaryTool initialize method called"); + + + // Retrieve the DetectorStore + if (StatusCode::SUCCESS!=m_detStore.retrieve()) { + ATH_MSG_FATAL("Could not retrieve " << m_detStore); + return StatusCode::FAILURE; + } + + // Find ToolService + if (StatusCode::SUCCESS!=m_toolsvc.retrieve()) { + ATH_MSG_FATAL("ToolSvc not found"); + return StatusCode::FAILURE; + } + + // Get the TRT ID helper + if (StatusCode::SUCCESS!=m_detStore->retrieve(m_trtId,"TRT_ID")) { + ATH_MSG_FATAL("Problem retrieving TRTID helper"); + return StatusCode::FAILURE; + } + + // Read keys in case of normal reconstruction/digitization + ATH_CHECK( m_statReadKey.initialize() ); + ATH_CHECK( m_permReadKey.initialize() ); + + if(!m_isGEANT4) { + + ATH_CHECK( m_statHTReadKey.initialize() ); + } + + if(m_isGEANT4) { + // processing GEANT4 simulation - revert to old non-MT style cond access + + if(StatusCode::SUCCESS!=m_detStore->retrieve(m_strawstatusHTG4,m_par_strawstatusHTcontainerkey)) { + ATH_MSG_FATAL("Could not retrieve folder " << m_par_strawstatusHTcontainerkey); + return StatusCode::FAILURE; + } + + } + + ATH_MSG_INFO("TRT_StrawStatusSummaryTool initialized successfully "); + return StatusCode::SUCCESS; +} + +/////////////////////////////////////////////////// + + +StatusCode TRT_StrawStatusSummaryTool::finalize() +{ + msg(MSG::INFO) << " in finalize() " << endmsg; + return StatusCode::SUCCESS; +} + + +int TRT_StrawStatusSummaryTool::getStatus(Identifier offlineID) const{ + int stat = 0; + int level = TRTCond::ExpandedIdentifier::STRAW ; + TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID), + m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID), + m_trtId->straw(offlineID),level ); + const StrawStatusContainer* strawstatuscontainer = getStrawStatusContainer(); + static int countStrawStatusContainerError(0); + if (!strawstatuscontainer) { + if (countStrawStatusContainerError<5) { + ATH_MSG_WARNING(" getStatus, strawstatuscontainer == 0, dead straws not set"); + countStrawStatusContainerError++; + } + return 0; + } + stat=int((*strawstatuscontainer).get(id).getstatus()); + return stat; +} + + + +int TRT_StrawStatusSummaryTool::getStatusPermanent(Identifier offlineID) const{ + int stat = 0; + int level = TRTCond::ExpandedIdentifier::STRAW ; + TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID), + m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID), + m_trtId->straw(offlineID),level ); + const StrawStatusContainer* strawstatuspermanentcontainer = getStrawStatusPermanentContainer(); + static int countStrawStatusContainerError(0); + if (!strawstatuspermanentcontainer) { + if (countStrawStatusContainerError<5) { ATH_MSG_WARNING(" getStatusPermanent, strawstatuspermanentcontainer == 0, dead straws not set"); + countStrawStatusContainerError++; + } + return 0; + } + stat=int((*strawstatuspermanentcontainer).get(id).getstatus()); + return stat; +} + + + +int TRT_StrawStatusSummaryTool::getStatusHT(Identifier offlineID) const{ + int stat = 0; + int level = TRTCond::ExpandedIdentifier::STRAW ; + TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID), + m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID), + m_trtId->straw(offlineID),level ); + const StrawStatusContainer* strawstatusHTcontainer = getStrawStatusHTContainer(); + + static int countStrawStatusContainerError(0); + if (!strawstatusHTcontainer) { + if (countStrawStatusContainerError<5) { + ATH_MSG_WARNING(" getStatusHT, strawstatusHTcontainer == 0, dead straws not set"); + countStrawStatusContainerError++; + } + return 0; + } + stat=int((*strawstatusHTcontainer).get(id).getstatus()); + return stat; +} + + +/////////////////////////////////////////////////// + + +bool TRT_StrawStatusSummaryTool::get_status(Identifier offlineID) const{ + const unsigned int statusbitmask = 1 << 8;// 0000001 00000000 + ATH_MSG_VERBOSE("offlineID "<<offlineID<<" "<<getStatus(offlineID)<<" "<<((getStatus(offlineID) & statusbitmask) >> 8)); + bool st = false, stperm=false; + if (getStatus(offlineID)==1) st = true; + else if (getStatus(offlineID)==0) st = false; + else {st = bool( (getStatus(offlineID) & statusbitmask) >> 8);}; + + + if (getStatusPermanent(offlineID)==1) stperm = true; + else if (getStatusPermanent(offlineID)==0) stperm = false; + else {stperm = bool( (getStatusPermanent(offlineID) & statusbitmask) >> 8);}; + + return ( (st||stperm) ); + +} + + + +bool TRT_StrawStatusSummaryTool::get_statusHT(Identifier offlineID) const{ + const unsigned int statusbitmask = 1 << 8;// 0000001 00000000 + ATH_MSG_VERBOSE("offlineID "<<offlineID<<" "<<getStatus(offlineID)<<" "<<((getStatus(offlineID) & statusbitmask) >> 8)); + bool stHT=false; + + + if (getStatusHT(offlineID)==1) stHT = true; + else if (getStatusHT(offlineID)==0) stHT = false; + else {stHT = bool( (getStatusHT(offlineID) & statusbitmask) >> 8);}; + + return ( stHT ); + +} + + + + + diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.h b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.h new file mode 100644 index 0000000000000000000000000000000000000000..c02352d3eb64eaed4df1d15b28f40d2d325e5398 --- /dev/null +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/TRT_StrawStatusSummaryTool.h @@ -0,0 +1,169 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_STRAWSTATUSSUMMARYTOOL_H +#define TRT_STRAWSTATUSSUMMARYTOOL_H +/** @file TRT_StrawStatusSummaryTool.h + * @brief interface to TRT straw status constants used in normal reconstruction + * @author Peter Hansen <phansen@nbi.dk> + */ +//STL +#include <vector> +//Gaudi +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ContextSpecificPtr.h" +#include "GaudiKernel/ThreadLocalContext.h" +#include "GaudiKernel/ICondSvc.h" +//StoreGate +#include "StoreGate/DataHandle.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/StoreGateSvc.h" +//Athena +#include "AthenaBaseComps/AthAlgTool.h" +//TRT +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" +#include "TRT_ConditionsServices/ITRT_ConditionsSvc.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_BaseElement.h" + + +class TRT_StrawStatusSummaryTool: public extends<AthAlgTool, ITRT_StrawStatusSummaryTool> +{ + public: + + /// constructor + TRT_StrawStatusSummaryTool ( const std::string& type, const std::string& name, const IInterface* parent); + + /// destructor + virtual ~TRT_StrawStatusSummaryTool() = default; + + /// tool initialize + virtual StatusCode initialize() override; + + /// tool finalize + virtual StatusCode finalize() override; + + + /// access to the status + int getStatus(Identifier offlineId) const; + int getStatusPermanent(Identifier offlineId) const; + int getStatusHT(Identifier offlineId) const; + bool get_status(Identifier offlineId) const; + bool get_statusHT(Identifier offlineId) const; + + + const StrawStatusContainer* getStrawStatusContainer() const; + const StrawStatusContainer* getStrawStatusPermanentContainer() const; + const StrawStatusContainer* getStrawStatusHTContainer() const; + + + private: + ServiceHandle<StoreGateSvc> m_detStore; + ServiceHandle<IToolSvc> m_toolsvc; + std::string m_par_strawstatuscontainerkey; + std::string m_par_strawstatuspermanentcontainerkey; + std::string m_par_strawstatusHTcontainerkey; + + + const TRT_ID* m_trtId; + + ServiceHandle<ICondSvc> m_condSvc; + // ReadHandle keys + SG::ReadCondHandleKey<StrawStatusContainer> m_statReadKey{this,"StatReadKeyName","in","StrawStatus in-key"}; + SG::ReadCondHandleKey<StrawStatusContainer> m_permReadKey{this,"PermReadKeyName","in","StrawStatusPermanent in-key"}; + SG::ReadCondHandleKey<StrawStatusContainer> m_statHTReadKey{this,"StatHTReadKeyName","in","StrawStatusHT in-key"}; + + // Caches + mutable std::vector<const StrawStatusContainer*> m_strawstatuscontainer; + mutable std::vector<const StrawStatusContainer*> m_strawstatuspermanentcontainer; + mutable std::vector<const StrawStatusContainer*> m_strawstatusHTcontainer; + mutable std::mutex m_cacheMutex; + mutable std::vector<EventContext::ContextEvt_t> m_evtstat; + mutable std::vector<EventContext::ContextEvt_t> m_evtperm; + mutable std::vector<EventContext::ContextEvt_t> m_evtstatHT; + + // Used in simulation (GEANT4) jobs + bool m_isGEANT4; + const DataHandle<StrawStatusContainer> m_strawstatusG4; + const DataHandle<StrawStatusContainer> m_strawstatuspermanentG4; + const DataHandle<StrawStatusContainer> m_strawstatusHTG4; + + +}; + + + +//////////////////////////////////////////////////////////////////////////////////////////// +// inline methods +//////////////////////////////////////////////////////////////////////////////////////////// + + + + +inline const TRT_StrawStatusSummaryTool::StrawStatusContainer* TRT_StrawStatusSummaryTool::getStrawStatusContainer() const{ + + const EventContext& event_context=Gaudi::Hive::currentContext(); + EventContext::ContextID_t slot=event_context.slot(); + EventContext::ContextEvt_t event_id=event_context.evt(); + std::lock_guard<std::mutex> lock(m_cacheMutex); + if(slot>=m_evtstat.size()) { + m_evtstat.resize(slot+1); + m_strawstatuscontainer.resize(slot+1); + } + + if(m_evtstat[slot]!=event_id) { + SG::ReadCondHandle<StrawStatusContainer> rst(m_statReadKey,event_context); + m_strawstatuscontainer[slot]=(*rst); + m_evtstat[slot]=event_id; + } + + return m_strawstatuscontainer[slot]; + +} +inline const TRT_StrawStatusSummaryTool::StrawStatusContainer* TRT_StrawStatusSummaryTool::getStrawStatusPermanentContainer() const{ + + + const EventContext& event_context=Gaudi::Hive::currentContext(); + EventContext::ContextID_t slot=event_context.slot(); + EventContext::ContextEvt_t event_id=event_context.evt(); + std::lock_guard<std::mutex> lock(m_cacheMutex); + if(slot>=m_evtperm.size()) { + m_evtperm.resize(slot+1); + m_strawstatuspermanentcontainer.resize(slot+1); + } + + if(m_evtperm[slot]!=event_id) { + SG::ReadCondHandle<StrawStatusContainer> rp(m_permReadKey,event_context); + m_strawstatuspermanentcontainer[slot]=(*rp); + m_evtperm[slot]=event_id; + } + + return m_strawstatuspermanentcontainer[slot]; + +} +inline const TRT_StrawStatusSummaryTool::StrawStatusContainer* TRT_StrawStatusSummaryTool::getStrawStatusHTContainer() const{ + + if(m_isGEANT4) { + return m_strawstatusHTG4.cptr(); + } + const EventContext& event_context=Gaudi::Hive::currentContext(); + EventContext::ContextID_t slot=event_context.slot(); + EventContext::ContextEvt_t event_id=event_context.evt(); + std::lock_guard<std::mutex> lock(m_cacheMutex); + if(slot>=m_evtstatHT.size()) { + m_evtstatHT.resize(slot+1); + m_strawstatusHTcontainer.resize(slot+1); + } + + if(m_evtstatHT[slot]!=event_id) { + SG::ReadCondHandle<StrawStatusContainer> rht(m_statHTReadKey,event_context); + m_strawstatusHTcontainer[slot]=(*rht); + m_evtstatHT[slot]=event_id; + } + + return m_strawstatusHTcontainer[slot]; +} +#endif // TRT_STRAWSTATUSSUMMARYTOOL_H diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/components/TRT_ConditionsServices_entries.cxx b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/components/TRT_ConditionsServices_entries.cxx index 7d9fd439da62f010a10498d7508207536b719546..99790a8f0d5f28576cc6da3589bd039862fcc8df 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsServices/src/components/TRT_ConditionsServices_entries.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/src/components/TRT_ConditionsServices_entries.cxx @@ -2,11 +2,13 @@ #include "src/TRT_ConditionsTestSvc.h" #include "src/TRT_AlignDbSvc.h" #include "src/TRT_CalDbSvc.h" +#include "src/TRT_CalDbTool.h" #include "src/TRT_StrawAlignDbSvc.h" #include "src/TRT_DCS_ConditionsSvc.h" #include "src/TRT_HWMappingSvc.h" #include "src/TRT_StrawNeighbourSvc.h" #include "src/TRT_StrawStatusSummarySvc.h" +#include "src/TRT_StrawStatusSummaryTool.h" #ifndef SIMULATIONBASE #include "src/TRT_ByteStream_ConditionsSvc.h" #endif @@ -16,11 +18,13 @@ DECLARE_COMPONENT( TRT_ConditionsSummarySvc ) DECLARE_COMPONENT( TRT_ConditionsTestSvc ) DECLARE_COMPONENT( TRT_AlignDbSvc ) DECLARE_COMPONENT( TRT_CalDbSvc ) +DECLARE_COMPONENT( TRT_CalDbTool ) DECLARE_COMPONENT( TRT_StrawAlignDbSvc ) DECLARE_COMPONENT( TRT_DCS_ConditionsSvc ) DECLARE_COMPONENT( TRT_HWMappingSvc ) DECLARE_COMPONENT( TRT_StrawNeighbourSvc ) DECLARE_COMPONENT( TRT_StrawStatusSummarySvc ) +DECLARE_COMPONENT( TRT_StrawStatusSummaryTool ) #ifndef SIMULATIONBASE DECLARE_COMPONENT( TRT_ByteStream_ConditionsSvc ) #endif diff --git a/InnerDetector/InDetExample/InDetRecExample/python/TRTCommon.py b/InnerDetector/InDetExample/InDetRecExample/python/TRTCommon.py index 28707794b778ef572ad823dba6c2b2f25920e434..f58ad7628d7f1eee395ce678de06f6abef274936 100644 --- a/InnerDetector/InDetExample/InDetRecExample/python/TRTCommon.py +++ b/InnerDetector/InDetExample/InDetRecExample/python/TRTCommon.py @@ -9,6 +9,7 @@ def _args( kwargs, **extra_kwargs) : def getInDetTRT_dEdxTool(**kwargs) : InDetTRT_dEdxTool = None + from InDetRecExample.InDetJobProperties import InDetFlags from AthenaCommon.DetFlags import DetFlags if DetFlags.haveRIO.TRT_on() and not InDetFlags.doSLHC() and not InDetFlags.doHighPileup() : diff --git a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py index 798cb07f16439a08e01b9f1b9c6c50114d1ed808..440eecb5779fc523d4ba1bb5ced710c091565b3d 100644 --- a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py @@ -37,6 +37,17 @@ class ConfiguredInDetPreProcessingTRT: collection = InDetKeys.TRT_DriftCirclesUncalibrated() if InDetFlags.doSplitReco() : collectionPU = InDetKeys.TRT_PU_DriftCirclesUncalibrated() + # Calibration DB Service + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool + InDetTRTCalDbTool = TRT_CalDbTool(name = "TRT_CalDbTool") + + + # --- set Data/MC flag + if globalflags.DataSource != 'geant4' : + InDetTRTCalDbTool.isGEANT4 = False + else : + InDetTRTCalDbTool.isGEANT4 = True + # # --- TRT_DriftFunctionTool # @@ -44,7 +55,7 @@ class ConfiguredInDetPreProcessingTRT: from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool(name = prefix+"DriftFunctionTool", - TRTCalDbTool = InDetTRTCalDbSvc) + TRTCalDbTool = InDetTRTCalDbTool) # --- overwrite for uncalibrated DC production if (not useTimeInfo) or InDetFlags.noTRTTiming(): InDetTRT_DriftFunctionTool.DummyMode = True @@ -56,6 +67,7 @@ class ConfiguredInDetPreProcessingTRT: else : InDetTRT_DriftFunctionTool.IsMC = True + # --- overwrite for calibration of MC if usePhase and jobproperties.Beam.beamType()=='cosmics' and globalflags.DataSource == "geant4": InDetTRT_DriftFunctionTool.AllowDigiVersionOverride = True @@ -76,10 +88,25 @@ class ConfiguredInDetPreProcessingTRT: -0.29828, -0.21344, -0.322892, -0.386718, -0.534751, -0.874178, -1.231799, -1.503689, -1.896464, -2.385958] InDetTRT_DriftFunctionTool.ToTCorrectionsEndcapAr = [0., 5.514777, 3.342712, 2.056626, 1.08293693, 0.3907979, -0.082819, -0.457485, -0.599706, -0.427493, -0.328962, -0.403399, -0.663656, -1.029428, -1.46008, -1.919092, -2.151582, -2.285481, -2.036822, -2.15805] + # Second calibration DB Service in case pile-up and physics hits have different calibrations + if DetFlags.overlay.TRT_on() : + InDetTRTCalDbTool2 = TRT_CalDbTool(name = "TRT_CalDbTool2") + InDetTRTCalDbTool2.IsGEANT4 = True + InDetTRTCalDbTool2.RtFolderName = "/TRT/Calib/MC/RT" + InDetTRTCalDbTool2.T0FolderName = "/TRT/Calib/MC/T0" + InDetTRT_DriftFunctionTool.TRTCalDbTool2 = InDetTRTCalDbTool2 + InDetTRT_DriftFunctionTool.IsOverlay = True + InDetTRT_DriftFunctionTool.IsMC = False ToolSvc += InDetTRT_DriftFunctionTool if (InDetFlags.doPrintConfigurables()): print InDetTRT_DriftFunctionTool + + # Straw status DB Tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + # # --- TRT_DriftCircleTool # @@ -109,8 +136,7 @@ class ConfiguredInDetPreProcessingTRT: InDetTRT_DriftCircleTool = InDet__TRT_DriftCircleTool(name = prefix+"DriftCircleTool", TRTDriftFunctionTool = InDetTRT_DriftFunctionTool, TrtDescrManageLocation = InDetKeys.TRT_Manager(), - ConditionsSummaryTool = InDetTRTStrawStatusSummarySvc, - #used to be InDetTRTConditionsSummaryService, + ConditionsSummaryTool = InDetTRTStrawStatusSummaryTool, UseConditionsStatus = True, UseConditionsHTStatus = True, SimpleOutOfTimePileupSupression = InDetFlags.doCosmics(), @@ -180,8 +206,8 @@ class ConfiguredInDetPreProcessingTRT: from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy( name = "InDet_TRT_LocalOccupancy", isTrigger = False, - TRTDriftFunctionTool = InDetTRT_DriftFunctionTool - ) + TRTCalDbTool = InDetTRTCalDbTool, + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool) ToolSvc += InDetTRT_LocalOccupancy if (InDetFlags.doPrintConfigurables()): diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py index 4cb832a1e9b43c3506346b9bf0cb5a134a437426..d8c6262ce6b62800fe7f5333b38243b11d521d7c 100644 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py @@ -348,13 +348,12 @@ if DetFlags.haveRIO.TRT_on(): # Added for run2. Clean the unsed ones!!! if not conddb.folderRequested( "/TRT/Calib/PID_vector" ): - conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/PID_vector", "/TRT/Calib/PID_vector") - + conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/PID_vector", "/TRT/Calib/PID_vector",className='CondAttrListVec') if not conddb.folderRequested( "/TRT/Calib/ToT/ToTVectors"): - conddb.addFolderSplitOnline( "TRT", "/TRT/Onl/Calib/ToT/ToTVectors", "/TRT/Calib/ToT/ToTVectors") + conddb.addFolderSplitOnline( "TRT", "/TRT/Onl/Calib/ToT/ToTVectors", "/TRT/Calib/ToT/ToTVectors",className='CondAttrListVec') if not conddb.folderRequested( "/TRT/Calib/ToT/ToTValue"): - conddb.addFolderSplitOnline( "TRT", "/TRT/Onl/Calib/ToT/ToTValue", "/TRT/Calib/ToT/ToTValue") + conddb.addFolderSplitOnline( "TRT", "/TRT/Onl/Calib/ToT/ToTValue", "/TRT/Calib/ToT/ToTValue",className='CondAttrListCollection') # @@ -389,6 +388,41 @@ if DetFlags.haveRIO.TRT_on(): if (InDetFlags.doPrintConfigurables()): print InDetTRTStrawStatusSummarySvc InDetTRTConditionsServices.append(InDetTRTStrawStatusSummarySvc) + + # Straw status tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4 = useOldStyle) + # Alive straws algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTStrawCondAlg + TRTStrawCondAlg = TRTStrawCondAlg(name = "TRTStrawCondAlg", + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool, + isGEANT4 = useOldStyle) + # Active Fraction algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTActiveCondAlg + TRTActiveCondAlg = TRTActiveCondAlg(name = "TRTActiveCondAlg", + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool) + + # HT probability algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTHTCondAlg + TRTHTCondAlg = TRTHTCondAlg(name = "TRTHTCondAlg") + + # dEdx probability algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTToTCondAlg + TRTToTCondAlg = TRTToTCondAlg(name = "TRTToTCondAlg") + + # Condition algorithms for straw conditions + if not hasattr(condSeq, "TRTStrawCondAlg"): + condSeq += TRTStrawCondAlg + if not hasattr(condSeq, "TRTActiveCondAlg"): + condSeq += TRTActiveCondAlg + + # Condition algorithms for Pid + if not hasattr(condSeq, "TRTHTCondAlg"): + condSeq += TRTHTCondAlg + if not hasattr(condSeq, "TRTToTCondAlg"): + condSeq += TRTToTCondAlg + # Services which only run on raw data if (globalflags.InputFormat() == 'bytestream' and globalflags.DataSource() == 'data'): @@ -425,9 +459,4 @@ if DetFlags.haveRIO.TRT_on(): if (InDetFlags.doPrintConfigurables()): print InDetTRTConditionsSummaryService - from TRT_RecoConditionsServices.TRT_RecoConditionsServicesConf import TRT_ActiveFractionSvc - InDetTRT_ActiveFractionSvc = TRT_ActiveFractionSvc(name = "InDetTRTActiveFractionSvc") - - ServiceMgr += InDetTRT_ActiveFractionSvc - if (InDetFlags.doPrintConfigurables()): - print InDetTRT_ActiveFractionSvc + diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py index fe6329886ca02ea3c56510969f69995d3b08cd93..9ae64155d2b48b9d381a5ffe827679d6c7dff746 100755 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py @@ -943,20 +943,20 @@ if InDetFlags.loadSummaryTool(): if DetFlags.haveRIO.TRT_on() and not InDetFlags.doSLHC() and not InDetFlags.doHighPileup() \ and not InDetFlags.useExistingTracksAsInput(): # TRT_RDOs (used byt the TRT_LocalOccupancy tool) are not present in ESD - isMC = False - if globalflags.DataSource == "geant4" : - isMC = True - - from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool - InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool( name = "InDetTRT_DriftFunctionTool", - IsMC = isMC ) - ToolSvc += InDetTRT_DriftFunctionTool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool + InDetTRTCalDbTool = TRT_CalDbTool(name = "TRT_CalDbTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + # Straw status DB Tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4=(globalflags.DataSource == 'geant4')) from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy( name ="InDet_TRT_LocalOccupancy", - isTrigger = False, - TRTDriftFunctionTool = InDetTRT_DriftFunctionTool - ) + isTrigger = False, + TRTCalDbTool = InDetTRTCalDbTool, + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool ) + ToolSvc += InDetTRT_LocalOccupancy if (InDetFlags.doPrintConfigurables()): print InDetTRT_LocalOccupancy @@ -964,9 +964,11 @@ if InDetFlags.loadSummaryTool(): from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2 InDetTRT_ElectronPidTool = InDet__TRT_ElectronPidToolRun2(name = "InDetTRT_ElectronPidTool", TRT_LocalOccupancyTool = InDetTRT_LocalOccupancy, + TRTStrawSummaryTool = InDetTRTStrawStatusSummaryTool, isData = (globalflags.DataSource == 'data')) + ToolSvc += InDetTRT_ElectronPidTool if (InDetFlags.doPrintConfigurables()): print InDetTRT_ElectronPidTool @@ -974,6 +976,7 @@ if InDetFlags.loadSummaryTool(): import InDetRecExample.TRTCommon InDetTRT_dEdxTool = InDetRecExample.TRTCommon.getInDetTRT_dEdxTool() + if (InDetTRT_dEdxTool != None and InDetFlags.doPrintConfigurables()): print InDetTRT_dEdxTool @@ -1159,10 +1162,6 @@ if InDetFlags.doPattern(): MinOffsetDCs = 5, UseNewParameterization = True, # Use Thomas's new parameterization by default UseActiveFractionSvc = DetFlags.haveRIO.TRT_on()) - if (DetFlags.haveRIO.TRT_on()): - InDetTRTDriftCircleCut.TrtConditionsSvc = InDetTRT_ActiveFractionSvc - else: - InDetTRTDriftCircleCut.TrtConditionsSvc = None ToolSvc += InDetTRTDriftCircleCut if (InDetFlags.doPrintConfigurables()): @@ -1238,10 +1237,6 @@ if InDetFlags.doPattern() and DetFlags.haveRIO.TRT_on(): MinOffsetDCs = 5, UseNewParameterization = InDetNewTrackingCuts.useNewParameterizationTRT(), # Use new parameterization only for high lumi UseActiveFractionSvc = DetFlags.haveRIO.TRT_on()) - if (DetFlags.haveRIO.TRT_on()): - InDetTRTDriftCircleCutForPatternReco.TrtConditionsSvc = InDetTRT_ActiveFractionSvc - else: - InDetTRTDriftCircleCutForPatternReco.TrtConditionsSvc = None ToolSvc += InDetTRTDriftCircleCutForPatternReco if (InDetFlags.doPrintConfigurables()): diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigCommonTools.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigCommonTools.py index ef65af23e24011086a67320a12926eb5bfe7a220..dc72b64fff9e94ccb488688a2148d361ed1a9208 100644 --- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigCommonTools.py +++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigCommonTools.py @@ -12,22 +12,60 @@ ___version___ = "$Id: $" from InDetTrigRecExample.InDetTrigConditionsAccess import TRT_ConditionsSetup from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.GlobalFlags import globalflags +from AthenaCommon.DetFlags import DetFlags -# TRT_DriftFunctionTool +# --- set Data/MC flag isMC = False if globalflags.DataSource == "geant4" : isMC = True +# Calibration DB Service +from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool +InDetTRTCalDbTool = TRT_CalDbTool(name = "TRT_CalDbTool") + + +if(isMC) : + InDetTRTCalDbTool.isGEANT4 = True +else : + InDetTRTCalDbTool.isGEANT4 = False + + +# TRT_DriftFunctionTool from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool InDetTrigTRT_DriftFunctionTool = TRT_DriftFunctionTool(name = "InDetTrigTRT_DriftFunctionTool", + TRTCalDbTool = InDetTRTCalDbTool, AllowDataMCOverride = True, ForceData = True, - IsMC = isMC, - TRTCalDbTool = "TRT_CalDbSvc/TRT_CalDbSvc" ) + IsMC = isMC) + +# Second calibration DB Service in case pile-up and physics hits have different calibrations +if DetFlags.overlay.TRT_on() : + + InDetTrigTRTCalDbTool2 = TRT_CalDbTool(name = "TRT_CalDbSvc2") + InDetTrigTRTCalDbTool2.IsGEANT4 = True + InDetTrigTRTCalDbTool2.RtFolderName = "/TRT/Calib/MC/RT" + InDetTrigTRTCalDbTool2.T0FolderName = "/TRT/Calib/MC/T0" + InDetTrigTRT_DriftFunctionTool.TRTCalDbTool2 = InDetTrigTRTCalDbTool2 + InDetTrigTRT_DriftFunctionTool.IsOverlay = True + InDetTrigTRT_DriftFunctionTool.IsMC = False + +# --- set HT corrections +InDetTrigTRT_DriftFunctionTool.HTCorrectionBarrelXe = 1.5205 +InDetTrigTRT_DriftFunctionTool.HTCorrectionEndcapXe = 1.2712 +InDetTrigTRT_DriftFunctionTool.HTCorrectionBarrelAr = 1.5205 +InDetTrigTRT_DriftFunctionTool.HTCorrectionEndcapAr = 1.2712 + +# --- set ToT corrections +InDetTrigTRT_DriftFunctionTool.ToTCorrectionsBarrelXe = [0., 4.358121, 3.032195, 1.631892, 0.7408397, -0.004113, -0.613288, -0.73758, -0.623346, -0.561229,-0.29828, -0.21344, -0.322892, -0.386718, -0.534751, -0.874178, -1.231799, -1.503689, -1.896464, -2.385958] +InDetTrigTRT_DriftFunctionTool.ToTCorrectionsEndcapXe = [0., 5.514777, 3.342712, 2.056626, 1.08293693, 0.3907979, -0.082819, -0.457485, -0.599706, -0.427493, -0.328962, -0.403399, -0.663656, -1.029428, -1.46008, -1.919092, -2.151582, -2.285481, -2.036822, -2.15805] +InDetTrigTRT_DriftFunctionTool.ToTCorrectionsBarrelAr = [0., 4.358121, 3.032195, 1.631892, 0.7408397, -0.004113, -0.613288, -0.73758, -0.623346, -0.561229, -0.29828, -0.21344, -0.322892, -0.386718, -0.534751, -0.874178, -1.231799, -1.503689, -1.896464, -2.385958] +InDetTrigTRT_DriftFunctionTool.ToTCorrectionsEndcapAr = [0., 5.514777, 3.342712, 2.056626, 1.08293693, 0.3907979, -0.082819, -0.457485, -0.599706, -0.427493, -0.328962, -0.403399, -0.663656, -1.029428, -1.46008, -1.919092, -2.151582, -2.285481, -2.036822, -2.15805] + ToolSvc += InDetTrigTRT_DriftFunctionTool + # TRT_RodDecoder from TRT_RawDataByteStreamCnv.TRT_RawDataByteStreamCnvConf import TRT_RodDecoder @@ -35,6 +73,11 @@ InDetTrigTRTRodDecoder = TRT_RodDecoder(name = "InDetTrigTRTRodDecoder", LoadCompressTableDB = (globalflags.DataSource() != 'geant4')) ToolSvc += InDetTrigTRTRodDecoder +# Straw status DB Tool +from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool +InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + # TRT_DriftCircleTool from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleTool #these settings offline keeps for MC @@ -55,6 +98,7 @@ if globalflags.DataSource != 'data': InDetTrigTRT_DriftCircleTool = InDet__TRT_DriftCircleTool( name = "InDetTrigTRT_DriftCircleTool", TRTDriftFunctionTool = InDetTrigTRT_DriftFunctionTool, + ConditionsSummaryTool = InDetTRTStrawStatusSummaryTool, UseConditionsStatus = True, UseConditionsHTStatus = True, SimpleOutOfTimePileupSupression = True, @@ -90,11 +134,6 @@ if InDetTrigFlags.InDet25nsec(): # InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression=False -InDetTrigTRT_DriftCircleTool.ConditionsSummaryTool= \ - "TRT_StrawStatusSummarySvc/"+TRT_ConditionsSetup.instanceName("InDetTRTStrawStatusSummarySvc") -# "TRT_ConditionsSummarySvc/"+TRT_ConditionsSetup.instanceName("InDetTRTConditionsSummaryService") - ToolSvc += InDetTrigTRT_DriftCircleTool print InDetTrigTRT_DriftCircleTool - diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py index a6e0389c9113d00a6c13ccfe75854787c40d6b38..195901186832f0d24ef17451fa4a3708464bb08c 100644 --- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py +++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py @@ -531,6 +531,37 @@ class TRTConditionsServicesSetup: if not conddb.folderRequested('/TRT/Cond/StatusHT'): conddb.addFolderSplitOnline("TRT","/TRT/Onl/Cond/StatusHT","/TRT/Cond/StatusHT",className='TRTCond::StrawStatusMultChanContainer') + # Straw status tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4 = self._isMC) + # Alive straws algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTStrawCondAlg + TRTStrawCondAlg = TRTStrawCondAlg(name = "TRTStrawCondAlg", + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool, + isGEANT4 = self._isMC) + # Active Fraction algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTActiveCondAlg + TRTActiveCondAlg = TRTActiveCondAlg(name = "TRTActiveCondAlg", + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool) + + + # HT probability algorithm + from TRT_ConditionsAlgs.TRT_ConditionsAlgsConf import TRTHTCondAlg + TRTHTCondAlg = TRTHTCondAlg(name = "TRTHTCondAlg") + + + from AthenaCommon.AlgSequence import AthSequencer + condSeq = AthSequencer("AthCondSeq") + + # Condition algorithms for straw conditions + if not hasattr(condSeq, "TRTStrawCondAlg"): + condSeq += TRTStrawCondAlg + if not hasattr(condSeq, "TRTActiveCondAlg"): + condSeq += TRTActiveCondAlg + # Condition algorithms for Pid + if not hasattr(condSeq, "TRTHTCondAlg"): + condSeq += TRTHTCondAlg from AthenaCommon.GlobalFlags import globalflags @@ -594,12 +625,6 @@ class TRTConditionsServicesSetup: if self._print: print InDetTRTConditionsSummaryService - from TRT_RecoConditionsServices.TRT_RecoConditionsServicesConf import TRT_ActiveFractionSvc - InDetTRT_ActiveFractionSvc = TRT_ActiveFractionSvc(name=self.instanceName("InDetTRTActiveFractionSvc"), - #missing link to TRTSummarySvc - ) - ServiceMgr += InDetTRT_ActiveFractionSvc - def instanceName(self, toolname): return self.prefix+toolname diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py index d9c5eb709bce514e4350f0064a94cc425f110b4a..c999a1ce38a9df675975cc0c0cdfde9ae91e850f 100755 --- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py +++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py @@ -740,34 +740,38 @@ if InDetTrigFlags.loadSummaryTool(): conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/PID_RToT","/TRT/Calib/PID_RToT") if not (conddb.folderRequested("/TRT/Calib/PID_vector") or \ conddb.folderRequested("/TRT/Onl/Calib/PID_vector")): - conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/PID_vector","/TRT/Calib/PID_vector") + conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/PID_vector","/TRT/Calib/PID_vector",className='CondAttrListVec') if not (conddb.folderRequested("/TRT/Calib/ToT/ToTVectors") or \ conddb.folderRequested("/TRT/Onl/Calib/ToT/ToTVectors")): - conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/ToT/ToTVectors","/TRT/Calib/ToT/ToTVectors") + conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/ToT/ToTVectors","/TRT/Calib/ToT/ToTVectors",className='CondAttrListVec') if not (conddb.folderRequested("/TRT/Calib/ToT/ToTValue") or \ conddb.folderRequested("/TRT/Onl/Calib/ToT/ToTValue")): - conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/ToT/ToTValue","/TRT/Calib/ToT/ToTValue") - - # from AthenaCommon.GlobalFlags import globalflags - # if globalflags.DataSource() == 'data': - # conddb.addOverride("/TRT/Onl/Calib/PID_vector" ,"TRTOnlCalibPID_vector-ES1-UPD1-00-00-01") - #else: - # conddb.addOverride("/TRT/Onl/Calib/PID_vector","TRTCalibPID_vector_MC_OnSetMC_CorrMC_noZR_00-01") + conddb.addFolderSplitOnline("TRT","/TRT/Onl/Calib/ToT/ToTValue","/TRT/Calib/ToT/ToTValue",className='CondAttrListCollection') + from AthenaCommon.GlobalFlags import globalflags from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2,InDet__TRT_LocalOccupancy - from AthenaCommon.GlobalFlags import globalflags from InDetTrigRecExample.InDetTrigConditionsAccess import TRT_ConditionsSetup - - InDetTrigTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(name ="InDetTrigTRT_LocalOccupancy", - isTrigger=True, + # Calibration DB Tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool + InDetTRTCalDbTool = TRT_CalDbTool(name = "TRT_CalDbTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + # Straw status DB Tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + + from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy + InDetTrigTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(name ="InDet_TRT_LocalOccupancy", + isTrigger = True, TRT_RDOContainerName="TRT_RDOs_EF", - TRTStrawSummarySvc=TRT_ConditionsSetup.instanceName('InDetTRTStrawStatusSummarySvc'), - ) + TRTCalDbTool = InDetTRTCalDbTool, + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool) ToolSvc += InDetTrigTRT_LocalOccupancy + InDetTrigTRT_ElectronPidTool = InDet__TRT_ElectronPidToolRun2(name = "InDetTrigTRT_ElectronPidTool", TRT_LocalOccupancyTool = InDetTrigTRT_LocalOccupancy, - TRTStrawSummarySvc=TRT_ConditionsSetup.instanceName('InDetTRTStrawStatusSummarySvc'), + TRTStrawSummaryTool= InDetTRTStrawStatusSummaryTool, OccupancyUsedInPID = True, isData = (globalflags.DataSource == 'data')) @@ -775,6 +779,8 @@ if InDetTrigFlags.loadSummaryTool(): if (InDetTrigFlags.doPrintConfigurables()): print InDetTrigTRT_ElectronPidTool + + # # Configurable version of TrkTrackSummaryTool # @@ -856,13 +862,9 @@ if InDetTrigFlags.doNewTracking() or InDetTrigFlags.doBackTracking() or InDetTri # TRT segment minimum number of drift circles tool # -from InDetTrigRecExample.InDetTrigConditionsAccess import TRT_ConditionsSetup -InDetTrigTRT_ActiveFractionSvc = TRT_ConditionsSetup.instanceName("InDetTRTActiveFractionSvc") - from InDetTrackSelectorTool.InDetTrackSelectorToolConf import InDet__InDetTrtDriftCircleCutTool InDetTrigTRTDriftCircleCut = InDet__InDetTrtDriftCircleCutTool( name = 'InDetTrigTRTDriftCircleCut', - TrtConditionsSvc = InDetTrigTRT_ActiveFractionSvc, MinOffsetDCs = 5, UseNewParameterization = True, UseActiveFractionSvc = True #DetFlags.haveRIO.TRT_on() # Use Thomas's new parameterization by default @@ -874,7 +876,6 @@ if (InDetTrigFlags.doPrintConfigurables()): InDetTrigTRTDriftCircleCutForPatt = InDet__InDetTrtDriftCircleCutTool( name = 'InDetTrigTRTDriftCircleCutForPatt', - TrtConditionsSvc = InDetTrigTRT_ActiveFractionSvc, MinOffsetDCs = 5, UseNewParameterization = InDetTrigCutValues.useNewParameterizationTRT(), UseActiveFractionSvc = True #DetFlags.haveRIO.TRT_on() # Use Thomas's new parameterization by default diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetTrtDriftCircleCutTool.h b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetTrtDriftCircleCutTool.h index 291aabe9785a1b9d68d8dba1b295cc8d97f831db..0fc7bf0d33c129eb7b7f5846cd58aa2a42e26b90 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetTrtDriftCircleCutTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetTrtDriftCircleCutTool.h @@ -7,8 +7,9 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" #include "InDetRecToolInterfaces/ITrtDriftCircleCutTool.h" +#include "TRT_ConditionsData/ActiveFraction.h" +#include "StoreGate/ReadCondHandleKey.h" /** * A tool to be used for trt segment pre-selection @@ -17,7 +18,6 @@ * April 2009 */ -class ITRT_ActiveFractionSvc; namespace InDet{ @@ -39,8 +39,7 @@ namespace InDet{ private: - ServiceHandle<ITRT_ActiveFractionSvc> m_trtCondSvc; //!< TRT active fraction service - + SG::ReadCondHandleKey<TRTCond::ActiveFraction> m_strawReadKey{this,"ActiveWriteKey","ActiveFraction","ActiveFraction in-key"}; /** Properties for track selection:all cuts are ANDed */ int m_minOffset; //!< Minimum number of TRT drit circles required bool m_param; //!< Use the new or the old parameterization diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetTrtDriftCircleCutTool.cxx b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetTrtDriftCircleCutTool.cxx index 5400c2e1cc6ea147a6a5a7d2b612ff45777742ff..d46a2587db7dcda0eec247e2f059ff127582a73f 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetTrtDriftCircleCutTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetTrtDriftCircleCutTool.cxx @@ -1,29 +1,23 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetTrackSelectorTool/InDetTrtDriftCircleCutTool.h" -#include "InDetRecToolInterfaces/ITRT_ActiveFractionSvc.h" +#include "StoreGate/ReadCondHandle.h" StatusCode InDet::InDetTrtDriftCircleCutTool::initialize() { StatusCode sc = AthAlgTool::initialize(); - /* Get the trt active fraction tool */ - if(m_useTRT){ - if ( m_trtCondSvc.retrieve().isFailure() ) { - msg(MSG::ERROR) << "Failed to retrieve tool " << m_trtCondSvc << endmsg; - return StatusCode::FAILURE; - } else { - msg(MSG::INFO) << "Retrieved tool " << m_trtCondSvc << endmsg; - } - } if(sc.isFailure()){ msg(MSG::ERROR)<<" Unable to initialize the AlgTool"<<endmsg; return StatusCode::FAILURE; } + // Read key + ATH_CHECK( m_strawReadKey.initialize() ); + return StatusCode::SUCCESS; } @@ -35,13 +29,11 @@ StatusCode InDet::InDetTrtDriftCircleCutTool::finalize() InDet::InDetTrtDriftCircleCutTool::InDetTrtDriftCircleCutTool(const std::string& t, const std::string& n, const IInterface* p) :AthAlgTool(t,n,p), - m_trtCondSvc("TRT_ActiveFractionSvc",n), m_minOffset(0), m_param(false), m_useTRT(true) { declareInterface<ITrtDriftCircleCutTool>(this); - declareProperty("TrtConditionsSvc", m_trtCondSvc); declareProperty("MinOffsetDCs", m_minOffset ); declareProperty("UseNewParameterization", m_param ); declareProperty("UseActiveFractionSvc", m_useTRT ); @@ -74,12 +66,17 @@ int InDet::InDetTrtDriftCircleCutTool::minNumberDCs(const Trk::TrackParameters* double eta = fabs(trkp->momentum().eta()); + SG::ReadCondHandle<TRTCond::ActiveFraction> strawReadHandle{m_strawReadKey}; + const TRTCond::ActiveFraction* actF{*strawReadHandle}; + for(int i=0; i!=6; ++i) { if(eta <= TrtEtaBin[i+1]) { double diff = eta; double nDiffTRT = TrtA[i]+TrtB[i]*diff+TrtC[i]*diff*diff+TrtD[i]*diff*diff*diff-TrtO[i]; double activeF = 1.; - if(m_useTRT) activeF = m_trtCondSvc->getActiveFraction(trkp); + float phi = trkp->momentum().phi(); + float eta = trkp->momentum().eta(); + if(m_useTRT) activeF = actF->getActiveFraction(eta,phi); nDiffTRT = nDiffTRT*activeF; if (nDiffTRT>=1) return int(nDiffTRT); else return int(m_minOffset); diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h index 3e46870de3cd72b780dc8cc4f9b6c7b1ca01e47d..f1a63aba74375b560334049f8db94b202ecaed2e 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h @@ -22,11 +22,11 @@ #include "TrkPrepRawData/PrepRawDataCLASS_DEF.h" #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" -#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" #include "StoreGate/ReadHandleKey.h" #include "xAODEventInfo/EventInfo.h" -class ITRT_StrawSummarySvc; +class ITRT_StrawSummaryTool; class ITRT_DriftFunctionTool; class IInDetConditionsSvc; class TRT_ID; @@ -77,7 +77,7 @@ public: /////////////////////////////////////////////////////////////////// SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey {this,"xAODEventInfoKey","EventInfo","RHK to retrieve xAOD::EventInfo" }; //!< key to retrieve eventinfo ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool; //!< DriftFunctionTool - ServiceHandle<ITRT_StrawStatusSummarySvc> m_ConditionsSummary; //!< The ConditionsSummaryTool + ToolHandle<ITRT_StrawStatusSummaryTool> m_ConditionsSummary; //!< The ConditionsSummaryTool // ServiceHandle<ITRT_ConditionsSvc> m_ConditionsSummary; //!< The ConditionsSummaryTool // ServiceHandle< IInDetConditionsSvc> m_ConditionsSummary; //!< The ConditionsSummaryTool bool m_useConditionsStatus; //!< Shall the ConditionsSummaryTool be used? diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx index 54d321749197a87661da7cf53052e9fbb4a8e7f0..7693f1a997da3587c9b350827343edf4f41537fc 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx @@ -24,9 +24,7 @@ #include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" #include "InDetReadoutGeometry/TRT_DetectorManager.h" #include "InDetIdentifier/TRT_ID.h" -//#include "InDetConditionsSummaryService/IInDetConditionsSvc.h" -//#include "TRT_ConditionsServices/ITRT_ConditionsSvc.h" -#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" #include "GeoPrimitives/GeoPrimitives.h" #include "EventPrimitives/EventPrimitives.h" @@ -42,7 +40,7 @@ InDet::TRT_DriftCircleTool::TRT_DriftCircleTool(const std::string& t, const IInterface* p ): AthAlgTool(t,n,p), m_driftFunctionTool("TRT_DriftFunctionTool"), - m_ConditionsSummary("InDetTRTConditionsSummaryService",n), + m_ConditionsSummary("TRT_StrawStatusSummaryTool",this), m_useConditionsStatus(false), m_useConditionsHTStatus(false), m_useToTCorrection(false), diff --git a/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/TRT_DriftFunctionTool/TRT_DriftFunctionTool.h b/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/TRT_DriftFunctionTool/TRT_DriftFunctionTool.h index b625f1611a5863c3a995e8b6c0325a9afed797bc..5564a86b88814700e3c938b08baebd7eb038d4ea 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/TRT_DriftFunctionTool/TRT_DriftFunctionTool.h +++ b/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/TRT_DriftFunctionTool/TRT_DriftFunctionTool.h @@ -18,15 +18,13 @@ #include <string> #include "AthenaBaseComps/AthAlgTool.h" #include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" - -class ITRT_CalDbSvc; +#include "TRT_ConditionsServices/ITRT_CalDbTool.h" class TRT_ID; #include "InDetReadoutGeometry/TRT_DetectorManager.h" -#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ICondSvc.h" -#include "StoreGate/ReadCondHandleKey.h" #include "StoreGate/DataHandle.h" // AttributeList #include "AthenaPoolUtilities/CondAttrListCollection.h" @@ -99,9 +97,8 @@ public: private: /** Tool to fetch data from database */ - ServiceHandle< ITRT_CalDbSvc > m_TRTCalDbSvc; - ServiceHandle< ITRT_CalDbSvc > m_TRTCalDbSvc2; - + ToolHandle< ITRT_CalDbTool > m_TRTCalDbTool; + ToolHandle< ITRT_CalDbTool > m_TRTCalDbTool2; /** DetectorManager and helper */ const InDetDD::TRT_DetectorManager* m_manager{}; diff --git a/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/src/TRT_DriftFunctionTool.cxx b/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/src/TRT_DriftFunctionTool.cxx index 8ac2c340e2d2fe275757d85b3a8e7723580da49a..d76490b9b03b07f0136640cde0fae33beb595446 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/src/TRT_DriftFunctionTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftFunctionTool/src/TRT_DriftFunctionTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -22,8 +22,6 @@ #include "InDetReadoutGeometry/TRT_DetectorManager.h" #include "InDetReadoutGeometry/TRT_Numerology.h" #include "InDetReadoutGeometry/Version.h" -#include "StoreGate/ReadCondHandle.h" -#include "TRT_ConditionsServices/ITRT_CalDbSvc.h" #include "CLHEP/Units/SystemOfUnits.h" @@ -38,8 +36,8 @@ TRT_DriftFunctionTool::TRT_DriftFunctionTool(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent), - m_TRTCalDbSvc("TRT_CalDbSvc",name), - m_TRTCalDbSvc2("",name), + m_TRTCalDbTool("TRT_CalDbTool",this), + m_TRTCalDbTool2("",this), m_drifttimeperbin(3.125 * CLHEP::ns), m_error(0.17), m_drifttimeperhalfbin(0.), // set later @@ -81,8 +79,8 @@ TRT_DriftFunctionTool::TRT_DriftFunctionTool(const std::string& type, declareProperty("UniversalError",m_uni_error); declareProperty("DummyMode",m_dummy); declareProperty("ErrorFudgeFactor",m_err_fudge); - declareProperty("TRTCalDbTool", m_TRTCalDbSvc); - declareProperty("TRTCalDbTool2", m_TRTCalDbSvc2); + declareProperty("TRTCalDbTool", m_TRTCalDbTool); + declareProperty("TRTCalDbTool2", m_TRTCalDbTool2); declareProperty("DriftFunctionFile", m_inputfile); declareProperty("TrtDescrManageLocation",m_trt_mgr_location); declareProperty("ToTCorrectionsBarrelXe",m_tot_corrections_barrel_Xe); @@ -315,19 +313,19 @@ double TRT_DriftFunctionTool::driftRadius(double rawtime, Identifier id, double& { double radius = 0.; if (!m_isoverlay){ //standard case - radius = m_TRTCalDbSvc->driftRadius(crawtime,ft0,cid,isOK); + radius = m_TRTCalDbTool->driftRadius(crawtime,ft0,cid,isOK); t0=ft0 + m_t0_shift; } else{ //overlay case - radius = m_TRTCalDbSvc->driftRadius(rawtime,ft0,cid,isOK);// no m_t0_shift in rawtime, and use data TRTCalDbSvc + radius = m_TRTCalDbTool->driftRadius(rawtime,ft0,cid,isOK);// no m_t0_shift in rawtime, and use data TRTCalDbSvc t0=ft0; bool mcdigit = word & (1<<31); if (mcdigit ){ //check if it's a MC digit, and if so apply other calibration - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc gave radius: "<<radius<<", t0: "<<t0); - radius = m_TRTCalDbSvc2->driftRadius(crawtime,ft0,cid,isOK);//t0_shift in crawtime, and use MC TRTCalDbSvc(2) + ATH_MSG_DEBUG ("Overlay TRTCalDbTool gave radius: "<<radius<<", t0: "<<t0); + radius = m_TRTCalDbTool2->driftRadius(crawtime,ft0,cid,isOK);//t0_shift in crawtime, and use MC TRTCalDbSvc(2) t0=ft0 + m_t0_shift; - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc2 gives radius: "<<radius<<", t0: "<<t0); + ATH_MSG_DEBUG ("Overlay TRTCalDbTool2 gives radius: "<<radius<<", t0: "<<t0); } } double drifttime = rawtime-t0; @@ -391,17 +389,17 @@ double TRT_DriftFunctionTool::errorOfDriftRadius(double drifttime, Identifier id if(m_force_universal_errors && m_uni_error!=0) return m_uni_error; bool founderr=true; bool foundslope=true; - double error = m_TRTCalDbSvc->driftError(drifttime,id,founderr); - double slope = m_TRTCalDbSvc->driftSlope(drifttime,id,foundslope); + double error = m_TRTCalDbTool->driftError(drifttime,id,founderr); + double slope = m_TRTCalDbTool->driftSlope(drifttime,id,foundslope); bool mcdigit = word & (1<<31); if (m_isoverlay && mcdigit ){ //check if it's a MC digit, and if so apply other calibration - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc gave error: "<<error<<", found="<<founderr); - error = m_TRTCalDbSvc2->driftError(drifttime,id,founderr); - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc2 gives error: "<<error<<", found="<<founderr); - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc gave slope: "<<slope<<", found="<<foundslope); - slope = m_TRTCalDbSvc2->driftSlope(drifttime,id,foundslope); - ATH_MSG_DEBUG ("Overlay TRTCalDbSvc2 gives slope: "<<slope<<", found="<<foundslope); + ATH_MSG_DEBUG ("Overlay TRTCalDbTool gave error: "<<error<<", found="<<founderr); + error = m_TRTCalDbTool2->driftError(drifttime,id,founderr); + ATH_MSG_DEBUG ("Overlay TRTCalDbTool2 gives error: "<<error<<", found="<<founderr); + ATH_MSG_DEBUG ("Overlay TRTCalDbTool gave slope: "<<slope<<", found="<<foundslope); + slope = m_TRTCalDbTool2->driftSlope(drifttime,id,foundslope); + ATH_MSG_DEBUG ("Overlay TRTCalDbTool2 gives slope: "<<slope<<", found="<<foundslope); } if(founderr && foundslope) { @@ -459,21 +457,21 @@ void TRT_DriftFunctionTool::setupRtRelationData() //Setting up for data ATH_MSG_DEBUG(" Setting up for data "); - ATH_MSG_DEBUG(" Using TRTCalDbSvc "); - if ( m_TRTCalDbSvc.retrieve().isFailure() ) { - ATH_MSG_FATAL(m_TRTCalDbSvc.propertyName() << - ": Failed to retrieve service " << m_TRTCalDbSvc.type()); + ATH_MSG_DEBUG(" Using TRTCalDbTool "); + if ( m_TRTCalDbTool.retrieve().isFailure() ) { + ATH_MSG_FATAL(m_TRTCalDbTool.propertyName() << + ": Failed to retrieve service " << m_TRTCalDbTool.type()); return; } else { - ATH_MSG_DEBUG(m_TRTCalDbSvc.propertyName() << - ": Retrieved service " << m_TRTCalDbSvc.type()); + ATH_MSG_DEBUG(m_TRTCalDbTool.propertyName() << + ": Retrieved service " << m_TRTCalDbTool.type()); } if (m_isoverlay){ - ATH_MSG_INFO("Using TRTCalDbSvc2 for overlay ! "); - if ( m_TRTCalDbSvc2.retrieve().isFailure() ) { - ATH_MSG_FATAL(m_TRTCalDbSvc2.propertyName() <<": Failed to retrieveservice " << m_TRTCalDbSvc2.type()); + ATH_MSG_INFO("Using TRTCalDbTool2 for overlay ! "); + if ( m_TRTCalDbTool2.retrieve().isFailure() ) { + ATH_MSG_FATAL(m_TRTCalDbTool2.propertyName() <<": Failed to retrieveservice " << m_TRTCalDbTool2.type()); return; } } diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/CMakeLists.txt b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/CMakeLists.txt index c164a70c58b8c76391588bb335c37d80f16ec5dd..7e01b33a1b078131f5d3845b6d13f0d002c22cfa 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/CMakeLists.txt +++ b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/CMakeLists.txt @@ -15,6 +15,7 @@ atlas_depends_on_subdirs( PUBLIC InnerDetector/InDetRecTools/TRT_DriftFunctionTool Tracking/TrkEvent/TrkEventPrimitives Tracking/TrkTools/TrkToolInterfaces + InnerDetector/InDetConditions/TRT_ConditionsData PRIVATE Control/StoreGate DetectorDescription/Identifier @@ -36,7 +37,7 @@ atlas_add_component( TRT_ElectronPidTools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} AthenaBaseComps AthenaPoolUtilities GaudiKernel TRT_ConditionsServicesLib InDetPrepRawData TrkEventPrimitives TrkToolInterfaces Identifier InDetIdentifier InDetRawData InDetRIO_OnTrack TrkSurfaces TrkMeasurementBase TrkParameters TrkRIO_OnTrack TrkTrack ) + LINK_LIBRARIES ${CORAL_LIBRARIES} AthenaBaseComps AthenaPoolUtilities GaudiKernel TRT_ConditionsServicesLib InDetPrepRawData TrkEventPrimitives TrkToolInterfaces Identifier InDetIdentifier InDetRawData InDetRIO_OnTrack TrkSurfaces TrkMeasurementBase TrkParameters TrkRIO_OnTrack TrkTrack TRT_ConditionsData) # Install files from the package: atlas_install_headers( TRT_ElectronPidTools ) diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h index 50696480bb4866bc1fe4f61eb6972bf27effeb5f..dad3c13029b90c9e16b5ec38f7b0e61ff27a719a 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h +++ b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h @@ -14,18 +14,17 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ITHistSvc.h" #include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" - +#include "StoreGate/ReadCondHandleKey.h" #include "TrkToolInterfaces/ITRT_ElectronPidTool.h" #include "TRT_ElectronPidTools/ITRT_ElectronToTTool.h" +#include "TRT_ConditionsData/HTcalculator.h" #include "TrkEventPrimitives/ParticleHypothesis.h" #include "TRT_ElectronPidTools/ITRT_LocalOccupancy.h" -#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" -//#include "TRT_ToT_Tools/ITRT_ToT_dEdx.h" #include <vector> #include <string> @@ -39,12 +38,8 @@ namespace InDet{ class ITRT_LocalOccupancy; } +class ITRT_StrawSummaryTool; -// Troels (Sep 2014): -class ITRT_StrawSummarySvc; - - -//class IChronoStatSvc; class ITRT_ToT_dEdx; namespace Trk { @@ -106,21 +101,10 @@ namespace InDet //double GetD(double R_track) const; private: - // Update of database entries. - StatusCode update( IOVSVC_CALLBACK_ARGS ); - // - ///////////////////////////////////////////////////////////////////////////////////////////////////// - - /** Probability functions used in calculation */ - // Also used extenally by the Atlfast simulation to get pHT: - //virtual double probHT(double momentum, Trk::ParticleHypothesis, int HitPart, double HitDepth, double TrkAnodeDist, double eta, double phi); - - // //possibly used by Atlfast in the future - //virtual double probToT(double momentum, Trk::ParticleHypothesis, int ToT, double TrkAnodeDist, double eta); bool m_DATA; - //Check valid TRT straw: + //Check valid TRT straw: bool CheckGeometry(int BEC, int Layer, int Strawlayer) const; //Turn the Bitpattern into a human readable string @@ -130,28 +114,18 @@ namespace InDet int CountLTBitPattern(unsigned int bitpattern); int CountHTBitPattern(unsigned int bitpattern); - // IChronoStatSvc *m_timingProfile; - - + double inline sqr(double a) {return a*a;} const TRT_ID* m_trtId; // TRT ID helper (identifying barrel/wheels and global position) const InDetDD::TRT_DetectorManager* m_TRTdetMgr; // TRT detector manager (to get ID helper) - // StoreGateSvc* p_detstore; // Detector store. Trk::ParticleMasses m_particlemasses; // Particle masses. (initalized in default constructor) unsigned int m_minTRThits; // Minimum number of TRT hits to give PID. bool m_OccupancyUsedInPID; // DEPRECATED!!! - public: - class HTcalculator; - private: - HTcalculator & m_HTcalc; - - public: - class StorePIDinfo; - ToolHandle<ITRT_ToT_dEdx> m_TRTdEdxTool; //!< the track selector tool ToolHandle<InDet::ITRT_LocalOccupancy> m_LocalOccTool; //!< the track selector tool - ServiceHandle<ITRT_StrawStatusSummarySvc> m_TRTStrawSummarySvc; + ToolHandle<ITRT_StrawStatusSummaryTool> m_TRTStrawSummaryTool; + SG::ReadCondHandleKey<HTcalculator> m_HTReadKey{this,"HTcalculator","HTcalculator","HTcalculator in-key"}; }; } // end of namespace diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2_HTcalculation.h b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2_HTcalculation.h deleted file mode 100644 index a539b3d62c9984be4fb6d5844592a3dbf82455df..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_ElectronPidToolRun2_HTcalculation.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// TRT_ElectronPidToolRun2_HTcalculation.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -/****************************************************************************************\ - - This class is only instantiated once in the constuctor of the Pid Tool. - It was created in order to encapsulate the code that is used for - the HT calulation that forms part of the Pid Tool. - It is not true singleton as this was deemed unnecessary. - - Original creator: Simon Heisterkamp (simon.heisterkamp@cern.ch) - Author: Troels Petersen (petersen@nbi.dk) - -\****************************************************************************************/ -#include "AthenaPoolUtilities/CondAttrListVec.h" -#include "AthenaKernel/MsgStreamMember.h" -#include <vector> - -class InDet::TRT_ElectronPidToolRun2::StorePIDinfo{ - public: - StorePIDinfo(); - StorePIDinfo(int nbins, float min, float max, std::vector<float> values); - ~StorePIDinfo(); - void update (int nbins, float min, float max, std::vector<float> values ); - void push_back ( float value ); - StatusCode check ( int gas, int detpart); - float GetValue ( float input ); - float GetBinValue ( int bin ); - int GetBin ( float input ); - private: - unsigned int m_nbins ; - float m_min ; - float m_max ; - std::vector<float> m_values; -}; - - -class InDet::TRT_ElectronPidToolRun2::HTcalculator : public InDet::BaseTRTPIDCalculator { - public: - - static const int my_CurrentVersion = 4; - - HTcalculator(AthAlgTool&); - virtual ~HTcalculator(); - - // set constants to hard coded defaults - void setDefaultCalibrationConstants(); - - StatusCode ReadVectorDB( const DataHandle<CondAttrListVec> channel_values ); - - //void PrintBlob(); - //bool FillBlob(const unsigned char*); - - float getProbHT( float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkAnode, float Occupancy, bool hasTrackPars); -// float pHTvsP(int TrtPart, float p, float mass); - float pHTvsPGOG(int TrtPart, int GasType, float p, float mass, float occ); - - MsgStream& msg (MSG::Level lvl) const { return m_msg << lvl; } - bool msgLvl (MSG::Level lvl) { return m_msg.get().level() <= lvl; } - - private: - // as long has reading from database does not work well yet, do this check: - //bool HasDataBeenInitialized; - //void checkIntialization(); - - double inline sqr(double a) {return a*a;} - - static const int N_GAS = 3; - static const int N_DET = 3; - static const int N_PAR2 = 10; - StorePIDinfo m_par_pHTvsPGOG_new [N_GAS][N_DET]; // New approach (useOccupancy = true) - - -// Store in a compact way all the corrections - StorePIDinfo m_CpHT_B_Zee_SL_new [N_GAS] [N_DET]; - StorePIDinfo m_CpHT_B_Zmm_SL_new [N_GAS] [N_DET]; - - StorePIDinfo m_CpHT_B_Zee_ZR_new [N_GAS] [N_DET]; - StorePIDinfo m_CpHT_B_Zmm_ZR_new [N_GAS] [N_DET]; - - StorePIDinfo m_CpHT_B_Zee_TW_new [N_GAS] [N_DET]; - StorePIDinfo m_CpHT_B_Zmm_TW_new [N_GAS] [N_DET]; - - StorePIDinfo m_CpHT_B_Zee_OR_new [N_GAS] [N_DET]; - StorePIDinfo m_CpHT_B_Zmm_OR_new [N_GAS] [N_DET]; - - - Trk::ParticleMasses m_particlemasses; - - static const int SIZE_OF_HEADER = sizeof(float) * 4; - static const int SIZE_OF_BLOB = sizeof(float) *( (N_PAR2*N_DET)); - - bool m_datainplace; - - mutable Athena::MsgStreamMember m_msg; -}; diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_LocalOccupancy.h b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_LocalOccupancy.h index 635e72a6687317468e88d38e5dd77e4c90978b15..a6d904a2084f49338c17223988fb11025e4c8c8c 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_LocalOccupancy.h +++ b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/TRT_ElectronPidTools/TRT_LocalOccupancy.h @@ -15,21 +15,20 @@ #include "GaudiKernel/ToolHandle.h" #include "TrkTrack/Track.h" -#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" +#include "TRT_ConditionsServices/ITRT_CalDbTool.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" #include "InDetPrepRawData/TRT_DriftCircleContainer.h" -#include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" #include "SGTools/CLASS_DEF.h" #include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" #include "InDetRawData/TRT_RDO_Container.h" - +#include "TRT_ConditionsData/AliveStraws.h" #include <vector> class AtlasDetectorID; -class ITRT_StrawStatusSummarySvc ; class TRT_ID; -class ITRT_DriftFunctionTool; namespace Trk{ class Track; @@ -115,10 +114,11 @@ namespace InDet /** External tools: */ const TRT_ID *m_TRTHelper; + ToolHandle< ITRT_CalDbTool > m_CalDbTool; //!< CalDbTool + ToolHandle< ITRT_StrawStatusSummaryTool > m_StrawStatusSummaryTool; //!< StrawStatusSummaryTool SG::ReadHandleKey<TRT_RDO_Container> m_trt_rdo_location{ this, "TRT_RDOContainerName", "TRT_RDOs", "m_trt_rdo_location" }; SG::ReadHandleKey<TRT_DriftCircleContainer> m_trt_driftcircles{ this, "TRT_DriftCircleCollection", "TRT_DriftCircles", "m_trt_driftcircles" }; - ServiceHandle<ITRT_StrawStatusSummarySvc> m_TRTStrawStatusSummarySvc; - ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool; //!< DriftFunctionTool + SG::ReadCondHandleKey<TRTCond::AliveStraws> m_strawReadKey{this,"AliveStraws","AliveStraws","AliveStraws in-key"}; bool m_isTrigger; bool m_T0Shift; // choice to use T0shift or not diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2.cxx b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2.cxx index 3fbdb6abfd9fb217616ad45319c7bb1cb40342c6..e859139b26b57be2f25799ef3469145de2ffe632 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2.cxx +++ b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_ElectronPidToolRun2.cxx @@ -1,514 +1,480 @@ + /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// TRT_ElectronPidToolRun2.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - - -#include "TRT_ElectronPidTools/BaseTRTPIDCalculator.h" -#include "TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h" -#include "TRT_ElectronPidTools/TRT_ElectronPidToolRun2_HTcalculation.h" - -// StoreGate, Athena, and Database stuff: -#include "Identifier/Identifier.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "AthenaPoolUtilities/AthenaAttributeList.h" -#include "CoralBase/AttributeListSpecification.h" -#include "CoralBase/Blob.h" -#include "AthenaPoolUtilities/CondAttrListVec.h" -// Tracking: -#include "TrkTrack/Track.h" -#include "TrkTrack/TrackStateOnSurface.h" -#include "TrkMeasurementBase/MeasurementBase.h" -#include "TrkRIO_OnTrack/RIO_OnTrack.h" -#include "TrkParameters/TrackParameters.h" -#include "TrkSurfaces/Surface.h" -#include "TrkTrack/TrackInfo.h" - -// Drift circles and TRT identifiers: -#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" -#include "InDetIdentifier/TRT_ID.h" - -// ToT Tool Interface -#include "TRT_ToT_Tools/ITRT_ToT_dEdx.h" - -// Particle masses - -// Math functions: -#include <cmath> - -//STL includes -#include <sstream> - -//#define TRTDBG ATH_MSG_INFO("To line "<<__LINE__); -//#define TRTDBG 0; - -#include "TRT_ElectronPidToolRun2_HTcalculation.cxx" - - -/*****************************************************************************\ -|*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -|*%%% PID Tool Constructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -|*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -InDet::TRT_ElectronPidToolRun2::TRT_ElectronPidToolRun2(const std::string& t, const std::string& n, const IInterface* p ) - : - AthAlgTool(t,n,p), - m_trtId(nullptr), - m_TRTdetMgr(nullptr), - m_minTRThits(5), - m_HTcalc(*(new HTcalculator(*this))), - m_TRTdEdxTool("TRT_ToT_dEdx"), - m_LocalOccTool(), - m_TRTStrawSummarySvc("InDetTRTStrawStatusSummarySvc",n) -{ - declareInterface<ITRT_ElectronPidTool>(this); - declareInterface<ITRT_ElectronToTTool>(this); - declareProperty("MinimumTRThitsForIDpid", m_minTRThits); - declareProperty("TRT_ToT_dEdx_Tool", m_TRTdEdxTool); - declareProperty("TRT_LocalOccupancyTool", m_LocalOccTool); - declareProperty("isData", m_DATA = true); - declareProperty("TRTStrawSummarySvc", m_TRTStrawSummarySvc); - declareProperty("OccupancyUsedInPID", m_OccupancyUsedInPID=true); -} - - -/*****************************************************************************\ -|*%%% PID Tool Destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -InDet::TRT_ElectronPidToolRun2::~TRT_ElectronPidToolRun2() -{ - delete &m_HTcalc; -} - -/*****************************************************************************\ -|*%%% Initialisation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -StatusCode InDet::TRT_ElectronPidToolRun2::initialize() -{ - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) return sc; - - // Get the TRT Identifier-helper: - CHECK (detStore()->retrieve(m_trtId, "TRT_ID")); - - // Register callback function for cache updates - HT: - const DataHandle<CondAttrListVec> aptr;; - if (StatusCode::SUCCESS == detStore()->regFcn(&InDet::TRT_ElectronPidToolRun2::update,this, aptr, "/TRT/Calib/PID_vector" )) { - ATH_MSG_DEBUG ("Registered callback for TRT_ElectronPidToolRun2 - HT."); - } else { - ATH_MSG_ERROR ("Callback registration failed for TRT_ElectronPidToolRun2 - HT! "); - } - - /* Get the TRT_ToT_dEdx tool */ - CHECK( m_TRTdEdxTool.retrieve() ); - - CHECK( m_LocalOccTool.retrieve() ); - - CHECK( m_TRTStrawSummarySvc.retrieve() ); - if ( !m_TRTStrawSummarySvc.empty()) ATH_MSG_INFO( "Retrieved tool " << m_TRTStrawSummarySvc); - - ATH_MSG_INFO ("initialize() successful in " << name()); - return StatusCode::SUCCESS; -} - - - -/*****************************************************************************\ -|*%%% Finalisation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -StatusCode InDet::TRT_ElectronPidToolRun2::finalize() -{ - return AthAlgTool::finalize(); -} - -/* Jared - remove ToTcalc -double InDet::TRT_ElectronPidToolRun2::GetD(double R_Track)const { - R_Track=fabs(R_Track); - if(R_Track>2.) return 0; - return 2. * sqrt( 4. - R_Track * R_Track ); -} - -double InDet::TRT_ElectronPidToolRun2::GetToT(unsigned int bitpattern, double HitZ, double HitR, int BEC, int Layer, int Strawlayer)const { - return -999.99; //ToTcalc.GetToT( bitpattern, HitZ, HitR, BEC, Layer, Strawlayer); -} -*/ - -// Kept for backward compatibility. -// See TRT_ElectronPidTools-01-00-28 for the full (commented) code. -std::vector<float> InDet::TRT_ElectronPidToolRun2::electronProbability_old(const Trk::Track& track) -{ - // Simply return values without calculation - std::vector<float> PIDvalues(4); - PIDvalues[0] = 0.5; - PIDvalues[1] = 0.5; - PIDvalues[2] = 0.0; - PIDvalues[3] = 0.5; - const Trk::TrackParameters* perigee = track.perigeeParameters(); - if (!perigee) { return PIDvalues; } - return PIDvalues; -} - - -/*****************************************************************************\ -|*%%% electronProbability - The interface method during reconstruction %%%%*| -\*****************************************************************************/ - -std::vector<float> -InDet::TRT_ElectronPidToolRun2::electronProbability(const Trk::Track& track) const { - - //ATH_MSG_INFO("started electronProbabaility"); - //Initialize the return vector - std::vector<float> PIDvalues(5); - float & prob_El_Comb = PIDvalues[0] = 0.5; - float & prob_El_HT = PIDvalues[1] = 0.5; - float & prob_El_ToT = PIDvalues[2] = 0.5; - float & prob_El_Brem = PIDvalues[3] = 0.5; - float & occ_local = PIDvalues[4] = 0.0; - - // float & dEdx = PIDvalues[2] = 0.0; - float dEdx = 0.0; - - // Check for perigee: - const Trk::TrackParameters* perigee = track.perigeeParameters(); - if (!perigee) return PIDvalues; - - // Get parameters at perigee and check that they are reasonable: - const Amg::VectorX& parameterVector = perigee->parameters(); - double qOverP = parameterVector[Trk::qOverP]; - double theta = parameterVector[Trk::theta]; - double phi = parameterVector[Trk::phi]; - - // Check the parameters are reasonable: - if (tan(theta/2.0) < 0.0001) { - ATH_MSG_DEBUG (" Track has negative theta or is VERY close to beampipe! (tan(theta/2) < 0.0001). Returning default Pid values."); - return PIDvalues; - } - - if (qOverP == 0.0) { - ATH_MSG_DEBUG (" Track momentum infinite! (i.e. q/p = 0). Returning default Pid values."); - return PIDvalues; - } - - double pTrk = fabs(1.0 / qOverP); - double pT = pTrk * sin(theta); - double eta = -log(tan(theta/2.0)); - - // Check the tool to get the local occupancy (i.e. for the track in question): - occ_local = m_LocalOccTool->LocalOccupancy(track); - - ATH_MSG_DEBUG (""); - ATH_MSG_DEBUG (""); - ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); - ATH_MSG_DEBUG ("check Got track: pT: " << pT << " eta: " << eta << " phi: " << phi); - ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); - - // Jared - Development Output... - /* - std::cout << "check---------------------------------------------------------------------------------------" << std::endl; - std::cout << "check Got track: pT: " << pT << " eta: " << eta << " phi: " << phi << std::endl; - std::cout << "check---------------------------------------------------------------------------------------" << std::endl; - */ - - // For calculation of HT probability: - double pHTel_prod = 1.0; - double pHTpi_prod = 1.0; - - // ------------------------------------------------------------------------------------ - // Loop over TRT hits on track, and calculate HT and R-ToT probability: - // ------------------------------------------------------------------------------------ - - unsigned int nTRThits = 0; - unsigned int nTRThitsHTMB = 0; - - // Check for track states: - const DataVector<const Trk::TrackStateOnSurface>* recoTrackStates = track.trackStateOnSurfaces(); - if (not recoTrackStates) { - ATH_MSG_DEBUG("track.trackStateOnSurfaces() was zero"); - //m_timingProfile->chronoStop("Tool::electronProb"); - return PIDvalues; - } - - DataVector<const Trk::TrackStateOnSurface>::const_iterator tsosIter = recoTrackStates->begin(); - DataVector<const Trk::TrackStateOnSurface>::const_iterator tsosIterEnd = recoTrackStates->end(); - - // Loop over track states on surfaces (i.e. generalized hits): - for ( ; tsosIter != tsosIterEnd; ++tsosIter) { - - const Trk::MeasurementBase *measurement = (*tsosIter)->measurementOnTrack(); - if (!measurement) continue; - - // Get drift circle (ensures that hit is from TRT): - const InDet::TRT_DriftCircleOnTrack *driftcircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(measurement); - if (!driftcircle) continue; - - // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT: - bool isHTMB = ((driftcircle->prepRawData()->getWord() & 0x00020000) > 0) ? true : false; - - nTRThits++; - if (isHTMB) nTRThitsHTMB++; - - - // ------------------------------------------------------------------------------------ - // Get the necessary input for the probability calculations: - // ------------------------------------------------------------------------------------ - Identifier DCid = driftcircle->identify(); - - // Part of TRT hit belongs to (TrtPart = 0: Barrel, 1: EndcapA, 2: EndcapB). - int TrtPart = 0; // 0: Barrel, 1: EndcapA, 2: EndcapB - if (abs(m_trtId->barrel_ec(DCid)) == 2) - TrtPart = (m_trtId->layer_or_wheel(DCid) < 6) ? 1 : 2; - - // Get Straw Layer (Barrel: 0-72, EndcapA: 0-95 (16 layers in 6 modules), EndcapB: 0-63 (8 layers in 8 modules)): - int StrawLayer = 0; - if (TrtPart == 0) { - // Barrel: - if (m_trtId->layer_or_wheel(DCid) == 0) StrawLayer = m_trtId->straw_layer(DCid); - else if (m_trtId->layer_or_wheel(DCid) == 1) StrawLayer = 19 + m_trtId->straw_layer(DCid); - else StrawLayer = 19 + 24 + m_trtId->straw_layer(DCid); - } else { - // Endcap: - if (m_trtId->layer_or_wheel(DCid) < 6) StrawLayer = 16*m_trtId->layer_or_wheel(DCid) + m_trtId->straw_layer(DCid); - else StrawLayer = 8*(m_trtId->layer_or_wheel(DCid)-6) + m_trtId->straw_layer(DCid); - } - - // Get Z (Barrel) or R (Endcap) location of the hit, and distance from track to wire (i.e. anode) in straw: - double HitZ, HitR, rTrkWire; - bool hasTrackParameters= true; // Keep track of this for HT prob calculation - if ((*tsosIter)->trackParameters()) { - // If we have precise information (from hit), get that: - const Amg::Vector3D& gp = driftcircle->globalPosition(); - HitR = gp.perp(); - HitZ = gp.z(); - rTrkWire = fabs((*tsosIter)->trackParameters()->parameters()[Trk::driftRadius]); - } else { - // Otherwise just use the straw coordinates: - hasTrackParameters = false; // Jared - pass this to HT calculation - HitZ = driftcircle->associatedSurface().center().z(); - HitR = driftcircle->associatedSurface().center().perp(); - rTrkWire = 0; - } - - - // ------------------------------------------------------------------------------------ - // Collection and checks of input variables for HT probability calculation: - // ------------------------------------------------------------------------------------ - - int SL_max[3] = {73, 96, 64}; - if (StrawLayer > SL_max[TrtPart] || StrawLayer < 0) { - ATH_MSG_WARNING(" StrawLayer was outside allowed range! TrtPart = " << TrtPart << " SL = " << StrawLayer); - continue; - } - - double ZRpos[3] = {fabs(HitZ), HitR, HitR}; - double ZRpos_min[3] = { 0.0, 630.0, 630.0}; - double ZRpos_max[3] = {720.0, 1030.0, 1030.0}; - if (ZRpos[TrtPart] > ZRpos_max[TrtPart]) { - ATH_MSG_WARNING(" ZRpos was above allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]); - ZRpos[TrtPart] = ZRpos_max[TrtPart] - 0.001; - } - if (ZRpos[TrtPart] < ZRpos_min[TrtPart]) { - ATH_MSG_WARNING(" ZRpos was below allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]); - ZRpos[TrtPart] = ZRpos_min[TrtPart] + 0.001; - } - - if (rTrkWire > 2.2) rTrkWire = 2.175; // Happens once in a while - no need for warning! - - if (occ_local > 1.0 || occ_local < 0.0) { - ATH_MSG_WARNING(" Occupancy was outside allowed range! TrtPart = " << TrtPart << " Occupancy = " << occ_local); - continue; - } - - // ------------------------------------------------------------------------------------ - // Calculate the HT probability: - // ------------------------------------------------------------------------------------ - - // getStatusHT returns enum {Undefined, Dead, Good, Xenon, Argon, Krypton, EmulatedArgon, EmulatedKrypton}. - // Our representation of 'GasType' is 0:Xenon, 1:Argon, 2:Krypton - int GasType=0; // Xenon is default - if (!m_TRTStrawSummarySvc.empty()) { - int stat = m_TRTStrawSummarySvc->getStatusHT(DCid); - if ( stat==2 || stat==3 ) { GasType = 0; } // Xe - else if ( stat==1 || stat==4 ) { GasType = 1; } // Ar - else if ( stat==5 ) { GasType = 1; } // Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR - else if ( stat==6 ) { GasType = 1; } // Emulated Ar - else if ( stat==7 ) { GasType = 1; } // Emulated Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR - else { ATH_MSG_FATAL ("getStatusHT = " << stat << ", must be 'Good(2)||Xenon(3)' or 'Dead(1)||Argon(4)' or 'Krypton(5)' or 'EmulatedArgon(6)' or 'EmulatedKr(7)'!"); - throw std::exception(); - } - } - - ATH_MSG_DEBUG ("check Hit: " << nTRThits << " TrtPart: " << TrtPart << " GasType: " << GasType << " SL: " << StrawLayer - << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local << " HTMB: " << isHTMB ); - - - // Jared - Development Output... - /* - std::cout << "check Hit: " << nTRThits << " TrtPart: " << TrtPart << " GasType: " << GasType << " SL: " << StrawLayer - << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local - << " HTMB: " << isHTMB << std::endl; - */ - - // Then call pHT functions with these values: - // ------------------------------------------ - double pHTel = m_HTcalc.getProbHT( pTrk, Trk::electron, TrtPart, GasType, StrawLayer, ZRpos[TrtPart], rTrkWire, occ_local, hasTrackParameters); - double pHTpi = m_HTcalc.getProbHT( pTrk, Trk::pion, TrtPart, GasType, StrawLayer, ZRpos[TrtPart], rTrkWire, occ_local, hasTrackParameters); - - if (pHTel > 0.999 || pHTpi > 0.999 || pHTel < 0.001 || pHTpi < 0.001) { - ATH_MSG_DEBUG(" pHT outside allowed range! pHTel = " << pHTel << " pHTpi = " << pHTpi << " TrtPart: " << TrtPart << " SL: " << StrawLayer << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local); - continue; - } - - if (pHTel > 0.80 || pHTpi > 0.50 || pHTel < 0.025 || pHTpi < 0.010) { - ATH_MSG_DEBUG(" pHT has abnormal value! pHTel = " << pHTel << " pHTpi = " << pHTpi << " TrtPart: " << TrtPart << " SL: " << StrawLayer << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local); - continue; - } - - // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT: - if (isHTMB) {pHTel_prod *= pHTel; pHTpi_prod *= pHTpi;} - else {pHTel_prod *= 1.0-pHTel; pHTpi_prod *= 1.0-pHTpi;} - ATH_MSG_DEBUG ("check pHT(el): " << pHTel << " pHT(pi): " << pHTpi ); - - // Jared - Development Output... - //std::cout << "check pHT(el): " << pHTel << " pHT(pi): " << pHTpi << std::endl; - - }//of loop over hits - - - // If number of hits is adequate (default is 5 hits), calculate HT and ToT probability. - if (not (nTRThits >= m_minTRThits)) return PIDvalues; - - // Calculate electron probability (HT) - prob_El_HT = pHTel_prod / (pHTel_prod + pHTpi_prod); - - ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); - ATH_MSG_DEBUG ("check nTRThits: " << nTRThits << " : " << nTRThitsHTMB << " pHTel_prod: " << pHTel_prod << " pHTpi_prod: " << pHTpi_prod << " probEl: " << prob_El_HT); - ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); - ATH_MSG_DEBUG (""); - ATH_MSG_DEBUG (""); - - // Jared - Development Output... - /* - std::cout << "check---------------------------------------------------------------------------------------" << std::endl; - std::cout << "check nTRThits: " << nTRThits << " : " << nTRThitsHTMB << " pHTel_prod: " << pHTel_prod << " pHTpi_prod: " << pHTpi_prod << " probEl: " << prob_El_HT << std::endl; - std::cout << "check---------------------------------------------------------------------------------------" << std::endl; - std::cout << std::endl << std::endl; - */ - - // Jared - ToT Implementation - dEdx = m_TRTdEdxTool->dEdx( &track, true, false, true); // Divide by L, exclude HT hits - double usedHits = m_TRTdEdxTool->usedHits( &track, true, false); - prob_El_ToT = m_TRTdEdxTool->getTest( dEdx, pTrk, Trk::electron, Trk::pion, usedHits, true ); - - // Limit the probability values the upper and lower limits that are given/trusted for each part: - double limProbHT = m_HTcalc.Limit(prob_El_HT); - double limProbToT = m_HTcalc.Limit(prob_El_ToT); - - // Calculate the combined probability, assuming no correlations (none are expected). - prob_El_Comb = (limProbHT * limProbToT ) / ( (limProbHT * limProbToT) + ( (1.0-limProbHT) * (1.0-limProbToT)) ); - - // Troels: VERY NASTY NAMING, BUT AGREED UPON FOR NOW (for debugging, 27. NOV. 2014): - prob_El_Brem = pHTel_prod; // decorates electron LH to el brem for now... (still used?) - - //std::cout << "Prob_HT = " << prob_El_HT << " Prob_ToT = " << prob_El_ToT << " Prob_Comb = " << prob_El_Comb << std::endl; - - return PIDvalues; -} - -/* ----------------------------------------------------------------------------------- */ -// Callback function to update constants from database: -/* ----------------------------------------------------------------------------------- */ - -StatusCode InDet::TRT_ElectronPidToolRun2::update( IOVSVC_CALLBACK_ARGS_P(I,keys) ) { - - ATH_MSG_DEBUG ("Updating constants for the TRT_ElectronPidToolRun2! "); - - // Callback function to update HT onset parameter cache when condDB data changes: - for(std::list<std::string>::const_iterator key=keys.begin(); key != keys.end(); ++key) - ATH_MSG_DEBUG("IOVCALLBACK for key " << *key << " number " << I); - - // NEW reading from DB - StatusCode sc = StatusCode::SUCCESS; - ATH_MSG_INFO("HT Calculator : Reading vector format"); - - const DataHandle<CondAttrListVec> channel_values; - if (StatusCode::SUCCESS == detStore()->retrieve(channel_values, "/TRT/Calib/PID_vector" )){ - sc = m_HTcalc.ReadVectorDB( channel_values ); - } else { - ATH_MSG_ERROR ("Problem reading condDB object. HT Calculator."); - } - - return sc; -} - -/*****************************************************************************\ -|*%%% TRT straw address check, done once per hit. %%%%%%%%%%%%%%%%%%%%%%%%%*| -|*%%% Nowhere else are these numbers checked. If this is deemed %%%%%%%%%%%*| -|*%%% unnecessary it can be taken out by simply letting the function %%%%%%%*| -|*%%% return true every time %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -bool InDet::TRT_ElectronPidToolRun2::CheckGeometry(int BEC, int Layer, int StrawLayer) const { - - //first check that the BEC is valid: - if(not ( BEC==-2 || BEC ==-1 || BEC==1 || BEC==2)){ - ATH_MSG_ERROR("Found a wrong TRT part: "<<BEC<<" expected one of (-2,-1,1,2)"); - return false; - } - const int part = abs(BEC)-1; - - //next check that the layer is valid - if( Layer < 0){ - ATH_MSG_ERROR("Found a negative TRT Layer"); - return false; //must be positive - } - - static const int nlayers[2]={3,14}; - - if( not ( Layer < nlayers[part] ) ){ - ATH_MSG_ERROR("Found TRT Layer index "<<Layer<<" in part "<<BEC<<" but part only has "<<nlayers[part]<<" layers."); - return false; - } - - //and finally check that the StrawLayer is valid: - if( StrawLayer < 0){ - ATH_MSG_ERROR("Found a negative TRT StrawLayer"); - return false; //must be positive - } - - static const int strawsPerBEC[2][14]={{19,24,30, 0, 0, 0,0,0,0,0,0,0,0,0}, - {16,16,16,16,16,16,8,8,8,8,8,8,8,8}}; - - if(not(StrawLayer < strawsPerBEC[part][Layer])){ - ATH_MSG_ERROR("TRT part "<<BEC<<" Layer "<<Layer<<" only has "<<strawsPerBEC[part][Layer]<<" straws. Found index "<<StrawLayer); - return false; - } - - return true; -} - -/*****************************************************************************\ -|*%%% Auxiliary function to return the HT probability to Atlfast %%%%%%%%%%*| -|*%%% a geometry check is performed every time here %%%%%%%%%%%%%%%%%%%%%%%*| -\*****************************************************************************/ - -double InDet::TRT_ElectronPidToolRun2::probHT( const double /*pTrk*/, const Trk::ParticleHypothesis /*hypothesis*/, const int HitPart, const int Layer, const int StrawLayer) const { - if (not CheckGeometry(HitPart,Layer,StrawLayer) ){ - ATH_MSG_ERROR("TRT geometry fail. Returning default value."); - return 0.5; - } - //return m_HTcalc.getProbHT(pTrk, hypothesis, HitPart, Layer, StrawLayer); - // FIXME - return 1.0;//m_HTcalc.getProbHT(pTrk, hypothesis, HitPart, Layer, StrawLayer); -} - - -double InDet::TRT_ElectronPidToolRun2::probHTRun2( float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkWire, float Occupancy ) const { - return m_HTcalc.getProbHT( pTrk, hypothesis, TrtPart, GasType, StrawLayer, ZR, rTrkWire, Occupancy ); -} +/////////////////////////////////////////////////////////////////// +// TRT_ElectronPidToolRun2.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + + +#include "TRT_ElectronPidTools/BaseTRTPIDCalculator.h" +#include "TRT_ElectronPidTools/TRT_ElectronPidToolRun2.h" + +// StoreGate, Athena, and Database stuff: +#include "Identifier/Identifier.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/AttributeListSpecification.h" +#include "CoralBase/Blob.h" +#include "AthenaPoolUtilities/CondAttrListVec.h" +#include "StoreGate/ReadCondHandle.h" + +// Tracking: +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackStateOnSurface.h" +#include "TrkMeasurementBase/MeasurementBase.h" +#include "TrkRIO_OnTrack/RIO_OnTrack.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkSurfaces/Surface.h" +#include "TrkTrack/TrackInfo.h" + +// Drift circles and TRT identifiers: +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +#include "InDetIdentifier/TRT_ID.h" + +// ToT Tool Interface +#include "TRT_ToT_Tools/ITRT_ToT_dEdx.h" + +// Particle masses + +// Math functions: +#include <cmath> + +//STL includes +#include <sstream> + +//#define TRTDBG ATH_MSG_INFO("To line "<<__LINE__); +//#define TRTDBG 0; + +//#include "TRT_ElectronPidToolRun2_HTcalculation.cxx" + + +/*****************************************************************************\ +|*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +|*%%% PID Tool Constructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +|*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +InDet::TRT_ElectronPidToolRun2::TRT_ElectronPidToolRun2(const std::string& t, const std::string& n, const IInterface* p ) + : + AthAlgTool(t,n,p), + m_trtId(nullptr), + m_TRTdetMgr(nullptr), + m_minTRThits(5), + m_TRTdEdxTool("TRT_ToT_dEdx"), + m_LocalOccTool(), + m_TRTStrawSummaryTool("InDetTRTStrawStatusSummaryTool",this) +{ + declareInterface<ITRT_ElectronPidTool>(this); + declareInterface<ITRT_ElectronToTTool>(this); + declareProperty("MinimumTRThitsForIDpid", m_minTRThits); + declareProperty("TRT_ToT_dEdx_Tool", m_TRTdEdxTool); + declareProperty("TRT_LocalOccupancyTool", m_LocalOccTool); + declareProperty("isData", m_DATA = true); + declareProperty("TRTStrawSummaryTool", m_TRTStrawSummaryTool); + declareProperty("OccupancyUsedInPID", m_OccupancyUsedInPID=true); +} + + +/*****************************************************************************\ +|*%%% PID Tool Destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +InDet::TRT_ElectronPidToolRun2::~TRT_ElectronPidToolRun2() +{} + +/*****************************************************************************\ +|*%%% Initialisation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +StatusCode InDet::TRT_ElectronPidToolRun2::initialize() +{ + StatusCode sc = AthAlgTool::initialize(); + if (sc.isFailure()) return sc; + + // Get the TRT Identifier-helper: + CHECK (detStore()->retrieve(m_trtId, "TRT_ID")); + + /* Get the TRT_ToT_dEdx tool */ + CHECK( m_TRTdEdxTool.retrieve() ); + + CHECK( m_LocalOccTool.retrieve() ); + + ATH_CHECK( m_HTReadKey.initialize() ); + + CHECK( m_TRTStrawSummaryTool.retrieve() ); + if ( !m_TRTStrawSummaryTool.empty()) ATH_MSG_INFO( "Retrieved tool " << m_TRTStrawSummaryTool); + + ATH_MSG_INFO ("initialize() successful in " << name()); + return StatusCode::SUCCESS; +} + + + +/*****************************************************************************\ +|*%%% Finalisation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +StatusCode InDet::TRT_ElectronPidToolRun2::finalize() +{ + return AthAlgTool::finalize(); +} + +// Kept for backward compatibility. +// See TRT_ElectronPidTools-01-00-28 for the full (commented) code. +std::vector<float> InDet::TRT_ElectronPidToolRun2::electronProbability_old(const Trk::Track& track) +{ + // Simply return values without calculation + std::vector<float> PIDvalues(4); + PIDvalues[0] = 0.5; + PIDvalues[1] = 0.5; + PIDvalues[2] = 0.0; + PIDvalues[3] = 0.5; + const Trk::TrackParameters* perigee = track.perigeeParameters(); + if (!perigee) { return PIDvalues; } + return PIDvalues; +} + + +/*****************************************************************************\ +|*%%% electronProbability - The interface method during reconstruction %%%%*| +\*****************************************************************************/ + +std::vector<float> +InDet::TRT_ElectronPidToolRun2::electronProbability(const Trk::Track& track) const { + + // Get the probability calculator + SG::ReadCondHandle<HTcalculator> readHandle{m_HTReadKey}; + HTcalculator* HTcalc = const_cast<HTcalculator*>(*readHandle); + // make sure some calibration is available + if(HTcalc==nullptr) ATH_MSG_WARNING (" No Pid calibration from the DB."); + HTcalc->checkInitialization(); + + + //Initialize the return vector + std::vector<float> PIDvalues(5); + float & prob_El_Comb = PIDvalues[0] = 0.5; + float & prob_El_HT = PIDvalues[1] = 0.5; + float & prob_El_ToT = PIDvalues[2] = 0.5; + float & prob_El_Brem = PIDvalues[3] = 0.5; + float & occ_local = PIDvalues[4] = 0.0; + + float dEdx = 0.0; + + // Check for perigee: + const Trk::TrackParameters* perigee = track.perigeeParameters(); + if (!perigee) return PIDvalues; + + // Get parameters at perigee and check that they are reasonable: + const Amg::VectorX& parameterVector = perigee->parameters(); + double qOverP = parameterVector[Trk::qOverP]; + double theta = parameterVector[Trk::theta]; + double phi = parameterVector[Trk::phi]; + + // Check the parameters are reasonable: + if (tan(theta/2.0) < 0.0001) { + ATH_MSG_DEBUG (" Track has negative theta or is VERY close to beampipe! (tan(theta/2) < 0.0001). Returning default Pid values."); + return PIDvalues; + } + + if (qOverP == 0.0) { + ATH_MSG_DEBUG (" Track momentum infinite! (i.e. q/p = 0). Returning default Pid values."); + return PIDvalues; + } + + double pTrk = fabs(1.0 / qOverP); + double pT = pTrk * sin(theta); + double eta = -log(tan(theta/2.0)); + + // Check the tool to get the local occupancy (i.e. for the track in question): + occ_local = m_LocalOccTool->LocalOccupancy(track); + + ATH_MSG_DEBUG (""); + ATH_MSG_DEBUG (""); + ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); + ATH_MSG_DEBUG ("check Got track: pT: " << pT << " eta: " << eta << " phi: " << phi); + ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); + + // Jared - Development Output... + /* + std::cout << "check---------------------------------------------------------------------------------------" << std::endl; + std::cout << "check Got track: pT: " << pT << " eta: " << eta << " phi: " << phi << std::endl; + std::cout << "check---------------------------------------------------------------------------------------" << std::endl; + */ + // For calculation of HT probability: + double pHTel_prod = 1.0; + double pHTpi_prod = 1.0; + + // ------------------------------------------------------------------------------------ + // Loop over TRT hits on track, and calculate HT and R-ToT probability: + // ------------------------------------------------------------------------------------ + + unsigned int nTRThits = 0; + unsigned int nTRThitsHTMB = 0; + + + // Check for track states: + const DataVector<const Trk::TrackStateOnSurface>* recoTrackStates = track.trackStateOnSurfaces(); + if (not recoTrackStates) { + ATH_MSG_DEBUG("track.trackStateOnSurfaces() was zero"); + //m_timingProfile->chronoStop("Tool::electronProb"); + return PIDvalues; + } + + DataVector<const Trk::TrackStateOnSurface>::const_iterator tsosIter = recoTrackStates->begin(); + DataVector<const Trk::TrackStateOnSurface>::const_iterator tsosIterEnd = recoTrackStates->end(); + + // Loop over track states on surfaces (i.e. generalized hits): + for ( ; tsosIter != tsosIterEnd; ++tsosIter) { + + const Trk::MeasurementBase *measurement = (*tsosIter)->measurementOnTrack(); + if (!measurement) continue; + + // Get drift circle (ensures that hit is from TRT): + const InDet::TRT_DriftCircleOnTrack *driftcircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(measurement); + if (!driftcircle) continue; + + // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT: + bool isHTMB = ((driftcircle->prepRawData()->getWord() & 0x00020000) > 0) ? true : false; + + nTRThits++; + if (isHTMB) nTRThitsHTMB++; + + + // ------------------------------------------------------------------------------------ + // Get the necessary input for the probability calculations: + // ------------------------------------------------------------------------------------ + Identifier DCid = driftcircle->identify(); + + // Part of TRT hit belongs to (TrtPart = 0: Barrel, 1: EndcapA, 2: EndcapB). + int TrtPart = 0; // 0: Barrel, 1: EndcapA, 2: EndcapB + if (abs(m_trtId->barrel_ec(DCid)) == 2) + TrtPart = (m_trtId->layer_or_wheel(DCid) < 6) ? 1 : 2; + + // Get Straw Layer (Barrel: 0-72, EndcapA: 0-95 (16 layers in 6 modules), EndcapB: 0-63 (8 layers in 8 modules)): + int StrawLayer = 0; + if (TrtPart == 0) { + // Barrel: + if (m_trtId->layer_or_wheel(DCid) == 0) StrawLayer = m_trtId->straw_layer(DCid); + else if (m_trtId->layer_or_wheel(DCid) == 1) StrawLayer = 19 + m_trtId->straw_layer(DCid); + else StrawLayer = 19 + 24 + m_trtId->straw_layer(DCid); + } else { + // Endcap: + if (m_trtId->layer_or_wheel(DCid) < 6) StrawLayer = 16*m_trtId->layer_or_wheel(DCid) + m_trtId->straw_layer(DCid); + else StrawLayer = 8*(m_trtId->layer_or_wheel(DCid)-6) + m_trtId->straw_layer(DCid); + } + + // Get Z (Barrel) or R (Endcap) location of the hit, and distance from track to wire (i.e. anode) in straw: + double HitZ, HitR, rTrkWire; + bool hasTrackParameters= true; // Keep track of this for HT prob calculation + if ((*tsosIter)->trackParameters()) { + // If we have precise information (from hit), get that: + const Amg::Vector3D& gp = driftcircle->globalPosition(); + HitR = gp.perp(); + HitZ = gp.z(); + rTrkWire = fabs((*tsosIter)->trackParameters()->parameters()[Trk::driftRadius]); + } else { + // Otherwise just use the straw coordinates: + hasTrackParameters = false; // Jared - pass this to HT calculation + HitZ = driftcircle->associatedSurface().center().z(); + HitR = driftcircle->associatedSurface().center().perp(); + rTrkWire = 0; + } + + + // ------------------------------------------------------------------------------------ + // Collection and checks of input variables for HT probability calculation: + // ------------------------------------------------------------------------------------ + + int SL_max[3] = {73, 96, 64}; + if (StrawLayer > SL_max[TrtPart] || StrawLayer < 0) { + ATH_MSG_WARNING(" StrawLayer was outside allowed range! TrtPart = " << TrtPart << " SL = " << StrawLayer); + continue; + } + + double ZRpos[3] = {fabs(HitZ), HitR, HitR}; + double ZRpos_min[3] = { 0.0, 630.0, 630.0}; + double ZRpos_max[3] = {720.0, 1030.0, 1030.0}; + if (ZRpos[TrtPart] > ZRpos_max[TrtPart]) { + ATH_MSG_WARNING(" ZRpos was above allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]); + ZRpos[TrtPart] = ZRpos_max[TrtPart] - 0.001; + } + if (ZRpos[TrtPart] < ZRpos_min[TrtPart]) { + ATH_MSG_WARNING(" ZRpos was below allowed range - adjusted! TrtPart = " << TrtPart << " ZRpos = " << ZRpos[TrtPart]); + ZRpos[TrtPart] = ZRpos_min[TrtPart] + 0.001; + } + + if (rTrkWire > 2.2) rTrkWire = 2.175; // Happens once in a while - no need for warning! + + if (occ_local > 1.0 || occ_local < 0.0) { + ATH_MSG_WARNING(" Occupancy was outside allowed range! TrtPart = " << TrtPart << " Occupancy = " << occ_local); + continue; + } + + // ------------------------------------------------------------------------------------ + // Calculate the HT probability: + // ------------------------------------------------------------------------------------ + + // getStatusHT returns enum {Undefined, Dead, Good, Xenon, Argon, Krypton, EmulatedArgon, EmulatedKrypton}. + // Our representation of 'GasType' is 0:Xenon, 1:Argon, 2:Krypton + int GasType=0; // Xenon is default + if (!m_TRTStrawSummaryTool.empty()) { + int stat = m_TRTStrawSummaryTool->getStatusHT(DCid); + if ( stat==2 || stat==3 ) { GasType = 0; } // Xe + else if ( stat==1 || stat==4 ) { GasType = 1; } // Ar + else if ( stat==5 ) { GasType = 1; } // Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR + else if ( stat==6 ) { GasType = 1; } // Emulated Ar + else if ( stat==7 ) { GasType = 1; } // Emulated Kr -- ESTIMATED AS AR UNTIL PID IS TUNED TO HANDLE KR + else { ATH_MSG_FATAL ("getStatusHT = " << stat << ", must be 'Good(2)||Xenon(3)' or 'Dead(1)||Argon(4)' or 'Krypton(5)' or 'EmulatedArgon(6)' or 'EmulatedKr(7)'!"); + throw std::exception(); + } + } + + ATH_MSG_DEBUG ("check Hit: " << nTRThits << " TrtPart: " << TrtPart << " GasType: " << GasType << " SL: " << StrawLayer + << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local << " HTMB: " << isHTMB ); + + + // Jared - Development Output... + /* + std::cout << "check Hit: " << nTRThits << " TrtPart: " << TrtPart << " GasType: " << GasType << " SL: " << StrawLayer + << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local + << " HTMB: " << isHTMB << std::endl; + */ + + // Then call pHT functions with these values: + // ------------------------------------------ + + + double pHTel = HTcalc->getProbHT( pTrk, Trk::electron, TrtPart, GasType, StrawLayer, ZRpos[TrtPart], rTrkWire, occ_local, hasTrackParameters); + double pHTpi = HTcalc->getProbHT( pTrk, Trk::pion, TrtPart, GasType, StrawLayer, ZRpos[TrtPart], rTrkWire, occ_local, hasTrackParameters); + + if (pHTel > 0.999 || pHTpi > 0.999 || pHTel < 0.001 || pHTpi < 0.001) { + ATH_MSG_DEBUG(" pHT outside allowed range! pHTel = " << pHTel << " pHTpi = " << pHTpi << " TrtPart: " << TrtPart << " SL: " << StrawLayer << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local); + continue; + } + + if (pHTel > 0.80 || pHTpi > 0.50 || pHTel < 0.025 || pHTpi < 0.010) { + ATH_MSG_DEBUG(" pHT has abnormal value! pHTel = " << pHTel << " pHTpi = " << pHTpi << " TrtPart: " << TrtPart << " SL: " << StrawLayer << " ZRpos: " << ZRpos[TrtPart] << " TWdist: " << rTrkWire << " Occ_Local: " << occ_local); + continue; + } + + // From now (May 2015) onwards, we ONLY USE MIDDLE HT BIT: + if (isHTMB) {pHTel_prod *= pHTel; pHTpi_prod *= pHTpi;} + else {pHTel_prod *= 1.0-pHTel; pHTpi_prod *= 1.0-pHTpi;} + ATH_MSG_DEBUG ("check pHT(el): " << pHTel << " pHT(pi): " << pHTpi ); + + // Jared - Development Output... + + //std::cout << "check pHT(el): " << pHTel << " pHT(pi): " << pHTpi << std::endl; + + }//of loop over hits + + + // If number of hits is adequate (default is 5 hits), calculate HT and ToT probability. + if (not (nTRThits >= m_minTRThits)) return PIDvalues; + + // Calculate electron probability (HT) + prob_El_HT = pHTel_prod / (pHTel_prod + pHTpi_prod); + + ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); + ATH_MSG_DEBUG ("check nTRThits: " << nTRThits << " : " << nTRThitsHTMB << " pHTel_prod: " << pHTel_prod << " pHTpi_prod: " << pHTpi_prod << " probEl: " << prob_El_HT); + ATH_MSG_DEBUG ("check---------------------------------------------------------------------------------------"); + ATH_MSG_DEBUG (""); + ATH_MSG_DEBUG (""); + + // Jared - Development Output... + /* + std::cout << "check---------------------------------------------------------------------------------------" << std::endl; + std::cout << "check nTRThits: " << nTRThits << " : " << nTRThitsHTMB << " pHTel_prod: " << pHTel_prod << " pHTpi_prod: " << pHTpi_prod << " probEl: " << prob_El_HT << std::endl; + std::cout << "check---------------------------------------------------------------------------------------" << std::endl; + std::cout << std::endl << std::endl; + */ + + // Jared - ToT Implementation + dEdx = m_TRTdEdxTool->dEdx( &track, true, false, true); // Divide by L, exclude HT hits + double usedHits = m_TRTdEdxTool->usedHits( &track, true, false); + prob_El_ToT = m_TRTdEdxTool->getTest( dEdx, pTrk, Trk::electron, Trk::pion, usedHits, true ); + + // Limit the probability values the upper and lower limits that are given/trusted for each part: + double limProbHT = HTcalc->Limit(prob_El_HT); + double limProbToT = HTcalc->Limit(prob_El_ToT); + + // Calculate the combined probability, assuming no correlations (none are expected). + prob_El_Comb = (limProbHT * limProbToT ) / ( (limProbHT * limProbToT) + ( (1.0-limProbHT) * (1.0-limProbToT)) ); + + // Troels: VERY NASTY NAMING, BUT AGREED UPON FOR NOW (for debugging, 27. NOV. 2014): + prob_El_Brem = pHTel_prod; // decorates electron LH to el brem for now... (still used?) + + //std::cout << "Prob_HT = " << prob_El_HT << " Prob_ToT = " << prob_El_ToT << " Prob_Comb = " << prob_El_Comb << std::endl; + + return PIDvalues; +} + + +/*****************************************************************************\ +|*%%% TRT straw address check, done once per hit. %%%%%%%%%%%%%%%%%%%%%%%%%*| +|*%%% Nowhere else are these numbers checked. If this is deemed %%%%%%%%%%%*| +|*%%% unnecessary it can be taken out by simply letting the function %%%%%%%*| +|*%%% return true every time %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +bool InDet::TRT_ElectronPidToolRun2::CheckGeometry(int BEC, int Layer, int StrawLayer) const { + + //first check that the BEC is valid: + if(not ( BEC==-2 || BEC ==-1 || BEC==1 || BEC==2)){ + ATH_MSG_ERROR("Found a wrong TRT part: "<<BEC<<" expected one of (-2,-1,1,2)"); + return false; + } + const int part = abs(BEC)-1; + + //next check that the layer is valid + if( Layer < 0){ + ATH_MSG_ERROR("Found a negative TRT Layer"); + return false; //must be positive + } + + static const int nlayers[2]={3,14}; + + if( not ( Layer < nlayers[part] ) ){ + ATH_MSG_ERROR("Found TRT Layer index "<<Layer<<" in part "<<BEC<<" but part only has "<<nlayers[part]<<" layers."); + return false; + } + + //and finally check that the StrawLayer is valid: + if( StrawLayer < 0){ + ATH_MSG_ERROR("Found a negative TRT StrawLayer"); + return false; //must be positive + } + + static const int strawsPerBEC[2][14]={{19,24,30, 0, 0, 0,0,0,0,0,0,0,0,0}, + {16,16,16,16,16,16,8,8,8,8,8,8,8,8}}; + + if(not(StrawLayer < strawsPerBEC[part][Layer])){ + ATH_MSG_ERROR("TRT part "<<BEC<<" Layer "<<Layer<<" only has "<<strawsPerBEC[part][Layer]<<" straws. Found index "<<StrawLayer); + return false; + } + + return true; +} + +/*****************************************************************************\ +|*%%% Auxiliary function to return the HT probability to Atlfast %%%%%%%%%%*| +|*%%% a geometry check is performed every time here %%%%%%%%%%%%%%%%%%%%%%%*| +\*****************************************************************************/ + +double InDet::TRT_ElectronPidToolRun2::probHT( const double /*pTrk*/, const Trk::ParticleHypothesis /*hypothesis*/, const int HitPart, const int Layer, const int StrawLayer) const { + if (not CheckGeometry(HitPart,Layer,StrawLayer) ){ + ATH_MSG_ERROR("TRT geometry fail. Returning default value."); + return 0.5; + } + + return 1.0; +} + + +double InDet::TRT_ElectronPidToolRun2::probHTRun2( float pTrk, Trk::ParticleHypothesis hypothesis, int TrtPart, int GasType, int StrawLayer, float ZR, float rTrkWire, float Occupancy ) const { + SG::ReadCondHandle<HTcalculator> readHandle{m_HTReadKey}; + bool hasTrackPar=true; + return (*readHandle)->getProbHT( pTrk, hypothesis, TrtPart, GasType, StrawLayer, ZR, rTrkWire, Occupancy, hasTrackPar ); +} diff --git a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_LocalOccupancy.cxx b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_LocalOccupancy.cxx index aca757faf83ce6f543921e3cddd9750e6f53e804..1c7de3fd9e7c381c710eb1f314a917388d999b7f 100644 --- a/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_LocalOccupancy.cxx +++ b/InnerDetector/InDetRecTools/TRT_ElectronPidTools/src/TRT_LocalOccupancy.cxx @@ -1,3 +1,4 @@ + /* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -29,6 +30,7 @@ // ReadHandle #include "StoreGate/ReadHandle.h" +#include "StoreGate/ReadCondHandle.h" //STL includes #include <sstream> @@ -45,18 +47,17 @@ TRT_LocalOccupancy::TRT_LocalOccupancy(const std::string& t, : base_class(t,n,p), m_TRTHelper(nullptr), - m_TRTStrawStatusSummarySvc("InDetTRTStrawStatusSummarySvc", n), - m_driftFunctionTool("TRT_DriftFunctionTool") + m_CalDbTool("TRT_CalDbTool",this), + m_StrawStatusSummaryTool("TRT_StrawStatusSummaryTool",this) { - //declareProperty("isData", m_DATA = true); - declareProperty("TRTStrawSummarySvc", m_TRTStrawStatusSummarySvc); declareProperty("isTrigger", m_isTrigger = false); declareProperty("includeT0Shift", m_T0Shift = true); declareProperty("LowGate", m_lowGate = 14.0625*CLHEP::ns); declareProperty("HighGate", m_highGate = 42.1875*CLHEP::ns); declareProperty("LowWideGate", m_lowWideGate = 20.3125*CLHEP::ns); declareProperty("HighWideGate", m_highWideGate = 54.6875*CLHEP::ns); - declareProperty("TRTDriftFunctionTool", m_driftFunctionTool); + declareProperty("TRTCalDbTool", m_CalDbTool); + declareProperty("TRTStrawStatusSummaryTool", m_StrawStatusSummaryTool); } // ======================================================================= @@ -70,20 +71,23 @@ StatusCode TRT_LocalOccupancy::initialize() // The TRT helper: CHECK( detStore()->retrieve(m_TRTHelper, "TRT_ID") ); + // access to t0 and straw status if (m_T0Shift) { - CHECK( m_driftFunctionTool.retrieve() ); + CHECK( m_CalDbTool.retrieve()); } else { //use wider validity gate if no T0 shift m_lowGate = m_lowWideGate ; m_highGate = m_highWideGate ; } - CHECK ( m_TRTStrawStatusSummarySvc.retrieve() ); + CHECK( m_StrawStatusSummaryTool.retrieve()); + ATH_MSG_INFO ("initialize() successful in " << name()); //Initlalize ReadHandleKey ATH_CHECK( m_trt_rdo_location.initialize() ); ATH_CHECK( m_trt_driftcircles.initialize() ); + ATH_CHECK( m_strawReadKey.initialize() ); return StatusCode::SUCCESS; } @@ -209,8 +213,8 @@ std::map<int, double> TRT_LocalOccupancy::getDetectorOccupancy( const TRT_RDO_C Identifier rdo_id = (*r)->identify () ; //Check if straw is OK - if((m_TRTStrawStatusSummarySvc->getStatus(rdo_id) != TRTCond::StrawStatus::Good) - || (m_TRTStrawStatusSummarySvc->getStatusPermanent(rdo_id))) { + if((m_StrawStatusSummaryTool->getStatus(rdo_id) != TRTCond::StrawStatus::Good) + || (m_StrawStatusSummaryTool->getStatusPermanent(rdo_id))) { continue; } @@ -231,8 +235,7 @@ std::map<int, double> TRT_LocalOccupancy::getDetectorOccupancy( const TRT_RDO_C if(tdcvalue==7 || tdcvalue==15) mask>>=1; } if(!(tdcvalue==0 || tdcvalue==24)) { - double dummy_rawrad=0. ; bool dummy_isOK=true; - m_driftFunctionTool->driftRadius(dummy_rawrad,rdo_id,t0,dummy_isOK); + t0 = m_CalDbTool->getT0(rdo_id); } } @@ -243,7 +246,11 @@ std::map<int, double> TRT_LocalOccupancy::getDetectorOccupancy( const TRT_RDO_C } } - int* straws = m_TRTStrawStatusSummarySvc->getStwTotal(); + SG::ReadCondHandle<TRTCond::AliveStraws> strawHandle{m_strawReadKey}; + const TRTCond::AliveStraws* strawCounts{*strawHandle}; + + + int* straws = strawCounts->getStwTotal(); occResults[-1] = (double)hitCounter[-1]/(double)straws[1]; @@ -288,8 +295,8 @@ TRT_LocalOccupancy::countHitsNearTrack (OccupancyData& data, if (!*r) continue; Identifier rdo_id = (*r)->identify () ; - if((m_TRTStrawStatusSummarySvc->getStatus(rdo_id) != TRTCond::StrawStatus::Good) - || (m_TRTStrawStatusSummarySvc->getStatusPermanent(rdo_id))) { + if((m_StrawStatusSummaryTool->getStatus(rdo_id) != TRTCond::StrawStatus::Good) + || (m_StrawStatusSummaryTool->getStatusPermanent(rdo_id))) { continue; } @@ -314,9 +321,7 @@ TRT_LocalOccupancy::countHitsNearTrack (OccupancyData& data, if(tdcvalue==7 || tdcvalue==15) mask>>=1; } if(!(tdcvalue==0 || tdcvalue==24)) { - double dummy_rawrad=0. ; bool dummy_isOK=true; - m_driftFunctionTool->driftRadius(dummy_rawrad,rdo_id,t0,dummy_isOK); - // double dummy_radius = m_driftFunctionTool->driftRadius(dummy_rawrad,rdo_id,t0,dummy_isOK); + t0 = m_CalDbTool->getT0(rdo_id); } } @@ -518,9 +523,13 @@ TRT_LocalOccupancy::makeData() const ATH_MSG_WARNING("No TRT Drift Circles in StoreGate"); } + // count live straws - data->m_stw_total = m_TRTStrawStatusSummarySvc->getStwTotal(); - data->m_stw_local = m_TRTStrawStatusSummarySvc->getStwLocal(); + SG::ReadCondHandle<TRTCond::AliveStraws> strawHandle{m_strawReadKey}; + const TRTCond::AliveStraws* strawCounts{*strawHandle}; + + data->m_stw_total = strawCounts->getStwTotal(); + data->m_stw_local = strawCounts->getStwLocal(); // Calculate Occs: for (int i=0; i<NTOTAL; ++i) { @@ -550,9 +559,11 @@ std::unique_ptr<TRT_LocalOccupancy::OccupancyData> TRT_LocalOccupancy::makeDataTrigger() const { auto data = std::make_unique<OccupancyData>(); + SG::ReadCondHandle<TRTCond::AliveStraws> strawHandle{m_strawReadKey}; + const TRTCond::AliveStraws* strawCounts{*strawHandle}; - data->m_stw_local = m_TRTStrawStatusSummarySvc->getStwLocal(); - data->m_stw_wheel = m_TRTStrawStatusSummarySvc->getStwWheel(); + data->m_stw_local = strawCounts->getStwLocal(); + data->m_stw_wheel = strawCounts->getStwWheel(); for (int i=0; i<5; ++i){ for (int j=0; j<NLOCALPHI; ++j){ diff --git a/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h b/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h index c1b7b5081720e20ecd6591f9b36ef757ae7cd693..b6d9e3da08c7a7089632c9afc6a20de1f6b568c4 100644 --- a/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h +++ b/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h @@ -21,7 +21,9 @@ #include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" #include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" #include "xAODEventInfo/EventInfo.h" +#include "TRT_ConditionsData/TRTDedxcorrection.h" /* @@ -36,7 +38,7 @@ class TRT_ID; class IChronoStatSvc; -class ITRT_StrawSummarySvc; +class ITRT_StrawSummaryTool; namespace InDetDD { class TRT_DetectorManager; @@ -313,13 +315,8 @@ public: EGasType gasTypeInStraw(const InDet::TRT_DriftCircleOnTrack *driftcircle) const; private: - - /** callbacks for calibration constants DB **/ - StatusCode update(int&, std::list<std::string>&); - void update_New(std::map<std::string,std::vector<float> > &result_dict); - void update_Old(std::map<std::string,std::vector<float> > &result_dict); - StatusCode update2(int&, std::list<std::string>&); + SG::ReadCondHandleKey<TRTDedxcorrection> m_ReadKey{this,"Dedxcorrection","Dedxcorrection","Dedx constants in-key"}; /** * @brief function to compute correction factor in endcap region @@ -449,6 +446,7 @@ public: private: bool isData() const; mutable bool m_isDataSet; + }; diff --git a/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx b/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx index 63eee31608c8889d77e28716b5d9c1a9ce60a88e..0bd32f385a8d4e0738217740f2d79cb065189789 100644 --- a/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx +++ b/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx @@ -22,12 +22,9 @@ #include "TF1.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "AthenaPoolUtilities/AthenaAttributeList.h" -#include "CoralBase/AttributeListSpecification.h" -#include "AthenaPoolUtilities/CondAttrListVec.h" #include "StoreGate/DataHandle.h" #include "StoreGate/ReadHandle.h" +#include "StoreGate/ReadCondHandle.h" // constructor TRT_ToT_dEdx::TRT_ToT_dEdx(const std::string& t, const std::string& n, const IInterface* p) @@ -126,23 +123,9 @@ StatusCode TRT_ToT_dEdx::initialize() ATH_MSG_DEBUG ("Can not find ChronoStatSvc name="<<m_timingProfile ); } - const DataHandle<CondAttrListVec> aptr; - std::string folderName = {"/TRT/Calib/ToT/ToTVectors"}; - if (StatusCode::SUCCESS == detStore->regFcn(&TRT_ToT_dEdx::update,this,aptr,folderName)){ - ATH_MSG_DEBUG ("Registered callback for ToT"); - }else{ - ATH_MSG_ERROR ("Callback registration failed for /TRT/Calib/ToT/ToTVectors "); - } - - const DataHandle<CondAttrListCollection> affectedRegionH; - if (detStore->regFcn(&TRT_ToT_dEdx::update2,this,affectedRegionH,"/TRT/Calib/ToT/ToTValue").isSuccess()){ - ATH_MSG_DEBUG ( "Registered callback for /TRT/Calib/ToT/ToTValue " ); - }else{ - ATH_MSG_WARNING ( "Cannot register callback for /TRT/Calib/ToT/ToTValue " ); - } - - // Initialize ReadHandleKey + // Initialize ReadHandleKey and ReadCondHandleKey ATH_CHECK(m_eventInfoKey.initialize()); + ATH_CHECK(m_ReadKey.initialize()); //|-TRTStrawSummarySvc = ServiceHandle('InDetTRTStrawStatusSummarySvc') sc = m_TRTStrawSummarySvc.retrieve(); @@ -197,488 +180,6 @@ StatusCode TRT_ToT_dEdx::finalize() -// callback for DB for arrays -StatusCode TRT_ToT_dEdx::update(int& /*i*/ , std::list<std::string>& /*l*/) -{ - StoreGateSvc* detStore = 0; - StatusCode sc = service( "DetectorStore", detStore ); - - std::vector<std::string> dict_names = {"para_end_corrRZLXe","para_end_corrRZ_Xe","para_end_mimicToXeXe","para_long_corrRZLXe","para_long_corrRZ_Xe","para_long_mimicToXeXe","para_short_corrRZLXe","para_short_corrRZ_Xe","para_short_mimicToXeXe","resolution_Xe","resolution_e_Xe","para_end_corrRZLAr","para_end_corrRZ_Ar","para_end_mimicToXeAr","para_long_corrRZLAr","para_long_corrRZ_Ar","para_long_mimicToXeAr","para_short_corrRZLAr","para_short_corrRZ_Ar","para_short_mimicToXeAr","resolution_Ar","resolution_e_Ar","para_end_corrRZLKr","para_end_corrRZ_Kr","para_end_mimicToXeKr","para_long_corrRZLKr","para_long_corrRZ_Kr","para_long_mimicToXeKr","para_short_corrRZLKr","para_short_corrRZ_Kr","para_short_mimicToXeKr","resolution_Kr","resolution_e_Kr"}; - std::map<std::string,std::vector<float> > result_dict; - - const DataHandle<CondAttrListVec> channel_values; - - if (StatusCode::SUCCESS == detStore->retrieve(channel_values, "/TRT/Calib/ToT/ToTVectors" )) - { - int dataBaseType = kNewDB; - ATH_MSG_DEBUG("update():: dict_names[]="<<dict_names.size()<<", channel_values[]="<<channel_values->size()<<""); - if(channel_values->size()<19695) - dataBaseType = kOldDB; - - if(dataBaseType==kNewDB) - { - CondAttrListVec::const_iterator first_channel = channel_values->begin(); - CondAttrListVec::const_iterator last_channel = channel_values->end(); - - unsigned int current_channel = 0; - std::vector<float> current_array_values = {}; - - for (; first_channel != last_channel; ++first_channel) { - if (current_channel != first_channel->first){ - result_dict[dict_names[current_channel]] = current_array_values; - current_channel = first_channel->first; - current_array_values.clear(); - } - current_array_values.push_back(first_channel->second["array_value"].data<float>()); - } - - result_dict[dict_names[current_channel]] = current_array_values; - - update_New(result_dict); - ATH_MSG_DEBUG ("update():: Reading new database is done!"); - - return StatusCode::SUCCESS; - - } else - if(dataBaseType==kOldDB) - { - ATH_MSG_WARNING ("update():: Old COOL database tag!"); - - std::vector<std::string> dict_names_old = {"resolution","resolution_e","para_long_corrRZ_MC","para_short_corrRZ_MC","para_end_corrRZ_MC","para_long_corrRZL_MC","para_short_corrRZL_MC","para_end_corrRZL_MC"}; - - CondAttrListVec::const_iterator first_channel = channel_values->begin(); - CondAttrListVec::const_iterator last_channel = channel_values->end(); - - unsigned int current_channel = 0; - std::vector<float> current_array_values = {}; - - for (; first_channel != last_channel; ++first_channel) - { - if (current_channel != first_channel->first) - { - result_dict[dict_names_old[current_channel]] = current_array_values; - current_channel = first_channel->first; - current_array_values.clear(); - } - current_array_values.push_back(first_channel->second["array_value"].data<float>()); - } - - result_dict[dict_names_old[current_channel]] = current_array_values; - - update_Old(result_dict); - ATH_MSG_DEBUG ("update():: Reading old database is done!"); - - return StatusCode::SUCCESS; - } - else { - ATH_MSG_ERROR ("Problem reading condDB object. dataBaseType="<<dataBaseType<<""); - return StatusCode::FAILURE; - } - } - else { - ATH_MSG_ERROR ("Problem reading condDB object. -"); - return StatusCode::FAILURE; - } -} - - - -void TRT_ToT_dEdx::update_New(std::map<std::string,std::vector<float> > &result_dict) -{ - // fill Xenon +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution[0][ind]=result_dict["resolution_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution_e[0][ind]=result_dict["resolution_e_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ_MC[0][ind]=result_dict["para_long_corrRZ_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ_MC[0][ind]=result_dict["para_short_corrRZ_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_MC[0][ind]=result_dict["para_long_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_MC[0][ind]=result_dict["para_short_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_MC[0][ind]=result_dict["para_end_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ[0][ind]=result_dict["para_long_corrRZ_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ[0][ind]=result_dict["para_short_corrRZ_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_DATA[0][ind]=result_dict["para_long_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_DATA[0][ind]=result_dict["para_short_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_DATA[0][ind]=result_dict["para_end_corrRZLXe"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ[0][ind]=result_dict["para_end_corrRZ_Xe"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ_MC[0][ind]=result_dict["para_end_corrRZ_Xe"][ind]; - } - - - - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_DATA[0][ind]=result_dict["para_end_mimicToXeXe"][ind]; - } - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_MC[0][ind]=result_dict["para_end_mimicToXeXe"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_DATA[0][ind]=result_dict["para_short_mimicToXeXe"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_MC[0][ind]=result_dict["para_short_mimicToXeXe"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_DATA[0][ind]=result_dict["para_long_mimicToXeXe"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_MC[0][ind]=result_dict["para_long_mimicToXeXe"][ind]; - } - - // fill Argon +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution[1][ind]=result_dict["resolution_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution_e[1][ind]=result_dict["resolution_e_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ_MC[1][ind]=result_dict["para_long_corrRZ_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ_MC[1][ind]=result_dict["para_short_corrRZ_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_MC[1][ind]=result_dict["para_long_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_MC[1][ind]=result_dict["para_short_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_MC[1][ind]=result_dict["para_end_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ[1][ind]=result_dict["para_long_corrRZ_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ[1][ind]=result_dict["para_short_corrRZ_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_DATA[1][ind]=result_dict["para_long_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_DATA[1][ind]=result_dict["para_short_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_DATA[1][ind]=result_dict["para_end_corrRZLAr"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ[1][ind]=result_dict["para_end_corrRZ_Ar"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ_MC[1][ind]=result_dict["para_end_corrRZ_Ar"][ind]; - } - - - - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_DATA[1][ind]=result_dict["para_end_mimicToXeAr"][ind]; - } - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_MC[1][ind]=result_dict["para_end_mimicToXeAr"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_DATA[1][ind]=result_dict["para_short_mimicToXeAr"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_MC[1][ind]=result_dict["para_short_mimicToXeAr"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_DATA[1][ind]=result_dict["para_long_mimicToXeAr"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_MC[1][ind]=result_dict["para_long_mimicToXeAr"][ind]; - } - - // fill Krypton +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution[2][ind]=result_dict["resolution_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution_e[2][ind]=result_dict["resolution_e_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ_MC[2][ind]=result_dict["para_long_corrRZ_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ_MC[2][ind]=result_dict["para_short_corrRZ_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_MC[2][ind]=result_dict["para_long_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_MC[2][ind]=result_dict["para_short_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_MC[2][ind]=result_dict["para_end_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ[2][ind]=result_dict["para_long_corrRZ_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ[2][ind]=result_dict["para_short_corrRZ_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_DATA[2][ind]=result_dict["para_long_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_DATA[2][ind]=result_dict["para_short_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_DATA[2][ind]=result_dict["para_end_corrRZLKr"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ[2][ind]=result_dict["para_end_corrRZ_Kr"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ_MC[2][ind]=result_dict["para_end_corrRZ_Kr"][ind]; - } - - - - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_DATA[2][ind]=result_dict["para_end_mimicToXeKr"][ind]; - } - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_MC[2][ind]=result_dict["para_end_mimicToXeKr"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_DATA[2][ind]=result_dict["para_short_mimicToXeKr"][ind]; - } - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_MC[2][ind]=result_dict["para_short_mimicToXeKr"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_DATA[2][ind]=result_dict["para_long_mimicToXeKr"][ind]; - } - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_MC[2][ind]=result_dict["para_long_mimicToXeKr"][ind]; - } -} - - - -void TRT_ToT_dEdx::update_Old(std::map<std::string,std::vector<float> > &result_dict) -{ - for(int gasType = 0; gasType<3; gasType++) { // loop over gas types - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution[gasType][ind]=result_dict["resolution"][ind]; - } - - for (unsigned int ind=0; ind < 4; ++ind) { - Dedxcorrection::resolution_e[gasType][ind]=result_dict["resolution_e"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ_MC[gasType][ind]=result_dict["para_long_corrRZ_MC"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ_MC[gasType][ind]=result_dict["para_short_corrRZ_MC"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_MC[gasType][ind]=result_dict["para_long_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_MC[gasType][ind]=result_dict["para_short_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_MC[gasType][ind]=result_dict["para_end_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 3240; ++ind) { - Dedxcorrection::para_long_corrRZ[gasType][ind]=result_dict["para_long_corrRZ_MC"][ind]; - } - - for (unsigned int ind=0; ind < 216; ++ind) { - Dedxcorrection::para_short_corrRZ[gasType][ind]=result_dict["para_short_corrRZ_MC"][ind]; - } - - for (unsigned int ind=0; ind < 630; ++ind) { - Dedxcorrection::para_long_corrRZL_DATA[gasType][ind]=result_dict["para_long_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 63; ++ind) { - Dedxcorrection::para_short_corrRZL_DATA[gasType][ind]=result_dict["para_short_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 252; ++ind) { - Dedxcorrection::para_end_corrRZL_DATA[gasType][ind]=result_dict["para_end_corrRZL_MC"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ[gasType][ind]=result_dict["para_end_corrRZ_MC"][ind]; - } - - for (unsigned int ind=0; ind < 336; ++ind) { - Dedxcorrection::para_end_corrRZ_MC[gasType][ind]=result_dict["para_end_corrRZ_MC"][ind]; - } - - // Setting aditional corrections - for (unsigned int ind=0; ind < 560; ++ind) { - Dedxcorrection::para_end_mimicToXe_MC[gasType][ind] = 1.; - Dedxcorrection::para_end_mimicToXe_DATA[gasType][ind] = 1.; - } - - for (unsigned int ind=0; ind < 180; ++ind) { - Dedxcorrection::para_short_mimicToXe_MC[gasType][ind] = 1.; - Dedxcorrection::para_short_mimicToXe_DATA[gasType][ind] = 1.; - } - - for (unsigned int ind=0; ind < 1800; ++ind) { - Dedxcorrection::para_long_mimicToXe_MC[gasType][ind] = 1.; - Dedxcorrection::para_long_mimicToXe_DATA[gasType][ind] = 1.; - } - } -} - - - -// callback for DB for scalar values -StatusCode TRT_ToT_dEdx::update2(int& /*i*/, std::list<std::string>& /*l*/ ) -{ - const CondAttrListCollection* attrListColl = 0; - StoreGateSvc* detStore = 0; - StatusCode sc = service( "DetectorStore", detStore ); - - if (StatusCode::SUCCESS == detStore->retrieve(attrListColl, "/TRT/Calib/ToT/ToTValue" )) - { - int dataBaseType = kNewDB; - if(attrListColl->size() < 2) dataBaseType = kOldDB; - - CondAttrListCollection::const_iterator first = attrListColl->begin(); - CondAttrListCollection::const_iterator last = attrListColl->end(); - - if(dataBaseType==kNewDB) - { - for (int index=0; first != last; ++first,++index) - { - const coral::AttributeList& attrList = (*first).second; - Dedxcorrection::paraL_dEdx_p1[index] = attrList["paraL_dEdx_p1"].data<float>(); - Dedxcorrection::paraL_dEdx_p2[index] = attrList["paraL_dEdx_p2"].data<float>(); - Dedxcorrection::paraL_dEdx_p3[index] = attrList["paraL_dEdx_p3"].data<float>(); - Dedxcorrection::paraL_dEdx_p4[index] = attrList["paraL_dEdx_p4"].data<float>(); - Dedxcorrection::paraL_dEdx_p5[index] = attrList["paraL_dEdx_p5"].data<float>(); - - Dedxcorrection::para_dEdx_p1[index] = attrList["para_dEdx_p1"].data<float>(); - Dedxcorrection::para_dEdx_p2[index] = attrList["para_dEdx_p2"].data<float>(); - Dedxcorrection::para_dEdx_p3[index] = attrList["para_dEdx_p3"].data<float>(); - Dedxcorrection::para_dEdx_p4[index] = attrList["para_dEdx_p4"].data<float>(); - Dedxcorrection::para_dEdx_p5[index] = attrList["para_dEdx_p5"].data<float>(); - - Dedxcorrection::norm_offset_data[index] = attrList["norm_offset_data"].data<float>(); - Dedxcorrection::norm_slope_tot[index] = attrList["norm_slope_tot"].data<float>(); - Dedxcorrection::norm_slope_totl[index] = attrList["norm_slope_totl"].data<float>(); - Dedxcorrection::norm_offset_tot[index] = attrList["norm_offset_tot"].data<float>(); - Dedxcorrection::norm_offset_totl[index] = attrList["norm_offset_totl"].data<float>(); - Dedxcorrection::norm_nzero[index]=attrList["norm_nzero"].data<int>(); - } - } - else - { - ATH_MSG_WARNING ("update2():: Old COOL database tag!"); - // return update2_Old(); - for (; first != last; ++first) { - const coral::AttributeList& attrList = (*first).second; - for(int gasType=0; gasType<3; gasType++) - { - Dedxcorrection::paraL_dEdx_p1[gasType] = attrList["paraL_dEdx_p1"].data<float>(); - Dedxcorrection::paraL_dEdx_p2[gasType] = attrList["paraL_dEdx_p2"].data<float>(); - Dedxcorrection::paraL_dEdx_p3[gasType] = attrList["paraL_dEdx_p3"].data<float>(); - Dedxcorrection::paraL_dEdx_p4[gasType] = attrList["paraL_dEdx_p4"].data<float>(); - Dedxcorrection::paraL_dEdx_p5[gasType] = attrList["paraL_dEdx_p5"].data<float>(); - - Dedxcorrection::para_dEdx_p1[gasType] = attrList["para_dEdx_p1"].data<float>(); - Dedxcorrection::para_dEdx_p2[gasType] = attrList["para_dEdx_p2"].data<float>(); - Dedxcorrection::para_dEdx_p3[gasType] = attrList["para_dEdx_p3"].data<float>(); - Dedxcorrection::para_dEdx_p4[gasType] = attrList["para_dEdx_p4"].data<float>(); - Dedxcorrection::para_dEdx_p5[gasType] = attrList["para_dEdx_p5"].data<float>(); - - Dedxcorrection::norm_offset_data[gasType] = attrList["norm_offset_data"].data<float>(); - Dedxcorrection::norm_slope_tot[gasType] = attrList["norm_slope_tot"].data<float>(); - Dedxcorrection::norm_slope_totl[gasType] = attrList["norm_slope_totl"].data<float>(); - Dedxcorrection::norm_offset_tot[gasType] = attrList["norm_offset_tot"].data<float>(); - Dedxcorrection::norm_offset_totl[gasType] = attrList["norm_offset_totl"].data<float>(); - Dedxcorrection::norm_nzero[gasType]=attrList["norm_nzero"].data<int>(); - } - } - } - } else { - ATH_MSG_ERROR ("Problem reading condDB object. -"); - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} - - bool TRT_ToT_dEdx::isGood_Hit(const Trk::TrackStateOnSurface *itr) const { @@ -1057,6 +558,15 @@ double TRT_ToT_dEdx::getProb(EGasType gasType, const double dEdx_obs, const doub ATH_MSG_DEBUG("getProb():: gasTypeInStraw = "<<gasType<<""); + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" getProb: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + + if(gasType==kUnset) { ATH_MSG_DEBUG("getProb():: gasTypeInStraw set kUnset that is not allowed! Use gasTypeInStraw(*itr) to get gas type info for that hit first!"); @@ -1073,9 +583,9 @@ double TRT_ToT_dEdx::getProb(EGasType gasType, const double dEdx_obs, const doub dEdx_pred= dEdx_pred/correct; } - double Resolution = Dedxcorrection::resolution[gasType][0]+Dedxcorrection::resolution[gasType][1]*(nUsedHits+0.5)+Dedxcorrection::resolution[gasType][2]*(nUsedHits+0.5)*(nUsedHits+0.5)+Dedxcorrection::resolution[gasType][3]*(nUsedHits+0.5)*(nUsedHits+0.5)*(nUsedHits+0.5); + double Resolution = Dedxcorrection->resolution[gasType][0]+Dedxcorrection->resolution[gasType][1]*(nUsedHits+0.5)+Dedxcorrection->resolution[gasType][2]*(nUsedHits+0.5)*(nUsedHits+0.5)+Dedxcorrection->resolution[gasType][3]*(nUsedHits+0.5)*(nUsedHits+0.5)*(nUsedHits+0.5); if(hypothesis==Trk::electron){ - Resolution = Dedxcorrection::resolution_e[gasType][0]+Dedxcorrection::resolution_e[gasType][1]*(nUsedHits+0.5)+Dedxcorrection::resolution_e[gasType][2]*(nUsedHits+0.5)*(nUsedHits+0.5)+Dedxcorrection::resolution_e[gasType][3]*(nUsedHits+0.5)*(nUsedHits+0.5)*(nUsedHits+0.5); + Resolution = Dedxcorrection->resolution_e[gasType][0]+Dedxcorrection->resolution_e[gasType][1]*(nUsedHits+0.5)+Dedxcorrection->resolution_e[gasType][2]*(nUsedHits+0.5)*(nUsedHits+0.5)+Dedxcorrection->resolution_e[gasType][3]*(nUsedHits+0.5)*(nUsedHits+0.5)*(nUsedHits+0.5); } double prob =exp( -0.5 * ( ( ( dEdx_obs - dEdx_pred ) / (Resolution*dEdx_pred) ) * @@ -1129,6 +639,14 @@ double TRT_ToT_dEdx::predictdEdx(EGasType gasType, const double pTrk, Trk::Parti ATH_MSG_DEBUG("predictdEdx(): gasTypeInStraw = "<<gasType<<""); + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" predictdEdx: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + if(gasType==kUnset) { ATH_MSG_DEBUG("predictdEdx():: gasTypeInStraw set kUnset that is not allowed! Use gasTypeInStraw(*itr) to get gas type info for that hit first!"); @@ -1145,15 +663,15 @@ double TRT_ToT_dEdx::predictdEdx(EGasType gasType, const double pTrk, Trk::Parti // do we want to throw an assertion here? if(pTrk<100)return 0; if(divideByL){ - if(Dedxcorrection::paraL_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection::paraL_dEdx_p5[gasType]))<=0) return 0; - return Dedxcorrection::paraL_dEdx_p1[gasType]/std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection::paraL_dEdx_p4[gasType]) * - (Dedxcorrection::paraL_dEdx_p2[gasType] - std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection::paraL_dEdx_p4[gasType] ) - - log(Dedxcorrection::paraL_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection::paraL_dEdx_p5[gasType]) ) ) ); + if(Dedxcorrection->paraL_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection->paraL_dEdx_p5[gasType]))<=0) return 0; + return Dedxcorrection->paraL_dEdx_p1[gasType]/std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection->paraL_dEdx_p4[gasType]) * + (Dedxcorrection->paraL_dEdx_p2[gasType] - std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection->paraL_dEdx_p4[gasType] ) + - log(Dedxcorrection->paraL_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection->paraL_dEdx_p5[gasType]) ) ) ); }else { - if(Dedxcorrection::para_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection::para_dEdx_p5[gasType]) )<=0)return 0; - return Dedxcorrection::para_dEdx_p1[gasType]/std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection::para_dEdx_p4[gasType]) * - (Dedxcorrection::para_dEdx_p2[gasType] - std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection::para_dEdx_p4[gasType] ) - - log(Dedxcorrection::para_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection::para_dEdx_p5[gasType]) ) ) ); + if(Dedxcorrection->para_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection->para_dEdx_p5[gasType]) )<=0)return 0; + return Dedxcorrection->para_dEdx_p1[gasType]/std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection->para_dEdx_p4[gasType]) * + (Dedxcorrection->para_dEdx_p2[gasType] - std::pow( sqrt( (betaGamma*betaGamma)/(1.+(betaGamma*betaGamma)) ), Dedxcorrection->para_dEdx_p4[gasType] ) + - log(Dedxcorrection->para_dEdx_p3[gasType]+1./( std::pow( betaGamma, Dedxcorrection->para_dEdx_p5[gasType]) ) ) ); } //return 0; } @@ -1166,6 +684,14 @@ double TRT_ToT_dEdx::mass(const Trk::TrackStateOnSurface *itr, const double pTrk ATH_MSG_DEBUG("mass(): gasTypeInStraw = "<<gasType<<""); + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" mass: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + if(gasType==kUnset) { ATH_MSG_WARNING("mass():: gasTypeInStraw set kUnset that is not allowed! Use gasTypeInStraw(*itr) to get gas type info for that hit first!"); @@ -1183,8 +709,8 @@ double TRT_ToT_dEdx::mass(const Trk::TrackStateOnSurface *itr, const double pTrk TF1 blumRolandi( "BR", blumRolandiFunction.c_str(), 0.7, 100000); - blumRolandi.SetParameters(Dedxcorrection::para_dEdx_p1[gasType],Dedxcorrection::para_dEdx_p2[gasType],Dedxcorrection::para_dEdx_p3[gasType],Dedxcorrection::para_dEdx_p4[gasType],Dedxcorrection::para_dEdx_p5[gasType], 1. ); - //blumRolandi.SetParameters(&Dedxcorrection::para_dEdx_BB); + blumRolandi.SetParameters(Dedxcorrection->para_dEdx_p1[gasType],Dedxcorrection->para_dEdx_p2[gasType],Dedxcorrection->para_dEdx_p3[gasType],Dedxcorrection->para_dEdx_p4[gasType],Dedxcorrection->para_dEdx_p5[gasType], 1. ); + //blumRolandi.SetParameters(&Dedxcorrection->para_dEdx_BB); double betaGamma = blumRolandi.GetX(dEdx, bg_min, bg_max); ATH_MSG_DEBUG("mass():: return "<<pTrk/betaGamma<<""); @@ -1253,19 +779,28 @@ double TRT_ToT_dEdx::getToT(unsigned int BitPattern) const double TRT_ToT_dEdx::correctNormalization(bool divideLength,bool scaledata, double nVtx) const { + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" correctNormalization: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + + EGasType gasType = static_cast<EGasType> (m_useTrackPartWithGasType); if(m_useTrackPartWithGasType==kUnset) gasType=kXenon; - if(nVtx<=0)nVtx=Dedxcorrection::norm_nzero[gasType]; - double slope = Dedxcorrection::norm_slope_tot[gasType]; - double offset = Dedxcorrection::norm_offset_tot[gasType]; + if(nVtx<=0)nVtx=Dedxcorrection->norm_nzero[gasType]; + double slope = Dedxcorrection->norm_slope_tot[gasType]; + double offset = Dedxcorrection->norm_offset_tot[gasType]; if(divideLength){ - slope = Dedxcorrection::norm_slope_tot[gasType]; - offset = Dedxcorrection::norm_offset_tot[gasType]; + slope = Dedxcorrection->norm_slope_tot[gasType]; + offset = Dedxcorrection->norm_offset_tot[gasType]; } - double shift = Dedxcorrection::norm_offset_data[gasType]; + double shift = Dedxcorrection->norm_offset_data[gasType]; if(!scaledata)shift = 0; - return (slope*Dedxcorrection::norm_nzero[gasType]+offset)/(slope*nVtx+offset+shift); + return (slope*Dedxcorrection->norm_nzero[gasType]+offset)/(slope*nVtx+offset+shift); } @@ -1569,6 +1104,14 @@ double TRT_ToT_dEdx::fitFuncBarrelShort_corrRZ(EGasType gasType, double driftRad double TRT_ToT_dEdx::fitFuncPol_corrRZ(EGasType gasType, int parameter, double driftRadius, int Layer, int Strawlayer, int sign, int set) const { + + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" fitFuncPol_corrRZ: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } double a = 0; double b = 0; @@ -1584,55 +1127,55 @@ double TRT_ToT_dEdx::fitFuncPol_corrRZ(EGasType gasType, int parameter, double d //int parId=0; //parId=0; //if(sign>0)parId=1620; // FIXME: parId is not used - a = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+0)*30*3+Layer*30+Strawlayer+offset]; - b = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+1)*30*3+Layer*30+Strawlayer+offset]; - c = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+2)*30*3+Layer*30+Strawlayer+offset]; - d = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+3)*30*3+Layer*30+Strawlayer+offset]; - e = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+4)*30*3+Layer*30+Strawlayer+offset]; - f = Dedxcorrection::para_long_corrRZ[gasType][(6*parameter+5)*30*3+Layer*30+Strawlayer+offset]; + a = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+0)*30*3+Layer*30+Strawlayer+offset]; + b = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+1)*30*3+Layer*30+Strawlayer+offset]; + c = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+2)*30*3+Layer*30+Strawlayer+offset]; + d = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+3)*30*3+Layer*30+Strawlayer+offset]; + e = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+4)*30*3+Layer*30+Strawlayer+offset]; + f = Dedxcorrection->para_long_corrRZ[gasType][(6*parameter+5)*30*3+Layer*30+Strawlayer+offset]; }else if (set ==1) { // short straws in barrel if(sign > 0) offset+=108; - a = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+0)*9+Layer+offset]; - b = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+1)*9+Layer+offset]; - c = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+2)*9+Layer+offset]; - d = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+3)*9+Layer+offset]; - e = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+4)*9+Layer+offset]; - f = Dedxcorrection::para_short_corrRZ[gasType][(6*parameter+5)*9+Layer+offset]; + a = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+0)*9+Layer+offset]; + b = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+1)*9+Layer+offset]; + c = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+2)*9+Layer+offset]; + d = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+3)*9+Layer+offset]; + e = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+4)*9+Layer+offset]; + f = Dedxcorrection->para_short_corrRZ[gasType][(6*parameter+5)*9+Layer+offset]; }else{ // straws in endcap if(sign >0) Layer+=14; - a = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+0)*28+Layer]; - b = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+1)*28+Layer]; - c = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+2)*28+Layer]; - d = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+3)*28+Layer]; - e = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+4)*28+Layer]; - f = Dedxcorrection::para_end_corrRZ[gasType][(6*parameter+5)*28+Layer]; + a = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+0)*28+Layer]; + b = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+1)*28+Layer]; + c = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+2)*28+Layer]; + d = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+3)*28+Layer]; + e = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+4)*28+Layer]; + f = Dedxcorrection->para_end_corrRZ[gasType][(6*parameter+5)*28+Layer]; } }else{ if(set==0){ // long straws in barrel if(sign > 0) offset=1620; - a = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+0)*30*3+Layer*30+Strawlayer+offset]; - b = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+1)*30*3+Layer*30+Strawlayer+offset]; - c = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+2)*30*3+Layer*30+Strawlayer+offset]; - d = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+3)*30*3+Layer*30+Strawlayer+offset]; - e = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+4)*30*3+Layer*30+Strawlayer+offset]; - f = Dedxcorrection::para_long_corrRZ_MC[gasType][(6*parameter+5)*30*3+Layer*30+Strawlayer+offset]; + a = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+0)*30*3+Layer*30+Strawlayer+offset]; + b = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+1)*30*3+Layer*30+Strawlayer+offset]; + c = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+2)*30*3+Layer*30+Strawlayer+offset]; + d = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+3)*30*3+Layer*30+Strawlayer+offset]; + e = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+4)*30*3+Layer*30+Strawlayer+offset]; + f = Dedxcorrection->para_long_corrRZ_MC[gasType][(6*parameter+5)*30*3+Layer*30+Strawlayer+offset]; }else if (set ==1) { // short straws in barrel if(sign > 0) offset+=108; - a = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+0)*9+Layer+offset]; - b = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+1)*9+Layer+offset]; - c = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+2)*9+Layer+offset]; - d = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+3)*9+Layer+offset]; - e = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+4)*9+Layer+offset]; - f = Dedxcorrection::para_short_corrRZ_MC[gasType][(6*parameter+5)*9+Layer+offset]; + a = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+0)*9+Layer+offset]; + b = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+1)*9+Layer+offset]; + c = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+2)*9+Layer+offset]; + d = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+3)*9+Layer+offset]; + e = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+4)*9+Layer+offset]; + f = Dedxcorrection->para_short_corrRZ_MC[gasType][(6*parameter+5)*9+Layer+offset]; }else{ // straws in endcap if(sign >0) Layer+=14; - a = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+0)*28+Layer]; - b = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+1)*28+Layer]; - c = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+2)*28+Layer]; - d = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+3)*28+Layer]; - e = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+4)*28+Layer]; - f = Dedxcorrection::para_end_corrRZ_MC[gasType][(6*parameter+5)*28+Layer]; + a = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+0)*28+Layer]; + b = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+1)*28+Layer]; + c = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+2)*28+Layer]; + d = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+3)*28+Layer]; + e = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+4)*28+Layer]; + f = Dedxcorrection->para_end_corrRZ_MC[gasType][(6*parameter+5)*28+Layer]; } } return a+b*r+c*r*r+d*r*r*r+e*r*r*r*r+f*r*r*r*r*r; @@ -1645,29 +1188,37 @@ double TRT_ToT_dEdx::fitFuncEndcap_corrRZL(EGasType gasType, double driftRadius, * T(r,R) = T0(r)+ a(r)*R */ + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" fitFuncEndcap_corrRZL: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + double r = fabs(driftRadius); double a,b,c,d,e,f,g,h,i; if(sign >0) Layer+=14; if(isData()){ - a = Dedxcorrection::para_end_corrRZL_DATA[gasType][(0)*28+Layer]; - b = Dedxcorrection::para_end_corrRZL_DATA[gasType][(1)*28+Layer]; - c = Dedxcorrection::para_end_corrRZL_DATA[gasType][(2)*28+Layer]; - d = Dedxcorrection::para_end_corrRZL_DATA[gasType][(3)*28+Layer]; - e = Dedxcorrection::para_end_corrRZL_DATA[gasType][(4)*28+Layer]; - f = Dedxcorrection::para_end_corrRZL_DATA[gasType][(5)*28+Layer]; - g = Dedxcorrection::para_end_corrRZL_DATA[gasType][(6)*28+Layer]; - h = Dedxcorrection::para_end_corrRZL_DATA[gasType][(7)*28+Layer]; - i = Dedxcorrection::para_end_corrRZL_DATA[gasType][(8)*28+Layer]; + a = Dedxcorrection->para_end_corrRZL_DATA[gasType][(0)*28+Layer]; + b = Dedxcorrection->para_end_corrRZL_DATA[gasType][(1)*28+Layer]; + c = Dedxcorrection->para_end_corrRZL_DATA[gasType][(2)*28+Layer]; + d = Dedxcorrection->para_end_corrRZL_DATA[gasType][(3)*28+Layer]; + e = Dedxcorrection->para_end_corrRZL_DATA[gasType][(4)*28+Layer]; + f = Dedxcorrection->para_end_corrRZL_DATA[gasType][(5)*28+Layer]; + g = Dedxcorrection->para_end_corrRZL_DATA[gasType][(6)*28+Layer]; + h = Dedxcorrection->para_end_corrRZL_DATA[gasType][(7)*28+Layer]; + i = Dedxcorrection->para_end_corrRZL_DATA[gasType][(8)*28+Layer]; }else{ - a = Dedxcorrection::para_end_corrRZL_MC[gasType][(0)*28+Layer]; - b = Dedxcorrection::para_end_corrRZL_MC[gasType][(1)*28+Layer]; - c = Dedxcorrection::para_end_corrRZL_MC[gasType][(2)*28+Layer]; - d = Dedxcorrection::para_end_corrRZL_MC[gasType][(3)*28+Layer]; - e = Dedxcorrection::para_end_corrRZL_MC[gasType][(4)*28+Layer]; - f = Dedxcorrection::para_end_corrRZL_MC[gasType][(5)*28+Layer]; - g = Dedxcorrection::para_end_corrRZL_MC[gasType][(6)*28+Layer]; - h = Dedxcorrection::para_end_corrRZL_MC[gasType][(7)*28+Layer]; - i = Dedxcorrection::para_end_corrRZL_MC[gasType][(8)*28+Layer]; + a = Dedxcorrection->para_end_corrRZL_MC[gasType][(0)*28+Layer]; + b = Dedxcorrection->para_end_corrRZL_MC[gasType][(1)*28+Layer]; + c = Dedxcorrection->para_end_corrRZL_MC[gasType][(2)*28+Layer]; + d = Dedxcorrection->para_end_corrRZL_MC[gasType][(3)*28+Layer]; + e = Dedxcorrection->para_end_corrRZL_MC[gasType][(4)*28+Layer]; + f = Dedxcorrection->para_end_corrRZL_MC[gasType][(5)*28+Layer]; + g = Dedxcorrection->para_end_corrRZL_MC[gasType][(6)*28+Layer]; + h = Dedxcorrection->para_end_corrRZL_MC[gasType][(7)*28+Layer]; + i = Dedxcorrection->para_end_corrRZL_MC[gasType][(8)*28+Layer]; } double T1 = b*r+c*r*r+d*r*r*r+e*r*r*r*r+f*r*r*r*r*r; @@ -1683,45 +1234,52 @@ double TRT_ToT_dEdx::fitFuncBarrel_corrRZL(EGasType gasType, double driftRadius, /* * T(r,z) = T0(r)+ b(r)*z*z */ + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" fitFuncBarrel_corrRZL: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } double a,b,c,d,e,f,g; if(Layer==0 && Strawlayer<9){ // short straws if(isData()){ - a = Dedxcorrection::para_short_corrRZL_DATA[gasType][(0)*9+Strawlayer]; - b = Dedxcorrection::para_short_corrRZL_DATA[gasType][(1)*9+Strawlayer]; - c = Dedxcorrection::para_short_corrRZL_DATA[gasType][(2)*9+Strawlayer]; - d = Dedxcorrection::para_short_corrRZL_DATA[gasType][(3)*9+Strawlayer]; - e = Dedxcorrection::para_short_corrRZL_DATA[gasType][(4)*9+Strawlayer]; - f = Dedxcorrection::para_short_corrRZL_DATA[gasType][(5)*9+Strawlayer]; - g = Dedxcorrection::para_short_corrRZL_DATA[gasType][(6)*9+Strawlayer]; + a = Dedxcorrection->para_short_corrRZL_DATA[gasType][(0)*9+Strawlayer]; + b = Dedxcorrection->para_short_corrRZL_DATA[gasType][(1)*9+Strawlayer]; + c = Dedxcorrection->para_short_corrRZL_DATA[gasType][(2)*9+Strawlayer]; + d = Dedxcorrection->para_short_corrRZL_DATA[gasType][(3)*9+Strawlayer]; + e = Dedxcorrection->para_short_corrRZL_DATA[gasType][(4)*9+Strawlayer]; + f = Dedxcorrection->para_short_corrRZL_DATA[gasType][(5)*9+Strawlayer]; + g = Dedxcorrection->para_short_corrRZL_DATA[gasType][(6)*9+Strawlayer]; }else{ - a = Dedxcorrection::para_short_corrRZL_MC[gasType][(0)*9+Strawlayer]; - b = Dedxcorrection::para_short_corrRZL_MC[gasType][(1)*9+Strawlayer]; - c = Dedxcorrection::para_short_corrRZL_MC[gasType][(2)*9+Strawlayer]; - d = Dedxcorrection::para_short_corrRZL_MC[gasType][(3)*9+Strawlayer]; - e = Dedxcorrection::para_short_corrRZL_MC[gasType][(4)*9+Strawlayer]; - f = Dedxcorrection::para_short_corrRZL_MC[gasType][(5)*9+Strawlayer]; - g = Dedxcorrection::para_short_corrRZL_MC[gasType][(6)*9+Strawlayer]; + a = Dedxcorrection->para_short_corrRZL_MC[gasType][(0)*9+Strawlayer]; + b = Dedxcorrection->para_short_corrRZL_MC[gasType][(1)*9+Strawlayer]; + c = Dedxcorrection->para_short_corrRZL_MC[gasType][(2)*9+Strawlayer]; + d = Dedxcorrection->para_short_corrRZL_MC[gasType][(3)*9+Strawlayer]; + e = Dedxcorrection->para_short_corrRZL_MC[gasType][(4)*9+Strawlayer]; + f = Dedxcorrection->para_short_corrRZL_MC[gasType][(5)*9+Strawlayer]; + g = Dedxcorrection->para_short_corrRZL_MC[gasType][(6)*9+Strawlayer]; } }else{ if(isData()){ - a = Dedxcorrection::para_long_corrRZL_DATA[gasType][(0)*30*3+Layer*30+Strawlayer]; - b = Dedxcorrection::para_long_corrRZL_DATA[gasType][(1)*30*3+Layer*30+Strawlayer]; - c = Dedxcorrection::para_long_corrRZL_DATA[gasType][(2)*30*3+Layer*30+Strawlayer]; - d = Dedxcorrection::para_long_corrRZL_DATA[gasType][(3)*30*3+Layer*30+Strawlayer]; - e = Dedxcorrection::para_long_corrRZL_DATA[gasType][(4)*30*3+Layer*30+Strawlayer]; - f = Dedxcorrection::para_long_corrRZL_DATA[gasType][(5)*30*3+Layer*30+Strawlayer]; - g = Dedxcorrection::para_long_corrRZL_DATA[gasType][(6)*30*3+Layer*30+Strawlayer]; + a = Dedxcorrection->para_long_corrRZL_DATA[gasType][(0)*30*3+Layer*30+Strawlayer]; + b = Dedxcorrection->para_long_corrRZL_DATA[gasType][(1)*30*3+Layer*30+Strawlayer]; + c = Dedxcorrection->para_long_corrRZL_DATA[gasType][(2)*30*3+Layer*30+Strawlayer]; + d = Dedxcorrection->para_long_corrRZL_DATA[gasType][(3)*30*3+Layer*30+Strawlayer]; + e = Dedxcorrection->para_long_corrRZL_DATA[gasType][(4)*30*3+Layer*30+Strawlayer]; + f = Dedxcorrection->para_long_corrRZL_DATA[gasType][(5)*30*3+Layer*30+Strawlayer]; + g = Dedxcorrection->para_long_corrRZL_DATA[gasType][(6)*30*3+Layer*30+Strawlayer]; }else{ - a = Dedxcorrection::para_long_corrRZL_MC[gasType][(0)*30*3+Layer*30+Strawlayer]; - b = Dedxcorrection::para_long_corrRZL_MC[gasType][(1)*30*3+Layer*30+Strawlayer]; - c = Dedxcorrection::para_long_corrRZL_MC[gasType][(2)*30*3+Layer*30+Strawlayer]; - d = Dedxcorrection::para_long_corrRZL_MC[gasType][(3)*30*3+Layer*30+Strawlayer]; - e = Dedxcorrection::para_long_corrRZL_MC[gasType][(4)*30*3+Layer*30+Strawlayer]; - f = Dedxcorrection::para_long_corrRZL_MC[gasType][(5)*30*3+Layer*30+Strawlayer]; - g = Dedxcorrection::para_long_corrRZL_MC[gasType][(6)*30*3+Layer*30+Strawlayer]; + a = Dedxcorrection->para_long_corrRZL_MC[gasType][(0)*30*3+Layer*30+Strawlayer]; + b = Dedxcorrection->para_long_corrRZL_MC[gasType][(1)*30*3+Layer*30+Strawlayer]; + c = Dedxcorrection->para_long_corrRZL_MC[gasType][(2)*30*3+Layer*30+Strawlayer]; + d = Dedxcorrection->para_long_corrRZL_MC[gasType][(3)*30*3+Layer*30+Strawlayer]; + e = Dedxcorrection->para_long_corrRZL_MC[gasType][(4)*30*3+Layer*30+Strawlayer]; + f = Dedxcorrection->para_long_corrRZL_MC[gasType][(5)*30*3+Layer*30+Strawlayer]; + g = Dedxcorrection->para_long_corrRZL_MC[gasType][(6)*30*3+Layer*30+Strawlayer]; } } double z = fabs(zPosition); @@ -1979,6 +1537,15 @@ int TRT_ToT_dEdx::TrailingEdge_v3(unsigned int BitPattern) const double TRT_ToT_dEdx::mimicToXeHit_Endcap(EGasType gasType, double driftRadius, int Layer, int sign) const { + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" mimicToXeHit_Endcap: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + + double r = fabs(driftRadius); double a; @@ -1994,9 +1561,9 @@ double TRT_ToT_dEdx::mimicToXeHit_Endcap(EGasType gasType, double driftRadius, i int side = 0; // A side if(sign <0) side =1; // C side if(isData()) - a = Dedxcorrection::para_end_mimicToXe_DATA[gasType][(side*14+Layer)*20+(rBin)]; + a = Dedxcorrection->para_end_mimicToXe_DATA[gasType][(side*14+Layer)*20+(rBin)]; else - a = Dedxcorrection::para_end_mimicToXe_MC[gasType][(side*14+Layer)*20+(rBin)]; + a = Dedxcorrection->para_end_mimicToXe_MC[gasType][(side*14+Layer)*20+(rBin)]; ATH_MSG_DEBUG("mimicToXeHit_Endcap():: isData = " << isData() << " gasTypeInStraw = " << gasType << " side = " << side << " Layer = " << Layer << " rBin = " << rBin <<" BINPOS = " << (side*14+Layer)*20+(rBin) @@ -2007,6 +1574,15 @@ double TRT_ToT_dEdx::mimicToXeHit_Endcap(EGasType gasType, double driftRadius, i double TRT_ToT_dEdx::mimicToXeHit_Barrel(EGasType gasType, double driftRadius, int Layer, int Strawlayer) const { + + SG::ReadCondHandle<TRTDedxcorrection> readHandle{m_ReadKey}; + const TRTDedxcorrection* Dedxcorrection{*readHandle}; + if(Dedxcorrection==nullptr) + { + ATH_MSG_ERROR(" mimicToXeHit_Barrel: Could not find any Dedxcorrection in CondStore. Return zero."); + return 0; + } + double r = fabs(driftRadius); double a; @@ -2021,14 +1597,14 @@ double TRT_ToT_dEdx::mimicToXeHit_Barrel(EGasType gasType, double driftRadius, i if(Layer==0 && Strawlayer<9){ // short straws if(isData()) - a = Dedxcorrection::para_short_mimicToXe_DATA[gasType][Strawlayer*20+(rBin)]; + a = Dedxcorrection->para_short_mimicToXe_DATA[gasType][Strawlayer*20+(rBin)]; else - a = Dedxcorrection::para_short_mimicToXe_MC[gasType][Strawlayer*20+(rBin)]; + a = Dedxcorrection->para_short_mimicToXe_MC[gasType][Strawlayer*20+(rBin)]; }else{ if(isData()) - a = Dedxcorrection::para_long_mimicToXe_DATA[gasType][Layer*30*20+Strawlayer*20+(rBin)]; + a = Dedxcorrection->para_long_mimicToXe_DATA[gasType][Layer*30*20+Strawlayer*20+(rBin)]; else - a = Dedxcorrection::para_long_mimicToXe_MC[gasType][Layer*30*20+Strawlayer*20+(rBin)]; + a = Dedxcorrection->para_long_mimicToXe_MC[gasType][Layer*30*20+Strawlayer*20+(rBin)]; } ATH_MSG_DEBUG("mimicToXeHit_Barrel():: isData = " << isData() << " Layer = " << Layer << " Strawlayer = " << Strawlayer << " rBin = " << rBin << " a = " << a << "" ); diff --git a/Reconstruction/egamma/egammaAlgs/python/EMBremCollectionBuilder.py b/Reconstruction/egamma/egammaAlgs/python/EMBremCollectionBuilder.py index ba1341fc1159ed198955c0ba16d068c013e89e4a..9f486b387a82d8d2684f7ebdebf257b48f64dc6f 100644 --- a/Reconstruction/egamma/egammaAlgs/python/EMBremCollectionBuilder.py +++ b/Reconstruction/egamma/egammaAlgs/python/EMBremCollectionBuilder.py @@ -107,27 +107,34 @@ class egammaBremCollectionBuilder ( egammaAlgsConf.EMBremCollectionBuilder ) : GSFBuildTRT_ElectronPidTool = None if DetFlags.haveRIO.TRT_on() and not InDetFlags.doSLHC() and not InDetFlags.doHighPileup() : - isMC = False - if globalflags.DataSource == "geant4" : - isMC = True - from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool - InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool(name = "InDetTRT_DriftFunctionTool", - IsMC = isMC) - ToolSvc += InDetTRT_DriftFunctionTool - + + # Calibration DB Service + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool + InDetTRTCalDbTool = TRT_CalDbTool(name = "TRT_CalDbTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + # Straw status DB Tool + from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool + InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(name = "TRT_StrawStatusSummaryTool", + isGEANT4=(globalflags.DataSource == 'geant4')) + from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy GSFBuildTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(name ="GSF_TRT_LocalOccupancy", - TRTDriftFunctionTool = InDetTRT_DriftFunctionTool) + isTrigger = False, + TRTCalDbTool = InDetTRTCalDbTool, + TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool ) + ToolSvc += GSFBuildTRT_LocalOccupancy from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2 GSFBuildTRT_ElectronPidTool = InDet__TRT_ElectronPidToolRun2(name = "GSFBuildTRT_ElectronPidTool", TRT_LocalOccupancyTool = GSFBuildTRT_LocalOccupancy, + TRTStrawSummaryTool = InDetTRTStrawStatusSummaryTool, isData = (globalflags.DataSource == 'data') ) ToolSvc += GSFBuildTRT_ElectronPidTool + # # Configurable version of PixelToTPIDTOol #