CMS 3D CMS Logo

Public Member Functions | Private Attributes

EpCombinationTool Class Reference

#include <EpCombinationTool.h>

List of all members.

Public Member Functions

void combine (SimpleElectron &mySimpleElectron)
 EpCombinationTool ()
bool init (const std::string &regressionFile, const std::string &bdtName="")
 ~EpCombinationTool ()

Private Attributes

GBRForestm_forest

Detailed Description

Definition at line 10 of file EpCombinationTool.h.


Constructor & Destructor Documentation

EpCombinationTool::EpCombinationTool ( )

Definition at line 13 of file EpCombinationTool.cc.

                                    :
    m_forest(NULL)
/*****************************************************************/
{
}
EpCombinationTool::~EpCombinationTool ( )

Definition at line 22 of file EpCombinationTool.cc.

References m_forest.

{
    if(m_forest) delete m_forest;
}

Member Function Documentation

void EpCombinationTool::combine ( SimpleElectron mySimpleElectron)

Definition at line 54 of file EpCombinationTool.cc.

References gather_cfg::cout, relval_parameters_module::energy, energyError(), SimpleElectron::getElClass(), SimpleElectron::getNewEnergy(), SimpleElectron::getNewEnergyError(), GBRForest::GetResponse(), SimpleElectron::getTrackerMomentum(), SimpleElectron::getTrackerMomentumError(), SimpleElectron::isEB(), SimpleElectron::isEcalDriven(), SimpleElectron::isTrackerDriven(), m_forest, SimpleElectron::setCombinedMomentum(), SimpleElectron::setCombinedMomentumError(), mathSSE::sqrt(), and CommonMethods::weight().

{
    if(!m_forest)
    {
        cout<<"ERROR: The combination tool is not initialized\n";
        return;
    }

    float energy = mySimpleElectron.getNewEnergy();
    float energyError = mySimpleElectron.getNewEnergyError();
    float momentum = mySimpleElectron.getTrackerMomentum();
    float momentumError = mySimpleElectron.getTrackerMomentumError();
    int electronClass = mySimpleElectron.getElClass();
    bool isEcalDriven = mySimpleElectron.isEcalDriven();
    bool isTrackerDriven =  mySimpleElectron.isTrackerDriven();
    bool isEB = mySimpleElectron.isEB();

    // compute relative errors and ratio of errors
    float energyRelError = energyError / energy;
    float momentumRelError = momentumError / momentum;
    float errorRatio = energyRelError / momentumRelError;

    // calculate E/p and corresponding error
    float eOverP = energy / momentum;
    float eOverPerror = sqrt(
            (energyError/momentum)*(energyError/momentum) +
            (energy*momentumError/momentum/momentum)*
            (energy*momentumError/momentum/momentum));

    // fill input variables
    float* regressionInputs = new float[11];
    regressionInputs[0]  = energy;
    regressionInputs[1]  = energyRelError;
    regressionInputs[2]  = momentum;
    regressionInputs[3]  = momentumRelError;
    regressionInputs[4]  = errorRatio;
    regressionInputs[5]  = eOverP;
    regressionInputs[6]  = eOverPerror;
    regressionInputs[7]  = static_cast<float>(isEcalDriven);
    regressionInputs[8]  = static_cast<float>(isTrackerDriven);
    regressionInputs[9]  = static_cast<float>(electronClass);
    regressionInputs[10] = static_cast<float>(isEB);
    
    // retrieve combination weight
    float weight = 0.;
    if(eOverP>0.025 
       &&fabs(momentum-energy)<15.*sqrt(momentumError*momentumError + energyError*energyError)
           ) // protection against crazy track measurement
   {
        weight = m_forest->GetResponse(regressionInputs);
        if(weight>1.) weight = 1.;
        else if(weight<0.) weight = 0.;
    }

    float combinedMomentum = weight*momentum + (1.-weight)*energy;
    float combinedMomentumError = sqrt(weight*weight*momentumError*momentumError + (1.-weight)*(1.-weight)*energyError*energyError);

    // FIXME : pure tracker electrons have track momentum error of 999.
    // If the combination try to combine such electrons then the original combined momentum is kept
    if(momentumError!=999. || weight==0.)
    {
        mySimpleElectron.setCombinedMomentum(combinedMomentum);
        mySimpleElectron.setCombinedMomentumError(combinedMomentumError);
    }

    delete[] regressionInputs;
}
bool EpCombinationTool::init ( const std::string &  regressionFile,
const std::string &  bdtName = "" 
)

Member Data Documentation

Definition at line 25 of file EpCombinationTool.h.

Referenced by combine(), and ~EpCombinationTool().