CMS 3D CMS Logo

Classes | Public Types | Public Member Functions

PhysicsTools::MVATrainerContainerLooperImpl< Record_t > Class Template Reference

#include <MVATrainerLooperImpl.h>

Inheritance diagram for PhysicsTools::MVATrainerContainerLooperImpl< Record_t >:
PhysicsTools::MVATrainerLooper edm::ESProducerLooper edm::ESProducer edm::EventSetupRecordIntervalFinder edm::EDLooper edm::ESProxyFactoryProducer edm::EDLooperBase edm::eventsetup::DataProxyProvider

List of all members.

Classes

class  Trainer

Public Types

enum  { kTrainer, kTrained }

Public Member Functions

 MVATrainerContainerLooperImpl (const edm::ParameterSet &params)
edm::ESProducts< edm::es::L
< Calibration::MVAComputerContainer,
kTrainer >, edm::es::L
< Calibration::MVAComputerContainer,
kTrained > > 
produce (const Record_t &record)
virtual ~MVATrainerContainerLooperImpl ()

Detailed Description

template<class Record_t>
class PhysicsTools::MVATrainerContainerLooperImpl< Record_t >

Definition at line 36 of file MVATrainerLooperImpl.h.


Member Enumeration Documentation

template<class Record_t >
anonymous enum
Enumerator:
kTrainer 
kTrained 

Definition at line 38 of file MVATrainerLooperImpl.h.


Constructor & Destructor Documentation

template<class Record_t >
PhysicsTools::MVATrainerContainerLooperImpl< Record_t >::MVATrainerContainerLooperImpl ( const edm::ParameterSet params) [inline]

Definition at line 40 of file MVATrainerLooperImpl.h.

References PhysicsTools::MVATrainerLooper::addTrainer(), edm::ParameterSet::getParameter(), PhysicsTools::MVATrainerContainerLooperImpl< Record_t >::kTrained, PhysicsTools::MVATrainerContainerLooperImpl< Record_t >::kTrainer, edm::es::label(), edm::ESProducer::setWhatProduced(), and PhysicsTools::MVATrainerLooper::trainers.

                                                                     :
                MVATrainerLooper(params)
        {
                setWhatProduced(this, edm::es::label("trainer", kTrainer)
                                                    ("trained", kTrained));

                std::vector<edm::ParameterSet> trainers =
                        params.getParameter<std::vector<edm::ParameterSet> >(
                                                                "trainers");

                for(std::vector<edm::ParameterSet>::const_iterator iter =
                        trainers.begin(); iter != trainers.end(); iter++)

                        addTrainer(new Trainer(*iter));
        }
template<class Record_t >
virtual PhysicsTools::MVATrainerContainerLooperImpl< Record_t >::~MVATrainerContainerLooperImpl ( ) [inline, virtual]

Definition at line 56 of file MVATrainerLooperImpl.h.

{}

Member Function Documentation

template<class Record_t >
edm::ESProducts< edm::es::L<Calibration::MVAComputerContainer, kTrainer>, edm::es::L<Calibration::MVAComputerContainer, kTrained> > PhysicsTools::MVATrainerContainerLooperImpl< Record_t >::produce ( const Record_t &  record) [inline]

Definition at line 61 of file MVATrainerLooperImpl.h.

References begin, calib, PhysicsTools::MVATrainerLooper::TrainerContainer::end(), PhysicsTools::MVATrainer::getCalibration(), PhysicsTools::MVATrainerLooper::Trainer::getCalibration(), PhysicsTools::MVATrainerLooper::Trainer::getTrainer(), PhysicsTools::MVATrainerLooper::getTrainers(), and edm::es::products().

        {
                boost::shared_ptr<MVATrainerContainer> trainerCalib(
                                                new MVATrainerContainer());
                TrainContainer trainedCalib;

                bool untrained = false;
                for(TrainerContainer::const_iterator iter =
                                                        getTrainers().begin();
                    iter != getTrainers().end(); iter++) {
                        Trainer *trainer = dynamic_cast<Trainer*>(*iter);
                        TrainObject calib = trainer->getCalibration();

                        trainerCalib->addTrainer(trainer->calibrationRecord,
                                                 calib);
                        if (calib) {
                                untrained = true;
                                continue;
                        }

                        if (!trainedCalib)
                                trainedCalib = TrainContainer(
                                        new Calibration::MVAComputerContainer);

                        trainedCalib->add(trainer->calibrationRecord) =
                                *trainer->getTrainer()->getCalibration();
                }

                if (untrained)
                        trainedCalib = TrainContainer(
                                        new UntrainedMVAComputerContainer);

                edm::es::L<Calibration::MVAComputerContainer, kTrainer>
                                                trainedESLabel(trainerCalib);

                return edm::es::products(trainedESLabel,
                                         edm::es::l<kTrained>(trainedCalib));
        }