Skip to content
Snippets Groups Projects

Clean out Supercell functionality from regular LArRawChannelBuilderAlg

Merged Walter Lampl requested to merge wlampl/athena:LArRawChannelBuilder_NoSC into master
2 files
+ 23
101
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -5,22 +5,18 @@
#include "LArRawChannelBuilderAlg.h"
#include "GaudiKernel/SystemOfUnits.h"
#include "LArRawEvent/LArRawChannelContainer.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
//#include "CaloDetDescr/CaloDetDescrManager.h"
#include "LArRawEvent/LArDigitContainer.h"
#include "LArIdentifier/LArOnline_SuperCellID.h"
#include "LArIdentifier/LArOnlineID.h"
#include "LArCOOLConditions/LArDSPThresholdsFlat.h"
#include "AthAllocators/DataPool.h"
#include <cmath>
LArRawChannelBuilderAlg::LArRawChannelBuilderAlg(const std::string& name, ISvcLocator* pSvcLocator):
AthReentrantAlgorithm(name, pSvcLocator), m_sem_mgr(0) {}
AthReentrantAlgorithm(name, pSvcLocator) {}
StatusCode LArRawChannelBuilderAlg::initialize() {
ATH_CHECK(m_digitKey.initialize());
ATH_CHECK(m_cellKey.initialize(m_isSC));
ATH_CHECK(m_rawChannelKey.initialize(!m_isSC));
ATH_CHECK(m_rawChannelKey.initialize());
ATH_CHECK(m_pedestalKey.initialize());
ATH_CHECK(m_adc2MeVKey.initialize());
ATH_CHECK(m_ofcKey.initialize());
@@ -35,17 +31,9 @@ StatusCode LArRawChannelBuilderAlg::initialize() {
}
}
if ( m_isSC ) {
const LArOnline_SuperCellID* ll;
ATH_CHECK(detStore()->retrieve(ll,"LArOnline_SuperCellID"));
m_onlineId = (const LArOnlineID_Base*)ll;
ATH_CHECK( detStore()->retrieve (m_sem_mgr, "CaloSuperCellMgr") );
}
else {
const LArOnlineID* ll;
ATH_CHECK(detStore()->retrieve(ll,"LArOnlineID"));
m_onlineId = (const LArOnlineID_Base*)ll;
}
ATH_CHECK(detStore()->retrieve(m_onlineId,"LArOnlineID"));
const std::string cutmsg = m_absECutFortQ.value() ? " fabs(E) < " : " E < ";
ATH_MSG_INFO("Energy cut for time and quality computation: " << cutmsg <<
@@ -65,18 +53,7 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
SG::ReadHandle<LArDigitContainer> inputContainer(m_digitKey,ctx);
//Write output via write handle
auto outputContainerCellPtr = std::make_unique<CaloCellContainer>(SG::VIEW_ELEMENTS);
auto outputContainerLRPtr = std::make_unique<LArRawChannelContainer>();
DataPool<CaloCell> dataPool;
if ( m_isSC ) {
unsigned int hash_max = m_onlineId->channelHashMax();
if (dataPool.allocated()==0){
dataPool.reserve (hash_max);
}
outputContainerCellPtr->reserve( hash_max );
}
auto outputContainer = std::make_unique<LArRawChannelContainer>();
//Get Conditions input
SG::ReadCondHandle<ILArPedestal> pedHdl(m_pedestalKey,ctx);
@@ -146,14 +123,12 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
//Sanity check on input conditions data:
// FIXME: fix to get splash test running, should implement the iterations later
size_t len=nSamples;
if(!m_isSC && ATH_UNLIKELY(ofca.size()<nSamples)) {
if(ATH_UNLIKELY(ofca.size()<nSamples)) {
if (!connected) continue; //No conditions for disconnected channel, who cares?
ATH_MSG_DEBUG("Number of OFC a's doesn't match number of samples for conencted channel " << m_onlineId->channel_name(id)
<< " gain " << gain << ". OFC size=" << ofca.size() << ", nbr ADC samples=" << nSamples);
len=ofca.size();
}
if (m_isSC && !connected ) continue;
if (m_isSC ) len = nSamples <= ofca.size() ? nSamples : ofca.size();
if (ATH_UNLIKELY(p==ILArPedestal::ERRORCODE)) {
if (!connected) continue; //No conditions for disconencted channel, who cares?
@@ -175,33 +150,16 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
// across platforms.
double A=0;
bool saturated=false;
unsigned int init=0;
bool passBCIDmax=false;
// Check saturation AND discount pedestal
std::vector<float> samp_no_ped(nSamples,0.0);
for (size_t i=0;i<nSamples;++i) {
if (samples[i+firstSample]==4096 || samples[i+firstSample]==0) saturated=true; //choose the correct first sample
samp_no_ped[i]=samples[i+firstSample]-p;
}
if (!m_isSC){
for (size_t i=0;i<len;++i) {
A+=static_cast<double>(samp_no_ped[i])*ofca[i];
}
} else {
init=1;
for (size_t i=0;i<len;++i) {
A+=static_cast<double>(samp_no_ped[i+init])*ofca[i];
}
double Am1=0.;
for (size_t i=0;i<len;++i) {
Am1+=static_cast<double>(samp_no_ped[i])*ofca[i];
}
double AM1=0.;
for (size_t i=0;i<len;++i) {
AM1+=static_cast<double>(samp_no_ped[i+2])*ofca[i];
}
if ( (A>Am1) && (A>AM1) ) passBCIDmax=true;
} // end of m_isSC
for (size_t i=0;i<len;++i) {
A+=static_cast<double>(samp_no_ped[i])*ofca[i];
}
//Apply Ramp
const float E=adc2mev[0]+A*adc2mev[1];
@@ -238,7 +196,7 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
const auto& ofcb=ofcs->OFC_b(id,gain);
double At=0;
for (size_t i=0;i<len;++i) {
At+=static_cast<double>(samp_no_ped[i+init])*ofcb[i];
At+=static_cast<double>(samp_no_ped[i])*ofcb[i];
}
//Divide A*t/A to get time
tau=(std::fabs(A)>0.1) ? At/A : 0.0;
@@ -275,13 +233,13 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
const float* shapeDer=&*fullshapeDer.begin()+firstSample;
for (size_t i=0;i<len;++i) {
q += std::pow((A*(shape[i]-tau*shapeDer[i])-(samp_no_ped[i+init])),2);
q += std::pow((A*(shape[i]-tau*shapeDer[i])-(samp_no_ped[i])),2);
}
}//end if useShapeDer
else {
//Q-factor w/o shape derivative
for (size_t i=0;i<len;++i) {
q += std::pow((A*shape[i]-(samp_no_ped[i+init])),2);
q += std::pow((A*shape[i]-(samp_no_ped[i])),2);
}
}
@@ -293,42 +251,15 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const {
tau*=(Gaudi::Units::nanosecond/Gaudi::Units::picosecond); //Convert time to ps
}//end if above cut
if ( m_isSC ){
CaloCell* ss = dataPool.nextElementPtr();
Identifier offId = cabling->cnvToIdentifier(id);
const CaloDetDescrElement* dde = m_sem_mgr->get_element (offId);
ss->setCaloDDE(dde);
ss->setEnergy(E);
tau*=1e-3; // time in ns
ss->setTime(tau);
ss->setGain((CaloGain::CaloGain)0);
float et = ss->et()*1e-3; // et in GeV
// for super-cells provenance and time are slightly different
uint16_t prov = 0x2000;
if(et>10e3 && tau>-8 && tau<16) prov |= 0x200;
else if(et<=10e3 && fabs(tau)<8) prov |= 0x200;
if ( passBCIDmax ) prov |=0x40;
ss->setProvenance(prov);
ss->setQuality(iquaShort);
outputContainerCellPtr->push_back(ss);
}
else{
outputContainerLRPtr->emplace_back(id,static_cast<int>(std::floor(E+0.5)),
outputContainer->emplace_back(id,static_cast<int>(std::floor(E+0.5)),
static_cast<int>(std::floor(tau+0.5)),
iquaShort,prov,(CaloGain::CaloGain)gain);
}
}
if ( m_isSC ) {
SG::WriteHandle<CaloCellContainer>outputContainer(m_cellKey,ctx);
ATH_CHECK(outputContainer.record(std::move(outputContainerCellPtr) ) );
} else {
SG::WriteHandle<LArRawChannelContainer>outputContainer(m_rawChannelKey,ctx);
ATH_CHECK(outputContainer.record(std::move(outputContainerLRPtr) ) );
}
SG::WriteHandle<LArRawChannelContainer>outputHandle(m_rawChannelKey,ctx);
ATH_CHECK(outputHandle.record(std::move(outputContainer) ) );
return StatusCode::SUCCESS;
}
Loading