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
44 changes: 37 additions & 7 deletions src/libraries/TRIGGER/DTrigger_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "FCAL/DFCALHit.h"

#include <JANA/JEvent.h>
#include "DANA/DEvent.h"


//------------------
Expand All @@ -28,9 +29,39 @@ void DTrigger_factory::Init()
locUsageString = "Calculate calorimter energy sums using emulated triggers (1/0, off by default)";
app->SetDefaultParameter("TRIGGER:EMULATE_CAL_ENERGY_SUMS", EMULATE_CAL_ENERGY_SUMS, locUsageString);

locUsageString = "";
app->SetDefaultParameter("TRIGGER:MC_TRIGGER_TAG", MC_TRIGGER_TAG, locUsageString);
locUsageString = "";
app->SetDefaultParameter("TRIGGER:DATA_SIM_TRIGGER_TAG", DATA_SIM_TRIGGER_TAG, locUsageString);

}


//------------------
// BeginRun
//------------------
void DTrigger_factory::BeginRun(const std::shared_ptr<const JEvent>& event)
{
map<string,string> trigger_tags;
if( DEvent::GetCalib(event, "/ANALYSIS/dtrigger_types", trigger_tags) ) {
jerr << "Cannot find requested /ANALYSIS/dtrigger_types in CCDB for this run!" << endl;
return; // RESOURCE_UNAVAILABLE;
}

if (trigger_tags.find("data_tag") != trigger_tags.end()) {
DATA_SIM_TRIGGER_TAG = trigger_tags["data_tag"];
} else {
jerr << "Unable to get DATA_SIM_TRIGGER_TAG from /ANALYSIS/dtrigger_types !" << endl;
return; // RESOURCE_UNAVAILABLE;
}
if (trigger_tags.find("mc_tag") != trigger_tags.end()) {
MC_TRIGGER_TAG = trigger_tags["mc_tag"];
} else {
jerr << "Unable to get MC_TRIGGER_TAG from /ANALYSIS/dtrigger_types !" << endl;
return; // RESOURCE_UNAVAILABLE;
}

}


//------------------
Expand Down Expand Up @@ -82,15 +113,15 @@ void DTrigger_factory::Process(const std::shared_ptr<const JEvent>& event)
// eventually we'll get the values directly from the firmware
if(EMULATE_CAL_ENERGY_SUMS) {
vector<const DL1MCTrigger*> locMCTriggers;
event->Get(locMCTriggers, "DATA");
event->Get(locMCTriggers, DATA_SIM_TRIGGER_TAG);
const DL1MCTrigger* locMCTrigger = locMCTriggers.empty() ? NULL : locMCTriggers[0];

if(locMCTrigger != NULL)
{
locTrigger->Set_GTP_BCALEnergy(locMCTrigger->bcal_gtp_en);
locTrigger->Set_GTP_FCALEnergy(locMCTrigger->fcal_gtp_en);
locTrigger->Set_GTP_ECALEnergy(locMCTrigger->ecal_gtp_en);
locTrigger->Set_GTP_FCAL2Energy(locMCTrigger->fcal2_gtp_en);
locTrigger->Set_GTP_ECALEnergy(locMCTrigger->ecal_gtp_en);
locTrigger->Set_GTP_FCAL2Energy(locMCTrigger->fcal2_gtp_en);
}
}

Expand All @@ -114,7 +145,7 @@ void DTrigger_factory::Process(const std::shared_ptr<const JEvent>& event)

// realistic trigger simulation
vector<const DL1MCTrigger*> locMCTriggers;
event->Get(locMCTriggers);
event->Get(locMCTriggers, MC_TRIGGER_TAG);
const DL1MCTrigger* locMCTrigger = locMCTriggers.empty() ? NULL : locMCTriggers[0];

if(locMCTrigger != NULL)
Expand All @@ -124,9 +155,8 @@ void DTrigger_factory::Process(const std::shared_ptr<const JEvent>& event)
locTrigger->Set_L1FrontPanelTriggerBits(0);
locTrigger->Set_GTP_BCALEnergy(locMCTrigger->bcal_gtp_en);
locTrigger->Set_GTP_FCALEnergy(locMCTrigger->fcal_gtp_en);
locTrigger->Set_GTP_ECALEnergy(locMCTrigger->ecal_gtp_en);
locTrigger->Set_GTP_FCAL2Energy(locMCTrigger->fcal2_gtp_en);

locTrigger->Set_GTP_ECALEnergy(locMCTrigger->ecal_gtp_en);
locTrigger->Set_GTP_FCAL2Energy(locMCTrigger->fcal2_gtp_en);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/libraries/TRIGGER/DTrigger_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DTrigger_factory : public JFactoryT<DTrigger>

private:
void Init() override;
void BeginRun(const std::shared_ptr<const JEvent>& event) override;
void Process(const std::shared_ptr<const JEvent>& event) override;

bool EMULATE_BCAL_LED_TRIGGER;
Expand All @@ -29,6 +30,9 @@ class DTrigger_factory : public JFactoryT<DTrigger>

unsigned int BCAL_LED_NHITS_THRESHOLD;
unsigned int FCAL_LED_NHITS_THRESHOLD;

string MC_TRIGGER_TAG = "";
string DATA_SIM_TRIGGER_TAG = "DATA";
};

#endif // _DTrigger_factory_