Commit 33b7c074 authored by Frank Winklmeier's avatar Frank Winklmeier Committed by Graeme Stewart
Browse files

Fix for COOL3 (HLTRates2COOL-00-01-03)

parent 8a6758fd
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef HLTRATES2COOL_HLTCOOLFOLDERSPEC
#define HLTRATES2COOL_HLTCOOLFOLDERSPEC
#include "HLTRates2COOL/HLTCounter.h"
#include <iostream>
#include "CoolKernel/DatabaseId.h"
#include "CoolKernel/Exception.h"
#include "CoolKernel/IDatabaseSvc.h"
#include "CoolKernel/IDatabase.h"
#include "CoolKernel/Record.h"
#include "CoolKernel/RecordSpecification.h"
/**@brief Definition of the COOL folder structure for the trigger configuration data*/
namespace hltca {
class HLTCoolFolderSpec
{
public:
/**@brief creates the folder structure in the COOL database
*
* @param db COOL database
*
* @returns pointer to the folder structure
*/
static cool::IFolderSetPtr createFolderStructure(cool::IDatabasePtr db);
/**@brief prints the folder structure that is in the COOL database
*
* @param db COOL database
*
* @param o output stream
*
* @returns pointer to the folder
*/
static void printFolderStructure(cool::IDatabasePtr db, std::ostream & o);
/**@brief get a handle to the HLT Rates folder in the COOL db
*
* @param db COOL database
*
* @returns pointer to the folder
*/
// static cool::IFolderPtr getHLTRatesFolder(cool::IDatabasePtr db);
static cool::IFolderPtr getL2CountersFolder(cool::IDatabasePtr db);
static cool::IFolderPtr getEFCountersFolder(cool::IDatabasePtr db);
static cool::Record createHLTCountersPayload(unsigned char format, const std::vector<hltca::HLTCounter>& counters, hltca::HLTCounter::TriggerLevel level);
static void readHLTCountersPayload(const cool::IRecord & payload, std::vector<hltca::HLTCounter>& counters, hltca::HLTCounter::TriggerLevel level);
private:
/**@brief default constructor*/
HLTCoolFolderSpec(){};
/**@brief copy constructor*/
HLTCoolFolderSpec(const HLTCoolFolderSpec &) {};
static cool::RecordSpecification getHLTCountersFolderSpecification();
static void pack(unsigned char format, const std::vector<hltca::HLTCounter>& counters, cool::Blob64k& blob, hltca::HLTCounter::TriggerLevel level);
static void unpack(unsigned char format, const cool::Blob64k& blob, std::vector<hltca::HLTCounter>& counters, hltca::HLTCounter::TriggerLevel level);
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// -*-c++-*-
#ifndef HLTRATES2COOL_HLTTOCOOLWRITER
#define HLTRATES2COOL_HLTTOCOOLWRITER
#include "HLTRates2COOL/HLTCounter.h"
#include "CoolKernel/DatabaseId.h"
#include "CoolKernel/Exception.h"
#include "CoolKernel/IDatabaseSvc.h"
#include "CoolKernel/IDatabase.h"
#include <string>
#include <iostream>
namespace hltca {
class HLTCountCoolWriter {
public:
/**@brief constructor
*
* @param dbId database connection string
*
* @param o output stream for all messages (defaults to cout)
*/
HLTCountCoolWriter(const std::string& dbId, std::ostream & o = std::cout) :
m_dbId(cool::DatabaseId(dbId)),
m_ostream(o)
{};
/**@brief destructor*/
~HLTCountCoolWriter(){};
/**@brief Create a new schema in the COOL database*/
void createSchema(bool print=false);
/**@brief Prints the schema in the COOL database
*
* @param o output stream
*/
void printSchema();
/**@brief Enables the buffered writing of the counter folders*/
void setupStorageBuffers();
/**@brief Enables the buffered writing of the counter folders*/
void flushStorageBuffers();
void writeHLTCountersPayload(unsigned int runNumber,
unsigned int lumiblockNumber,
const std::vector<HLTCounter>& counters,
HLTCounter::TriggerLevel level = HLTCounter::BOTH);
void writeHLTCountersPayload( cool::ValidityKey since,
cool::ValidityKey until,
const std::vector<HLTCounter>& counters,
HLTCounter::TriggerLevel level = HLTCounter::BOTH);
bool readHLTCountersPayload(unsigned int runNumber,
unsigned int lumiblockNumber,
std::vector< HLTCounter>& counters,
HLTCounter::TriggerLevel level);
/**@brief open COOL db connection
* @param readOnly if @c true the db is opened in readonly mode
*/
cool::IDatabasePtr openDb( bool readOnly = true );
/**@brief check if db is open
*/
bool dbIsOpen();
/**@brief delete the COOL database*/
void dropDb();
/**@brief close the COOL database*/
//void closeDb(cool::IDatabasePtr& db);
void closeDb(); // to be used
private:
/**@brief get COOL db service
*/
cool::IDatabaseSvc& databaseService();
/**@brief create a new COOL database*/
cool::IDatabasePtr createDb();
/**@brief create a new COOL database with prior deletion of the old one*/
cool::IDatabasePtr recreateDb();
// data members
// DB connection string: oracle://<server>;schema=<acc_name>;dbname=<db_name>;user=<acc_name>;password=<pwd>
cool::DatabaseId m_dbId; //< db connection string
cool::IDatabasePtr m_dbPtr; //< COOL database pointer
std::ostream & m_ostream; //< output stream for all messages
void rangeInfo(const std::string& content, cool::ValidityKey since, cool::ValidityKey until);
/**@brief Create a new schema in the COOL database with prior deletion of the old one*/
void recreateSchema(){};
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// Dear emacs, this is -*-c++-*-
#ifndef hltca_HLTCountOHReceiver
#define hltca_HLTCountOHReceiver
#include "HLTRates2COOL/HLTCounter.h"
#include <iostream>
#include <vector>
#include <owl/regexp.h>
// OH include files
#include <oh/OHRootReceiver.h>
#include <oh/OHSubscriber.h>
#include "TH2.h"
ERS_DECLARE_ISSUE( hltca,
HLTCountReceivingIssue,
"HLTCountOHReceiver: " << explanation,
((const char*) explanation)
)
namespace hltca {
class HLTCountOHReceiver : public OHRootReceiver {
public:
HLTCountOHReceiver();
using OHRootReceiver::receive;
void receive( OHRootHistogram & h);
void receive( std::vector<OHRootHistogram*> & )
{
std::cout << "receive( std::vector<OHRootHistogram*> & ) notification has been received" << std::endl;
}
int last_LB() const;
const std::vector<hltca::HLTCounter>& hltCounters(int lumiblock, hltca::HLTCounter::TriggerLevel level);
void ClearStorage();
private:
struct Content {
Content(): h(0), valid(true), filled(false), sum(0) {}
~Content() {delete h;}
TH2I * h;
std::vector<HLTCounter> counters;
bool valid; // true: content of h agrees with content of counters
bool filled; // true after the first histogram for is received
int sum;
};
void updateInternalStore(const OHRootHistogram & h);
void CopyHistContent(const TH2& src, TH2& dest);
void SetChainCounterBins(TAxis *axis, int level);
void updateHLTCounters(Content& c, HLTCounter::TriggerLevel level);
std::vector<Content> fCountStore[2]; // one store for each level
std::vector<int> fChainCounters[2]; // bin index for chain_counter
}; //end class HLTCountOHReceiver
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// -*-c++-*-
#ifndef HLTRATES2COOL_HLTCOUNTER
#define HLTRATES2COOL_HLTCOUNTER
#include <string>
#include <iostream>
namespace hltca {
class HLTCounter;
}
class TAxis;
class TH2;
namespace hltca {
std::ostream & operator<<(std::ostream &, const HLTCounter &);
class HLTCounter
{
public:
enum TriggerLevel { UNKNOWN=0, BOTH=1, L2=2, EF=3 };
HLTCounter( unsigned int chainCounter,
unsigned int input,
unsigned int afterPrescale,
unsigned int raw,
unsigned int total,
TriggerLevel lvl):
m_chainCounter(chainCounter),
m_input(input),
m_afterPS(afterPrescale),
m_raw(raw),
m_total(total),
m_lvl(lvl)
{};
HLTCounter( unsigned int chainCounter,
TriggerLevel lvl):
m_chainCounter(chainCounter),
m_input(0),
m_afterPS(0),
m_raw(0),
m_total(0),
m_lvl(lvl)
{};
unsigned int input() const { return m_input; }
unsigned int chain_counter() const { return m_chainCounter; }
unsigned int after_prescale() const { return m_afterPS; }
unsigned int raw() const { return m_raw; }
unsigned int total() const { return m_total; }
TriggerLevel trlevel() const { return m_lvl; }
std::string level() const {
switch (m_lvl) {
case L2: return "L2"; break;
case EF: return "EF"; break;
case BOTH: return "BOTH"; break;
case UNKNOWN: return "UNKNOWN"; break;
}
return "";
}
void setContent(const TH2* h, int binx);
static bool hasBinsSet();
static bool setBins(TAxis * axis);
private:
unsigned int m_chainCounter;
unsigned int m_input;
unsigned int m_afterPS;
unsigned int m_raw;
unsigned int m_total;
TriggerLevel m_lvl;
static int g_inputbin;
static int g_afterPSbin;
static int g_rawbin;
static int g_totalbin;
friend std::ostream & operator<<(std::ostream &, const HLTCounter &);
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* @file HLTCountsArchiverRCApp.h
* @author Joerg Stelzer
* $Author: stelzer $
* $Revision: 1.1 $
* $Date: 2010-02-05 $
*
* @brief the class for writing HLT trigger counts to COOL online
*/
#ifndef hltca_HLTCountsArchiverRCApp
#define hltca_HLTCountsArchiverRCApp
#include <string>
#include "HLTRates2COOL/JobConfig.h"
#include "RunControl/Common/Controllable.h"
#include "ipc/core.h"
namespace hltca {
class HLTCountsArchiverRCApp;
class HLTCountCoolWriter;
class HLTCountOHReceiver;
class JobConfig;
}
class IPCPartition;
class OHSubscriber;
class hltca::HLTCountsArchiverRCApp : public daq::rc::Controllable {
public:
/**
* Constructor. Only the parameter name is required (this is the named published in IPC.)
*/
HLTCountsArchiverRCApp(JobConfig& conf, IPCPartition* part, hltca::HLTCountOHReceiver * rec);
virtual ~HLTCountsArchiverRCApp() noexcept;
virtual void prepareForRun(const daq::rc::TransitionCmd&);
virtual void stopArchiving(const daq::rc::TransitionCmd&);
hltca::JobConfig& conf() { return fJobConfig; }
private:
void writeToCool(); // writes the objects held by the receiver to cool
bool getRunNumberFromIS();
hltca::JobConfig fJobConfig; // object to hold different job configuration parameters
hltca::HLTCountCoolWriter* fCoolWriter; // the class that does the writing to COOL
IPCPartition* fIPCPartition; // the ipc partition object
hltca::HLTCountOHReceiver* fReceiver;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef hltca_JobConfig
#define hltca_JobConfig
#include <iostream>
namespace hltca {
class JobConfig;
std::ostream& operator<<( std::ostream& os, const JobConfig& event );
class JobConfig {
friend std::ostream& operator<<( std::ostream& os, const JobConfig& event );
public:
JobConfig();
~JobConfig();
std::string& PartitionName() { return fPartitionName; }
std::string& CoolDb() { return fCoolDb; }
std::string& ISServer() { return fISServer; }
std::string& Provider(const std::string& lvl) { return fProvider[lvl=="L2"?0:1]; }
std::string& Histogram(const std::string& lvl) { return fHistogram[lvl=="L2"?0:1]; }
uint32_t& CurrentRunNumber() { return fCurrentRunNumber; }
bool& COOLconnStat() { return fCOOLconnStat; }
private:
std::string fPartitionName;
std::string fCoolDb;
std::string fISServer;
std::string fProvider[2];
std::string fHistogram[2];
uint32_t fCurrentRunNumber;
bool fCOOLconnStat;
};
}
#endif
# $Revision: 1.7 $
package HLTRates2COOL
author Joerg Stelzer stelzer@cern.ch
#use OnlinePolicy # This one doesn't produce the executables in the install area.
use AtlasPolicy AtlasPolicy-*
use AtlasROOT AtlasROOT-* External
use AtlasCOOL AtlasCOOL-* External
use HLTtdaq HLTtdaq-* HLT/HLTExternal
private
use AtlasBoost AtlasBoost-* External
use AtlasCORAL AtlasCORAL-* External
# Remove to avoid compiler warning
macro_remove_regexp AtlasCxxPolicy_pp_cppflags "'-DPACKAGE_VERSION=.*'"
macro LcgLibs " -llcg_CoolApplication "
library HLTRates2COOL *.cxx
apply_pattern installed_library
apply_tag NEEDS_CORAL_BASE
apply_tag NEEDS_COOL_FACTORY
application HLTCountsArchiver test/HLTCountsArchiver.cxx
macro HLTCountsArchiver_dependencies HLTRates2COOL
macro HLTCountsArchiver_cppflags " $(LcgIncludes) "
macro HLTCountsArchiverlinkopts " $(LcgLibs) -lrc_CmdLine -lrc_ItemCtrl -lohroot -lers -lcmdline -lHLTRates2COOL $(Boost_linkopts_program_options) "
application testHLTtoCOOL test/testHLTtoCOOL.cxx
macro testHLTtoCOOL_dependencies HLTRates2COOL
macro testHLTtoCOOL_cppflags " $(LcgIncludes) "
macro testHLTtoCOOLlinkopts " $(LcgLibs) -lohroot -lers -lcmdline -lHLTRates2COOL "
application HLTRatesFromCOOL test/HLTRatesFromCOOL.cxx
macro HLTRatesFromCOOL_dependencies HLTRates2COOL
macro HLTRatesFromCOOL_cppflags " $(LcgIncludes) "
macro HLTRatesFromCOOLlinkopts " $(LcgLibs) -lohroot -lers -lcmdline -lHLTRates2COOL $(Boost_linkopts_program_options) "
# until checkreq is fixed to translate RunControl to HLTtdaq
#action checkreq "checkreq.py -i 3 -n"
# disable it completely
action checkreq "true"
## How to source tdaq-02-00-03
source /afs/cern.ch/atlas/project/tdaq/cmt/bin/cmtsetup.sh tdaq-02-00-03 i686-slc4-gcc34-opt
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_53f/InstallArea/i686-slc4-gcc34-opt/lib
export LD_LIBRARY_PATH=/afs/cern.ch/atlas/software/builds/AtlasTrigger/15.5.3/InstallArea/i686-slc4-gcc34-opt/lib:$LD_LIBRARY_PATH
#Set the TDAQ partition name:
export TDAQ_PARTITION=DQMD
#Set the configuration file:
export TDAQ_DB_DATA=/afs/cern.ch/atlas/project/tdaq/cmt/tdaq-02-00-02/installed/share/data/dqmf/examples/DQM_test_partition.data.xml
#Start DQM partition:
setup_daq $TDAQ_PARTITION
## need additional file project.cmt -why??
cd users/risler
mkdir cmt
echo "use tdaq-02-00-03" > cmt/project.cmt
## compile ...
cd HLTtoCOOL/cmt
cmt config
. ./setup.sh
gmake
## testHLTtoCOOl
## writeHLTtoCOOL
source code writeHLTtoCOOl.cxx and MyReceiver.cxx
## publish_test_histo
source code publish_test_histo2.cpp
read histos from debughist.root and publish them to OH, for different lumi blocks
start infrastructure:
ipc_server &
ipc_server -p MyTestPartition &
is_server -p MyTestPartition -n MyTest2 &
is_server -p MyTestPartition -n Histogramming &
is_server -p MyTestPartition -n LumiBlock &
publish histos :
../i686-slc4-gcc34-dbg/publish_test_histo -L EF -d 2
## receive_test_histo
source code receive_test_histo.cpp
receive the published histos :
../i686-slc4-gcc34-dbg/receive_test_histo -p MyTestPartition -s Histogramming
## publish_test_data
source code publish_test_data.cpp
publish L1 info IS_LB with increased counters TBP, TAP, TAV and turns for different lumi Blocks on server MyTest
is_server -p MyTestPartition -n MyTest &
## publish_test_runnr
source code publish_test_runnr.cpp
publish CTP info LB_CTP_<runnr>_<LBnr> (containing only 1 attribute, runnumber)
## receive_test_runnr
source code receive_test_runnr2.cpp
receive LB_CTP.* info and retreive the runnumber
## receive_test_keys
source code receive_test_keys.cpp