ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
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::Resultexecute (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.

53  {
54  return new AFP_LBsOutOfRange();
55 }

◆ 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 )
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 }

◆ 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, databaseName, 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 }

◆ 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:
dqm_algorithms::tools::GetBinRange
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:380
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
dqm_algorithms::AFP_LBsOutOfRange::IOVSet
std::vector< std::pair< int, int > > IOVSet
Definition: AFP_LBsOutOfRange.h:30
beamspotman.lbs
lbs
Definition: beamspotman.py:1154
Undefined
@ Undefined
Definition: MaterialTypes.h:8
get_generator_info.result
result
Definition: get_generator_info.py:21
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
find_tgc_unfilled_channelids.iovs
iovs
Definition: find_tgc_unfilled_channelids.py:12
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
lumiFormat.i
int i
Definition: lumiFormat.py:85
xmin
double xmin
Definition: listroot.cxx:60
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
dqm_algorithms::AFP_LBsOutOfRange::AFP_LBsOutOfRange
AFP_LBsOutOfRange()
Definition: AFP_LBsOutOfRange.cxx:45
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.handimod.Green
int Green
Definition: handimod.py:524
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
run
Definition: run.py:1
dqm_algorithms::AFP_LBsOutOfRange::fetchIOVs
const IOVSet & fetchIOVs(uint32_t run, uint32_t channel)
Definition: AFP_LBsOutOfRange.cxx:58
python.handimod.Red
Red
Definition: handimod.py:551
CaloCellTimeCorrFiller.folderName
string folderName
Definition: CaloCellTimeCorrFiller.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
xmax
double xmax
Definition: listroot.cxx:61
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114
pickleTool.object
object
Definition: pickleTool.py:30
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
dqm_algorithms::AFP_LBsOutOfRange::m_iov_cache
std::map< std::pair< uint32_t, uint32_t >, IOVSet > m_iov_cache
Definition: AFP_LBsOutOfRange.h:42
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
histogram
std::string histogram
Definition: chains.cxx:52