Skip to content
Open
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
34 changes: 30 additions & 4 deletions offline/QA/Calorimeters/CaloValid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ int CaloValid::process_event(PHCompositeNode* topNode)
return Fun4AllReturnCodes::EVENT_OK;
}

/**
* @brief Process tower, trigger, MBD, and cluster information for a single event and fill QA histograms.
*
* Processes calibrated and raw towers for CEMC, HCALIN, and HCALOUT plus MBD PMTs; decodes GL1 trigger bits;
* accumulates per-calorimeter totals; fills per-channel, eta/phi, timing, status, and QA histograms; builds
* cluster pairs to produce pi0 candidates and fills related mass/IB histograms; and fills trigger-aligned
* distributions and livetime/rejection profiles.
*
* The function reads multiple nodes from the provided top-level node tree (EventHeader, GlobalVertexMap,
* Gl1Packet, TowerInfoContainer for several collections, MbdPmtContainer, RawClusterContainer, RawTowerGeomContainer)
* and relies on an available TriggerAnalyzer if set. If the required cluster node ("CLUSTERINFO_CEMC") is missing
* the function logs an error and returns 0. Histograms updated by this method include correlations between EMCal/MBD/HCAL,
* per-channel pedestal/energy/timing, eta-phi maps, cluster QA, pi0/IB mass distributions, and trigger-related profiles.
*
* @param topNode Top-level node providing event data containers accessed by name.
* @return int Fun4All return code; `Fun4AllReturnCodes::EVENT_OK` on normal completion, or `0` if the CEMC cluster node is missing.
*/
int CaloValid::process_towers(PHCompositeNode* topNode)
{
//---------------------------Event header--------------------------------//
Expand Down Expand Up @@ -335,7 +352,10 @@ int CaloValid::process_towers(PHCompositeNode* topNode)
status = status >> 1U; // clang-tidy mark 1 as unsigned
}

totalcemc += offlineenergy;
if (isGood)
{
totalcemc += offlineenergy;
}
h_emcaltime->Fill(_timef);
if (offlineenergy > emcal_hit_threshold)
{
Expand Down Expand Up @@ -407,7 +427,10 @@ int CaloValid::process_towers(PHCompositeNode* topNode)
status = status >> 1U; // clang-tidy mark 1 as unsigned
}

totalihcal += offlineenergy;
if (isGood)
{
totalihcal += offlineenergy;
}
h_ihcaltime->Fill(_timef);

if (offlineenergy > ihcal_hit_threshold)
Expand Down Expand Up @@ -472,7 +495,10 @@ int CaloValid::process_towers(PHCompositeNode* topNode)
status = status >> 1U; // clang-tidy mark 1 as unsigned
}

totalohcal += offlineenergy;
if (isGood)
{
totalohcal += offlineenergy;
}
h_ohcaltime->Fill(_timef);

if (offlineenergy > ohcal_hit_threshold)
Expand Down Expand Up @@ -1292,4 +1318,4 @@ void CaloValid::createHistos()
}
hm->registerHisto(h_triggerVec);
hm->registerHisto(pr_ldClus_trig);
}
}
173 changes: 77 additions & 96 deletions offline/framework/fun4allraw/Fun4AllStreamingInputManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,19 @@ int Fun4AllStreamingInputManager::FillGl1()
return 0;
}

/**
* @brief Populate the INTT raw-hit container from buffered streaming inputs.
*
* Calls FillInttPool() to ensure INTT input pools are populated, determines a BCO
* selection window relative to the manager's reference BCO, and appends all INTT
* raw hits whose BCO is within that window into the InttRawHitContainer found
* under the top node. While doing so, the method may set m_RefBCO if it was
* unset, drop buffered entries earlier than the configured negative offset, and
* fill QA histograms that describe per-packet and per-FEE tagging and BCO
* differences.
*
* @return int 0 on success; non-zero error code returned from FillInttPool() on failure.
*/
int Fun4AllStreamingInputManager::FillIntt()
{
int iret = FillInttPool();
Expand Down Expand Up @@ -776,9 +789,15 @@ int Fun4AllStreamingInputManager::FillIntt()
{
h_taggedAllFee_intt->Fill(refbcobitshift);
}
while (m_InttRawHitMap.begin()->first <= select_crossings - m_intt_negative_bco)

for (auto& [bco, hitinfo] : m_InttRawHitMap)
{
for (auto *intthititer : m_InttRawHitMap.begin()->second.InttRawHitVector)
if (bco > select_crossings)
{
break;
}

for (auto *intthititer : hitinfo.InttRawHitVector)
{
if (Verbosity() > 1)
{
Expand All @@ -788,25 +807,24 @@ int Fun4AllStreamingInputManager::FillIntt()
}
inttcont->AddHit(intthititer);
}
for (auto *iter : m_InttInputVector)
{
iter->CleanupUsedPackets(m_InttRawHitMap.begin()->first);
if (m_intt_negative_bco < 2) // triggered mode
{
iter->clearPacketBClkStackMap(m_InttRawHitMap.begin()->first);
iter->clearFeeGTML1BCOMap(m_InttRawHitMap.begin()->first);
}
}
m_InttRawHitMap.begin()->second.InttRawHitVector.clear();
m_InttRawHitMap.erase(m_InttRawHitMap.begin());
if (m_InttRawHitMap.empty())
{
break;
}
}
}
return 0;
}

/**
* @brief Collects MVTX streaming data for the current reference BCO and fills MVTX event/header containers and QA histograms.
*
* Processes MVTX input pools, prunes MVTX BCO entries older than the configured negative window, updates the internal reference BCO if unset, evaluates packet/FEE tagging and fills QA histograms, and transfers MVTX fee information, L1 trigger BCOs, and raw hits into the MVTX event header and hit container for BCOS inside the configured selection window.
*
* Side effects:
* - May set m_RefBCO when it was zero.
* - Adds fee ID info entries and L1 trigger BCOs to the MVTX raw event header node.
* - Adds MVTX raw hits to the MVTX raw hit container node.
* - Updates internal per-input packet bookkeeping via CleanupUsedPackets/clearFeeGTML1BCOMap during pruning.
* - Fills multiple MVTX QA histograms used for tag and BCO-difference monitoring.
* - Terminates the process with exit(1) if required MVTX nodes are missing.
*
* @return int `0` on successful fill; non-zero return values are propagated from FillMvtxPool when pool filling fails.
*/
int Fun4AllStreamingInputManager::FillMvtx()
{
int iret = FillMvtxPool();
Expand Down Expand Up @@ -846,7 +864,7 @@ int Fun4AllStreamingInputManager::FillMvtx()
}
select_crossings += m_RefBCO;

uint64_t ref_bco_minus_range = m_RefBCO < m_mvtx_bco_range ? 0 : m_RefBCO - m_mvtx_bco_range;
uint64_t ref_bco_minus_range = m_RefBCO < m_mvtx_negative_bco ? 0 : m_RefBCO - m_mvtx_negative_bco;
if (Verbosity() > 2)
{
std::cout << "select MVTX crossings"
Expand Down Expand Up @@ -981,90 +999,42 @@ int Fun4AllStreamingInputManager::FillMvtx()
}
taggedPacketsFEEs.clear();

if (m_mvtx_is_triggered)
uint64_t lower_limit = m_mvtx_is_triggered ? select_crossings : select_crossings - m_mvtx_bco_range - m_mvtx_negative_bco;
uint64_t upper_limit = m_mvtx_is_triggered ? select_crossings + m_mvtx_bco_range : select_crossings;

for (auto& [bco, hitinfo] : m_MvtxRawHitMap)
{
while (select_crossings <= m_MvtxRawHitMap.begin()->first && m_MvtxRawHitMap.begin()->first <= select_crossings + m_mvtx_bco_range) // triggered
if (bco < lower_limit)
{
if (Verbosity() > 2)
{
std::cout << "Adding 0x" << std::hex << m_MvtxRawHitMap.begin()->first
<< " ref: 0x" << select_crossings << std::dec << std::endl;
}
for (auto *mvtxFeeIdInfo : m_MvtxRawHitMap.begin()->second.MvtxFeeIdInfoVector)
{
if (Verbosity() > 1)
{
mvtxFeeIdInfo->identify();
}
mvtxEvtHeader->AddFeeIdInfo(mvtxFeeIdInfo);
delete mvtxFeeIdInfo;
}
m_MvtxRawHitMap.begin()->second.MvtxFeeIdInfoVector.clear();
mvtxEvtHeader->AddL1Trg(m_MvtxRawHitMap.begin()->second.MvtxL1TrgBco);
continue;
}
if (bco > upper_limit)
{
break;
}

for (auto *mvtxhititer : m_MvtxRawHitMap.begin()->second.MvtxRawHitVector)
{
if (Verbosity() > 1)
{
mvtxhititer->identify();
}
mvtxcont->AddHit(mvtxhititer);
}
for (auto *iter : m_MvtxInputVector)
{
iter->CleanupUsedPackets(m_MvtxRawHitMap.begin()->first);
}
m_MvtxRawHitMap.begin()->second.MvtxRawHitVector.clear();
m_MvtxRawHitMap.begin()->second.MvtxL1TrgBco.clear();
m_MvtxRawHitMap.erase(m_MvtxRawHitMap.begin());
// m_MvtxRawHitMap.empty() need to be checked here since we do not call FillPoolMvtx()
if (m_MvtxRawHitMap.empty())
{
break;
}
if (Verbosity() > 2)
{
std::cout << "Adding 0x" << std::hex << bco
<< " ref: 0x" << select_crossings << std::dec << std::endl;
}
}
else
{
while (select_crossings - m_mvtx_bco_range - m_mvtx_negative_bco <= m_MvtxRawHitMap.begin()->first && m_MvtxRawHitMap.begin()->first <= select_crossings) // streamed
for (auto *mvtxFeeIdInfo : hitinfo.MvtxFeeIdInfoVector)
{
if (Verbosity() > 2)
{
std::cout << "Adding 0x" << std::hex << m_MvtxRawHitMap.begin()->first
<< " ref: 0x" << select_crossings << std::dec << std::endl;
}
for (auto *mvtxFeeIdInfo : m_MvtxRawHitMap.begin()->second.MvtxFeeIdInfoVector)
if (Verbosity() > 1)
{
if (Verbosity() > 1)
{
mvtxFeeIdInfo->identify();
}
mvtxEvtHeader->AddFeeIdInfo(mvtxFeeIdInfo);
delete mvtxFeeIdInfo;
mvtxFeeIdInfo->identify();
}
m_MvtxRawHitMap.begin()->second.MvtxFeeIdInfoVector.clear();
mvtxEvtHeader->AddL1Trg(m_MvtxRawHitMap.begin()->second.MvtxL1TrgBco);
mvtxEvtHeader->AddFeeIdInfo(mvtxFeeIdInfo);
}
mvtxEvtHeader->AddL1Trg(hitinfo.MvtxL1TrgBco);

for (auto *mvtxhititer : m_MvtxRawHitMap.begin()->second.MvtxRawHitVector)
{
if (Verbosity() > 1)
{
mvtxhititer->identify();
}
mvtxcont->AddHit(mvtxhititer);
}
for (auto *iter : m_MvtxInputVector)
{
iter->CleanupUsedPackets(m_MvtxRawHitMap.begin()->first);
}
m_MvtxRawHitMap.begin()->second.MvtxRawHitVector.clear();
m_MvtxRawHitMap.begin()->second.MvtxL1TrgBco.clear();
m_MvtxRawHitMap.erase(m_MvtxRawHitMap.begin());
// m_MvtxRawHitMap.empty() need to be checked here since we do not call FillPoolMvtx()
if (m_MvtxRawHitMap.empty())
for (auto *mvtxhititer : hitinfo.MvtxRawHitVector)
{
if (Verbosity() > 1)
{
break;
mvtxhititer->identify();
}
mvtxcont->AddHit(mvtxhititer);
}
}

Expand Down Expand Up @@ -1420,9 +1390,20 @@ int Fun4AllStreamingInputManager::FillMicromegasPool()
return 0;
}

/**
* @brief Fill MVTX input pools and ensure run-number consistency.
*
* Calls FillPool(ref_bco_minus_range) on each registered MVTX input, updates the manager's run number
* from the first input, and validates that all inputs share the same run number.
*
* @return int `0` on success, `-1` if no MVTX hits were collected (MvtxRawHitMap is empty).
*
* @note This function may terminate the process (exit with code 1) if a run-number mismatch is detected
* between MVTX inputs.
*/
int Fun4AllStreamingInputManager::FillMvtxPool()
{
uint64_t ref_bco_minus_range = m_RefBCO < m_mvtx_bco_range ? m_mvtx_bco_range : m_RefBCO - m_mvtx_bco_range;
uint64_t ref_bco_minus_range = m_RefBCO < m_mvtx_negative_bco ? m_mvtx_negative_bco : m_RefBCO - m_mvtx_negative_bco;
for (auto *iter : m_MvtxInputVector)
{
if (Verbosity() > 3)
Expand Down Expand Up @@ -1569,4 +1550,4 @@ void Fun4AllStreamingInputManager::createQAHistos()
h_tagBcoFelix_mvtx[i] = dynamic_cast<TH1 *>(hm->getHisto((boost::format("h_MvtxPoolQA_TagBCO_felix%i") % i).str()));
h_tagBcoFelixAllFees_mvtx[i] = dynamic_cast<TH1 *>(hm->getHisto((boost::format("h_MvtxPoolQA_TagBCOAllFees_Felix%i") % i).str()));
}
}
}
Loading