ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
dqm_algorithms::Bins_GreaterThanAbs_Threshold Struct Reference

#include <Bins_GreaterThanAbs_Threshold.h>

Inheritance diagram for dqm_algorithms::Bins_GreaterThanAbs_Threshold:
Collaboration diagram for dqm_algorithms::Bins_GreaterThanAbs_Threshold:

Public Member Functions

 Bins_GreaterThanAbs_Threshold ()
 
BinThresholdclone ()
 
dqm_core::Resultexecute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
 
bool CompareBinThreshold (const std::string &objname, double bincontent, double threshold)
 
void printDescription (std::ostream &out)
 

Private Attributes

std::string m_name
 

Detailed Description

Definition at line 16 of file Bins_GreaterThanAbs_Threshold.h.

Constructor & Destructor Documentation

◆ Bins_GreaterThanAbs_Threshold()

dqm_algorithms::Bins_GreaterThanAbs_Threshold::Bins_GreaterThanAbs_Threshold ( )
inline

Definition at line 18 of file Bins_GreaterThanAbs_Threshold.h.

18 : BinThreshold("GreaterThanAbs") {};

Member Function Documentation

◆ clone()

dqm_algorithms::BinThreshold * dqm_algorithms::BinThreshold::clone ( )
inherited

Definition at line 43 of file BinThreshold.cxx.

44 {
45 
46  return new BinThreshold( m_name );
47 }

◆ CompareBinThreshold()

bool dqm_algorithms::BinThreshold::CompareBinThreshold ( const std::string &  objname,
double  bincontent,
double  threshold 
)
inherited

Definition at line 175 of file BinThreshold.cxx.

175  {
176 
177  if (type == "GreaterThan") return (bincontent > threshold);
178  if (type == "GreaterThanAbs") return (std::abs(bincontent) > threshold);
179  if (type == "GreaterThanNonZeroMedian") return (bincontent > threshold);
180  if (type == "LessThan") return (bincontent < threshold);
181  if (type == "LessThanAbs") return (std::abs(bincontent) < threshold);
182  if (type == "LessThanNonZeroMedian") return (bincontent < threshold);
183  if (type == "LessThanEqual") return (bincontent <= threshold);
184  if (type == "GreaterThanEqual") return (bincontent >= threshold);
185  if (type == "Equal") return (bincontent == threshold);
186  if (type == "NotEqual") return (bincontent != threshold);
187 
188  return 0;
189 }

◆ execute()

dqm_core::Result * dqm_algorithms::BinThreshold::execute ( const std::string &  name,
const TObject &  object,
const dqm_core::AlgorithmConfig &  config 
)
inherited

Definition at line 51 of file BinThreshold.cxx.

54 {
55  const TH1 * histogram;
56 
57  if( object.IsA()->InheritsFrom( "TH1" ) ) {
58  histogram = static_cast<const TH1*>(&object);
59  if (histogram->GetDimension() > 2 ){
60  throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
61  }
62  } else {
63  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
64  }
65 
66  const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
67  const bool publish = (bool) dqm_algorithms::tools::GetFirstFromMap( "PublishBins", config.getParameters(), 0);
68  const int maxpublish = (int) dqm_algorithms::tools::GetFirstFromMap( "MaxPublish", config.getParameters(), 20);
69 
70  if (histogram->GetEntries() < minstat ) {
72  result->tags_["InsufficientEntries"] = histogram->GetEntries();
73  return result;
74  }
75 
76  double bin_threshold;
77  double gthreshold;
78  double rthreshold;
79  try {
80  bin_threshold = dqm_algorithms::tools::GetFirstFromMap( "BinThreshold", config.getParameters() );
81  rthreshold = dqm_algorithms::tools::GetFromMap( "NBins", config.getRedThresholds() );
82  gthreshold = dqm_algorithms::tools::GetFromMap( "NBins", config.getGreenThresholds() );
83  }
84  catch ( dqm_core::Exception & ex ) {
85  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
86  }
87 
88 
89  int count = 0;
90  std::vector<int> range=dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
92  TH1* resulthisto;
93  if (histogram->InheritsFrom("TH2")) {
94  resulthisto=(TH1*)(histogram->Clone());
95  } else if (histogram->InheritsFrom("TH1")) {
96  resulthisto=(TH1*)(histogram->Clone());
97  } else {
98  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
99  }
100 
101  resulthisto->Reset();
102  if(m_name.find("Median")!=std::string::npos){
103  std::vector<double> bin_vals;
104  for ( int i = range[0]; i <= range[1]; ++i ) {
105  for ( int j = range[2]; j <= range[3]; ++j ) {
106  if(histogram -> GetBinContent(i,j) > 0) bin_vals . push_back( histogram -> GetBinContent(i,j) );
107  }
108  }
109  std::sort(bin_vals.begin(), bin_vals.end());
110  unsigned bin_vals_size = bin_vals.size();
111  double median = 0;
112  if(bin_vals_size%2==0 && bin_vals_size>1) median = (bin_vals.at(bin_vals_size/2-1)+bin_vals.at(bin_vals_size/2))/2;
113  else if(bin_vals_size%2==1 && bin_vals_size>1) median = bin_vals.at(bin_vals_size/2-1);
114  else if(bin_vals_size==1) median = bin_vals.at(0);
115 
116  double min_bin_threshold = dqm_algorithms::tools::GetFirstFromMap( "MinBinThreshold", config.getParameters() , -99999);
117  double max_bin_threshold = dqm_algorithms::tools::GetFirstFromMap( "MaxBinTrheshold", config.getParameters() , -99999);
118  bin_threshold=median*bin_threshold;
119 
120  bin_threshold = std::max(bin_threshold, min_bin_threshold);
121  if(max_bin_threshold > -1 ) bin_threshold = std::min(bin_threshold, max_bin_threshold);
122 
123  result->tags_["Effective_BinThreshold"] = bin_threshold;
124  }
125 
126  for ( int i = range[0]; i <= range[1]; ++i ) {
127  for ( int j = range[2]; j <= range[3]; ++j ) {
128  double content= histogram -> GetBinContent(i,j);
129  if ( CompareBinThreshold(m_name, content, bin_threshold )) {
130  ++count;
131  resulthisto->SetBinContent(i,j,content);
132  if (publish && count< maxpublish){
134  }
135  }
136  }
137  }
138 
139  ERS_DEBUG(1,"Number of bins " << m_name << " treshold of " << bin_threshold << " is " << count );
140  ERS_DEBUG(1,"Green threshold: "<< gthreshold << " bin(s); Red threshold : " << rthreshold << " bin(s) ");
141 
142  int TotalBins = (int) dqm_algorithms::tools::GetFirstFromMap( "TotalBins", config.getParameters() , -99999);
143  if(TotalBins > -10){
144  if(TotalBins < 0) TotalBins = histogram->GetNbinsX()*histogram->GetNbinsY()*histogram->GetNbinsZ();
145  int effectiveCount = count - (histogram->GetNbinsX()*histogram->GetNbinsY()*histogram->GetNbinsZ() - TotalBins);
146  if(m_name.find("LessThan")!=std::string::npos) result->tags_["NBins_%"] = 100.*effectiveCount/TotalBins;
147  else result->tags_["NBins_%"] = 100.*count/TotalBins;
148  }
149 
150  result->tags_["NBins"] = count;
151  result->object_ = (boost::shared_ptr<TObject>)(TObject*)(resulthisto);
152  if (gthreshold > rthreshold) {
153  if ( count >= gthreshold ) {
154  result->status_ = dqm_core::Result::Green;
155  } else if ( count > rthreshold ) {
156  result->status_ = dqm_core::Result::Yellow;
157  } else {
158  result->status_ = dqm_core::Result::Red;
159  }
160  } else {
161  if ( count <= gthreshold ) {
162  result->status_ = dqm_core::Result::Green;
163  } else if ( count < rthreshold ) {
164  result->status_ = dqm_core::Result::Yellow;
165  } else {
166  result->status_ = dqm_core::Result::Red;
167  }
168  }
169 
170  return result;
171 
172 }

◆ printDescription()

void dqm_algorithms::BinThreshold::printDescription ( std::ostream &  out)
inherited

Definition at line 193 of file BinThreshold.cxx.

194 {
195 
196  out<<"Bins_"+m_name+"_Threshold: Checks for number of bins "+m_name+" threshold value\n"<<std::endl;
197 
198  out<<"Mandatory Parameter: BinThreshold: Look for bins "+m_name+" BinTreshold; Count number of bins satifying requirement \n"<<std::endl;
199 
200  out<<"Mandatory Green/Red Threshold: NBins: Number of bins satifying "+m_name+" BinThreshold constraint to give Green/Red result\n"<<std::endl;
201 
202  out<<"Optional Parameter: PublishBins: Save bins which are different from average in Result (set to 1)\n"<<std::endl;
203  out<<"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
204  out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
205  out<<"Optional Parameter: xmin: minimum x range"<<std::endl;
206  out<<"Optional Parameter: xmax: maximum x range"<<std::endl;
207  out<<"Optional Parameter: ymin: minimum y range"<<std::endl;
208  out<<"Optional Parameter: ymax: maximum y range\n"<<std::endl;
209 
210 
211 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::BinThreshold::m_name
privateinherited

Definition at line 30 of file BinThreshold.h.


The documentation for this struct was generated from the following file:
dqm_algorithms::tools::GetBinRange
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:380
dqm_algorithms::BinThreshold::m_name
std::string m_name
Definition: BinThreshold.h:30
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::BinThreshold::CompareBinThreshold
bool CompareBinThreshold(const std::string &objname, double bincontent, double threshold)
Definition: BinThreshold.cxx:175
InDet::median
float median(std::vector< float > &Vec)
Definition: BTagVrtSec.cxx:35
dqm_algorithms::tools::PublishBin
void PublishBin(const TH1 *histogram, int xbin, int ybin, double content, dqm_core::Result *result)
Definition: AlgorithmHelper.cxx:426
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
grepfile.content
string content
Definition: grepfile.py:56
lumiFormat.i
int i
Definition: lumiFormat.py:85
dqm_algorithms::BinThreshold::BinThreshold
BinThreshold(const std::string &name)
Definition: BinThreshold.cxx:36
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.handimod.Green
int Green
Definition: handimod.py:524
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
threshold
Definition: chainparser.cxx:74
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
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
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
histogram
std::string histogram
Definition: chains.cxx:52