CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

hitfit::EtaDepResolution Class Reference

Hold on to $\eta$-dependent resolution. This class acts as a function object and returns Vector_Resolution as a function of $\eta$. It does not assume symmetry between $+\eta$ and $-\eta$. The interpretation of $\eta$ as physics $\eta$ or detector $\eta$ is left to users's implementation. More...

#include <EtaDepResolution.h>

List of all members.

Public Member Functions

const bool CheckEta (double eta) const
 Check is an input $\eta$ value is within the valid $\eta$-range of this instance.
bool CheckNoOverlap (const std::vector< EtaDepResElement > &v)
 Check for non-overlapping $\eta$-range between $\eta$-dependent resolution elements in a list.
 EtaDepResolution ()
 Default constructor, instantiate an EtaDepResolution object with empty list of $\eta$-dependent resolution elements.
 EtaDepResolution (const std::string &default_file)
 Instantiate an EtaDepResolution object with a filename which contains information about $\eta$-dependent resolution.
const double EtaMax () const
 Return the upper limit of the valid $\eta$-range.
const double EtaMin () const
 Return the lower limit of the valid $\eta$-range.
const std::vector
< EtaDepResElement
GetEtaDepResElement () const
 Access the internal list of $\eta$-dependent resolution elements.
EtaDepResElement GetEtaDepResElement (double &eta) const
 Return the corresponding $\eta$-dependent resolution element (of type EtaDepResElement)for a value of $\eta$.
Vector_Resolution GetResolution (double &eta) const
 Return the corresponding resolution for a value of $\eta$.
Vector_Resolution operator() (double &eta)
 Allow users to call this instance as a function to access the corresponding resolution for an input value of $\eta$.
std::vector< EtaDepResElement >
::size_type 
Read (const std::string &default_file)
 Read the $\eta$-dependent resolution information from an ASCII text file.
std::vector< EtaDepResElement >
::size_type 
Read (const Defaults_Text &defs)
 Read the $\eta$-dependent resolution information from a Defaults_Text object.
void sort ()
 ~EtaDepResolution ()

Private Member Functions

std::vector< EtaDepResElement >
::const_iterator 
FindResolution (double &eta) const
 Internal method to return the corresponding $\eta$-dependent resolution element for a given $\eta$ value.

Private Attributes

std::vector< EtaDepResElement_EtaDepResElement

Detailed Description

Hold on to $\eta$-dependent resolution. This class acts as a function object and returns Vector_Resolution as a function of $\eta$. It does not assume symmetry between $+\eta$ and $-\eta$. The interpretation of $\eta$ as physics $\eta$ or detector $\eta$ is left to users's implementation.

Usage:
Users should write the $\eta$-dependent resolution in a plain ASCII text file with the following format:

etadep_etaminX = etamin

etadep_etamaxX = etamax

etadep_vecresX = vecres

where:

X is an integer starting from 0 (0, 1, 2, 3, ...). Users can write as many resolutions as long as each of them has different integer, and complete information regarding $\eta$ range an resolution.

etamin is a floating-point number, the lower limit of the valid $\eta$ range.

etamax is a floating-point number, the upper limit of the valid $\eta$ range.

vecres is a string-encoded Vector_Resolution, see the documentation for Vector_Resolution class for details.

The constructor will read the ASCII text file and read all resolutions in the file. Then it will instantiate the EtaDepResolution and sort the internal list of EtaDepResElement.

Author:
Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
Creation date:
June 2009.

Definition at line 88 of file EtaDepResolution.h.


Constructor & Destructor Documentation

hitfit::EtaDepResolution::EtaDepResolution ( )

Default constructor, instantiate an EtaDepResolution object with empty list of $\eta$-dependent resolution elements.

Definition at line 56 of file EtaDepResolution.cc.

{
}
hitfit::EtaDepResolution::EtaDepResolution ( const std::string &  default_file)

Instantiate an EtaDepResolution object with a filename which contains information about $\eta$-dependent resolution.

Parameters:
default_fileThe input ASCII text file.

Definition at line 61 of file EtaDepResolution.cc.

References Read().

{
    Read(default_file);
}
hitfit::EtaDepResolution::~EtaDepResolution ( )

Destructor.

Definition at line 67 of file EtaDepResolution.cc.

{
}

Member Function Documentation

const bool hitfit::EtaDepResolution::CheckEta ( double  eta) const

Check is an input $\eta$ value is within the valid $\eta$-range of this instance.

Parameters:
etaThe $\eta$ value to be check.
Return:
true if eta is within the valid $\eta$-range.
false if is not within the valid $\eta$-range.

Definition at line 165 of file EtaDepResolution.cc.

References _EtaDepResElement, and FindResolution().

{
    return FindResolution(eta) != _EtaDepResElement.end();
}
bool hitfit::EtaDepResolution::CheckNoOverlap ( const std::vector< EtaDepResElement > &  v)

Check for non-overlapping $\eta$-range between $\eta$-dependent resolution elements in a list.

Parameters:
vThe list of $\eta$-dependent resolution elements to check.
Return:
true if there is no overlap.
false if there is overlap.

Definition at line 127 of file EtaDepResolution.cc.

References i, and j.

Referenced by Read().

{
    for (std::vector<EtaDepResElement>::size_type i = 0 ;
         i != v.size() ;
         i++) {
        for (std::vector<EtaDepResElement>::size_type j = i + 1 ;
             j != v.size() ;
             j++) {
            if (v[i].IsOverlap(v[j])) {
                return false;
            }
        }
    }
    return true;
}
const double hitfit::EtaDepResolution::EtaMax ( ) const

Return the upper limit of the valid $\eta$-range.

Definition at line 155 of file EtaDepResolution.cc.

References _EtaDepResElement.

{
    if (!(_EtaDepResElement.empty())) {
        return _EtaDepResElement.back().EtaMax();
    }
    return -999.; // a ridiculously negative large number
}
const double hitfit::EtaDepResolution::EtaMin ( ) const

Return the lower limit of the valid $\eta$-range.

Definition at line 145 of file EtaDepResolution.cc.

References _EtaDepResElement.

{
    if (!(_EtaDepResElement.empty())) {
        return _EtaDepResElement.front().EtaMin();
    }
    return 999.; // a ridiculously positive large number
}
std::vector< EtaDepResElement >::const_iterator hitfit::EtaDepResolution::FindResolution ( double &  eta) const [private]

Internal method to return the corresponding $\eta$-dependent resolution element for a given $\eta$ value.

Parameters:
etaThe value of $\eta$ whose corresponding resolution is to be found.
Return:
An iterator (pointer) to the corresponding $\eta$-dependent resolution element.

Definition at line 34 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by CheckEta(), GetEtaDepResElement(), and GetResolution().

{

    for (std::vector<EtaDepResElement>::const_iterator res = _EtaDepResElement.begin() ;
         res != _EtaDepResElement.end() ;
         ++res) {
        if (res->IsInInterval(eta) || res->IsOnEdge(eta)) {
            return res;
        }
    }
    return _EtaDepResElement.end() ;

}
EtaDepResElement hitfit::EtaDepResolution::GetEtaDepResElement ( double &  eta) const

Return the corresponding $\eta$-dependent resolution element (of type EtaDepResElement)for a value of $\eta$.

Parameters:
etaThe $\eta$ value for which the corresponding element
Return:
The corresponding element if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 195 of file EtaDepResolution.cc.

References FindResolution().

{
    return *(FindResolution(eta));
}
const std::vector< EtaDepResElement > hitfit::EtaDepResolution::GetEtaDepResElement ( ) const

Access the internal list of $\eta$-dependent resolution elements.

Return:
The list of $\eta$-dependent resolution elements.

Definition at line 202 of file EtaDepResolution.cc.

References _EtaDepResElement.

{
    return _EtaDepResElement;
}
Vector_Resolution hitfit::EtaDepResolution::GetResolution ( double &  eta) const

Return the corresponding resolution for a value of $\eta$.

Parameters:
etaThe $\eta$ value for which the corresponding resolution is desired.
Return:
The corresponding resolution if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 179 of file EtaDepResolution.cc.

References _EtaDepResElement, FindResolution(), and python::rootplot::argparse::message.

Referenced by operator()().

{

    std::vector<EtaDepResElement>::const_iterator etaDepResEleVecIter = FindResolution(eta);
    if (etaDepResEleVecIter != _EtaDepResElement.end()) {
        return etaDepResEleVecIter->GetResolution();
    }

    std::stringstream message;
    message << "Error, the given eta value : "
            << eta << " is not inside the valid eta range!" ;

    throw std::runtime_error(message.str());
}
Vector_Resolution hitfit::EtaDepResolution::operator() ( double &  eta)

Allow users to call this instance as a function to access the corresponding resolution for an input value of $\eta$.

Parameters:
etaThe $\eta$ value for which the corresponding resolution is desired.
Return:
The corresponding resolution if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 172 of file EtaDepResolution.cc.

References GetResolution().

{
    return GetResolution(eta);
}
std::vector< EtaDepResElement >::size_type hitfit::EtaDepResolution::Read ( const std::string &  default_file)

Read the $\eta$-dependent resolution information from an ASCII text file.

Parameters:
default_fileThe ASCII text file to read.
Return:
The number of $\eta$-dependent resolution element read from the file.

Definition at line 73 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by EtaDepResolution().

{
    const Defaults_Text defs(default_file);
    Read(defs);
    return _EtaDepResElement.size();
}
std::vector< EtaDepResElement >::size_type hitfit::EtaDepResolution::Read ( const Defaults_Text defs)

Read the $\eta$-dependent resolution information from a Defaults_Text object.

Parameters:
defsThe Defaults_Text object to read.
Return:
The number of $\eta$-dependent resolution element read from the file.

Definition at line 82 of file EtaDepResolution.cc.

References _EtaDepResElement, CheckNoOverlap(), hitfit::Defaults_Text::exists(), hitfit::Defaults_Text::get_float(), hitfit::Defaults_Text::get_string(), i, and sort().

{

    _EtaDepResElement.clear();

    for (std::vector<EtaDepResElement>::size_type i = 0 ;
         ;
         ++i) {

        std::ostringstream os_etamin ;
        std::ostringstream os_etamax ;
        std::ostringstream os_res ;

        os_etamin << "etadep_etamin" << i ;
        os_etamax << "etadep_etamax" << i ;
        os_res    << "etadep_vecres" << i ;

        if (defs.exists(os_etamin.str()) &&
            defs.exists(os_etamax.str()) &&
            defs.exists(os_res.str())) {

            double            etamin = defs.get_float(os_etamin.str());
            double            etamax = defs.get_float(os_etamax.str());
            Vector_Resolution res(defs.get_string(os_res.str()));
            _EtaDepResElement.push_back(EtaDepResElement(etamin,etamax,res));

        }
        else {
            break;
        }

    }

    if (CheckNoOverlap(_EtaDepResElement)) {
        sort();
    } else {
        _EtaDepResElement.clear();
    }

    return _EtaDepResElement.size();

}
void hitfit::EtaDepResolution::sort ( )

Sort the internal list of $\eta$-dependent resolution elements.

Definition at line 50 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by Read().

{
    std::stable_sort(_EtaDepResElement.begin(),_EtaDepResElement.end());
}

Member Data Documentation

List of $\eta$-dependent resolution elements.

Definition at line 95 of file EtaDepResolution.h.

Referenced by CheckEta(), EtaMax(), EtaMin(), FindResolution(), GetEtaDepResElement(), GetResolution(), Read(), and sort().