From 92a5820a3d3e8ed99d6113587a08fef9ea572bd0 Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Fri, 28 Aug 2020 09:32:07 +0200
Subject: [PATCH] avoid crash when counters are missing in setup

---
 reco/detectors/tof/CbmTofCalibrator.cxx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/reco/detectors/tof/CbmTofCalibrator.cxx b/reco/detectors/tof/CbmTofCalibrator.cxx
index 913e764fce..bd0db693d9 100644
--- a/reco/detectors/tof/CbmTofCalibrator.cxx
+++ b/reco/detectors/tof/CbmTofCalibrator.cxx
@@ -403,17 +403,17 @@ Bool_t CbmTofCalibrator::UpdateCalHist(Int_t iOpt) {
     Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId);
     Int_t iSm     = CbmTofAddress::GetSmId(iUniqueId);
     Int_t iRpc    = CbmTofAddress::GetRpcId(iUniqueId);
+    if(NULL == fhCorTOff[iDetIndx]) {
+      LOG(warn) << "hCorTOff for TSR "<<iSmType<<iSm<<iRpc<<" not available";
+      continue;
+    }
+
     switch (iOpt) {
       case 0:  // none
         break;
       case 1:  // update channel mean
       {
-        LOG(info) << "Update Offsets for TSR " << iSmType << iSm << iRpc;
-        if (NULL == fhCorTOff[iDetIndx]) {
-          LOG(warn) << "hCorTOff for TSR " << iSmType << iSm << iRpc
-                    << " not available";
-          continue;
-        }
+        LOG(info) << "Update Offsets for TSR "<<iSmType<<iSm<<iRpc;
 
         TProfile* hpP = fhCalPos[iDetIndx]->ProfileX();
         TProfile* hpT = fhCalTOff[iDetIndx]->ProfileX();
-- 
GitLab