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
72 changes: 15 additions & 57 deletions offline/packages/CaloReco/CaloTowerBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <calobase/TowerInfoContainerv4.h>

#include <ffarawobjects/CaloPacket.h>
#include <ffarawobjects/CaloPacketContainer.h>

#include <cdbobjects/CDBTTree.h> // for CDBTTree

Expand Down Expand Up @@ -263,45 +262,8 @@ int CaloTowerBuilder::process_sim()

int CaloTowerBuilder::process_data(PHCompositeNode *topNode, std::vector<std::vector<float>> &waveforms)
{
std::variant<CaloPacketContainer *, Event *> event;
if (m_UseOfflinePacketFlag)
{
CaloPacketContainer *calopacketcontainer = findNode::getClass<CaloPacketContainer>(topNode, nodemap.find(m_dettype)->second);
if (!calopacketcontainer)
{
for (int pid = m_packet_low; pid <= m_packet_high; pid++)
{
if (findNode::getClass<CaloPacket>(topNode, pid))
{
m_PacketNodesFlag = true;
break;
}
}
if (!m_PacketNodesFlag)
{
return Fun4AllReturnCodes::EVENT_OK;
}
}
else
{
event = calopacketcontainer;
}
}
else
{
Event *_event = findNode::getClass<Event>(topNode, "PRDF");
if (_event == nullptr)
{
std::cout << PHWHERE << " Event not found" << std::endl;
return Fun4AllReturnCodes::ABORTEVENT;
}
if (_event->getEvtType() != DATAEVENT)
{
return Fun4AllReturnCodes::ABORTEVENT;
}
event = _event;
}
// since the function call on Packet and CaloPacket is the same, maybe we can use lambda?
// this lambda function call is used for Event Packet and CaloPacket.
// since we kept the method calls identical we can handle both of them in a single function
auto process_packet = [&](auto *packet, int pid)
{
if (packet)
Expand Down Expand Up @@ -436,29 +398,25 @@ int CaloTowerBuilder::process_data(PHCompositeNode *topNode, std::vector<std::ve
return Fun4AllReturnCodes::EVENT_OK;
};

Event *event = findNode::getClass<Event>(topNode, "PRDF");
if (event)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{
if (event->getEvtType() != DATAEVENT)
{
return Fun4AllReturnCodes::ABORTEVENT;
}
}
for (int pid = m_packet_low; pid <= m_packet_high; pid++)
{
if (!m_PacketNodesFlag)
if (event)
{
if (auto *hcalcont = std::get_if<CaloPacketContainer *>(&event))
{
CaloPacket *packet = (*hcalcont)->getPacketbyId(pid);
if (process_packet(packet, pid) == Fun4AllReturnCodes::ABORTEVENT)
{
return Fun4AllReturnCodes::ABORTEVENT;
}
}
else if (auto *_event = std::get_if<Event *>(&event))
Packet *packet = event->getPacket(pid);
if (process_packet(packet, pid) == Fun4AllReturnCodes::ABORTEVENT)
{
Packet *packet = (*_event)->getPacket(pid);
if (process_packet(packet, pid) == Fun4AllReturnCodes::ABORTEVENT)
{
// I think it is safe to delete a nullptr...
delete packet;
return Fun4AllReturnCodes::ABORTEVENT;
}
delete packet;
return Fun4AllReturnCodes::ABORTEVENT;
}
delete packet;
}
else
{
Expand Down
19 changes: 10 additions & 9 deletions offline/packages/CaloReco/CaloTowerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TowerInfoContainerv3;

class CaloTowerBuilder : public SubsysReco
{
public:
public:
explicit CaloTowerBuilder(const std::string &name = "CaloTowerBuilder");
~CaloTowerBuilder() override;

Expand Down Expand Up @@ -79,8 +79,10 @@ class CaloTowerBuilder : public SubsysReco

void set_offlineflag(const bool f = true)
{
m_UseOfflinePacketFlag = f;
tmpdummy = f;
return;
}

void set_timeFitLim(float low, float high)
{
m_setTimeLim = true;
Expand Down Expand Up @@ -129,22 +131,21 @@ class CaloTowerBuilder : public SubsysReco

CaloWaveformProcessing *get_WaveformProcessing() { return WaveformProcessing; }

private:
private:
int process_sim();
bool skipChannel(int ich, int pid);
static bool isSZS(float time, float chi2);
CaloWaveformProcessing *WaveformProcessing{nullptr};
TowerInfoContainer *m_CaloInfoContainer{nullptr}; //! Calo info
TowerInfoContainer *m_CalowaveformContainer{nullptr}; // waveform from simulation
CDBTTree *cdbttree = nullptr;
CDBTTree *cdbttree_sepd_map = nullptr;
CDBTTree *cdbttree_tbt_zs = nullptr;
CDBTTree *cdbttree{nullptr};
CDBTTree *cdbttree_sepd_map{nullptr};
CDBTTree *cdbttree_tbt_zs{nullptr};

bool m_isdata{true};
bool m_bdosoftwarezerosuppression{false};
bool m_UseOfflinePacketFlag{false};
bool m_dotbtszs{false};
bool m_PacketNodesFlag{false};
bool tmpdummy{false};
int m_packet_low{std::numeric_limits<int>::min()};
int m_packet_high{std::numeric_limits<int>::min()};
int m_nsamples{16};
Expand Down Expand Up @@ -181,4 +182,4 @@ class CaloTowerBuilder : public SubsysReco
double m_doubleexp_ratio{0.3};
};

#endif // CALOTOWERBUILDER_H
#endif // CALORECO_CALOTOWERBUILDER_H
2 changes: 1 addition & 1 deletion offline/packages/tpc/TpcCombinedRawDataUnpacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int TpcCombinedRawDataUnpacker::Init(PHCompositeNode* /*topNode*/)
}
else
{
std::cout << "TpcRawDataDecoder::::InitRun No calibration file found" << std::endl;
std::cout << "TpcCombinedRawDataUnpacker::::InitRun No calibration file found" << std::endl;
exit(1);
}

Expand Down
Loading