ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::SideBand Class Reference

#include <SideBand.h>

Inheritance diagram for dqm_algorithms::SideBand:
Collaboration diagram for dqm_algorithms::SideBand:

Public Member Functions

 SideBand (const std::string &name)
virtual SideBandclone ()
virtual dqm_core::Result * execute (const std::string &, const TObject &obj, const dqm_core::AlgorithmConfig &conf)
virtual ~SideBand ()
void printDescription (std::ostream &out)

Private Attributes

std::string m_name

Detailed Description

Definition at line 39 of file SideBand.h.

Constructor & Destructor Documentation

◆ SideBand()

dqm_algorithms::SideBand::SideBand ( const std::string & name)

Definition at line 26 of file SideBand.cxx.

26 : m_name(name) {
27 dqm_core::AlgorithmManager::instance().registerAlgorithm(name,this);
28}

◆ ~SideBand()

virtual dqm_algorithms::SideBand::~SideBand ( )
inlinevirtual

Definition at line 47 of file SideBand.h.

47{};

Member Function Documentation

◆ clone()

dqm_algorithms::SideBand * dqm_algorithms::SideBand::clone ( )
virtual

Definition at line 30 of file SideBand.cxx.

30 {
31 return new SideBand( m_name );
32}
SideBand(const std::string &name)
Definition SideBand.cxx:26

◆ execute()

dqm_core::Result * dqm_algorithms::SideBand::execute ( const std::string & name,
const TObject & obj,
const dqm_core::AlgorithmConfig & conf )
virtual

Definition at line 34 of file SideBand.cxx.

37{
38 const TH1* histo;
39 if ( obj.IsA()->InheritsFrom("TH2") || obj.IsA()->InheritsFrom("TH3") )
40 {
41 throw dqm_core::BadConfig( ERS_HERE , name , " dimension > 1 ");
42 }
43 if ( obj.IsA()->InheritsFrom("TH1") )
44 {
45 ERS_DEBUG(2,"Got TH1 called: "<<obj.GetName()<<" of type:"<<obj.IsA()->GetName());
46 histo=static_cast<const TH1*>(&obj);
47 }
48 else
49 {
50 throw dqm_core::BadConfig( ERS_HERE ,name , " does not inherit from TH1");
51 }
52 // Configure the DQ algorithm
53 const bool UseUnderFlow = static_cast<bool>(dqm_algorithms::tools::GetFirstFromMap("UseUnderFlow", config.getParameters(), 0));
54 const bool UseOverFlow = static_cast<bool>(dqm_algorithms::tools::GetFirstFromMap("UseOverFlow", config.getParameters(), 0));
55 // the following is a duplicate of dqm_algorithms::tools::GetBinRange, but with different parameter names
56 const double notFound = -99999;
57 const double xmin = dqm_algorithms::tools::GetFirstFromMap("Min", config.getParameters(), notFound);
58 const double xmax = dqm_algorithms::tools::GetFirstFromMap("Max", config.getParameters(), notFound);
59 const int minbin = (xmin == notFound) ? 1 : histo->GetXaxis()->FindBin(xmin);
60 const int maxbin = (xmax == notFound) ? histo->GetNbinsX() : histo->GetXaxis()->FindBin(xmax);
61
62 double grThr, reThr; // Green and Red thresholds
63 try
64 {
65 grThr = dqm_algorithms::tools::GetFromMap("Threshold",config.getGreenThresholds() );
66 reThr = dqm_algorithms::tools::GetFromMap("Threshold",config.getRedThresholds() );
67 }
68 catch ( dqm_core::Exception & ex )
69 {
70 throw dqm_core::BadConfig(ERS_HERE,name,"Paramter: 'Threshold' is mandatory, cannot continue");
71 }
72
73 if ( m_name== "SideBand_Relative" && (grThr>1.0 || reThr>1.0) )
74 //non sense case: compare fraction and threshold >100%
75 {
76 throw dqm_core::BadConfig(ERS_HERE,m_name,"Configuration Error: Threshold>100%");
77 }
78#if DEBUG_LEVEL > 1
79 std::stringstream configuration;
80 configuration
81 << " - UseUnderFlow = " << UseUnderFlow << " - UseOverFlow = " << UseOverFlow
82 << " - Min = " << xmin << " - Max = " << xmax
83 << " - Green Threshold = " << grThr << " - Red Threshold = " << reThr;
84 ERS_DEBUG(2,"Configuration:"<<configuration.str());
85#endif
86 // Just a translation in something more readable...
87 const bool AbsoluteValue = ( m_name == "SideBand_Absolute" );
88 Double_t tot = histo->Integral( 1, histo->GetNbinsX() );
89 Double_t inside = histo->Integral( minbin , maxbin );
90 if ( UseUnderFlow ) tot+=histo->GetBinContent(0);
91 if ( UseOverFlow ) tot+=histo->GetBinContent(histo->GetNbinsX()+1);
92 Double_t sideband = tot-inside;
93 if ( !AbsoluteValue ) { // Compare fraction of events in sideband
94 // if (tot != 0) {
95 if (tot > 0. || tot < 0.) {// should be safer than !=
96 sideband /= tot;
97 }
98 }
99 ERS_DEBUG(2,"Total:"<<tot<<" SideBand:"<<sideband);
100 dqm_core::Result * result = new dqm_core::Result;
101 result->tags_.insert(std::make_pair("TotalIntegral",tot));
102 result->tags_.insert(std::make_pair("SideBands",sideband));
103
104
105 if (reThr> grThr) {
106 if ( sideband>reThr ){
107 ERS_DEBUG(1,"[RED] Result : "<<sideband);
108 result->status_=dqm_core::Result::Red;
109 return result;
110 } else if ( sideband > grThr ){
111 ERS_DEBUG(1,"[YELLOW] Result : "<<sideband);
112 result->status_=dqm_core::Result::Yellow;
113 return result;
114 }
115 }else {
116 if ( sideband < reThr ){
117 ERS_DEBUG(1,"[RED] Result : "<<sideband);
118 result->status_=dqm_core::Result::Red;
119 return result;
120 } else if ( sideband < grThr ){
121 ERS_DEBUG(1,"[YELLOW] Result : "<<sideband);
122 result->status_=dqm_core::Result::Yellow;
123 return result;
124 }
125 }
126
127 ERS_DEBUG(1,"[GREEN] Result");
128 result->status_=dqm_core::Result::Green;
129 return result;
130}
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
Int_t FindBin(const TAxis *axis, const double x)
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)

◆ printDescription()

void dqm_algorithms::SideBand::printDescription ( std::ostream & out)

Definition at line 132 of file SideBand.cxx.

132 {
133 std::stringstream msg;
134 msg<<m_name<<": Checks the integral of a histogram outside a specified range ";
135 if ( m_name=="SideBand_Absolute" )
136 msg<<" using an absolute threshold.";
137 else
138 msg<<" using a relative threshold.";
139 msg<<"\n\n";
140 out << msg.str() <<
141 "Parameter: UseUnderFlow: if != 0 include also underflow bin\n"
142 "Parameter: UseOverFlow: if != 0 include also overflow bin\n"
143 "Parameter: Min: Specify Lower limit (unset means full range)\n"
144 "Parameter: Max: Specify Upper limit (unset means full range)\n"
145 "Threshold: Threshold: How large or small the sidebands should be.\n"
146 " The comparison type (greater-than or less-than) depends on\n"
147 " the relative order of the green and red threshold value." << std::endl;
148}
MsgStream & msg
Definition testRead.cxx:32

Member Data Documentation

◆ m_name

std::string dqm_algorithms::SideBand::m_name
private

Definition at line 51 of file SideBand.h.


The documentation for this class was generated from the following files: