Skip to content

Commit

Permalink
Update to make MC-truth beased examples work with latest classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Grunewald committed Dec 4, 2007
1 parent 766b7ef commit 0c9d611
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 67 deletions.
63 changes: 34 additions & 29 deletions HLTrigger/HLTexample/src/HLTProdCand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"
#include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/METReco/interface/CaloMETCollection.h"
#include "DataFormats/METReco/interface/CaloMETFwd.h"
#include "DataFormats/METReco/interface/MET.h"
#include "DataFormats/METReco/interface/METFwd.h"

#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/METReco/interface/GenMET.h"
#include "DataFormats/METReco/interface/GenMETCollection.h"

#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"

#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand All @@ -54,14 +54,16 @@ HLTProdCand::HLTProdCand(const edm::ParameterSet& iConfig) :

//register your products

produces<reco::PhotonCollection>();
produces<reco::ElectronCollection>();
produces<reco::MuonCollection>();
produces<reco::RecoEcalCandidateCollection>("photons");
produces<reco::ElectronCollection>("electrons");
produces<reco::RecoChargedCandidateCollection>("muons");
produces<reco::CaloJetCollection>("taus");
produces<reco::CaloJetCollection>("jets");
produces<reco::CaloMETCollection>();
produces<reco::RecoChargedCandidateCollection>();
produces<reco::RecoEcalCandidateCollection>();
produces<reco::CaloMETCollection>("mets");
produces<reco::METCollection>("hts");

produces<reco::RecoChargedCandidateCollection>("tracks");
produces<reco::RecoEcalCandidateCollection>("clusters");

}

Expand All @@ -82,12 +84,13 @@ HLTProdCand::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
using namespace reco;

// produce collections of photons, electrons, muons, taus, jets, MET
auto_ptr<PhotonCollection> phot (new PhotonCollection);
auto_ptr<RecoEcalCandidateCollection> phot (new RecoEcalCandidateCollection);
auto_ptr<ElectronCollection> elec (new ElectronCollection);
auto_ptr<MuonCollection> muon (new MuonCollection);
auto_ptr<RecoChargedCandidateCollection> muon (new RecoChargedCandidateCollection);
auto_ptr<CaloJetCollection> taus (new CaloJetCollection); // stored as jets
auto_ptr<CaloJetCollection> jets (new CaloJetCollection);
auto_ptr<CaloMETCollection> mets (new CaloMETCollection);
auto_ptr<METCollection> hts (new METCollection);

// as well as charged tracks and elmg. superclusters
auto_ptr<RecoChargedCandidateCollection> trck (new RecoChargedCandidateCollection);
Expand Down Expand Up @@ -155,15 +158,15 @@ HLTProdCand::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
ecal->push_back(RecoEcalCandidate(-ipdg/abs(ipdg),p4));
} else if (abs(ipdg)==13) {
// mu+ mu-
muon->push_back(Muon(-ipdg/abs(ipdg),p4));
muon->push_back(RecoChargedCandidate(-ipdg/abs(ipdg),p4));
} else if (abs(ipdg)==15 || abs(ipdg)==17) {
// tau+ tau- or 4th generation tau'+ tau'-
CaloJet::Specific specific;
Jet::Constituents jetconst;
taus->push_back(CaloJet(p4,specific,jetconst));
} else if (abs(ipdg)==22) {
// photon
// phot->push_back( Photon(0,p4,math::XYZPoint(0,0,0),SuperClusterRef(), ClusterShapeRef()) );
phot->push_back(RecoEcalCandidate(0,p4));
ecal->push_back(RecoEcalCandidate(0,p4));
} else if (abs(ipdg)==12 || abs(ipdg)==14 || abs(ipdg)==16 || abs(ipdg)==18) {
// neutrinos (e mu tau 4th generation)
Expand All @@ -185,27 +188,29 @@ HLTProdCand::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
}
}

LogDebug("") << "Number of g/e/m/t/j/M/SC/TR objects reconstructed:"
LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects reconstructed:"
<< " " << phot->size()
<< " " << elec->size()
<< " " << muon->size()
<< " " << taus->size()
<< " " << jets->size()
<< " " << mets->size()
<< " " << ecal->size()
<< " " << hts->size()
<< " " << trck->size()
<< " " << ecal->size()
;

// put them into the event

iEvent.put(phot);
iEvent.put(elec);
iEvent.put(muon);
iEvent.put(phot,"photons");
iEvent.put(elec,"electrons");
iEvent.put(muon,"muons");
iEvent.put(taus,"taus");
iEvent.put(jets,"jets");
iEvent.put(mets);
iEvent.put(ecal);
iEvent.put(trck);
iEvent.put(mets,"mets");
iEvent.put(hts,"hts");
iEvent.put(trck,"tracks");
iEvent.put(ecal,"clusters");

return;
}
5 changes: 3 additions & 2 deletions HLTrigger/HLTfilters/interface/HLTFiltCand.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* HLT trigger acting on candidates, requiring a g/e/m/j tuple above
* pt cuts
*
* $Date: 2006/10/04 16:02:42 $
* $Revision: 1.16 $
* $Date: 2007/03/26 11:31:42 $
* $Revision: 1.1 $
*
* \author Martin Grunewald
*
Expand All @@ -35,6 +35,7 @@ class HLTFiltCand : public HLTFilter {
edm::InputTag tausTag_; // input tag identifying product containing taus
edm::InputTag jetsTag_; // input tag identifying product containing jets
edm::InputTag metsTag_; // input tag identifying product containing METs
edm::InputTag httsTag_; // input tag identifying product containing HTs
edm::InputTag trckTag_; // input tag identifying product containing Tracks
edm::InputTag ecalTag_; // input tag identifying product containing SuperClusters

Expand Down
74 changes: 48 additions & 26 deletions HLTrigger/HLTfilters/src/HLTFiltCand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
*
* See header file for documentation
*
* $Date: 2007/09/20 19:58:39 $
* $Revision: 1.5 $
* $Date: 2007/09/24 18:20:12 $
* $Revision: 1.6 $
*
* \author Martin Grunewald
*
Expand All @@ -13,21 +13,25 @@

#include "DataFormats/Common/interface/Handle.h"

#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"
#include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/METReco/interface/CaloMETCollection.h"
#include "DataFormats/METReco/interface/GenMET.h"
#include "DataFormats/METReco/interface/CaloMETFwd.h"
#include "DataFormats/METReco/interface/MET.h"
#include "DataFormats/METReco/interface/METFwd.h"

#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/METReco/interface/GenMET.h"
#include "DataFormats/METReco/interface/GenMETCollection.h"

#include "DataFormats/Common/interface/RefToBase.h"
#include "DataFormats/HLTReco/interface/HLTFilterObject.h"
Expand All @@ -45,6 +49,7 @@ HLTFiltCand::HLTFiltCand(const edm::ParameterSet& iConfig) :
tausTag_ (iConfig.getParameter<edm::InputTag>("tausTag")),
jetsTag_ (iConfig.getParameter<edm::InputTag>("jetsTag")),
metsTag_ (iConfig.getParameter<edm::InputTag>("metsTag")),
httsTag_ (iConfig.getParameter<edm::InputTag>("httsTag")),
trckTag_ (iConfig.getParameter<edm::InputTag>("trckTag")),
ecalTag_ (iConfig.getParameter<edm::InputTag>("ecalTag")),

Expand All @@ -57,6 +62,7 @@ HLTFiltCand::HLTFiltCand(const edm::ParameterSet& iConfig) :
<< " t: " << tausTag_.encode()
<< " j: " << jetsTag_.encode()
<< " M: " << metsTag_.encode()
<< " H: " << httsTag_.encode()
<<" TR: " << trckTag_.encode()
<<" SC: " << ecalTag_.encode()
;
Expand Down Expand Up @@ -96,12 +102,13 @@ HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)

// get hold of products from Event

Handle<PhotonCollection> photons;
Handle<RecoEcalCandidateCollection> photons;
Handle<ElectronCollection> electrons;
Handle<MuonCollection> muons;
Handle<RecoChargedCandidateCollection> muons;
Handle<CaloJetCollection> taus;
Handle<CaloJetCollection> jets;
Handle<CaloMETCollection> mets;
Handle<METCollection> htts;
Handle<RecoChargedCandidateCollection> trcks;
Handle<RecoEcalCandidateCollection> ecals;

Expand All @@ -111,21 +118,22 @@ HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
iEvent.getByLabel(tausTag_,taus );
iEvent.getByLabel(jetsTag_,jets );
iEvent.getByLabel(metsTag_,mets );
iEvent.getByLabel(httsTag_,htts );
iEvent.getByLabel(trckTag_,trcks );
iEvent.getByLabel(ecalTag_,ecals );


// look for at least one g,e,m,t,j,M,TR,SC above its pt cut
// look for at least one g,e,m,t,j,M,H,TR,SC above its pt cut

// photons
int nphot(0);
PhotonCollection::const_iterator aphot(photons->begin());
PhotonCollection::const_iterator ophot(photons->end());
PhotonCollection::const_iterator iphot;
RecoEcalCandidateCollection::const_iterator aphot(photons->begin());
RecoEcalCandidateCollection::const_iterator ophot(photons->end());
RecoEcalCandidateCollection::const_iterator iphot;
for (iphot=aphot; iphot!=ophot; iphot++) {
if (iphot->pt() >= min_Pt_) {
nphot++;
ref=RefToBase<Candidate>(PhotonRef(photons,distance(aphot,iphot)));
ref=RefToBase<Candidate>(RecoEcalCandidateRef(photons,distance(aphot,iphot)));
filterobject->putParticle(ref);
}
}
Expand All @@ -145,13 +153,13 @@ HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)

// muon
int nmuon(0);
MuonCollection::const_iterator amuon(muons->begin());
MuonCollection::const_iterator omuon(muons->end());
MuonCollection::const_iterator imuon;
RecoChargedCandidateCollection::const_iterator amuon(muons->begin());
RecoChargedCandidateCollection::const_iterator omuon(muons->end());
RecoChargedCandidateCollection::const_iterator imuon;
for (imuon=amuon; imuon!=omuon; imuon++) {
if (imuon->pt() >= min_Pt_) {
nmuon++;
ref=RefToBase<Candidate>(MuonRef(muons,distance(amuon,imuon)));
ref=RefToBase<Candidate>(RecoChargedCandidateRef(muons,distance(amuon,imuon)));
filterobject->putParticle(ref);
}
}
Expand Down Expand Up @@ -195,6 +203,19 @@ HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
}
}

// htts
int nhtts(0);
METCollection::const_iterator ahtts(htts->begin());
METCollection::const_iterator ohtts(htts->end());
METCollection::const_iterator ihtts;
for (ihtts=ahtts; ihtts!=ohtts; ihtts++) {
if (ihtts->pt() >= min_Pt_) {
nhtts++;
ref=RefToBase<Candidate>(METRef(htts,distance(ahtts,ihtts)));
filterobject->putParticle(ref);
}
}

// trcks
int ntrck(0);
RecoChargedCandidateCollection::const_iterator atrcks(trcks->begin());
Expand Down Expand Up @@ -223,20 +244,21 @@ HLTFiltCand::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)

// final filter decision:
const bool accept ( (nphot>0) && (nelec>0) && (nmuon>0) && (ntaus>0) &&
(njets>0) && (nmets>0) && (ntrck>0) && (necal>0) );
(njets>0) && (nmets>0) && (nhtts>=0) && (ntrck>0) && (necal>0) );

// All filters: put filter object into the Event
iEvent.put(filterobject);

LogDebug("") << "Number of g/e/m/t/j/M/SC/TR objects accepted:"
LogDebug("") << "Number of g/e/m/t/j/M/H/TR/SC objects accepted:"
<< " " << nphot
<< " " << nelec
<< " " << nmuon
<< " " << ntaus
<< " " << njets
<< " " << nmets
<< " " << necal
<< " " << nhtts
<< " " << ntrck
<< " " << necal
;

// return with final filter decision
Expand Down
24 changes: 14 additions & 10 deletions HLTrigger/HLTfilters/src/SealModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@
#include "HLTrigger/HLTfilters/interface/HLTHighLevel.h"
#include "HLTrigger/HLTfilters/interface/HLTDoublet.h"

#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"
#include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/METReco/interface/CaloMETFwd.h"
#include "DataFormats/METReco/interface/MET.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"

#include "DataFormats/METReco/interface/METFwd.h"

#include "HLTrigger/HLTfilters/interface/HLTSinglet.h"
#include "HLTrigger/HLTfilters/src/HLTSinglet.cc"

// template HLTSinglet<reco::Electron> ;

typedef HLTSinglet<reco::RecoEcalCandidate> HLT1Photon ;
typedef HLTSinglet<reco::Electron> HLT1Electron ;
typedef HLTSinglet<reco::Photon> HLT1Photon ;
typedef HLTSinglet<reco::Muon> HLT1Muon ;
typedef HLTSinglet<reco::RecoChargedCandidate> HLT1Muon ;
typedef HLTSinglet<reco::CaloJet> HLT1Tau ; // taus are stored as jets
typedef HLTSinglet<reco::CaloJet> HLT1CaloJet ;
typedef HLTSinglet<reco::CaloMET> HLT1CaloMET ;
Expand All @@ -38,9 +42,9 @@ typedef HLTSinglet<reco::RecoEcalCandidate> HLT1SuperCluster;

// template HLTSmartSinglet<reco::Electron> ;

typedef HLTSmartSinglet<reco::RecoEcalCandidate> HLT1SmartPhoton ;
typedef HLTSmartSinglet<reco::Electron> HLT1SmartElectron ;
typedef HLTSmartSinglet<reco::Photon> HLT1SmartPhoton ;
typedef HLTSmartSinglet<reco::Muon> HLT1SmartMuon ;
typedef HLTSmartSinglet<reco::RecoChargedCandidate> HLT1SmartMuon ;
typedef HLTSmartSinglet<reco::CaloJet> HLT1SmartTau ; // taus are stored as jets
typedef HLTSmartSinglet<reco::CaloJet> HLT1SmartCaloJet ;
typedef HLTSmartSinglet<reco::CaloMET> HLT1SmartCaloMET ;
Expand Down

0 comments on commit 0c9d611

Please sign in to comment.