ATLAS Offline Software
Loading...
Searching...
No Matches
PrimaryDPDPrescaler.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
8#include "CLHEP/Random/RandFlat.h"
9#include <sstream>
10
11PrimaryDPDPrescaler::PrimaryDPDPrescaler(const std::string& name, ISvcLocator* pSvcLocator) :
12 AthReentrantAlgorithm(name, pSvcLocator){
15}
16
18 ATH_MSG_DEBUG( "in initialize()" );
19 ATH_CHECK( m_rndmSvc.retrieve());
20 return StatusCode::SUCCESS;
21}
22
23StatusCode PrimaryDPDPrescaler::execute(const EventContext& ctx) const {
24 if (m_prescale <= 1.){
25 ATH_MSG_DEBUG("No prescale active. Do nothing");
26 return StatusCode::SUCCESS;
27 }
28
29 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this);
30 rngWrapper->setSeed( name(), ctx );
31 CLHEP::HepRandomEngine* rndmEngine= rngWrapper->getEngine(ctx);
32
33
34 const double random_number = CLHEP::RandFlat::shoot( rndmEngine, 0, 1 );
35 if (random_number * m_prescale > 1.){
36 ATH_MSG_DEBUG("The event "<<ctx<<" exceeds the prescale");
37 setFilterPassed(false, ctx);
38 ++m_vetoed;
39 } else {
40 ATH_MSG_DEBUG("The event "<<ctx<<" is accepted");
41 ++m_accepted;
42 setFilterPassed(true,ctx);
43 }
44 return StatusCode::SUCCESS;
45}
46
48{
49 ATH_MSG_DEBUG( "***************************************************************");
50 ATH_MSG_DEBUG( "Total processed events : " << m_accepted + m_vetoed);
51 ATH_MSG_DEBUG( "Accepted events : " << m_accepted );
52 ATH_MSG_DEBUG( "Vetoed events : " << m_vetoed );
53 ATH_MSG_DEBUG( "Nominal prescale/ratio : " << m_prescale << " / " << 1./m_prescale );
54 if( (m_accepted+m_vetoed)>0 ){
55 ATH_MSG_DEBUG( "Accept ratio : " << 1.*m_accepted/(m_accepted+m_vetoed) );
56 }
57 else{ ATH_MSG_DEBUG( "Accept ratio : " << 0 ); }
58 ATH_MSG_DEBUG( "File rollover : " << m_rollover );
59 ATH_MSG_DEBUG( "***************************************************************" );
60 return StatusCode::SUCCESS;
61}
62
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual void setFilterPassed(bool state, const EventContext &ctx) const
An algorithm that can be simultaneously executed in multiple threads.
std::atomic< unsigned int > m_accepted
std::atomic< unsigned int > m_vetoed
StatusCode initialize() override
Gaudi Service Interface method implementations:
StringArrayProperty m_theRequireAlgNames
List of algorithms names to combine with logical AND.
StatusCode finalize() override
StringArrayProperty m_theAcceptAlgNames
Keep these two properties for now in order not to break the current configuration.
ServiceHandle< IAthRNGSvc > m_rndmSvc
handle to the IAthRNGSvc we want to test
PrimaryDPDPrescaler(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Gaudi::Property< double > m_prescale
StatusCode execute(const EventContext &ctx) const override