From e3e6796381b42b3426a92e97153d495c719407da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 25 Sep 2024 21:55:30 +0000 Subject: [PATCH] Apply clang-format --- Hcal/src/Hcal/HcalDigiProducer.cxx | 108 +++++++++++++++------------ Tools/include/Tools/HgcrocEmulator.h | 10 ++- Tools/include/Tools/PulseRecord.h | 32 ++++---- Tools/src/Tools/HgcrocEmulator.cxx | 37 +++++---- 4 files changed, 99 insertions(+), 88 deletions(-) diff --git a/Hcal/src/Hcal/HcalDigiProducer.cxx b/Hcal/src/Hcal/HcalDigiProducer.cxx index 49b4aaa86..2a604be71 100644 --- a/Hcal/src/Hcal/HcalDigiProducer.cxx +++ b/Hcal/src/Hcal/HcalDigiProducer.cxx @@ -7,9 +7,11 @@ */ #include "Hcal/HcalDigiProducer.h" -#include "Tools/PulseRecord.h" + #include + #include "Framework/RandomNumberSeedService.h" +#include "Tools/PulseRecord.h" namespace hcal { @@ -131,7 +133,7 @@ void HcalDigiProducer::produce(framework::Event& event) { std::vector> pulses_posend; std::vector> pulses_negend; - // For plotting purposes + // For plotting purposes std::vector> DigiToPlot; DigiToPlot.clear(); @@ -219,8 +221,9 @@ void HcalDigiProducer::produce(framework::Event& event) { iContrib++) { double voltage = simHit.getContrib(iContrib).edep * MeV_; - std::cout << " Energy deposited: " << simHit.getContrib(iContrib).edep << std::endl; - + std::cout << " Energy deposited: " << simHit.getContrib(iContrib).edep + << std::endl; + double time = simHit.getContrib(iContrib).time; // global time (t=0ns at target) time -= position.at(2) / @@ -255,36 +258,39 @@ void HcalDigiProducer::produce(framework::Event& event) { hcalDigis.addDigi(posendID.raw(), digiToAddPosend); hcalDigis.addDigi(negendID.raw(), digiToAddNegend); - //for(const auto& digi: hcalDigis){ - //std::cout << " DEBUG PRINT 2: " << digi.at(2) << std::endl; - //} - } - - // Recording digitized pulses in PulseRecord + // for(const auto& digi: hcalDigis){ + // std::cout << " DEBUG PRINT 2: " << digi.at(2) << std::endl; + // } + } + + // Recording digitized pulses in PulseRecord // Since two pulses are digitized, using existing loop is bit untidy. // Access PulseRecord if (hgcroc_->digitize(posendID.raw(), pulses_posend, digiToAddPosend) && - hgcroc_->digitize(negendID.raw(), pulses_negend, digiToAddNegend)){ - const auto& pulseRecord = hgcroc_->getPulseRecord(); + hgcroc_->digitize(negendID.raw(), pulses_negend, digiToAddNegend)) { + const auto& pulseRecord = hgcroc_->getPulseRecord(); - for(const auto& record: pulseRecord){ - DigiToPlot.emplace_back(record.getVolts(), record.getADC(), record.getTOT()); - } + for (const auto& record : pulseRecord) { + DigiToPlot.emplace_back(record.getVolts(), record.getADC(), + record.getTOT()); + } } if (hgcroc_->digitize(posendID.raw(), pulses_negend, digiToAddNegend) && - hgcroc_->digitize(posendID.raw(), pulses_posend, digiToAddPosend)){ - const auto& pulseRecord = hgcroc_->getPulseRecord(); + hgcroc_->digitize(posendID.raw(), pulses_posend, digiToAddPosend)) { + const auto& pulseRecord = hgcroc_->getPulseRecord(); - for(const auto& record: pulseRecord){ - DigiToPlot.emplace_back(record.getVolts(), record.getADC(), record.getTOT()); - } + for (const auto& record : pulseRecord) { + DigiToPlot.emplace_back(record.getVolts(), record.getADC(), + record.getTOT()); + } } // Print Voltages, adc/tot values to the same txt file std::ofstream dataFile("Voltage_ADC_TOT.txt", std::ios::app); - for(const auto& entry: DigiToPlot){ - dataFile <(entry) << " " <(entry) << " " <(entry) << "\n"; + for (const auto& entry : DigiToPlot) { + dataFile << std::get<0>(entry) << " " << std::get<1>(entry) << " " + << std::get<2>(entry) << "\n"; } dataFile.close(); @@ -304,20 +310,22 @@ void HcalDigiProducer::produce(framework::Event& event) { if (hgcroc_->digitize(digiID.raw(), pulses_posend, digiToAdd)) { hcalDigis.addDigi(digiID.raw(), digiToAdd); } - // Recording digitized pulses in PulseRecord - // Access PulseRecord - const auto& pulseRecord = hgcroc_->getPulseRecord(); + // Recording digitized pulses in PulseRecord + // Access PulseRecord + const auto& pulseRecord = hgcroc_->getPulseRecord(); - for(const auto& record: pulseRecord){ - DigiToPlot.emplace_back(record.getVolts(), record.getADC(), record.getTOT()); - } + for (const auto& record : pulseRecord) { + DigiToPlot.emplace_back(record.getVolts(), record.getADC(), + record.getTOT()); + } - // Print Voltages, adc/tot values to the same txt file - std::ofstream dataFile("Voltage_ADC_TOT.txt", std::ios::app); - for(const auto& entry: DigiToPlot){ - dataFile <(entry) << " " <(entry) << " " <(entry) << "\n"; - } - dataFile.close(); + // Print Voltages, adc/tot values to the same txt file + std::ofstream dataFile("Voltage_ADC_TOT.txt", std::ios::app); + for (const auto& entry : DigiToPlot) { + dataFile << std::get<0>(entry) << " " << std::get<1>(entry) << " " + << std::get<2>(entry) << "\n"; + } + dataFile.close(); } else { ldmx::HcalDigiID digiID(section, layer, strip, 1); @@ -325,20 +333,22 @@ void HcalDigiProducer::produce(framework::Event& event) { hcalDigis.addDigi(digiID.raw(), digiToAdd); } - // Recording digitized pulses in PulseRecord - // Access PulseRecord - const auto& pulseRecord = hgcroc_->getPulseRecord(); + // Recording digitized pulses in PulseRecord + // Access PulseRecord + const auto& pulseRecord = hgcroc_->getPulseRecord(); - for(const auto& record: pulseRecord){ - DigiToPlot.emplace_back(record.getVolts(), record.getADC(), record.getTOT()); - } + for (const auto& record : pulseRecord) { + DigiToPlot.emplace_back(record.getVolts(), record.getADC(), + record.getTOT()); + } - // Print Voltages, adc/tot values to the same txt file - std::ofstream dataFile("Voltage_ADC_TOT.txt", std::ios::app); - for(const auto& entry: DigiToPlot){ - dataFile <(entry) << " " <(entry) << " " <(entry) << "\n"; - } - dataFile.close(); + // Print Voltages, adc/tot values to the same txt file + std::ofstream dataFile("Voltage_ADC_TOT.txt", std::ios::app); + for (const auto& entry : DigiToPlot) { + dataFile << std::get<0>(entry) << " " << std::get<1>(entry) << " " + << std::get<2>(entry) << "\n"; + } + dataFile.close(); } } } @@ -346,8 +356,8 @@ void HcalDigiProducer::produce(framework::Event& event) { /****************************************************************************************** * Noise Simulation on Empty Channels *****************************************************************************************/ - //bool noise_ = false; - //std::cout << " noise: " << noise_ << std::endl; + // bool noise_ = false; + // std::cout << " noise: " << noise_ << std::endl; if (noise_) { int numChannels = 0; for (int section = 0; section < hcalGeometry.getNumSections(); section++) { @@ -424,7 +434,7 @@ void HcalDigiProducer::produce(framework::Event& event) { } } // loop over noise amplitudes - } // if we should add noise + } // if we should add noise event.add(digiCollName_, hcalDigis); diff --git a/Tools/include/Tools/HgcrocEmulator.h b/Tools/include/Tools/HgcrocEmulator.h index d97452807..4de325f0c 100644 --- a/Tools/include/Tools/HgcrocEmulator.h +++ b/Tools/include/Tools/HgcrocEmulator.h @@ -442,11 +442,13 @@ class HgcrocEmulator { */ mutable TF1 pulseFunc_; - mutable std::vector pulseRecord_ ; + mutable std::vector pulseRecord_; - //Getter to access pulseRecord_ - public: - const std::vector& getPulseRecord() const { return pulseRecord_;} + // Getter to access pulseRecord_ + public: + const std::vector& getPulseRecord() const { + return pulseRecord_; + } }; // HgcrocEmulator diff --git a/Tools/include/Tools/PulseRecord.h b/Tools/include/Tools/PulseRecord.h index 5df906910..792bd4395 100644 --- a/Tools/include/Tools/PulseRecord.h +++ b/Tools/include/Tools/PulseRecord.h @@ -5,22 +5,22 @@ namespace ldmx { - class PulseRecord { - public: - // Constructor to initialize Voltage, ADC, and TOT - PulseRecord(double volts, int adc, int tot) - : volts_(volts), adc_(adc), tot_(tot) {} +class PulseRecord { + public: + // Constructor to initialize Voltage, ADC, and TOT + PulseRecord(double volts, int adc, int tot) + : volts_(volts), adc_(adc), tot_(tot) {} - // Getters for the recorded data - double getVolts() const {return volts_;} - int getADC() const { return adc_; } - int getTOT() const { return tot_; } + // Getters for the recorded data + double getVolts() const { return volts_; } + int getADC() const { return adc_; } + int getTOT() const { return tot_; } - private: - double volts_; - int adc_; - int tot_; - }; -} + private: + double volts_; + int adc_; + int tot_; +}; +} // namespace ldmx -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/Tools/src/Tools/HgcrocEmulator.cxx b/Tools/src/Tools/HgcrocEmulator.cxx index 52888a442..f086cdb94 100644 --- a/Tools/src/Tools/HgcrocEmulator.cxx +++ b/Tools/src/Tools/HgcrocEmulator.cxx @@ -48,8 +48,8 @@ bool HgcrocEmulator::digitize( std::vector &digiToAdd) const { // step 0: prepare ourselves for emulation - digiToAdd.clear(); // make sure it is clean - pulseRecord_.clear(); // clear pulseRecord + digiToAdd.clear(); // make sure it is clean + pulseRecord_.clear(); // clear pulseRecord // Configure chip settings based off of table (that may have been passed) double totMax = getCondition(channelID, "TOT_MAX"); @@ -104,18 +104,18 @@ bool HgcrocEmulator::digitize( double vpeak = pulse(hit.second); double bxvolts = pulse((iADC - iSOI_) * clockCycle_); - //std::cout << "DEBUG PRINT - COMPARE IN COMING VOLTAGE AND PULSE FUNC VOLTAGE" << std::endl; - //std::cout << " Incoming peak Voltage: " << vpeak << std::endl; - //std::cout << " Pulse func Voltage: " << bxvolts << std::endl; - //std::cout << " " << std::endl; + // std::cout << "DEBUG PRINT - COMPARE IN COMING VOLTAGE AND PULSE FUNC + // VOLTAGE" << std::endl; std::cout << " Incoming peak Voltage: " << + // vpeak << std::endl; std::cout << " Pulse func Voltage: " << bxvolts + // << std::endl; std::cout << " " << std::endl; - //if (vpeak > totThreshold){ - //startTOT = true; - //if (toverTOT < hit.second) - //toverTOT = hit.second; // use the latest time in the window + // if (vpeak > totThreshold){ + // startTOT = true; + // if (toverTOT < hit.second) + // toverTOT = hit.second; // use the latest time in the window //} - if (bxvolts > totThreshold){ + if (bxvolts > totThreshold) { startTOT = true; if (toverTOT < hit.second) toverTOT = hit.second; // use the latest time in the window @@ -199,13 +199,12 @@ bool HgcrocEmulator::digitize( // Now just kill everything... while (digiToAdd.size() < nADCs_) { digiToAdd.emplace_back(true, false, // flags to mark type of sample - 0x3FF, 0x3FF, 0); + 0x3FF, 0x3FF, 0); } - for(const auto& digi: digiToAdd) - return true; // always readout + for (const auto &digi : digiToAdd) return true; // always readout - } else { + } else { // determine the voltage at the sampling time double bxvolts = pulse((iADC - iSOI_) * clockCycle_); // add noise if requested @@ -216,9 +215,9 @@ bool HgcrocEmulator::digitize( if (adc > 1023) adc = 1023; // Record in PulseRecord - if(adc >= readoutThreshold){ - //pulseRecord_.clear(); - pulseRecord_.emplace_back(bxvolts, adc, 0); + if (adc >= readoutThreshold) { + // pulseRecord_.clear(); + pulseRecord_.emplace_back(bxvolts, adc, 0); } // check for TOA @@ -241,7 +240,7 @@ bool HgcrocEmulator::digitize( adc, // ADC[t] is the second field toa // TOA is third measurement ); - + } // TOT or ADC Mode } // sampling baskets