Skip to content
Snippets Groups Projects
Commit c5273f27 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'removeMCWeightFix.xAODEventInfoCnv-20190613' into 'master'

xAODEventInfoCnv: Remove EventInfoMCWeightFixAlg.

See merge request atlas/athena!24186
parents c40271a7 b7196fc8
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// EventInfoMgt includes
#include "EventInfoMCWeightFixAlg.h"
#include "xAODTruth/TruthEventContainer.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventType.h"
EventInfoMCWeightFixAlg::EventInfoMCWeightFixAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ){
}
EventInfoMCWeightFixAlg::~EventInfoMCWeightFixAlg() {}
StatusCode EventInfoMCWeightFixAlg::initialize() {
return StatusCode::SUCCESS;
}
StatusCode EventInfoMCWeightFixAlg::finalize() {
return StatusCode::SUCCESS;
}
StatusCode EventInfoMCWeightFixAlg::execute() {
setFilterPassed(false); //will set to true if we actually fixed EventInfo
const EventInfo* evtInfo = 0;
CHECK( evtStore()->retrieve( evtInfo ) );
//check we are MC
if( !evtInfo->event_type()->test(EventType::IS_SIMULATION) ) return StatusCode::SUCCESS;
const xAOD::TruthEventContainer* truthEvents = 0;
CHECK( evtStore()->retrieve( truthEvents , "TruthEvents" ) );
//check if the first event in TruthEvents has same vector of weights as EventInfo (just check size)
if( truthEvents->size()==0 || truthEvents->at(0)->weights().size() == evtInfo->event_type()->n_mc_event_weights() ) return StatusCode::SUCCESS;
auto& weights = truthEvents->at(0)->weights();
//got here, so there must be a mismatch
ATH_MSG_VERBOSE("Fixing weights: TruthEvent[0].weights().size() = " << weights.size() << " vs EventInfo n_mc_event_weights() = " << evtInfo->event_type()->n_mc_event_weights() );
for(unsigned int i=0;i<weights.size();i++) {
evtInfo->event_type()->set_mc_event_weight( weights[i] , i );
}
setFilterPassed(true);
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EVENTINFOMGT_EVENTINFOMCWEIGHTFIXALG_H
#define EVENTINFOMGT_EVENTINFOMCWEIGHTFIXALG_H 1
#include "AthenaBaseComps/AthAlgorithm.h"
//Author: Will Buttinger
//This algorithm is to fix the ATLASSIM-2989 issue with mc weights in EventInfo
//It should be used in AODFix for 20.7 xAOD
class EventInfoMCWeightFixAlg: public ::AthAlgorithm {
public:
EventInfoMCWeightFixAlg( const std::string& name, ISvcLocator* pSvcLocator );
virtual ~EventInfoMCWeightFixAlg();
virtual StatusCode initialize();
virtual StatusCode execute();
virtual StatusCode finalize();
private:
};
#endif //> !EVENTINFOMGT_EVENTINFOMCWEIGHTFIXALG_H
......@@ -4,13 +4,8 @@
#include "../EventInfoReaderAlg.h"
#include "../EventDuplicateFinderAlg.h"
#include "../EventInfoMCWeightFixAlg.h"
DECLARE_COMPONENT( xAODMaker::EventInfoCnvTool )
DECLARE_COMPONENT( xAODMaker::EventInfoSelectorTool )
DECLARE_COMPONENT( xAODMaker::EventInfoCnvAlg )
DECLARE_COMPONENT( xAODReader::EventInfoReaderAlg )
DECLARE_COMPONENT( xAODReader::EventDuplicateFinderAlg )
DECLARE_COMPONENT( EventInfoMCWeightFixAlg )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment