61 auto& dbService = cool::DatabaseSvcFactory::databaseService();
63 uint64_t runStartTime = 0xFFffFFffFFffFFff;
64 uint64_t runEndTime = 0;
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 );
74 auto iterPtr = folderPtr->browseObjects( since, until, cool::ChannelSelection::all() );
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, std::move(databaseName), std::move(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 ) );
94 uint64_t since = 0, until = 0;
95 iovs.reserve( iterPtr->size() / 2 );
96 static const std::string inPhysicsStr{
"inphysics"};
97 while ( iterPtr->goToNext() ) {
98 auto&
object = iterPtr->currentRef();
99 auto inphysics =
object.payload()[ inPhysicsStr ].data<cool::Bool>();
101 if ( since == 0 ) since =
object.since();
102 until =
object.until();
103 }
else if ( since != 0 ) {
104 uint32_t start = lbs.lower_bound( since )->second;
105 uint32_t end = ( --lbs.upper_bound( until ) )->second;
106 iovs.emplace_back( start, end );
112 if ( iovs.empty() ) {
113 iovs.emplace_back( 0u, 0u );
121 const TObject&
object,
122 const dqm_core::AlgorithmConfig& config ) {
123 if ( !
object.
IsA()->InheritsFrom(
"TH1" ) ) {
124 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1" );
127 auto histogram =
static_cast<const TH1*
>( &object );
130 throw dqm_core::BadConfig( ERS_HERE, name,
"histogram has more than 1 dimension" );
146 uint32_t
xmin = range[ 0 ];
147 uint32_t
xmax = range[ 1 ] + 1;
149 std::vector<uint32_t> badbins;
150 uint32_t checkedLBs = 0;
151 for (
auto& iov : iovs ) {
152 auto xstart = std::max<uint32_t>( xaxis->FindFixBin( iov.first ),
xmin );
153 auto xend = std::min<uint32_t>( xaxis->FindFixBin( iov.second ),
xmax );
154 for ( uint32_t ix = xstart; ix < xend; ++ix ) {
155 double binvalue =
histogram->GetBinContent( ix );
156 if ( binvalue == ignoreval )
continue;
158 if ( RANGE_D < binvalue && binvalue < RANGE_U )
continue;
159 badbins.push_back( ix );
165 auto result =
new dqm_core::Result();
168 result->tags_[
"NBadBins" ] = badbins.size();
170 auto npublish = std::min<uint32_t>( Nmaxpublish, badbins.size() );
171 for ( uint32_t i = 0; i < npublish; ++i ) {
172 uint32_t ix = badbins[ i ];
173 uint32_t
lb = std::floor( xaxis->GetBinCenter( ix ) );
174 auto tag = ( std::ostringstream() <<
"LB " <<
lb ).
str();
176 result->tags_[ tag ] =
histogram->GetBinContent( ix );
180 if ( checkedLBs < minLBs )
181 result->status_ = dqm_core::Result::Undefined;
182 else if ( badbins.size() > rthreshold )
183 result->status_ = dqm_core::Result::Red;
184 else if ( badbins.size() > gthreshold )
185 result->status_ = dqm_core::Result::Yellow;
187 result->status_ = dqm_core::Result::Green;