diff --git a/src/modules/EventLoaderALiBaVa/ALiBaVa/DataFileRoot.cpp b/src/modules/EventLoaderALiBaVa/ALiBaVa/DataFileRoot.cpp index 8628fef602c73b54950ffcad97a45ae0b072ad60..0dcf61ea49b496d2d32e9df5dcb83159e44e380c 100644 --- a/src/modules/EventLoaderALiBaVa/ALiBaVa/DataFileRoot.cpp +++ b/src/modules/EventLoaderALiBaVa/ALiBaVa/DataFileRoot.cpp @@ -300,20 +300,18 @@ DataFileRoot* DataFileRoot::OpenFile(const char* nam, const char* pedfile, const if(stat(nam, &sb) == -1) return 0; - - -std::ifstream ifile(nam); -if(!ifile) - return 0; + std::ifstream ifile(nam); + if(!ifile) + return 0; -char buf[5] = {'\0'}; -ifile.read(buf, 4); -ifile.close(); -std::string idf(buf + 1); + char buf[5] = {'\0'}; + ifile.read(buf, 4); + ifile.close(); + std::string idf(buf + 1); -if(idf == "HDF") - return new HDFRoot(nam, pedfile, gainfile); -else - return new AsciiRoot(nam, pedfile, gainfile); + if(idf == "HDF") + return new HDFRoot(nam, pedfile, gainfile); + else + return new AsciiRoot(nam, pedfile, gainfile); } diff --git a/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.cpp b/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.cpp index 8eb390048a7a3d729dcb7c5c8dd050d174d33b9e..cbe67fd4eb8e11803c77c609ac2e7a48e7646456 100644 --- a/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.cpp +++ b/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.cpp @@ -104,15 +104,15 @@ void EventLoaderALiBaVa::initialize() { hTimeProfile = new TProfile("timeProfile", "Time profile; Time [ns], Ave. signal highest channel [ADC]", 35, 0, 35, 0, 200); // Create a pointer with the data file. - ALiBaVaPointer = DataFileRoot::OpenFile(datafilename.c_str()); + m_alibava.reset(DataFileRoot::OpenFile(datafilename.c_str())); // Sort vector to avoid errors later on std::sort(roi.begin(), roi.end()); // Set the region of interest - ALiBaVaPointer->set_ROI(roi); + m_alibava->set_ROI(roi); // Get the vector with all ROI channels listed to use here - m_roi_ch = ALiBaVaPointer->get_ROI(); + m_roi_ch = m_alibava->get_ROI(); - ALiBaVaPointer->set_polarity(polarity); + m_alibava->set_polarity(polarity); const char* ped_f = "alibava_ped.ped"; const char* cal_f = "alibava_cal.cal"; @@ -145,7 +145,7 @@ void EventLoaderALiBaVa::initialize() { PedestalPointer->close(); delete PedestalPointer; // Load the calculated pedestal info into the original datafile - ALiBaVaPointer->load_pedestals(ped_f, kTRUE); + m_alibava->load_pedestals(ped_f, kTRUE); int columns, rows; @@ -174,11 +174,11 @@ void EventLoaderALiBaVa::initialize() { } // Set the timecuts - ALiBaVaPointer->set_timecut(timecut_low, timecut_up); + m_alibava->set_timecut(timecut_low, timecut_up); // Ignore the first X events to ensure synchronisation, default is X = 1 which ignores the first event. for(int ievt = 0; ievt < ignore_events; ievt++) { - ALiBaVaPointer->read_event(); + m_alibava->read_event(); } } @@ -197,7 +197,7 @@ StatusCode EventLoaderALiBaVa::run(const std::shared_ptr<Clipboard>& clipboard) // Read a data event from the ALiBaVa data file // Give feedback according to return code - int return_code = ALiBaVaPointer->read_event(); + int return_code = m_alibava->read_event(); if(return_code == -1) { return StatusCode::EndRun; // Not sure if this is end of run or something else. Need to see difference between HDF5 and binary @@ -224,13 +224,13 @@ StatusCode EventLoaderALiBaVa::run(const std::shared_ptr<Clipboard>& clipboard) return StatusCode::EndRun; } // Calculate the common mode for the signal in this event - ALiBaVaPointer->calc_common_mode_signal(); + m_alibava->calc_common_mode_signal(); // Process the opened data event, i.e. pedestal correction, common mode noise correction - ALiBaVaPointer->process_event(); + m_alibava->process_event(); // This gets the TDC time from the event, allowing timecuts around the event peak // The timecut is set in the ALiBaVa_loader() function. - double TDCTime = ALiBaVaPointer->time(); - if(!ALiBaVaPointer->valid_time(TDCTime)) { + double TDCTime = m_alibava->time(); + if(!m_alibava->valid_time(TDCTime)) { clipboard->putData(pixels, detector_->getName()); return StatusCode::NoData; } @@ -249,8 +249,8 @@ StatusCode EventLoaderALiBaVa::run(const std::shared_ptr<Clipboard>& clipboard) double max_signal = 0; // This loops over the channels in the current ALiBaVa event for(int chan : m_roi_ch) { - double ADCSignal = ALiBaVaPointer->ADC_signal(chan); - double SNRatio = ALiBaVaPointer->sn(chan); + double ADCSignal = m_alibava->ADC_signal(chan); + double SNRatio = m_alibava->sn(chan); double CalSignal = ADCSignal * m_calibration_constant; if(ADCSignal > max_signal) { @@ -293,6 +293,7 @@ StatusCode EventLoaderALiBaVa::run(const std::shared_ptr<Clipboard>& clipboard) } void EventLoaderALiBaVa::finalize(const std::shared_ptr<ReadonlyClipboard>&) { - ALiBaVaPointer->close(); - delete ALiBaVaPointer; + m_alibava->close(); + //delete m_alibava; + m_alibava.reset(); } diff --git a/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.h b/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.h index 5a48276fb26d7f225d68a488b86242cf39a9e5a5..0f1d1792bcee85c32ed9e0034e15fac8094ff5ab 100644 --- a/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.h +++ b/src/modules/EventLoaderALiBaVa/EventLoaderALiBaVa.h @@ -47,7 +47,7 @@ namespace corryvreckan { private: std::shared_ptr<Detector> detector_; - DataFileRoot* ALiBaVaPointer; + std::shared_ptr<DataFileRoot> m_alibava; TH1F* hChargeSignal{}; TH1F* hADCSignal{};