ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_SiTEfficiency.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 <TEfficiency.h>
16#include <TFile.h>
17
18namespace {
20}
21
23 dqm_core::AlgorithmManager::instance().registerAlgorithm( "AFP_SiTEfficiency", this );
24}
25
28
33
34dqm_core::Result*
36 const TObject& object,
37 const dqm_core::AlgorithmConfig& config ) {
38 if ( !object.IsA()->InheritsFrom( "TEfficiency" ) ) {
39 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TEfficiency" );
40 }
41
42 auto histogram = static_cast<const TEfficiency*>( &object );
43
44 auto gthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NEfficiency", config.getGreenThresholds() ) );
45 auto rthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NEfficiency", config.getRedThresholds() ) );
46 float efficiency = 0;
47
48 TH1* h_total = histogram->GetCopyTotalHisto();
49 TH1* h_passed = histogram->GetCopyPassedHisto();
50
51 float n_total = float ( h_total->GetEntries() );
52 float n_passed = float ( h_passed->GetEntries() );
53 efficiency = n_passed/n_total*100;
54
55 auto result = new dqm_core::Result();
56
57 // publish problematic bins
58 result->tags_[ "Plane efficiency = " ] = efficiency;
59
60 if ( efficiency == 0 )
61 result->status_ = dqm_core::Result::Undefined;
62 else if ( efficiency > gthreshold )
63 result->status_ = dqm_core::Result::Green;
64 else if ( ( efficiency <= gthreshold ) && (efficiency > rthreshold) )
65 result->status_ = dqm_core::Result::Yellow;
66 else
67 result->status_ = dqm_core::Result::Red;
68
69 return result;
70}
71
73 out << "AFP_SiTEfficiency: Print out if general plane efficiency is less than limit"<< std::endl;
74}
std::map< std::string, double > instance
std::string histogram
Definition chains.cxx:52
void printDescriptionTo(std::ostream &out) override
dqm_core::Result * execute(const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config) override
AFP_SiTEfficiency * clone() override
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
#define IsA
Declare the TObject style functions.