ATLAS Offline Software
Loading...
Searching...
No Matches
LArRAWtoSuperCell.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 *
4 * Name : LArRAWtoSuperCell.cxx
5 * PACKAGE : LArCalorimeter/LArCell/LArRAWtoSuperCell
6 *
7 * AUTHOR : Denis Oliveira Damazio
8 *
9 * PURPOSE : prepares SuperCellContainer in CaloCellContainer formar from LArRawSCContainer
10 *
11 * **/
12
13#include "LArRAWtoSuperCell.h"
19
20LArRAWtoSuperCell::LArRAWtoSuperCell( const std::string& name, ISvcLocator* pSvcLocator)
21 : AthReentrantAlgorithm( name, pSvcLocator)
22{
23}
24
25StatusCode
27{
28
29 ATH_CHECK( m_sCellContainerInKey.initialize() );
30 ATH_CHECK( m_sCellContainerOutKey.initialize() );
31 ATH_CHECK( m_cablingKey.initialize() );
32 ATH_CHECK(detStore()->retrieve(m_laronline_id,"LArOnline_SuperCellID"));
33 ATH_CHECK( m_caloMgrKey.initialize());
36 return StatusCode::SUCCESS;
37}
38
39StatusCode
40LArRAWtoSuperCell::execute(const EventContext& context) const
41{
42
44 const CaloSuperCellDetDescrManager* sem_mgr = *caloMgrHandle;;
45
46 SG::WriteHandle<CaloCellContainer> scellContainerHandle( m_sCellContainerOutKey, context);
47 auto new_scell_cont = std::make_unique<CaloCellContainer> ();
48
49 auto cellsHandle = SG::makeHandle( m_sCellContainerInKey, context );
50 if ( not cellsHandle.isValid() ) {
51 ATH_MSG_ERROR("Did not get CaloCellContainer input");
52 // to avoid crash
53 ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
54 return StatusCode::FAILURE;
55 }
56 const LArOnOffIdMapping* cabling;
58 cabling=*cablingHdl;
59
60 const LArBadChannelCont* badchannel(nullptr);
61 const LArBadChannelCont* maskedchannel(nullptr);
62 if ( !m_bcContKey.empty() ){
64 badchannel = *larBadChan;
65 }
66 if ( !m_maskedContKey.empty() ){
68 maskedchannel = *larBadChan;
69 }
70
71 const LArRawSCContainer* scells_from_sg = cellsHandle.cptr();
72 ATH_MSG_DEBUG("Got a CaloCellContainer input with size : "<<scells_from_sg->size());
73 if ( scells_from_sg->empty() ) {
74 ATH_MSG_WARNING("Got an empty input collection, maybe the key is wrong : "
76 // to avoid crash
77 ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
78 return StatusCode::SUCCESS;
79 }
80
81 const EventIDBase& EIHandle = context.eventID();
82 const unsigned int bcid = EIHandle.bunch_crossing_id();
83
84 new_scell_cont->reserve(scells_from_sg->size());
85
86 for(const auto *sc : *scells_from_sg){
87 if ( !sc ) continue;
88 Identifier off_id = cabling->cnvToIdentifier(sc->hardwareID());
89 const CaloDetDescrElement* dde = sem_mgr ->get_element(off_id);
90 CaloCell* cell = new CaloCell();
91 cell->setCaloDDE(dde);
92 if (dde->getSubCalo() == CaloCell_ID::LARHEC)
93 cell->setGain (CaloGain::LARMEDIUMGAIN);
94 else
95 cell->setGain (CaloGain::LARHIGHGAIN);
96
97 float energy(0.);
98 bool saturation(false);
99
100 if(m_isReco) {
101 energy=sc->energies().at(0);
102 if(energy != 0. && sc->passTauSelection().at(0)) {
103 int Etau=sc->tauEnergies().at(0);
104 cell->setTime((float)Etau / energy);
105 cell->setProvenance(cell->provenance()|0x200);
106 }
107 } else {
108 const std::vector< unsigned short >& bcids = sc->bcids();
109 const std::vector< int >& energies = sc->energies();
110 const std::vector< bool>& satur = sc->satur();
111 for(unsigned int i=0;i<bcids.size();i++) {
112 if ( bcids[i]==bcid+m_bcidOffset) {
113 energy=energies[i];
114 saturation = satur[i];
115 break;
116 }
117 }
118 }
119
120 // convert ET (coming from LATOMEs) into Energy and
121 // apply magic 12.5 factor
122 cell->setEnergy( 12.5*energy*cosh(cell->eta()) );
123
124 // set some provenance to indicate bad channel
125 if(badchannel) {
126 LArBadChannel bc = badchannel->offlineStatus(off_id);
128 cell->setProvenance(cell->provenance()|0x80);
129 }
130 }
131 // similarly for OTF-masked cells
132 if(maskedchannel) {
133 LArBadChannel bc = maskedchannel->offlineStatus(off_id);
135 cell->setProvenance(cell->provenance()|0x80);
136 }
137 }
138 // energy value selected in LArLATOMEDecoder to mean
139 // invalid channel. Converting it to a bit-wise representation
140 // on the provenance word.
141 if ( energy < -99998.0 ){
142 cell->setProvenance(cell->provenance()|0x40);
143 }
144 // we probably should soon associate some quality information to the saturation, maybe the bcid to provenance
145 cell->setQuality((unsigned short)saturation);
146 new_scell_cont->push_back( cell );
147 }
148 ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
149
150 return StatusCode::SUCCESS;
151}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
LArBadXCont< LArBadChannel > LArBadChannelCont
static Double_t sc
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
bool statusBad(PosType pb) const
Returns true if corresponding status bit its set.
bool good() const
Returns true if no problems at all (all bits at zero)
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
SG::ReadCondHandleKey< LArBadChannelCont > m_maskedContKey
OTF Channel masking for Super-Cells.
StatusCode execute(const EventContext &context) const
IntegerProperty m_bcidOffset
BooleanProperty m_isReco
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Bad Channel masking for Super-Cells.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
LArRAWtoSuperCell(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloMgrKey
Geometry manager.
const LArOnline_SuperCellID * m_laronline_id
SG::ReadHandleKey< LArRawSCContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
Container class for LArRawSC.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARHIGHGAIN
Definition CaloGain.h:18
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())