diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h index 74c2d287e..9bafa315a 100644 --- a/slsDetectorCalibration/analogDetector.h +++ b/slsDetectorCalibration/analogDetector.h @@ -113,49 +113,20 @@ template class analogDetector { destructor. Deletes the pdestalSubtraction array and the image */ virtual ~analogDetector() { - std::cout << "#### Debug: Destructing analogDetector! ####" - << std::endl; + // std::cout << "#### Debug: Destructing analogDetector! ####" + // << std::endl; for (int i = 0; i < ny; i++) { - std::cout << " # " << i; - if (stat[i]) { - if (i == 0) { - std::cout - << "#### Debug: Deleting analogDetector member stat[" - << i << "] at " << stat[i] << " ####" << std::endl; - } - delete[] stat[i]; - if (i == 0) { - std::cout - << "#### Debug: Deleted analogDetector member stat[" - << i << "]! ####" << std::endl; - } - stat[i] = nullptr; - } + if (stat[i]) { delete[] stat[i]; stat[i] = nullptr; } // delete[] stat[i]; /* delete [] pedMean[i]; */ /* delete [] pedVariance[i]; */ } - std::cout << " #\n"; /* delete [] pedMean; */ /* delete [] pedVariance; */ // delete[] stat; // delete[] image; - if (stat) { - std::cout << "#### Debug: Deleting analogDetector member stat at " - << stat << " ####" << std::endl; - delete[] stat; - std::cout << "#### Debug: Deleted analogDetector member stat! ####" - << std::endl; - stat = nullptr; - } - if (image) { - std::cout << "#### Debug: Deleting analogDetector member image at " - << image << " ####" << std::endl; - delete[] image; - std::cout << "#### Debug: Deleted analogDetector member image! ####" - << std::endl; - image = nullptr; - } + if (stat) { delete[] stat; stat = nullptr; } + if (image) { delete[] image; image = nullptr; } #ifdef ROOTSPECTRUM delete hs; #ifdef ROOTCLUST @@ -173,8 +144,8 @@ template class analogDetector { */ analogDetector(analogDetector *orig) { /* copy construction from orig*/ - std::cout << "#### Debug: Calling analogDetector cloning method! ####" - << std::endl; + // std::cout << "#### Debug: Calling analogDetector cloning method! ####" + // << std::endl; det = orig->det; nx = orig->nx; ny = orig->ny; @@ -267,8 +238,8 @@ template class analogDetector { ymax(other.ymax), thr(other.thr), fMode(other.fMode), dMode(other.dMode), myFile(NULL) { - std::cout << "#### Debug: Calling analogDetector copy constructor! ####" - << std::endl; + // std::cout << "#### Debug: Calling analogDetector copy constructor! ####" + // << std::endl; // Deep copy the stat array stat = new pedestalSubtraction *[ny]; diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index 546b5ca36..85aacc1a4 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -113,16 +113,14 @@ class threadedAnalogDetector { virtual ~threadedAnalogDetector() { - std::cout << "#### Debug: Destructing threadedAnalogDetector! ####" << std::endl; + // std::cout << "#### Debug: Destructing threadedAnalogDetector! ####" << std::endl; StopThread(); if (fifoFree) { delete fifoFree; fifoFree = nullptr; } if (fifoData) { delete fifoData; fifoData = nullptr; } if (det) { - std::cout << "#### Debug: Deleting threadedAnalogDetector member det at " << det << " ####" << std::endl; delete det; // Call destructor for singlePhotonDetector - std::cout << "#### Debug: Deleted threadedAnalogDetector member det! ####" << std::endl; det = nullptr; } } @@ -363,14 +361,13 @@ class multiThreadedAnalogDetector { */ // Create separate detectorObjects for each SC (each owns its mutex) - std::cout << "#### Debug: Constructing vector of analogDetector objects! ####" << std::endl; std::vector< analogDetector* > sc_detectors(nSC, nullptr); sc_detectors[0] = d; // First storage cell uses the given detector - std::cout << "#### Debug: Copied analogDetector object for storage cell 0! ####" << std::endl; + // std::cout << "#### Debug: Copied analogDetector object for storage cell 0! ####" << std::endl; for (int sc = 1; sc < nSC; ++sc) { sc_detectors[sc] = d->Copy(); // Ensure unique mutex for each SC - std::cout << "#### Debug: Copied analogDetector object for storage cell " << sc << "! ####" << std::endl; + // std::cout << "#### Debug: Copied analogDetector object for storage cell " << sc << "! ####" << std::endl; } // Distribute threads among storage cells @@ -419,7 +416,7 @@ class multiThreadedAnalogDetector { } virtual ~multiThreadedAnalogDetector() { - std::cout << "#### Debug: Destructing multiThreadedAnalogDetector! ####" << std::endl; + // std::cout << "#### Debug: Destructing multiThreadedAnalogDetector! ####" << std::endl; //StopThreads(); // Superfluous, leads to double delete /* Reverse loop for destruction. @@ -427,9 +424,7 @@ class multiThreadedAnalogDetector { * (ensure shared mutex is deleted last). * Optional solution: reference counting (safer but more complex) */ for (int i = nThreads - 1; i >= 0; --i) { - std::cout << "#### Debug: Deleting multiThreadedAnalogDetector member dets[" << i << "] at " << dets[i] << " ####" << std::endl; delete dets[i]; //StopThread() called by each ~threadedAnalogDetector() - std::cout << "#### Debug: Deleted multiThreadedAnalogDetector member dets [" << i << "]! ####" << std::endl; dets[i] = nullptr; } diff --git a/slsDetectorCalibration/singlePhotonDetector.h b/slsDetectorCalibration/singlePhotonDetector.h index e6322ebb2..a9716e486 100644 --- a/slsDetectorCalibration/singlePhotonDetector.h +++ b/slsDetectorCalibration/singlePhotonDetector.h @@ -89,37 +89,16 @@ class singlePhotonDetector : public analogDetector { Destructor. Deletes the cluster structure, event mask, and destroys the mutex. */ virtual ~singlePhotonDetector() { - std::cout << "#### Debug: Destructing singlePhotonDetector! ####" << std::endl; - if (clusters) { - std::cout << "#### Debug: Deleting singlePhotonDetector member clusters at " << clusters << " ####" << std::endl; - delete[] clusters; - std::cout << "#### Debug: Deleted singlePhotonDetector member clusters! ####" << std::endl; - clusters = nullptr; - } + // std::cout << "#### Debug: Destructing singlePhotonDetector! ####" << std::endl; + if (clusters) { delete[] clusters; clusters = nullptr; } for (int i = 0; i < ny; i++) { - if (eventMask[i]) { - if (i==0) { - std::cout << "#### Debug: Deleting singlePhotonDetector member eventMask[i]! ####" << std::endl; - } - delete[] eventMask[i]; - if (i==0) { - std::cout << "#### Debug: Deleted singlePhotonDetector member eventMask[i]! ####" << std::endl; - } - eventMask[i] = nullptr; - } - } - if (eventMask) { - std::cout << "#### Debug: Deleting singlePhotonDetector member eventMask at " << eventMask << " ####" << std::endl; - delete[] eventMask; - std::cout << "#### Debug: Deleted singlePhotonDetector member eventMask! ####" << std::endl; - eventMask = nullptr; + if (eventMask[i]) { delete[] eventMask[i]; eventMask[i] = nullptr; } } + if (eventMask) { delete[] eventMask; eventMask = nullptr; } if (ownsMutex) { if (fm) { //pthread_mutex_destroy(fm); // Destroy the mutex (not necessary with std::mutex) - std::cout << "#### Debug: Deleting std::mutex singlePhotonDetector member fm at " << fm << " ####" << std::endl; delete fm; // Free the memory allocated for the mutex - std::cout << "#### Debug: Deleted std::mutex singlePhotonDetector member fm! ####" << std::endl; fm = nullptr; // Set the pointer to nullptr to avoid dangling pointer } }