Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:15

0001 // Copyright 2023, Christopher Dilks
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 #include "RawHitAnalysis.h"
0005 #include <edm4eic/EDM4eicVersion.h>
0006 
0007 namespace benchmarks {
0008 
0009   // AlgorithmInit
0010   //---------------------------------------------------------------------------
0011   void RawHitAnalysis::AlgorithmInit(
0012       std::shared_ptr<spdlog::logger>& logger
0013       )
0014   {
0015     m_log = logger;
0016 
0017     // define histograms
0018     m_adc_dist = new TH1D("adc_dist", "ADC Distribution;counts", adc_max, 0, adc_max);
0019     m_tdc_dist = new TH1D("tdc_dist", "TDC Distribution;counts", tdc_max, 0, tdc_max);
0020     m_tdc_vs_adc = new TH2D("tdc_vs_adc", "TDC vs. ADC;ADC counts;TDC counts",
0021         adc_max/2, 0, adc_max/2,
0022         tdc_max/2, 0, tdc_max/2
0023         );
0024     m_phot_spectrum = new TH1D(
0025         "phot_spectrum_rec",
0026         "Photon wavelength for digitized hits;#lambda [nm], at emission point",
0027         Tools::wl_bins, Tools::wl_min, Tools::wl_max
0028         );
0029     m_nhits_dist = new TH1D("nhits_dist", "Number of digitized hits;N_{hits}",
0030         Tools::npe_max, 0, Tools::npe_max
0031         );
0032 
0033     // format histograms
0034     auto format1D = [] (auto h) {
0035       h->SetLineColor(kBlack);
0036       h->SetFillColor(kBlack);
0037     };
0038     format1D(m_adc_dist);
0039     format1D(m_tdc_dist);
0040     m_phot_spectrum->SetLineColor(kViolet+2);
0041     m_phot_spectrum->SetFillColor(kViolet+2);
0042     m_nhits_dist->SetLineColor(kCyan+2);
0043     m_nhits_dist->SetFillColor(kCyan+2);
0044   }
0045 
0046 
0047   // AlgorithmProcess
0048   //---------------------------------------------------------------------------
0049   void RawHitAnalysis::AlgorithmProcess(
0050       const edm4eic::RawTrackerHitCollection& raw_hits,
0051       const edm4eic::MCRecoTrackerHitAssociationCollection& assocs
0052       )
0053   {
0054 
0055     // fill nhits
0056     m_nhits_dist->Fill(raw_hits.size());
0057 
0058     // loop over all raw hits (including noise)
0059     for(const auto& raw_hit : raw_hits) {
0060       auto adc = raw_hit.getCharge();
0061       auto tdc = raw_hit.getTimeStamp();
0062       m_adc_dist->Fill(adc);
0063       m_tdc_dist->Fill(tdc);
0064       m_tdc_vs_adc->Fill(adc,tdc);
0065     }
0066 
0067     // loop over hits with associations (no noise)
0068     for(const auto& assoc : assocs) {
0069 #if EDM4EIC_VERSION_MAJOR >= 6
0070       auto hit = assoc.getSimHit();
0071 #else
0072     for(const auto& hit : assoc.getSimHits()) {
0073 #endif
0074       auto wavelength = Tools::GetPhotonWavelength(hit, m_log);
0075       if(wavelength>=0)
0076         m_phot_spectrum->Fill(wavelength);
0077 #if EDM4EIC_VERSION_MAJOR >= 6
0078 #else
0079     }
0080 #endif
0081     }
0082   }
0083 
0084 
0085   // AlgorithmFinish
0086   //---------------------------------------------------------------------------
0087   void RawHitAnalysis::AlgorithmFinish() {
0088   }
0089 
0090 }