65 {
67
68 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
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;
80 double gmin;
81 double rmin;
82 try {
87 }
88 catch ( dqm_core::Exception & ex ) {
89 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
90 }
91
92
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
105 if(binStart>binEnd) {
106 binStart= 1;
108 }
109 int binSize = binEnd-binStart+1;
110
113 for(
int i=0;
i<binSize;
i++) {
114 int binx = binStart+
i;
116 for ( int j = 1; j <= nbiny; ++j ) {
121 avX += binx ;
122 avY += j ;
123 avX2 += binx*binx ;
124 avY2 += j*j ;
125 avXY += binx*j ;
126 }
127 }
128 }
129
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
162 }
double GetFromMap(const std::string &pname, const std::map< std::string, double > ¶ms)
double GetFirstFromMap(const std::string &pname, const std::map< std::string, std::vector< double > > ¶ms)
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 ®x)
count how many occurances of a regx are in a string
#define IsA
Declare the TObject style functions.