Skip to content

Commit

Permalink
Fix try/catch in Vx3DHLTAnalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobrivio committed Sep 1, 2022
1 parent 3cac6aa commit ee5b0ec
Showing 1 changed file with 55 additions and 38 deletions.
93 changes: 55 additions & 38 deletions DQM/BeamMonitor/plugins/Vx3DHLTAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,17 @@ double Vx3DHLTAnalyzer::Gauss3DFunc(const double* par) {
}

int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {
// ############################################
// # RETURN CODE: #
// # >0 == NO OK - fit status (MINUIT manual) #
// # 0 == OK #
// # -1 == NO OK - not finite edm #
// # -2 == NO OK - not enough "minNentries" #
// # -3 == NO OK - not finite errors #
// # -4 == NO OK - negative determinant #
// # -5 == NO OK - maxLumiIntegration reached #
// ############################################
// ###############################################
// # RETURN CODE: #
// # >0 == NOT OK - fit status (MINUIT manual) #
// # 0 == OK #
// # -1 == NOT OK - not finite edm #
// # -2 == NOT OK - not enough "minNentries" #
// # -3 == NOT OK - not finite errors #
// # -4 == NOT OK - negative determinant #
// # -5 == NOT OK - maxLumiIntegration reached #
// # -6 == NOT OK - FatalRootError: @SUB=Minuit2 #
// ###############################################

if ((vals != nullptr) && (vals->size() == nParams * 2)) {
double nSigmaXY = 10.;
Expand Down Expand Up @@ -342,19 +343,22 @@ int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {

try {
Gauss3D->Minimize();
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();
} catch (cms::Exception& er) {
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception: " << er.what();
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception @ Fit at X: \n" << er.what();
goodData = -6;
edm = 1.;
continue;
}
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();

if (counterVx < minNentries)
goodData = -2;
else if (isNotFinite(edm) == true) {
goodData = -1;
if (internalDebug == true)
edm::LogInfo("Vx3DHLTAnalyzer") << "\tNot finite edm !";
} else
} else if (goodData != -6)
for (unsigned int j = 0; j < nParams; j++)
if (isNotFinite(Gauss3D->Errors()[j]) == true) {
goodData = -3;
Expand Down Expand Up @@ -418,19 +422,22 @@ int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {

try {
Gauss3D->Minimize();
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();
} catch (cms::Exception& er) {
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception: " << er.what();
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception @ Fit at Y: \n" << er.what();
goodData = -6;
edm = 1.;
continue;
}
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();

if (counterVx < minNentries)
goodData = -2;
else if (isNotFinite(edm) == true) {
goodData = -1;
if (internalDebug == true)
edm::LogInfo("Vx3DHLTAnalyzer") << "\tNot finite edm !";
} else
} else if (goodData != -6)
for (unsigned int j = 0; j < nParams; j++)
if (isNotFinite(Gauss3D->Errors()[j]) == true) {
goodData = -3;
Expand Down Expand Up @@ -495,19 +502,22 @@ int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {

try {
Gauss3D->Minimize();
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();
} catch (cms::Exception& er) {
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception: " << er.what();
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception @ Fit at Z: \n" << er.what();
goodData = -6;
edm = 1.;
continue;
}
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();

if (counterVx < minNentries)
goodData = -2;
else if (isNotFinite(edm) == true) {
goodData = -1;
if (internalDebug == true)
edm::LogInfo("Vx3DHLTAnalyzer") << "\tNot finite edm !";
} else
} else if (goodData != -6)
for (unsigned int j = 0; j < nParams; j++)
if (isNotFinite(Gauss3D->Errors()[j]) == true) {
goodData = -3;
Expand Down Expand Up @@ -563,19 +573,21 @@ int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {

try {
Gauss3D->Minimize();
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();
} catch (cms::Exception& er) {
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception: " << er.what();
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception @ Final fit: \n" << er.what();
goodData = -6;
edm = 1.;
}
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();

if (counterVx < minNentries)
goodData = -2;
else if (isNotFinite(edm) == true) {
goodData = -1;
if (internalDebug == true)
edm::LogInfo("Vx3DHLTAnalyzer") << "\tNot finite edm !";
} else
} else if (goodData != -6)
for (unsigned int j = 0; j < nParams; j++)
if (isNotFinite(Gauss3D->Errors()[j]) == true) {
goodData = -3;
Expand Down Expand Up @@ -635,19 +647,23 @@ int Vx3DHLTAnalyzer::MyFit(vector<double>* vals) {

try {
Gauss3D->Minimize();
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();
} catch (cms::Exception& er) {
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception: " << er.what();
edm::LogError("Vx3DHLTAnalyzer") << "\tCaught Minuit2 exception @ Fit with different distances: \n"
<< er.what();
goodData = -6;
edm = 1.;
continue;
}
goodData = Gauss3D->Status();
edm = Gauss3D->Edm();

if (counterVx < minNentries)
goodData = -2;
else if (isNotFinite(edm) == true) {
goodData = -1;
if (internalDebug == true)
edm::LogInfo("Vx3DHLTAnalyzer") << "\tNot finite edm !";
} else
} else if (goodData != -6)
for (unsigned int j = 0; j < nParams; j++)
if (isNotFinite(Gauss3D->Errors()[j]) == true) {
goodData = -3;
Expand Down Expand Up @@ -1525,18 +1541,19 @@ void Vx3DHLTAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, Run const& iRun
"L - status vs lumi", "App. Status vs. Lumisection", nLumiXaxisRange, 0.5, ((double)nLumiXaxisRange) + 0.5);
statusCounter->setAxisTitle("Lumisection [#]", 1);
statusCounter->getTH1()->SetOption("E1");
statusCounter->getTH1()->GetYaxis()->Set(11, -5.5, 5.5);
statusCounter->getTH1()->GetYaxis()->SetBinLabel(1, "Max Lumi.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(2, "Neg. det.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(3, "Infinite err.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(4, "No vtx.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(5, "Infinite EDM");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(6, "OK");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(7, "MINUIT stat.");
statusCounter->getTH1()->GetYaxis()->Set(12, -6.5, 5.5);
statusCounter->getTH1()->GetYaxis()->SetBinLabel(1, "FatalRootError");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(2, "Max Lumi.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(3, "Neg. det.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(4, "Infinite err.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(5, "No vtx.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(6, "Infinite EDM");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(7, "OK");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(8, "MINUIT stat.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(9, "MINUIT stat.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(10, "MINUIT stat.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(11, "MINUIT stat.");
statusCounter->getTH1()->GetYaxis()->SetBinLabel(12, "MINUIT stat.");

fitResults = ibooker.book2D("A - fit results", "Results of Beam Spot Fit", 2, 0., 2., 9, 0., 9.);
fitResults->setAxisTitle("Ongoing: bootstrapping", 1);
Expand Down

0 comments on commit ee5b0ec

Please sign in to comment.