Previous page

PFlow at L1 trigger


This page provide useful information about implementation of the FPlow with FPGAs for CMS L1 trigger using HLS

On this page:

Usefull Links


All samples to be used for the L1 trigger studies have HGC v11 geometry, produced with rel 11.1.2. For full list of samples run dasgoclient -query="dataset=/*/Phase2HLTTDRSummer20ReRECOMiniAOD-*/*"



L1 Trigger emulation

The following code is the emulation of the L1 trigger (SWGuideL1TPhase2Instructions) for phase 2 upgrade.

export SCRAM_ARCH=slc7_amd64_gcc700
cmsrel CMSSW_10_6_1_patch2
cd CMSSW_10_6_1_patch2/src
git cms-init
git remote add cms-l1t-offline
git fetch cms-l1t-offline phase2-l1t-integration-CMSSW_10_6_1_patch2
git cms-merge-topic -u cms-l1t-offline:l1t-phase2-v2.36.4
git cms-addpkg L1Trigger/L1TCommon
scram b -j8

  • Initial setup:

cd CMSSW_10_6_1_patch2/src

Before running the code, slim the output file by requesting the following. This to be able to process the events using the of FastPUPPI code:

define era:
process = cms.Process('REPR',eras.Phase2C4_trigger)
and change the outputCommands:
            outputCommands = cms.untracked.vstring("drop *",
            # --- GEN
            "keep *_genParticles_*_*",
            "keep *_ak4GenJetsNoNu_*_*",
            # --- PF IN
            "keep *_TTTracksFromTracklet_Level1TTTracks_*",
            # HGC
            "keep *_hgcalBackEndLayer2Producer*_*_REPR",
            # muons
            "keep *_simGmtStage2Digis__*",
            # hcal (old)
            "keep *_simHcalTriggerPrimitiveDigis__*",
            # new ecal and hcal
            "keep *_L1EGammaClusterEmuProducer_*_*",
            # --- VERTEXING ---
            "keep *_VertexProducer_*_*",
            # E/gamma
            "keep *_l1EGammaEEProducer_*_*",
            "keep *_L1TkElectronsHGC_*_*",
            # --- PF OUT
            "keep l1tPFClusters_pfClustersFromHGC3DClusters_*_*",
            "keep l1tPFCandidates_l1tPFCandidates_PF_REPR",

cd ${CMSSW_BASE}/src
cmsRun L1Trigger/L1TCommon/test/

For quick validation of the inputs, one can access the PF and L1 objects:
The objects are of form of BXVector, which is a vectors for different bunch crossing (to define timing). To plot the reconstruction algorithm variable (hwQual) execute the following lines:
Events->Scan(" : L1Electron.hwQual() : L1Electron.hwQual() :")
Events->Scan(",7).pt() :,7).hwQual() ","L1Egamma.size()>6")


To ntuplize the output file, we adapt the code from FastPUPPI. To setup the code do the following:

cmsrel CMSSW_11_1_0_pre6
cd CMSSW_11_1_0_pre6/src
git cms-init
git cms-merge-topic -u cms-L1TK:L1TK-integration-CMSSW_11_1_0_pre4
git cms-merge-topic -u cms-l1t-offline:l1t-phase2-v3.0.2
git cms-addpkg L1Trigger/L1TCommon
cp ~mpitt/public/Trigger/L1TCommon/plugins/ Trigger/L1TCommon/plugins/
cp ~mpitt/public/Trigger/L1TCommon/test/ Trigger/L1TCommon/test/
scram b -j 8

then update L1Trigger/L1TCommon/plugins/BuildFile.xml with

<use name="L1Trigger/Phase2L1ParticleFlow"/>
<use name="DataFormats/L1Trigger"/>
<use name="DataFormats/Phase2L1ParticleFlow"/>

To run the ntuplizer, execute:

cmsRun ${CMSSW_BASE}/src/L1Trigger/L1TCommon/test/ inputFiles=PATH_TO_FILE

In the ntuplizer two objects are obtained: PFlow and and L1Egamma.


The PFElectron is stored as reco::Candidate. To retrieve them from the event container use:

//token= consumes<reco::CandidateView> (iConfig.getParameter<edm::InputTag>("PFElectron"));
edm::Handle<reco::CandidateView> ecals;
iEvent.getByToken(token, ecals);
for (const reco::Candidate & it : *ecals) {
            std::cout << "L1TPFCaloProducer: adding ECal input pt " << << ", eta " << it.eta() << ", phi " << it.phi() << std::endl;


The L1Electron is stored as egamma towers l1t::EGammaBxCollection. Each tower have hwQual value depending on calibrations EG ID, brem recovery etc. For the EndCup we will use hwQual=4,5 requirement before and after brem recovery. Example of class used to retrieve L1 objects can be found in L1TriggerNtupleTkElectrons.

PFlow implementation

The following code used to study the implementation of the PFlow algorithm using the FastPUPPI at the first trigger level.

export SCRAM_ARCH=slc7_amd64_gcc700
cmsrel CMSSW_10_6_1_patch2
cd CMSSW_10_6_1_patch2/src
git cms-init
git cms-checkout-topic -u p2l1pfp:L1PF_10_6_1p2_X
git clone -b 106X
scram b -j8

  • Initial setup:

cd CMSSW_10_6_1_patch2/src

  • Generation of input files (update the maxEvents before running)

cd ${CMSSW_BASE}/src/FastPUPPI/NtupleProducer/python/
The output file inputs104X.root will be generated.

  • process of the files
update in the fileNames path to link to the new file, and run:
cd ${CMSSW_BASE}/src/FastPUPPI/NtupleProducer/python/
The output file respTupleNew.root will be generated.

  • plots acceptance
cd ${CMSSW_BASE}/src/FastPUPPI/NtupleProducer/python/
python scripts/ respTupleNew_eos.root plots_dir -w l1pf -p electron --no-eta --no-fit --no-resol --xpt "mc_pt" "Gen Electron p_{T}"

The code will plot the reconstructed values of variables defined in whats depend on the -w argument. The plots will be as a function of a pT and |η| in bins defined in sels. In short it create 2D histograms of: tree->Draw("variable_pt : mc_pt","mc_eta cuts and mc_id cut").

-- MichaelPitt - 2020-01-23

Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r20 - 2020-09-16 - MichaelPitt
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback