ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_Sync_check.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 <TProfile.h>
16#include <TFile.h>
17
18namespace {
20}
21
23 dqm_core::AlgorithmManager::instance().registerAlgorithm( "AFP_Sync_check", this );
24}
25
28
33
34dqm_core::Result*
36 const TObject& object,
37 const dqm_core::AlgorithmConfig& config ) {
38 if ( !object.IsA()->InheritsFrom( "TProfile" ) ) {
39 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TProfile" );
40 }
41
42 auto histogram = static_cast<const TProfile*>( &object );
43
44 auto gthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "FractionBadLBs", config.getGreenThresholds() ) );
45 auto rthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "FractionBadLBs", config.getRedThresholds() ) );
46 auto dif_limit = static_cast<float>( dqm_algorithms::tools::GetFirstFromMap( "dif_limit", config.getParameters() ) );
47
48 std::vector<double> bad_errs;
49 std::vector<int> bad_lbs;
50 int nonZerocounter = 0;
51 double percentBadBins = -10.0;
52
53 for (int i = 1; i <= 2000; i++)
54 {
55 if (abs(histogram->GetBinContent(i)) >= dif_limit)
56 {
57 bad_errs.push_back( histogram->GetBinContent(i) );
58 bad_lbs.push_back(i);
59 }
60 if (histogram->GetBinContent(i) != 0)
61 nonZerocounter++;
62 }
63 percentBadBins = double( bad_errs.size() )/double(nonZerocounter)*100;
64
65 auto result = new dqm_core::Result();
66
67 // publish problematic bins
68 result->tags_[ "% Bad bins " ] = percentBadBins;
69 for ( int i = 0; i < int(bad_errs.size()); ++i )
70 {
71 auto tag = ( std::ostringstream() << "LB " << bad_lbs[i] ).str();
72 result->tags_[ tag ] = bad_errs[i];
73 }
74
75 if ( nonZerocounter == 0 )
76 result->status_ = dqm_core::Result::Undefined;
77 else if ( percentBadBins > rthreshold )
78 result->status_ = dqm_core::Result::Red;
79 else if ( percentBadBins > gthreshold )
80 result->status_ = dqm_core::Result::Yellow;
81 else
82 result->status_ = dqm_core::Result::Green;
83
84 return result;
85}
86
88 out << "AFP_Sync_check: Print out fraction of bad bins where module/station is out of synchronization\n"
89 << "Required Parameter: dif_limit: threshold for content of the individual bin to be assumed out of sync" << std::endl;
90}
std::map< std::string, double > instance
std::string histogram
Definition chains.cxx:52
AFP_Sync_check * clone() override
void printDescriptionTo(std::ostream &out) override
dqm_core::Result * execute(const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config) 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.