cms-l1t-offline / cmssw

CMS Offline Software
cms-sw.github.io/cmssw
Apache License 2.0
17 stars 27 forks source link

Offline tau reco broken in L1 ntuples (Run 3) #1089

Open lathomas opened 1 year ago

lathomas commented 1 year ago

Hello,

I believe this issue is known since a long time but was never reported here. Reco tau is broken when producing the L1 ntuples.

For example the following command (using CMSSW_13_0_0):

cmsDriver.py l1Ntuple -s RAW2DIGI --python_filename=L1ntuplizer_reemufromunpackedcaloTPs_withRECO_data.py -n 100 --no_output --era=Run3 --data --conditions=124X_dataRun3_Prompt_v10 --customise=L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW --customise=L1Trigger/L1TNtuples/customiseL1Ntuple.L1NtupleAODRAWEMU --filein=/store/data/Run2022G/Muon/RAW-RECO/ZMu-PromptReco-v1/000/362/433/00000/3228170e-0b47-456f-8739-c682b595da61.root 

leads to an error;

----- Begin Fatal Exception 31-Mar-2023 12:18:49 CEST----------------------- An exception of category 'ProductNotFound' occurred while [0] Processing Event run: 362433 lumi: 36 event: 26508279 stream: 0 [1] Running path 'l1ntupleaod' [2] Calling method for module L1TauRecoTreeProducer/'l1TauRecoTree' Exception Message: Principal::getByToken: Found zero products matching all criteria Looking for type: reco::PFTauDiscriminator Looking for module label: hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits Looking for productInstanceName:

Additional Info: [a] If you wish to continue processing events after a ProductNotFound exception, add "SkipEvent = cms.untracked.vstring('ProductNotFound')" to the "options" PSet in the configuration.

----- End Fatal Exception -------------------------------------------------

The command works if one disables tau reco by commenting out the following line:
https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1TNtuples/python/L1NtupleAOD_cff.py#L20

Not sure if it's worth fixing or if one should rather work on porting this to custom NANO though !

Thanks,

Laurent

aloeliger commented 1 year ago

Hi @lathomas ,

I took a look at this today. This error is of course a symptom of the fact that this module: hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits is not run or that it's output has changed. The name is important, because this implies though that we are looking for HPS taus, not L1 taus.

Now, a quick search through CMSSW gives this file:

https://github.com/cms-sw/cmssw/blob/master/RecoTauTag/Configuration/python/HPSPFTaus_cff.py

would seem to show the module tasks are defined. They are in CMSSW, but that is no guarantee they are in our file or that there in the way we expect.

From the command you have provided here, the resulting configuration schedule consists of roughly this:

cms.Schedule(*
   [ process.raw2digi_step, 
   process.endjob_step, 
   process.L1TReEmulPath, 
   process.l1ntupleraw, 
   process.l1ntupleemu, 
   process.l1CustomReco, 
   process.l1ntupleaod 
], 
   tasks=[process.patAlgosToolsTask])

I wrote a quick script to dump out the sequence or module components of these. The last one is where the tau reco ntuplization task occurs in the l1ntuple job:

        +--------------------------------------------------------------------------------------------------------+
        |<class 'FWCore.ParameterSet.SequenceTypes.Path'>                                                        |
        |l1EventTree+l1RecoTree+l1JetRecoTree+l1MetFilterRecoTree+l1ElectronRecoTree+l1TauRecoTree+l1MuonRecoTree|
        +--------------------------------------------------------------------------------------------------------+

Given that tau's are a higher level object reconstructed via HPS after a reco step (i.e. they are a resident of AOD, and typically not before unless we want to discuss L1 taus). So, this leads me to believe that I should be seeing some sort of tau task happening in whatever AOD customizations are given to this ntuple OR it should exist in AOD without us doing it. Looking at the path before the tau tree, l1CustomReco, I find the following:

        +--------------------------------------------------------------------------------------------------+
        |<class 'FWCore.ParameterSet.SequenceTypes.Path'>                                                  |
        |HBHENoiseFilterResultProducer+pfMetT1+egmGsfElectronIDs+BadPFMuonFilter+BadChargedCandidateFilter,|
        |ak4PFCHSL1FastjetCorrector,                                                                       |
        |ak4PFCHSL2RelativeCorrector,                                                                      |
        |ak4PFCHSL3AbsoluteCorrector,                                                                      |
        |ak4PFCHSResidualCorrector,                                                                        |
        |ak4PFCHSL1FastL2L3ResidualCorrector,                                                              |
        |ak4CaloL1FastjetCorrector,                                                                        |
        |ak4CaloL2RelativeCorrector,                                                                       |
        |ak4CaloL3AbsoluteCorrector,                                                                       |
        |ak4CaloResidualCorrector,                                                                         |
        |ak4CaloL1FastL2L3ResidualCorrector,                                                               |
        |pfJetsPtrForMetCorr,                                                                              |
        |particleFlowPtrs,                                                                                 |
        |pfCandsNotInJetsPtrForMetCorr,                                                                    |
        |pfCandsNotInJetsForMetCorr,                                                                       |
        |pfCandMETcorr,                                                                                    |
        |ak4PFCHSL1FastjetCorrector,                                                                       |
        |ak4PFCHSL2RelativeCorrector,                                                                      |
        |ak4PFCHSL3AbsoluteCorrector,                                                                      |
        |ak4PFCHSResidualCorrector,                                                                        |
        |ak4PFCHSL1FastL2L3ResidualCorrector,                                                              |
        |ak4PFCHSL1FastjetCorrector,                                                                       |
        |ak4PFCHSL2RelativeCorrector,                                                                      |
        |ak4PFCHSL3AbsoluteCorrector,                                                                      |
        |ak4PFCHSL1FastL2L3Corrector,                                                                      |
        |corrPfMetType1,                                                                                   |
        |corrPfMetType2                                                                                    |
        +--------------------------------------------------------------------------------------------------+

This is largely just ak4 jet tasks, met correction tasks, some filters, and whatever particleFlowPtrs is (as best I can tell, it doesn't or shouldn't run the tau process). So we do not have any tau tasks run by this. We need to be able to find the thing we want in AOD then.

dumping out the contents of the AOD file, I find this:

edm::ValueMap<reco::SingleTauDiscriminatorContainer>    "hpsPFTauBasicDiscriminators"   ""                "RECO"    
edm::ValueMap<reco::SingleTauDiscriminatorContainer>    "hpsPFTauBasicDiscriminatorsdR03"   ""                "RECO"    
edm::ValueMap<reco::SingleTauDiscriminatorContainer>    "hpsPFTauDiscriminationByMuonRejection3"   ""                "RECO"    
reco::PFTauDiscriminator              "hpsPFTauDiscriminationByDeadECALElectronRejection"   ""                "RECO"    
reco::PFTauDiscriminator              "hpsPFTauDiscriminationByDecayModeFinding"   ""                "RECO"    
reco::PFTauDiscriminator              "hpsPFTauDiscriminationByDecayModeFindingNewDMs"   ""                "RECO"    
reco::PFTauDiscriminator              "hpsPFTauDiscriminationByDecayModeFindingOldDMs"   ""                "RECO"    
vector<reco::PFTau>                   "hpsPFTauProducer"          ""                "RECO"    

Now this is interesting because hpsPFTauBasicDiscriminators is the module or class of modules that was associated with similar looking discriminants to the ones we had before, but it is not the module name we expect, nor is it the format we would expect.

So the issue is, these contents:

https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1TNtuples/python/l1TauRecoTree_cfi.py#L9-L16

are not in the AOD file, presumably because the module and method by which they are entered into the event have changed

This can be fixed by adjusting the L1 ntuples to use the new version of the stored discriminants.

aloeliger commented 1 year ago

This basic structure for reco taus seems to have existed for at least three years