8 #include <dqm_core/AlgorithmManager.h>
9 #include <dqm_core/exceptions.h>
11 #include <CoolApplication/DatabaseSvcFactory.h>
12 #include <CoolKernel/ChannelSelection.h>
13 #include <CoolKernel/IDatabase.h>
14 #include <CoolKernel/IDatabaseSvc.h>
15 #include <CoolKernel/IField.h>
16 #include <CoolKernel/IFolder.h>
17 #include <CoolKernel/IObject.h>
18 #include <CoolKernel/IObjectIterator.h>
19 #include <CoolKernel/IRecord.h>
20 #include <CoolKernel/ValidityKey.h>
21 #include <CoolKernel/pointers.h>
22 #include <CoolKernel/types.h>
24 #include <TDirectory.h>
30 constexpr
uint64_t LB_MASK = 0xffffffff;
32 return obj.payload()[
name ].data<cool::UInt63>();
41 return obj.since() & LB_MASK;
61 auto& dbService = cool::DatabaseSvcFactory::databaseService();
63 uint64_t runStartTime = 0xFFffFFffFFffFFff;
65 std::map<uint64_t, uint32_t>
lbs;
67 auto databaseName = std::string(
"COOLONL_TRIGGER/CONDBR2" );
68 auto folderName = std::string(
"/TRIGGER/LUMI/LBLB" );
69 auto databasePtr = dbService.openDatabase( databaseName,
true );
70 auto folderPtr = databasePtr->getFolder(
folderName );
72 auto since = cool::ValidityKey( run64 << 32 );
73 auto until = cool::ValidityKey( ( run64 + 1 ) << 32 );
75 while ( iterPtr->goToNext() ) {
76 auto&
object = iterPtr->currentRef();
77 auto lbStartTime = getStartTime(
object );
78 auto lbEndTime = getEndTime(
object );
79 lbs.emplace( lbStartTime, getLB(
object ) );
80 if ( lbStartTime < runStartTime ) runStartTime = lbStartTime;
81 if ( lbEndTime > runEndTime ) runEndTime = lbEndTime;
83 if (
lbs.empty() )
throw afp::CantReadCool( ERS_HERE, databaseName,
folderName );
89 auto databaseName = std::string(
"COOLOFL_DCS/CONDBR2" );
90 auto folderName = std::string(
"/AFP/DCS/STATION" );
91 auto databasePtr = dbService.openDatabase( databaseName,
true );
92 auto folderPtr = databasePtr->getFolder(
folderName );
93 auto iterPtr = folderPtr->browseObjects( runStartTime, runEndTime, cool::ChannelSelection(
channel ) );
95 iovs.reserve( iterPtr->size() / 2 );
96 while ( iterPtr->goToNext() ) {
97 auto&
object = iterPtr->currentRef();
98 auto inphysics =
object.payload()[
"inphysics" ].data<cool::Bool>();
101 until =
object.until();
102 }
else if (
since != 0 ) {
111 if (
iovs.empty() ) {
112 iovs.emplace_back( 0
u, 0
u );
120 const TObject&
object,
121 const dqm_core::AlgorithmConfig&
config ) {
122 if ( !
object.
IsA()->InheritsFrom(
"TH1" ) ) {
123 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
129 throw dqm_core::BadConfig( ERS_HERE,
name,
"histogram has more than 1 dimension" );
148 std::vector<uint32_t> badbins;
151 auto xstart = std::max<uint32_t>( xaxis->FindFixBin(
iov.first ),
xmin );
152 auto xend = std::min<uint32_t>( xaxis->FindFixBin(
iov.second ),
xmax );
153 for (
uint32_t ix = xstart; ix < xend; ++ix ) {
154 double binvalue =
histogram->GetBinContent( ix );
155 if ( binvalue == ignoreval )
continue;
157 if ( RANGE_D < binvalue && binvalue < RANGE_U )
continue;
158 badbins.push_back( ix );
167 result->tags_[
"NBadBins" ] = badbins.size();
169 auto npublish = std::min<uint32_t>( Nmaxpublish, badbins.size() );
172 uint32_t lb = std::floor( xaxis->GetBinCenter( ix ) );
173 auto tag = ( std::ostringstream() <<
"LB " <<
lb ).
str();
179 if ( checkedLBs < minLBs )
181 else if ( badbins.size() > rthreshold )
183 else if ( badbins.size() > gthreshold )
184 result->status_ = dqm_core::Result::Yellow;
192 out <<
"AFP_LBsOutOfRange: Print out the bad LBs, during which AFP was in physics position, and which are out of range [RANDE_D,RANGE_U] (default [-100,100])\n"
193 <<
"Required Parameter: channel: channel number of the station in COOLOFL_DCS/CONDBR2 /AFP/DCS/STATION\n"
194 <<
"Optional Parameter: ignoreval: value to be ignored for being processed (default 0)\n"
195 <<
"Optional Parameter: MaxPublish: Max number of bins to save (default 20)\n"
196 <<
"Optional Parameter: MinLBs: Minimum number of LBs in physics with value not equal to ignoreval to assign color (default 0)" << std::endl;