CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

pat::L1MuonMatcher Class Reference

Matcher of reconstructed objects to L1 Muons. More...

Inheritance diagram for pat::L1MuonMatcher:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &iRun, const edm::EventSetup &iSetup)
 L1MuonMatcher (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual ~L1MuonMatcher ()

Private Types

typedef
pat::TriggerObjectStandAlone 
PATPrimitive
typedef
pat::TriggerObjectStandAloneCollection 
PATPrimitiveCollection
typedef
pat::TriggerObjectStandAloneMatch 
PATTriggerAssociation

Private Member Functions

template<typename Hand , typename T >
void storeExtraInfo (edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
 Store extra information in a ValueMap.

Private Attributes

edm::InputTag l1_
std::string labelL1_
 Labels to set as filter names in the output.
std::string labelProp_
L1MuonMatcherAlgo matcher_
edm::InputTag reco_
 Labels for input collections.
bool writeExtraInfo_
 Write out additional info as ValueMaps.

Detailed Description

Matcher of reconstructed objects to L1 Muons.

Author:
Giovanni Petrucciani
Version:
Id:
HLTL1MuonMatcher.cc,v 1.3 2010/07/12 20:56:11 gpetrucc Exp
Author:
Giovanni Petrucciani
Version:
Id:
L1MuonMatcher.cc,v 1.4 2011/03/31 09:59:33 gpetrucc Exp

Definition at line 34 of file L1MuonMatcher.cc.


Member Typedef Documentation

Definition at line 43 of file L1MuonMatcher.cc.

Definition at line 44 of file L1MuonMatcher.cc.

Definition at line 45 of file L1MuonMatcher.cc.


Constructor & Destructor Documentation

pat::L1MuonMatcher::L1MuonMatcher ( const edm::ParameterSet iConfig) [explicit]

Definition at line 68 of file L1MuonMatcher.cc.

References writeExtraInfo_.

                                                               :
    matcher_(iConfig),
    reco_(iConfig.getParameter<edm::InputTag>("src")),
    l1_(iConfig.getParameter<edm::InputTag>("matched")),
    labelL1_(iConfig.getParameter<std::string>(  "setL1Label")),
    labelProp_(iConfig.getParameter<std::string>("setPropLabel")),
    writeExtraInfo_(iConfig.getParameter<bool>("writeExtraInfo"))
{
    produces<PATPrimitiveCollection>("l1muons");        // l1 in PAT format
    produces<PATPrimitiveCollection>("propagatedReco"); // reco to muon station 2
    produces<PATTriggerAssociation>("propagatedReco");  // asso reco to propagated reco
    produces<PATTriggerAssociation>();                  // asso reco to l1
    if (writeExtraInfo_) {
        produces<edm::ValueMap<float> >("deltaR");
        produces<edm::ValueMap<float> >("deltaPhi");
        produces<edm::ValueMap<int>   >("quality");
        produces<edm::ValueMap<int>   >("bx");
        produces<edm::ValueMap<int>   >("isolated");
        produces<edm::ValueMap<reco::CandidatePtr> >();
        produces<edm::ValueMap<reco::CandidatePtr> >("l1ToReco");
    }
}
virtual pat::L1MuonMatcher::~L1MuonMatcher ( ) [inline, virtual]

Definition at line 37 of file L1MuonMatcher.cc.

{ }

Member Function Documentation

void pat::L1MuonMatcher::beginRun ( edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 182 of file L1MuonMatcher.cc.

                                                                      {
    matcher_.init(iSetup);
}
void pat::L1MuonMatcher::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 92 of file L1MuonMatcher.cc.

References L1MuGMTCand::bx(), reco::LeafCandidate::charge(), reco::Candidate::charge(), PV3DBase< T, PVType, FrameType >::eta(), edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), TrajectoryStateOnSurface::globalPosition(), l1extra::L1MuonParticle::gmtMuonCand(), i, edm::helper::Filler< Map >::insert(), L1MuGMTCand::isol(), TrajectoryStateOnSurface::isValid(), L1Scalers_cfi::l1s, reco::Candidate::mass(), match(), RPCpg::mu, n, PV3DBase< T, PVType, FrameType >::phi(), reco::LeafCandidate::polarP4(), pos, reco::Candidate::pt(), edm::Event::put(), L1MuGMTCand::quality(), and dt_dqm_sourceclient_common_cff::reco.

                                                                         {
    using namespace edm;
    using namespace std;

    Handle<View<reco::Candidate> > reco;
    Handle<vector<l1extra::L1MuonParticle> > l1s;

    iEvent.getByLabel(reco_, reco);
    iEvent.getByLabel(l1_, l1s);

    auto_ptr<PATPrimitiveCollection> propOut(new PATPrimitiveCollection());
    auto_ptr<PATPrimitiveCollection> l1Out(new PATPrimitiveCollection());
    std::vector<edm::Ptr<reco::Candidate> > l1rawMatches(reco->size());
    vector<int>   isSelected(l1s->size(), -1); 
    std::vector<edm::Ptr<reco::Candidate> > whichRecoMatch(l1s->size());
    vector<int>   propMatches(reco->size(), -1);
    vector<int>   fullMatches(reco->size(), -1);
    vector<float> deltaRs(reco->size(), 999), deltaPhis(reco->size(), 999);
    vector<int>   quality(reco->size(),   0), bx(reco->size(), -999), isolated(reco->size(), -999);
    for (int i = 0, n = reco->size(); i < n; ++i) {
        TrajectoryStateOnSurface propagated;
        const reco::Candidate &mu = (*reco)[i];
        int match = matcher_.match(mu, *l1s, deltaRs[i], deltaPhis[i], propagated);
        if (propagated.isValid()) {
            GlobalPoint pos = propagated.globalPosition();
            propMatches[i] = propOut->size();
            propOut->push_back(PATPrimitive(math::PtEtaPhiMLorentzVector(mu.pt(), pos.eta(), pos.phi(), mu.mass())));
            propOut->back().addFilterLabel(labelProp_);
            propOut->back().setCharge(mu.charge());
        }
        if (match != -1) {
            const l1extra::L1MuonParticle & l1 = (*l1s)[match];
            whichRecoMatch[match] = reco->ptrAt(i); 
            if (isSelected[match] == -1) { // copy to output if needed
                isSelected[match] = l1Out->size();
                l1Out->push_back(PATPrimitive(l1.polarP4()));
                l1Out->back().addFilterLabel(labelL1_);
                l1Out->back().setCharge(l1.charge());
            }
            fullMatches[i] = isSelected[match]; // index in the output collection
            const L1MuGMTCand & gmt = l1.gmtMuonCand();
            quality[i]  = gmt.quality();
            bx[i]       = gmt.bx();
            isolated[i] = gmt.isol();
            l1rawMatches[i] = edm::Ptr<reco::Candidate>(l1s, size_t(match));
        }
    }

    OrphanHandle<PATPrimitiveCollection> l1Done = iEvent.put(l1Out, "l1muons");
    OrphanHandle<PATPrimitiveCollection> propDone = iEvent.put(propOut, "propagatedReco");

    auto_ptr<PATTriggerAssociation> propAss(new PATTriggerAssociation(propDone));
    PATTriggerAssociation::Filler propFiller(*propAss);
    propFiller.insert(reco, propMatches.begin(), propMatches.end());
    propFiller.fill();
    iEvent.put(propAss, "propagatedReco");

    auto_ptr<PATTriggerAssociation> fullAss(new PATTriggerAssociation(  l1Done));
    PATTriggerAssociation::Filler fullFiller(*fullAss);
    fullFiller.insert(reco, fullMatches.begin(), fullMatches.end());
    fullFiller.fill();
    iEvent.put(fullAss);

    if (writeExtraInfo_) {
        storeExtraInfo(iEvent, reco, deltaRs,   "deltaR");
        storeExtraInfo(iEvent, reco, deltaPhis, "deltaPhi");
        storeExtraInfo(iEvent, reco, bx,        "bx");
        storeExtraInfo(iEvent, reco, isolated,  "isolated");
        storeExtraInfo(iEvent, reco, quality,   "quality");
        storeExtraInfo(iEvent, reco, l1rawMatches,   "");
        storeExtraInfo(iEvent, l1s,  whichRecoMatch, "l1ToReco");
    }
}
template<typename Hand , typename T >
void pat::L1MuonMatcher::storeExtraInfo ( edm::Event iEvent,
const Hand &  handle,
const std::vector< T > &  values,
const std::string &  label 
) const [private]

Store extra information in a ValueMap.

Definition at line 168 of file L1MuonMatcher.cc.

References edm::helper::Filler< Map >::fill(), edm::helper::Filler< Map >::insert(), and edm::Event::put().

                                                       {
    using namespace edm; using namespace std;
    auto_ptr<ValueMap<T> > valMap(new ValueMap<T>());
    typename edm::ValueMap<T>::Filler filler(*valMap);
    filler.insert(handle, values.begin(), values.end());
    filler.fill();
    iEvent.put(valMap, label);
}

Member Data Documentation

Definition at line 50 of file L1MuonMatcher.cc.

std::string pat::L1MuonMatcher::labelL1_ [private]

Labels to set as filter names in the output.

Definition at line 53 of file L1MuonMatcher.cc.

std::string pat::L1MuonMatcher::labelProp_ [private]

Definition at line 53 of file L1MuonMatcher.cc.

Definition at line 47 of file L1MuonMatcher.cc.

Labels for input collections.

Definition at line 50 of file L1MuonMatcher.cc.

Write out additional info as ValueMaps.

Definition at line 56 of file L1MuonMatcher.cc.

Referenced by L1MuonMatcher().