ATLAS Offline Software
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 
20 LArRAWtoSuperCell::LArRAWtoSuperCell( const std::string& name, ISvcLocator* pSvcLocator)
21  : AthReentrantAlgorithm( name, pSvcLocator)
22 {
23 }
24 
27 {
28 
32  ATH_CHECK(detStore()->retrieve(m_laronline_id,"LArOnline_SuperCellID"));
34  ATH_CHECK( m_bcContKey.initialize(SG::AllowEmpty) );
36  return StatusCode::SUCCESS;
37 }
38 
40 LArRAWtoSuperCell::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  }
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArBadChannel::good
bool good() const
Returns true if no problems at all (all bits at zero)
Definition: LArBadChannel.h:89
LArRAWtoSuperCell::LArRAWtoSuperCell
LArRAWtoSuperCell(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArRAWtoSuperCell.cxx:20
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
LArBadChannel.h
LArRAWtoSuperCell::m_bcidOffset
IntegerProperty m_bcidOffset
Definition: LArRAWtoSuperCell.h:70
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
LArRAWtoSuperCell::initialize
StatusCode initialize()
Definition: LArRAWtoSuperCell.cxx:26
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArRAWtoSuperCell::m_caloMgrKey
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloMgrKey
Geometry manager.
Definition: LArRAWtoSuperCell.h:59
LArBadChannel::LArBadChannelSCEnum::maskedOSUMBit
@ maskedOSUMBit
Definition: LArBadChannel.h:52
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
LArBadXCont::offlineStatus
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArRAWtoSuperCell.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CaloSuperCellDetDescrManager
Definition: CaloDetDescrManager.h:490
CaloDetDescrElement::getSubCalo
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:433
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
LArBadChannel::statusBad
bool statusBad(PosType pb) const
Returns true if corresponding status bit its set
Definition: LArBadChannel.h:80
LArRAWtoSuperCell::m_sCellContainerOutKey
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
Definition: LArRAWtoSuperCell.h:52
LArOnOffIdMapping.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LArRAWtoSuperCell::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArRAWtoSuperCell.h:55
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArRAWtoSuperCell::m_sCellContainerInKey
SG::ReadHandleKey< LArRawSCContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
Definition: LArRAWtoSuperCell.h:47
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArBadChannel
Definition: LArBadChannel.h:10
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArRAWtoSuperCell::m_maskedContKey
SG::ReadCondHandleKey< LArBadChannelCont > m_maskedContKey
OTF Channel masking for Super-Cells.
Definition: LArRAWtoSuperCell.h:66
LArRAWtoSuperCell::m_laronline_id
const LArOnline_SuperCellID * m_laronline_id
Definition: LArRAWtoSuperCell.h:73
LArRAWtoSuperCell::m_isReco
BooleanProperty m_isReco
Definition: LArRAWtoSuperCell.h:68
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArRAWtoSuperCell::m_bcContKey
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Bad Channel masking for Super-Cells.
Definition: LArRAWtoSuperCell.h:63
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
EventInfo.h
SG::WriteHandle< CaloCellContainer >
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArRAWtoSuperCell::execute
StatusCode execute(const EventContext &context) const
Definition: LArRAWtoSuperCell.cxx:40
LArOnline_SuperCellID.h
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20