ATLAS Offline Software
Loading...
Searching...
No Matches
dqi::CorrelationYX Class Reference

#include <CorrelationYX.h>

Inheritance diagram for dqi::CorrelationYX:
Collaboration diagram for dqi::CorrelationYX:

Public Member Functions

 CorrelationYX ()
 CorrelationYX (const CorrelationYX &other)
virtual ~CorrelationYX ()
virtual dqm_core::Algorithm * clone ()
virtual dqm_core::Result * execute (const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config)
virtual void printDescription ()

Protected Member Functions

double GetFirstFromMap (const std::string &pname, const std::map< std::string, std::vector< double > > &params)
std::vector< double > GetVectorFromMap (const std::string &pname, const std::map< std::string, std::vector< double > > &params)
double GetFromMap (const std::string &pname, const std::map< std::string, double > &params)

Protected Attributes

std::string name

Detailed Description

Constructor & Destructor Documentation

◆ CorrelationYX() [1/2]

dqi::CorrelationYX::CorrelationYX ( )

Definition at line 32 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

34 : name("CorrelationYX")
35 {
36 dqm_core::AlgorithmManager::instance().registerAlgorithm( name, this );
37 }

◆ CorrelationYX() [2/2]

dqi::CorrelationYX::CorrelationYX ( const CorrelationYX & other)

Definition at line 40 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

42 : dqm_core::Algorithm(other)
43 , name(other.name)
44 {
45 }

◆ ~CorrelationYX()

dqi::CorrelationYX::~CorrelationYX ( )
virtual

Member Function Documentation

◆ clone()

dqm_core::Algorithm * dqi::CorrelationYX::clone ( )
virtual

◆ execute()

dqm_core::Result * dqi::CorrelationYX::execute ( const std::string & name,
const TObject & object,
const dqm_core::AlgorithmConfig & config )
virtual

Definition at line 63 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

65 {
66 TH1 * histogram;
67
68 if( object.IsA()->InheritsFrom( "TH1" ) ) {
69 histogram = (TH1*)&object;
70 if (histogram->GetDimension() > 2 ){
71 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
72 }
73 } else {
74 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
75 }
76
77 int binStart, binEnd;
78 int CountsTh;
79 int method;
80 double gmin;
81 double rmin;
82 try {
83 binStart = (int) GetFirstFromMap("BinStart", config.getParameters() );
84 binEnd = (int) GetFirstFromMap("BinEnd" , config.getParameters() );
85 rmin = GetFromMap( "CorrMin", config.getRedThresholds());
86 gmin = GetFromMap( "CorrMin", config.getGreenThresholds() );
87 }
88 catch ( dqm_core::Exception & ex ) {
89 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
90 }
91
92
93 double count = 0;
94 double avX = 0;
95 double avY = 0;
96 double avX2 = 0;
97 double avY2 = 0;
98 double avXY = 0;
99 double sdX = 0;
100 double sdY = 0;
101 double correlation=0;
102
103 int nbinx = histogram -> GetNbinsX();
104 int nbiny = histogram -> GetNbinsY();
105 if(binStart>binEnd) {
106 binStart= 1;
107 binEnd = histogram -> GetNbinsX();
108 }
109 int binSize = binEnd-binStart+1;
110
111 std::vector<double> contents;
112 contents.resize(binSize);
113 for(int i=0;i<binSize;i++) {
114 int binx = binStart+i;
115 contents[i]=0;
116 for ( int j = 1; j <= nbiny; ++j ) {
117 double content= histogram -> GetBinContent(binx,j);
119 for(int k=0; k!=content;k++) {
120 count ++ ;
121 avX += binx ;
122 avY += j ;
123 avX2 += binx*binx ;
124 avY2 += j*j ;
125 avXY += binx*j ;
126 }
127 }
128 }
129
130 if(count>0) {
131 avX = avX / count;
132 avY = avY / count;
133 avX2 = avX2 / count;
134 avY2 = avY2 / count;
135 avXY = avXY / count;
136 }
137
138 sdX = sqrt(avX2-avX*avX) ;
139 sdY = sqrt(avY2-avY*avY) ;
140 if(sdX>0&&sdY>0)correlation=(avXY-avX*avY)/(sdX*sdY);
141
142
143 ERS_DEBUG(1,"Number of entries for bins is "<< count );
144 ERS_DEBUG(1,"Correlation biny and binx is "<< correlation );
145 ERS_DEBUG(1,"Green: "<< gmin << " entries; Red: " << rmin << " entries ");
146
147 dqm_core::Result* result = new dqm_core::Result();
148
149
150
151 if ( correlation >= gmin ) {
152 result->status_ = dqm_core::Result::Green;
153 } else if ( correlation > rmin ) {
154 result->status_ = dqm_core::Result::Yellow;
155 } else {
156 result->status_ = dqm_core::Result::Red;
157 }
158 result->tags_["Correlation"] = correlation;
159
160
161 return result;
162 }
std::string histogram
Definition chains.cxx:52
double GetFromMap(const std::string &pname, const std::map< std::string, double > &params)
double GetFirstFromMap(const std::string &pname, const std::map< std::string, std::vector< double > > &params)
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
str content
Definition grepfile.py:56
#define IsA
Declare the TObject style functions.

◆ GetFirstFromMap()

double dqi::CorrelationYX::GetFirstFromMap ( const std::string & pname,
const std::map< std::string, std::vector< double > > & params )
protected

Definition at line 186 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

187 {
188 std::map<std::string,std::vector<double> >::const_iterator it = params.find(pname);
189 if ( it != params.end() && it->second.size() ){
190 return it->second[0];
191 }else {
192 throw dqm_core::BadConfig( ERS_HERE, "None", pname );
193 }
194 }

◆ GetFromMap()

double dqi::CorrelationYX::GetFromMap ( const std::string & pname,
const std::map< std::string, double > & params )
protected

Definition at line 206 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

207 {
208 std::map<std::string,double>::const_iterator it = params.find( pname );
209 if ( it != params.end() ){
210 return it->second;
211 }else {
212 throw dqm_core::BadConfig( ERS_HERE, "None", pname );
213 }
214 }

◆ GetVectorFromMap()

std::vector< double > dqi::CorrelationYX::GetVectorFromMap ( const std::string & pname,
const std::map< std::string, std::vector< double > > & params )
protected

Definition at line 196 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

197 {
198 std::map<std::string,std::vector<double> >::const_iterator it = params.find(pname);
199 if ( it != params.end() && it->second.size() ){
200 return it->second;
201 }else {
202 throw dqm_core::BadConfig( ERS_HERE, "None", pname );
203 }
204 }

◆ printDescription()

void dqi::CorrelationYX::printDescription ( )
virtual

Definition at line 166 of file MuonSpectrometer/MuonValidation/MuonDQA/MuonDQAMonitoring/dqmfAlgs/CorrelationYX.cxx.

168 {
169 std::string message;
170 message += "\n";
171 message += "Algorithm: \"" + name + "\"\n";
172 message += "Description: Counts the number of listed bins with entries above CountsTh\n";
173 message += "Parameters: BinStart first bin to be checked (1=first bin)\n";
174 message += " BinEnd last bin to be checked (nbin=last bin)\n";
175 message += " CorrMin minimum correlation Red/Green\n";
176 message += "\n";
177
178 std::cout << message;
179 }

Member Data Documentation

◆ name

std::string dqi::CorrelationYX::name
protected

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