Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions offline/QA/Tpc/TpcRawHitQA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ int TpcRawHitQA::InitRun(PHCompositeNode *topNode)
}
}

h_nadc_bins_event = dynamic_cast<TH1 *>(hm->getHisto(std::string(getHistoPrefix() + "nadc_bins_event")));

h_xy_N = dynamic_cast<TH2 *>(hm->getHisto(std::string(getHistoPrefix() + "xyPos_North")));
h_xy_S = dynamic_cast<TH2 *>(hm->getHisto(std::string(getHistoPrefix() + "xyPos_South")));

Expand All @@ -120,6 +122,8 @@ int TpcRawHitQA::process_event(PHCompositeNode * /*unused*/)
float nhit_sectors_fees_sampas[24][26][8] = {{{0}}};

unsigned int raw_hit_num = 0;
unsigned int nadc_bins_event = 0;

for (TpcRawHitContainer *&rawhitcont : rawhitcont_vec)
{
raw_hit_num = rawhitcont->get_nhits();
Expand Down Expand Up @@ -215,6 +219,9 @@ int TpcRawHitQA::process_event(PHCompositeNode * /*unused*/)
{
const uint16_t sampleN = adc_iterator->CurrentTimeBin();
const uint16_t adc = adc_iterator->CurrentAdc();

++nadc_bins_event;

if (adc - median <= (std::max(5 * stdDev, (float) 20.)))
{
continue;
Expand Down Expand Up @@ -249,6 +256,8 @@ int TpcRawHitQA::process_event(PHCompositeNode * /*unused*/)
return Fun4AllReturnCodes::EVENT_OK;
}

h_nadc_bins_event->Fill(nadc_bins_event);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '110,275p' offline/QA/Tpc/TpcRawHitQA.cc

Repository: sPHENIX-Collaboration/coresoftware

Length of output: 4782


Use an event-level raw-hit count before filling the histogram.

raw_hit_num is overwritten for each container. If the final container is empty, the early return skips h_nadc_bins_event->Fill(...) even when an earlier container contributed ADC bins. Accumulate the hit count across containers before applying the event-level guard.

Suggested fix
-  unsigned int raw_hit_num = 0;
+  unsigned int raw_hit_num_event = 0;
   unsigned int nadc_bins_event = 0;

   for (TpcRawHitContainer *&rawhitcont : rawhitcont_vec)
     {
-      raw_hit_num = rawhitcont->get_nhits();
-      for (unsigned int i = 0; i < raw_hit_num; i++)
+      const unsigned int raw_hit_num = rawhitcont->get_nhits();
+      raw_hit_num_event += raw_hit_num;
+      for (unsigned int i = 0; i < raw_hit_num; i++)
...
-  if (raw_hit_num == 0)
+  if (raw_hit_num_event == 0)


for (int s = 0; s < 24; s++)
{
h_nhits_sectors[s]->Fill(nhit_sectors[s]);
Expand Down Expand Up @@ -309,6 +318,8 @@ void TpcRawHitQA::createHistos()
}
}

hm->registerHisto(new TH1F(std::string(getHistoPrefix() + "nadc_bins_event").c_str(), "Number of ADC Bins per Event;Number of ADC Bins/Event;Entries", 2500, 0, 1000000));

hm->registerHisto(new TH2F(std::string(getHistoPrefix() + "xyPos_North").c_str(), "Hit XY distribution (North);X [mm];Y [mm]", 400, -800, 800, 400, -800, 800));
hm->registerHisto(new TH2F(std::string(getHistoPrefix() + "xyPos_South").c_str(), "Hit XY distribution (South);X [mm];Y [mm]", 400, -800, 800, 400, -800, 800));
}
2 changes: 2 additions & 0 deletions offline/QA/Tpc/TpcRawHitQA.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class TpcRawHitQA : public SubsysReco
TH2* h_nhits_sectors_fees_sampas[24][26]{{nullptr}};
TH1* h_nhits_sam[24][3]{{nullptr}};
TH1* h_adc[24][3]{{nullptr}};
TH1* h_nadc_bins_event{nullptr};

TH2* h_xy_N{nullptr};
TH2* h_xy_S{nullptr};

Expand Down
Loading