ATLAS Offline Software
AFP_ToFEfficiency.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 #include <dqm_core/AlgorithmManager.h>
9 #include "dqm_core/AlgorithmConfig.h"
10 #include <dqm_core/exceptions.h>
11 
12 #include <TDirectory.h>
13 #include <TH1.h>
14 #include <TH2.h>
15 #include <TFile.h>
16 
17 namespace {
19 }
20 
22  dqm_core::AlgorithmManager::instance().registerAlgorithm( "AFP_ToFEfficiency", this );
23 }
24 
26 }
27 
30  return new AFP_ToFEfficiency();
31 }
32 
35  const TObject& object,
36  const dqm_core::AlgorithmConfig& config ) {
37  if ( !object.IsA()->InheritsFrom( "TH2" ) ) {
38  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH2" );
39  }
40 
41  auto histogram = static_cast<const TH2D*>( &object );
42 
43  auto gthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NbadTrains", config.getGreenThresholds() ) );
44  auto rthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NbadTrains", config.getRedThresholds() ) );
45  auto eff_limit = static_cast<float>( dqm_algorithms::tools::GetFirstFromMap( "eff_limit", config.getParameters() ) );
46 
47  uint32_t each_tr_status[2] = {};
48  for (uint32_t i = 1; i < 5; ++i)
49  {
50  float current_eff = histogram->GetBinContent(histogram->GetBin(5,i));
51  if (current_eff >= eff_limit)
52  each_tr_status[0]++;
53  else
54  each_tr_status[1]++;
55  }
56 
57  auto result = new dqm_core::Result();
58 
59  // publish problematic bins
60  result->tags_[ ("N Trains with efficiency less than " + (std::to_string(eff_limit)).substr(0,4)).c_str() ] = each_tr_status[1];
61 
62  if ( each_tr_status[0]==0 && each_tr_status[1]==0 )
64  else if ( each_tr_status[0] == 4 )
66  else if ( each_tr_status[1] >= gthreshold && each_tr_status[1] < rthreshold )
67  result->status_ = dqm_core::Result::Yellow;
68  else
69  result->status_ = dqm_core::Result::Red;
70 
71  return result;
72 }
73 
75  out << "AFP_ToFEfficiency: Print out how many trains have efficiency less than limit\n"
76  << "Required Parameter: eff_limit: threshold percentage of efficiency" << std::endl;
77 }
Undefined
@ Undefined
Definition: MaterialTypes.h:8
get_generator_info.result
result
Definition: get_generator_info.py:21
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
dqm_algorithms::AFP_ToFEfficiency
Definition: AFP_ToFEfficiency.h:21
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
AFP_ToFEfficiency.h
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
lumiFormat.i
int i
Definition: lumiFormat.py:85
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
dqm_algorithms::AFP_ToFEfficiency::~AFP_ToFEfficiency
~AFP_ToFEfficiency()
Definition: AFP_ToFEfficiency.cxx:25
python.handimod.Green
int Green
Definition: handimod.py:524
dqm_algorithms::AFP_ToFEfficiency::AFP_ToFEfficiency
AFP_ToFEfficiency()
Definition: AFP_ToFEfficiency.cxx:21
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
dqm_algorithms::AFP_ToFEfficiency::printDescriptionTo
void printDescriptionTo(std::ostream &out) override
Definition: AFP_ToFEfficiency.cxx:74
dqm_algorithms::AFP_ToFEfficiency::clone
AFP_ToFEfficiency * clone() override
Definition: AFP_ToFEfficiency.cxx:29
AlgorithmHelper.h
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114
pickleTool.object
object
Definition: pickleTool.py:30
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
dqm_algorithms::AFP_ToFEfficiency::execute
dqm_core::Result * execute(const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config) override
Definition: AFP_ToFEfficiency.cxx:34
histogram
std::string histogram
Definition: chains.cxx:52