ATLAS Offline Software
Loading...
Searching...
No Matches
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.
 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.
bool isBinInMap (unsigned int bin) const
 Checks if the global bin number belongs to this map.
bool CheckConsistency ()
 Consistency check of all scale-factor maps managed by the container instance.
std::string sysname () const
 Returns MUON_EFF_<sysname()>
bool SetSystematicBin (unsigned int Bin)
 Activate this bin to run in the uncorrelated systematic mode.
void SetGlobalOffSet (unsigned int OffSet)
 Sets the global offset to align the order in the map into a global numbering scheme.
unsigned int nBins () const
 Number of bins of the map itself.
unsigned int nOverFlowBins () const
 Number of overflow bins in the map.
bool isOverFlowBin (int b) const
 Check whether the bin is overflow or not.
unsigned int globalOffSet () const
 Global offset of the bin numbers.
std::string GetBinName (unsigned int Bin) const
 Name of the i-th bin.
int FindBinSF (const xAOD::Muon &mu) const
 Returns the global bin number corresponding to the muon kinematics.
EffiCollection::CollectionType type () const
 File type of the map.
bool isNominal () const
bool isUpVariation () const
bool separateBinSyst () const
void addSubtoolsTo (columnar::ColumnarTool<> &parentTool)

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.

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 140 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 354 of file EffiCollection.cxx.

354 :
355 m_SF(),
356 m_currentSF(nullptr),
357 m_FileType(FileType),
358 m_binOffSet(0){
359
360 std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
361 for (auto& period : map) {
362 m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(ref_tool, fileName(ref_tool), period.first));
363 m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
364 }
365 }
std::map< std::string, std::pair< unsigned int, unsigned int > > findPeriods(const MuonEfficiencyScaleFactors &ref_tool) const
EffiCollection::CollectionType m_FileType
std::vector< std::shared_ptr< EfficiencyScaleFactor > > m_SF
std::string fileName(const MuonEfficiencyScaleFactors &ref_tool) const
EfficiencyScaleFactor * m_currentSF
unsigned int m_binOffSet
Offset to translate between the bin-numbers in the bin numbers of each file against the global bin-nu...

◆ 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 366 of file EffiCollection.cxx.

366 :
367 m_SF(),
368 m_currentSF(nullptr),
369 m_FileType(Nominal->type()),
370 m_binOffSet(0) {
371 std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
372 for (auto& period : map) {
373 std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator itr = std::find_if( Nominal->m_SF.begin(),
374 Nominal->m_SF.end(),
375 [&period](const std::shared_ptr<EfficiencyScaleFactor>& a){
376 return a->coversRunNumber(period.second.first);
377 });
378 m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(*itr, ref_tool, fileName(ref_tool), period.first, syst_name, syst_bit_map));
379 m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
380 }
381 }
static Double_t a

Member Function Documentation

◆ addSubtoolsTo()

void CP::CollectionContainer::addSubtoolsTo ( columnar::ColumnarTool<> & parentTool)

Definition at line 512 of file EffiCollection.cxx.

512 {
513 for (auto& SF : m_SF)
514 parentTool.addSubtool(*SF);
515 }

◆ 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 419 of file EffiCollection.cxx.

419 {
420 if (m_SF.empty()) {
421 Error("CollectionContainer", "Could not retrieve any SFs from the input file");
422 return false;
423 }
425 for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator first_sf = m_SF.begin() ; first_sf != m_SF.end(); ++first_sf) {
426 if (!(*first_sf)->CheckConsistency()) return false;
427 for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator second_sf = m_SF.begin(); second_sf != first_sf; ++second_sf) {
428 if ( (*first_sf)->coversRunNumber( (*second_sf)->firstRun()) || (*first_sf)->coversRunNumber((*second_sf)->lastRun()) ||
429 (*second_sf)->coversRunNumber( (*first_sf)->firstRun()) || (*second_sf)->coversRunNumber((*first_sf)->lastRun())){
430 Error("CollectionContainer", "Overlapping periods observed in file type %s. As run %i is in period %i - %i. Please check your SF file!",
431 EffiCollection::FileTypeName(m_FileType).c_str(), (*first_sf)->firstRun(), (*second_sf)->firstRun(), (*second_sf)->lastRun());
432 return false;
433 }
434 }
435 }
436
437 std::sort(m_SF.begin(), m_SF.end(), [](const std::shared_ptr<EfficiencyScaleFactor>& a, const std::shared_ptr<EfficiencyScaleFactor>& b){
438 return a->firstRun() < b->firstRun();});
439 return true;
440 }
static std::string FileTypeName(EffiCollection::CollectionType T)
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ fileName()

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

Definition at line 411 of file EffiCollection.cxx.

411 {
412 if (type() == EffiCollection::CollectionType::Central) return ref_tool.filename_Central();
413 if (type() == EffiCollection::CollectionType::Calo) return ref_tool.filename_Calo();
414 if (type() == EffiCollection::CollectionType::CentralLowPt) return ref_tool.filename_LowPt();
415 if (type() == EffiCollection::CollectionType::CaloLowPt) return ref_tool.filename_LowPtCalo();
416 return ref_tool.filename_HighEta();
417 }
EffiCollection::CollectionType type() const
File type of the map.
@ Central
The five different scale-factor maps.

◆ 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 485 of file EffiCollection.cxx.

485 {
486 if (m_SF.empty() ) return -1;
487 int bin = (*m_SF.begin())->FindBinSF(mu);
488 return bin > 0 ? m_binOffSet + bin : bin;
489 }

◆ findPeriods()

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

Definition at line 382 of file EffiCollection.cxx.

382 {
383
384 std::string file_name = fileName(ref_tool);
385 std::map<std::string, std::pair<unsigned int, unsigned int>> map;
386
387 std::unique_ptr<TFile> fin (TFile::Open(file_name.c_str()));
388 if (!fin || !fin->IsOpen()) {
389 Error("CollectionContainer","Unable to open file %s", file_name.c_str());
390 return map;
391 }
392 TTree* intree = 0;
393 fin->GetObject("LumiData", intree);
394
395 // if no Lumi tree is found, we assume that the SF are not binned in time
396 if (!intree) {
397 map["All"] = std::pair<unsigned int,unsigned int>(1, 999999);
398 } else {
399 std::string *period = 0;
400 unsigned int firstRun = 0;
401 unsigned int lastRun = 0;
402 intree->SetBranchAddress("Period", &period);
403 intree->SetBranchAddress("FirstRun", &firstRun);
404 intree->SetBranchAddress("LastRun", &lastRun);
405 for (int t = 0; intree->GetEntry(t); t++) {
406 map[*period] = std::pair<unsigned int, unsigned int>(firstRun, lastRun);
407 }
408 }
409 return map;
410 }

◆ GetBinName()

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

Name of the i-th bin.

Definition at line 482 of file EffiCollection.cxx.

482 {
483 return (*m_SF.begin())->GetBinName(Bin- m_binOffSet);
484 }

◆ globalOffSet()

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

Global offset of the bin numbers.

Definition at line 493 of file EffiCollection.cxx.

493 {
494 return m_binOffSet;
495 }

◆ isBinInMap()

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

Checks if the global bin number belongs to this map.

Definition at line 476 of file EffiCollection.cxx.

476 {
477 return m_binOffSet <= bin && bin < m_binOffSet + nBins();
478 }
unsigned int nBins() const
Number of bins of the map itself.

◆ isNominal()

bool CP::CollectionContainer::isNominal ( ) const

Definition at line 496 of file EffiCollection.cxx.

496 {
497 if (m_SF.empty()) return false;
498 return (*m_SF.begin())->sysname(false).empty();
499 }

◆ isOverFlowBin()

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

Check whether the bin is overflow or not.

Definition at line 473 of file EffiCollection.cxx.

473 {
474 return m_SF.empty() ? true : (*m_SF.begin())->isOverFlowBin(b-m_binOffSet);
475 }

◆ isUpVariation()

bool CP::CollectionContainer::isUpVariation ( ) const

Definition at line 500 of file EffiCollection.cxx.

500 {
501 if (m_SF.empty()) return false;
502 return (*m_SF.begin())->IsUpVariation();
503 }

◆ LoadPeriod()

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

Definition at line 441 of file EffiCollection.cxx.

441 {
442 if (!m_currentSF || !m_currentSF->coversRunNumber(RunNumber)) {
443 for (auto& period : m_SF) {
444 if (period->coversRunNumber(RunNumber)) {
445 m_currentSF = period.get();
446 return true;
447 }
448 }
449 } else return true;
450 Warning("CollectionContainer", "Could not find any SF period in %s matching the run number %u", EffiCollection::FileTypeName(type()).c_str(), RunNumber);
451 return false;
452 }

◆ nBins()

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

Number of bins of the map itself.

Definition at line 467 of file EffiCollection.cxx.

467 {
468 return m_SF.empty() ? 0 : (*m_SF.begin())->nBins();
469 }

◆ nOverFlowBins()

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

Number of overflow bins in the map.

Definition at line 470 of file EffiCollection.cxx.

470 {
471 return m_SF.empty() ? 0 : (*m_SF.begin())->nOverFlowBins();
472 }

◆ retrieve()

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

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

Definition at line 453 of file EffiCollection.cxx.

453 {
454 if (!LoadPeriod(RunNumber)) {
455 return (*m_SF.begin()).get();
456 }
457 return m_currentSF;
458 }
bool LoadPeriod(unsigned int RunNumber)

◆ separateBinSyst()

bool CP::CollectionContainer::separateBinSyst ( ) const

Definition at line 504 of file EffiCollection.cxx.

504 {
505 if (m_SF.empty()) return false;
506 return (*m_SF.begin())->separateBinSyst();
507 }

◆ 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 490 of file EffiCollection.cxx.

490 {
491 m_binOffSet = OffSet;
492 }

◆ SetSystematicBin()

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

Activate this bin to run in the uncorrelated systematic mode.

Definition at line 459 of file EffiCollection.cxx.

459 {
460 for ( std::shared_ptr<EfficiencyScaleFactor>& Period : m_SF) {
461 if (!Period->SetSystematicBin(Bin- m_binOffSet)) {
462 return false;
463 }
464 }
465 return true;
466 }
int Period
--> Execution phase:

◆ sysname()

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

Returns MUON_EFF_<sysname()>

Definition at line 508 of file EffiCollection.cxx.

508 {
509 if (m_SF.empty()) return "UNKNOWN SYST";
510 return (*m_SF.begin())->sysname(false);
511 }

◆ type()

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

File type of the map.

Definition at line 479 of file EffiCollection.cxx.

479 {
480 return m_FileType;
481 }

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 201 of file EffiCollection.h.

◆ m_currentSF

EfficiencyScaleFactor* CP::CollectionContainer::m_currentSF
private

Definition at line 196 of file EffiCollection.h.

◆ m_FileType

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

Definition at line 198 of file EffiCollection.h.

◆ m_SF

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

Definition at line 195 of file EffiCollection.h.


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