Commit b3353066 authored by Rosen Matev's avatar Rosen Matev
Browse files

Merge branch 'sponce_dropUTCommonBase' into 'master'

Modernized UT code and adapted to drop of UT base classes

See merge request !375
parents 93882dc6 5037c527
Pipeline #3446037 passed with stage
in 20 seconds
......@@ -67,7 +67,6 @@ DigiMuonSeq INFO Member list: MuonDigitization, MuonDigitToRawBuffer
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq, GaudiSequencer/LinkRichSeq, GaudiSequencer/LinkCaloSeq, GaudiSequencer/LinkMuonSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
LinkRichSeq INFO Member list: Rich::MC::MCRichDigitSummaryAlg
......@@ -104,10 +103,6 @@ BooleInit SUCCESS ======================================================
VPDigitCreator SUCCESS #WARNINGS = 1 Message = 'VP threshold parameters not in conditions DB'
VPDigitCreator SUCCESS Exceptions/Errors/Warnings/Infos Statistics : 0/0/1/0
UTEffChecker INFO -------Efficiency %---------
UTEffChecker INFO UTaX eff 9999 +/- 9999
UTEffChecker INFO UTaU eff 9999 +/- 9999
UTEffChecker INFO UTbV eff 9999 +/- 9999
UTEffChecker INFO UTbX eff 9999 +/- 9999
UTEffChecker INFO -----------------------
FTLiteClusterMo... INFO --------FT Lite clusters------------
FTLiteClusterMo... INFO -------------------------------
......
......@@ -30,7 +30,6 @@ MagneticFieldSvc INFO Map scaled by factor 1 with polarity internally used:
UTTightDigitCre... INFO Loading cuts tagged as Data11
Link INFO Member list: GaudiSequencer/LinkUTSeq
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
Moni INFO Member list: GaudiSequencer/MoniUTSeq
MoniUTSeq INFO Member list: MCUTDepositMonitor, MCUTDigitMonitor, UTDigitMonitor, MCParticle2MCHitAlg/MCP2UTMCHitAlg, UTEffChecker
UTEffChecker.MC... INFO MCParticle Momentum cut : 1 GeV/c < P < 1.79769e+305 GeV/c
......
......@@ -68,7 +68,6 @@ DigiMuonSeq INFO Member list: MuonDigitization, MuonDigitToRawBuffer
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq, GaudiSequencer/LinkRichSeq, GaudiSequencer/LinkCaloSeq, GaudiSequencer/LinkMuonSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
LinkRichSeq INFO Member list: Rich::MC::MCRichDigitSummaryAlg
......
......@@ -38,7 +38,6 @@ MCFTDepositCrea... INFO Selecting 50/fb attenuation map using power-law radiat
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
Moni INFO Member list: GaudiSequencer/MoniVPSeq, GaudiSequencer/MoniUTSeq, GaudiSequencer/MoniFTSeq
......
......@@ -38,7 +38,6 @@ MCFTDepositCrea... INFO Selecting 50/fb attenuation map using power-law radiat
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
Moni INFO Member list: GaudiSequencer/MoniVPSeq, GaudiSequencer/MoniUTSeq, GaudiSequencer/MoniFTSeq
......
......@@ -67,7 +67,6 @@ DigiMuonSeq INFO Member list: MuonDigitization, MuonDigitToRawBuffer
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq, GaudiSequencer/LinkRichSeq, GaudiSequencer/LinkCaloSeq, GaudiSequencer/LinkMuonSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
LinkRichSeq INFO Member list: Rich::MC::MCRichDigitSummaryAlg
......
......@@ -67,7 +67,6 @@ DigiMuonSeq INFO Member list: MuonDigitization, MuonDigitToRawBuffer
Link INFO Member list: GaudiSequencer/LinkVPSeq, GaudiSequencer/LinkUTSeq, GaudiSequencer/LinkFTSeq, GaudiSequencer/LinkTrSeq, GaudiSequencer/LinkRichSeq, GaudiSequencer/LinkCaloSeq, GaudiSequencer/LinkMuonSeq
LinkVPSeq INFO Member list: VPDigitLinker
LinkUTSeq INFO Member list: UTDigit2MCHitLinker/UTDigitLinker, UTClusterCreator_Monitor, UTCluster2MCHitLinker/UTClusterLinker, UTCluster2MCParticleLinker/UTTruthLinker
UTClusterCreato... INFO Loading cuts tagged as Data11
LinkFTSeq INFO Member list:
LinkTrSeq INFO Member list: BuildMCTrackInfo
LinkRichSeq INFO Member list: Rich::MC::MCRichDigitSummaryAlg
......
......@@ -8,29 +8,21 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef IUTCMSIMTOOL_H
#define IUTCMSIMTOOL_H 1
#pragma once
#include "Kernel/UTChannelID.h"
#include "UTDet/DeUTDetector.h"
#include "GaudiKernel/IAlgTool.h"
/** @class IUTCMSimTool IUTCMSimTool.h
*
/**
* Interface Class for simulating pedestal
*
* @author M.Needham
* @date 14/3/2010
*/
namespace LHCb {
class UTChannelID;
}
struct IUTCMSimTool : extend_interfaces<IAlgTool> {
DeclareInterfaceID( IUTCMSimTool, 1, 0 );
/// calc sharinh
virtual double noise( const LHCb::UTChannelID& chan ) const = 0;
virtual double noise( const LHCb::UTChannelID&, DeUTDetector const& ) const = 0;
};
#endif // IUTCMSimTool_H
......@@ -8,16 +8,14 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "DetDesc/GenericConditionAccessorHolder.h"
#include "Event/MCHit.h"
#include "Event/MCUTDeposit.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/SystemOfUnits.h"
#include "IUTChargeSharingTool.h"
#include "Kernel/ILHCbMagnetSvc.h"
#include "Kernel/ISiAmplifierResponse.h"
#include "Kernel/IUTReadoutTool.h"
#include "Kernel/UTChannelID.h"
#include "Kernel/UTCommonBase.h"
#include "Kernel/UTDataFunctor.h"
#include "LHCbMath/LHCbMath.h"
#include "MCInterfaces/ISiDepositedCharge.h"
......@@ -25,11 +23,15 @@
#include "UTDet/DeUTSector.h"
#include "UTDet/DeUTSensor.h"
#include "LHCbAlgs/Consumer.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/SystemOfUnits.h"
using namespace LHCb;
using namespace Gaudi::Units;
/** @class MCUTDepositCreator MCUTDepositCreator.h
*
/**
* Algorithm for creating MCUTDeposits from MCHits. The following processes
* are simulated:
* - For each available spill the MCHits are digitized (spill-over).
......@@ -44,25 +46,28 @@ using namespace Gaudi::Units;
* - A deposit is created from the ADC value, the channel and the MCHit link.
* - The deposits are sorted by UTChannelID.
*
* FIXME This algorithm is not really functional although it looks like it
* It retrieves a lot of data directly from the transient store manually in
* operator() and also stores a lot. This has to be fixed.
*
* @author M.Needham
* @author J. van Tilburg
* @date 05/01/2006
*/
class MCUTDepositCreator : public UT::CommonBase<GaudiAlgorithm> {
class MCUTDepositCreator
: public LHCb::Algorithm::Consumer<void( DeUTDetector const& ),
LHCb::DetDesc::usesBaseAndConditions<GaudiAlgorithm, DeUTDetector>> {
public:
// Constructor: A constructor of this form must be provided.
MCUTDepositCreator( const std::string& name, ISvcLocator* pSvcLocator );
MCUTDepositCreator( const std::string& name, ISvcLocator* pSvcLocator )
: Consumer{name, pSvcLocator, {"UTLocation", DeUTDetLocation::location()}} {}
StatusCode initialize() override;
StatusCode execute() override;
void operator()( DeUTDetector const& ) const override;
private:
/// create the deposits
void createDeposits( const LHCb::MCHits* mcHitsCont, const double spillTime,
std::vector<LHCb::MCUTDeposits*>& depositCont );
std::vector<LHCb::MCUTDeposits*>& depositCont, DeUTDetector const& ) const;
/// check can digitize this tracking hit
bool hitToDigitize( const LHCb::MCHit* aHit ) const;
......@@ -71,9 +76,9 @@ private:
std::vector<double> distributeCharge( const double entryU, const double exitU ) const;
std::map<unsigned int, double> chargeSharing( const std::vector<double>& sites, const DeUTSensor* aSensor,
double& possibleCollectedCharge );
double& possibleCollectedCharge ) const;
double beetleResponse( const double time, const double capacitance, const std::string& type );
double beetleResponse( const double time, const double capacitance, const std::string& type ) const;
void lorentzShift( const DeUTSensor* sensor, const Gaudi::XYZPoint& midPoint, Gaudi::XYZPoint& entry,
Gaudi::XYZPoint& exit ) const;
......@@ -132,45 +137,45 @@ private:
Gaudi::Property<bool> m_applyLorentzCorrection{this, "ApplyLorentzCorrection", true};
Gaudi::Property<double> m_lorentzFactor{this, "LorentzFactor", 0.025 / Gaudi::Units::tesla};
// FIXME One should not use ConditionAccessors by hand
// The Conditions should be declared at the algorithm level
// and be used transparently via the functional framework
LHCb::DetDesc::ConditionAccessor<DeUTDetector> m_detector{this, "DeUTLocation", DeUTDetLocation::location()};
SmartIF<ILHCbMagnetSvc> m_fieldSvc; ///< Pointer to the magnetic field service
};
DECLARE_COMPONENT_WITH_ID( MCUTDepositCreator, "MCUTDepositCreator" )
MCUTDepositCreator::MCUTDepositCreator( const std::string& name, ISvcLocator* pSvcLocator )
: CommonBase( name, pSvcLocator ) {}
StatusCode MCUTDepositCreator::initialize() {
StatusCode sc = CommonBase::initialize();
if ( sc.isFailure() ) return sc;
// charge sharing tool
std::transform( m_chargeSharerTypes.begin(), m_chargeSharerTypes.end(), std::back_inserter( m_chargeSharer ),
[&]( const std::string& n ) {
return tool<IUTChargeSharingTool>( m_chargeSharerName, m_chargeSharerName + n, this );
} );
// deposited charge
m_depositedCharge = tool<ISiDepositedCharge>( m_depChargeToolName, "DepCharge", this );
// make beetle response functions
std::transform( m_beetleResponseTypes.begin(), m_beetleResponseTypes.end(), std::back_inserter( m_amplifierResponse ),
[&]( const std::string& n ) {
return tool<ISiAmplifierResponse>( "SiAmplifierResponse", "Response" + n, this );
} );
// construct container names once
std::transform( m_spillNames.begin(), m_spillNames.end(), std::back_inserter( m_spillPaths ),
[&]( const std::string& n ) { // path in Transient data store
return "/Event" + n + m_inputLocation.value();
} );
std::transform( m_sampleNames.begin(), m_sampleNames.end(), std::back_inserter( m_outPaths ),
[&]( const std::string& n ) { // path in Transient data store
return "/Event" + n + m_outputLocation.value();
} );
if ( m_applyLorentzCorrection ) m_fieldSvc = service( "MagneticFieldSvc", true );
return StatusCode::SUCCESS;
return ConditionAccessorHolder::initialize().andThen( [&] {
// charge sharing tool
std::transform( m_chargeSharerTypes.begin(), m_chargeSharerTypes.end(), std::back_inserter( m_chargeSharer ),
[&]( const std::string& n ) {
return tool<IUTChargeSharingTool>( m_chargeSharerName, m_chargeSharerName + n, this );
} );
// deposited charge
m_depositedCharge = tool<ISiDepositedCharge>( m_depChargeToolName, "DepCharge", this );
// make beetle response functions
std::transform( m_beetleResponseTypes.begin(), m_beetleResponseTypes.end(),
std::back_inserter( m_amplifierResponse ), [&]( const std::string& n ) {
return tool<ISiAmplifierResponse>( "SiAmplifierResponse", "Response" + n, this );
} );
// construct container names once
std::transform( m_spillNames.begin(), m_spillNames.end(), std::back_inserter( m_spillPaths ),
[&]( const std::string& n ) { // path in Transient data store
return "/Event" + n + m_inputLocation.value();
} );
std::transform( m_sampleNames.begin(), m_sampleNames.end(), std::back_inserter( m_outPaths ),
[&]( const std::string& n ) { // path in Transient data store
return "/Event" + n + m_outputLocation.value();
} );
if ( m_applyLorentzCorrection ) m_fieldSvc = service( "MagneticFieldSvc", true );
return StatusCode::SUCCESS;
} );
}
StatusCode MCUTDepositCreator::execute() {
void MCUTDepositCreator::operator()( DeUTDetector const& det ) const {
// make output containers and put them in the store
std::vector<MCUTDeposits*> depositsVec;
for ( const auto& path : m_outPaths ) {
......@@ -189,7 +194,7 @@ StatusCode MCUTDepositCreator::execute() {
if ( msgLevel( MSG::DEBUG ) ) debug() << "Unable to retrieve " + m_spillPaths[iSpill] << endmsg;
} else {
// found spill - create digitizations and add them to deposits container
createDeposits( hits, m_spillTimes[iSpill], depositsVec );
createDeposits( hits, m_spillTimes[iSpill], depositsVec, det );
}
} // iSpill
......@@ -198,17 +203,15 @@ StatusCode MCUTDepositCreator::execute() {
std::stable_sort( depositsCont->begin(), depositsCont->end(),
UTDataFunctor::Less_by_Channel<const MCUTDeposit*>() );
} // for each
return StatusCode::SUCCESS;
}
void MCUTDepositCreator::createDeposits( const MCHits* mcHitsCont, const double spillTime,
std::vector<MCUTDeposits*>& depositCont ) {
std::vector<MCUTDeposits*>& depositCont, DeUTDetector const& det ) const {
// loop over MChits
for ( MCHit* aHit : *mcHitsCont ) {
const DeUTSector* aSector = tracker()->findSector( aHit->midPoint() );
const DeUTSector* aSector = det.findSector( aHit->midPoint() );
if ( !aSector ) {
if ( msgLevel( MSG::DEBUG ) ) debug() << "point " << aHit->midPoint() << endmsg;
Warning( "Failed to find sector", StatusCode::SUCCESS, 1 ).ignore();
......@@ -366,7 +369,7 @@ std::vector<double> MCUTDepositCreator::distributeCharge( const double entryU, c
std::map<unsigned int, double> MCUTDepositCreator::chargeSharing( const std::vector<double>& sites,
const DeUTSensor* aSensor,
double& possibleCollectedCharge ) {
double& possibleCollectedCharge ) const {
// init
const double chargeOnSite = 1.0 / ( (double)sites.size() );
double frac = 0.0;
......@@ -417,7 +420,8 @@ std::map<unsigned int, double> MCUTDepositCreator::chargeSharing( const std::vec
return stripMap;
}
double MCUTDepositCreator::beetleResponse( const double time, const double capacitance, const std::string& type ) {
double MCUTDepositCreator::beetleResponse( const double time, const double capacitance,
const std::string& type ) const {
// choose the best spline for our needs...
ISiAmplifierResponse* bResponse = nullptr;
double testCap = 9999.0 * Gaudi::Units::picofarad;
......
......@@ -10,24 +10,19 @@
\*****************************************************************************/
#include "Event/MCUTDeposit.h"
#include "Event/MCUTDigit.h"
#include "GaudiAlg/Transformer.h"
#include "Kernel/UTAlgBase.h"
#include "LHCbAlgs/Transformer.h"
using namespace LHCb;
/** @class MCUTDigitCreator MCUTDigitCreator.h
*
/**
* Algorithm for creating MCUTDigits from MCUTDeposits.
*
* @author M.Needham
* @date 10/03/2002
*/
struct MCUTDigitCreator : Gaudi::Functional::Transformer<MCUTDigits( const MCUTDeposits& ),
Gaudi::Functional::Traits::BaseClass_t<UT::AlgBase>> {
struct MCUTDigitCreator : LHCb::Algorithm::Transformer<MCUTDigits( const MCUTDeposits& )> {
MCUTDigitCreator( const std::string& name, ISvcLocator* pSvcLocator );
MCUTDigits operator()( const MCUTDeposits& ) const override;
};
......@@ -46,7 +41,6 @@ MCUTDigitCreator::MCUTDigitCreator( const std::string& name, ISvcLocator* pSvcLo
{"OutputLocation", MCUTDigitLocation::UTDigits}} {}
MCUTDigits MCUTDigitCreator::operator()( const MCUTDeposits& depositCont ) const {
// digits container
MCUTDigits digitCont;
digitCont.reserve( depositCont.size() );
......@@ -72,6 +66,5 @@ MCUTDigits MCUTDigitCreator::operator()( const MCUTDeposits& depositCont ) const
iterDep = jterDep;
} // iterDep
return digitCont;
}
......@@ -8,32 +8,31 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "IUTCMSimTool.h"
#include "UTDet/DeUTDetector.h"
#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/IIncidentListener.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/IRndmGen.h"
#include "GaudiKernel/SmartIF.h"
#include "IUTCMSimTool.h"
#include "Kernel/UTToolBase.h"
#include "UTDet/DeUTDetector.h"
/** @class UTCMSimTool UTCMSimTool.h
*
/**
* Tool for for simulating pedestal
*
* @author M.Needham
* @date 14/3/2010
*/
class UTCMSimTool : public extends<UT::ToolBase, IUTCMSimTool, IIncidentListener> {
class UTCMSimTool : public extends<GaudiTool, IUTCMSimTool, IIncidentListener> {
public:
using extends::extends;
/// initialize
StatusCode initialize() override;
/// return the simulated cm noise in this sector for this event
double noise( const LHCb::UTChannelID& chan ) const override;
double noise( const LHCb::UTChannelID&, DeUTDetector const& ) const override;
/** Implement the handle method for the Incident service.
* This is used to inform the tool of software incidents.
......@@ -43,7 +42,7 @@ public:
void handle( const Incident& incident ) override;
private:
void initEvent() const;
void initEvent( DeUTDetector const& ) const;
SmartIF<IRndmGen> m_gaussDist;
Gaudi::Property<bool> m_forceOptions{this, "forceOptions", true};
......@@ -56,8 +55,7 @@ private:
DECLARE_COMPONENT( UTCMSimTool )
StatusCode UTCMSimTool::initialize() {
return UT::ToolBase::initialize().andThen( [&] {
return extends::initialize().andThen( [&] {
// Add incident at begin of each event
incSvc()->addListener( this, IncidentType::BeginEvent );
} );
......@@ -67,10 +65,10 @@ void UTCMSimTool::handle( const Incident& incident ) {
if ( IncidentType::BeginEvent == incident.type() ) m_isInitialized = false;
}
void UTCMSimTool::initEvent() const {
void UTCMSimTool::initEvent( DeUTDetector const& det ) const {
// make the map
m_cmValues.clear();
for ( const auto& iterS : tracker()->sectors() ) {
for ( const auto& iterS : det.sectors() ) {
if ( m_forceOptions.value() ) {
m_cmValues[iterS->elementID()] = m_cmNoise * m_gaussDist->shoot();
} else {
......@@ -79,7 +77,7 @@ void UTCMSimTool::initEvent() const {
}
}
double UTCMSimTool::noise( const LHCb::UTChannelID& chan ) const {
if ( !m_isInitialized ) initEvent();
double UTCMSimTool::noise( const LHCb::UTChannelID& chan, DeUTDetector const& det ) const {
if ( !m_isInitialized ) initEvent( det );
return m_cmValues[chan];
}
......@@ -8,10 +8,12 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "IUTChargeSharingTool.h"
#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/SystemOfUnits.h"
#include "GaudiMath/GaudiMath.h"
#include "IUTChargeSharingTool.h"
#include "Kernel/UTToolBase.h"
#include "gsl/gsl_sf_erf.h"
#include <boost/assign/list_of.hpp>
......@@ -27,11 +29,10 @@ using namespace Gaudi::Units;
* @date 14/3/2002
*/
class UTChargeSharingTool : public extends<UT::ToolBase, IUTChargeSharingTool> {
class UTChargeSharingTool : public extends<GaudiTool, IUTChargeSharingTool> {
public:
using extends::extends;
StatusCode initialize() override;
/// calculate charge fraction as function of the relative distance
......
......@@ -9,17 +9,22 @@
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/UTDigit.h"
#include "GaudiAlg/Transformer.h"
#include "GaudiKernel/IRndmGen.h"
#include "GaudiKernel/RndmGenerators.h"
#include "GaudiKernel/SmartIF.h"
#include "IUTCMSimTool.h"
#include "IUTPedestalSimTool.h"
#include "Kernel/UTAlgBase.h"
#include "Kernel/UTChannelID.h"
#include "LHCbMath/LHCbMath.h"
#include "UTDet/DeUTDetector.h"
#include "UTDet/DeUTSector.h"
#include "LHCbAlgs/Transformer.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/IRndmGen.h"
#include "GaudiKernel/RndmGenerators.h"
#include "GaudiKernel/SmartIF.h"
#include "gsl/gsl_math.h"
#include <algorithm>
#include <cmath>
#include <map>
......@@ -29,19 +34,17 @@
using namespace LHCb;
class UTCommonModeSim : public Gaudi::Functional::Transformer<UTDigits( const UTDigits& inputCont ),
Gaudi::Functional::Traits::BaseClass_t<UT::AlgBase>> {
class UTCommonModeSim
: public LHCb::Algorithm::Transformer<UTDigits( UTDigits const&, DeUTDetector const& ),
LHCb::DetDesc::usesBaseAndConditions<GaudiAlgorithm, DeUTDetector>> {
public:
// Constructor: A constructor of this form must be provided.
UTCommonModeSim( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override;
UTDigits operator()( const UTDigits& inputCont ) const override;
UTDigits operator()( UTDigits const&, DeUTDetector const& ) const override;
private:
void processPort( LHCb::UTDigits::const_iterator& start, LHCb::UTDigits::const_iterator& end,
LHCb::UTDigits* outputCont ) const;
LHCb::UTDigits* outputCont, DeUTDetector const& det ) const;
StatusCode loadCutsFromConditions();
......@@ -69,32 +72,29 @@ namespace {
} );
}
} // namespace
UTCommonModeSim::UTCommonModeSim( const std::string& name, ISvcLocator* pSvcLocator )
: Transformer{name,
pSvcLocator,
{"inputLocation", UTDigitLocation::UTDigits},
{{"inputLocation", UTDigitLocation::UTDigits}, {"UTLocation", DeUTDetLocation::location()}},
{"outputLocation", UTDigitLocation::UTDigits + "CMCorrected"}} {}
StatusCode UTCommonModeSim::initialize() {
StatusCode sc = UT::AlgBase::initialize();
if ( sc.isFailure() ) return sc;
// Gaussian
m_gaussDist = randSvc()->generator( Rndm::Gauss( 0., 1. ) );
// get the cuts from condition if present
if ( !existDet<Condition>( m_conditionLocation ) || m_forceOptions.value() ) {
info() << "Default to jobOptions for cuts" << endmsg;
} else {
registerCondition( m_conditionLocation, &UTCommonModeSim::loadCutsFromConditions );
sc = runUpdate();
}
return sc;
return Transformer::initialize().andThen( [&]() -> StatusCode {
// Gaussian
m_gaussDist = randSvc()->generator( Rndm::Gauss( 0., 1. ) );
// get the cuts from condition if present
if ( !existDet<Condition>( m_conditionLocation ) || m_forceOptions.value() ) {
info() << "Default to jobOptions for cuts" << endmsg;
return StatusCode::SUCCESS;
} else {
registerCondition( m_conditionLocation, &UTCommonModeSim::loadCutsFromConditions );
return runUpdate();
}
} );
}
UTDigits UTCommonModeSim::operator()( const UTDigits& inputCont ) const {
UTDigits UTCommonModeSim::operator()( UTDigits const& inputCont, DeUTDetector const& det ) const {
UTDigits outputCont;
outputCont.reserve( inputCont.size() );
......@@ -105,19 +105,19 @@ UTDigits UTCommonModeSim::operator()( const UTDigits& inputCont ) const {
// collect hits
auto endPort = collectByPort( iterDigit, inputCont.end() );
// apply correction
processPort( iterDigit, endPort, &outputCont );
processPort( iterDigit, endPort, &outputCont, det );
iterDigit = endPort;
} // iterDigit
return outputCont;
}
void UTCommonModeSim::processPort( UTDigits::const_iterator& start, UTDigits::const_iterator& end,
UTDigits* outputCont ) const {
void UTCommonModeSim::processPort( UTDigits::const_iterator& start, UTDigits::const_iterator& end, UTDigits* outputCont,
DeUTDetector const& det ) const {
const DeUTSector* sector = findSector( ( *start )->channelID() );
const DeUTSector* sector = det.findSector( ( *start )->channelID() );
const double noiseCounts = sector->sectorNoise();
const double cmNoise = m_cmTool->noise( ( *start )->channelID() );
const double cmNoise = m_cmTool->noise( ( *start )->channelID(), det );
unsigned int nMissed = LHCbConstants::nStripsInPort - ( end - start );
double ranNoise = cmNoise + m_gaussDist->shoot() * noiseCounts / sqrt( (double)nMissed );
......
......@@ -11,26 +11,38 @@
#include "Event/MCTruth.h"