|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef ManagedMonitorToolBase_CXX
6 #define ManagedMonitorToolBase_CXX
20 #include "TEfficiency.h"
24 #include "Gaudi/Interfaces/IOptionsSvc.h"
25 #include "GaudiKernel/IHistogramSvc.h"
26 #include "GaudiKernel/IMessageSvc.h"
27 #include "GaudiKernel/ISvcLocator.h"
28 #include "GaudiKernel/MsgStream.h"
32 #include "GaudiKernel/ITHistSvc.h"
88 m_bench_book.finishMeasurement();
89 m_bench_total += m_bench_book;
90 m_benchNFillAfterbook = 0;
99 m_bench_tmp.startMeasurement();
105 if (!m_doResourceMon)
107 m_bench_tmp.finishMeasurement();
108 m_bench_total += m_bench_tmp;
109 ++m_benchNFillAfterbook;
110 if (m_benchNFillAfterbook==1) {
111 m_bench_fillfirst = m_bench_tmp;
113 m_bench_fillall += m_bench_tmp;
114 m_bench_filllast = m_bench_tmp;
121 if (!m_doResourceMon)
123 m_bench_proc.startMeasurement();
129 if (!m_doResourceMon)
131 m_bench_proc.finishMeasurement();
132 m_bench_total += m_bench_proc;
133 m_bench_fillall -= m_bench_filllast;
134 m_benchNFillAfterbook = 0;
142 if (!m_doResourceMon)
144 m_benchNFillAfterbook = 0;
146 m_bench_book.reset();
147 m_bench_fillfirst.reset();
148 m_bench_fillall.reset();
149 m_bench_filllast.reset();
150 m_bench_proc.reset();
151 m_bench_total.reset();
158 if (!m_doResourceMon)
166 m_bench_total.setUnitCount();
179 std::string strToLower(
const std::string&
str );
183 static std::atomic<unsigned> s_mmtb_mongroup_ncopies=0;
195 std::string hName(
h->GetName() );
196 HistMap_t::value_type valToInsert( hName,
h );
197 m_map.insert( valToInsert );
198 return m_tool->regHist(
h, *
this );
201 return StatusCode::FAILURE;
206 getHist( TH1*&
h,
const std::string& hName )
209 return m_tool->getHist(
h, hName, *
this );
212 return StatusCode::FAILURE;
218 getHist( TH2*&
h,
const std::string& hName )
221 return m_tool->getHist(
h, hName, *
this );
224 return StatusCode::FAILURE;
230 return m_tool->regEfficiency(
e, *
this );
232 return StatusCode::FAILURE;
241 return m_tool->regGraph(
g, *
this );
244 return StatusCode::FAILURE;
253 return m_tool->regTree(
t, *
this );
256 return StatusCode::FAILURE;
265 std::string hName(
h->GetName() );
266 m_map.erase( hName );
267 return m_tool->writeAndDelete(
h, *
this );
270 return StatusCode::FAILURE;
279 std::string hName(
h->GetName() );
280 m_map.erase( hName );
281 return m_tool->deregHist(
h );
284 return StatusCode::FAILURE;
293 return m_tool->deregGraph(
g );
296 return StatusCode::FAILURE;
305 return m_tool->deregObject( objName, *
this );
308 return StatusCode::FAILURE;
317 bool isSuccess(
true);
320 typedef HistMap_t::const_iterator MapIter_t;
321 MapIter_t mapEnd = m_map.end();
322 for( MapIter_t
i = m_map.begin();
i != mapEnd; ++
i ) {
323 sc = m_tool->deregHist(
i->second );
324 if( !
sc.isSuccess() )
331 return StatusCode::SUCCESS;
334 return StatusCode::FAILURE;
340 const IInterface*
parent )
373 declareInterface<IMonitorToolBase>(
this);
409 newLowStatInterval =
false;
410 newMedStatInterval =
false;
411 newHigStatInterval =
false;
413 newLumiBlock =
false;
415 newEventsBlock =
false;
416 endOfEventsBlock =
false;
417 endOfLowStat =
false;
418 endOfLumiBlock =
false;
455 msg(MSG::ERROR) <<
"!! streamNameFunction() has not been initialized !!" <<
endmsg;
456 msg(MSG::ERROR) <<
" --> neither ManagedMonitorToolBase::initialize() nor" <<
endmsg;
457 msg(MSG::ERROR) <<
" --> ManagedMonitorToolBase::setMonManager() has been called." <<
endmsg;
458 msg(MSG::ERROR) <<
" --> Correct configuration cannot be guaranteed from this point." <<
endmsg;
539 std::string
str(
"file");
581 std::string lcstr( strToLower(
str) );
585 else if( lcstr ==
"fill" )
587 else if( lcstr ==
"run" )
589 else if( lcstr ==
"lowStat" )
591 else if( lcstr ==
"medStat" )
593 else if( lcstr ==
"higStat" )
595 else if( lcstr ==
"lumiBlock" )
597 else if( lcstr ==
"eventsBlock" )
599 else if( lcstr ==
"file" )
605 MsgStream
log(
ms,
"ManagedMonitorToolBase::intervalStringToEnum()" );
606 log << MSG::WARNING <<
"Unknown ManagedMonitorToolBase::Interval_t \""
607 <<
str <<
"\", returning \"file\"" <<
endmsg;
622 if( !
sc.isSuccess() )
623 return StatusCode::FAILURE;
630 if( !
sc.isSuccess() ) {
631 msg(MSG::ERROR) <<
"!! Unable to locate the THistSvc service !!" <<
endmsg;
638 if( !
sc.isSuccess() ) {
639 msg(MSG::ERROR) <<
"!! Unable to retrieve the TrigDecisionTool !!" <<
endmsg;
646 if ( !
sc.isSuccess() ) {
655 if(!
sc.isSuccess()) {
656 msg(MSG::WARNING) <<
"Error parsing the trigger chain list, using empty list" <<
endmsg;
669 if(!
sc.isSuccess()) {
670 msg(MSG::WARNING) <<
"Error parsing the trigger group names list, using empty list" <<
endmsg;
686 if( !
sc.isSuccess() ) {
698 auto getProp = [
this,joSvc](std::string&
var,
const std::string&
name) {
699 if (joSvc->has(
name))
725 return StatusCode::SUCCESS;
735 return StatusCode::SUCCESS;
746 msg(MSG::WARNING) <<
"ManagedMonitorToolBase::initialize() never called from reimplementation!" <<
endmsg;
757 newLumiBlock =
false;
763 newLowStatInterval =
false;
764 newMedStatInterval =
false;
765 newHigStatInterval =
false;
778 isNewEventsBlock =
true;
793 if( LBsLowStat*LBsMedStat*LBsHigStat == 0) {
794 msg(MSG::WARNING) <<
"zero LBs requested for interval" <<
endmsg;
846 std::vector<Interval_t> intervals_to_process;
851 for (
const auto interval: intervals_to_process) {
863 it.m_templateHist->LabelsInflate(
"X");
870 TH1* passedHist =
it.m_templateHist->GetCopyPassedHisto();
871 TH1* totalHist =
it.m_templateHist->GetCopyTotalHisto();
874 passedHist->LabelsInflate(
"X");
875 totalHist->LabelsInflate(
"X");
880 it.m_templateHist->SetPassedHistogram(*passedHist,
"f");
881 it.m_templateHist->SetTotalHistogram(*totalHist,
" ");
889 streamname->updateRunLB();
899 bool filterresult(
true);
902 for (; filterresult && (ifilter != filterend);
904 filterresult = (filterresult && (*ifilter)->accept());
934 if( LBsLowStat*LBsMedStat*LBsHigStat > 0) {
942 return StatusCode::SUCCESS;
952 size_t found=mdStreamName.rfind(
'/');
954 if (
found != std::string::npos )
955 mdStreamName.replace(
found, mdStreamName.length(),
"/metadata" );
959 metadata =
new TTree(
"metadata",
"Monitoring Metadata" );
960 if (!
metadata)
return StatusCode::FAILURE;
962 if (scmd == StatusCode::FAILURE)
return StatusCode::FAILURE;
969 return StatusCode::SUCCESS;
994 TH1* theHist = (*it).m_templateHist;
997 TH1*
h =
static_cast<TH1*
>(theHist->Clone());
1001 std::string hName =
h->GetName();
1008 if (sc1 == StatusCode::FAILURE) allIsOk =
false;
1012 if (sc2 == StatusCode::FAILURE) allIsOk =
false;
1024 if (
smd != StatusCode::SUCCESS) allIsOk =
false;
1028 if (sc3 == StatusCode::FAILURE) allIsOk =
false;
1032 if (!allIsOk)
return StatusCode::FAILURE;
1034 return StatusCode::SUCCESS;
1051 bool graphRemoved =
false;
1054 TDirectory*
dir =
file->GetDirectory(directoryName.c_str());
1057 TObject*
obj =
dir->Remove(theGraph);
1059 graphRemoved =
true;
1062 if (!graphRemoved) {
1063 return StatusCode::FAILURE;
1066 return StatusCode::SUCCESS;
1074 bool allIsOk =
true;
1080 TGraph* theGraph = (*it).m_templateHist;
1083 TGraph*
g =
static_cast<TGraph*
>(theGraph->Clone());
1087 std::string gName =
g->GetName();
1094 if (sc1 == StatusCode::FAILURE)
1099 bool doneCleaning =
false;
1101 TSeqCollection *
filelist=gROOT->GetListOfFiles();
1106 if (sc2 == StatusCode::SUCCESS)
1107 doneCleaning =
true;
1111 if (!doneCleaning) {
1112 ATH_MSG_ERROR(
"THistSvc_deReg_fixTGraph: failed to apply TGraph fix for the THist Svc!");
1119 if (sc3 == StatusCode::FAILURE)
1126 if (
smd != StatusCode::SUCCESS)
1131 if (sc4 == StatusCode::FAILURE)
1136 if (!allIsOk)
return StatusCode::FAILURE;
1138 return StatusCode::SUCCESS;
1142 bool allIsOk =
true;
1143 for(
auto&
it : templateEfficiencies ) {
1146 TEfficiency* theEfficiency =
it.m_templateHist;
1147 TEfficiency*
e =
static_cast<TEfficiency*
>(theEfficiency->Clone());
1148 int nbins = theEfficiency->GetTotalHistogram()->GetNbinsX();
1149 int xlow = theEfficiency->GetTotalHistogram()->GetXaxis()->GetXmin();
1150 int xhigh = theEfficiency->GetTotalHistogram()->GetXaxis()->GetXmax();
1151 e->SetBins(
nbins,xlow,xhigh);
1152 std::string
name =
e->GetName();
1155 TGraph* theGraph =
reinterpret_cast<TGraph*
>(theEfficiency);
1156 TGraph*
g =
reinterpret_cast<TGraph*
>(
e);
1164 if (sc1 == StatusCode::FAILURE) allIsOk =
false;
1166 bool doneCleaning =
false;
1168 TSeqCollection *
filelist=gROOT->GetListOfFiles();
1173 if (sc2 == StatusCode::SUCCESS) doneCleaning =
true;
1176 if (!doneCleaning) {
1177 ATH_MSG_ERROR(
"THistSvc_deReg_fixTGraph: failed to apply TGraph fix for the THist Svc!");
1182 if (sc3 == StatusCode::FAILURE)
1189 if (
smd != StatusCode::SUCCESS) allIsOk =
false;
1192 if (sc4 == StatusCode::FAILURE) allIsOk =
false;
1195 if (!allIsOk)
return StatusCode::FAILURE;
1196 return StatusCode::SUCCESS;
1205 bool allIsOk =
true;
1211 TTree* theTree = (*it).m_templateHist;
1214 TTree*
t =
static_cast<TTree*
>(theTree->Clone());
1218 std::string
name =
t->GetName();
1225 if (sc1 == StatusCode::FAILURE) allIsOk =
false;
1229 if (sc2 == StatusCode::FAILURE) allIsOk =
false;
1241 if (
smd != StatusCode::SUCCESS) allIsOk =
false;
1245 if (sc3 == StatusCode::FAILURE) allIsOk =
false;
1249 if (!allIsOk)
return StatusCode::FAILURE;
1251 return StatusCode::SUCCESS;
1271 endOfEventsBlock =
true;
1272 endOfLowStat =
true;
1273 endOfLumiBlock =
true;
1281 return StatusCode::SUCCESS;
1293 return StatusCode::SUCCESS;
1302 return StatusCode::SUCCESS;
1309 return StatusCode::SUCCESS;
1322 return StatusCode::SUCCESS;
1346 regHist( TH1*
h,
const std::string& system,
1360 return StatusCode::FAILURE;
1373 ATH_MSG_WARNING(
"HEY! You're attempting to register " <<
h->GetName() <<
" as a per-LB histogram, but you're not setting the merge algorithm! This is a SUPER-BAD idea! Use \"merge\", at least.");
1380 return StatusCode::FAILURE;
1383 std::string hName =
h->GetName();
1391 std::string hName =
h->GetName();
1402 if (
smd != StatusCode::SUCCESS)
return StatusCode::FAILURE;
1410 getHist( TH1*&
h,
const std::string& hName,
const std::string& system,
1429 getHist( TH2*&
h,
const std::string& hName,
const std::string& system,
1448 return StatusCode::FAILURE;
1450 TGraph*
g =
reinterpret_cast<TGraph*
>(
e);
1451 std::string
name =
e->GetName();
1457 ATH_MSG_WARNING(
"HEY! Attempting to register "<<
name<<
" as a per-LB histogram, but not setting the merge algorithm! Use \"merge\", at least.");
1464 return StatusCode::FAILURE;
1481 if (
smd != StatusCode::SUCCESS)
1482 return StatusCode::FAILURE;
1491 regGraph( TGraph*
g,
const std::string& system,
1504 return StatusCode::FAILURE;
1517 return StatusCode::FAILURE;
1520 std::string
name =
g->GetName();
1528 std::string gName =
g->GetName();
1539 if (
smd != StatusCode::SUCCESS)
return StatusCode::FAILURE;
1547 regTree( TTree*
t,
const std::string& system,
1571 return StatusCode::FAILURE;
1574 std::string
name =
t->GetName();
1583 std::string tName =
t->GetName();
1594 if (
smd != StatusCode::SUCCESS)
return StatusCode::FAILURE;
1604 return StatusCode::FAILURE;
1606 std::string hName =
h->GetName();
1612 return StatusCode::SUCCESS;
1634 deregObject(
const std::string& objName,
const std::string& system,
1658 return StatusCode::SUCCESS;
1666 return StatusCode::SUCCESS;
1676 return StatusCode::SUCCESS;
1698 return lumi->lbAverageInteractionsPerCrossing();
1701 ATH_MSG_DEBUG(
"Warning: lbAverageInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1714 float muToLumi =
lumi->muToLumi();
1716 return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()) / muToLumi;
1721 ATH_MSG_DEBUG(
"Warning: lbInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1734 return lumi->lbAverageLuminosity();
1737 ATH_MSG_DEBUG(
"Warning: lbAverageLuminosity() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1750 return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id());
1753 ATH_MSG_DEBUG(
"Warning: lbLuminosityPerBCID() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1773 ATH_MSG_DEBUG(
"Warning: lbAverageLivefraction() - luminosity not availble (i.e. EnableLumi = False)");
1792 ATH_MSG_DEBUG(
"Warning: livefractionPerBCID() - luminosity retrieved available (i.e. EnableLumi = False)");
1807 ATH_MSG_DEBUG(
"Warning: lbLumiWeight() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1827 ATH_MSG_DEBUG(
"Warning: lbDuration() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1840 : m_charArrSize(100)
1864 delete [] m_mergeData;
1865 delete [] m_triggerData;
1866 delete [] m_intervalData;
1868 delete [] m_nameData;
1877 std::string trigger,
1884 if( trigger.empty() )
1887 merge =
"<default>";
1889 copyString( m_nameData,
name );
1892 copyString( m_triggerData, trigger );
1893 copyString( m_mergeData,
merge );
1903 const char*
f = from.c_str();
1904 while( (++
i < m_charArrSize) && ((*
to++ = *
f++) != 0) ) {};
1905 if(
i == m_charArrSize ) {
1928 std::string
root, rem;
1932 rem.erase(rem.rfind(
'/'), rem.length());
1951 return getStreamName(
tool,
group, objName, usePreviousInterval);
1973 return getStreamName(
tool,
group, objName, usePreviousInterval);
1992 bool isTemp =
false;
1994 bool useRunFolders =
group.interval() !=
all;
1996 bool useLBFolders = ( useRunFolders )
1999 bool useLowStatInterval = ( useRunFolders )
2002 bool useMedStatInterval = ( useRunFolders )
2005 bool useHigStatInterval = ( useRunFolders )
2014 if( useRunFolders ) {
2016 streamName <<
"run_" << m_prev_run_number <<
"/";
2022 if( useLBFolders ) {
2024 streamName <<
"lb_" << m_prev_lumi_block <<
"/";
2028 else if( useLowStatInterval ) {
2036 else if( useMedStatInterval ) {
2041 else if( useHigStatInterval ) {
2046 else if( useEBFolders ) {
2051 long eventsBlockNumber = 1;
2052 long procNEventsProp =
tool->get_procNEventsProp();
2054 if (procNEventsProp > 0) {
2055 eventsBlockNumber = (long)
nEvents / procNEventsProp;
2056 if ((
nEvents % procNEventsProp) != 0)
2057 eventsBlockNumber++;
2061 if (usePreviousInterval) {
2062 eventsBlockNumber--;
2065 streamName <<
"eb_" << eventsBlockNumber <<
"/";
2078 std::string
root, rem;
2082 rem.erase(rem.rfind(
'/'), rem.length());
2097 ATH_MSG_DEBUG(
"ManagedMonitorToolBase::trigChainsArePassed:");
2099 for(
unsigned int i=0;
i<vTrigNames.size();
i++) {
2101 ATH_MSG_DEBUG(
" + \"" << vTrigNames[
i] <<
"\" passed, returning \'true\'");
2116 std::stringstream
ss(
line);
2120 while ( std::getline(
ss,
item,
',') ) {
2121 std::stringstream iss(
item);
2128 return StatusCode::SUCCESS;
2134 for (
size_t i = 0;
i < vTrigChainNames.size(); ++
i) {
2135 std::string& thisName = vTrigChainNames[
i];
2136 if (thisName.compare(0, 9,
"CATEGORY_") ==0) {
2137 ATH_MSG_DEBUG(
"Found a trigger category: " << thisName <<
". We will unpack it.");
2139 std::ostringstream oss;
2141 for (
size_t itrig = 0; itrig <
triggers.size(); ++itrig) {
2149 std::string newval = oss.str();
2151 vTrigChainNames[
i] = newval;
2189 if (
pos == std::string::npos) {
2226 std::string strToLower(
const std::string&
str )
2228 std::string lstr(
str);
2229 std::string::const_iterator from =
str.begin();
2230 std::string::const_iterator strend =
str.end();
2232 while( from != strend ) {
2240 std::string strToUpper(
const std::string&
str )
2242 std::string ustr(
str);
2243 std::string::const_iterator from =
str.begin();
2244 std::string::const_iterator strend =
str.end();
2246 while( from != strend ) {
2247 *
to++ = toupper(*from++);
JetConstituentVector::iterator iterator
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
static unsigned int runNumber()
virtual std::string fileKey() const
virtual void passOwnership(TObject *h, const std::string &key)
Pass ownership of a TObject to this manager so that it will be deleted appropriately.
static Environment_t envStringToEnum(const std::string &str)
Converts a string to an Environment_t of the same name.
bool msgLvl(const MSG::Level lvl) const
bool empty() const
Test if the key is blank.
static unsigned int getLBsLowStat()
float lbAverageLiveFraction(bool highPriority=true) const
Luminosity-averaged live fraction over all physics BCIDs.
static Environment_t environment()
Returns the running environment of the monitoring application to help ManagedMonitorToolBase objects ...
static unsigned int getLBsMedStat()
static DataType_t dataType()
Returns the data type that the monitoring application is running over to help ManagedMonitorToolBase ...
An Algorithm that manages a set of modules, each inheriting from ManagedMonitorToolBase,...
static DataType_t dataTypeStringToEnum(const std::string &str)
Converts a string to a DataType_t of the same name.
::StatusCode StatusCode
StatusCode definition for legacy code.
void tolower(std::string &s)
virtual void writeAndDelete(const std::string &key)
If the TObject is owned by this manager, its Write() method is called and it is deleted.
const std::vector< float > & l1LiveFractionVector(bool highPriority=true) const
Return vector with all BCIDs indexed by BCID number.
double lbDuration() const
static const MSG::Level s_resourceMonThreshold
static unsigned int getLBsHigStat()
StatusCode initialize(bool used=true)
#define ATH_MSG_WARNING(x)
filelist
print ("Checking files %s..." % fullfile)
static unsigned int lumiBlockNumber()