This page contains example workflows for producing ntuples.
Example Workflows
Simple production of a single collection
Simple production of a single collection
- Here we use the ICElectronProducer to copy the complete electron collection.
Example config:
1 import UserCode.ICHiggsTauTau.default_producers_cfi
as producers
3 process.icElectronProducer = producers.icElectronProducer.clone(
4 branch = cms.string(
"electrons"),
5 input = cms.InputTag(
"gsfElectrons")
9 process.icElectronProducer
Filter and produce a collection
Production of a filtered collection
- First we filter the input
vector<GsfElectron>
, to select only electrons with pt > 20
. For this we use a standard "RefSelector" type module which we provide with a cut-string and which produces an edm::RefVector<GsfElectron>
collection. Other examples are found in python/default_selectors_cfi.py
- An
edm::RefVector
behaves a lot like a vector of pointers, which in this case point to the electrons in the original collection.
- The ICElectronProducer will happily taken a
vector<GsfElectron>
or RefVector<GsfElectron>
as input - in fact we don't even have to specific which type - in the module code we access the collection via an edm::View<GsfElectron>,
which can read both input types.
Example config:
1 import UserCode.ICHiggsTauTau.default_producers_cfi
as producers
3 process.icElectronProducer = producers.icElectronProducer.clone(
4 branch = cms.string(
"electrons"),
5 input = cms.InputTag(
"selectedElectrons")
8 process.selectedElectrons = cms.EDFilter(
"GsfElectronRefSelector",
9 src = cms.InputTag(
"gsfElectrons"),
10 cut = cms.string(
"pt > 20")
14 process.selectedElectrons+
15 process.icElectronProducer
Produce, request and merge collections
Merging of collections and requests
- Here we store collections of
PFTau
and PFJet
objects into our ntuples. In this example they are concrete vectors of objects, but they could equally well be filtered edm::RefVector
inputs as in the previous example.
- As well as saving the tau and jet objects, we might also want to save information about the tracks that were used to build them. We could just save the entire
reco::Track
collection in the event, but this is typically very large and so wastes a lot of space if we are only interested in a handful of tracks. The solution is object requests.
- Both these modules have the option to place requests for their constituent
reco::Track
objects into the edm::Event
. In the tau case, these are the tracks associated to the charged PF candidates that are used in an identified decay mode, and in the jet case these are all the tracks associated to the charged PF candidates in the jet. A request is simply a an edm::RefVector<reco::Track>
collection, where each object points to a track in the main track collection.
- It's quite possible that some of the same tracks end up in both requests - after all each
PFTau
is built from the PFJet
collection. To remove the duplication we run a Merge
module. This is a template module that is specialised to a named producer for each kind of collection we might want to merge. It takes any number of vector<T>
or edm::RefVector<T>
collections as input (which can also be mixed) and produces an edm::RefVector<T>
collection containing all requests without duplicates.
- We can then use this merged collection as input to the ICTrackProducer, and efficiently store just the tracks we're interested in.
- Later in our analysis code we can recreate the links between these objects using the id() variable stored in each object. For example, the ic::Tau class has a method ic::Tau::constituent_tracks that returns a vector of id values. Each id value will be matched to the ic::Track::id value of an ic::Track in the track collection.
Example config:
1 import UserCode.ICHiggsTauTau.default_producers_cfi
as producers
3 process.icTauProducer = producers.icTauProducer.clone(
4 branch = cms.string(
"taus"),
5 input = cms.InputTag(
"hpsPFTauProducer")
8 process.icPFJetProducer = producers.icPFJetProducer.clone(
9 branch = cms.string(
"pfJets"),
10 input = cms.InputTag(
"ak5PFJets")
13 process.icMergedTracks = cms.EDProducer(
'ICTrackMerger',
14 merge = cms.VInputTag(
15 cms.InputTag(
"icTauProducer",
"requestedTracks"),
16 cms.InputTag(
"icPFJetProducer",
"requestedTracks")
20 process.icTrackProducer = cms.EDProducer(
'ICTrackProducer',
21 branch = cms.string(
"tracks"),
22 input = cms.InputTag(
"icMergedTracks")
26 process.icTauProducer+
27 process.icPFJetProducer+
28 process.icMergedTracks+
29 process.icTrackProducer