roll back debug comments

This commit is contained in:
hinger_v 2025-03-18 18:56:01 +01:00
parent 8c35fc16b9
commit 5e8a354194
3 changed files with 17 additions and 72 deletions

View File

@ -113,49 +113,20 @@ template <class dataType> class analogDetector {
destructor. Deletes the pdestalSubtraction array and the image destructor. Deletes the pdestalSubtraction array and the image
*/ */
virtual ~analogDetector() { virtual ~analogDetector() {
std::cout << "#### Debug: Destructing analogDetector! ####" // std::cout << "#### Debug: Destructing analogDetector! ####"
<< std::endl; // << std::endl;
for (int i = 0; i < ny; i++) { for (int i = 0; i < ny; i++) {
std::cout << " # " << i; if (stat[i]) { delete[] stat[i]; stat[i] = nullptr; }
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;
}
// delete[] stat[i]; // delete[] stat[i];
/* delete [] pedMean[i]; */ /* delete [] pedMean[i]; */
/* delete [] pedVariance[i]; */ /* delete [] pedVariance[i]; */
} }
std::cout << " #\n";
/* delete [] pedMean; */ /* delete [] pedMean; */
/* delete [] pedVariance; */ /* delete [] pedVariance; */
// delete[] stat; // delete[] stat;
// delete[] image; // delete[] image;
if (stat) { if (stat) { delete[] stat; stat = nullptr; }
std::cout << "#### Debug: Deleting analogDetector member stat at " if (image) { delete[] image; image = nullptr; }
<< 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;
}
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
delete hs; delete hs;
#ifdef ROOTCLUST #ifdef ROOTCLUST
@ -173,8 +144,8 @@ template <class dataType> class analogDetector {
*/ */
analogDetector(analogDetector *orig) { analogDetector(analogDetector *orig) {
/* copy construction from orig*/ /* copy construction from orig*/
std::cout << "#### Debug: Calling analogDetector cloning method! ####" // std::cout << "#### Debug: Calling analogDetector cloning method! ####"
<< std::endl; // << std::endl;
det = orig->det; det = orig->det;
nx = orig->nx; nx = orig->nx;
ny = orig->ny; ny = orig->ny;
@ -267,8 +238,8 @@ template <class dataType> class analogDetector {
ymax(other.ymax), thr(other.thr), fMode(other.fMode), ymax(other.ymax), thr(other.thr), fMode(other.fMode),
dMode(other.dMode), myFile(NULL) { dMode(other.dMode), myFile(NULL) {
std::cout << "#### Debug: Calling analogDetector copy constructor! ####" // std::cout << "#### Debug: Calling analogDetector copy constructor! ####"
<< std::endl; // << std::endl;
// Deep copy the stat array // Deep copy the stat array
stat = new pedestalSubtraction *[ny]; stat = new pedestalSubtraction *[ny];

View File

@ -113,16 +113,14 @@ class threadedAnalogDetector {
virtual ~threadedAnalogDetector() { virtual ~threadedAnalogDetector() {
std::cout << "#### Debug: Destructing threadedAnalogDetector! ####" << std::endl; // std::cout << "#### Debug: Destructing threadedAnalogDetector! ####" << std::endl;
StopThread(); StopThread();
if (fifoFree) { delete fifoFree; fifoFree = nullptr; } if (fifoFree) { delete fifoFree; fifoFree = nullptr; }
if (fifoData) { delete fifoData; fifoData = nullptr; } if (fifoData) { delete fifoData; fifoData = nullptr; }
if (det) { if (det) {
std::cout << "#### Debug: Deleting threadedAnalogDetector member det at " << det << " ####" << std::endl;
delete det; // Call destructor for singlePhotonDetector delete det; // Call destructor for singlePhotonDetector
std::cout << "#### Debug: Deleted threadedAnalogDetector member det! ####" << std::endl;
det = nullptr; det = nullptr;
} }
} }
@ -363,14 +361,13 @@ class multiThreadedAnalogDetector {
*/ */
// Create separate detectorObjects for each SC (each owns its mutex) // Create separate detectorObjects for each SC (each owns its mutex)
std::cout << "#### Debug: Constructing vector of analogDetector objects! ####" << std::endl;
std::vector< analogDetector<uint16_t>* > sc_detectors(nSC, nullptr); std::vector< analogDetector<uint16_t>* > sc_detectors(nSC, nullptr);
sc_detectors[0] = d; // First storage cell uses the given detector 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) { for (int sc = 1; sc < nSC; ++sc) {
sc_detectors[sc] = d->Copy(); // Ensure unique mutex for each 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 // Distribute threads among storage cells
@ -419,7 +416,7 @@ class multiThreadedAnalogDetector {
} }
virtual ~multiThreadedAnalogDetector() { virtual ~multiThreadedAnalogDetector() {
std::cout << "#### Debug: Destructing multiThreadedAnalogDetector! ####" << std::endl; // std::cout << "#### Debug: Destructing multiThreadedAnalogDetector! ####" << std::endl;
//StopThreads(); // Superfluous, leads to double delete //StopThreads(); // Superfluous, leads to double delete
/* Reverse loop for destruction. /* Reverse loop for destruction.
@ -427,9 +424,7 @@ class multiThreadedAnalogDetector {
* (ensure shared mutex is deleted last). * (ensure shared mutex is deleted last).
* Optional solution: reference counting (safer but more complex) */ * Optional solution: reference counting (safer but more complex) */
for (int i = nThreads - 1; i >= 0; --i) { 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() delete dets[i]; //StopThread() called by each ~threadedAnalogDetector()
std::cout << "#### Debug: Deleted multiThreadedAnalogDetector member dets [" << i << "]! ####" << std::endl;
dets[i] = nullptr; dets[i] = nullptr;
} }

View File

@ -89,37 +89,16 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
Destructor. Deletes the cluster structure, event mask, and destroys the mutex. Destructor. Deletes the cluster structure, event mask, and destroys the mutex.
*/ */
virtual ~singlePhotonDetector() { virtual ~singlePhotonDetector() {
std::cout << "#### Debug: Destructing singlePhotonDetector! ####" << std::endl; // std::cout << "#### Debug: Destructing singlePhotonDetector! ####" << std::endl;
if (clusters) { if (clusters) { delete[] clusters; clusters = nullptr; }
std::cout << "#### Debug: Deleting singlePhotonDetector member clusters at " << clusters << " ####" << std::endl;
delete[] clusters;
std::cout << "#### Debug: Deleted singlePhotonDetector member clusters! ####" << std::endl;
clusters = nullptr;
}
for (int i = 0; i < ny; i++) { for (int i = 0; i < ny; i++) {
if (eventMask[i]) { if (eventMask[i]) { delete[] eventMask[i]; eventMask[i] = nullptr; }
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) { delete[] eventMask; eventMask = nullptr; }
if (ownsMutex) { if (ownsMutex) {
if (fm) { if (fm) {
//pthread_mutex_destroy(fm); // Destroy the mutex (not necessary with std::mutex) //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 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 fm = nullptr; // Set the pointer to nullptr to avoid dangling pointer
} }
} }