Verified Commit ae292d11 authored by Tadej Novak's avatar Tadej Novak
Browse files

TGC Digitization: Implementation of signal propagation time between the sensor edge and ASD

parent 2170101f
Pipeline #3026689 passed with stage
in 0 seconds
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TGCDIGITASDPOSCONDALG_H
#define TGCDIGITASDPOSCONDALG_H
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "AthenaPoolUtilities/CondAttrListCollection.h"
#include "GaudiKernel/ICondSvc.h"
#include "MuonCondData/TgcDigitASDposData.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/WriteCondHandleKey.h"
class TgcDigitASDposCondAlg : public AthReentrantAlgorithm
{
public:
TgcDigitASDposCondAlg (const std::string& name, ISvcLocator* pSvcLocator);
virtual ~TgcDigitASDposCondAlg() = default;
virtual StatusCode initialize() override;
virtual StatusCode execute(const EventContext& ctx) const override;
private:
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_ASDpos{this, "ReadKeyAsdPos", "/TGC/DIGIT/ASDPOS", "SG key for TGCDIGITASDPOS"};
SG::WriteCondHandleKey<TgcDigitASDposData> m_writeKey{this, "WriteKey", "TGCDigitASDposData", "SG Key of TGCDigit AsdPos"};
ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"};
};
#endif
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonCondAlg/TgcDigitASDposCondAlg.h"
#include "MuonCondSvc/MdtStringUtils.h"
#include "StoreGate/ReadCondHandle.h"
#include "StoreGate/WriteCondHandle.h"
#include "CoralBase/Blob.h"
TgcDigitASDposCondAlg::TgcDigitASDposCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm(name, pSvcLocator)
{}
StatusCode TgcDigitASDposCondAlg::initialize()
{
ATH_MSG_DEBUG("initialize " << name());
ATH_CHECK(m_condSvc.retrieve());
ATH_CHECK(m_readKey_ASDpos.initialize());
ATH_CHECK(m_writeKey.initialize());
if(m_condSvc->regHandle(this, m_writeKey).isFailure()) {
ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc");
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
StatusCode TgcDigitASDposCondAlg::execute(const EventContext& ctx) const
{
SG::WriteCondHandle<TgcDigitASDposData> writeHandle{m_writeKey, ctx};
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;
}
SG::ReadCondHandle<CondAttrListCollection> readHandle_ASDpos{m_readKey_ASDpos, ctx};
if (readHandle_ASDpos.cptr() == nullptr) {
ATH_MSG_ERROR("Null pointer to the read conditions object");
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Size of CondAttrListCollection" << readHandle_ASDpos.fullKey() << " = " << readHandle_ASDpos->size());
EventIDRange rangeW_ASDpos;
if (!readHandle_ASDpos.range(rangeW_ASDpos)) {
ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandle_ASDpos.key());
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Range of input is " << rangeW_ASDpos);
// write condition object
EventIDRange rangeIntersection = EventIDRange::intersect(rangeW_ASDpos);
if(rangeIntersection.start()>rangeIntersection.stop()) {
ATH_MSG_ERROR("Invalid intersection range: " << rangeIntersection);
return StatusCode::FAILURE;
}
// Fill
auto outputCdo = std::make_unique<TgcDigitASDposData>();
outputCdo->asdPos.assign(TgcDigitASDposData::N_STRIPASDPOS + TgcDigitASDposData::N_WIREASDPOS, std::vector<float>(readHandle_ASDpos->size(), 0));
size_t dbLine{};
std::string delimiter{";"};
for(const auto &[channel, attribute] : *readHandle_ASDpos.cptr()) {
const coral::Blob& blob = attribute["bASDPos"].data<coral::Blob>();
const char *blobCStr = reinterpret_cast<const char *>(blob.startingAddress());
std::string blobline(blobCStr);
std::vector<std::string> tokens;
MuonCalib::MdtStringUtils::tokenize(blobline, tokens, delimiter);
auto it = std::begin(tokens);
outputCdo->stationNum.push_back(stoi(*it));
++it;
outputCdo->stationEta.push_back(stoi(*it));
++it;
outputCdo->stationPhi.push_back(stoi(*it));
for(int i=0;i<TgcDigitASDposData::N_STRIPASDPOS;i++){
++it;
outputCdo->asdPos[i][dbLine] = stof(*it);
}
for(int i=0;i<TgcDigitASDposData::N_WIREASDPOS;i++){
++it;
outputCdo->asdPos[i + (int)TgcDigitASDposData::N_STRIPASDPOS][dbLine] = stof(*it);
}
dbLine += 1;
} // end of for(attrmap)
// Record
if (writeHandle.record(rangeIntersection, std::move(outputCdo)).isFailure()) {
ATH_MSG_FATAL("Could not record TgcDigitASDposData " << writeHandle.key()
<< " with EventRange " << rangeIntersection
<< " into Conditions Store");
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("recorded new " << writeHandle.key() << " with range " << rangeIntersection << " into Conditions Store");
return StatusCode::SUCCESS;
}
......@@ -6,6 +6,7 @@
#include "MuonCondAlg/MuonAlignmentErrorDbAlg.h"
#include "MuonCondAlg/RpcCondDbAlg.h"
#include "MuonCondAlg/TgcCondDbAlg.h"
#include "MuonCondAlg/TgcDigitASDposCondAlg.h"
DECLARE_COMPONENT(CscCondDbAlg)
DECLARE_COMPONENT(MdtCondDbAlg)
......@@ -15,3 +16,4 @@ DECLARE_COMPONENT(MuonAlignmentErrorDbAlg)
DECLARE_COMPONENT(MuonAlignmentCondAlg)
DECLARE_COMPONENT(MdtCalibDbAlg)
DECLARE_COMPONENT(MdtCalibFormatAlgTest)
DECLARE_COMPONENT(TgcDigitASDposCondAlg)
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TGCDIGITASDPOSDATA_H
#define TGCDIGITASDPOSDATA_H
#include "AthenaKernel/BaseInfo.h"
#include "AthenaKernel/CLASS_DEF.h"
#include <vector>
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Contents of TGC_Digitization_AsdPosition.db *
* ================================================================== *
* |1|2|3|4|5|6|7|8|9|10|11|12|13| *
* *
* 1 -- station number(unsigned short) -> 41~48 *
* 2 -- station eta(unsigned short) -> 1~5 *
* 3 -- station phi(short) -> BW is -99, EI is 1~21, FI is 1~24 *
* 4~5 -- strip ASD position coordinate(float) *
* 6~13 -- Wire ASD position coordinate(float) *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class TgcDigitASDposData
{
public:
TgcDigitASDposData();
virtual ~TgcDigitASDposData() = default;
enum {
N_WIREASDPOS=8,
N_STRIPASDPOS=2,
N_CHANNELINPUT_TOASD=16
};
std::vector<unsigned short> stationNum;
std::vector<unsigned short> stationEta;
std::vector<short> stationPhi;
std::vector<std::vector<float>> asdPos;
};
CLASS_DEF(TgcDigitASDposData, 54799429, 1)
#include "AthenaKernel/CondCont.h"
CLASS_DEF(CondCont<TgcDigitASDposData>, 50515203, 1)
#endif // TGCDIGITASDPOSDATA_H
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonCondData/TgcDigitASDposData.h"
TgcDigitASDposData::TgcDigitASDposData()
{}
......@@ -29,4 +29,3 @@ DECLARE_COMPONENT( RPC_STATUSConditionsSvc )
DECLARE_COMPONENT( RPC_DCSConditionsSvc )
DECLARE_COMPONENT( TriggerCoolSvc )
DECLARE_COMPONENT( TGC_STATUSConditionsSvc )
......@@ -150,4 +150,8 @@ def CscCondDbAlgCfg(flags, **kwargs):
### return result
def TgcDigitASDposCondAlgCfg(flags):
result = ComponentAccumulator()
result.addCondAlgo(CompFactory.TgcDigitASDposCondAlg())
result.merge(addFolders(flags, ["/TGC/DIGIT/ASDPOS"] , detDb="TGC_OFL", className="CondAttrListCollection"))
return result
......@@ -46,6 +46,12 @@ def TGC_DigitizationToolCfg(flags, name="TgcDigitizationTool", **kwargs):
kwargs.setdefault("OutputSDOName", flags.Overlay.BkgPrefix + "TGC_SDO")
else:
kwargs.setdefault("OutputSDOName", "TGC_SDO")
if flags.Digitization.UseUpdatedTGCConditions:
from MuonConfig.MuonCondAlgConfig import TgcDigitASDposCondAlgCfg
acc.merge(TgcDigitASDposCondAlgCfg(flags))
kwargs.setdefault("TGCDigitASDposKey", "TGCDigitASDposData")
TgcDigitizationTool = CompFactory.TgcDigitizationTool
acc.setPrivateTools(TgcDigitizationTool(name, **kwargs))
return acc
......@@ -57,6 +63,12 @@ def TGC_OverlayDigitizationToolCfg(flags, name="Tgc_OverlayDigitizationTool", **
kwargs.setdefault("OnlyUseContainerName", False)
kwargs.setdefault("OutputObjectName", flags.Overlay.SigPrefix + "TGC_DIGITS")
kwargs.setdefault("OutputSDOName", flags.Overlay.SigPrefix + "TGC_SDO")
if flags.Digitization.UseUpdatedTGCConditions:
from MuonConfig.MuonCondAlgConfig import TgcDigitASDposCondAlgCfg
acc.merge(TgcDigitASDposCondAlgCfg(flags))
kwargs.setdefault("TGCDigitASDposKey", "TGCDigitASDposData")
TgcDigitizationTool = CompFactory.TgcDigitizationTool
acc.setPrivateTools(TgcDigitizationTool(name, **kwargs))
return acc
......
......@@ -15,7 +15,7 @@ atlas_add_component( TGC_Digitization
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel PileUpToolsLib GeoPrimitives Identifier GaudiKernel MuonSimEvent HitManagement xAODEventInfo GeneratorObjects MuonReadoutGeometry MuonDigitContainer MuonIdHelpersLib MuonSimData PathResolver RDBAccessSvcLib )
LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel PileUpToolsLib GeoPrimitives Identifier GaudiKernel MuonSimEvent HitManagement xAODEventInfo GeneratorObjects MuonCondData MuonReadoutGeometry MuonDigitContainer MuonIdHelpersLib MuonSimData PathResolver RDBAccessSvcLib )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
......
......@@ -13,6 +13,14 @@ def TGC_FirstXing():
def TGC_LastXing():
return 75
def setupTgcDigitASDposCondAlg():
from AthenaCommon.AlgSequence import AthSequencer
condSequence = AthSequencer("AthCondSeq")
if not hasattr(condSequence, "TgcDigitASDposCondAlg"):
from IOVDbSvc.CondDB import conddb
conddb.addFolder("TGC_OFL", "/TGC/DIGIT/ASDPOS", className='CondAttrListCollection')
condSequence += CfgMgr.TgcDigitASDposCondAlg("TgcDigitASDposCondAlg")
def TgcDigitizationTool(name="TgcDigitizationTool", **kwargs):
if jobproperties.Digitization.doXingByXingPileUp(): # PileUpTool approach
# This should match the range for the TGC in Simulation/Digitization/share/MuonDigitization.py
......@@ -26,6 +34,11 @@ def TgcDigitizationTool(name="TgcDigitizationTool", **kwargs):
else:
kwargs.setdefault("OutputSDOName", "TGC_SDO")
from Digitization.DigitizationFlags import digitizationFlags
if digitizationFlags.UseUpdatedTGCConditions():
setupTgcDigitASDposCondAlg()
kwargs.setdefault("TGCDigitASDposKey", "TGCDigitASDposData")
return CfgMgr.TgcDigitizationTool(name, **kwargs)
def getTgcRange(name="TgcRange", **kwargs):
......@@ -46,6 +59,12 @@ def Tgc_OverlayDigitizationTool(name="Tgc_OverlayDigitizationTool", **kwargs):
kwargs.setdefault("OutputObjectName",overlayFlags.evtStore()+"+TGC_DIGITS")
if not overlayFlags.isDataOverlay():
kwargs.setdefault("OutputSDOName",overlayFlags.evtStore()+"+TGC_SDO")
from Digitization.DigitizationFlags import digitizationFlags
if digitizationFlags.UseUpdatedTGCConditions():
setupTgcDigitASDposCondAlg()
kwargs.setdefault("TGCDigitASDposKey", "TGCDigitASDposData")
return TgcDigitizationTool(name,**kwargs)
def getTGC_OverlayDigitizer(name="TGC_OverlayDigitizer", **kwargs):
......
41 1 0 1 16 -5
42 1 0 1 16 -6
42 2 0 1 16 -4.5
42 3 0 1 16 -5
42 4 0 1 16 -8
43 1 0 1 16 -5
44 1 0 1 16 -6
44 2 0 1 16 -6
44 3 0 1 16 -6
44 4 0 1 16 -6
44 5 0 1 16 -6
45 1 0 1 16 -5
46 1 0 1 16 -6
46 2 0 1 16 -6
46 3 0 1 16 -6
46 4 0 1 16 -6
46 5 0 1 16 -6
47 1 0 1 16 -6
48 1 0 1 16 -8
41 -1 0 1 16 -5
42 -1 0 1 16 -6
42 -2 0 1 16 -4.5
42 -3 0 1 16 -6
42 -4 0 1 16 -8
43 -1 0 1 16 -5
44 -1 0 1 16 -6
44 -2 0 1 16 -6
44 -3 0 1 16 -6
44 -4 0 1 16 -6
44 -5 0 1 16 -6
45 -1 0 1 16 -5
46 -1 0 1 16 -6
46 -2 0 1 16 -6
46 -3 0 1 16 -6
46 -4 0 1 16 -6
46 -5 0 1 16 -6
47 -1 0 1 16 -6
48 -1 0 1 16 -8
41 1 0 2 32 -5
42 1 0 2 32 -6
42 2 0 2 32 -4.5
42 3 0 2 32 -5
42 4 0 2 32 -8
43 1 0 2 32 -5
44 1 0 2 32 -6
44 2 0 2 32 -6
44 3 0 2 32 -6
44 4 0 2 32 -6
44 5 0 2 32 -6
45 1 0 2 32 -5
46 1 0 2 32 -6
46 2 0 2 32 -6
46 3 0 2 32 -6
46 4 0 2 32 -6
46 5 0 2 32 -6
47 1 0 2 32 -7
48 1 0 2 32 -9
41 -1 0 2 32 -5
42 -1 0 2 32 -6
42 -2 0 2 32 -4.5
42 -3 0 2 32 -5
42 -4 0 2 32 -8
43 -1 0 2 32 -5
44 -1 0 2 32 -6
44 -2 0 2 32 -6
44 -3 0 2 32 -6
44 -4 0 2 32 -6
44 -5 0 2 32 -6
45 -1 0 2 32 -5
46 -1 0 2 32 -6
46 -2 0 2 32 -6
46 -3 0 2 32 -6
46 -4 0 2 32 -6
46 -5 0 2 32 -6
47 -1 0 2 32 -7
48 -1 0 2 32 -9
41 1 0 3 48 -5
42 1 0 3 48 -6
42 2 0 3 48 -4.5
43 1 0 3 48 -5
44 1 0 3 48 -6
44 2 0 3 48 -6
45 1 0 3 48 -5
46 1 0 3 48 -6
46 2 0 3 48 -6
41 -1 0 3 48 -5
42 -1 0 3 48 -6
42 -2 0 3 48 -4.5
43 -1 0 3 48 -5
44 -1 0 3 48 -6
44 -2 0 3 48 -6
45 -1 0 3 48 -5
46 -1 0 3 48 -6
46 -2 0 3 48 -6
41 1 0 4 64 -5
42 1 0 4 64 -6
42 2 0 4 64 -4.5
43 1 0 4 64 -5
44 1 0 4 64 -6
44 2 0 4 64 -6
45 1 0 4 64 -5
46 1 0 4 64 -6
46 2 0 4 64 -6
41 -1 0 4 64 -5
42 -1 0 4 64 -6
42 -2 0 4 64 -4.5
43 -1 0 4 64 -5
44 -1 0 4 64 -6
44 -2 0 4 64 -6
45 -1 0 4 64 -5
46 -1 0 4 64 -6
46 -2 0 4 64 -6
41 1 0 5 80 -5
42 1 0 5 80 -6
43 1 0 5 80 -5
44 1 0 5 80 -6
44 2 0 5 80 -6
45 1 0 5 80 -5
46 1 0 5 80 -6
46 2 0 5 80 -6
41 -1 0 5 80 -5
42 -1 0 5 80 -6
43 -1 0 5 80 -5
44 -1 0 5 80 -6
44 -2 0 5 80 -6
45 -1 0 5 80 -5
46 -1 0 5 80 -6
46 -2 0 5 80 -6
41 1 0 6 96 -5
42 1 0 6 96 -6
43 1 0 6 96 -5
44 1 0 6 96 -6
44 2 0 6 96 -6
45 1 0 6 96 -5
46 1 0 6 96 -6
46 2 0 6 96 -6
41 -1 0 6 96 -5
42 -1 0 6 96 -6
43 -1 0 6 96 -5
44 -1 0 6 96 -6
44 -2 0 6 96 -6
45 -1 0 6 96 -5
46 -1 0 6 96 -6
46 -2 0 6 96 -6
41 1 0 7 112 -5
43 1 0 7 112 -5
44 1 0 7 112 -6
44 2 0 7 112 -6
45 1 0 7 112 -5
46 2 0 7 112 -6
41 -1 0 7 112 -5
43 -1 0 7 112 -5
44 -1 0 7 112 -6
44 -2 0 7 112 -6
45 -1 0 7 112 -5
46 -2 0 7 112 -6
43 1 0 8 128 -5
45 1 0 8 128 -5
43 -1 0 8 128 -5
45 -1 0 8 128 -5
41 1 1 1 16 -1.5
42 1 1 1 16 -1.5
42 2 1 1 16 -1.5
42 3 1 1 16 -2
42 4 1 1 16 -2
43 1 1 1 16 -2
44 1 1 1 16 -1.5
44 2 1 1 16 -1.5
44 3 1 1 16 -2
44 4 1 1 16 -2
44 5 1 1 16 -2
45 1 1 1 16 -2
46 1 1 1 16 -1.5
46 2 1 1 16 -1.5
46 3 1 1 16 -2
46 4 1 1 16 -2
46 5 1 1 16 -2
47 1 1 1 16 -8
48 1 1 1 16 -7.5
41 -1 1 1 16 -1.5
42 -1 1 1 16 -1.5
42 -2 1 1 16 -1.5
42 -3 1 1 16 -2
42 -4 1 1 16 -2
43 -1 1 1 16 -2
44 -1 1 1 16 -1.5
44 -2 1 1 16 -1.5
44 -3 1 1 16 -2
44 -4 1 1 16 -2
44 -5 1 1 16 -2
45 -1 1 1 16 -2
46 -1 1 1 16 -1.5
46 -2 1 1 16 -1.5
46 -3 1 1 16 -2
46 -4 1 1 16 -2
46 -5 1 1 16 -2
47 -1 1 1 16 -8
48 -1 1 1 16 -7.5
41 1 1 2 32 -1.5
42 1 1 2 32 -1.5
42 2 1 2 32 -1.5
42 3 1 2 32 -2
42 4 1 2 32 -2
43 1 1 2 32 -2
44 1 1 2 32 -1.5
44 2 1 2 32 -1.5
44 3 1 2 32 -2
44 4 1 2 32 -2
44 5 1 2 32 -2
45 1 1 2 32 -2
46 1 1 2 32 -1.5
46 2 1 2 32 -1.5
46 3 1 2 32 -2
46 4 1 2 32 -2
46 5 1 2 32 -2
47 1 1 2 32 -8
48 1 1 2 32 -7.5
41 -1 1 2 32 -1.5
42 -1 1 2 32 -1.5
42 -2 1 2 32 -1.5
42 -3 1 2 32 -2
42 -4 1 2 32 -2
43 -1 1 2 32 -2
44 -1 1 2 32 -1.5
44 -2 1 2 32 -1.5
44 -3 1 2 32 -2
44 -4 1 2 32 -2
44 -5 1 2 32 -2
45 -1 1 2 32 -2
46 -1 1 2 32 -1.5
46 -2 1 2 32 -1.5
46 -3 1 2 32 -2
46 -4 1 2 32 -2
46 -5 1 2 32 -2
47 -1 1 2 32 -8
48 -1 1 2 32 -7.5
41 1 1 -537.92
41 1 2 -523.07
41 1 3 -487.23
41 1 4 -451.48
41 1 5 -415.8
41 1 6 -380.18
41 1 7 -344.63
41 1 8 -309.13
41 1 9 -273.68
41 1 10 -238.28
41 1 11 -202.91
41 1 12 -167.57
41 1 13 -132.27
41 1 14 -96.98
41 1 15 -61.71
41 1 16 -26.44
41 1 17 8.81
41 1 18 44.07
41 1 19 79.34
41 1 20 114.62
41 1 21 149.92
41 1 22 185.24
41 1 23 220.59
41 1 24 255.97
41 1 25 291.4
41 1 26 326.87
41 1 27 362.4
41 1 28 397.98
41 1 29 433.63
41 1 30 469.35
41 1 31 505.14
41 1 32 541.01
42 1 1 -438.01
42 1 2 -404.78
42 1 3 -377.27
42 1 4 -349.77
42 1 5 -322.28
42 1 6 -294.81
42 1 7 -267.35
42 1 8 -239.9
42 1 9 -212.46