|
ATLAS Offline Software
|
Go to the documentation of this file.
23 : AnaAlgorithm(
name, pSvcLocator) {
28 "Crash if metadata reading failed");
31 "Index of the showering algorithm for FTAG MC/MC SFs");
33 "Name of the showering algorithm for FTAG MC/MC SFs");
35 "Year of data taking (primarily for trigger configuration)");
49 if (
inputMetaStore()->contains<xAOD::FileMetaData>(
"FileMetaData")) {
53 ATH_MSG_ERROR(
"Could not retrieve FileMetadata. We thus cannot reliably pre-determine DSID, "
54 "whether this is MC, and simulation type.");
56 return StatusCode::FAILURE;
76 bool useTracking =
true;
77 m_settings->retrieve(
"WriteTrackingData", useTracking);
86 if (
m_settings->value(
"PerfStats") ==
"Summary")
99 return StatusCode::FAILURE;
111 "Failed to setProperty of triggerGRLSelection");
118 "Failed to setProperty of systObjMaker");
151 if (
m_settings->value(
"TopPartonHistory") ==
"ttbar") {
154 "Failed to setProperty of top::CalcTtbarPartonHistory");
156 ATH_MSG_ERROR(
"Only ttbar TopPartonHistory is supported for the moment!");
157 return StatusCode::FAILURE;
164 "Failed to set config for PDF SF Calculator");
171 "Failed to setProperty of top::TopEventMaker");
178 "Failed to setProperty of top::ScaleFactorCalculator");
184 std::vector<std::string> extraBranches;
201 if (
m_config->doMCGeneratorWeights()) {
212 unsigned int dsidPdf =
m_config->getDSID();
216 for (
const auto &pdf_set :
m_config->LHAPDFSets()) {
229 return StatusCode::SUCCESS;
234 double sumW_file = 0;
235 ULong64_t initialEvents = 0;
238 std::vector<float> LHE3_sumW_file;
239 std::vector<std::string> LHE3_names_file;
243 ATH_MSG_INFO(
"Bookkeepers are not read for TRUTH derivations");
246 "Cannot retrieve CutBookkeepers");
250 const std::vector<std::string> &weight_names =
m_pmg_weightTool->getWeightNames();
264 const size_t nominalWeightIndex =
m_config->nominalWeightIndex();
265 sumW_file = LHE3_sumW_file.at(nominalWeightIndex);
268 sumW_file = initialEvents;
281 ATH_MSG_ERROR(
"Strange inconsistency of vector sizes in sum of LHE3 weights calculation.");
282 return StatusCode::FAILURE;
284 for (
unsigned int i_genweights = 0; i_genweights < LHE3_names_file.size(); i_genweights++) {
285 if (
m_names_LHE3.at(i_genweights) != LHE3_names_file.at(i_genweights)) {
286 ATH_MSG_ERROR(
"Strange inconsistency in the vector of weight names in sum of LHE3 "
287 "weights calculation.");
288 return StatusCode::FAILURE;
295 for (
unsigned int i_genweights = 0; i_genweights < LHE3_names_file.size(); i_genweights++) {
296 m_names_LHE3.push_back(LHE3_names_file.at(i_genweights));
302 "The sum of weights for the following LHE3 weights were retrieved from the input file:");
306 msgInfo << std::endl;
310 "No sum of LHE3 weights could be found in meta-data. Will try to recompute these sums.\n"
311 "This only works on un-skimmed derivations, and the names of these weights may be "
312 "unknown (but we'll try to read them from the PMG tool");
320 if (
m_config->printCDIpathWarning()) {
322 "\n*************************************************************************\n"
323 <<
"YOU ARE USING A CUSTOM PATH TO THE CDI FILE WHICH IS NOT THE DEFAULT PATH\n"
324 <<
" YOU MANY NOT BE USING THE LATEST BTAGGING RECOMMENDATIONS \n"
325 <<
"*************************************************************************\n\n");
327 if (
m_config->printEgammaCalibModelWarning()) {
329 "\n*************************************************************************\n"
330 <<
" YOU HAVE CHANGED DEFAULT EGAMMA CALIBRATION MODEL \n"
331 <<
" TO USE DEFAULT MODEL, REMOVE 'EGammaCalibrationModel' FROM CONFIG FILE \n"
332 <<
"*************************************************************************\n\n");
335 if (
m_config->printEIDFileWarning()) {
337 "\n*************************************************************************\n"
338 <<
" YOU ARE USING THIS CUSTOM PATH TO THE ELECTRON ID SF FILE: \n\n"
339 <<
m_config->electronIDSFFilePath() <<
"(Tight) \n\n"
340 <<
m_config->electronIDSFFileLoosePath() <<
"(Loose) \n\n"
341 <<
" INSTEAD OF THE MOST RECENT RECOMMENDED MAP \n"
342 <<
" YOU MANY NOT BE USING THE LATEST ELECTRON ID RECOMMENDATIONS \n"
343 <<
"*************************************************************************\n\n");
346 return StatusCode::SUCCESS;
354 float mcEventWeight(1.), pileupWeight(1.);
396 const bool saveEventInOutputFile =
399 if (saveEventInOutputFile) {
400 m_eventSaver->saveParticleLevelEvent(particleLevelEvent);
408 "Failed to retrieve TruthEvent container for LHAPDF");
410 "TruthEvent container size != 1, not sure what to do with PDF reweighting");
411 for (
const auto *tePtr : *truthEvent) {
413 if (tePtr->isAvailable<std::vector<float>>(
"AnalysisTop_" +
pdf.first +
"_Weights")) {
415 tePtr->auxdata<std::vector<float>>(
"AnalysisTop_" +
pdf.first +
"_Weights").size());
426 "Failed to retrieve LHE3 weights from EventInfo");
430 ATH_MSG_INFO(
"Trying to recalculate nominal weights sum for TRUTH derivation");
431 const size_t nominalWeightIndex =
m_config->nominalWeightIndex();
436 if (
m_config->doMCGeneratorWeights()) {
441 for (
unsigned int i_LHE3 = 0; i_LHE3 < weightsSize; i_LHE3++) {
446 const std::vector<std::string> &weight_names =
m_pmg_weightTool->getWeightNames();
447 if (weight_names.size() != weightsSize) {
449 "In top-xaod, while calculating mc weights sums on the fly, names from PMG tools "
450 "have different size wrt weight vector, we'll not retrieve weight names");
453 for (
unsigned int i_wgt = 0; i_wgt < weight_names.size(); i_wgt++)
457 for (
unsigned int i_LHE3 = 0; i_LHE3 < weightsSize; i_LHE3++) {
464 ATH_MSG_ERROR(
"Strange size inconsistency in the AllExecutedEvents* "
465 "sum of weights bookkeepers from the meta-data and the vector of "
466 "LHE3 weights in the EventInfo container.");
467 return StatusCode::FAILURE;
473 return StatusCode::SUCCESS;
487 setFilterPassed(
false);
488 return StatusCode::SUCCESS;
496 setFilterPassed(
false);
497 return StatusCode::SUCCESS;
505 setFilterPassed(
false);
506 return StatusCode::SUCCESS;
518 if (!passAnyTriggerVeto) {
519 setFilterPassed(
false);
520 return StatusCode::SUCCESS;
553 for (
const auto *currentSystematic : *allSystematics) {
554 if (!(currentSystematic->hashValue() ==
m_config->nominalHashValue() ||
561 const bool passAnyEventSelection =
570 "\n********************************************************************************"
571 "*******\nYou are running over MC campaigns which support actual mu rewighting, but you are not using it!"
572 "\nYou are strongly adviced to use it.\nCheck "
573 "https://twiki.cern.ch/twiki/bin/view/AtlasProtected/"
574 "TopxAODStartGuideR21#PRW_and_Lumicalc_files\n*************************************"
575 "**************************************************\n");
579 currentSystematic->auxdecor<
char>(
m_config->passEventSelectionDecoration()) =
580 passAnyEventSelection ? 1 : 0;
586 if (passAnyEventSelection && currentSystematic->hashValue() ==
m_config->nominalHashValue())
597 for (
const auto *currentSystematic : *allSystematicsLoose) {
598 if (!(currentSystematic->hashValue() ==
m_config->nominalHashValue() ||
605 const bool passAnyEventSelection =
615 "\n********************************************************************************"
616 "*******\nYou are running over mc16d or mc16e sample but you are not using actual "
617 "mu reweighting!\nYou are strongly adviced to use it.\nCheck "
618 "https://twiki.cern.ch/twiki/bin/view/AtlasProtected/"
619 "TopxAODStartGuideR21#PRW_and_Lumicalc_files\n*************************************"
620 "**************************************************\n");
624 currentSystematic->auxdecor<
char>(
m_config->passEventSelectionDecoration()) =
625 passAnyEventSelection ? 1 : 0;
629 currentSystematic->hashValue() ==
m_config->nominalHashValue()) {
642 if (passAnyEventSelection && currentSystematic->hashValue() ==
m_config->nominalHashValue())
653 return StatusCode::SUCCESS;
666 bool pdfInCBK =
false;
671 std::string
p = pdf_set +
"_0";
673 std::string
pdfName = cbk->name();
695 std::string pdf_set = pdfentry.first;
698 bool foundPdf =
false;
700 std::string
pdfName = cbk->name();
710 ATH_MSG_ERROR(
"The force is not strong with us, young Padawan ...\n"
711 "You want to save weights to do PDF reweighting using '"
712 << pdf_set <<
"', which I figure has "
715 "There is metadata information for the sum of MC*PDF weights in "
717 "but none seem to refer to '"
719 <<
"' therefore I do not know how to estimate "
720 "the sum of weights before acceptance for this configuration.\n"
721 "May the force be with you in your next attempt.");
722 return StatusCode::FAILURE;
730 return StatusCode::SUCCESS;
761 ATH_MSG_ERROR(
"These are not the droids you are looking for.\n"
762 "You are running over skimmed derivations. We cannot determine "
763 "the sum of MC*PDF weights before skimming "
764 "because no PDF metadata is available in the file!");
765 return StatusCode::FAILURE;
769 for (
auto &pdf_result :
m_config->getLHAPDFResults())
780 m_tracker->writeTree(
"AnalysisTracking");
786 ATH_MSG_INFO(
"Events saved to output file nominal loose reconstruction tree: "
803 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
unsigned int m_eventSavedRecoLoose
const xAOD::EventInfo * m_info
Pointer to the event info - nullptr if not loaded, but that's probably a bad idea.
TopConfig A simple configuration that is NOT a singleton.
ToolHandle< top::ParticleLevelLoader > m_particleLevelLoader
bool m_recalculateNominalWeightSum
ReadStats & stats()
Access the object belonging to the current thread.
void start(bool clear=true)
Start the statistics collection.
unsigned int m_eventSavedParticle
StatusCode initialize() override
Maybe you want to run multiple selections (e+jets, mu+jets) on the same input files at the same time.
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
ToolHandle< top::ScaleFactorCalculator > m_topScaleFactors
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
ToolHandle< top::ObjectCollectionMaker > m_systObjMaker
std::unordered_map< std::string, std::vector< std::string > > m_boostedTaggersSFSysNames
Description of the class that is used to keep track of event counts.
unsigned int m_totalYieldSoFar
ConstMetaStorePtr_t inputMetaStore() const
StatusCode beginInputFile() override
void Print(::Option_t *option="") const
Print information about the collected statistics.
std::unique_ptr< top::AnalysisTrackingHelper > m_tracker
SampleXsection::showering m_showeringAlgo
std::unordered_map< std::string, std::unique_ptr< std::vector< float > > > m_totalEventsPdfWeighted
unsigned int m_eventSavedReco
std::vector< double > m_totalEventsWeighted_LHE3
std::shared_ptr< ConfigurationSettings > m_settings
top::TopObjectSelection * loadObjectSelection(const std::shared_ptr< top::TopConfig > &config)
Users may want to define (and load!) their own object selection.
ToolHandle< top::EventCleaningSelection > m_eventCleaning
bool readMetaData(TFile *inputFile, const std::shared_ptr< top::TopConfig > &config)
This function will be used to load the metadata object and pull information from it.
uint32_t runNumber() const
The current event's run number.
ToolHandle< top::TopToolStore > m_topTools
Loading tool which creates a particle level event object.
StatusCode endInputFile() override
TopEventMaker produce top::Event objects from xAOD::SystematicEvent objects.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
std::vector< double > m_totalEventsWeighted_LHE3_temp
xAOD::MuonContainer m_muons
Container of muons (can be sorted)
POOL::TEvent event(POOL::TEvent::kClassAccess)
xAOD::ElectronContainer m_electrons
Container of electrons (can be sorted)
unsigned int m_FTAGMapIndex
::StatusCode StatusCode
StatusCode definition for legacy code.
static ConfigurationSettings * get(bool reset=false)
Design patterns 101.
::StatusCode requestBeginInputFile()
register this algorithm to have an implementation of beginInputFile
Helper for collecting data for analysis tracking.
TopxAODAlg(const std::string &name, ISvcLocator *pSvcLocator)
unsigned int m_firstEvent
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
void parseCutBookkeepers(xAOD::TEvent &xaodEvent, const std::size_t size, std::vector< std::string > &names, std::vector< float > &sumW)
Search bookkeepers for ones matching AllExecutedEvents, and which originate from AOD before skimming.
Container that holds the Container of all CutBookkeepers.
ToolHandle< top::PDFScaleFactorCalculator > m_PDF_SF
static IOStats & instance()
Singleton object accessor.
unsigned int m_doPerfStats
std::vector< std::string > m_names_LHE3
ULong64_t getRawEventsBookkeeper(const xAOD::CutBookkeeperContainer *cutBookKeepers)
Get raw number of events before skimming from "AllExecutedEvents" bookkeeper.
StatusCode execute() override
ToolHandle< top::TopObjectSelection > m_objectSelection
std::string to_string(const DetectorType &type)
bool m_crashOnMetaDataFail
::StatusCode requestEndInputFile()
register this algorithm to have an implementation of endInputFile
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ULong64_t m_totalEventsInFiles
static PerfStats & instance()
Function accessing the singleton instance.
double m_totalEventsWeighted_temp
unsigned int m_eventSavedTruth
Class describing the basic event information.
std::unique_ptr< top::EventSelectionManager > m_eventSelectionManager
std::unique_ptr< top::EventSaverBase > m_eventSaver
StatusCode finalize() override
#define ATH_MSG_WARNING(x)
double m_totalEventsWeighted
std::string m_derivationStream
ToolHandle< PMGTools::IPMGTruthWeightTool > m_pmg_weightTool
void renameCutBookkeepers(std::vector< std::string > &bookkeeper_names, const std::vector< std::string > &pmg_weight_names)
Rename CutBookkeeper names according to MC generator weight names reported by PMGTruthWeightTool.
void stop()
Stop the statistics collection.
ToolHandle< top::TopEventMaker > m_topEventMaker
Very simple class to hold event data after reading from a file.
ToolHandle< top::CalcTtbarPartonHistory > m_topPartonHistory
std::string m_libraryNames
size_type size() const noexcept
Returns the number of elements in the collection.
top::EventSaverBase * loadEventSaver(const std::shared_ptr< top::TopConfig > &config)
Users may also want to write out custom ntuples / xAODs.
For testing PDF reweighting with LHAPDF6.
std::string m_configPath
properties
std::shared_ptr< TopConfig > m_config
bool m_saveEvent
save the event?