ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::AFP_LBsOutOfRange Class Reference

#include <AFP_LBsOutOfRange.h>

Inheritance diagram for dqm_algorithms::AFP_LBsOutOfRange:
Collaboration diagram for dqm_algorithms::AFP_LBsOutOfRange:

Public Types

using IOVSet = std::vector<std::pair<int, int>>

Public Member Functions

 AFP_LBsOutOfRange ()
 ~AFP_LBsOutOfRange ()
AFP_LBsOutOfRangeclone () override
dqm_core::Result * execute (const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config) override
void printDescriptionTo (std::ostream &out) override
const IOVSetfetchIOVs (uint32_t run, uint32_t channel)

Private Attributes

std::map< std::pair< uint32_t, uint32_t >, IOVSetm_iov_cache

Detailed Description

Definition at line 28 of file AFP_LBsOutOfRange.h.

Member Typedef Documentation

◆ IOVSet

using dqm_algorithms::AFP_LBsOutOfRange::IOVSet = std::vector<std::pair<int, int>>

Definition at line 30 of file AFP_LBsOutOfRange.h.

Constructor & Destructor Documentation

◆ AFP_LBsOutOfRange()

dqm_algorithms::AFP_LBsOutOfRange::AFP_LBsOutOfRange ( )

Definition at line 45 of file AFP_LBsOutOfRange.cxx.

45 {
46 dqm_core::AlgorithmManager::instance().registerAlgorithm( "AFP_LBsOutOfRange", this );
47}

◆ ~AFP_LBsOutOfRange()

dqm_algorithms::AFP_LBsOutOfRange::~AFP_LBsOutOfRange ( )

Definition at line 49 of file AFP_LBsOutOfRange.cxx.

49 {
50}

Member Function Documentation

◆ clone()

dqm_algorithms::AFP_LBsOutOfRange * dqm_algorithms::AFP_LBsOutOfRange::clone ( )
override

Definition at line 53 of file AFP_LBsOutOfRange.cxx.

◆ execute()

dqm_core::Result * dqm_algorithms::AFP_LBsOutOfRange::execute ( const std::string & name,
const TObject & object,
const dqm_core::AlgorithmConfig & config )
override

Definition at line 119 of file AFP_LBsOutOfRange.cxx.

121 {
122 if ( !object.IsA()->InheritsFrom( "TH1" ) ) {
123 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
124 }
125
126 auto histogram = static_cast<const TH1*>( &object );
127
128 if ( histogram->GetDimension() > 1 ) {
129 throw dqm_core::BadConfig( ERS_HERE, name, "histogram has more than 1 dimension" );
130 }
131
132 auto gthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NbadBins", config.getGreenThresholds() ) );
133 auto rthreshold = static_cast<uint32_t>( dqm_algorithms::tools::GetFromMap( "NbadBins", config.getRedThresholds() ) );
134
135 auto channel = static_cast<uint32_t>( dqm_algorithms::tools::GetFirstFromMap( "channel", config.getParameters() ) );
136 auto RANGE_D = static_cast<double>( dqm_algorithms::tools::GetFirstFromMap( "RANGE_D", config.getParameters(), -100 ) );
137 auto RANGE_U = static_cast<double>( dqm_algorithms::tools::GetFirstFromMap( "RANGE_U", config.getParameters(), 100 ) );
138 auto ignoreval = static_cast<double>( dqm_algorithms::tools::GetFirstFromMap( "ignoreval", config.getParameters(), 0 ) );
139 auto minLBs = static_cast<uint32_t>( dqm_algorithms::tools::GetFirstFromMap( "MinLBs", config.getParameters(), 0 ) );
140
141 auto run = dqm_algorithms::tools::GetFirstFromMap( "run_number", config.getParameters(), 0 );
142 auto& iovs = run > 0 ? fetchIOVs( run, channel ) : IOVSet{ { 0, 0 } };
143
144 auto range = dqm_algorithms::tools::GetBinRange( histogram, config.getParameters() );
145 uint32_t xmin = range[ 0 ];
146 uint32_t xmax = range[ 1 ] + 1;
147 auto xaxis = histogram->GetXaxis();
148 std::vector<uint32_t> badbins;
149 uint32_t checkedLBs = 0;
150 for ( auto& iov : iovs ) {
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;
156 ++checkedLBs;
157 if ( RANGE_D < binvalue && binvalue < RANGE_U ) continue;
158 badbins.push_back( ix );
159 }
160 }
161
162 auto publish = static_cast<bool>( dqm_algorithms::tools::GetFirstFromMap( "PublishBins", config.getParameters(), true ) );
163 auto Nmaxpublish = static_cast<uint32_t>( dqm_algorithms::tools::GetFirstFromMap( "MaxPublish", config.getParameters(), 20 ) );
164 auto result = new dqm_core::Result();
165
166 // publish problematic bins
167 result->tags_[ "NBadBins" ] = badbins.size();
168 if ( publish ) {
169 auto npublish = std::min<uint32_t>( Nmaxpublish, badbins.size() );
170 for ( uint32_t i = 0; i < npublish; ++i ) {
171 uint32_t ix = badbins[ i ];
172 uint32_t lb = std::floor( xaxis->GetBinCenter( ix ) );
173 auto tag = ( std::ostringstream() << "LB " << lb ).str();
174
175 result->tags_[ tag ] = histogram->GetBinContent( ix );
176 }
177 }
178
179 if ( checkedLBs < minLBs )
180 result->status_ = dqm_core::Result::Undefined;
181 else if ( badbins.size() > rthreshold )
182 result->status_ = dqm_core::Result::Red;
183 else if ( badbins.size() > gthreshold )
184 result->status_ = dqm_core::Result::Yellow;
185 else
186 result->status_ = dqm_core::Result::Green;
187
188 return result;
189}
std::string histogram
Definition chains.cxx:52
std::vector< std::pair< int, int > > IOVSet
const IOVSet & fetchIOVs(uint32_t run, uint32_t channel)
int lb
Definition globals.cxx:23
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
setEventNumber uint32_t
#define IsA
Declare the TObject style functions.

◆ fetchIOVs()

const dqm_algorithms::AFP_LBsOutOfRange::IOVSet & dqm_algorithms::AFP_LBsOutOfRange::fetchIOVs ( uint32_t run,
uint32_t channel )

Definition at line 58 of file AFP_LBsOutOfRange.cxx.

58 {
59 auto& iovs = m_iov_cache[ std::make_pair( run, channel ) ];
60 if ( iovs.empty() ) {
61 auto& dbService = cool::DatabaseSvcFactory::databaseService();
62 // Get map of LB timestamps to LB numbers
63 uint64_t runStartTime = 0xFFffFFffFFffFFff;
64 uint64_t runEndTime = 0;
65 std::map<uint64_t, uint32_t> lbs;
66 {
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 );
71 uint64_t run64 = run;
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;
82 }
83 if ( lbs.empty() ) throw afp::CantReadCool( ERS_HERE, std::move(databaseName), std::move(folderName) );
84 }
85 // Get IOVs where the station was in physics position,
86 // merge the neighbouring ones,
87 // and translate the timestamps to LB numbers
88 {
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 while ( iterPtr->goToNext() ) {
97 auto& object = iterPtr->currentRef();
98 auto inphysics = object.payload()[ "inphysics" ].data<cool::Bool>();
99 if ( inphysics ) {
100 if ( since == 0 ) since = object.since();
101 until = object.until();
102 } else if ( since != 0 ) {
103 uint32_t start = lbs.lower_bound( since )->second;
104 uint32_t end = ( --lbs.upper_bound( until ) )->second;
105 iovs.emplace_back( start, end );
106 since = 0;
107 }
108 }
109 }
110 // Ensure the list is not empty
111 if ( iovs.empty() ) {
112 iovs.emplace_back( 0u, 0u );
113 }
114 }
115 return iovs;
116}
std::map< std::pair< uint32_t, uint32_t >, IOVSet > m_iov_cache

◆ printDescriptionTo()

void dqm_algorithms::AFP_LBsOutOfRange::printDescriptionTo ( std::ostream & out)
override

Definition at line 191 of file AFP_LBsOutOfRange.cxx.

191 {
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;
197}

Member Data Documentation

◆ m_iov_cache

std::map<std::pair<uint32_t, uint32_t>, IOVSet> dqm_algorithms::AFP_LBsOutOfRange::m_iov_cache
private

Definition at line 42 of file AFP_LBsOutOfRange.h.


The documentation for this class was generated from the following files: