@@ -56,12 +56,12 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
5656 (void )moName;
5757 // For -> Histo to check
5858 for (int ih = 0 ; ih < (int )mVectHistoCheck .size (); ih++) {
59- mVectHistoCheck .at (ih).numE = 0 ;
60- mVectHistoCheck .at (ih).numW = 0 ;
61- mVectHistoCheck .at (ih).stringW = " " ;
62- mVectHistoCheck .at (ih).stringE = " " ;
6359 if (mo->getName () == mVectHistoCheck .at (ih).nameHisto ) {
6460 if ((mo->getName () == " hpedSummary" )) {
61+ mVectHistoCheck .at (ih).numE = 0 ;
62+ mVectHistoCheck .at (ih).numW = 0 ;
63+ mVectHistoCheck .at (ih).stringW = " " ;
64+ mVectHistoCheck .at (ih).stringE = " " ;
6565 auto * h = dynamic_cast <TH1*>(mo->getObject ());
6666 if (h == nullptr ) {
6767 ILOG (Error, Support) << " could not cast hpedSummary to TH1*" << ENDM;
@@ -87,6 +87,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
8787 }
8888
8989 if ((mo->getName () == " hAlignPlot" ) || (mo->getName () == " hAlignPlotShift" )) {
90+ mVectHistoCheck .at (ih).numE = 0 ;
91+ mVectHistoCheck .at (ih).numW = 0 ;
92+ mVectHistoCheck .at (ih).stringW = " " ;
93+ mVectHistoCheck .at (ih).stringE = " " ;
9094 int flag_ch_empty = 1 ;
9195 int flag_all_ch_empty = 1 ;
9296 auto * h = dynamic_cast <TH2*>(mo->getObject ());
@@ -128,6 +132,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
128132 }
129133
130134 if (mo->getName () == " herrorSummary" ) {
135+ mVectHistoCheck .at (ih).numE = 0 ;
136+ mVectHistoCheck .at (ih).numW = 0 ;
137+ mVectHistoCheck .at (ih).stringW = " " ;
138+ mVectHistoCheck .at (ih).stringE = " " ;
131139 int flag_ch_empty = 1 ;
132140 auto * h = dynamic_cast <TH2*>(mo->getObject ());
133141 if (h == nullptr ) {
@@ -161,6 +169,36 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
161169 flag_ch_empty = 1 ;
162170 }
163171 }
172+ if (mo->getName () == " hBCAlignPlot" ) {
173+ mVectHistoCheck .at (ih).numE = 0 ;
174+ mVectHistoCheck .at (ih).numW = 0 ;
175+ mVectHistoCheck .at (ih).stringW = " " ;
176+ mVectHistoCheck .at (ih).stringE = " " ;
177+ bool ratio_array[12 ];
178+ float ratio = 0.0 ;
179+ auto * h = dynamic_cast <TH2*>(mo->getObject ());
180+ if (h == nullptr ) {
181+ ILOG (Error, Support) << " could not cast herrorSummary to TH2*" << ENDM;
182+ return Quality::Null;
183+ }
184+ if ((int )h->GetNbinsX () != (int )mVectHistoCheck .at (ih).paramch .size ()) {
185+ return Quality::Null;
186+ }
187+ for (int x = 0 ; x < h->GetNbinsX (); x++) {
188+ for (int y = 0 ; y < h->GetNbinsY (); y++) {
189+ ratio = (h->GetBinContent (x + 1 , y + 1 )) / (h->GetBinContent (x + 1 , REFERENCE_BIN));
190+ if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) {
191+ ratio_array[y] = true ;
192+ } else {
193+ ratio_array[y] = false ;
194+ }
195+ }
196+ if (!std::equal (std::begin (ratio_array), std::end (ratio_array), std::begin (COMPARATOR_ARRAY))) {
197+ mVectHistoCheck .at (ih).numE += 1 ;
198+ mVectHistoCheck .at (ih).stringE = mVectHistoCheck .at (ih).stringE + mVectHistoCheck .at (ih).paramch .at (x).ch + " " ;
199+ }
200+ }
201+ }
164202 // check result check
165203 if (mVectHistoCheck .at (ih).numW == 0 && mVectHistoCheck .at (ih).numE == 0 ) {
166204 result = Quality::Good;
@@ -175,7 +213,7 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
175213 if (mVectHistoCheck .at (ih).numE > 0 ) {
176214 result = Quality::Bad;
177215 result.addFlag (FlagTypeFactory::Unknown (),
178- " It is bad because " + std::to_string (mVectHistoCheck .at (ih).numW ) + " channels:" + mVectHistoCheck .at (ih).stringE + " have a value in the bad range" );
216+ " It is bad because " + std::to_string (mVectHistoCheck .at (ih).numE ) + " channels:" + mVectHistoCheck .at (ih).stringE + " have a value in the bad range" );
179217 mVectHistoCheck .at (ih).quality = 3 ;
180218 }
181219 }
@@ -188,8 +226,6 @@ std::string ZDCRawDataCheck::getAcceptedType() { return "TH1"; }
188226
189227void ZDCRawDataCheck::beautify (std::shared_ptr<MonitorObject> mo, Quality checkResult)
190228{
191- // dumpStruct();
192-
193229 for (int ih = 0 ; ih < (int )mVectHistoCheck .size (); ih++) {
194230
195231 if (mo->getName () == mVectHistoCheck .at (ih).nameHisto ) {
@@ -198,6 +234,25 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR
198234 ILOG (Error, Support) << " could not cast '" << mo->getName () << " ' to TH1*" << ENDM;
199235 return ;
200236 }
237+ if (mo->getName () == " hBCAlignPlot" ) {
238+ float ratio = 0.0 ;
239+ for (int x = 0 ; x < h->GetNbinsX (); x++) {
240+ for (int y = 0 ; y < h->GetNbinsY (); y++) {
241+ ratio = (h->GetBinContent (x + 1 , y + 1 )) / (h->GetBinContent (x + 1 , REFERENCE_BIN));
242+ float xpos = h->GetXaxis ()->GetBinCenter (x + 1 );
243+ float ypos = h->GetYaxis ()->GetBinCenter (y + 1 );
244+ std::string strValue = std::format (" {:.2f}" , ratio);
245+ TLatex* msgr = new TLatex (xpos - 0.35 , ypos - 0.15 , strValue.c_str ());
246+ msgr->SetTextSize (9 );
247+ if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) {
248+ msgr->SetTextColor (kGreen );
249+ } else {
250+ msgr->SetTextColor (kRed );
251+ }
252+ h->GetListOfFunctions ()->Add (msgr);
253+ }
254+ }
255+ }
201256 if (mVectHistoCheck .at (ih).quality == 1 ) {
202257 std::string errorSt = getCurrentDataTime () + " Ok" ;
203258 TLatex* msg = new TLatex (mVectHistoCheck .at (ih).posMsgX , mVectHistoCheck .at (ih).posMsgY , errorSt.c_str ());
@@ -209,7 +264,7 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR
209264 h->SetFillColor (kGreen );
210265 msg->Draw ();
211266 } else if (mVectHistoCheck .at (ih).quality == 3 ) {
212- std::string errorSt = getCurrentDataTime () + " Errors --> Call the expert." + mVectHistoCheck .at (ih).stringE ;
267+ std::string errorSt = getCurrentDataTime () + " Errors --> Call the expert. " + mVectHistoCheck .at (ih).stringE ;
213268 TLatex* msg = new TLatex (mVectHistoCheck .at (ih).posMsgX , mVectHistoCheck .at (ih).posMsgY , errorSt.c_str ());
214269 msg->SetNDC ();
215270 msg->SetTextSize (16 );
@@ -267,7 +322,45 @@ void ZDCRawDataCheck::init(const Activity& activity)
267322 setChCheck (" hpedSummary" , " TH1F" , " PED" , " PED_POS_MSG_X" , " PED_POS_MSG_Y" , activity);
268323 setChCheck (" hAlignPlotShift" , " TH2F" , " ALIGN" , " ALIGN_POS_MSG_X" , " ALIGN_POS_MSG_Y" , activity);
269324 setChCheck (" herrorSummary" , " TH2F" , " ERROR" , " ERROR_POS_MSG_X" , " ERROR_POS_MSG_Y" , activity);
270- // dumpStruct();
325+ setChCheck (" hBCAlignPlot" , " TH2F" , " PED" , " PED_POS_MSG_X" , " PED_POS_MSG_Y" , activity);
326+
327+ std::vector<std::string> tokenString;
328+ if (auto param = mCustomParameters .find (" REFERENCE_BIN" ); param != mCustomParameters .end ()) {
329+ ILOG (Debug, Devel) << " Custom parameter - REFERENCE_BIN: " << param->second << ENDM;
330+ tokenString = tokenLine (param->second , " ;" );
331+ REFERENCE_BIN = atoi (param->second .c_str ());
332+ } else {
333+ REFERENCE_BIN = 7 ;
334+ }
335+ if (auto param = mCustomParameters .find (" NOISE_LEVEL_LOW" ); param != mCustomParameters .end ()) {
336+ ILOG (Debug, Devel) << " Custom parameter - NOISE_LEVEL_LOW: " << param->second << ENDM;
337+ tokenString = tokenLine (param->second , " ;" );
338+ NOISE_LEVEL_LOW = atof (param->second .c_str ());
339+ } else {
340+ NOISE_LEVEL_LOW = 0.0 ;
341+ }
342+ if (auto param = mCustomParameters .find (" NOISE_LEVEL_HIGH" ); param != mCustomParameters .end ()) {
343+ ILOG (Debug, Devel) << " Custom parameter - NOISE_LEVEL_HIGH: " << param->second << ENDM;
344+ tokenString = tokenLine (param->second , " ;" );
345+ NOISE_LEVEL_HIGH = atof (param->second .c_str ());
346+ } else {
347+ NOISE_LEVEL_HIGH = 2.0 ;
348+ }
349+ if (auto param = mCustomParameters .find (" COMPARATOR_ARRAY" ); param != mCustomParameters .end ()) {
350+ ILOG (Debug, Devel) << " Custom parameter - COMPARATOR_ARRAY: " << param->second << ENDM;
351+ tokenString = tokenLine (param->second , " ;" );
352+ for (int i = 0 ; i < 12 ; i++) {
353+ if (atoi (tokenString.at (i).c_str ()) == 1 ) {
354+ COMPARATOR_ARRAY[i] = true ;
355+ } else {
356+ COMPARATOR_ARRAY[i] = false ;
357+ }
358+ }
359+ } else {
360+ for (int i = 0 ; i < 12 ; i++) {
361+ COMPARATOR_ARRAY[i] = false ;
362+ }
363+ }
271364}
272365
273366void ZDCRawDataCheck::setChName (std::string channel)
0 commit comments