Skip to content
Snippets Groups Projects
Commit f7252b15 authored by Tim Martin's avatar Tim Martin
Browse files

Fix an issue at T0 when events from multiple LB have different trigger configurations.

Otherwise this tries to record the same collection to storegate twice

Affects T0 RAW->NTUP_TRIGCOST transform only
parent 80969d3c
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@ private:
bool ReadConfig(ServiceHandle<StoreGateSvc> &storeGate);
bool ReadConfigDB(ServiceHandle<StoreGateSvc> &storeGate,
const TrigMonEvent* trigMonEvent,
std::set<const TrigMonEvent*> trigMonEvents,
ToolHandle<Trig::ITrigNtTool> &confTool);
bool ReadEvent (ServiceHandle<StoreGateSvc> &storeGate,
......
......@@ -91,10 +91,10 @@ StatusCode TrigCostRun::initialize()
ATH_MSG_DEBUG("Retrieved : " << m_tools);
CHECK(m_toolsSave.retrieve());
ATH_MSG_DEBUG("Retrieved " << m_toolsSave << endreq);
ATH_MSG_DEBUG("Retrieved " << m_toolsSave << endmsg);
CHECK(m_toolConf.retrieve());
ATH_MSG_DEBUG("Retrieved " << m_toolConf << endreq);
ATH_MSG_DEBUG("Retrieved " << m_toolConf << endmsg);
//
// Pass global configuration pointer to sub-tools
......@@ -355,7 +355,8 @@ bool TrigCostRun::ReadHLTResult::ProcessEvent(ServiceHandle<StoreGateSvc> &store
// - read TrigMonEvent collection
// - read TrigMonConfig collection
//
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "In ProcessEvent" << endmsg;
if (doLevel == false) return false;
vecConfig.clear();
......@@ -380,6 +381,8 @@ bool TrigCostRun::ReadHLTResult::ProcessEvent(ServiceHandle<StoreGateSvc> &store
const bool gotConfigSG = ReadConfig(storeGate);
// If gotConfigSG is false, we will try again to read in from the DB configs for cost mon events stored in this dummy-export-event
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "gotConfigSG = " << gotConfigSG << endmsg;
ReadEvent(storeGate, gotConfigSG, confTool);
return true;
......@@ -393,27 +396,27 @@ bool TrigCostRun::ReadHLTResult::ReadResult(ServiceHandle<StoreGateSvc> &storeGa
// Find HLTResult and extract application id
//
if(!storeGate->contains<HLT::HLTResult>(keyResult)) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "StoreGate does not contain HLTResult: " << keyResult << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "StoreGate does not contain HLTResult: " << keyResult << endmsg;
return false;
}
const HLT::HLTResult *hlt_result = 0;
if(storeGate->retrieve<HLT::HLTResult>(hlt_result, keyResult).isFailure() || !hlt_result) {
log() << MSG::WARNING << "Failed to retrieve HLTResult: " << keyResult << endreq;
log() << MSG::WARNING << "Failed to retrieve HLTResult: " << keyResult << endmsg;
return false;
}
else {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Found HLTResult: " << keyResult << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Found HLTResult: " << keyResult << endmsg;
}
if(hlt_result->isHLTResultTruncated()) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "HLTResult is truncated" << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "HLTResult is truncated" << endmsg;
++countTrunc;
}
const std::vector<uint32_t>& navData = hlt_result->getNavigationResult();
if(navData.empty()) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Navigation data is empty" << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Navigation data is empty" << endmsg;
return false;
}
......@@ -421,14 +424,14 @@ bool TrigCostRun::ReadHLTResult::ReadResult(ServiceHandle<StoreGateSvc> &storeGa
ScopeResumePauseTimer scopeTimer(timerNavig, false);
if(!navigation->deserialize(navData)) {
log() << MSG::WARNING << "Failed to deserialize navigation" << endreq;
log() << MSG::WARNING << "Failed to deserialize navigation" << endmsg;
return false;
}
}
const std::vector<uint32_t> &extraData = hlt_result->getExtras();
if(extraData.empty()) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Extra data is empty" << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Extra data is empty" << endmsg;
return true;
}
......@@ -438,34 +441,34 @@ bool TrigCostRun::ReadHLTResult::ReadResult(ServiceHandle<StoreGateSvc> &storeGa
StringSerializer().deserialize(extraData, appName);
if(appName.empty()) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Application name is empty" << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Application name is empty" << endmsg;
return true;
}
if(hlt_result->getHLTLevel() == HLT::L2) {
if(hltLevel != "L2") {
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endreq;
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endmsg;
}
}
else if(hlt_result->getHLTLevel() == HLT::EF) {
if(hltLevel != "EF") {
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endreq;
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endmsg;
}
}
else if(hlt_result->getHLTLevel() == HLT::HLT) {
if(hltLevel != "HLT") {
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endreq;
log() << MSG::WARNING << "HLT level error: " << hltLevel << "!=" << hlt_result->getHLTLevel() << endmsg;
}
}
else {
log() << MSG::WARNING << "Unknown level for HLTResult: " << hlt_result->getHLTLevel() << endreq;
log() << MSG::WARNING << "Unknown level for HLTResult: " << hlt_result->getHLTLevel() << endmsg;
}
//
// Append application ID with level string
//
appName = "APP_"+hltLevel+":"+appName;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Extracted App Name: " << appName << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Extracted App Name: " << appName << endmsg;
//
// Save a map between application name and application id (hashed name) in global config
......@@ -495,16 +498,16 @@ bool TrigCostRun::ReadHLTResult::ReadConfig(ServiceHandle<StoreGateSvc> &storeGa
ScopeResumePauseTimer scopeTimer(timerNavig, false);
if(!storeGate->contains<TrigMonConfigCollection>(keyConfig)) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "TrigMonConfigCollection does not exist: " << keyConfig << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "TrigMonConfigCollection does not exist: " << keyConfig << endmsg;
return false;
}
if(storeGate->retrieve(configCol, keyConfig).isFailure() || !configCol) {
log() << MSG::WARNING << "Failed to retrieve TrigMonConfigCollection: " << keyConfig << endreq;
log() << MSG::WARNING << "Failed to retrieve TrigMonConfigCollection: " << keyConfig << endmsg;
return false;
}
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Found TrigMonConfigCollection: " << keyConfig << " size=" << configCol->size() << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Found TrigMonConfigCollection: " << keyConfig << " size=" << configCol->size() << endmsg;
}
for(TrigMonConfigCollection::const_iterator it = configCol->begin(); it != configCol->end(); ++it) {
......@@ -522,7 +525,7 @@ bool TrigCostRun::ReadHLTResult::ReadConfig(ServiceHandle<StoreGateSvc> &storeGa
const std::vector<uint32_t> &ids = ptr->getVarId();
if(!std::count(ids.begin(), ids.end(), appId)) {
ptr->add<TrigConfVar>(TrigConfVar(appName, appId));
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Attaching App Name map to Config " << appName << " = " << appId << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Attaching App Name map to Config " << appName << " = " << appId << endmsg;
}
//
......@@ -532,7 +535,7 @@ bool TrigCostRun::ReadHLTResult::ReadConfig(ServiceHandle<StoreGateSvc> &storeGa
log() << MSG::INFO << "ExtractConfig M:" << ptr->getMasterKey()
<< " L1:" << ptr->getLV1PrescaleKey() << " HLT:" << ptr->getHLTPrescaleKey()
<< " Lumi:" << ptr->getLumi() << endreq;
<< " Lumi:" << ptr->getLumi() << endmsg;
}
//
......@@ -545,7 +548,7 @@ bool TrigCostRun::ReadHLTResult::ReadConfig(ServiceHandle<StoreGateSvc> &storeGa
//---------------------------------------------------------------------------------------
bool TrigCostRun::ReadHLTResult::ReadConfigDB(ServiceHandle<StoreGateSvc> &storeGate,
const TrigMonEvent* trigMonEvent,
std::set<const TrigMonEvent*> trigMonEvents,
ToolHandle<Trig::ITrigNtTool> &confTool) {
//
// Read in trig config from data base
......@@ -555,33 +558,48 @@ bool TrigCostRun::ReadHLTResult::ReadConfigDB(ServiceHandle<StoreGateSvc> &store
// the D3PD maker
//
TrigMonConfig* trigMonConfig = new TrigMonConfig();
// Write me to storegate so that I can get picked up by the ntuple tools
TrigMonConfigCollection* trigMonConfigCollection = new TrigMonConfigCollection();
// Look at all events in this container event which come from a different LB
for (const TrigMonEvent* trigMonEvent : trigMonEvents) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << " Get config for event " << trigMonEvent->getEvent() << " lumi " << trigMonEvents->getLumi() << endmsg;
trigMonConfig->setEventID(trigMonEvent->getEvent(),
trigMonEvent->getLumi(),
trigMonEvent->getRun(),
trigMonEvent->getSec(),
trigMonEvent->getNanoSec());
TrigMonConfig* trigMonConfig = new TrigMonConfig();
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "ProcessConfig - Attempting load from DB " << endreq;
// Set the vital stats needed to identify the correct config
trigMonConfig->setEventID(trigMonEvent->getEvent(),
trigMonEvent->getLumi(),
trigMonEvent->getRun(),
trigMonEvent->getSec(),
trigMonEvent->getNanoSec());
confTool->SetOption(2); //2 = DBAccess
confTool->Fill(trigMonConfig);
confTool->SetOption(2); //2 = DBAccess
if (!confTool->Fill(trigMonConfig)) { // false indicates nothing changed
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << " Keys did not change in this LB, no need to update. (SMK:" << trigMonConfig->getMasterKey() << " L1:" << trigMonConfig->getLV1PrescaleKey() << " HLT:" << trigMonConfig->getHLTPrescaleKey() << ")" << endmsg;
delete trigMonConfig;
continue;
}
// Have we already saved this config?
std::pair<int,int> prescaleKeys( trigMonConfig->getLV1PrescaleKey(), trigMonConfig->getHLTPrescaleKey() );
if ( exportedConfigs.find(prescaleKeys) != exportedConfigs.end() ) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Already exported for L1 "
<< trigMonConfig->getLV1PrescaleKey() << " HLT " << trigMonConfig->getHLTPrescaleKey() << endreq;
delete trigMonConfig;
return true;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << " Loaded from DB-fetcher SMK:" << trigMonConfig->getMasterKey() << " L1:" << trigMonConfig->getLV1PrescaleKey() << " HLT:" << trigMonConfig->getHLTPrescaleKey() << endmsg;
// Have we already saved this config? Note this is set in the next fn so we could end up with dupes here (not harmful)
std::pair<int,int> prescaleKeys( trigMonConfig->getLV1PrescaleKey(), trigMonConfig->getHLTPrescaleKey() );
if ( exportedConfigs.find(prescaleKeys) != exportedConfigs.end() ) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << " Already exported for L1 " << trigMonConfig->getLV1PrescaleKey() << " HLT " << trigMonConfig->getHLTPrescaleKey() << endmsg;
delete trigMonConfig;
continue;
}
// Add to the export list
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << " Adding to SG" << endmsg;
trigMonConfigCollection->push_back(trigMonConfig);
}
// Write me to storegate so that I can get picked up by the ntuple tools
TrigMonConfigCollection* trigMonConfigCollection = new TrigMonConfigCollection();
trigMonConfigCollection->push_back(trigMonConfig);
if(storeGate->record(trigMonConfigCollection, keyConfig).isFailure()) {
log() << MSG::ERROR << "Failed to write TrigMonEventCollection: " << keyConfig << endreq;
log() << MSG::ERROR << "Failed to write TrigMonEventCollection: " << keyConfig << endmsg;
for (TrigMonConfig* trigMonConfig : *trigMonConfigCollection) delete trigMonConfig;
delete trigMonConfigCollection;
return false;
}
......@@ -594,6 +612,7 @@ bool TrigCostRun::ReadHLTResult::ReadConfigDB(ServiceHandle<StoreGateSvc> &store
bool TrigCostRun::ReadHLTResult::ReadEvent(ServiceHandle<StoreGateSvc> &storeGate,
const bool gotConfigSG,
ToolHandle<Trig::ITrigNtTool> &confTool) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "In ReadEvent" << endmsg;
if (doLevel == false) return false;
......@@ -606,12 +625,12 @@ bool TrigCostRun::ReadHLTResult::ReadEvent(ServiceHandle<StoreGateSvc> &storeGat
ScopeResumePauseTimer scopeTimer(timerNavig, false);
if(!storeGate->contains<TrigMonEventCollection>(keyEvent)) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "TrigMonEventCollection does not exist: " << keyEvent << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "TrigMonEventCollection does not exist: " << keyEvent << endmsg;
return false;
}
if(storeGate->retrieve(eventCol, keyEvent).isFailure() || !eventCol) {
log() << MSG::WARNING << "Failed to retrieve TrigMonEventCollection: " << keyEvent << endreq;
log() << MSG::WARNING << "Failed to retrieve TrigMonEventCollection: " << keyEvent << endmsg;
return false;
}
}
......@@ -621,12 +640,33 @@ bool TrigCostRun::ReadHLTResult::ReadEvent(ServiceHandle<StoreGateSvc> &storeGat
std::vector<std::string> &vars = globalConfig->getVarName();
std::vector<uint32_t> &vals = globalConfig->getVarId();
// If we did not get config data from the bytestream - fetch it for all the events we have in this carrier "event"
if (!gotConfigSG) {
std::set<uint32_t> lumiBlocks; // Only need one event per LB as a LB must have the same HLT config
std::set<const TrigMonEvent*> eventsToGetConfig; // Set of events we need to see if we have the config loaded for
for(TrigMonEventCollection::const_iterator it = eventCol->begin(); it != eventCol->end(); ++it) {
TrigMonEvent *ptr = *it;
if(!ptr) continue;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Check Conf for event " << ptr->getEvent() << " lumi " << ptr->getLumi() << "? -> ";
if (lumiBlocks.find(ptr->getLumi()) != lumiBlocks.end()) {
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "No already have an event from lumi " << ptr->getLumi() << endmsg;
continue;
}
eventsToGetConfig.insert(ptr);
lumiBlocks.insert(ptr->getLumi());
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Yes checking this event" << endmsg;
}
// Read in all the configs for these events
ReadConfigDB(storeGate, eventsToGetConfig, confTool);
}
// Second loop - read events
for(TrigMonEventCollection::const_iterator it = eventCol->begin(); it != eventCol->end(); ++it) {
TrigMonEvent *ptr = *it;
if(!ptr) continue;
// If we didn't export configs from the HLT itself, then check if we need to get the config for this event
if (!gotConfigSG) ReadConfigDB(storeGate, ptr, confTool);
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Extracting Cost Data for event " << ptr->getEvent() << endmsg;
// Add my HLT node
ptr->addWord(appId); //Backward compatability
......@@ -651,18 +691,18 @@ bool TrigCostRun::ReadHLTResult::ReadEvent(ServiceHandle<StoreGateSvc> &storeGat
for (unsigned i=0; i < ptr->getVarKey().size(); ++i) {
if (ptr->getVarKey().at(i) == Trig::kEventLumiBlockLength) {
_haveLumiLength = true;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Lumi length already stored in event" << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Lumi length already stored in event" << endmsg;
break;
}
}
if (_haveLumiLength == false) {
if (m_readLumiBlock.getTriedSetup() == false) {
log() << MSG::INFO << "Reading lumi length" << endreq;
log() << MSG::INFO << "Reading lumi length" << endmsg;
m_readLumiBlock.updateLumiBlocks( ptr->getRun() );
}
ptr->addVar(Trig::kEventLumiBlockLength, m_readLumiBlock.getLumiBlockLength(ptr->getLumi())); // 43 is lumi block length
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Decorating Event:" << ptr->getEvent() << " LB:"<< ptr->getLumi()<<" with LB Length " << m_readLumiBlock.getLumiBlockLength( ptr->getLumi()) << endreq;
if(outputLevel <= MSG::DEBUG) log() << MSG::DEBUG << "Decorating Event:" << ptr->getEvent() << " LB:"<< ptr->getLumi()<<" with LB Length " << m_readLumiBlock.getLumiBlockLength( ptr->getLumi()) << endmsg;
std::string _msg = m_readLumiBlock.infos();
if (_msg.size()) log() << MSG::INFO << _msg;
std::string _dbg = m_readLumiBlock.debug();
......@@ -695,10 +735,10 @@ void TrigCostRun::ReadHLTResult::PrintInit()
// Print summary counters
//
log() << MSG::INFO
<< " " << hltLevel << ": HLTResult key = " << keyResult << endreq
<< " " << hltLevel << ": TrigMonConfig key = " << keyConfig << endreq
<< " " << hltLevel << ": TrigMonEvent key = " << keyEvent << endreq
<< " " << hltLevel << ": Enabled = " << (doLevel ? "Yes" : "NO") << endreq;
<< " " << hltLevel << ": HLTResult key = " << keyResult << endmsg
<< " " << hltLevel << ": TrigMonConfig key = " << keyConfig << endmsg
<< " " << hltLevel << ": TrigMonEvent key = " << keyEvent << endmsg
<< " " << hltLevel << ": Enabled = " << (doLevel ? "Yes" : "NO") << endmsg;
}
//---------------------------------------------------------------------------------------
......@@ -711,7 +751,7 @@ void TrigCostRun::ReadHLTResult::PrintEvent()
// Print current events in memory
//
log() << MSG::INFO << "Extracted TrigMonEventCollection: " << keyEvent
<< " with: " << vecEvent.size() << " event(s)" << endreq;
<< " with: " << vecEvent.size() << " event(s)" << endmsg;
static unsigned _nPrinted = 0;
for(unsigned i = 0; i < vecEvent.size(); ++i) {
......@@ -733,10 +773,10 @@ void TrigCostRun::ReadHLTResult::PrintSummary()
// Print summary counters
//
log() << MSG::INFO
<< " " << hltLevel << ": POST_HLT: # of valid HLT results = " << countValid << endreq
<< " " << hltLevel << ": POST_HLT: # of invalid HLT results = " << countInvalid << endreq
<< " " << hltLevel << ": POST_HLT: # of truncated HLT results = " << countTrunc << endreq
<< " " << hltLevel << ": POST_HLT: # of read TrigMonEvent = " << countEvent << endreq
<< " " << hltLevel << ": POST_HLT: # of read TrigMonCostEvent = " << countCostEvent << "(In which scale tools were run)" << endreq
<< " " << hltLevel << ": POST_HLT: # of read TrigMonConfig = " << countConfig << endreq;
<< " " << hltLevel << ": POST_HLT: # of valid HLT results = " << countValid << endmsg
<< " " << hltLevel << ": POST_HLT: # of invalid HLT results = " << countInvalid << endmsg
<< " " << hltLevel << ": POST_HLT: # of truncated HLT results = " << countTrunc << endmsg
<< " " << hltLevel << ": POST_HLT: # of read TrigMonEvent = " << countEvent << endmsg
<< " " << hltLevel << ": POST_HLT: # of read TrigMonCostEvent = " << countCostEvent << "(In which scale tools were run)" << endmsg
<< " " << hltLevel << ": POST_HLT: # of read TrigMonConfig = " << countConfig << endmsg;
}
......@@ -444,12 +444,11 @@ bool Trig::TrigNtConfTool::ReadFromDB(TrigMonConfig &confg, unsigned run, unsign
{
// Do we need to update? (note that if we do, this also sets m_currentKey)
if (GetKeysChangedFromDB(run, lumi) == false) {
return false; // Nothing to do
}
const bool getChanged = GetKeysChangedFromDB(run, lumi);
confg.setTriggerKeys(m_currentKey.getSMK(), m_currentKey.getLV1_PS(), m_currentKey.getHLT_PS());
if (getChanged == false) return false; // Nothing to do
std::stringstream _ss1, _ss2, _ss3;
_ss1 << m_currentKey.getSMK();
_ss1 >> m_triggerMenuSetup;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment