ATLAS Offline Software
Loading...
Searching...
No Matches
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
17namespace {
19}
20
22 dqm_core::AlgorithmManager::instance().registerAlgorithm( "AFP_ToFEfficiency", this );
23}
24
27
32
33dqm_core::Result*
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 )
63 result->status_ = dqm_core::Result::Undefined;
64 else if ( each_tr_status[0] == 4 )
65 result->status_ = dqm_core::Result::Green;
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}
std::map< std::string, double > instance
std::string histogram
Definition chains.cxx:52
dqm_core::Result * execute(const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config) override
AFP_ToFEfficiency * clone() override
void printDescriptionTo(std::ostream &out) override
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
#define IsA
Declare the TObject style functions.