ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CP::CollectionContainer Class Referencefinal

The collection container manages the time binning of a particular scale-factor map. More...

#include <EffiCollection.h>

Collaboration diagram for CP::CollectionContainer:

Public Member Functions

 CollectionContainer (const MuonEfficiencyScaleFactors &ref_tool, EffiCollection::CollectionType FileType)
 Nominal constructor... Only needs to know about it's type and the file to load. More...
 
 CollectionContainer (const MuonEfficiencyScaleFactors &ref_tool, CollectionContainer *Nominal, const std::string &syst_name, unsigned int syst_bit_map)
 
EfficiencyScaleFactorretrieve (unsigned int RunNumer)
 Retrieve the scale-factor map belonging to that particular run of data-taking. More...
 
bool isBinInMap (unsigned int bin) const
 Checks if the global bin number belongs to this map. More...
 
bool CheckConsistency ()
 Consistency check of all scale-factor maps managed by the container instance. More...
 
std::string sysname () const
 Returns MUON_EFF_<sysname()> More...
 
bool SetSystematicBin (unsigned int Bin)
 Activate this bin to run in the uncorrelated systematic mode. More...
 
void SetGlobalOffSet (unsigned int OffSet)
 Sets the global offset to align the order in the map into a global numbering scheme. More...
 
unsigned int nBins () const
 Number of bins of the map itself. More...
 
unsigned int nOverFlowBins () const
 Number of overflow bins in the map. More...
 
bool isOverFlowBin (int b) const
 Check whether the bin is overflow or not. More...
 
unsigned int globalOffSet () const
 Global offset of the bin numbers. More...
 
std::string GetBinName (unsigned int Bin) const
 Name of the i-th bin. More...
 
int FindBinSF (const xAOD::Muon &mu) const
 Returns the global bin number corresponding to the muon kinematics. More...
 
EffiCollection::CollectionType type () const
 File type of the map. More...
 
bool isNominal () const
 
bool isUpVariation () const
 
bool separateBinSyst () const
 

Private Member Functions

std::map< std::string, std::pair< unsigned int, unsigned int > > findPeriods (const MuonEfficiencyScaleFactors &ref_tool) const
 
std::string fileName (const MuonEfficiencyScaleFactors &ref_tool) const
 
bool LoadPeriod (unsigned int RunNumber)
 

Private Attributes

std::vector< std::shared_ptr< EfficiencyScaleFactor > > m_SF
 
EfficiencyScaleFactorm_currentSF
 
EffiCollection::CollectionType m_FileType
 
unsigned int m_binOffSet
 Offset to translate between the bin-numbers in the bin numbers of each file against the global bin-number. More...
 

Detailed Description

The collection container manages the time binning of a particular scale-factor map.

For a given runNumber, it pipes the right map to the upstream tools.

Definition at line 126 of file EffiCollection.h.

Constructor & Destructor Documentation

◆ CollectionContainer() [1/2]

CP::CollectionContainer::CollectionContainer ( const MuonEfficiencyScaleFactors ref_tool,
EffiCollection::CollectionType  FileType 
)

Nominal constructor... Only needs to know about it's type and the file to load.

Definition at line 339 of file EffiCollection.cxx.

339  :
340  m_SF(),
341  m_currentSF(nullptr),
342  m_FileType(FileType),
343  m_binOffSet(0){
344 
345  std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
346  for (auto& period : map) {
347  m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(ref_tool, fileName(ref_tool), period.first));
348  m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
349  }
350  }

◆ CollectionContainer() [2/2]

CP::CollectionContainer::CollectionContainer ( const MuonEfficiencyScaleFactors ref_tool,
CollectionContainer Nominal,
const std::string &  syst_name,
unsigned int  syst_bit_map 
)

Definition at line 351 of file EffiCollection.cxx.

351  :
352  m_SF(),
353  m_currentSF(nullptr),
354  m_FileType(Nominal->type()),
355  m_binOffSet(0) {
356  std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
357  for (auto& period : map) {
358  std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator itr = std::find_if( Nominal->m_SF.begin(),
359  Nominal->m_SF.end(),
360  [&period](const std::shared_ptr<EfficiencyScaleFactor>& a){
361  return a->coversRunNumber(period.second.first);
362  });
363  m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(*itr, ref_tool, fileName(ref_tool), period.first, syst_name, syst_bit_map));
364  m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
365  }
366  }

Member Function Documentation

◆ CheckConsistency()

bool CP::CollectionContainer::CheckConsistency ( )

Consistency check of all scale-factor maps managed by the container instance.

Check that there are no overlapping run numbers in the periods

Definition at line 404 of file EffiCollection.cxx.

404  {
405  if (m_SF.empty()) {
406  Error("CollectionContainer", "Could not retrieve any SFs from the input file");
407  return false;
408  }
410  for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator first_sf = m_SF.begin() ; first_sf != m_SF.end(); ++first_sf) {
411  if (!(*first_sf)->CheckConsistency()) return false;
412  for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator second_sf = m_SF.begin(); second_sf != first_sf; ++second_sf) {
413  if ( (*first_sf)->coversRunNumber( (*second_sf)->firstRun()) || (*first_sf)->coversRunNumber((*second_sf)->lastRun()) ||
414  (*second_sf)->coversRunNumber( (*first_sf)->firstRun()) || (*second_sf)->coversRunNumber((*first_sf)->lastRun())){
415  Error("CollectionContainer", "Overlapping periods observed in file type %s. As run %i is in period %i - %i. Please check your SF file!",
416  EffiCollection::FileTypeName(m_FileType).c_str(), (*first_sf)->firstRun(), (*second_sf)->firstRun(), (*second_sf)->lastRun());
417  return false;
418  }
419  }
420  }
421 
422  std::sort(m_SF.begin(), m_SF.end(), [](const std::shared_ptr<EfficiencyScaleFactor>& a, const std::shared_ptr<EfficiencyScaleFactor>& b){
423  return a->firstRun() < b->firstRun();});
424  return true;
425  }

◆ fileName()

std::string CP::CollectionContainer::fileName ( const MuonEfficiencyScaleFactors ref_tool) const
private

Definition at line 396 of file EffiCollection.cxx.

396  {
397  if (type() == EffiCollection::CollectionType::Central) return ref_tool.filename_Central();
398  if (type() == EffiCollection::CollectionType::Calo) return ref_tool.filename_Calo();
399  if (type() == EffiCollection::CollectionType::CentralLowPt) return ref_tool.filename_LowPt();
400  if (type() == EffiCollection::CollectionType::CaloLowPt) return ref_tool.filename_LowPtCalo();
401  return ref_tool.filename_HighEta();
402  }

◆ FindBinSF()

int CP::CollectionContainer::FindBinSF ( const xAOD::Muon mu) const

Returns the global bin number corresponding to the muon kinematics.

In case of failures -1 is returned

Definition at line 470 of file EffiCollection.cxx.

470  {
471  if (m_SF.empty() ) return -1;
472  int bin = (*m_SF.begin())->FindBinSF(mu);
473  return bin > 0 ? m_binOffSet + bin : bin;
474  }

◆ findPeriods()

std::map< std::string, std::pair< unsigned int, unsigned int > > CP::CollectionContainer::findPeriods ( const MuonEfficiencyScaleFactors ref_tool) const
private

Definition at line 367 of file EffiCollection.cxx.

367  {
368 
369  std::string file_name = fileName(ref_tool);
370  std::map<std::string, std::pair<unsigned int, unsigned int>> map;
371 
372  std::unique_ptr<TFile> fin (TFile::Open(file_name.c_str()));
373  if (!fin || !fin->IsOpen()) {
374  Error("CollectionContainer","Unable to open file %s", file_name.c_str());
375  return map;
376  }
377  TTree* intree = 0;
378  fin->GetObject("LumiData", intree);
379 
380  // if no Lumi tree is found, we assume that the SF are not binned in time
381  if (!intree) {
382  map["All"] = std::pair<unsigned int,unsigned int>(1, 999999);
383  } else {
384  std::string *period = 0;
385  unsigned int firstRun = 0;
386  unsigned int lastRun = 0;
387  intree->SetBranchAddress("Period", &period);
388  intree->SetBranchAddress("FirstRun", &firstRun);
389  intree->SetBranchAddress("LastRun", &lastRun);
390  for (int t = 0; intree->GetEntry(t); t++) {
391  map[*period] = std::pair<unsigned int, unsigned int>(firstRun, lastRun);
392  }
393  }
394  return map;
395  }

◆ GetBinName()

std::string CP::CollectionContainer::GetBinName ( unsigned int  Bin) const

Name of the i-th bin.

Definition at line 467 of file EffiCollection.cxx.

467  {
468  return (*m_SF.begin())->GetBinName(Bin- m_binOffSet);
469  }

◆ globalOffSet()

unsigned int CP::CollectionContainer::globalOffSet ( ) const

Global offset of the bin numbers.

Definition at line 478 of file EffiCollection.cxx.

478  {
479  return m_binOffSet;
480  }

◆ isBinInMap()

bool CP::CollectionContainer::isBinInMap ( unsigned int  bin) const

Checks if the global bin number belongs to this map.

Definition at line 461 of file EffiCollection.cxx.

461  {
462  return m_binOffSet <= bin && bin < m_binOffSet + nBins();
463  }

◆ isNominal()

bool CP::CollectionContainer::isNominal ( ) const

Definition at line 481 of file EffiCollection.cxx.

481  {
482  if (m_SF.empty()) return false;
483  return (*m_SF.begin())->sysname(false).empty();
484  }

◆ isOverFlowBin()

bool CP::CollectionContainer::isOverFlowBin ( int  b) const

Check whether the bin is overflow or not.

Definition at line 458 of file EffiCollection.cxx.

458  {
459  return m_SF.empty() ? true : (*m_SF.begin())->isOverFlowBin(b-m_binOffSet);
460  }

◆ isUpVariation()

bool CP::CollectionContainer::isUpVariation ( ) const

Definition at line 485 of file EffiCollection.cxx.

485  {
486  if (m_SF.empty()) return false;
487  return (*m_SF.begin())->IsUpVariation();
488  }

◆ LoadPeriod()

bool CP::CollectionContainer::LoadPeriod ( unsigned int  RunNumber)
private

Definition at line 426 of file EffiCollection.cxx.

426  {
428  for (auto& period : m_SF) {
429  if (period->coversRunNumber(RunNumber)) {
430  m_currentSF = period.get();
431  return true;
432  }
433  }
434  } else return true;
435  Warning("CollectionContainer", "Could not find any SF period in %s matching the run number %u", EffiCollection::FileTypeName(type()).c_str(), RunNumber);
436  return false;
437  }

◆ nBins()

unsigned int CP::CollectionContainer::nBins ( ) const

Number of bins of the map itself.

Definition at line 452 of file EffiCollection.cxx.

452  {
453  return m_SF.empty() ? 0 : (*m_SF.begin())->nBins();
454  }

◆ nOverFlowBins()

unsigned int CP::CollectionContainer::nOverFlowBins ( ) const

Number of overflow bins in the map.

Definition at line 455 of file EffiCollection.cxx.

455  {
456  return m_SF.empty() ? 0 : (*m_SF.begin())->nOverFlowBins();
457  }

◆ retrieve()

EfficiencyScaleFactor * CP::CollectionContainer::retrieve ( unsigned int  RunNumer)

Retrieve the scale-factor map belonging to that particular run of data-taking.

Definition at line 438 of file EffiCollection.cxx.

438  {
439  if (!LoadPeriod(RunNumber)) {
440  return (*m_SF.begin()).get();
441  }
442  return m_currentSF;
443  }

◆ separateBinSyst()

bool CP::CollectionContainer::separateBinSyst ( ) const

Definition at line 489 of file EffiCollection.cxx.

489  {
490  if (m_SF.empty()) return false;
491  return (*m_SF.begin())->separateBinSyst();
492  }

◆ SetGlobalOffSet()

void CP::CollectionContainer::SetGlobalOffSet ( unsigned int  OffSet)

Sets the global offset to align the order in the map into a global numbering scheme.

Definition at line 475 of file EffiCollection.cxx.

475  {
476  m_binOffSet = OffSet;
477  }

◆ SetSystematicBin()

bool CP::CollectionContainer::SetSystematicBin ( unsigned int  Bin)

Activate this bin to run in the uncorrelated systematic mode.

Definition at line 444 of file EffiCollection.cxx.

444  {
445  for ( std::shared_ptr<EfficiencyScaleFactor>& Period : m_SF) {
446  if (!Period->SetSystematicBin(Bin- m_binOffSet)) {
447  return false;
448  }
449  }
450  return true;
451  }

◆ sysname()

std::string CP::CollectionContainer::sysname ( ) const

Returns MUON_EFF_<sysname()>

Definition at line 493 of file EffiCollection.cxx.

493  {
494  if (m_SF.empty()) return "UNKNOWN SYST";
495  return (*m_SF.begin())->sysname(false);
496  }

◆ type()

EffiCollection::CollectionType CP::CollectionContainer::type ( ) const

File type of the map.

Definition at line 464 of file EffiCollection.cxx.

464  {
465  return m_FileType;
466  }

Member Data Documentation

◆ m_binOffSet

unsigned int CP::CollectionContainer::m_binOffSet
private

Offset to translate between the bin-numbers in the bin numbers of each file against the global bin-number.

Definition at line 187 of file EffiCollection.h.

◆ m_currentSF

EfficiencyScaleFactor* CP::CollectionContainer::m_currentSF
private

Definition at line 182 of file EffiCollection.h.

◆ m_FileType

EffiCollection::CollectionType CP::CollectionContainer::m_FileType
private

Definition at line 184 of file EffiCollection.h.

◆ m_SF

std::vector<std::shared_ptr<EfficiencyScaleFactor> > CP::CollectionContainer::m_SF
private

Definition at line 181 of file EffiCollection.h.


The documentation for this class was generated from the following files:
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
CP::CollectionContainer::LoadPeriod
bool LoadPeriod(unsigned int RunNumber)
Definition: EffiCollection.cxx:426
athena_checkUpload.Period
int Period
--> Execution phase:
Definition: athena_checkUpload.py:179
bin
Definition: BinsDiffFromStripMedian.h:43
CP::CollectionContainer::isOverFlowBin
bool isOverFlowBin(int b) const
Check whether the bin is overflow or not.
Definition: EffiCollection.cxx:458
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CP::EfficiencyScaleFactor::coversRunNumber
bool coversRunNumber(unsigned int run) const
Check if a run of data-taking is covered by this map.
Definition: EfficiencyScaleFactor.cxx:194
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
jet::CombMassComp::Calo
@ Calo
Definition: UncertaintyEnum.h:197
egEnergyCorr::Resolution::Nominal
@ Nominal
Definition: egammaEnergyCorrectionTool.h:62
CP::CollectionContainer::nBins
unsigned int nBins() const
Number of bins of the map itself.
Definition: EffiCollection.cxx:452
CP::CollectionContainer::FindBinSF
int FindBinSF(const xAOD::Muon &mu) const
Returns the global bin number corresponding to the muon kinematics.
Definition: EffiCollection.cxx:470
EventInfoWrite.RunNumber
RunNumber
Definition: EventInfoWrite.py:50
CP::CollectionContainer::type
EffiCollection::CollectionType type() const
File type of the map.
Definition: EffiCollection.cxx:464
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
CP::EffiCollection::FileTypeName
static std::string FileTypeName(EffiCollection::CollectionType T)
Definition: EffiCollection.cxx:291
a
TList * a
Definition: liststreamerinfos.cxx:10
CP::CollectionContainer::findPeriods
std::map< std::string, std::pair< unsigned int, unsigned int > > findPeriods(const MuonEfficiencyScaleFactors &ref_tool) const
Definition: EffiCollection.cxx:367
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
CP::CollectionContainer::m_SF
std::vector< std::shared_ptr< EfficiencyScaleFactor > > m_SF
Definition: EffiCollection.h:181
CP::CollectionContainer::nOverFlowBins
unsigned int nOverFlowBins() const
Number of overflow bins in the map.
Definition: EffiCollection.cxx:455
ReadBchFromCool.lastRun
lastRun
Definition: ReadBchFromCool.py:278
compute_lumi.fin
fin
Definition: compute_lumi.py:19
CP::CollectionContainer::m_currentSF
EfficiencyScaleFactor * m_currentSF
Definition: EffiCollection.h:182
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
CP::CollectionContainer::m_binOffSet
unsigned int m_binOffSet
Offset to translate between the bin-numbers in the bin numbers of each file against the global bin-nu...
Definition: EffiCollection.h:187
CP::CollectionContainer::m_FileType
EffiCollection::CollectionType m_FileType
Definition: EffiCollection.h:184
CP::CollectionContainer::fileName
std::string fileName(const MuonEfficiencyScaleFactors &ref_tool) const
Definition: EffiCollection.cxx:396
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53