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

#include <CheckBinSpike.h>

Inheritance diagram for dqm_algorithms::CheckBinSpike:
Collaboration diagram for dqm_algorithms::CheckBinSpike:

Public Member Functions

 CheckBinSpike (const std::string &name)
 
CheckBinSpikeclone ()
 
dqm_core::Resultexecute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
 
void printDescription (std::ostream &out)
 
void checkBinByBin (const TH1 *hist, float &result, float &detectedBin)
 

Private Attributes

std::string m_name
 

Detailed Description

Definition at line 18 of file CheckBinSpike.h.

Constructor & Destructor Documentation

◆ CheckBinSpike()

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

Definition at line 30 of file CheckBinSpike.cxx.

31  : m_name ( name )
32 {
33  dqm_core::AlgorithmManager::instance().registerAlgorithm("CheckBinSpike_" + name, this );
34 }

Member Function Documentation

◆ checkBinByBin()

void dqm_algorithms::CheckBinSpike::checkBinByBin ( const TH1 *  hist,
float &  result,
float &  detectedBin 
)

Definition at line 82 of file CheckBinSpike.cxx.

82  {
83  std::vector<float> values;
84  for ( int ibin=1; ibin<hist->GetNbinsX()+1; ibin++ ){
85  float ref = (hist->GetBinContent(ibin-1) + hist->GetBinContent(ibin+1))*0.5;
86  if ( ibin==1 ) {
87  ref = (hist->GetBinContent(hist->GetNbinsX()) + hist->GetBinContent(ibin+1))*0.5;
88  }
89  if ( ibin==hist->GetNbinsX() ){
90  ref = (hist->GetBinContent(1) + hist->GetBinContent(ibin-1))*0.5;
91  }
92  float test = hist->GetBinContent(ibin);
93  values.push_back(test/ref);
94  }
95  result = *std::max_element(values.begin(),values.end());
96  int bin = std::max_element(values.begin(),values.end()) - values.begin();
97  detectedBin = hist->GetXaxis()->GetBinCenter(bin);
98 }

◆ clone()

dqm_algorithms::CheckBinSpike * dqm_algorithms::CheckBinSpike::clone ( )

Definition at line 36 of file CheckBinSpike.cxx.

36  {
37  return new CheckBinSpike(m_name);
38 }

◆ execute()

dqm_core::Result * dqm_algorithms::CheckBinSpike::execute ( const std::string &  name,
const TObject &  data,
const dqm_core::AlgorithmConfig &  config 
)

Definition at line 41 of file CheckBinSpike.cxx.

41  {
42  // Cast to the type of TObject to assess
43  const TH1* h = dynamic_cast<const TH1*>( &data );
44  if( h == 0 ) {
45  throw dqm_core::BadConfig( ERS_HERE, name, "Cannot cast data to type TH1" );
46  }
47  const TH1* ref = dynamic_cast<const TH1*>( config.getReference() );
48  if( ref == 0 ) {
49  throw dqm_core::BadConfig( ERS_HERE, name, "Cannot obtain reference of type TH1" );
50  }
51  double greenThr, redThr;
52 
53  std::string thrName="MaxDist";
54 
55  try {
56  greenThr = dqm_algorithms::tools::GetFromMap( thrName, config.getGreenThresholds() );
57  redThr = dqm_algorithms::tools::GetFromMap( thrName, config.getRedThresholds() );
58  }
59  catch ( dqm_core::Exception & ex ) {
60  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
61 
62  }
63  float bin = 0;
64  float maxValue = 0;
66  std::unique_ptr<dqm_core::Result> result (new dqm_core::Result());
67  result->tags_["MaximumValue"] = maxValue;
68  result->tags_["SpottedBin"] = bin;
69 
70  if( maxValue < greenThr ) {
72  }
73  else if( maxValue > redThr ) {
74  result->status_ = dqm_core::Result::Red;
75  }
76  else {
77  result->status_ = dqm_core::Result::Yellow;
78  }
79  return result.release();
80 }

◆ printDescription()

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

Definition at line 100 of file CheckBinSpike.cxx.

100  {
101  std::string message;
102  message += "\n";
103  message += "Algorithm: \"" + m_name + "\"\n";
104  message += "Description: Checks if the maximum ratio between bins in a TH1F\n";
105  message += " is above a given threshold. Useful for peak detection\n";
106  message += "Parameters: none\n";
107  message += "\n";
108  out << message;
109 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::CheckBinSpike::m_name
private

Definition at line 27 of file CheckBinSpike.h.


The documentation for this struct was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
get_generator_info.result
result
Definition: get_generator_info.py:21
maxValue
#define maxValue(current, test)
Definition: CompoundLayerMaterialCreator.h:22
dqm_algorithms::CheckBinSpike::m_name
std::string m_name
Definition: CheckBinSpike.h:27
plotmaker.hist
hist
Definition: plotmaker.py:148
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
bin
Definition: BinsDiffFromStripMedian.h:43
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
ReweightUtils.message
message
Definition: ReweightUtils.py:15
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
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
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
dqm_algorithms::CheckBinSpike::CheckBinSpike
CheckBinSpike(const std::string &name)
Definition: CheckBinSpike.cxx:30
dqm_algorithms::CheckBinSpike::checkBinByBin
void checkBinByBin(const TH1 *hist, float &result, float &detectedBin)
Definition: CheckBinSpike.cxx:82
h
ref
const boost::regex ref(r_ef)
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114