2323// ROOT
2424#include < TH1.h>
2525#include < TLatex.h>
26+ #include < TMath.h>
2627#include < DataFormatsParameters/GRPLHCIFData.h>
2728#include < DataFormatsQualityControl/FlagType.h>
2829#include < DetectorsBase/GRPGeomHelper.h>
@@ -38,27 +39,28 @@ void RawDataReaderCheck::configure()
3839{
3940 // reading the parameters from the config.json
4041 // if not available, setting a default value
41- std::string param = mCustomParameters .atOrDefaultValue (" thresholdRateBad" , " 0.15" );
42+ // the threshold values are nSigma
43+ std::string param = mCustomParameters .atOrDefaultValue (" thresholdRateBad" , " 3" );
4244 mThresholdRateBad = std::stof (param);
43- if (mThresholdRateBad > 1 || mThresholdRateBad < 0 ) {
44- mThresholdRateBad = 0.15 ;
45+ if (mThresholdRateBad > 4 || mThresholdRateBad < 0 ) {
46+ mThresholdRateBad = 3 ;
4547 }
4648
47- param = mCustomParameters .atOrDefaultValue (" thresholdRateMedium" , " 0.1 " );
49+ param = mCustomParameters .atOrDefaultValue (" thresholdRateMedium" , " 2 " );
4850 mThresholdRateMedium = std::stof (param);
49- if (mThresholdRateMedium > 1 || mThresholdRateMedium < 0 ) {
50- mThresholdRateMedium = 0.1 ;
51+ if (mThresholdRateMedium > 4 || mThresholdRateMedium < 0 ) {
52+ mThresholdRateMedium = 2 ;
5153 }
5254
53- param = mCustomParameters .atOrDefaultValue (" thresholdRateRatioBad" , " 0.1 " );
55+ param = mCustomParameters .atOrDefaultValue (" thresholdRateRatioBad" , " 3 " );
5456 mThresholdRateRatioBad = std::stof (param);
55- if (mThresholdRateRatioBad > 1 || mThresholdRateRatioBad < 0 ) {
56- mThresholdRateRatioBad = 0.1 ;
57+ if (mThresholdRateRatioBad > 4 || mThresholdRateRatioBad < 0 ) {
58+ mThresholdRateRatioBad = 3 ;
5759 }
58- param = mCustomParameters .atOrDefaultValue (" thresholdRateRatioMedium" , " 0.05 " );
59- mThresholdRateRatioBad = std::stof (param);
60- if (mThresholdRateRatioMedium > 1 || mThresholdRateRatioMedium < 0 ) {
61- mThresholdRateRatioMedium = 0.05 ;
60+ param = mCustomParameters .atOrDefaultValue (" thresholdRateRatioMedium" , " 2 " );
61+ mThresholdRateRatioMedium = std::stof (param);
62+ if (mThresholdRateRatioMedium > 4 || mThresholdRateRatioMedium < 0 ) {
63+ mThresholdRateRatioMedium = 2 ;
6264 }
6365}
6466
@@ -104,10 +106,11 @@ Quality RawDataReaderCheck::check(std::map<std::string, std::shared_ptr<MonitorO
104106 delete mHistInputPrevious ;
105107 result.set (setQualityResult (mVecIndexBad , mVecIndexMedium ));
106108 }
109+ mHistAbsolute = (TH1D*)h->Clone ();
107110 mHistInputPrevious = (TH1D*)h->Clone ();
108111 } else if (mo->getName () == " inputRatio" ) {
109112 if (mHistInputRatioPrevious ) {
110- checkChange (h, mHistInputRatioPrevious );
113+ checkChangeOfRatio (h, mHistInputRatioPrevious , mHistAbsolute );
111114 delete mHistInputRatioPrevious ;
112115 result.set (setQualityResult (mVecIndexBad , mVecIndexMedium ));
113116 }
@@ -118,10 +121,11 @@ Quality RawDataReaderCheck::check(std::map<std::string, std::shared_ptr<MonitorO
118121 delete mHistClassesPrevious ;
119122 result.set (setQualityResult (mVecIndexBad , mVecIndexMedium ));
120123 }
124+ mHistAbsolute = (TH1D*)h->Clone ();
121125 mHistClassesPrevious = (TH1D*)h->Clone ();
122126 } else if (mo->getName () == " classRatio" ) {
123127 if (mHistClassRatioPrevious ) {
124- checkChange (h, mHistClassRatioPrevious );
128+ checkChangeOfRatio (h, mHistClassRatioPrevious , mHistAbsolute );
125129 delete mHistClassRatioPrevious ;
126130 result.set (setQualityResult (mVecIndexBad , mVecIndexMedium ));
127131 }
@@ -139,14 +143,34 @@ int RawDataReaderCheck::checkChange(TH1D* mHist, TH1D* mHistPrev)
139143 // / this function check how much the rates differ from previous cycle
140144 float thrBad = mThresholdRateBad ;
141145 float thrMedium = mThresholdRateMedium ;
142- if (mFlagRatio ) {
143- thrBad = mThresholdRateRatioBad ;
144- thrMedium = mThresholdRateRatioMedium ;
146+ for (size_t i = 1 ; i < mHist ->GetXaxis ()->GetNbins () + 1 ; i++) { // Check how many inputs/classes changed more than a threshold value
147+ double val = mHist ->GetBinContent (i);
148+ double valPrev = mHistPrev ->GetBinContent (i);
149+ double relDiff = (valPrev != 0 || val != 0 ) ? (val - valPrev) / TMath::Sqrt (val) : 0 ;
150+ if (TMath::Abs (relDiff) > thrBad) {
151+ mVecIndexBad .push_back (i - 1 );
152+ } else if (TMath::Abs (relDiff) > thrMedium) {
153+ mVecIndexMedium .push_back (i - 1 );
154+ }
155+ }
156+ return 0 ;
157+ }
158+ int RawDataReaderCheck::checkChangeOfRatio (TH1D* mHist , TH1D* mHistPrev , TH1D* mHistAbs )
159+ {
160+ // / this function check how much the rates differ from previous cycle
161+ float thrBad = mThresholdRateRatioBad ;
162+ float thrMedium = mThresholdRateRatioMedium ;
163+ int binMB;
164+ for (int i = 1 ; i < mHist ->GetXaxis ()->GetNbins () + 1 ; i++) {
165+ if (mHist ->GetBinContent (i) == mHistPrev ->GetBinContent (i) && mHist ->GetBinContent (i) == 1 ) {
166+ binMB = i;
167+ break ;
168+ }
145169 }
146170 for (size_t i = 1 ; i < mHist ->GetXaxis ()->GetNbins () + 1 ; i++) { // Check how many inputs/classes changed more than a threshold value
147171 double val = mHist ->GetBinContent (i);
148172 double valPrev = mHistPrev ->GetBinContent (i);
149- double relDiff = (valPrev != 0 ) ? (val - valPrev) / valPrev : 0 ;
173+ double relDiff = (val != 0 || mHistAbs -> GetBinContent (i) != 0 ) ? (val - valPrev) / (val * TMath::Sqrt ( 1 / mHistAbs -> GetBinContent (binMB) + 1 / mHistAbs -> GetBinContent (i))) : 0 ;
150174 if (TMath::Abs (relDiff) > thrBad) {
151175 mVecIndexBad .push_back (i - 1 );
152176 } else if (TMath::Abs (relDiff) > thrMedium) {
@@ -242,20 +266,21 @@ void RawDataReaderCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality che
242266 }
243267 h->GetXaxis ()->SetLabelSize (0.045 );
244268 h->GetXaxis ()->LabelsOption (" v" );
269+ h->GetXaxis ()->CenterLabels (true );
245270 }
246271 if (checkResult == Quality::Bad) {
247272 msg->SetTextColor (kRed );
248273 msg->SetNDC ();
249274 h->GetListOfFunctions ()->Add (msg->Clone ());
250- msg = std::make_shared<TLatex>(0.45 , 0.75 , Form (" Number of %s with big %s rate change: %lu" , groupName.c_str (), relativeness.c_str (), mVecIndexBad .size ()));
275+ msg = std::make_shared<TLatex>(0.45 , 0.70 , Form (" Number of %s with big %s rate change: %lu" , groupName.c_str (), relativeness.c_str (), mVecIndexBad .size ()));
251276 msg->SetTextSize (0.03 );
252277 msg->SetNDC ();
253278 h->GetListOfFunctions ()->Add (msg->Clone ());
254279 for (size_t i = 0 ; i < mVecIndexBad .size (); i++) {
255280 if (mFlagInput ) {
256- msg = std::make_shared<TLatex>(0.45 , 0.7 - i * 0.05 , Form (" Check %s %s" , ctpinputs[mVecIndexBad [i]], groupName.c_str ()));
281+ msg = std::make_shared<TLatex>(0.45 , 0.65 - i * 0.05 , Form (" Check %s %s" , ctpinputs[mVecIndexBad [i]], groupName.c_str ()));
257282 } else {
258- msg = std::make_shared<TLatex>(0.45 , 0.7 - i * 0.05 , Form (" Check %s with Index: %d " , groupName.c_str (), mVecIndexBad [i]));
283+ msg = std::make_shared<TLatex>(0.45 , 0.65 - i * 0.05 , Form (" Check %s %s " , groupName.c_str (), h-> GetXaxis ()-> GetBinLabel ( mVecIndexBad [i] + 1 ) ));
259284 }
260285 msg->SetTextSize (0.03 );
261286 msg->SetNDC ();
0 commit comments